Kernel32VirtualProtect(IntPtr, UIntPtr, MemoryProtectionOptions, MemoryProtectionOptions) Method
Changes the protection on a region of committed pages in the virtual address space of the calling process.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public:
[DllImportAttribute(L"Kernel32.dll", SetLastError = true)]
static bool VirtualProtect(
[InAttribute] IntPtr address,
UIntPtr size,
MemoryProtectionOptions newProtect,
[OutAttribute] MemoryProtectionOptions% refOldProtect
)
No code example is currently available or this language may not be supported.
- address IntPtr
-
A pointer an address that describes the starting page of the region of pages whose access protection attributes are to be changed.
All pages in the specified region must be within the same reserved region allocated when calling the
VirtualAlloc(IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) or VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function
using Reserve flag.
The pages cannot span adjacent reserved regions that were allocated by separate calls to
VirtualAlloc(IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) or VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function
using Reserve flag.
- size UIntPtr
-
The size of the region whose access protection attributes are to be changed, in bytes.
The region of affected pages includes all pages containing one or more bytes in the range from the
address parameter to (address+size).
This means that a 2-byte range straddling a page boundary causes the protection attributes of both pages to be changed.
- newProtect MemoryProtectionOptions
-
The memory protection option.
- refOldProtect MemoryProtectionOptions
-
A pointer to a variable that receives the previous memory protection option value of the first page in the
specified region of pages.
If this parameter is or does not point to a valid variable, the function fails.
Boolean
If the function succeeds, the return value is
.
If the function fails, the return value is
.
To get extended error information, call
GetLastWin32Error.