WDF_MEMORY_DESCRIPTOR_INIT_MDL function

[Applies to KMDF and UMDF]

The WDF_MEMORY_DESCRIPTOR_INIT_MDL function initializes a WDF_MEMORY_DESCRIPTOR structure so that it describes a specified memory descriptor list (MDL).

Syntax

void WDF_MEMORY_DESCRIPTOR_INIT_MDL(
  PWDF_MEMORY_DESCRIPTOR Descriptor,
  PMDL                   Mdl,
  ULONG                  BufferLength
);

Parameters

Descriptor

A pointer to a WDF_MEMORY_DESCRIPTOR structure.

Mdl

A pointer to an MDL that describes a buffer.

BufferLength

The size, in bytes, of the buffer that Mdl specifies.

Return Value

None

Remarks

The WDF_MEMORY_DESCRIPTOR_INIT_MDL function zeros the specified WDF_MEMORY_DESCRIPTOR structure and sets the structure's Type member to WdfMemoryDescriptorTypeMdl. Then it sets the structure's u.MdlType.Mdl and u.MdlType.BufferLength members to the values that the Mdl and BufferLength parameters specify, respectively.

Examples

The following code example allocates a buffer, creates an MDL for the buffer, and uses the MDL to initialize a WDF_MEMORY_DESCRIPTOR structure.

PVOID  pBuffer = NULL;
PMDL  pMdl = NULL;

pBuffer = ExAllocatePoolWithTag(
                                NonPagedPool, 
                                BUFFER_LENGTH, 
                                IOTARGET_DRIVER_TAG
                                );
if (pBuffer == NULL){
    Status = STATUS_UNSUCCESSFUL;
    goto Cleanup;
}
pMdl = IoAllocateMdl(
                     pBuffer,
                     BUFFER_LENGTH,
                     FALSE,
                     TRUE,
                     NULL
                     );
if (pMdl == NULL){
    Status = STATUS_UNSUCCESSFUL;
    goto Cleanup;
}
MmBuildMdlForNonPagedPool(pMdl);
WDF_MEMORY_DESCRIPTOR_INIT_MDL(
                               pInputBuffer,
                               pMdl,
                               BUFFER_LENGTH
                               );

Requirements

   
Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfmemory.h (include Wdf.h)
DDI compliance rules MdlAfterReqCompletedIntIoctlA, MdlAfterReqCompletedIoctlA, MdlAfterReqCompletedReadA, MdlAfterReqCompletedWriteA

See Also

ExAllocatePoolWithTag

IoAllocateMdl

MmBuildMdlForNonPagedPool

WDF_MEMORY_DESCRIPTOR

WDF_MEMORY_DESCRIPTOR_INIT_BUFFER

WDF_MEMORY_DESCRIPTOR_INIT_HANDLE