Skip to main content

XMemMapPhysicalPages

Maps pages allocated by XMemAllocatePhysicalPages into the virtual address space.

Syntax

Parameters

VirtualAddress   _In_
Type: PVOID
Address at which the pages should be mapped. NumberOfPages   _In_
Type: ULONG_PTR
Number of entries in the PageArray. PageArray   _In_reads_opt_(NumberOfPages)
Type: PULONG_PTR
Array of page frame numbers representing the pages to map.

Return value

Type: PVOID Virtual address at which the physical pages have been mapped, or NULL if there was a mapping failure. In the case of a mapping failure, call GetLastError to get extended error information.

Remarks

The virtual address range must be previously reserved by a call to XMemVirtualAlloc with MEM_RESERVE, a page size of MEM_64K_PAGES or MEM_2MB_PAGES and the XMEM_MAPPABLE flag. MEM_PHYSICAL address reservations made by VirtualAlloc will not be usable for mapping this memory. If the virtual address range already has mapped pages, they will be unmapped. Additionally, NULL may be specified for the PageArray in order to decommit the memory region. XMemMapPhysicalPages may be used to map the same physical pages multiple times in the virtual address space. If pages are mapped multiple times, the multiple mappings must specify identical caching attributes (CPU coherent is implied if no cache attribute is provided, otherwise the list is PAGE_NOCACHE or PAGE_WRITECOMBINE).
When mapping physical pages into memory reserved with MEM_2MB_PAGES the physical pages must have been allocated with XMEM_2MB_CLUSTERS. The PageArray parameter should only contain the first physical page of each 2MB cluster.
Example:

Requirements

Header: xmem.h Library: xmem.lib Supported platforms: XBOX One family consoles and XBOX Series consoles

See also

XMem reference
XMemVirtualAlloc
VirtualFree
XMemFreePhysicalPages
Last modified on August 31, 2026