NdisAllocateMdl function

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

Syntax


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

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.

Requirements

Target platform

Universal

Version

Supported in NDIS 6.0 and later.

Header

Ndis.h (include Ndis.h)

Library

Ndis.lib

IRQL

<= DISPATCH_LEVEL

DDI compliance rules

Irql_NetBuffer_Function, NdisAllocateMdl

See also

IoAllocateMdl
MmBuildMdlForNonPagedPool
MmProbeAndLockPages
NdisFreeMdl
ExAllocatePool
NdisAllocateMemoryWithTagPriority
NdisMAllocateSharedMemory

 

 

Send comments about this topic to Microsoft

Show: