Microsoft KB Archive/279112

= How Windows determines the most suitable device driver to install during Setup =

Article ID: 279112

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows XP Professional
 * Microsoft Windows XP Home Edition
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Professional Edition
 * Microsoft Windows Small Business Server 2003 Premium Edition
 * Microsoft Windows Small Business Server 2003 Standard Edition

-



This article was previously published under Q279112



SUMMARY
This article describes the process that is used to select the most suitable device driver for a device during Setup.

When you run Windows Setup, you may have more than one set of device drivers or .inf files that work with a particular device. Both Setup and Plug and Play attempt to resolve these conflicts by selecting the device driver that is the most suitable match for the device that is being installed.

NOTE: This article only describes the process that is used for the devices that are being installed during the graphical user interface (GUI) phase of Setup or after Setup is complete. The mass-storage controller detection and device-driver selection processes that are performed during the Text mode portion of Setup follow a different process.



MORE INFORMATION
For more information about the mass-storage controller detection process, click the following article number to view the article in the Microsoft Knowledge Base:

220845 Adding third-party or updated driver during Windows Setup

Plug and Play attempts to locate a compatible device driver by comparing the Plug and Play Identifications (IDs) of the hardware (returned by the device firmware or system BIOS at the time the device had been enumerated) with any matching Plug and Play IDs that are located in the .inf files.

Plug and Play can search all the .inf files for the most suitable device driver to install for a particular device. Plug and Play does not stop its search on the first match that Plug and Play finds. Plug and Play continues to search all the .inf files that are listed in the search path of Plug and Play, as defined in the following registry entry:

HKEY-LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion

DevicePath:Reg_Expand_SZ:%Systemroot%\Inf

NOTE: By default, the preceding registry location only contains this single entry, however, extra paths may be appended to this entry when you perform an unattended Setup and the OemPnpDriversPath = parameter is used in the Unattended Answer file.

Setup builds a list of compatible device drivers that contained a match in an .inf file and assigns a &quot;rank&quot; for each one that had been located. The rank can range from &quot;0&quot; to &quot;0xFFFF&quot; with 0 being the most suitable possible match and 0xFFFF the worst possible match. The device driver with the lowest rank is considered the most suitable possible match and is the device driver installed.

The device driver rankings have the following ranges:
 * 0x0 to 0xfff: The device hardware ID matched with a hardware ID listed in an .inf file.
 * 0x1000 to 0x1fff: The device hardware ID matched one of the compatible IDs in an .inf file.
 * 0x2000 to 0x2fff: One of the devices compatible IDs matched with the hardware ID in an .inf file.
 * 0x3000 to 0x3fff: One of the devices compatible IDs matched with the compatible ID in an .inf file.
 * 0xFFFF: The worst case match.



In Windows XP and Windows Server 2003, there are additional device driver rank ranges:
 * 0x8000 to 0x8FFF: Untrusted Hardware ID matches
 * 0x9000 to 0x9FFF: Untrusted compatible ID matches

Some .inf files may be in the untrusted range if they are not digitally signed or if the Model section name does not contain Windows NT-specific decorations (the device can be installed on Windows NT, Windows 95, or Windows 98, but the device does not have specific entries for these operating systems).

If Setup determines that a device driver is untrusted, Setup can change the device driver rank into the preceding appropriate ranges.

Device driver ranks in the range of 0x0 to 0xfff are called &quot;Hardware ID matches&quot; because they match hardware ID to hardware ID. These ranks are also considered the most suitable matches and any other ranks are listed as &quot;compatible&quot; because there is at least one compatible ID in building the device driver rank. Class installers and co-installers can also affect the selection of the device driver by flagging the device driver as &quot;invalid&quot; if the installer determines that the device driver is unable to support the device, or if the installer changes the rank of a device driver.

However, if two device drivers have the same lowest rank, Setup uses the device driver with the most recent date. If one of the device drivers is signed and the other device driver is unsigned, the unsigned device driver date is assigned a value of 0xFFFFFFFF, and the signed device driver is selected and installed.

It may be possible to supply an OEM-supplied device driver, but it may not be selected and used. Even though a manufacturer has supplied an updated device driver, it may have only been written as a compatible device driver which can give it a higher rank number that results in a worse match. Setup does not consider whether the OEM-supplied device driver is digitally signed when Setup selects a device driver match. If the unsigned device driver has a lower rank and is a better match than any other in-box device driver, that device driver can be selected and installed by Setup.

When you run Setup, if a match is not found in any .inf file, the device installation is postponed and the device may become an unknown device in Device Manager. If a new device is introduced (not during Setup) and a match is not found in any .inf files on the computer, you can receive a &quot;New Hardware Found&quot; prompt and you can be asked to supply a device driver.

For example, you have a computer that has a PCI video adapter with a Plug and Play ID that is displayed in two different .inf files, Nv3_disp.inf and Nv4_disp.inf. Neither of these device driver files are digitally signed so both of the device driver dates are assigned a value of 0xFFFFFFFF. In this example, these files are located in the following D:\Drivers\Video1 and D:\Drivers\Video2 folders.

The current Devicepath= in the registry has the %Systemroot%\Inf;%Systemdrive%\Drivers\Video1;%Systemdrive%\Drivers\Video2 entries.

NOTE: The %Systemroot% is D:\Winnt and %Systemdrive% is D:

Both Setup and Plug and Play searches all the .inf files found in these preceding paths and records any matches that are found. If either Setup or Plug and Plug finds more that one match, the most suitable match is used.

The following excerpt from the Setupapi.log file details the preceding process. For this example, the Logging mode for setup had been placed in the Verbose mode by using the following article:

243996 How to enable Verbose Logging in Windows 2000 GUI-Mode Setup

If Setup runs normally, you do not observe this much detail in the Setupapi.log file.

When a device is queried, it returns a list of hardware IDs and compatible IDs. Not all devices return multiple IDs, but in most cases, they do. In this example, a video card returns the following IDs: Searching for hardware IDs: Pci\Ven_10de&dev_0028&subsys_5a001092&rev_11, Pci\Ven_10de&dev_0028&subsys_5a001092, Pci\Ven_10de&dev_0028&cc_030000, Pci\Ven_10de&dev_0028&cc_0300 Searching for compatible IDs: Pci\Ven_10de&dev_0028&rev_11, Pci\Ven_10de&dev_0028, Pci\Ven_10de&cc_030000, Pci\Ven_10de&cc_0300, Pci\Ven_10de,pci\cc_030000, Pci\Cc_0300 Enumerating files D:\Winnt\Inf\*.inf @ 07:11:59.191 : Opened PNF of &quot;D:\Winnt\Inf\1394.inf&quot;. @ 07:11:59.191 : Opened PNF of &quot;D:\Winnt\Inf\accessor.inf&quot;. @ 07:11:59.191 : Opened PNF of &quot;D:\Winnt\Inf\acpi.inf&quot;. @ 07:11:59.191 : Opened PNF of &quot;D:\Winnt\Inf\adm_mult.inf&quot;. @ 07:11:59.191 : Opened PNF of &quot;D:\Winnt\Inf\adm_port.inf&quot;. @ 07:11:59.207 : Opened PNF of &quot;D:\Winnt\Inf\agtinst.inf&quot;. . . . Enumerating files D:\Drivers\Video1\*.inf @ 07:12:00.660 : Opened PNF of &quot;D:\Drivers\Video1\NV4_DISP.inf&quot;. @ 07:12:00.660 : The file (D:\Drivers\Video1\NV4_DISP.inf) is not digitally signed, ignoring driver date. @ 07:12:00.660 :Found Pci\VEN_10DE&DEV_0028 in D:\Drivers\Video1\NV4_DISP.inf; Device: NVIDIA RIVA TNT2; Driver: NVIDIA RIVA TNT2; Provider: NVIDIA; Mfg: NVIDIA; Section: nv4 @ 07:12:00.660 : Decorated section name: nv4 Enumerating files D:\Drivers\Video2\*.inf @ 07:12:00.660 : Opened PNF of &quot;D:\Drivers\Video2\NV3_DISP.inf&quot;. @ 07:12:00.675 : The file (D:\Drivers\Video2\NV3_DISP.inf) is not digitally signed, ignoring driver date. @ 07:12:00.675 : Found PCI\VEN_10DE&DEV_0028 in D:\Drivers\Video2\NV3_DISP.inf; Device: NVIDIA RIVA TNT2; Driver: NVIDIA RIVA TNT2; Provider: NVIDIA; Mfg: NVIDIA; Section: nv4 @ 07:12:00.675 : Decorated section name: nv4 @ 07:12:01.706 : Device install function: DIF_SELECTBESTCOMPATDRV. @ 07:12:01.706 : Executing class installer. @ 07:12:01.894 : Completed class installer. @ 07:12:01.894 : Executing default installer. @ 07:12:01.894 : Selected driver installs from section nv4 in D:\Drivers\Video1\Nv4_disp.inf. @ 07:12:01.894 : Changed class GUID of device to {4D36E968-E325-11CE-BFC1-08002BE10318}. @ 07:12:01.894 : Set selected driver. @ 07:12:01.894 : Selected best compatible driver. @ 07:12:01.894 : Completed default installer. @ 07:12:06.565 : Device install function: DIF_ALLOW_INSTALL. @ 07:12:06.565 : Executing class installer. @ 07:12:06.565 : Completed class installer. @ 07:12:06.581 : Device install function: DIF_INSTALLDEVICEFILES. @ 07:12:06.581 : Executing class installer. @ 07:12:06.581 : Completed class installer. @ 07:12:06.581 : Executing default installer. In the example output, Setup selected and installed the device driver by using the D:\Drivers\Video1\Nv4_disp.inf file because Setup found that device driver to be the most suitable match.

To easily locate the installed devices and the .inf files that had been used to install the device, open the %Systemroot%\Setupapi.log file in Windows Notepad and search for DIF_SelectBestCompatDrv for Plug and Play installed devices or DIF_SelectDevice for devices that had been installed manually.

Keywords: kbenv kbinfo kbsetup KB279112

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.