We have a USB Bus driver and a Function driver. During SurpriseRemoval, Function driver disable its interface, so that OS Services can close the Open Handle to the driver.
WDF calls the D0Exit and ReleaseHardware of Function driver, and the calls EvtDeviceFileClose. The delay in WDF callback EvtDeviceFileClose, doesnt allow the filter driver to unload. Meanwhile, even though the Bus driver is in Releasehardware.
Meanwhile OS calls a AddDevice to the BusDriver, which cant be handled as this stage as we have already started the cleanup, and we have to return a error for Adddevice.
Is there a way, we can ask Framework not to do a Addevice, until the driver unloads completely ? or can EvtDeviceFileClose on Function driver be called before ReleaseHardware callback on Function driver ?