private VirtualProtectEx ( |
||
hProcess | ||
lpAddress | ||
dwSize | uint | |
flNewProtect | MemoryProtection | |
flOldProtect | MemoryProtection | |
return | int |
public void Protect(SafeProcessHandle handle, uint offset, uint size, MemoryProtection newProtect) { if (Address == IntPtr.Zero) { throw new ObjectDisposedException("RemoteMemoryRegion"); } if ((offset + size) > (Size)) { throw new ArgumentException("Size too large for region"); } MemoryProtection oldProtect; int result = Win32.VirtualProtectEx( handle.DangerousGetHandle(), (uint)(Address.ToInt64() + offset), size, newProtect, out oldProtect ); if (result == 0) { var error = Win32.GetLastError(); throw new Exception(String.Format("Protect failed: Error {0:x8}", error)); } }