Saturday, June 4, 2016

Why Do I Need a Bus Filter?

After a new PnP device is enumerated by a bus function driver and identified by PnP Manager, PnP Manager will send the following PnP IRPs to the device stack of that device:
  1. IRP_MN_QUERY_ID
    • BusQueryDeviceID
    • BusQueryInstanceID
    • BusQueryHardwareIDs
    • BusQueryCompatibleIDs
    • BusQueryContainerID (for Windows 7+)
  2. IRP_MN_QUERY_CAPABILITIES
  3. IRP_MN_QUERY_DEVICE_TEXT
    • DeviceTextDescription
    • DeviceTextLocationInformation
  4. IRP_MN_QUERY_BUS_INFORMATION
  5. IRP_MN_QUERY_RESOURCES
  6. IRP_MN_QUERY_RESOURCE_REQUIREMENTS
Note that, at this moment, the device stack has only one PDO, and optionally one or more bus filter DOs. And don't forget that the function driver and filter drivers, if any, are selected and loaded by PnP Manager, according to a matched hardware ID or compatible ID. Therefore, if you want to influence PnP Manager's decision on which function and any optional filter drivers get selected and loaded, you must modify hardware IDs or compatible IDs generated by the bus function driver. In other words, you have two options:
  1. You either write your own bus function driver, or
  2. You write a bus filter driver.
Obviously, the second one is easier.

No comments:

Post a Comment