winapi - C++ ReadProcessMemory is Inconsistant -
i've used cheat engine retrieve base address value want change in memory in c++ program.
the address is:
base address: "threadstack0"-0000032c // threadstack0 exe file believe offset 1: 0x12e0 offset 2: 0x130 offset 3: 0xf00 offset 4: 0x500 offset 5: 0x298
i have following c++ code calculate base address:
uint_ptr modulehandle = (uint_ptr)getmodulehandle(null); uint_ptr addr = modulehandle - 0x32c; addr += 0x12e0; addr += 0x130; addr += 0xf00; addr += 0x500; addr += 0x298; if (!readprocessmemory(hprocess, (lpvoid)addr, &powerup, sizeof(powerup), null)) { cout << "failed read process memory" << endl; } else { cout << "read process memory successfully" << endl; }
i run it, , 1 out of 10 times, have success. rest of time readprocessmemory
fails.
why readprocessmemory
inconsistant it's success? nothing on computer, keep running program , works, doesn't.
i pretty sure it's not fault of readprocessmemory
, rather getmodulehandle(null)
culprit. i'm not sure on how getmodulehandle
works exactly, i'm guessing times works, when uses process memory address accessed last? , program runs findwindowa
why works. , when doesn't work, that's because process's memory address accessed/changed between program calling findwindowa
, getmodulehandle
.
something along lines?
is there solution make program consistant in getmodulehandle(null)
, readprocessmemory
?
Comments
Post a Comment