I am developing a filter driver under Windows. The driver is PnP-aware to receive device notifications and it also creates a control device to communicate with an accompanying usermode service via IOCTLs.
As far as I understand, driver's lifetime is controlled by PnP-manager. The driver is unloaded after processing next device notification given that by that time no device objects are owned by the driver.
What I need to do is to stop the driver on demand, not when the next device arrives/departures. So far I do not think that's the way it's supposed to work, on the other hand I do not see any logic that forbids unloading filter drivers on demand. I researched sending STOP control and I do not see how that can be handled in a PnP driver (works only for legacy drivers).
Right now I'm thinking of adding special IOCTL handler, that would close all device objects. But that's not enough, driver's lifetime is managed by PnP-manager so I need to somehow "bring attention" of the manager to my driver. Any help is appreciated!
If you are wondering, I need the driver to be stoppable so that deinstallation does not require a reboot.