Kernel32VirtualProtectEx(IntPtr, IntPtr, IntPtr, MemoryProtectionOptions, MemoryProtectionOptions) Method
Changes the protection on a region of committed pages in the virtual address space of a specified 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.
<DllImportAttribute("Kernel32.dll", SetLastError := true>]
Public Shared Function VirtualProtectEx (
hProcess As IntPtr,
address As IntPtr,
size As IntPtr,
newProtect As MemoryProtectionOptions,
<OutAttribute> ByRef refOldProtect As MemoryProtectionOptions
) As Boolean
Dim hProcess As IntPtr
Dim address As IntPtr
Dim size As IntPtr
Dim newProtect As MemoryProtectionOptions
Dim refOldProtect As MemoryProtectionOptions
Dim returnValue As Boolean
returnValue = Kernel32.VirtualProtectEx(hProcess,
address, size, newProtect, refOldProtect)
public:
[DllImportAttribute(L"Kernel32.dll", SetLastError = true)]
static bool VirtualProtectEx(
[InAttribute] IntPtr hProcess,
[InAttribute] IntPtr address,
IntPtr size,
MemoryProtectionOptions newProtect,
[OutAttribute] MemoryProtectionOptions% refOldProtect
)
[<DllImportAttribute("Kernel32.dll", SetLastError = true)>]
static member VirtualProtectEx :
hProcess : IntPtr *
address : IntPtr *
size : IntPtr *
newProtect : MemoryProtectionOptions *
refOldProtect : MemoryProtectionOptions byref -> bool
No code example is currently available or this language may not be supported.
- hProcess IntPtr
-
A handle to the process whose memory protection is to be changed.
The handle must have the VirtualMemoryOperation access right.
- 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 IntPtr
-
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.