MmBuildMdlForNonPagedPool function (wdm.h)

The MmBuildMdlForNonPagedPool routine receives an MDL that specifies a nonpaged virtual memory buffer, and updates it to describe the underlying physical pages.


void MmBuildMdlForNonPagedPool(
  [in, out] PMDL MemoryDescriptorList


[in, out] MemoryDescriptorList

A pointer to an MDL that specifies a virtual memory buffer in nonpaged memory. The caller used the IoAllocateMdl routine to create the MDL for this buffer.

Return value



At entry, the specified MDL must describe a buffer in nonpaged system memory or in memory that is locked down (the physical pages cannot be traded), such as memory that is allocated by the ExAllocatePoolWithTag routine with PoolType = NonPagedPool or by the MmAllocateContiguousMemorySpecifyCache routine. MmBuildMdlForNonPagedPool updates the MDL to describe the underlying physical pages.

MmBuildMdlForNonPagedPool may not be used with MDLs describing buffers allocated on a kernel stack. To build an MDL describing a kernel stack buffer, drivers must call MmProbeAndLockPages. This is because kernel stack pages can be traded unless they are probe-and-locked. This rule applies even if the driver guarantees that the kernel stack cannot be paged out.

Because the pages described by the MDL are already nonpageable and are already mapped to the system address space, drivers must not try to lock them by using the MmProbeAndLockPages routine, or to create additional system-address-space mappings by using the MmMapLockedPagesSpecifyCache routine. Similarly, drivers must not try to unlock the pages by using the MmUnlockPages routine, or to release the existing system-address-space mapping by using the MmUnmapLockedPages routine. If a driver performs any of these illegal operations on an MDL that is built by MmBuildMdlForNonPagedPool, the resulting behavior is undefined.

Passing an MDL built by MmBuildMdlForNonPagedPool to the MmGetSystemAddressForMdlSafe routine is allowed. The MmGetSystemAddressForMdlSafe call, in this case, simply returns the starting virtual address of the buffer that is described by the MDL.

A driver can use the MmMapLockedPagesSpecifyCache routine to map an MDL that is built by MmBuildMdlForNonPagedPool into user virtual address space. However, the driver must perform this operation in a way that avoids certain security issues. For more information, see MmMapLockedPagesSpecifyCache.


Requirement Value
Minimum supported client Available starting with Windows 2000.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe

See also