Cancellation of driver-owned WDFREQUEST

Hello,

I’m trying to write a KMDF driver in which a service can make requests for data from my driver. If there is no data to fulfill a request, the driver parks the request in a manual WDFQUEUE. I know that the framework will automatically complete/abort a cancelled request if it’s sitting in a queue, but I’m worried I may be missing a cancellation if I’m in one of the following situations where the driver owns the request:

  1. The driver is processing a request in the IOCTL handler for its default I/O queue and there is no data to fulfill the request. The handler forwards the request to the manual queue using WdfRequestForwardToIoQueue.
  2. The driver has pulled a request off of the manual queue but cannot complete the request. The request is requeued using WdfRequestRequeue.

In the two cases described above, I understand that my driver owns the request and is responsible for completing it. What if the request gets cancelled while the driver owns the it, but it then gets put into a queue? Presumably the framework has “missed” the request because it the request was not in a queue at the time. Does the framework complete the request once it’s in the queue, or is it up to the driver to somehow figure out that cancellation has occurred? I know that EvtRequestCancel exists, but I understand that’s only used when requests are explicitly marked cancelable using WdfRequestMarkCancelable, which (I think) is precluded by use of WDFQUEUEs to park requests.

for both cases above, when a request is inserted into a WDFQUEUE, the state cancelation state of the request is evaluated. in both cases, if the request is canceled (without a cancel routine set) while your driver is processing the request, when you requeue , the cancelation will be processsed by the wdfqueue.