I have been working on a legacy driver that attaches to the CdRom devices to filter IOCTLs in Device_Control. All of this works as expected but I have problem that I seem be be having a hard time locating. The problem is reproduced by starting my driver at say system startup and then either creating a new USB style CD or by inserting a CD to read that causes the udfs file system to attach to the CD device. If I stop my driver it looks as though it works fine but the next time I try and start it I get “[SC] StartService FAILED 2” and the only way I have been able to restart the driver is to reboot the machine. If I just burn CD’s or don’t do anything, I can stop and start the driver as many time as I want. Does the file system manager make an attachment to my driver that would prevent it from reloading and if so can I remove it? I remove my attachment to the next lower driver and then call IoDeleteDevice for my device in my DriverUnload routine. Are there any other possibilities that would cause this?
Looking at device tree, it would look like this:
\device\CdRom0
– att \device\MyDriver
– fs \filesystems\udfs
---- att \filesystem\FltMgr
Also if I put in a CD and the filesystem attaches before I load my driver, it all works as expected. If I then open the CD drive and close causing a cd to load then it has this same load-unload-fail problem.
Thanks in advance for any assistance.