Jump to content

[Help][C#.Net]Memory Reading/Writing with pointer + offsets

- - - - -

  • Please log in to reply
No replies to this topic

#1
Tsproggy

Tsproggy

    Newbie

  • Members
  • Pip
  • 1 posts
Hello,

I've always usually done my memory editing with an editor such as T-search or Cheat Engine. I'm really good at using both i've even done other things related to memory editing such as hex editing etc. Anyway I decided today that I wanted to try my hand at programming a trainer because i've actually never done it before. I'm a pretty good programmer considering it's all I really do as it is my hobby but i've come across a problem or two that i'm completely stuck on. I'm hoping the community will help me on this as i'm completely stumped and frustrated.

So, I wanted to start small and decided to make a trainer for Quake since it is an older game I figured the pointers/addresses would be easier to get and I was right. I have found that all the info I need uses 1 pointer and 8 offsets.

[Found in Cheat Engine]

006C5214 - Pointer

Offsets I want to use (in hex):
  • 48C - Health
  • 514 - Armor
  • 4A0 - Shells 1
  • 4A4 - Shells 2
  • 4A8 - Nails
  • 4AC - Grenades/Rockets
  • 4B0 - Charges
  • 494 - Current Weapon

All use the same pointer above (ex:006C5214 + 48C), I have the GUI and base code of my program ready for the most part with the exception of code that would write anything into memory as I cannot seem to get this problem solved. My problem is that I believe i'm not using my ReadProcessMemory function right.. Atleast the Address part of it.


        private void CharInfoUpdate()

        {

            if (bFound)// Boolean set to true or false if my process is found.

            {

                IntPtr MyAddress = IntPtr.Add(bAddr, 1196);//bAddr = 0x6C5214, 1196 = 48C(Health) converted to DEC from HEX.

                ReadProcessMemory(hProc, MyAddress, bBuff, 1, out bytesRW);

                textBox1.Text = BitConverter.ToInt32(bBuff, 0).ToString();//These 2 lines are just some debug stuff to display anything I actually manage to read :(

                textBox1.AppendText(bytesRW.ToString());

            }

        }


That is the code for the moment though I have changed it many times.. I've tried using the base address added to the offset (6C56A0) and then I found that IntPtr has an Add function that accepts an address and an offset so I thought that would work but it wants the offset as an integer.. So I changed my offset to decimal and it still reads 0. This is supposed to be my health value.. I was expecting it to read either 64(Hex) or 100(Dec). But nope.. ALWAYS reads 0 no matter what I do, I know that the function itself can work because if I tell it to just read the pointer without an offset added to it, it reads a bunch of numbers that don't pertain to what I want.

I'm completely new to programming using memory functions.. any help would be nice. I can't seem to find anything on the internet..Believe me i've searched so much and retried all the things I could think of to the point of deleting it >.<. If you need any more info just ask.

EDIT: Nevermind, I figured it out myself (as i'm trying to fall asleep >.<) I just completely forgot what pointers are.. they point to an address in memory, so I look at it a different way and notice that it's giving me the base address I need :) except it's backwards now lol (endian order) So now all I have to do is figure out a way to switch it around into the right order, then i'll tell it to read from that and that should give me my value of health or whatever I want :)

Edited by Tsproggy, 23 August 2011 - 02:44 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users