Hardware Dev Center

Collapse the table of content
Expand the table of content
Espandi Riduci a icona

WdfDmaTransactionInitializeUsingRequest method

[Applies to KMDF only]

The WdfDmaTransactionInitializeUsingRequest method initializes a specified DMA transaction by using the parameters of a specified I/O request.


NTSTATUS WdfDmaTransactionInitializeUsingRequest(
  [in] WDFDMATRANSACTION   DmaTransaction,
  [in] WDFREQUEST          Request,
  [in] PFN_WDF_PROGRAM_DMA EvtProgramDmaFunction,
  [in] WDF_DMA_DIRECTION   DmaDirection


DmaTransaction [in]

A handle to a DMA transaction object that the driver obtained from a previous call to WdfDmaTransactionCreate.

Request [in]

A handle to a framework request object.

EvtProgramDmaFunction [in]

A pointer to the driver's EvtProgramDma event callback function.

DmaDirection [in]

A WDF_DMA_DIRECTION-typed value that specifies the direction of the DMA transfer.

Return value

WdfDmaTransactionInitializeUsingRequest returns STATUS_SUCCESS if the operation succeeds. Otherwise, the method returns one of the following values:

Return codeDescription

An invalid parameter was detected.


The request object that the Request parameter specified contained an invalid memory descriptor list (MDL), or the DmaDirection parameter specifies a direction that is invalid for type of request that the request object contains.


The number of scatter/gather elements that were needed to handle the transaction was greater than the value that the driver's call to WdfDmaEnablerSetMaximumScatterGatherElements specified. For more information, see the following Remarks section.


This method also might return other NTSTATUS values.

A bug check occurs if the driver supplies an invalid object handle.


The WdfDmaTransactionInitializeUsingRequest method prepares a DMA operation for execution, by performing initialization operations such as setting up a transaction's scatter/gather list. After your driver calls WdfDmaTransactionInitializeUsingRequest, the driver must call WdfDmaTransactionExecute.

The driver can call WdfRequestGetParameters to obtain a request's type. The value that the driver specifies for the DmaDirection parameter must be appropriate for the request type, as follows:

  • The DmaDirection value must be WdfDmaDirectionReadFromDevice if:
    • The request type is WdfRequestTypeRead
    • The request type is WdfRequestTypeDeviceControl or WdfRequestTypeDeviceControlInternal and the I/O control code specifies a transfer type of METHOD_OUT_DIRECT
  • The DmaDirection value must be WdfDmaDirectionWriteToDevice if:

    • The request type is WdfRequestTypeWrite

    • The request type is WdfRequestTypeDeviceControl or WdfRequestTypeDeviceControlInternal and the I/O control code specifies a transfer type of METHOD_IN_DIRECT

For more information about transfer types for I/O control codes, see Defining I/O Control Codes.

Framework-based drivers typically call WdfDmaTransactionInitializeUsingRequest from within an I/O queue event callback function.

Your driver should call WdfDmaTransactionInitializeUsingRequest if you are creating a DMA transaction that is based on information that a framework request object contains. Use WdfDmaTransactionInitialize if you are creating a DMA transaction that is not based on a request object.

If the buffer that the request object describes is larger than the maximum transfer length that your driver specified when it called WdfDmaEnablerCreate or WdfDmaTransactionSetMaximumLength, the framework breaks the transaction into multiple transfers.

If the buffer that the request object describes is too fragmented (that is, it requires more scatter/gather elements than the device can handle), WdfDmaTransactionInitializeUsingRequest returns STATUS_WDF_TOO_FRAGMENTED. The driver can specify a smaller memory buffer and call WdfDmaTransactionInitializeUsingRequest again.

For more information about DMA transactions, see Creating and Initializing a DMA Transaction.


For a code example that uses WdfDmaTransactionInitializeUsingRequest, see WdfDmaTransactionExecute.


Target platform


Minimum KMDF version



Wdfdmatransaction.h (include Wdf.h)


Wdf01000.sys (see Framework Library Versioning.)



DDI compliance rules

DeferredRequestCompleted, DriverCreate, KmdfIrql, KmdfIrql2, RequestCompleted, RequestCompletedLocal

See also




Send comments about this topic to Microsoft

© 2015 Microsoft