Hello epvps,
I'm writing a class for memory editing, but I'm stuck with multi lvl pointers.
What I have so far :
And I want to use like that (outside the class) :
Any help would be appreciated
I'm writing a class for memory editing, but I'm stuck with multi lvl pointers.
What I have so far :
Code:
//API Declaration :
[DllImport("kernel32.dll")]
static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAdress, byte[] lpBuffer, uint iSize,out uint lpNumberOfBytesRead);
[DllImport("kernel32.dll")] // Overload for ptr
static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAdress, out IntPtr lpBuffer, uint iSize, out uint lpNumberOfBytesRead);
//........
public int Readlvl1Pointer(IntPtr adress)
{
uint bytesRead;
byte[] _Value = new byte[4];
ReadProcessMemory(_targetProcessHandle, adress, _Value, (uint)IntPtr.Size, out bytesRead);
int ptrVal = BitConverter.ToInt32(_Value, 0);
IntPtr ptr = (IntPtr)ptrVal;
ReadProcessMemory(_targetProcessHandle, adress, _Value, (uint)IntPtr.Size, out bytesRead);
return BitConverter.ToInt32(_Value, 0); // This function is working fine
}
private IntPtr ReadPointer(IntPtr adress)
{
IntPtr tempPTR;
uint NumberOfBytesRead;
ReadProcessMemory(_targetProcessHandle, adress, out tempPTR, (uint)IntPtr.Size, out NumberOfBytesRead);
return tempPTR;
}
public IntPtr FollowPointer(IntPtr adress, ulong[] Offsets) // To get the final adress
{
IntPtr ptr = ReadPointer(adress);
for (int i = 0; i < Offsets.Length; i++)
{
ptr = ReadPointer(new IntPtr(ptr + Offsets[i])); // error here, can't add IntPtr to IntPtr
}
return ptr;
}
Code:
IntPtr finalAdress = m.FollowPointer((IntPtr)0x0631390, {0xC,0x14,0}); // Don't know why I always have to convert here
m.WriteInteger(finalAdress,[new value here]);