Help with writeProcessMemory/openProcess
I am trying to transition from just using cheat engine for my hacks to also using c++, but I am having difficulty learning the writeProcessMemory command. I have read through the MSDN documentation on writeProcessMemory and openProcess but I can't seem to figure out what I am doing wrong.
Can't get it to work on the cheat engine tutorial even (step 2).
Seems when I run the code (without debugging) in visual studio, the HP address goes unchanged, even when I update it by hitting "Hit me"
Code:
#include <iostream>
#include <Windows.h>
using namespace std;
int main() {
int number = 50;
HWND hwnd = FindWindowA(NULL, "Step 2"); //"Step 2" is the window title
DWORD procID;
GetWindowThreadProcessId(hwnd, &procID);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
WriteProcessMemory(handle, (LPVOID)0x3860710, &number, sizeof(number), NULL); //the second argument is the address of the hp value
}