Installing filter driver as both, upper and lower

Hello all,
I am a little bit confused as to how to install my filter driver at both levels, upper and lower.
Should I add two lines to my inf-file, providing the class I want to install the filter with “UpperFilters” and “LowerFilters” keywords?
If so, how can I then identify a level the system is installing the filter to within onDeviceAdd()? Or should I specify somehow the level I want to install the filter while creating the device?
Thank you,
Mike

Class or device filter? Regardless, your adddevice will just be called twice and without additional work, you do not know if upper or lower. Two ways to detect this come to mind. First, you add support for a home beacon query interface interface. During add device before you create the wdfdevice you send the query does the stack. If supported you are the upper filter. If not, lower. Second, and a bit simpler in some sense is that you check for a sentinel value in the dev node parameters keys. If absent, you are the lower and write the value. If present, you are the upper. You need to then delete that value when processing surprise remove and graceful remove by deleting it in selfmanagediocleanup.

d

Bent from my phone


From: MikeS
Sent: Thursday, February 14, 2019 6:27:36 AM
To: Doron Holan
Subject: [NTDEV] Installing filter driver as both, upper and lower

OSR https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.osr.com%2F&data=02|01|doron.holan%40microsoft.com|aad5021c769b443f5d2908d692889196|72f988bf86f141af91ab2d7cd011db47|1|1|636857512589226325&sdata=m6H2BjmSAggfFbimB1TcWlBA5gq7CmxCV9ZlaNWDLtg%3D&reserved=0
MikeS started a new discussion: Installing filter driver as both, upper and lower

Hello all,

I am a little bit confused as to how to install my filter driver at both levels, upper and lower.

Should I add two lines to my inf-file, providing the class I want to install the filter with “UpperFilters” and “LowerFilters” keywords?

If so, how can I then identify a level the system is installing the filter to within onDeviceAdd()? Or should I specify somehow the level I want to install the filter while creating the device?

Thank you,

Mike

Thank you, Doron. I will try this out.
P.S.: I was hoping there is an easier way, but, it’s Windows drivers… so, nothing is easy… :slight_smile:

That is not quite a fair assessment. I have never seen the same driver as both an upper and lower filter driver in the same stack, so what you are doing is out of the ordinary. As a result of being on the fringe, you must handle the complexity of the choice you made.

d

Bent from my phone


From: MikeS
Sent: Thursday, February 14, 2019 8:43:17 AM
To: Doron Holan
Subject: Re: [NTDEV] Installing filter driver as both, upper and lower

OSR https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.osr.com%2F&data=02|01|doron.holan%40microsoft.com|ad587aab376549ebd37508d6929b8624|72f988bf86f141af91ab2d7cd011db47|1|0|636857594002101654&sdata=pjCgPo4q4Y%2FUHbil6FCJiyohrTc%2FqL2is8BaRp5P0U8%3D&reserved=0
MikeS commented on Installing filter driver as both, upper and lower

Thank you, Doron. I will try this out.

P.S.: I was hoping there is an easier way, but, it’s Windows drivers… so, nothing is easy…