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/


KMDF filter driver acting as a bus driver

ArushArush Member Posts: 6

I have a disk upper filter driver written using WDF (KMDF) and I currently have a control device object that is used to communicate to the driver from userspace. However, I find myself needing to specify what disk device (by instance ID with an appended string) I want to perform the operation on. I feel like this isn't the best approach and neither does microsoft's own documentation.

I was thinking of creating a device for each disk device, and the Microsoft docs here explain that I can do so. It says that the filter driver should "act as a bus driver and enumerate child devices that operate in raw mode." I'm confused about what this means for my disk filter.

Do I need to somehow write a bus filter driver to create the custom named PDOs? How do I create a "physical device object (PDO) that does not require a function driver?"

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,832

    Are there multiple instances of your device, one for each disk? If you're a PnP filter, that would be natural. A "PDO that does not require a function driver" is called a "raw device".

    Tim Roberts, [email protected]
    Software Wizard Emeritus

  • ArushArush Member Posts: 6

    Yes, so for each internal/external HDD (or like things like USB drives) there is a filter device added to the stack during the EvtDriverDeviceAdd routine.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,832

    Ah, but right now the driver just creates one single "control" device, and all requests arrive there?

    If your driver is KMDF, it is surprisingly easy to have each device create a raw PDO and accept requests on that PDO. You become a bus driver, but it's almost painless. You just have to come up with a naming convention.

    Tim Roberts, [email protected]
    Software Wizard Emeritus

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,828

    Both the kbfilter and moufiltr WDK examples demonstrate a filter driver enumerating a raw PDO

    d
  • ArushArush Member Posts: 6

    Yes, that single control device parses the requests and then dispatches them to the I/O queues of the target filter device object in the device stack.

    The reason I'm confused is because I'm not sure what exactly "becoming a bus driver" entails. Does this mean I have to handle bus-driver responsibilities like static and dynamic enumeration of child devices, handling power management queues, among other things? Also does my driver acting like a bus driver replace the bus driver in the stack? Or is like an "addition?"

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,832

    Being a bus driver really means nothing more than "I have child devices". In WDM, becoming a bus driver is a relatively big deal. In KMDF, it is a piece of cake, because they handle all of the standard overhead for you. You should go look at the samples Doron mentioned. Whether your driver is a bus driver or not has no impact to the drivers below you. There are many bus drivers in your stack.

    Tim Roberts, [email protected]
    Software Wizard Emeritus

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

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 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 20-24 May 2024 Live, Online