小默

[zz]DispatchPnP

DispatchPnP

The DispatchPnP routine services IRPs containing the IRP_MJ_PNP I/O function code.

DRIVER_DISPATCH DispatchPnP;

NTSTATUS
  DispatchPnP(
    __in struct _DEVICE_OBJECT  *DeviceObject,
    __in struct _IRP  *Irp
    )
  {...}

Parameters

DeviceObject
Caller-supplied pointer to a DEVICE_OBJECT structure. This is the device object for the target device, previously created by the driver's AddDevice routine.
Irp
Caller-supplied pointer to an IRP structure that describes the requested I/O operation.

Return Value

If the routine succeeds, it must return STATUS_SUCCESS. Otherwise, it must return one of the error status values defined in Ntstatus.h.

Comments

A driver's DispatchPnP routine should be named XxxDispatchPnP, where Xxx is a driver-specific prefix. The driver's DriverEntry routine must store the DispatchPnP routine's address in DriverObject->MajorFunction[IRP_MJ_PNP].

Input parameters for all Dispatch routines are supplied in the IRP structure pointed to by Irp. Additional parameters are supplied in the driver's associated I/O stack location, which is described by the IO_STACK_LOCATION structure and can be obtained by calling IoGetCurrentIrpStackLocation.

Generally, all Dispatch routines execute in an arbitrary thread context at IRQL = PASSIVE_LEVEL, but there are exceptions. For more information, see Dispatch Routines and IRQLs.

For more information about DispatchPnP routines, see Writing Dispatch Routines. For more information about IRPs, see Handling IRPs.

Example

To define a DispatchPnP callback function that is named MyDispatchPnP, you must first provide a function declaration that Static Driver Verifier (SDV) and other verification tools require, as follows:

DRIVER_DISPATCH MyDispatchPnP;

 

Then, implement your callback function as follows:

NTSTATUS
  MyDispatchPnP(
    __in struct _DEVICE_OBJECT  *DeviceObject,
    __in struct _IRP  *Irp
    )
  {
      // Function body
  }

 

The DRIVER_DISPATCH function type is defined in the Wdm.h header file. For more information about SDV requirements for function declarations, see Declaring Functions Using Function Role Types for WDM Drivers.

Requirements

IRQL: PASSIVE_LEVEL (see Comments section)

Headers: Declared in Wdm.h. Include Wdm.h, Ntddk.h, or Ntifs.h.

posted on 2009-12-29 11:20 小默 阅读(244) 评论(0)  编辑 收藏 引用 所属分类: Windows


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

统计

留言簿(13)

随笔分类(287)

随笔档案(289)

漏洞

搜索

积分与排名

最新评论

阅读排行榜