For completeness, if you are going to pass a process context specific
handle (like a handle to an event) you must call
ObReferenceObjectByHanle in your WDFDEVICE’s EvtIoInCallerContext
callback and not in your EvtIoDefault/Ioctl callback. Why? Because
EvtIoDefault/Ioctl are not guaranteed to be in the context of the
calling process when they are invoked and if you made the ObRef call in
EvtIoDefault/Ioctl you could be referencing a random handle table.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Thursday, November 30, 2006 4:07 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Asynchous IO using a WDF parallel IO queue
David Voeller wrote:
I have a USB device and a corresponding USB driver. I am using an
interrupt
pipe to handle the occasional data that comes in from the USB device
after
the USB device has received it from a separate infrared remote device.
Why does it use an interrupt pipe? If it is “occasional data”, it would
make more sense to use a bulk pipe, so as not to block out bandwidth
unnecessarily.
The
application has sent the driver an event object that the driver is
using to
signal when data has been received.
I haven’t done this yet but it looks like an overlapped IOCTL should
be used
where the application sends the IOCTL and the driver fills a buffer
supplied
by the IOCTL when data has been received on the interrupt pipe. I
have used
the interrupt pipe and external signaled event before but I have never
used
overlapped I/O so I’m looking for a little reassurance that I’m
approaching
this in the right way. I would create a parallel IO queue just for
this
task. All other IOCTLs I’m handling with a default serial queue.
You don’t really need overlapped I/O for this. Just have the app launch
a separate thread, submit the ioctl, and wait. The only reason you
would need overlapped I/O is if you were doing other I/O on the same
handle, and you didn’t want to open a new handle just for this task.
Remember that the use of overlapped I/O by the application is entirely
irrelevant to the driver. The only difference is in the way the
application gets its response. The driver treats the IRPs just the
same.
So, if there is a better or different way to transfer this asychronous
data
from the USB interrupt pipe to the application, please point me in the
right
direction.
A blocked ioctl is a fine way to get this kind of notification. I use
it regularly. It is philosophically similar to the event method, with
the added benefit that you can return information when you complete the
IRP.
The overlapped I/O question is really separate; it’s an application
implementation issue. There are good samples on the web showing how to
do overlapped I/O properly.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer