WdfRequestCancelSentRequest function (wdfrequest.h)

[Applies to KMDF and UMDF]

The WdfRequestCancelSentRequest method attempts to cancel an I/O request that the caller previously submitted to an I/O target.


BOOLEAN WdfRequestCancelSentRequest(
  [in] WDFREQUEST Request


[in] Request

A handle to a framework request object.

Return value

WdfRequestCancelSentRequest returns TRUE if it successfully delivers the cancel request to the driver's I/O target. This method returns FALSE if the request has already been completed or canceled, or if the I/O target driver has not called WdfRequestMarkCancelable or WdfRequestMarkCancelableEx.

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


A driver can call WdfRequestCancelSentRequest to attempt to cancel an I/O request that it previously had sent to an I/O target by calling WdfRequestSend.

If the request is in the I/O target's queue, the framework cancels the request. If the framework has already delivered the request to the I/O target's driver, and if that driver has called WdfRequestMarkCancelable or WdfRequestMarkCancelableEx to enable canceling, the framework calls that driver's EvtRequestCancel callback function. If the target's driver has not called WdfRequestMarkCancelable or WdfRequestMarkCancelableEx, the request is not canceled unless the request becomes cancelable.

If the driver has registered a CompletionRoutine callback function for the request, the framework calls the callback function after the request has been canceled.

Typically, if your driver calls WdfRequestCancelSentRequest, it must increment the request object's reference count. For more information, see Synchronizing Cancellation of Sent Requests.

For more information about request cancellation, see Canceling I/O Requests.


The following code example is from the kmdf_fx2 sample driver. This example is an EvtIoStop callback function. Because this driver sends each request to its I/O target, the EvtIoStop callback function calls WdfRequestCancelSentRequest if the device has been removed.

    IN WDFQUEUE  Queue,
    IN WDFREQUEST  Request,
    IN ULONG  ActionFlags

    if (ActionFlags & WdfRequestStopActionSuspend) {
        WdfRequestStopAcknowledge(Request, FALSE);
    } else if (ActionFlags & WdfRequestStopActionPurge) {


Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfrequest.h (include Wdf.h)
Library Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF)
DDI compliance rules DriverCreate(kmdf), EvtIoStopCancel(kmdf), EvtIoStopCompleteOrStopAck(kmdf), InvalidReqAccess(kmdf), InvalidReqAccessLocal(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf)

See also