The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.
Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/
Hi, I am debugging a KMDF-based PNP driver that creates dozens of Control Devices (CDOs) per FDO for legacy compatibility reasons. The driver creates the CDOs in EvtDevicePrepareHardware with WdfDeviceCreate and deletes them in EvtDeviceReleaseHardware with WdfObjectDelete. Apparently, WDF waits forever for the state machine of the m_DefaultQueueForCreates if a IRP_MJ_CREATE is completed on a CDO that is about to be deleted.
If your driver creates control device objects (which do not support PnP or power management), and if the driver also creates framework device objects that support PnP and power management, the driver must eventually call WdfObjectDelete at IRQL = PASSIVE_LEVEL to delete the control device objects.
If the driver creates both types of device objects, the operating system cannot unload your driver until the driver has deleted the control device objects.
However, the driver must not delete the control device objects until after the framework has deleted the other device objects. To determine when the framework has deleted the other device objects, your driver should provide EvtCleanupCallback functions for those objects.
The last paragraph irritates me: to my understanding the paragraph means that the only valid point to delete the CDOs is the EvtCleanupCallback of the FDO (as demonstrated in the toastDrv sideband sample), because (1) the CDO must outlive the FDO and (2) the PNP manager will not unload the driver if DOs remain after the FDO is cleaned up, as discussed in https://community.osr.com/discussion/128797/control-device-inhibits-unload.
My current understanding contradicts (1): CDOs and FDOs are unrelated and therefore have independent lifetimes, so the driver may delete CDOs at any time. Is this correct or does the paragraph hint at a restriction that I am not aware of? In case it is relevant: the FDO and each CDO have their own WdfIoQueue and all Ioctls are completed in the IrpPreprocessCallback.
Thanks for helping.
|Upcoming OSR Seminars|
|OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!||Kernel Debugging||30 Mar 2020||OSR Seminar Space|
|Developing Minifilters||15 Jun 2020||LIVE ONLINE|
|Writing WDF Drivers||22 June 2020||LIVE ONLINE|
|Internals & Software Drivers||28 Sept 2020||Dulles, VA|