Legacy driver filter

I’ve been experimenting with the sample KMDF wdffltr driver (NT Insider Jan-Feb 06 KMDF Filter Driver: 30 Minutes…). I’ve tried it with OSRUSBFX2 sample and it all looks straightfoward and appears to work well.

One Observation:

I did note that (certainly with KMDF 1.1 that I was using) the filter driver never gets unloaded - even using the DBG build with no control client running). WdfFltrQueryRemove never gets called unless you remove the control device creation support (i.e. don’t call WdfFltrCreateControlDevice). Is this perhaps due to something that has been added in KMDF 1.1 to avoid the chance of the race-condition mentioned in the wdffltr comments?

Goal:

What I really want to do though is to use the filter driver over an existing legacy (NT-style) driver (i.e. not WDM/PnP). Is this possible? Adding the UpperFilters value to the legacy driver’s Enum\Roor\LEGACY-based key appears to have no affect (i.e. the filter driver does not get started when the legacy driver starts). If this arrangement won’t work as is, what is the quickest solution - I really don’t want to have to change the legacy driver if I can avoid it?

Thanks

Will

If you create a non pnp (e.g. a control) WDFDEVICE, you must manually delete that WDFDEVICE when the last PNP WDFDEVICE has been destroyed. Since you are a pnp behavior, the i/o manager will not unload your driver until the last device object has been deleted, unlike an NT4 legacy/control device driver which can be unloaded with existing device objects still around. This is a WDM behavior, KMDF does not add anything new here.

Filters only work for pnp device stacks. They do not work for NT4 style devices w/out a PDO. The NT4 way of filtering is that you open the device you want filter via IoGetDeviceObjectPointer and then attach to it via IoAttachDeviceToDeviceStack. The issues here are load ordering b/c you don’t get explicitly notified of the legacy device object’s arrival and existing file handles at the time of attachment (you will only see newly created handles).

d

> What I really want to do though is to use the filter driver over an existing
legacy

(NT-style) driver (i.e. not WDM/PnP). Is this possible?

To filter non-PnP device, use IoGetDeviceObjectPointer and then
IoAttachDeviceToDeviceStack.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com