Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


USBDK -- another Windows generic USB driver

Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 185
Interestingly Redhat is now developing a new generic USB driver
for Windows even though I see no future of another generic
USB driver for Windows other than WinUSB.

UsbDk documentation:
1. Short presentation:
http://www.spice-space.org/docs/usbdk/UsbDk_at_a_Glance.pdf
2. SDM: http://www.spice-space.org/docs/usbdk/UsbDk_Software_Development_Manual.pdf
3. UsbDk architecture specificatin (part of source tree):
http://cgit.freedesktop.org/spice/win32/usbdk/tree/ARCHITECTURE

From the architecture, it seems interesting but potentially dangerous.
Will it really work?


+++++++++++++++++++++++++++++++++++++
Kernel mode component (UsbDk.sys) design and functionality

UsbDk.sys is both USB filter driver and generic USB device driver.
On installation it is being registered as USB filter driver and
system invokes it for each new USB device being discovered including
USB hubs. On invocation UsbDk.sys checks type of underlying device
and creates filter instances for USB hubs only.

Being a filter of USB hub UsbDk.sys receives all requests from upper
part of USB stack including enumeration requests that originated by
PNP manager (IRP_MJ_PNP/IRP_MN_QUERY_DEVICE_RELATIONS).

Upon enumeration request completion by USB hub driver UsbDk.sys scans
array of child devices returned and in case there are devices to be
redirected (according to current configuration) it attaches as filter
to those devices as well.

As a result all PNP manager requests pass via UsbDk.sys callbacks and the
latter patches device ID properties as needed to make PNP manager recognize
the device as a generic USB device.

Besides that UsbDk.sys marks underlying device object as raw PDO so the system
assigns the driver who created it (UsbDk.sys) to be the device driver as well.

At this stage any request to this vendor specific device will be forwarded
to UsbDk.sys which in turn will patch and pass requests to/from original device
created by USB hub as needed.

There is also a separate API provided by UsbDkHelper.dll intended to detach
USB device from USB stack without acquiring actual access to the
device (hider API).

This API may be useful for security applications that need to deny access
to USB devices according to security policy or to prevent Windows from showing
"New Hardware" pop-ups for devices solely managed by UsbDk. When UsbDk.sys
discovers device to be hidden during enumeration phase
(IRP_MJ_PNP/IRP_MN_QUERY_DEVICE_RELATIONS) it wipes corresponding PDO from
device array returned by underlying USB bus driver, this effectively hides
given device from PNP manager and OS driver stack.
+++++++++++++++++++++++++++++++++++++++++++++



--
Xiaofan

Comments

This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 15 Jun 2020 LIVE ONLINE
Writing WDF Drivers 22 June 2020 LIVE ONLINE
Internals & Software Drivers 28 Sept 2020 Dulles, VA