Plug and Play Overview: How Windows Finds Drivers for USB Devices

By LookinAround
May 20, 2009
Topic Status:
Not open for further replies.
  1. Plug and Play Overview: How Windows Finds Drivers for USB Devices
    Understanding the gnarly detail and workings of Windows Plug and Play and Drivers is a black art. (After tinkering with Windows' internals and trying to read up over the last many years, i'd say my knowledge is, at best, still a lighter shade of grey!) But I’ll attempt to paint the “10,000 foot” overview as best I can

    Let’s start with some basics
    Plug-and-Play (PnP)
    Plug and Play (PnP) describes a method of operation for
    >> Your computer's hardware data "bus" and
    >> Devices that connect to that hardware bus

    Plug-And-Play:
    • Facilitates discovery of PnP compliant hardware devices attached to a PnP compliant bus
    • Shouldn't require user intervention to physically configure a device. Note that PnP works because it's an international technical standard
    Universal Serial Bus (USB)
    USB is just one of several different types of data buses on your computer. The USB spec is designed to allow many devices to connect to USB using a single standardized interface socket and to improve plug and play capabilities by allowing hot swapping; that is, by allowing devices to be connected and disconnected without rebooting the computer or turning off the device. USB is another international technical standard

    Device Identification Strings
    PnP compliant devices are assigned a set of Device Identification Strings by their manufacturer. These strings are programmed into the device when it's built. These strings are fundamental to how PnP works: they are part of the Windows' information source used to match the device with a suitable driver
    There are 3 types of Device Identfication Strings
    • Device ID
      => The device ID is a vendor-defined identification string. A device has one and only one Device ID
      => The Device ID has the same format as Hardware IDs (described next)
    • Hardware IDs
      => Hardware IDs are also vendor-defined identification strings. A device has one or more Hardware IDs
      => By definition, the Device ID is always the first in the list of a device’s Hardware IDs
    • Compatible IDs
      Compatible IDs indicate that a device is compatible with and can use another device's driver. A device has zero or more Compatible IDs
    Example list of a USB device's Hardware IDs (by definition, the first in the list is the Device ID)
    => USB\VID_03F0&PID_6B11&REV_0100&MI_03
    => USB\VID_03F0&PID_6B11&MI_03


    Example list of a USB device's Compatible IDs
    => USB\Class_08&SubClass_06&Prot_50
    => USB\Class_08&SubClass_06
    => USB\Class_08

    Device Names
    Device Names are those nice human friendly strings we see displayed in Device Manager
    => The Device Name is NOT a Device Identification String! It is simply a comment as far as Windows is concerned
    => That's why people are often confused and frustrated when they find a driver based on Device Name yet the driver won't work or even install!
    => A driver must correctly match a device's Device Identification strings or "all bets are off"!
    => Ever try to install a driver only to get "No matching device" errors? That's 'cuz Windows couldn't match the driver to any of your device's Device Identification Strings!

    Driver Installation Setup Files
    Each driver has an installation setup (.inf) file associated with it. During a PnP install
    => Windows searches directories on your computer. (Your registry tells it which diretories to check)
    => Windows collects all the driver .inf files it finds on your computer

    Each driver installation file (i.e. each inf file)
    => Instructs Windows which Device Identification Strings “match up” with the driver as well as telling Windows just how good a match the device and driver would make
    => Provides Windows instructions which help it install the driver for the current operating system and system configuration environment
    USB Plug and Play
    So Plug and Play sounds great, right? Well, it is... when everything works right (which is why it's sometimes also called "Plug and Pray"!) PnP requires all its pieces (like device firmware, Device Identification string assignments, hardware detection, software drivers and more) are in place and occur in their proper sequence for PnP to work

    Generally, this is what should happen for USB PnP
    • USB device is plugged into USB port
    • PC detects a hardware change has occurred on the USB bus
    • PC “pings” the USB device for its Device Identification Strings (using standard USB protocol)
    • USB device responds to PC with its Device Identification Strings (also using standard USB protocol)
    • Windows searches directories on your computer looking for the Driver Installation Setup files
      >> Windows only searches through a limited and defined set directories (as defined within your registry)
      >> Windows collects a set of driver candidates. It compares Device Identification Strings it received from the hardware vs. the ones it finds defined in the .inf file to determine if the driver is a possible match for the hardware device
    • During driver selection process
      • Windows makes a first pass going through all the .inf files to create a list of "driver candidates"
      • Next pass, Windows numerically "ranks" each driver candidate for suitability. Windows "ranking" algorithm includes details like which ID matched the driver (e.g. Device ID match is far better match then a Compatible ID match) and whether or not the driver is digitally signed
      • Finally, Windows installs the driver with the lowest numerical rank (the candidate with the lowest numerical rank value is the best match)

    You can view the IDs for your own USB devices
    Open Device Manager, rt click your USB device select Properties and click the Details tab. Use the pull down menu to see
    => Hardware IDs (and, of course, Device ID is always first in the list)
    => Compatible IDs
    => Matching ID (the ID Windows used to finally match and rank its final driver selection)
  2. B00kWyrm

    B00kWyrm TechSpot Paladin Posts: 1,550   +18

    Great generalized update to your Webcam tutorial!
    Based on that earlier piece, I had made some of these extrapolations. Good Summary!

    I think you mean "Plug and Pray" not "Plug and Prey"?
  3. LookinAround

    LookinAround TechSpot Chancellor Topic Starter Posts: 8,284   +153

    :haha: Thanks for catching the typo!

    The typo wasn't intentional.. but i suppose in some ways it might be viewed as plug and "prey" on the poor user hoping it works like it's supposed to! :D
Topic Status:
Not open for further replies.


Add New Comment

TechSpot Members
Login or sign up for free,
it takes about 30 seconds.
You may also...


Get complete access to the TechSpot community. Join thousands of technology enthusiasts that contribute and share knowledge in our forum. Get a private inbox, upload your own photo gallery and more.