NdisAllocateMdl - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// mdlapi.h

NDIS_EXPORTED_ROUTINE MDL * NdisAllocateMdl(
  [in] NDIS_HANDLE NdisHandle,
  [in] PVOID       VirtualAddress,
  [in] ULONG       Length
);
View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nf-mdlapi-ndisallocatemdl)

NdisAllocateMdl function

Description

The NdisAllocateMdl function allocates an MDL that describes the memory buffer at the specified virtual address.

Parameters

NdisHandle [in]

An NDIS handle that was obtained during caller initialization. For more information, see Obtaining Pool Handles.

VirtualAddress [in]

A pointer to the base virtual address of the buffer that the MDL is to describe.

Important

The VirtualAddress parameter for NdisAllocateMdl only accepts memory from the nonpaged pool. In other words, it requires memory from ExAllocatePool*(NonPagedNx), NdisAllocateMemoryWithTagPriority, or NdisMAllocateSharedMemory. In particular, it should not be used with memory from the stack, paged pool, driver global data, or other memory regions.

If a driver needs to build an MDL for one of these non-nonpaged pool regions, it should use the appropriate kernel APIs for that type of memory, such as IoAllocateMdl combined with MmProbeAndLockPages.

Length [in]

The size, in bytes, of the memory buffer.

Return value

NdisAllocateMdl returns a pointer to the allocated MDL. If the allocation fails, the return value is NULL.

Remarks

All MDLs that are allocated by calling NdisAllocateMdl must be freed by calling the NdisFreeMdl function.

NdisAllocateMdl allocates memory and builds the MDL in one step. This process is different from IoAllocateMdl, which only allocates memory for the MDL, meaning the caller must build the MDL by calling either MmBuildMdlForNonPagedPool or MmProbeAndLockPages.

See also

ExAllocatePool

IoAllocateMdl

MmBuildMdlForNonPagedPool

MmProbeAndLockPages

NdisAllocateMemoryWithTagPriority

NdisFreeMdl

NdisMAllocateSharedMemory