A doubt with device co-installer

Hi,

I install a driver for a PCI device by claiming it with 4-point match (VID_DID_SVID_SDID). There is also another driver available for the same device that claims it with 2-point match (VID_DID).
Since I claim it with 4-point match, I get the priority over the other one. Under certain condition however I want to let the other driver own the device. I achieve it with a co-installer which checks for that condition and if necessary loads the other eligible driver using SetupDiEnumDriverInfo, SetupDiGetDriverInfoDetail and SetupDiSetSelectedDriver.

This works fine, but after a system reboot I see that it is still MY DRIVER that is being loaded. Am I missing any step in the co-installer to permanently set the other driver as the default one?

Regards,
Suresh

If the condition is permanent why not just uninstall your driver?

Mark Roddy

On Mon, Feb 13, 2017 at 1:31 PM, wrote:

> Hi,
>
> I install a driver for a PCI device by claiming it with 4-point match
> (VID_DID_SVID_SDID). There is also another driver available for the same
> device that claims it with 2-point match (VID_DID).
> Since I claim it with 4-point match, I get the priority over the other
> one. Under certain condition however I want to let the other driver own the
> device. I achieve it with a co-installer which checks for that condition
> and if necessary loads the other eligible driver using
> SetupDiEnumDriverInfo, SetupDiGetDriverInfoDetail and
> SetupDiSetSelectedDriver.
>
> This works fine, but after a system reboot I see that it is still MY
> DRIVER that is being loaded. Am I missing any step in the co-installer to
> permanently set the other driver as the default one?
>
> Regards,
> Suresh
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

I don’t think this is possible in a coinstaller. By the time the coinstaller gets invoked, the driver has already been selected and you’re in the middle of the install process. If you want that kind of logic, you’re better off using an exe. But even better yet would be to not need that logic, as PNP considers the hardware ID matching to be a contract.

> If the condition is permanent why not just uninstall your driver?

Is it possible to do this seamlessly without user interaction from within the coinstaller?

By the time the coinstaller gets invoked, the driver has already been selected

Isn’t SetupDiSetSelectedDriver supposed to override that default driver? Or is this only for that session?

If you want that kind of logic, you’re better off using an exe

Thanks. What exactly do I need to do in the EXE to achieve this? Also whatever APIs I would use in the exe, wouldn’t they available for use in the coinstaller too?

> Isn’t SetupDiSetSelectedDriver supposed to override that default driver?

Yes, but by the time you’re in the coinstaller, it’s too late to set the driver. You’re already installing a driver at that point. Coinstallers do not get invoked until after a driver has been selected and the install has begun.

Thanks. What exactly do I need to do in the EXE to achieve this? Also whatever APIs I would use in the exe, wouldn’t they available for use in the coinstaller too?

Yes, the APIs are available, but again, it’s too late to change the INF being installed once you’re inside a coinstaller. An EXE would let you run this same code before any installs happen. From an EXE, after you’ve set the selected driver, you can call DiInstallDevice (https://msdn.microsoft.com/en-us/library/windows/hardware/ff544710(v=vs.85).aspx)
and it will install the selected driver.

Thanks Zac for all your help, but I am sorry I misguided you. I have been testing all the while in WinPE (the device in question is SCSI adapter) and noticing that once the OS installation is complete, I still see MY DRIVE claiming the device.
But I see that this behavior is peculiar to WinPE environment.

If I install the OS first and then install my driver with my coinstaller, and say I don’t claim the device, then I see that it works as expected, i.e. even after system reboot it is the ‘other’ driver that gets loaded.

In WinPE, though this seems to work during installation, the ‘selected driver information’ is not preserved when the normal OS boots (i.e. does not get staged).
Is there any API that I am missing to preserve the changes done to the Driver Store in WinPE?

Regards,
Suresh

The driver store is entirely different from the one in WinPE, so anything you do to the WinPE driver store won’t affect the driver store of the main OS. You can use DISM to add a driver to the target OS. There’s an API for DISM: https://msdn.microsoft.com/en-us/library/windows/desktop/hh825834(v=vs.85).aspx

Keep in mind that since the driver has a coinstaller, it will not be installed until the OS is up and running - so on the first boot it may not be running the driver you expect.

Thanks Zac for the tip about DISM.

Keep in mind that since the driver has a coinstaller, it will not be installed
until the OS is up and running

Does this mean that the coinstaller is supposed to run after OS is up and running when the driver was installed using DISM?
I am actually seeing that the coinstaller DOES NOT run at all in this case and have posted in another thread for the confirmation of this behavior.