// wdfrequest.h
VOID WdfRequestMarkCancelable(
[in] WDFREQUEST Request,
[in] PFN_WDF_REQUEST_CANCEL EvtRequestCancel
);
View the official Windows Driver Kit DDI reference
No description available.
[Applies to KMDF and UMDF]
The WdfRequestMarkCancelable method enables cancellation of a specified I/O request.
Request
[in]A handle to a framework request object.
EvtRequestCancel
[in]A pointer to a driver-defined EvtRequestCancel callback function, which the framework calls if it cancels the I/O request.
A bug check occurs if the driver supplies an invalid object handle.
After your driver has received an I/O request from the framework, the driver can call WdfRequestMarkCancelable or, starting with KMDF version 1.9, WdfRequestMarkCancelableEx to make the request cancelable.
When calling WdfRequestMarkCancelable, your driver must specify an EvtRequestCancel callback function. The framework calls the callback function if the I/O manager or another driver is attempting to cancel the I/O request.
If your driver uses the framework's automatic synchronization, the driver can call either WdfRequestMarkCancelable or WdfRequestMarkCancelableEx.
If the driver does not use automatic synchronization, it must call WdfRequestMarkCancelableEx instead of WdfRequestMarkCancelable for the following reasons:
After a driver calls WdfRequestMarkCancelable to enable canceling, the request remains cancelable while the driver owns the request object, unless the driver calls WdfRequestUnmarkCancelable.
If a driver has called WdfRequestMarkCancelable, and if the driver's EvtRequestCancel callback function has not executed and called WdfRequestComplete, the driver must call WdfRequestUnmarkCancelable before it calls WdfRequestComplete outside of the EvtRequestCancel callback function.
If the driver calls WdfRequestForwardToIoQueue to forward the request to a different queue, the following rules apply:
I/O requests cannot be cancelable when your driver forwards them to a different queue.
Generally, your driver should not call WdfRequestMarkCancelable to enable canceling the request before calling WdfRequestForwardToIoQueue. If the driver does make the request cancelable, it must call WdfRequestUnmarkCancelable to disable cancellation before calling WdfRequestForwardToIoQueue.
While the request is in the second queue, the framework owns it and can cancel it without notifying the driver.
If the driver requires cancellation notification (so that it can deallocate any resources that it might have allocated before calling WdfRequestForwardToIoQueue), the driver should register an EvtIoCanceledOnQueue callback function, and it should use request-specific context memory to store information about the request's resources.
For more information about WdfRequestMarkCancelable, see Canceling I/O Requests.
The following code example shows parts of two callback functions:
The driver must use the framework's automatic synchronization.
VOID
MyEvtIoRead(
IN WDFQUEUE Queue,
IN WDFREQUEST Request,
IN size_t Length
)
{
...
// Perform request-specific work here
// (such as creating subrequests
// to send to an I/O target).
...
WdfRequestMarkCancelable(
Request,
MyEvtRequestCancel
);
}
...
}
VOID
MyEvtRequestCancel(
IN WDFREQUEST Request
)
{
// Remove request-specific work here, because
// we don't want the work to be done if the
// request was canceled.
WdfRequestComplete(
Request,
STATUS_CANCELLED
);
}