windows not detecting new devices enumerated properly

I am installing my drivers via the difx extension in the WiX installer,
and it works perfectly most of the time, but sometimes a ‘Scan for new
hardware changes’ in device manager is necessary to get everything
detecting properly.

I have tried installing the drivers for the enumerated devices first,
and then the bus driver, and the other way around. When I install the
bus driver first though, windows detects new hardware for which it
doesn’t (yet) have a driver and so pops up the dialog to ask the user
what to do about it.

Sometimes, if you wait long enough (5-10 minutes), windows finally
notices that the new devices have appeared and assigns drivers etc, and
other times it never happens.

Is there some WDF trick I need to do to trigger windows to detect new
hardware after I call (in my EvtChildListScanForChildren I am doing
WdfChildListBeginScan/WdfChildListEndScan etc)?

I am hoping to work around it by having the installer make an api call
to “scan for new hardware changes” but that doesn’t appear to be
possible. The best I can come up with is to trigger an ‘add new
hardware’ dialog via rundll, which is messy.

Thanks

James

IoInvalidateDeviceRelations type BusRelations for the PDO of the bus
device for all your child devices ought to cause a re-enumeration. If
your bus driver is installed and if it produces new child devices when
the enumeration request reaches it, pnp will run for those new child
devices.

If this works from ‘scan for new hardware’ from device manager then
your install program should be able to do the same thing from user
mode. Device manager is just a user mode app. Unfortunately the
documentation for the Cm API used by DeviceManager has been obscured
by Microsoft. (It used to be somewhat documented in early DDKs - now
it seems to be gone.)

Mark Roddy

On Sun, May 17, 2009 at 1:18 AM, James Harper
wrote:
> I am installing my drivers via the difx extension in the WiX installer,
> and it works perfectly most of the time, but sometimes a ‘Scan for new
> hardware changes’ in device manager is necessary to get everything
> detecting properly.
>
> I have tried installing the drivers for the enumerated devices first,
> and then the bus driver, and the other way around. When I install the
> bus driver first though, windows detects new hardware for which it
> doesn’t (yet) have a driver and so pops up the dialog to ask the user
> what to do about it.
>
> Sometimes, if you wait long enough (5-10 minutes), windows finally
> notices that the new devices have appeared and assigns drivers etc, and
> other times it never happens.
>
> Is there some WDF trick I need to do to trigger windows to detect new
> hardware after I call (in my EvtChildListScanForChildren I am doing
> WdfChildListBeginScan/WdfChildListEndScan etc)?
>
> I am hoping to work around it by having the installer make an api call
> to “scan for new hardware changes” but that doesn’t appear to be
> possible. The best I can come up with is to trigger an ‘add new
> hardware’ dialog via rundll, which is messy.
>
> Thanks
>
> James
>
> —
> NTDEV is sponsored by OSR
>
> 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
>

Mark Roddy wrote:

If this works from ‘scan for new hardware’ from device manager
then your install program should be able to do the same thing
from user mode. Device manager is just a user mode app.
Unfortunately the documentation for the Cm API used by
DeviceManager has been obscured by Microsoft. (It used to be
somewhat documented in early DDKs - now it seems to be gone.)

I’ve used code like this in the past to force a rescan:

DWORD devInst;

CM_Locate_DevNode(&devInst, 0,
CM_LOCATE_DEVNODE_PHANTOM);
CM_Reenumerate_DevNode(devInst,
CM_REENUMERATE_SYNCHRONOUS);

…followed by a call to CMP_WaitNoPendingInstallEvents() if you want to wait until any new devices that were detected were successfully installed.