The operating system, drivers, and device installation components store information about drivers and devices in the registry. In general, drivers and device installation components should use the registry to store data that must be maintained across reboots of the system. Drivers can access the registry to obtain this information.
Registry contents should always be treated as untrusted, modifiable information. If one of your driver components writes information to the registry and another component reads it later, do not assume that the information has not been modified in the meantime. After reading information from the registry, your driver components should always validate the information before using it.
For more information about the registry in general, see the Platform SDK documentation.
The following trees in the registry are of particular interest to driver writers (where HKLM represents HKEY_LOCAL_MACHINE):
Drivers must access Plug and Play (PnP) keys in the registry using system routines such as IoGetDeviceProperty or IoOpenDeviceRegistryKey. User-mode setup components should use device installation functions such as SetupDiGetDeviceRegistryProperty or SetupDiOpenDevRegKey. The registry can be accessed from INF files using INF AddReg directives.
Drivers must not access these keys directly. This discussion of registry information is solely for debugging a device installation or configuration problem.
The keys under HKLM\SYSTEM\CurrentControlSet are a safe place to preserve data that is vital to your driver because the data is stored in the system hive. The system takes extra precautions to protect the system hive (for example, keeping multiple copies).
The HKLM\SYSTEM\CurrentControlSet\Services registry tree stores information about each service on the system. Each driver has a key of the form HKLM\SYSTEM\CurrentControlSet\Services\DriverName. The PnP Manager passes this path to a driver in the RegistryPath parameter when it calls the driver's DriverEntry routine. A driver can store global driver-defined data under its key in the Services tree. Information stored under this key is available to the driver during its initialization.
The following keys and value entries are of particular interest:
The HKLM\SYSTEM\CurrentControlSet\Control registry tree contains information for controlling system startup and some aspects of device configuration. The following subkeys are of particular interest:
Each class subkey contains other subkeys known as software keys (or, driver keys) for each device instance of that class installed in the system. Each of these software keys is named by using a device instance ID, which is a base-10, four-digit ordinal value.
The HKLM\SYSTEM\CurrentControlSet\Enum registry tree contains information about the devices on the system. The PnP Manager creates a subkey for each device, with a name in the form of HKLM\SYSTEM\CurrentControlSet\Enum\enumerator\deviceID. Under each of these keys is a subkey for each device instance present on the system. This subkey, which is known as the device's hardware key (or, device key), has information such as the device description, hardware IDs, compatible IDs, resource requirements, and so forth.
The Enum tree is reserved for use by operating system components, and its layout is subject to change. Drivers and user-mode Setup components must use system-supplied functions, such as IoGetDeviceProperty and SetupDiGetDeviceRegistryProperty, to extract information from this tree. Drivers and Setup applications must not access the Enum tree directly. You can view the Enum tree directly using the registry editor when debugging drivers.
The HKLM\SYSTEM\CurrentControlSet\HardwareProfiles registry tree contains information about the hardware profiles on the system.