Installing driver on specific device instance

I am working with a AHCI miniport driver that does not expose disks to windows. I have been installing it using [device manager → Update driver] to install it on specific AHCI controllers.

As part of writing an installer, I tried using devcon and it installs it on all matching hardware IDs. This is a problem because it installs on the controller handling the Boot device and breaks the system on the next reboot.

I saw that devcon is using UpdateDriverForPlugAndPlayDevices so I assume it would have the same behaviour even if I were to implement it myself. Is there some way to install drivers on a specific device instance using a installer? I am able to do it with device manager so it is theoretically possible I think.

I think the question comes down to: How would you unambiguously programmatically identify the controller you want to install the driver on. With Device Manager you can choose.

Peter

I would further caution that if your driver is a better match than the inbox driver for the boot device controller; there is still a very likely scenario where your driver is installed on the boot device. All the user/program has to do is search for driver updates on the boot device and your driver will be installed.

Hello Peter
Since the Vendor ID & Device ID of controllers are same, the new driver will be installed on all controllers right? (At least, After a reboot) The PNP manager will only look for VID/PID while loading the driver. So the new driver will be loaded on all controllers with same VID PID. Is my understanding correct?

@“Peter_Viscarola_(OSR)” said:
I think the question comes down to: How would you unambiguously programmatically identify the controller you want to install the driver on. With Device Manager you can choose.

Peter

When I run “listclass hdc” in devcon, I get the device instance ID. It is different for each controller. Of course, this is not a valid input for UpdateDriverForPlugAndPlayDevices.

I get that it might be technically unsupported, but device manager does do it… that’s the whole reason I even ask. I might choose with the GUI but the code still has to identify which GUI element points to which specific device for that to work.

@Doron_Holan said:
I would further caution that if your driver is a better match than the inbox driver for the boot device controller; there is still a very likely scenario where your driver is installed on the boot device. All the user/program has to do is search for driver updates on the boot device and your driver will be installed.

This has not been an issue for me so far. It doesn’t disappear or cross over to other devices after reboots or updates.

I didn’t say it would happen on a reboot. I said if the user goes through the update driver wizard AND your driver package is a better rank than the in box package it will get installed. There is also the scenario where the OS is updated, in this case your driver would be installed on the boot device in the new OS (again only if it has a better rank).

> @Doron_Holan said: > I didn’t say it would happen on a reboot. I said if the user goes through the update driver wizard AND your driver package is a better rank than the in box package it will get installed. There is also the scenario where the OS is updated, in this case your driver would be installed on the boot device in the new OS (again only if it has a better rank). Ahh, okay. I am not really concerned about that since it is not meant to be released in the wild. But I did test right now and searching for best drivers actually installs the default driver onto a device with my driver, so it’s fine.

I don’t know how device manager does it. Then again, I am SO not an installer expert.

Peter

For anyone looking, this CAN be achieved with DiInstallDevice, though you’ll have to implement a custom application.

You need to add your driver to the driverstore first, using devcon or as part of your custom app, then

Use SetupDiGetClassDevs to get device instances, and choose the one you need. You can use Cm_Get_DevNode_Property to see device details.

Use SetupDiBuildDriverInfoList and SetupDiEnumDriverInfo to get a list of supported drivers for your device and select the one you added,
then finally use DiInstallDevice to trigger an installation.

1 Like