Chinaunix首页 | 论坛 | 博客
  • 博客访问: 426841
  • 博文数量: 72
  • 博客积分: 1583
  • 博客等级: 上尉
  • 技术积分: 775
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-23 09:36
文章分类

全部博文(72)

文章存档

2011年(72)

我的朋友

分类: WINDOWS

2011-02-08 11:28:03

DRIVER_OBJECT是驱动程序在内核中的数据结构,每个驱动程序有唯一DRIVER_OBJECT,IO管理器使用驱动程序对象代表每个设备驱动程序
驱动程序描述了驱动程序的载入到内存什么地方,
驱动程序的大小和它的主要入口点(MajorFunction数组);
驱动程序对象有一个DeviceObject域指向一个设备对象链表,每个设备对象代表一个设备。
  1. typedef struct _DRIVER_OBJECT {
  2.     CSHORT Type;
  3.     CSHORT Size;

  4.     //

  5.     // The following links all of the devices created by a single driver

  6.     // together on a list, and the Flags word provides an extensible flag

  7.     // location for driver objects.

  8.     //


  9.     PDEVICE_OBJECT DeviceObject;
  10.     ULONG Flags;

  11.     //

  12.     // The following section describes where the driver is loaded. The count

  13.     // field is used to count the number of times the driver has had its

  14.     // registered reinitialization routine invoked.

  15.     //


  16.     PVOID DriverStart;
  17.     ULONG DriverSize;
  18.     PVOID DriverSection;
  19.     PDRIVER_EXTENSION DriverExtension;

  20.     //

  21.     // The driver name field is used by the error log thread

  22.     // determine the name of the driver that an I/O request is/was bound.

  23.     //


  24.     UNICODE_STRING DriverName;

  25.     //

  26.     // The following section is for registry support. Thise is a pointer

  27.     // to the path to the hardware information in the registry

  28.     //


  29.     PUNICODE_STRING HardwareDatabase;

  30.     //

  31.     // The following section contains the optional pointer to an array of

  32.     // alternate entry points to a driver for "fast I/O" support. Fast I/O

  33.     // is performed by invoking the driver routine directly with separate

  34.     // parameters, rather than using the standard IRP call mechanism. Note

  35.     // that these functions may only be used for synchronous I/O, and when

  36.     // the file is cached.

  37.     //


  38.     PFAST_IO_DISPATCH FastIoDispatch;

  39.     //

  40.     // The following section describes the entry points to this particular

  41.     // driver. Note that the major function dispatch table must be the last

  42.     // field in the object so that it remains extensible.

  43.     //


  44.     PDRIVER_INITIALIZE DriverInit;
  45.     PDRIVER_STARTIO DriverStartIo;
  46.     PDRIVER_UNLOAD DriverUnload;
  47.     PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];

  48. } DRIVER_OBJECT;
  49. typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
 
  1. PDEVICE_OBJECT DeviceObject
  2. 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.
  3. PDRIVER_EXTENSION DriverExtension
  4. 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.
  5. PUNICODE_STRING HardwareDatabase
  6. Pointer to the \Registry\Machine\Hardware path to the hardware configuration information in the registry.
  7. PFAST_IO_DISPATCH FastIoDispatch
  8. Pointer to a structure defining the driver’s fast I/O entry points. This member is used only by FSDs and network transport drivers.
  9. PDRIVER_INITIALIZE DriverInit
  10. The entry point for the DriverEntry routine, which is set up by the I/O Manager.
  11. PDRIVER_STARTIO DriverStartIo
  12. 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.
  13. PDRIVER_UNLOAD DriverUnload
  14. 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.
  15. PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
  16. 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域指向与该设备相关的驱动程序对象。
      
阅读(3963) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~