none
how to write an USB class/device filter driver RRS feed

  • Question

  • I plan to write a lower filter driver for in-box USB MBIM class driver wmbclass.sys. Microsoft driver samples umdf_filter_kmdf and umdf_filter_umdf demoed a umdf filter driver on top of umdf or kmdf driver. But the filter and function driver are combined together. Appreciate if anyone could explain how to write a filter driver for Microsoft in-box USB driver.

    more specific questions:

    1) instead of writing a class filter driver, is it possible to write a device filter driver which sit between wmbclass.sys and usbhub.sys?

    2) How to bind filter driver to wmbclass.sys or specific device in INF file? 

    3) what driver model is suitable? UMDF or KMDF? My filter driver does not need to specific kernel functions such as DMA, IRQ handling.

    4) Is there any sample USB filter driver available? filter driver for other USB classes e.g. usbstor.sys is also fine. I cannot find any by myself. :(

    Thanks in advance!

    Regards,

    Jason 

    Tuesday, August 23, 2016 11:04 AM

Answers

  • you don't want to write a class filter, what you describe is a device filter. you "bind" your filter to wmbclass.sys and place yourself as a lower filter by writing an INF that looks almost exactly like the inbox inf that installs wmbclass.sys. In each section you use Need and Includes INF directives to bring in the relevant. if there is no inbox driver for the device, you can't use Needs/Includes as the vendor INF does not have a well known name.

    look at the toaster sample on how to write an filter and install it. it is generic, but will teach you the basics.

    once your filter is in place, you will need to understand URBs, look up URB and _URB on MSDN and start reading


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Jasonbit Wednesday, August 24, 2016 11:12 AM
    Tuesday, August 23, 2016 3:14 PM

All replies

  • First the simple answers, yes you can create a device lower filter see https://msdn.microsoft.com/en-us/windows/hardware/drivers/install/inf-addreg-directive for information.   This pretty much needs to be a KMDF driver.

    The challenge here is what do you want your filter to do, writing a filter for commands to the USB hub is not particularly a common thing, so there is little documentation on this area.   From your questions you are new to Windows driver development, so this is going to be a major challenge.  I recommend you tell the forum more about what your goals are, perhaps there is another way, or at least we may be able to give you guidance.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Tuesday, August 23, 2016 12:13 PM
  • you don't want to write a class filter, what you describe is a device filter. you "bind" your filter to wmbclass.sys and place yourself as a lower filter by writing an INF that looks almost exactly like the inbox inf that installs wmbclass.sys. In each section you use Need and Includes INF directives to bring in the relevant. if there is no inbox driver for the device, you can't use Needs/Includes as the vendor INF does not have a well known name.

    look at the toaster sample on how to write an filter and install it. it is generic, but will teach you the basics.

    once your filter is in place, you will need to understand URBs, look up URB and _URB on MSDN and start reading


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Jasonbit Wednesday, August 24, 2016 11:12 AM
    Tuesday, August 23, 2016 3:14 PM
  • Thanks for the advise! The toaster sample is a good start point. After updating the INF similar as netwmbclass.inf, the filter driver is hooked to my MBIM device successfully.

    Now, my filter driver can receive IRP_MJ_INTERNAL_DEVICE_CONTROL request and simply pass it to lower level driver. Next step would be to process URB requests within IRP_MJ_INTERNAL_DEVICE_CONTROL. 

    Thanks again for all the replies. :)

    Wednesday, August 24, 2016 11:12 AM