PMDL
IoAllocateMdl(
IN PVOID VirtualAddress,
IN ULONG Length,
IN BOOLEAN SecondaryBuffer,
IN BOOLEAN ChargeQuota,
IN OUT PIRP Irp /* optional */
);
IoAllocateMdl allocates an MDL large enough to map a buffer, given its starting address and length. Optionally, this routine associates the MDL with an IRP.
Parameters
VirtualAddress
Points to the base virtual address of the buffer the MDL is to describe.
Length
Specifies the length in bytes of the buffer the MDL is to describe.
SecondaryBuffer
Indicates whether the buffer is a primary or secondary buffer. This parameter determines how the MDL is to be linked to the IRP. All buffers except the first buffer described by an MDL in an IRP are considered secondary buffers. This field must be FALSE if no IRP is associated with the MDL.
ChargeQuota
Should be set to FALSE by intermediate drivers. This can be set to TRUE only by highest-level drivers that are called in the context of the thread that originates the I/O request for which the driver is allocating another IRP.
Irp
Points to an IRP to be associated with the MDL. If the Irp pointer is nonNULL, the allocated MDL is associated with the specified IRP's MDL list, according to the value of SecondaryBuffer.
Return Value
IoAllocateMdl returns a pointer to an MDL or a NULL pointer if the MDL cannot be allocated.
Comments
IoAllocateMdl can be used by a driver that needs to break a buffer into pieces, each mapped by a separate MDL, or to map a driver-allocated buffer. The driver should call MmBuildMdlForNonPagedPool with the MDL allocated by this call to set up an MDL describing a driver-allocated buffer in nonpaged pool.
Callers of IoAllocateMdl must be running at IRQL <= DISPATCH_LEVEL.
See Also