C#C
C#4y ago
Matt

get the address from pointer offsets.

Trying to make a function to grab an address from pointer offsets. New to pointers and tried to follow a tutorial using Pymem but write it in c# which I'm far more comfortable with. Hasn't gone so well. The function returns 0 from a correct input. Would really appreciate the help if someone knows what I'm doing wrong

        public int GetPointerAddress(int baseAddress, int[] offsets)
        {
            int bytesRead = 0;
            byte[] newAddrBytes = new byte[4];
            Program.ReadProcessMemory((int)tyexeHandle, baseAddress, newAddrBytes, 4, ref bytesRead);
            int addr = BitConverter.ToInt32(newAddrBytes, 0);
            foreach(int i in offsets)
            {
                if (i != offsets[offsets.Length - 1])
                {
                    bytesRead = 0;
                    byte[] newAddr = new byte[4];
                    Program.ReadProcessMemory((int)tyexeHandle, baseAddress + 1, newAddr, 4, ref bytesRead);
                    addr = BitConverter.ToInt32(newAddrBytes, 0);
                }
            }
            return addr + offsets[offsets.Length - 1];
        }
Was this page helpful?