Is there a way to call a WDM root-enumerated driver from another WDM PnP driver?

The WDM PnP driver was originally designed to be a bus enumerator for the serial ports of a USB to serial converter. Thus the serial ports are child devices of a USB device. The problem is that when the USB device is disconnected, the Device Manager removes the child devices (serial ports) and the application handle for an open serial port becomes invalid. I’d like to have a separate root-enumerated bus enumerator enumerate the serial ports so that if they (the serial ports) don’t get removed when the USB to serial converter gets disconnected. Is there a way to call into the root-enumerated driver from the WDM PnP driver if the root-enumerated driver exports an interface?

Sure. Why not have the enumerator register a device interface (IoRegisterDeviceInterface)? If you’re sure that the way you want to go.

I just recently spent time considering this problem, so I’ll pass along a bit of a warning: Consider the fact that an app using the serial port can set/change various setting, and that these will be reset to their defaults when a device goes away and later returns. Seems to me you need some way to track these and re-establish them, no?

Peter

Thanks, Peter. I was aware of the problem of having to save the serial port’s state and restore it when it returns. So once the enumerator registers a device interface, how would I call it. I’m assuming there’s some way of getting its device object and calling it with IoCallDriver?

In the OTHER driver (the one that does NOT register the device interface), use IoRegisterPlugPlayNotification. That’ll give you the PDEVICE_OBJECT that you can use to send IRPs.

If you’re going to write this second driver, I’d really recommend you use WDF… and you can STILL call IoRegisterPlugPlayNotification. Just create a Remote I/O Target using the returned DEVICE_OBJECT pointer.

Peter

When the other driver calls IoRegisterPlugPlayNotification, will the callback be dispatched if the interface is already enabled? Or does it only callback when it changes? The reason I ask is that I’m planning to have the root-enumerated driver register an interface as soon as it starts. which could before the other driver calls IoRegisterPlugPlayNotification.

The doc page for IoRegisterPlugPlayNotification answers your question. Did you read it?

1 Like

Thanks Doron. I read it over quite well (I thought) but missed it :frowning:
“Only valid with an EventCategory of EventCategoryDeviceInterfaceChange. If set, the PnP manager calls the driver callback routine for each device interface instance that is currently registered and active and registers the callback routine for future arrivals or removals of device interface instances.”