阅读:1844回复:1
关于wdf例子驱动osrusbfx2的蓝屏!
我用了wdk的osrusbfx2例子,修改ioctl,添加了一个bulkwrite,然后根据网上张佩的代码:
VOID BulkWrite(IN WDFQUEUE Queue, IN WDFREQUEST Request, IN size_t Length) { NTSTATUS status = STATUS_SUCCESS; WDFMEMORY hMem = NULL; WDFDEVICE hDevice = NULL; WDFUSBPIPE BulkOutputPipe = NULL; UCHAR* lpBuf; UNREFERENCED_PARAMETER(Length); hDevice = WdfIoQueueGetDevice(Queue); BulkOutputPipe = GetBulkPipe(FALSE, hDevice);// 取得批量输出 Pipe 。 中断Pipe 亦可。 if(NULL == BulkOutputPipe){ WdfRequestComplete(Request, STATUS_UNSUCCESSFUL); return; } KDBG(DPFLTR_INFO_LEVEL, "[BulkWrite] size: %d", Length); status = WdfRequestRetrieveInputMemory(Request, &hMem); if(!NT_SUCCESS(status)) { KDBG(DPFLTR_ERROR_LEVEL, "WdfRequestRetrieveInputMemory failed(status = 0x%0.8x)!!!", status); WdfRequestComplete(Request, status); return; } lpBuf = (UCHAR*)WdfMemoryGetBuffer(hMem, 0); KDBG(DPFLTR_TRACE_LEVEL, "%c %c", lpBuf[0], lpBuf[1]); // Format当前的 Request ,在 Request 中添加当前写入 Pipe 的相关信息。 status = WdfUsbTargetPipeFormatRequestForWrite(BulkOutputPipe, Request, hMem, NULL); if(!NT_SUCCESS(status)) { KDBG(DPFLTR_ERROR_LEVEL, "WdfUsbTargetPipeFormatRequestForWrite(status 0x%0.8x)!!!", status); WdfRequestComplete(Request, status); return; } WdfRequestSetCompletionRoutine(Request, BulkWriteComplete, BulkOutputPipe); // 设置完成函数 if(FALSE == WdfRequestSend(Request, WdfUsbTargetPipeGetIoTarget(BulkOutputPipe), NULL))// 发送到批量输出 Pipe 的 Target 对象 { status = WdfRequestGetStatus(Request); KDBG(DPFLTR_ERROR_LEVEL, "WdfRequestSend failed with status 0x%0.8x/n", status); WdfRequestComplete(Request, status); } } 完成函数就不列出来了 当运行到 if(FALSE == WdfRequestSend(Request, WdfUsbTargetPipeGetIoTarget(BulkOutputPipe), NULL))// 发送到批量输出 Pipe 的 Target 对象 出现蓝屏了!我检测了request和WdfUsbTargetPipeGetIoTarget(BulkOutputPipe)的句柄,不为NULL 高手指点一下吧!愁几天了,我比较菜~ |
|
沙发#
发布于:2011-07-13 08:30
肿么一个回复都么有
|
|