Bewerken

Delen via


MmAllocateContiguousMemoryEx function (wdm.h)

The MmAllocateContiguousMemoryEx function allocates a range of physically contiguous non-paged memory and returns its virtual address.

Syntax

NTSTATUS MmAllocateContiguousMemoryEx(
  [in]           PSIZE_T          NumberOfBytes,
  [in]           PHYSICAL_ADDRESS LowestAcceptableAddress,
  [in]           PHYSICAL_ADDRESS HighestAcceptableAddress,
  [in]           PHYSICAL_ADDRESS BoundaryAddressMultiple,
  [in]           NODE_REQUIREMENT PreferredNode,
  [in]           ULONG            Protect,
  [in, optional] PVOID            PartitionObject,
  [in]           ULONG            Tag,
  [in]           ULONG            Flags,
  [out]          PVOID            *BaseAddress
);

Parameters

[in] NumberOfBytes

On entry, supplies the number of bytes to allocate. On successful return, receives the amount allocated.

[in] LowestAcceptableAddress

Supplies the lowest physical address which is valid for the allocation. For example, if the device can only reference physical memory in the 8M to 16MB range, this value would be set to 0x800000 (8Mb).

[in] HighestAcceptableAddress

Supplies the highest physical address which is valid for the allocation. For example, if the device can only reference physical memory below 16MB, this value would be set to 0xFFFFFF (16Mb - 1).

[in] BoundaryAddressMultiple

Supplies the physical address multiple this allocation must not cross.

[in] PreferredNode

Supplies the preferred node the allocation should be made from if pages are available on that node. MM_ANY_NODE_OK is used to signify no node preference.

[in] Protect

Supplies the desired protection (including cache type) for the mapping.

[in, optional] PartitionObject

If specified, supplies a partition object to allocate the physical memory from. If not specified, the memory will come from the system partition.

[in] Tag

Supplies the tag for the allocation.

[in] Flags

Various flags:

  • MM_ALLOCATE_CONTIGUOUS_MEMORY_FAST_ONLY - Allocate desired contiguous memory only if it can be satisfied quickly. Fail if prolonged physical memory searching and trading must take place to satisfy the allocation.

[out] BaseAddress

On success, receives the base virtual address of the contiguous memory.

Return value

Returns an NTSTATUS code.

Remarks

This memory must be freed with MmFreeContiguousMemory.

Requirements

Requirement Value
Minimum supported server Windows Server 2022
Header wdm.h
IRQL <= DISPATCH_LEVEL

See also

MmFreeContiguousMemory