DRIVER_OBJECT是驱动程序在内核中的数据结构,每个驱动程序有唯一DRIVER_OBJECT,IO管理器使用驱动程序对象代表每个设备驱动程序
驱动程序描述了驱动程序的载入到内存什么地方,
驱动程序的大小和它的主要入口点(MajorFunction数组);
驱动程序对象有一个DeviceObject域指向一个设备对象链表,每个设备对象代表一个设备。
- typedef struct _DRIVER_OBJECT {
- CSHORT Type;
- CSHORT Size;
- //
- // The following links all of the devices created by a single driver
- // together on a list, and the Flags word provides an extensible flag
- // location for driver objects.
- //
- PDEVICE_OBJECT DeviceObject;
- ULONG Flags;
- //
- // The following section describes where the driver is loaded. The count
- // field is used to count the number of times the driver has had its
- // registered reinitialization routine invoked.
- //
- PVOID DriverStart;
- ULONG DriverSize;
- PVOID DriverSection;
- PDRIVER_EXTENSION DriverExtension;
- //
- // The driver name field is used by the error log thread
- // determine the name of the driver that an I/O request is/was bound.
- //
- UNICODE_STRING DriverName;
- //
- // The following section is for registry support. Thise is a pointer
- // to the path to the hardware information in the registry
- //
- PUNICODE_STRING HardwareDatabase;
- //
- // The following section contains the optional pointer to an array of
- // alternate entry points to a driver for "fast I/O" support. Fast I/O
- // is performed by invoking the driver routine directly with separate
- // parameters, rather than using the standard IRP call mechanism. Note
- // that these functions may only be used for synchronous I/O, and when
- // the file is cached.
- //
- PFAST_IO_DISPATCH FastIoDispatch;
- //
- // The following section describes the entry points to this particular
- // driver. Note that the major function dispatch table must be the last
- // field in the object so that it remains extensible.
- //
- PDRIVER_INITIALIZE DriverInit;
- PDRIVER_STARTIO DriverStartIo;
- PDRIVER_UNLOAD DriverUnload;
- PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
- } DRIVER_OBJECT;
- typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
- PDEVICE_OBJECT DeviceObject
- Pointer to the device objects created by the driver. This member is automatically updated when the driver calls IoCreateDevice successfully. A driver can use this member and the NextDevice member of DEVICE_OBJECT to step through a list of all the device objects that the driver created.
- PDRIVER_EXTENSION DriverExtension
- Pointer to the driver extension. The only accessible member of the driver extension is DriverExtension->AddDevice, into which a driver's DriverEntry routine stores the driver's AddDevice routine.
- PUNICODE_STRING HardwareDatabase
- Pointer to the \Registry\Machine\Hardware path to the hardware configuration information in the registry.
- PFAST_IO_DISPATCH FastIoDispatch
- Pointer to a structure defining the driver’s fast I/O entry points. This member is used only by FSDs and network transport drivers.
- PDRIVER_INITIALIZE DriverInit
- The entry point for the DriverEntry routine, which is set up by the I/O Manager.
- PDRIVER_STARTIO DriverStartIo
- The entry point for the driver’s StartIo routine, if any, which is set by the DriverEntry routine when the driver initializes. If a driver has no StartIo routine, this member is NULL.
- PDRIVER_UNLOAD DriverUnload
- The entry point for the driver’s Unload routine, if any, which is set by the DriverEntry routine when the driver initializes. If a driver has no Unload routine, this member is NULL.
- PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
- A dispatch table consisting of an array of entry points for the driver’s DispatchXxx routines. The array
DEVICE_OBJECT是物理设备或逻辑设备在内核中的数据结构,跟这个概念相关的有PDO和FDO;PDO对应于具体的硬件设备,每个硬件设备对应一个PDO,而一个PDO可以对应多个FDO;PDO和FDO都是DEVICE_OBJECT的实体;同一个设备驱动程序对象下的所有设备通过NextObject域连接成一个链表(即上述驱动程序设备对象的一个域);AttachedDevice域是针对“早期”驱动的(Window NT4以前的版本,在以后的版本中也可以正常使用);DriverObject域指向与该设备相关的驱动程序对象。
阅读(4003) | 评论(0) | 转发(0) |