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!|
|Developing Minifilters||24 May 2021||Live, Online|
|Writing WDF Drivers||14 June 2021||Live, Online|
|Internals & Software Drivers||27 September 2021||Live, Online|
|Kernel Debugging||15 November 2021||Live, Online|