There is a program that stores a value in memory, like 100. I read that value using ReadProcessMemory():
ReadProcessMemory(processHandle, (LPVOID)(programBaseAddress + offsetProgramToBaseAdress), &baseAddress, sizeof(baseAddress), NULL);
After ReadProcessMemory(), baseaddress contains 100.
With this code:
int value{};
cin >> value;
WriteProcessMemory(processHandle, (LPVOID)(pointsAddress), &value, 4, 0);
I can change the value in the other program.
But I don't want to set the other program's value to just any value. I want to add the user's input to that value. I mean, the user inputs a number like 50, the result should be 150, not 50.
I tried this but it didn't work:
WriteProcessMemory(processHandle, (LPVOID)(pointsAddress), &baseAddress + value, 4, 0);