Writing/Reading data with base address + offset

Posts 15 of 5 · Page 1 of 1
Writing/Reading data with base address + offset
Hello, today I was trying to start with game hacking when I came across a problem which I am now trying to solve for hours. I was trying to change my health in a game.
I'm trying to read and write data like this:

First I tried to get the base address with pointerscans:


Code:
int BASE = (int)Process.GetProcessesByName("GAME_NAME")[0].MainModule.BaseAddress;
int BASEOFFSET = 0x000B39F0;
int OFFSET1 = 0x8; <--------- health offset
int OFFSET2 = 0x268;
and then
Code:
ReadInteger(BASE + BASEOFFSET + OFFSET1 + OFFSET2);
It seems that I'm reading the wrong address, but I don't know what I have to do to fix this.
Can anyone help me with this problem?
what u need to do to do the same as cheat engine in the screenshot would be
ReadInteger(ReadAddress(ReadAddress(BASE + BASEOFFSET) + OFFSET1) + OFFSET2)
Quote Originally Posted by MikeRohsoft View Post
what u need to do to do the same as cheat engine in the screenshot would be
ReadInteger(ReadAddress(ReadAddress(BASE + BASEOFFSET) + OFFSET1) + OFFSET2)
Thanks, that worked! How would I handle writing to that address? Setting the address as that line of code didn't work
you does the same as u do for read
Code:
    public int ReadInt(Int64 Address)
    {
        byte[] buffer = new byte[4]; // reserve a buffer with the length of primitive Int
        ReadProcessMemory(pHandle, (IntPtr)Address, buffer, buffer.Length, IntPtr.Zero); // fill the buffer
        return BitConverter.ToInt32(buffer, 0); // convert the buffer to an Integer Object
    }
Code:
    public void Write(Int64 Address, int Value)
    {
        byte[] buffer = BitConverter.GetBytes(Value); // convert the Integer Object to bytes
        WriteProcessMemory(pHandle, (IntPtr)Address, buffer, buffer.Length, IntPtr.Zero); // write the bytes to the process
    }
Posts 15 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?