public static bool VirtualProtect(IntPtr pid, IntPtr address, uint size, PageAccessProtectionFlags flags, out PageAccessProtectionFlags oldFlags) { IntPtr handle = GetProcessHandle(pid, ProcessAccessFlags.VMOperation); bool result = VirtualProtectEx(handle, address, size, flags, out oldFlags); CloseHandle(handle); return(result); }
public static bool VirtualProtect( IntPtr pid, IntPtr address, uint size, PageAccessProtectionFlags flags, out PageAccessProtectionFlags oldFlags) { IntPtr processHandle = Kernel32.GetProcessHandle(pid, ProcessAccessFlags.VMOperation); int num = Kernel32.VirtualProtectEx(processHandle, address, size, flags, out oldFlags) ? 1 : 0; Kernel32.CloseHandle(processHandle); return(num != 0); }
public static IntPtr VirtualAlloc( Process p, IntPtr address, uint size, AllocationType type, PageAccessProtectionFlags flags) { IntPtr processHandle = Kernel32.GetProcessHandle(p, ProcessAccessFlags.VMOperation); IntPtr num = Kernel32.VirtualAllocEx(processHandle, address, size, type, flags); if (num == IntPtr.Zero) { throw new Win32Exception(Marshal.GetLastWin32Error()); } Kernel32.CloseProcessHandle(processHandle); return(num); }
private static extern IntPtr VirtualAllocEx( IntPtr hProcess, IntPtr lpAddress, uint dwSize, AllocationType flAllocationType, PageAccessProtectionFlags flProtect);
private static extern bool VirtualProtectEx( IntPtr hProcess, IntPtr lpAddress, uint dwSize, PageAccessProtectionFlags flags, out PageAccessProtectionFlags oldFlags);