[This is preliminary documentation and subject to change.]
The VirtualProtectVlm function changes the access type for a region of memory allocated using the VirtualAllocVlm function.
BOOL VirtualProtectVlm(
HANDLE hProcess, // process within which to protect memory
PVOID64 lpAddress, // address of region of committed pages
DWORDLONG ullSize, // size of the region
DWORD flNewProtect, // desired access protection
PDWORD lpflOldProtect
// address of variable to get old protection
);
Only full 64-bit addresses are supported here — 32-bit sign-extended addresses are not supported. In other words, the 4 GB range surrounding address zero cannot be modified using VirtualProtectVlm.
All pages in the specified region must have been allocated in a single call to the VirtualAllocVlm function. The pages cannot span adjacent regions that were allocated by separate calls to VirtualAllocVlm.
Value | Meaning |
---|---|
PAGE_NOACCESS | Disables all access to the committed region of pages. An attempt to read from, or write to, or execute code in the committed region results in an access violation exception. |
PAGE_READONLY | Enables read access to the committed region of pages. An attempt to write to the committed region results in an access violation. If the operating system differentiates between read-only access and execute access, an attempt to execute code in the committed region results in an access violation. |
PAGE_READWRITE | Enables both read and write access to the committed region of pages. |
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
You can set an access value for pages that have been committed only. If any page in the specified region is not committed, VirtualProtectVlm fails and returns without modifying the access state of any pages in the specified region.
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Memory Management Overview, Memory Management Functions, Very Large Memory (VLM), OpenProcess, VirtualAllocVlm, VirtualProtect, VirtualProtectEx