Artykalamata Cheater Reputation: 0
Joined: 21 Mar 2016 Posts: 32 Location: Germany
|
Posted: Mon Feb 13, 2017 1:50 pm Post subject: Help me fix my code. (c# and Pointers) |
|
|
Something with ReadProcessMemory() is wrong and i don't know what it is.
Code: | class Memory
{
const int PROCESS_ALL_ACCESS = 0x1f0fff;
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll")]
public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, int nSize, ref int lpNumberOfBytesRead);
[DllImport("kernel32.dll")]
public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseaddress, byte[] lpBuffer, int nSize, ref int lpNumberOfBytesWritten);
Process p = new Process();
IntPtr processHandel;
IntPtr baseAddress;
public Memory(Process process)
{
p = process;
processHandel = OpenProcess(PROCESS_ALL_ACCESS, false, p.Id);
baseAddress = p.MainModule.BaseAddress;
}
public IntPtr ReadPointer(int ceAddress, int[] offsets)
{
IntPtr pointer;
int bytesRead = 0;
byte[] buffer = new byte[8];
pointer = IntPtr.Add(baseAddress, ceAddress);
foreach (int offset in offsets)
{
ReadProcessMemory(p.Handle, IntPtr.Add(pointer, offset), buffer, buffer.Length, ref bytesRead); //buffer always returns 0
pointer = new IntPtr(BitConverter.ToInt64(buffer, 0));
}
return pointer;
}
}
|
Code: | int[] offsets = { 0x350, 0x38, 0x10, 0x68 };
IntPtr cool = mem.ReadPointer(0xDE5178, offsets);
|
|
|