关闭

驱动对象(DRIVER_OBJECT)

299人阅读 评论(0) 收藏 举报
分类:

每个驱动程序会有唯一的DRIVER_OBJECT驱动对象与之对应,并且这个DRIVER_OBJECT是在驱动加载时候,被内核中的对象管理器所创建。它作为驱动一个实例被内核加载,并且内核对一个驱动只加载一个实例。确切的说,是由内核的I/O管理器负责加载的。驱动程序需要在DriveEntry中初始化。

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;//the first pointer Of links
	
	
    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];//handle IRP functions
} DRIVER_OBJECT;
typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT; 

为了更形象的说明这个字段,我贴个图




0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:39004次
    • 积分:921
    • 等级:
    • 排名:千里之外
    • 原创:51篇
    • 转载:23篇
    • 译文:0篇
    • 评论:5条
    文章分类
    最新评论