VirtualAllocVlm

[This is preliminary documentation and subject to change.]

The VirtualAllocVlm function commits a region of pages in the virtual 64-bit address space of the indicated process.

PVOID64 VirtualAllocVlm(
  HANDLE hProcess,   // process within which to allocate memory
  PVOID64 lpAddress, // address of region to reserve or commit
  DWORDLONG ullSize, // size of region
  DWORD flAllocationType,
                     // type of allocation
  DWORD flProtect    // type of access protection
);
 

Parameters

hProcess
Handle to a process. VirtualAllocVlm allocates memory within the virtual address space of this process. The calling process must have had the PROCESS_VM_OPERATION flag set on a preceding call to the OpenProcess function, indicating virtual memory access to the target process, or VirtualAllocVlm fails.
lpAddress
Starting address of the region to allocate. The system rounds the specified address down to the next 64K boundary. If the lpAddress parameter is NULL, the operating system determines where to allocate the region.
ullSize
Size, in bytes, of the region to allocate. If lpAddress is NULL, this size is rounded up to the next page boundary. Otherwise, the allocated pages include all pages containing one or more bytes in the range from the value of lpAddress to the value of lpAddress plus the value of the ullSize parameter. This functionality means that a 2-byte range straddling a page boundary causes both pages to be included in the allocated region.
flAllocationType
Type of allocation. You can specify any combination of the following flags.
Value Meaning
MEM_COMMIT Allocates for the specified region of pages physical storage in memory or in the paging file on disk.
An attempt to commit an already committed page does not cause VirtualAllocVlm to fail. Thus, a range of committed or decommitted pages can be committed without causing a failure.
MEM_RESERVE Reserves a range of the process's virtual address space without allocating any physical storage. The reserved range cannot be used by any other allocation operations (for example, the malloc function, the LocalAlloc function, and so on) until it is released.

flProtect
Flag that specifies the type of access for the region to be allocated. You can specify one of the following.
Value Meaning
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.

Return Values

If the function succeeds, the return value is the base address of the allocated region of pages.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

The VirtualAllocVlm function is used to allocate and specify an initial protection value for memory regions that can be addressed through 64-bit pointers.

Memory allocated by VirtualAllocVlm must be physically present in the system. This memory is considered locked down and unavailable to the rest of the virtual memory management system of Windows NT. Programmers using VirtualAllocVlm should understand that this function is allocating dedicated resources.

QuickInfo

  Windows NT: Requires version 5.0 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in winbase.h.
  Import Library: Use kernel32.lib.

See Also

Memory Management Overview, Memory Management Functions, Very Large Memory (VLM), GlobalAlloc, HeapAlloc, LocalAlloc, OpenProcess, VirtualAlloc, VirtualFreeVlm, VirtualLock, VirtualProtectVlm, VirtualQueryVlm