25.2.1 Opening an Installable Driver

An application opens an installable driver by calling the OpenDriver function. When an application calls this function, Windows adds the driver name to an internal list of installed drivers. (When the application calls the CloseDriver function, Windows deletes the corresponding driver name from this list.)

When an application calls the OpenDriver function to open the first instance of a driver, Windows issues the DRV_LOAD, DRV_ENABLE, and DRV_OPEN messages, in that order. (Subsequent calls to OpenDriver cause only DRV_OPEN to be sent.) When the driver processes the DRV_LOAD message, it reads the configuration settings (if any exist) from the corresponding entry in the SYSTEM.INI file and configures the driver and any associated hardware. In addition to configuring the driver and associated hardware, the driver also allocates required memory.

After processing the DRV_LOAD message, the driver returns a nonzero value if it loads successfully. If it returns zero, Windows immediately unloads the driver (without issuing a DRV_FREE message).

When the driver processes the DRV_ENABLE message, it hooks or chains required interrupts and prepares associated peripherals.

When the driver processes the DRV_OPEN message, it allocates memory required by a single instance of the driver.