基于Windows2000开发WDM设备驱动程序的方法(2)
2014-10-19 01:03
导读:IoGetNextIrpStackLocation(IN PIRP Irp ); IoGetNextIrpStackLocation gives a higher level driver access to the next-lower driver's I/O stack location in an IRP so the caller can set it up for the lower
IoGetNextIrpStackLocation(IN PIRP Irp );
IoGetNextIrpStackLocation gives a higher level driver access to the next-lower driver's I/O stack location in an IRP so the caller can set it up for the lower driver.
可使用IoCallDriver调用下一个驱动程序,当最低一层的驱动处理玩后调用IoCompleteRequest,IRP再向上传递返回用户,当IRP向上传递时也可以每个驱动有机会再处理它,每个驱动要设置IoSetCompletionRoutine挂接一个例程 ,一个驱动不一定要沿着设备栈向下传递IRP,如果自己能处理就就使用IoCompleteRequest完成IrP
2.5 设备接口
用户态使用Win32 CreateFile访问驱动程序,dwShareMode为0时来请求独占内核对象在设备对象DEVICE_OBJECT结构中存储设备的信息,对于与设备的每个交互,相关的DEVICE_OBJECT被传递给驱动的回调例程。,但是开发者可以扩展设备结构,称为设备扩展
在PnP IRP中我们加载设备NTSTATUS Wdm1AddDevice( IN PDRIVER_OBJECT DriverObject,指向驱动程序的指针 IN PDEVICE_OBJECT pdo指向物理设备的指针)
{ DebugPrint("AddDevice");
status = IoCreateDevice (DriverObject,创建设备
sizeof(WDM1_DEVICE_EXTENSION),
NULL, // No Name
FILE_DEVICE_UNKNOWN,