5.2 DriverEntry Routine Functionality

This section summarizes how a representative NT device driver’s DriverEntry routine works.

The particulars of how any NT device driver uses the registry and initializes its device(s) are device-dependent, as well as dependent on the driver’s designer. The particulars of how any higher-level NT driver uses the registry are somewhat device-type-dependent, as well as dependent on the driver’s designer.

Every DriverEntry routine is called with two input pointers, as shown in the declaration. The input DriverObject pointer allows the DriverEntry routine to set appropriate entry points for its Dispatch, StartIo, and/or Unload routines in the driver object.

Using the Configuration Registry

The input DriverObject pointer also gives the driver access to DriverObject->HardwareDatabase, which points to a counted Unicode string that specified a path to the registry \Registry\Machine\Hardware tree. The RegistryPath input to the DriverEntry routine points to a counted Unicode string that specifies a path to the driver’s registry key \Registry\Machine\System\CurrentControlSet\Services\DriverName.

Every NT driver can get information from the registry in order to initialize successfully. For example, higher-level NT drivers that layer themselves over drivers for a particular kind of underlying device can get information about how many devices of that type are present in any particular Windows NT machine.

The DriverEntry routines of NT device drivers must successfully claim the hardware resources they need to support I/O on their devices in the registry before they attempt to initialize any physical device. If an NT device driver cannot establish a claim in the registry on the I/O ports, device memory ranges, interrupt, and/or DMA channel/port it needs to perform device I/O, that driver cannot remain loaded.

In general, an NT device driver whose support is necessary for the system to boot is likely to use the registry in a slightly different manner than a driver that can be loaded and unloaded on demand. The driver of a device that must be accessible for the system itself to load is more likely to get support from what the system’s hardware-detection code stored in the \Registry\Machine\Hardware\Description tree. The DriverEntry routine of a load-on-demand driver is likely to depend more on user-supplied value entries in the driver’s registry key \Registry\Machine\System\CurrentControlSet\Services\DriverName and/or in its Parameters subkey(s) that were set up when the driver was installed in the system.

For more information about how NT drivers use the registry, see Chapter 16. For more information about the installation of NT drivers, see the Programmer’s Guide.