AllocateTitlePhysicalPages

Allocates the requested amount of memory in separate contiguous runs.

Syntax

BOOL AllocateTitlePhysicalPages(
         HANDLE hProcess,
         ULONG flAllocationType,
         PULONG_PTR NumberOfPages,
         PULONG_PTR PageArray
)  

Parameters

hProcess
Type: HANDLE 

[in] A handle to a process. The function allocates memory that can later be mapped within the virtual address space of this process.

flAllocationType
Type: ULONG 

[in] Must be MEM_LARGE_PAGES or MEM_4MB_PAGES. Zero is not permitted. MEM_LARGE_PAGES implies 64 KB, and MEM_4MB_PAGES implies 4 MB.

NumberOfPages
Type: PULONG_PTR 

[in, out] The size of the physical memory to allocate, in 64 KB pages (the units are 64 KB pages even when MEM_4MB_PAGES is specified). On output, this parameter receives the number of pages that are actually allocated, which might be less than the number requested.

PageArray
Type: PULONG_PTR 

[out] A pointer to an array to store the page frame numbers of the allocated memory. The size of the array that is allocated should be at least the NumberOfPages times the size of the ULONG_PTR data type. Do not attempt to modify this buffer. (The buffer will contain individual page frame numbers for every 64 KB address range, even if MEM_4MB_PAGES is specified.)

Return value

Type: BOOL 

If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE, and no frames are allocated. To get extended error information, call GetLastError.

Remarks

AllocateTitlePhysicalPages is useful for those times when it may be desirable for applications to pre-allocate many runs of physically contiguous pages and subdivide them into separate 64 KB pages based on changing conditions determined dynamically at runtime. AllocateTitlePhysicalPages offers allocation of physical pages without placing them into the address space, and separate functions to map, MapTitlePhysicalPages, and unmap them from the address space using VirtualFree.

AllocateTitlePhysicalPages allocates the requested amount of memory in separate contiguous runs of 64 KB (or 4 MB if dwFlags includes MEM_LARGE_PAGES). The allocation is rounded up to a page size boundary (64 KB or 4 MB). An array of 64 KB page numbers will be returned via PageArray (even if 4 MB pages are requested); each value can be multiplied by 64 KB to derive the physical address of the corresponding page. If MEM_LARGE_PAGES is specified, NumberOfPages must be a multiple of 64 (since there are 64 64KB pages per 4 MB) or an error will be returned.

See also

MapTitlePhysicalPages

FreeTitlePhysicalPages

Requirements

Header: Declared in xmem.h.