2

I do have a USB device which is using the WinUSB driver (winusb.sys) as it's function driver. Now I need to write a video capture driver (has to be a kernel mode driver) which accesses this device.

My question is: Can I access and work with a WinUSB device from kernel mode? If so, is there any kind of documentation to do so?

All documentation I've found is talking about accessing WinUSB from user mode with the WinUSB.dll but this is not an option for me. I've already tried to use IoGetDeviceObjectPointer() to get the needed file handle for the USB pipes I'm communicating with on the USB device but the call always fails with STATUS_ACCESS_DENIED. I know that I could write my own KMDF driver for the USB device but it would be much easier to use the already in place WinUSB driver.

Any help would be much appreciate.

Titanic
  • 43
  • 4

1 Answers1

0

This could work ... but is very hard to do.

You can send i/o requests to the winusb device in kernel mode. You cannot use WinUSB functions to communicate, you have to use the actual IO requests to communicate from one i/o stack to another.

I wrote a AVStream miniport driver for a USB device, and can say, that the USB portion is not the hard part. Especially when using kmdf USB IO queue in miniport mode.

Christopher
  • 8,912
  • 3
  • 33
  • 38
  • I've already a working AVStream miniport driver for my USB device but this driver is using my old WDM USB driver to communicate with the device. The problem with my old WDM USB driver is that it's about 12 years old, doesn't work properly with Zero length packets and is not capable of supporting USB 3.0. That's the reason I've tried to replace it with WinUSB as USB driver because WinUSB supports USB 3.0 and also handling of Zero length packets. – Titanic Sep 17 '12 at 12:51
  • Main problem with AVStream and WinUSB is the way how the communicate with each other. With my old WDM driver, I simply called IoGetDeviceObjectPointer with the device reg key followed by PIPE00 to get a file handle for pipe 0 but this doesn't work with WinUSB (always get an STATUS_ACCESS_DENIED error if I try to open the pipe with WRITE permission). How can I get a file handle for the various pipes of my USB device from WinUSB? That's the question. – Titanic Sep 17 '12 at 12:58
  • As far as I know, WinUSB does not export its pipes as file-handles. So you have to use I/O controls. – Christopher Sep 17 '12 at 13:29
  • Thank you for your help. Where can I find the I/O control request codes for WinUSB? They don't seem to be documented anywhere. Do you have an idea where I could get them? – Titanic Sep 17 '12 at 14:28
  • Sorry, as far as I know, they are not officially documented, but you can reverse-engineer them, by capturing the device i/o controls sent from a winusb test application. – Christopher Sep 17 '12 at 16:37
  • Do you know a good tool for capturing these device I/O requests? I've found busTRACE 9.0 but I'm not sure if this exactly what I need – Titanic Sep 19 '12 at 06:00