windows api ReadProcessMemorry() fail when I reuse this

22 views Asked by At
LPVOID pTargetNew = new LPVOID();
::ReadProcessMemory(hprocess,pBase,pTargetNew,4,&byred);
pBase = (LPVOID)((*pTargetNew) + 800);
::ReadProcessMemory(hprocess,pBase,pTargetNew,4,&byred);
pBase = (LPVOID)((*pTargetNew) + 24);

This is my code of the problem. After I calculate the pointer at the third line and start to invoke ReadProcessMemory, then I get byred=0. Why does the call fail?

I tried to change the code in c way.

int target = 0;`
LPVOID pTarget = (LPVOID)⌖
pBase = (LPVOID)(target + 800);
::ReadProcessMemory(hprocess, pBase, pTarget, 4, &byred);
pBase = (LPVOID)(target + 24);
::ReadProcessMemory(hprocess, pBase, pTarget, 4, &byred);

Then the code could run.

0

There are 0 answers