ReadProcessMemory() problem
-
Hello, i wanted to get an idea of some basic memory editing so i thought writing a simple trainer for my favorite game would be a good idea. So i found out how to get the pointer, now when i use cheat engine it gives the correct value if i add the baseaddress + offset. But if i try that in my program it wont work for some reason.
int offset = 0x804; int address = 0x818794; int totalhp = offset + address; int value; ReadProcessMemory(hProcess, (LPCVOID)totalhp, &value, sizeof(value), NULL ); std::cout << value << std::endl;
value always returns zero for god knows what reason. Any idea what iam doing wrong?
-
Hello, i wanted to get an idea of some basic memory editing so i thought writing a simple trainer for my favorite game would be a good idea. So i found out how to get the pointer, now when i use cheat engine it gives the correct value if i add the baseaddress + offset. But if i try that in my program it wont work for some reason.
int offset = 0x804; int address = 0x818794; int totalhp = offset + address; int value; ReadProcessMemory(hProcess, (LPCVOID)totalhp, &value, sizeof(value), NULL ); std::cout << value << std::endl;
value always returns zero for god knows what reason. Any idea what iam doing wrong?
How are you initializing
hProcess
? -
How are you initializing
hProcess
?The problem is not the handle, the problem is the wrong value i get.
HWND hWnd = FindWindow(0, "AOEII"); if(hWnd == 0) { std::cout << "Cant find handle." << std::endl; \_getch(); } else { DWORD proccess\_ID; GetWindowThreadProcessId(hWnd, &proccess\_ID); HANDLE hProcess = OpenProcess(PROCESS\_ALL\_ACCESS, FALSE, proccess\_ID); if(!hProcess) { std::cout << "Cant open process." << std::endl; \_getch(); } else { Readprocessstuff...
-
The problem is not the handle, the problem is the wrong value i get.
HWND hWnd = FindWindow(0, "AOEII"); if(hWnd == 0) { std::cout << "Cant find handle." << std::endl; \_getch(); } else { DWORD proccess\_ID; GetWindowThreadProcessId(hWnd, &proccess\_ID); HANDLE hProcess = OpenProcess(PROCESS\_ALL\_ACCESS, FALSE, proccess\_ID); if(!hProcess) { std::cout << "Cant open process." << std::endl; \_getch(); } else { Readprocessstuff...
Well found the solution, not exactly sure why i have to do it this way but iam reading about it right now, just thought id post the solution before i forget about it.
int offset = 0x804; int baseaddress; int value; ReadProcessMemory(hProcess, (LPCVOID)0x00818794, (LPVOID)&baseaddress, sizeof(value), NULL ); ReadProcessMemory(hProcess, (LPCVOID)(baseaddress+offset), &value, sizeof(value), NULL );
Thanks for trying to help :)