|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
anhtraitan !BEWARE! Deletes post on answer Reputation: 0
Joined: 20 Jul 2017 Posts: 5
|
Posted: Thu Jul 20, 2017 5:42 pm Post subject: Write Process memory Visual C ++ Need Help |
|
|
Hi everybody!
This code is used to change the value of 0x22E5EC
But the problem here is that the anticheat of the game has done something with ProcessID
So HANDLE handle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, ProcessID) does not work.
But when I input ProcessID (hex) manually with the cheat engine, everything works.
I think using ProcessID = not working
PID (hex) = working
Someone please give me advice.
Code: | #include <iostream>
#include <Windows.h>
#include <string>
#include <TlHelp32.h>
#include <stdio.h>
using namespace std;
int newValue = 1000;
DWORD ProcessID;
int main()
{
SetConsoleTitle("trainer");
HWND hwnd = FindWindowA(0, ("GAME"));
GetWindowThreadProcessId(hwnd, &ProcessID);
if (hwnd)
{
cout << hex << ProcessID << endl; // show Hex PID
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessID); // I want ProcessID is the hex PID, pls help !!!!!!
while (newValue)
{
WriteProcessMemory(handle, (LPVOID)0x22E5EC, &newValue, sizeof(newValue), NULL);
}
}
else
{
cout << "Game Not Open!" << endl;
}
system("pause");
} |
Description: |
|
Filesize: |
140.14 KB |
Viewed: |
3378 Time(s) |
|
|
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1587
|
Posted: Thu Jul 20, 2017 7:32 pm Post subject: |
|
|
anhtraitan wrote: |
Hi everybody!
This code is used to change the value of 0x22E5EC
But the problem here is that the anticheat of the game has done something with ProcessID
So HANDLE handle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, ProcessID) does not work.
But when I input ProcessID (hex) manually with the cheat engine, everything works.
I think using ProcessID = not working
PID (hex) = working
Someone please give me advice.
<snip>
|
Code: | #include <iostream>
#include <Windows.h>
#include <string>
#include <ctime>
DWORD FindDMAaddress(int PointerLevel, HANDLE hProcHandle, DWORD offsets[], DWORD BaseAddress);
void WriteToMemory(HANDLE hProcHandle);
std::string GameName = "";
LPCSTR LGameWindow = ""; // type your game window name "here"
std::string GameStatus;
bool IsGameAvail;
bool UpdateOnNextRun;
// Ammo Var
bool AmmoStatus;
BYTE AmmoValue[] = { 0x00, 0x00, 0x00, 0x00 }; // hex value reversed
DWORD AmmoBaseAddress = {0x00000000}; // ammo base address
DWORD AmmoOffsets[] = {0x00}; // ammo offsets
// Health Var
bool HealthStatus;
BYTE HealthValue[] = { 0x00, 0x00, 0x00, 0x00 }; // hex value reversed
DWORD HealthBaseAddress = {0x00000000}; // health base address
DWORD HealthOffsets[] = {0x00}; // health offsets
int main()
{
HWND hGameWindow = NULL;
int TimeSinceLastUpdate = clock();
int GameAvailTimer = clock();
int OnePressTimer = clock();
DWORD dwProcID = NULL;
HANDLE hProcHandle = NULL;
UpdateOnNextRun = true;
std::string sAmmoStatus = "OFF";
std::string sHealthStatus = "OFF";
while (!GetAsyncKeyState(VK_INSERT))
{
if ( clock() - GameAvailTimer > 100)
{
GameAvailTimer = clock();
IsGameAvail = false;
hGameWindow = FindWindow(NULL, LGameWindow);
if (hGameWindow)
{
GetWindowThreadProcessId(hGameWindow, &dwProcID);
if (dwProcID != 0)
{
hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcID);
if (hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
{
GameStatus = "Failed To Open Process Handle";
}
else
{
GameStatus = "ready To Hack";
IsGameAvail = true;
}
}
else
{
GameStatus = "Failed To Get Process ID";
}
}
else
{
GameStatus = "NOT FOUND";
}
if (UpdateOnNextRun || clock() - TimeSinceLastUpdate > 5000)
{
system("cls");
std::cout << "=========================" << std::endl;
std::cout << " Memory Hacker" << std::endl;
std::cout << "=========================" << std::endl << std::endl;
std::cout << "GAME STATUS: " << GameStatus << std::endl << std::endl;
std::cout << "[F1] Ammo -> " << sAmmoStatus << " <-" << std::endl << std::endl;
std::cout << "[F2] Health -> " << sHealthStatus << " <-" << std::endl << std::endl;
std::cout << "[INSERT] Exit" << std::endl;
UpdateOnNextRun = false;
TimeSinceLastUpdate = clock();
}
if (IsGameAvail)
{
// write to game memory
WriteToMemory(hProcHandle);
}
}
if (clock() - OnePressTimer > 500 )
{
if (IsGameAvail)
{
if (GetAsyncKeyState(VK_F1))
{
OnePressTimer = clock();
AmmoStatus = !AmmoStatus;
UpdateOnNextRun = true;
if (AmmoStatus) sAmmoStatus = "ON";
else sAmmoStatus = "OFF";
}
else if (GetAsyncKeyState(VK_F2))
{
OnePressTimer = clock();
HealthStatus = !HealthStatus;
UpdateOnNextRun = true;
if (HealthStatus) sHealthStatus = "ON";
else sHealthStatus = "OFF";
}
}
}
}
/*CloseHandle(hProcHandle); you dont need it
CloseHandle(hGameWindow);*/ //you dont need it
return ERROR_SUCCESS;
//return 0; // you dont need it
}
DWORD FindDMAaddress(int PointerLevel, HANDLE hProcHandle, DWORD offsets[], DWORD BaseAddress)
{
DWORD pointer = BaseAddress;
DWORD pTemp;
DWORD pointerAddress;
for (int c = 0; c < PointerLevel; c++)
{
if (c == 0)
{
ReadProcessMemory(hProcHandle, (LPCVOID)pointer, &pTemp, sizeof(pTemp), NULL);
pointerAddress = pTemp + offsets[c];
ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddress, &pTemp, sizeof(pTemp), NULL);
}
return pointerAddress;
}
}
void WriteToMemory(HANDLE hProcHandle)
{
DWORD AddressToWrite;
if (AmmoStatus)
{
AddressToWrite = FindDMAaddress(1, hProcHandle, AmmoOffsets, AmmoBaseAddress); //first '1' parameter pointer level (aka offset level)
WriteProcessMemory(hProcHandle, (BYTE*)AddressToWrite, &AmmoValue, sizeof(AmmoValue), NULL);
}
if (HealthStatus)
{
AddressToWrite = FindDMAaddress(1, hProcHandle, HealthOffsets, HealthBaseAddress); //first '1' parameter pointer level (aka offset level)
WriteProcessMemory(hProcHandle, (BYTE*)AddressToWrite, &HealthValue, sizeof(HealthValue), NULL);
}
} |
_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote: | i am a sweetheart. |
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|