I have a mini-filter driver that’s been working great for several years now - no reported BSODs. The driver monitors the system for file and registry events, and writes certain events to a log file. We have a new requirement that the driver should work through a reboot process.
The problem I’m running into, I can’t seem to get the driver to write to the file on disk during system shutdown. I have a flush routine that calls the ZwXXX APIs and it works if the driver is stopped via ControlService(). But when the system is powered down or rebooted I get no file output. I’ve tried flushing the file from my DriverUnload and FilterUnload routines with no luck. I registered for the IRP_MJ_SHUTDOWN event and tried flushing there, but still no output. My guess is the IRP_MJ_SHUTDOWN event is happening after the file system has been shutdown. Is there another event I can trigger on? I’ve read some people talking about IRP_MJ_POWER. Honestly, I don’t even know if my shutdown handler is getting called. Is there a way I can know for sure my handler is getting called? I added KeBugCheck() to the shutdown handler but go no BSOD on shutdown.
I primarily program in user-mode, so anytime I’m down at the driver level it’s a humbling experience. So any help would be greatly appreciated. Thanks.