NdisAllocateMdl function (ndis/mdlapi.h)

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

Syntax

NDIS_EXPORTED_ROUTINE MDL * NdisAllocateMdl(
  [in] NDIS_HANDLE NdisHandle,
  [in] PVOID       VirtualAddress,
  [in] ULONG       Length
);

Parameters

[in] NdisHandle

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

[in] 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.

 

[in] 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

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

See also

ExAllocatePool

IoAllocateMdl

MmBuildMdlForNonPagedPool

MmProbeAndLockPages

NdisAllocateMemoryWithTagPriority

NdisFreeMdl

NdisMAllocateSharedMemory