Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C#] Reading/Writing multi level pointer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> Pointer tutorials
View previous topic :: View next topic  
Author Message
Darkwizzard70
How do I cheat?
Reputation: 0

Joined: 18 Oct 2007
Posts: 2

PostPosted: Mon Feb 17, 2014 6:52 pm    Post subject: [C#] Reading/Writing multi level pointer Reply with quote

So I've really tried my best, googled a lot and I've tried around 3-5 classes that were made by others to write/read pointers etc but I managed to do it wrong every time I guess.

So here is the base address and the offsets (IMAGE OF CE):
https://www(dot)dropbox(dot)com/s/rk39htan940694d/Height%20Pointer-Offsets.png

The C# code:
Code:
Process[] pname = Process.GetProcessesByName("GameName");
            IntPtr pHandle = pname[0].Handle; //Get the process handle
            IntPtr bytesRead;
            string hexValue;
            byte[] buffer = new byte[4];

            int BaseAddress = 0x01D93424;
            hexValue = BaseAddress.ToString("X");

            int address;

            ReadProcessMemory(pHandle, (IntPtr)BaseAddress, buffer, 4, out bytesRead);
            address = BitConverter.ToInt32(buffer, 0);
            hexValue = address.ToString("X"); //Hexvalue is not necessarily but its easier for me to read the address (Comparing it with CE)

            ReadProcessMemory(pHandle, (IntPtr)BaseAddress + 0x58, buffer, 4, out bytesRead);
            address = BitConverter.ToInt32(buffer, 0);
            hexValue = address.ToString("X"); //01D934B4

            ReadProcessMemory(pHandle, (IntPtr)address + 0x424, buffer, 4, out bytesRead);
            address = BitConverter.ToInt32(buffer, 0);
            hexValue = address.ToString("X"); //01D938FC

            ReadProcessMemory(pHandle, (IntPtr)address + 0x1C, buffer, 4, out bytesRead);
            address = BitConverter.ToInt32(buffer, 0);
            hexValue = address.ToString("X"); //01D938E0

            ReadProcessMemory(pHandle, (IntPtr)address + 0xEC, buffer, 4, out bytesRead);
            address = BitConverter.ToInt32(buffer, 0);
            hexValue = address.ToString("X"); //01D93A04

            ReadProcessMemory(pHandle, (IntPtr)address + 0x2F0, buffer, 4, out bytesRead);
            address = BitConverter.ToInt32(buffer, 0);
            hexValue = address.ToString("X"); //01D93D14

            ReadProcessMemory(pHandle, (IntPtr)address + 0x64, buffer, 4, out bytesRead);
            address = BitConverter.ToInt32(buffer, 0);
            hexValue = address.ToString("X"); //45FB9000


            //All went well until the code below has been executed (I've checked the addresses from each result from the codes above)
            //They are all correct (Compared it with CheatEngine results)

            //It goes wrong here somehow, the address is currently 45FB9000, adding that with the offset 5C should change it to 45FB905C according to Cheat Engine (Look at my image)
            //However.. I get a totally different address when I debug my code. Cheat Engine itself clearly shows me that 45FB9000 + 5C = 45FB905C
            //Everything else from the addresses here above goes good though..
            ReadProcessMemory(pHandle, (IntPtr)address + 0x5C, buffer, 4, out bytesRead);
            address = BitConverter.ToInt32(buffer, 0);
            hexValue = address.ToString("X"); //Should be 45FB905C but it was different


So yeah read the comments that I wrote there in the code.
It all goes well until it tries to get the latest address. I'm sure that I did something wrong but can anyone tell me what I did wrong?

I've worked with C# for few years but I just started memory hacking few days ago.
Oh and I've restarted the game several times but the multi level pointer still works so I guess that my pointer is right, right..? With "still works" I mean that I can see & adjust the value with Cheat Engine. It somehow just goes wrong somewhere when I try this in C#.

_________________
Thank me + rep me if i help ya Very Happy
Back to top
View user's profile Send private message
Hatschi
Master Cheater
Reputation: 2

Joined: 28 Jan 2010
Posts: 318

PostPosted: Tue Feb 18, 2014 4:57 am    Post subject: Reply with quote

This code isn't well written. Declare an array of byte with your pointer offsets and make a loop, check if you're at the last entry of the array if so, don't read instead just add the offset the current address. That's all.
Back to top
View user's profile Send private message
Darkwizzard70
How do I cheat?
Reputation: 0

Joined: 18 Oct 2007
Posts: 2

PostPosted: Wed Feb 19, 2014 1:04 pm    Post subject: Reply with quote

Thanks, will try it out tonight. If I get it to work, I'll post the solution here.
_________________
Thank me + rep me if i help ya Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> Pointer tutorials All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites