USB Device Driver Load Process

The USBD module takes the following steps when loading drivers, stopping as soon as it finds a driver that accepts control of the device. The following rules describe the algorithm that the USBD module uses to search for USB device drivers. In the descriptions, GroupX_ID refers to a key with the specified group set to one of the forms described in Registry Keys for USB Device Drivers and the remaining groups set to Default. If multiple drivers are registered within the same group, the one that contains the simplest form is loaded first. For example, a driver specifying a Group1_ID with device class code only, such as Default\DeviceClass\Default, loads before a driver specifying a Group1_ID with device class and subclass code, such as Default\DeviceClass_Subclass\Default. This allows Windows CE to conserve resources by loading as few drivers as possible. This proceeds in the following steps:

  1. The USBD module searches for a subkey with the name Default\Default\Default. If present, the module loads the driver listed within the Default\Default\Default\DriverName\DLL subkey. A driver registered in this way is loaded for all USB devices connected to the system.
  2. The USBD module searches for a vendor-specific driver. Vendor-specific drivers are identified by searching for the most general Group1_ID subkey that matches the device descriptor information. The most general subkey is the one that has a matching Group1_ID subkey containing the simplest allowable form and Default for the Group2_ID and Group3_ID subkeys. If a matching subkey is found, the module loads the driver listed within the subkey’s DriverName\DLL subkey. For more information on allowable forms, see Registry Keys for USB Device Drivers.
  3. The USBD module searches for a device-class-specific driver. Class-specific drivers are identified by searching for the most general Group2_ID subkey. If a matching subkey is found, the module loads the driver listed within the subkey’s DriverName\DLL subkey.

The searches in steps 1 through 3 may not yield a matching USBD to control the device as a whole; that is, the device may have multiple interfaces, but no driver identified in steps 1 through 3 may match all of the interfaces present on the device. If so, the USBD module takes the following steps to search for matching drivers for each interface present on the device, searching for the most general Group3_ID subkey. If the USBD module finds a matching subkey, it loads the driver listed within the subkey’s DriverName\DLL subkey.

Finally, if no appropriate USBD is located, the USBD module prompts the user to enter the name of a DLL containing the correct driver. The USBD module then loads the driver and calls the driver’s USBInstallDriver function. USBInstallDriver should create an appropriate subkey for the driver by calling the RegisterClientSettings function so that the next time that the USB device is attached, the USBD module can locate the correct driver without prompting the user.

In some cases it may be necessary to specify the precedence order to a greater level of detail, for example, combining a vendor and device class specifiers. In these cases, the GroupX_ID values may be combined to generate other combinations. The precedence for such combinations is as follows, in descending order:

  1. Group1_ID\Default\Default
  2. Group1_ID\Group2_ID\Default
  3. Default\Group2_ID\Default
  4. Group1_ID\Group2_ID\Group3_ID
  5. Group1_ID\Default\Group3_ID
  6. Default\Group2_ID\Group3_ID
  7. Default\Default\Group3_ID

If multiple drivers are registered at a particular precedence level, the USBD module loads the one with the most general form.