public static void Reprotect(IntPtr address, ulong size, MemoryPermission permission, bool throwOnFail) { bool result; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { IntPtr sizeNint = new IntPtr((long)size); result = MemoryManagementWindows.Reprotect(address, sizeNint, permission); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { result = MemoryManagementUnix.Reprotect(address, size, permission); } else { throw new PlatformNotSupportedException(); } if (!result && throwOnFail) { throw new MemoryProtectionException(permission); } }
public static void Reprotect(IntPtr address, ulong size, MemoryPermission permission, bool forView, bool force4KBMap, bool throwOnFail) { bool result; if (OperatingSystem.IsWindows()) { if (forView && force4KBMap) { result = MemoryManagementWindows.Reprotect4KB(address, (IntPtr)size, permission, forView); } else { result = MemoryManagementWindows.Reprotect(address, (IntPtr)size, permission, forView); } } else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) { result = MemoryManagementUnix.Reprotect(address, size, permission); } else { throw new PlatformNotSupportedException(); } if (!result && throwOnFail) { throw new MemoryProtectionException(permission); } }
public static void Reprotect(IntPtr address, ulong size, MemoryPermission permission, bool throwOnFail) { bool result; if (OperatingSystem.IsWindows()) { IntPtr sizeNint = new IntPtr((long)size); result = MemoryManagementWindows.Reprotect(address, sizeNint, permission); } else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) { result = MemoryManagementUnix.Reprotect(address, size, permission); } else { throw new PlatformNotSupportedException(); } if (!result && throwOnFail) { throw new MemoryProtectionException(permission); } }