0
votes

I'm trying to have WDK7 Toaster's bus device and child devices share a same .sys driver file. I combine the busenum.sys and toaster.sys into a single Nls_ufcom.sys(bus.inf and toaster.inf both refer to the same Nls_ufcom.sys as service binary), but Windows reports error 38(CM_PROB_DRIVER_FAILED_PRIOR_UNLOAD) for the child device after I assign toaster.inf as the driver from Device Manager. So, the AddDevice() callback is even not called for the child device.

I'm not sure whether I have done something wrong, or Windows really don't allow this. Wish to get some idea from you, Thank you.

enter image description here

enter image description here

1
My experience is that WDF discourages developers from making a single function driver for multiple device setup classes. You can always install multiple copies of you driver, each containing an INF file for one device class. It is also possible to put the whole logic into a (virtual) bus driver that spawns raw PDOs (PDOs that do not need function drivers). You can make a driver that act as an lower/upper filter for multiple device classes.Martin Drab

1 Answers

2
votes

I find out the reason. The reason is: I use different service name in bus.inf and toaster.inf . Apparent conclusion from my case, Windows does not allow two driver services to have [ the same service binary but difference service name ] .

The driver service name is the sub-key under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services .

Assigning the same service name in bus.inf and toaster.inf, then the driver is loaded successfully by both devices.

MSDN CM_PROB_DRIVER_FAILED_PRIOR_UNLOAD's statement is so vague and misleading(since Vista era), which says:

Additionally, this message can appear if a driver is referenced by multiple INF AddService directives in one or more INF files.

-- It does not point out the key problem.

[2017-07-01] Ten months later, I come back to make a confirmation, this sharing sys trick work great from Windows XP SP2 to latest Windows 10.1703, no problem identified until now. I apply this trick in my UFCOM virtual COM port driver so successfully.