Driver Objects

< BACK  NEXT >
[oR]

DriverEntry is the only driver routine with an exported name. When the I/O Manager needs to locate other driver functions, it uses the Driver object associated with a specific device. This object is basically a catalog that contains pointers to various driver functions. The life of a driver object is explained below.

  1. The I/O Manager creates a driver object whenever it loads a driver. If the driver fails during initialization, the I/O Manager deletes the object.

  2. During initialization, the DriverEntry routine loads pointers to other driver functions into the driver object.

  3. When an IRP is sent to a specific device, the I/O Manager uses the associated driver object to find the right Dispatch routine.

  4. If a request involves an actual device operation, the I/O Manager uses the driver object to locate the driver's Start I/O routine.

  5. If the driver is unloaded, the I/O Manager uses the driver object to find an Unload routine. When the Unload routine returns, the I/O Manager deletes the Driver object.

Layout of a Driver Object

There is a unique driver object for each driver currently loaded in the system. Figure 4.2 illustrates the structure of the driver object. As you can see, the driver object also contains a pointer to a linked list of devices serviced by this driver. A driver's Unload routine can use this list to locate any devices it needs to delete.

Figure 4.2. The driver object.
graphics/04fig02.gif

Table 4.5. Externally Visible Fields of a Driver Object
Driver Object Fields
Field Description
PDRIVER_STARTIO DriverStartIo Address of driver's Start I/O routine
PDRIVER_UNLOAD DriverUnload Address of driver's Unload routine
PDRIVER_DISPATCH MajorFunction[] Table of driver's Dispatch routines, indexed by I/O operation code
PDEVICE_OBJECT DeviceObject Linked list of device objects created by this driver

Unlike other objects, there are no access functions for modifying driver objects. Instead, the DriverEntry routine sets various fields directly. Table 4.5 lists the fields a driver is allowed to touch.

< BACK  NEXT >


The Windows 2000 Device Driver Book(c) A Guide for Programmers
The Windows 2000 Device Driver Book: A Guide for Programmers (2nd Edition)
ISBN: 0130204315
EAN: 2147483647
Year: 2000
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net