Driver Information in the Registry

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 Tree

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:

ImagePath
A value entry that specifies the fully qualified path of the driver’s image file. Setup creates this value using the required ServiceBinary entry in the driver's INF file. This entry is in the service-install-section referenced by the driver's INF AddService directive. A typical value for this path is %windir%\system32\Drivers\DriverName.sys, where DriverName is the name of the driver’s Services key.
Parameters
A key used to store driver-specific data. For some types of drivers, the system expects to find specific value entries. You can add value entries to this subkey using AddReg entries in the driver's INF file.
Performance
A key that specifies information for optional performance monitoring. The values under this key specify the name of the driver’s performance DLL and the names of certain exported functions in that DLL. You can add value entries to this subkey using AddReg entries in the driver's INF file.
The HKLM\SYSTEM\CurrentControlSet\Control Tree

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:

Class
Contains information about the device setup classes on the system. There is a subkey for each class, named using the GUID of the setup class. Each subkey contains information about a setup class, such as the class installer (if there is one), registered class upper-filter drivers, registered class lower-filter drivers, and so forth.

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.

 

CoDeviceInstallers
Contains information about the class-specific co-installers that are registered on the system.
DeviceClasses
Contains information about the device interfaces on the system. There is a subkey for each device interface class and entries under those subkeys for each instance of an interface that is registered for the device interface class.
The HKLM\SYSTEM\CurrentControlSet\Enum Tree

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 Tree

The HKLM\SYSTEM\CurrentControlSet\HardwareProfiles registry tree contains information about the hardware profiles on the system.

posted @ 2009-07-22 11:10  Fan Zhang  阅读(482)  评论(0编辑  收藏  举报