MajorFunction[IRP_MJ_CREATE]=//HelloWorldDispatch; DriverObject->MajorFunction[IRP" />
DbgPrint("Error IoCreateSymbolicLink()\n");
#endif
goto Error;
}
//设置IRP派遣例程和卸载例程
DriverObject->MajorFunction[IRP_MJ_CREATE]=//HelloWorldDispatch;
DriverObject->MajorFunction[IRP_MJ_CLOSE]=//HelloWorldDispatch;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL]=HelloWorldDispatch;
DriverObject->DriverUnload=HelloWorldUnLoad;
return ntStatus;
Error:
#ifdef DEBUGMSG
DbgPrint("Error DriverEntry()\n");
#endif
return ntStatus;
}
NTSTATUS HelloWorldDispatch (IN PDEVICE_OECT DeviceObject,IN PIRP pIrp)
{
NTSTATUS ntStatus=STATUS_SUCCESS;
ULONG IoControlCodes=0; //I/O控制代码
PIO_STACK_LOCATION IrpStack=NULL; //IRP堆栈
//设置IRP状态
pIrp->IoStatus.Status=STATUS_SUCCESS;
pIrp->IoStatus.Information=0;
#ifdef DEBUGMSG
DbgPrint("Starting HelloWorldDispatch()\n");
#endif
IrpStack=IoGetCurrentIrpStackLocation(pIrp); //得到当前调用者的IRP
switch (IrpStack->MajorFunction)
{
case IRP_MJ_CREATE:
#ifdef DEBUGMSG
DbgPrint("IRP_MJ_CREATE\n");
#endif
break;
case IRP_MJ_CLOSE:
#ifdef DEBUGMSG
DbgPrint("IRP_MJ_CLOSE\n");
#endif
break;
case IRP_MJ_DEVICE_CONTROL:
#ifdef DEBUGMSG
DbgPrint("IRP_MJ_DEVICE_CONTROL\n");
#endif
//取得I/O控制代码
IoControlCodes=IrpStack->Parameters.DeviceIoControl.IoControlCode;
switch (IoControlCodes)
{
//启动
case START_HELLPWORLD:
DbgPrint("Starting \"Hello World\"\n");
break;
//停止
case STOP_HELLPWORLD:
DbgPrint("Stoping \"Hello World\"\n");
break;
default:
pIrp->IoStatus.Status=STATUS_INVALID_PARAMETER;
break;
}
break;
default:break;
}
ntStatus=pIrp->IoStatus.Status;
IoCompleteRequest(pIrp,IO_NO_INCREMENT);
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-47708-2.html
1
无论行进速度还是射速都不及日本
内抓汉奸