First of all, what I am trying to do is changing a value in the memory of a game. In order to write to that variable I need to add the following pointer and offsets because then I always get to an address that works:
baseAddr + offset1 + offset2 + offset3 = myDesiredAddr
Now, this is what I have tried to do...
ReadProcessMemory(
hProc, (LPVOID)(BaseAddr + offset1), &myDesiredAddr, sizeof(myDesiredAddr), 0
);
ReadProcessMemory(
hProc, (LPVOID)(myDesiredAddr + offset2), &myDesiredAddr, sizeof(myDesiredAddr), 0
);
ReadProcessMemory(
hProc, (LPVOID)(myDesiredAddr + offset3), &myDesiredAddr, sizeof(myDesiredAddr), 0
);
I've tired to WriteProcessMemory on the final address that I got but it does not read and write successfully. Any advice will be helpful.
You could do something like this:
The above shows your declarations. I presume you check if the read and write functions return successfully, otherwise I would suggest you do so.
By adding the memory addresses and offsets and storing the value in Pointer, you can continue to read from Pointer and store the temporary addresses in a temp variable until you get to the final address that you want.
I suggest you do this in a loop for efficiency and neater code.