MSDN Library


Other versions of this page are also available for the following:
Windows Mobile Not SupportedWindows Embedded CE Supported

This function reserves or commits a region of pages in the virtual address space of the process specified by the hProcess parameter. Memory allocated by VirtualAllocEx is initialized to zero.

LPVOID VirtualAllocEx(
  HANDLE hProcess,
  LPVOID lpAddress,
  DWORD dwSize,
  DWORD flAllocationType,
  DWORD flProtect


[in] Process identifier, or a process handle returned from a call to the OpenProcess function.


[in] Long pointer to the specified starting address of the region to be allocated.

If the memory is being reserved, the specified address is rounded down to the next 64-KB boundary.

If the memory is reserved and is being committed, the address is rounded down to the next page boundary.

To determine the size of a page on the host computer, use the GetSystemInfofunction.

If this parameter is NULL, the system determines where to allocate the region.


[in] Specifies the size, in bytes, of the region. It is an error to set this parameter to zero.

If the lpAddress parameter is NULL, this value is rounded up to the next page boundary.

Otherwise, the allocated pages include all pages containing one or more bytes in the range from lpAddress to (lpAddress plus dwSize). This means that a 2-byte range straddling a page boundary causes both pages to be included in the allocated region.


[in] Specifies the type of allocation.

For information about the accepted values for this parameter, see VirtualAlloc.


[in] Specifies the type of access protection.

If the pages are being committed, you can specify any of the following flags, along with the PAGE_GUARD and PAGE_NOCACHE protection modifier flags.

For information about the accepted values for this parameter, see VirtualAlloc.

The base address of the allocated region of pages indicates success. NULL indicates failure. To get extended error information, call GetLastError.

For information about this function, see VirtualAlloc.

Windows Embedded CEWindows Embedded CE 6.0 and later

Community Additions

© 2016 Microsoft