Edit

Share via


MmAllocateMappingAddressEx function (wdm.h)

The MmAllocateMappingAddressEx function allocates a system PTE mapping of the requested length that can be used later to map arbitrary addresses.

Syntax

PVOID MmAllocateMappingAddressEx(
  [in] SIZE_T NumberOfBytes,
  [in] ULONG  PoolTag,
  [in] ULONG  Flags
);

Parameters

[in] NumberOfBytes

Supplies the maximum number of bytes the mapping can span.

[in] PoolTag

Specifies a four-character tag used to identify the buffer. Use a distinct PoolTag tag for each allocation code path. For a description of pool tags, see ExAllocatePoolWithTag.

[in] Flags

Specifies flags for this operation. Set this parameter to zero or to the bitwise-OR of one or more of the following flag bits:

Flag Meaning
MM_MAPPING_ADDRESS_DIVISIBLE Indicates that the mapping address must be divisible by the size of the mapping. This flag is useful for ensuring that the mapping address aligns with certain hardware requirements.

Return value

MmAllocateMappingAddressEx returns a pointer to the beginning of the reserved memory buffer if the operation is successful; otherwise, it returns NULL.

Remarks

MmAllocateMappingAddressEx provides an extended version of MmAllocateMappingAddress with additional flag support. This function reserves a range of system virtual address space that can be used for later mapping operations with MmMapLockedPagesWithReservedMapping.

No physical memory is allocated by this function; it only reserves virtual address space. The reserved memory can't be accessed until it is mapped using MmMapLockedPagesWithReservedMapping.

Callers must provide a non-zero PoolTag to identify the allocation.

The reserved address range should be freed using MmFreeMappingAddress when no longer needed.

Very large allocations (>= 4GB pages) will fail. The function might fail if insufficient system PTEs are available

Requirements

Requirement Value
Minimum supported client Windows 10, version 2004
Header wdm.h
IRQL <=APC_LEVEL

See also

MmAllocateMappingAddress

MmFreeMappingAddress

MmMapLockedPagesWithReservedMapping

MmUnmapReservedMapping