The problem:
There are two KMDF drivers: driverA and driverB. These drivers do not belong to the same driver stack.
The driverA creates device, this device creates interface (using WdfDeviceCreateDeviceInterface()), using specific GUID.
The driverB needs to be notified on each change of the state of this interface, even if it was created before driverB was loaded.
The driverB knows the interface GUID only.
Good question
Mainly because I see WDF as a tool that facilitates working on drivers, and I intuitively expect that everything will be easier
But more seriously, the main difficulty associated with using the IoRegisterPlugPlayNotification() function is that the callback cannot directly open a device - it is necessary to use the WorkItem mechanism. This is not a big problem, but I was hoping that WDF provides an equivalent function without such a limitation.
@PiotrG said:
Good question
Mainly because I see WDF as a tool that facilitates working on drivers, and I intuitively expect that everything will be easier
But more seriously, the main difficulty associated with using the IoRegisterPlugPlayNotification() function is that the callback cannot directly open a device - it is necessary to use the WorkItem mechanism.
It’s safe to open from within the callback routine as long as the target driver doesn’t trigger synchronous PnP operations from within its IRP_MJ_CREATE/EvtDeviceFileCreate callback. There used to be a case where an inbox driver stack did this (HID maybe?) and the documentation turned that into a generic statement of “don’t do it” (which we also perpetuated for a while)
SWENUM was the driver that caused the doc warning as it enumerated virtual audio/media devices on create. I would have never designed that behavior into HIDClass :).