NTSTATUS HelloDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP pIrp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PIO_STACK_LOCATION IrpStack = NULL;
DbgPrint("Hello: HelloDispatch\n");
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = 0;
IrpStack = IoGetCurrentIrpStackLocation(pIrp);
switch (IrpStack->MajorFunction)
{
case IRP_MJ_CREATE:
DbgPrint("Hello: IRP_MJ_CREATE\n");
break;
case IRP_MJ_CLOSE:
DbgPrint("Hello: IRP_MJ_CLOSE\n");
break;
case IRP_MJ_DEVICE_CONTROL:
DbgPrint("IRP_MJ_DEVICE_CONTROL\n");
{
ULONG IoControlCodes = IrpStack->Parameters.DeviceIoControl.IoControlCode;
switch(IoControlCodes)
{
case START_HELLPWORLD:
DbgPrint("Starting \"Hello World\"\n");
break;
default:
pIrp->IoStatus.Status = STATUS_INVALID_PARAMETER;
break;
}
}
break;
default:
break;
}
ntStatus = pIrp->IoStatus.Status;
DbgPrint("Hello: status:= %d\n", ntStatus);
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return ntStatus;
}
我写的一个Dispatch函数,分发IRP_MJ_CREATE/IRP_MJ_CLOSE/IRP_MJ_DEVICE_CONTROL,Open Close都正确,为什么调用DeviceIoControl(hDevice, START_HELLPWORLD, NULL, 0, NULL, 0, NULL, NULL)后就会Crash. 驱动中已经打印出
Starting "Hello World"
Hello: status:= 0
, 麻烦高人指点,谢谢。
怎么Crash的,要是死机蓝屏啥的,你咋看到log的