WDF_MEMORY_DESCRIPTOR_INIT_MDL function (wdfmemory.h)

[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(
  [out] PWDF_MEMORY_DESCRIPTOR Descriptor,
  [in]  PMDL                   Mdl,
  [in]  ULONG                  BufferLength
);

Parameters

[out] Descriptor

A pointer to a WDF_MEMORY_DESCRIPTOR structure.

[in] Mdl

A pointer to an MDL that describes a buffer.

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

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

See also

ExAllocatePoolWithTag

IoAllocateMdl

MmBuildMdlForNonPagedPool

WDF_MEMORY_DESCRIPTOR

WDF_MEMORY_DESCRIPTOR_INIT_BUFFER

WDF_MEMORY_DESCRIPTOR_INIT_HANDLE