WDF_MEMORY_DESCRIPTOR_INIT_MDL - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// wdfmemory.h

VOID WDF_MEMORY_DESCRIPTOR_INIT_MDL(
  [out] PWDF_MEMORY_DESCRIPTOR Descriptor,
  [in]  PMDL                   Mdl,
  [in]  ULONG                  BufferLength
);

View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nf-wdfmemory-wdf_memory_descriptor_init_mdl)

WDF_MEMORY_DESCRIPTOR_INIT_MDL function

Description

[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).

Parameters

Descriptor [out]

A pointer to a WDF_MEMORY_DESCRIPTOR structure.

Mdl [in]

A pointer to an MDL that describes a buffer.

BufferLength [in]

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

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
                               );

See also

ExAllocatePoolWithTag

IoAllocateMdl

MmBuildMdlForNonPagedPool

WDF_MEMORY_DESCRIPTOR

WDF_MEMORY_DESCRIPTOR_INIT_BUFFER

WDF_MEMORY_DESCRIPTOR_INIT_HANDLE