MajorFunction[IRP_MJ_CREATE]=//HelloWorldDispatch; DriverObject->MajorFunction[IRP" />
b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

wdm设备驱动程序开发_windows驱动开发工具_u盘win7缺少驱动程序(2)

电脑杂谈  发布时间:2017-05-17 20:09:07  来源:网络整理

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

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...