private void WriteValue(IntPtr handle, IntPtr pointer, object value, byte[] buffer) { int bytesWritten = 0; if (Win32Memory.WriteProcessMemory(handle, pointer, buffer, IntPtr.Size, ref bytesWritten)) { logger.Debug($"Wrote value {value} to address {pointer}"); } }
internal IntPtr OpenProcess(int processId) { IntPtr processHandle = Win32Memory.OpenProcess(PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION, false, processId); logger.Info($"Opened handle #{processHandle} for process #{processId}"); return(processHandle); }
internal long ReadInt64(IntPtr handle, IntPtr pointer) { byte[] buffer = new byte[8]; int bytesRead = 0; Win32Memory.ReadProcessMemory(handle, pointer, buffer, 8, ref bytesRead); var value = BitConverter.ToInt64(buffer, 0); logger.Debug($"Returning long value {value}"); return(value); }
internal IntPtr ReadPointer(IntPtr handle, IntPtr pointer) { byte[] buffer = new byte[IntPtr.Size]; int bytesRead = 0; Win32Memory.ReadProcessMemory(handle, pointer, buffer, IntPtr.Size, ref bytesRead); var value = BitConverter.ToInt64(buffer, 0); logger.Debug($"Returning pointer 0x{value:X}"); return(new IntPtr(value)); }