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(
  _Out_  PWDF_MEMORY_DESCRIPTOR Descriptor,
  _In_   PMDL Mdl,
  _In_   ULONG BufferLength
);

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.

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

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

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.