private WriteProcessMemory ( |
||
hProcess | ||
lpBaseAddress | ||
lpSrc | ||
nSize | uint | |
lpNumberOfBytesWritten | int | |
return | int |
public unsafe int Write(SafeProcessHandle handle, uint offset, uint size, byte *data) { if (Address == IntPtr.Zero) { throw new ObjectDisposedException("RemoteMemoryRegion"); } if ((offset + size) > Size) { throw new ArgumentException("Size too large for region"); } int bytesWritten = 0; int result = Win32.WriteProcessMemory( handle.DangerousGetHandle(), (uint)(Address.ToInt64() + offset), new IntPtr(data), size, out bytesWritten ); if (result == 0 || bytesWritten != size) { var error = Win32.GetLastError(); throw new Exception(String.Format("Write failed: Error {0:x8}", error)); } return(bytesWritten); }