Driver Order Dependency

I have 2 device drivers that must communicate with each other. One must load first, and the other one queries it for specific information.

Is there a way to specify a driver’s dependency on another, so that it does not load until the first is loaded?

No, there is not. Use device interfaces and register for device interface notifications (see the toaster toastmon sample) to know when the dependency is satisfied.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Friday, March 8, 2013 10:06 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Driver Order Dependency

I have 2 device drivers that must communicate with each other. One must load first, and the other one queries it for specific information.

Is there a way to specify a driver’s dependency on another, so that it does not load until the first is loaded?


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

That would depend on how these drivers are started. Are they legacy
(kernel service) drivers or PnP drivers?

Cheers,
Dave Cattley

They are PnP drivers. I think Doran’s solution should work.

> They are PnP drivers. I think Doran’s solution should work.

You need to then think in terms of the lifetime of the devices, not the
drivers.

If the drivers service DOs in the same stack, then stack order (Upper/Lower
filter) can be used to determine order.

If the drivers are for devices in unrelated device stacks, then you are
exactly right: Doran’s solution great advise.

Depending on what you are doing, the Network Module Registrar (NMR) might
also be an option.

Good Luck,
Dave Cattley

Thanks guys. Driver notifications was the solution. I simply added a EvtDeviceSelfManagedIoInit callback where I registered the notification (and of course the appropriate cleanup callback).

When I get a notification a driver dependency has been disabled or removed, I mark my current driver as disabled (WdfDeviceSetDeviceState). However, when I call WdfFdoRetrieveNextStaticChild to mark each of the children as missing…I get NULL as a return value. However, on normal device shutdown, when EvtDeviceCleanup is called, I get the correct children from the call to WdfFdoRetrieveNextStaticChild. Any suggestions??

Well…I fixed this by adding ‘WdfRetrieveAllChildren’ to the call. However, I get a bug check because my bus driver’s EvtDeviceAdd call finishes before its children are removed. Any suggestions?

It’s only a problem because I don’t want ‘MmUnmapIoSpace’ to be called until the children have been removed or stopped.

Alas…nevermind. The child device is a miniport driver, and its OID function handler was getting called before the HALT handler…I have to add code to return NDIS_STATUS_NOT_ACCEPTED once a surprise removal event occurs