开发者

.Net C# ReadProcessMemory Pointer function returns address backwards

开发者 https://www.devze.com 2023-03-31 10:51 出处:网络
I\'m new to posting on these forums but have come here multiple times for my programming help needs and have usually been able to find my answers fairly easily but I fear I might be either asking the

I'm new to posting on these forums but have come here multiple times for my programming help needs and have usually been able to find my answers fairly easily but I fear I might be either asking the wrong kind of questions or maybe it's very obvious and I just don't see it but here is my problem.

I am making my first trainer for Quake, I thought I would start small with a game that is easy to find pointers for instead of my other games which usually have 2+ level pointers. So I go through Quake with Cheat Engine and grab all the pointers I need, Make my gui etc but there is a problem. I read my first pointer and it returns the address I need backwards :/

Example:

Here is my pointer that i'm reading from - 006C5214

when read it gives me this address - 02BFD940

I then add my offset 48C to my address above which directs me to 02BFDDCC which contains the value I need.

when I read my pointer with ReadProcessMemory I get the correct address except it's backwards (endian?)

I need 02BFD940 I get 开发者_如何转开发40D9BF02

I've tried everything I can think of to flip around the order and get it back into an IntPtr for use in my ReadProcessMemory/WriteProcessMemory. I am able to flip it around in the order I want because my ReadProcessMemory gives my address like 40-D9-BF-02 which is easily cut into an array with Split('-');

Only problem is that after i'm done splitting and reordering it the way I want there is no way I can manage to convert it back into an IntPtr for use with my reading and writing memory functions.

I've always done my memory editing things with cheat engine or a disassembler. This is my first attempt at a fully working trainer any help with my problem would be much appreciated. I've tried setting the endian boolean on my BitConverter but it's read only :/

If i'm completely missing something and it's right there infront of me feel free to call me out on it and give me a slap upside the head xD I don't mind.

-P.S. your guys' forum is awesome.


try

    byte[] buffer = new byte[4];
    int bytesread;

    ReadProcessMemory(hProcess, dwAddress, buffer, 4, out bytesread);

    IntPtr P = new IntPtr (BitConverter.ToInt32(buffer, 0));
0

精彩评论

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

关注公众号