Pending a request of a control device in KMDF

Hello.
I made a KMDF filter driver for my HID mouse, and now I’m trying to share data to my user mode application.

Here is the scenario I’m trying to achieve:

  1. The user application start a readfile on the control device and waits.
  2. The filter device gets an irp (read, iocontrol or whatever).
  3. It then notifies the control device and sends it the data of the event.
  4. The control device completes the read request of the user with the data of the filter.
  5. The user gets the data.

I understand I’m supposed to mark the irp with STATUS_PENDING, after calling IoMarkIrpPending, and then callIoCompleteRequest() when I’m ready.
My problem is: I don’t understand how to do all this in KMDF.

In my EvtIoRead, I called WdfRequestSetCompletionRoutine to set a completion routine to my request. In this completion routine, I called WdfRequestCompleteWithInformation to finally complete the request.

So my question is:
How does my EvtIoRead pend the request, and what should I call to complete it later?

Thank you for your answers.
Erwan Martin.

KMDF pends all i/o for you, so no need to mark the request pending and return STATUS_PENDING. Furthermore, the completion routine you are setting is only valid if you are sending the request to some WDFIOTARGET, perhaps you are confusing a completion routine with a cancelation routine.

The bigger question you have is, do you want to support cancellation? I am guessing yes. The easiest thing for you to do is to create a manual WDFQIOQUEUE which you will forward the read requests to. This will automatically handle cancelation for you, all you need to do is pop out a request from the manual queue when you have data to complete.

Also, I suggest that you look at the KMDF kbdfiltr example which demonstrates how to use a raw PDO instead of a control device object. This has a couple of advantages. First, you are not tied to a fixed name so if you have more than one instance of the HID device that you are filtering, it is easy to discover all instances. Second, since it uses device interfaces you are dynamically notified when your HID arrives

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@fzwte.net
Sent: Sunday, June 22, 2008 4:01 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Pending a request of a control device in KMDF

Hello.
I made a KMDF filter driver for my HID mouse, and now I’m trying to share data to my user mode application.

Here is the scenario I’m trying to achieve:

  1. The user application start a readfile on the control device and waits.
  2. The filter device gets an irp (read, iocontrol or whatever).
  3. It then notifies the control device and sends it the data of the event.
  4. The control device completes the read request of the user with the data of the filter.
  5. The user gets the data.

I understand I’m supposed to mark the irp with STATUS_PENDING, after calling IoMarkIrpPending, and then callIoCompleteRequest() when I’m ready.
My problem is: I don’t understand how to do all this in KMDF.

In my EvtIoRead, I called WdfRequestSetCompletionRoutine to set a completion routine to my request. In this completion routine, I called WdfRequestCompleteWithInformation to finally complete the request.

So my question is:
How does my EvtIoRead pend the request, and what should I call to complete it later?

Thank you for your answers.
Erwan Martin.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer