installing the same filter for multiple classes

Hi experts,
imagine I have a few SIMPLE and MINIMAL KMDF filter drivers targeted for a few driver classes.
Is it possible to integrate all of them into one filter but install that one filter in multiple places?
well at least I have seen in devcon help for classFilter that it was showing as a sample that a filter is installed multiple times between other filter instances for the same driver class!
But in my case I want to combine a few filters and install for different classes.
Of course I consider IOCTLs and filtering logic must not collide or it will not be worth doing so.
I want to learn if you know of any other consideration encouraging or discouraging this combination

Of course you can, although it’s not clear why you would want to. The filter install process just needs a service name. It doesn’t matter how many clients are referring to that service. You’d have to fetch the PDO’s hardware identifier to figure out which device each instance is handling.

Remember that you can’t replace the filter binary until ALL of the instances have been unloaded.

Thanks for answering. And that note for the hwid!
About the reason:
Since the functionality would be minimal as designed and there might be a few classes to filter. I thaught it would be better to combine the projects and have one project instead of multiple.

Well, it might be. There’s a cost/benefit analysis here. If the filters are all doing pretty much the same tasks, then your benefit is reduced code duplication, and maybe that pays in the end. If you’re just doing it to reduce the number of files, then that’s not a good reason.

Kind of both!
Just wanted to confirm this is not a big fault for some reason unknown to me!
I will do the pros vs cons analysis later when the time comes.
Thanks again.

I’m working on a project right now that uses one driver to filter two different classes. The processing is slightly different but there is a lot of overlap and having it in two binaries would be a pain.

Note that you can use WdfFdoInitAllocAndQueryProperty in EvtDriverDeviceAdd to get the class name or GUID for the arriving device.

1 Like

Scott beat me to it. I just suggested that same function in another thread here!

Peter

:smiley:
Thanks for the function introduction