开发者

Getting ptr from memory address with c++

开发者 https://www.devze.com 2022-12-21 02:43 出处:网络
Im trying to get the engine version of a game from a global pointer, but I am fairly new to this. Here is a very small example I found...

Im trying to get the engine version of a game from a global pointer, but I am fairly new to this. Here is a very small example I found...

http://ampaste.net/mb42243

And this is the disassembly for what I am trying to get, the pointer (gpszVersionString) is the highlighted line (line 5)开发者_JAVA技巧

http://ampaste.net/m2a8f8887

So what I need to find out is basically using the example approach I found to get it, would I need to basically sig out the first part of the function and find the offset to that line?

Like...

Memory signature - /x56/x8B/x35/x74/xD5/x29/x10/x68/x00/xA8/x38/x10 Then an offset to reach that line? (not sure how to find the offset)


You can't directly do this. Process address space is completely unique to your process -- 0xDEADBEEF can point to "Dog" in one process, while 0xDEADBEEF can point to "Cat" in another. You would have to make operating system calls that allow you to access another process' address space, and even then you'd have to guess. Many times that location will be different each run of the application -- you can't generally predict what the runtime layout of a process will be in all cases.

Assuming you're on Windows you'll need to (EDIT: You don't need A and B in all cases but you usually need them) A. be an administrator, B. take the SeDebugPrivilege for your process, C, open a handle to the process, and then D. use ReadProcessMemory/WriteProcessMemory to do what you want.

Hope that helps :)

EDIT 2: It looks like you're looking at an address taken from a disassembler. If that's the case, then you can't use that value of the address -- the image can be re-based at runtime and the value there would be completely different. Particularly on recent versions of Windows which support Address Space Layout Randomization.

0

精彩评论

暂无评论...
验证码 换一张
取 消