NdisAllocateMdl function

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

Syntax

PMDL NdisAllocateMdl(
  NDIS_HANDLE NdisHandle,
  PVOID       VirtualAddress,
  UINT        Length
);

Parameters

NdisHandle

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

VirtualAddress

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

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.

Requirements

   
Minimum supported client Supported in NDIS 6.0 and later.
Target Platform Universal
Header ndis.h (include Ndis.h)
Library Ndis.lib
IRQL "<= DISPATCH_LEVEL"
DDI compliance rules Irql_NetBuffer_Function, NdisAllocateMdl

See Also

ExAllocatePool

IoAllocateMdl

MmBuildMdlForNonPagedPool

MmProbeAndLockPages

NdisAllocateMemoryWithTagPriority

NdisFreeMdl

NdisMAllocateSharedMemory