public static void Write(int address, byte[] arr, int count) { if (arr.Length < count) { throw new ArgumentException("Length < Count"); } if (address < PointerBorder) { if (address < ProcessBorder) { throw new ArgumentOutOfRangeException("Address: " + address.ToString("X4")); } if (!ProcessImports.WriteProcessMemory(handle, new IntPtr(address), arr, (uint)count, out uint byteWritten)) { Win32Exception.ThrowLastError(); } } else { // FIXME: use memcpy or ints for (int i = 0; i < count; i++) { *(byte *)(address + i) = arr[i]; } } }
public static uint Write(int address, byte[] arr, int count) { if (address == 0) { throw new ArgumentException("Write address is 0!"); } uint byteWritten; if (!ProcessImports.WriteProcessMemory(Handle, new IntPtr(address), arr, (uint)count, out byteWritten)) { Error.GetLastError(); } return(byteWritten); }
public static uint Write(int address, int value) { if (address == 0) { throw new Exception("Write position is 0!"); } IntPtr byteWritten = IntPtr.Zero; IntPtr ptr = new IntPtr(value); if (!ProcessImports.WriteProcessMemory(Handle, new IntPtr(address), out ptr, 4, out byteWritten)) { Error.GetLastError(); } return((uint)byteWritten.ToInt32()); }
public static void Write(int address, int value) { if (address < PointerBorder) { if (address < ProcessBorder) { throw new ArgumentOutOfRangeException("Address: " + address.ToString("X4")); } IntPtr ptr = new IntPtr(value); if (!ProcessImports.WriteProcessMemory(handle, new IntPtr(address), out ptr, 4, out IntPtr byteWritten)) { Win32Exception.ThrowLastError(); } } else { *(int *)address = value; } }