正如标题所示,我在使用以下代码时遇到了麻烦:
EvtDeviceIoWrite(
IN WDFQUEUE Queue,
IN WDFREQUEST Request,
IN size_t Length
) {
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = WdfIoQueueGetDevice(Queue);
status = WdfRequestCreate(&attributes, WdfDeviceGetIoTarget(WdfIoQueueGetDevice(Queue)), &newRequest);
if (!NT_SUCCESS(status)) {
KdPrint(("Serial: failed 0x%x\n", status));
WdfRequestComplete(Request, status);
return;
}
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = newRequest;
status = WdfMemoryCreate(&attributes, NonPagedPool, 'MyPl', 10, &newmem, &newbuf);
if (!NT_SUCCESS(status)) {
KdPrint(("Serial: failed 0x%x\n", status));
WdfRequestComplete(Request, status);
return;
}
WDF_REQUEST_SEND_OPTIONS_INIT(&options,
WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET);
ret = WdfRequestSend(newRequest, WdfDeviceGetIoTarget(WdfIoQueueGetDevice(Queue)), &options);
}
if (ret == FALSE) {
status = WdfRequestGetStatus(newRequest);
KdPrint(("WdfRequestSend failed: 0x%x\n", status));
WdfRequestComplete(Request, status);
}
我无法将newRequest发送到堆栈中... ret值为“FALSE”且状态为STATUS_INVALID_DEVICE_STATE。如何使设备处于正常状态?
我按照link的建议做了一切。总结一下,我无法向本地IO堆栈发送请求,目标IO处于不正常状态,我不知道如何使其工作?
答案 0 :(得分:0)
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = WdfIoQueueGetDevice(Queue);
status = WdfRequestCreate(&attributes, WdfDeviceGetIoTarget(WdfIoQueueGetDevice(Queue)), &newRequest);
if (!NT_SUCCESS(status)) {
KdPrint(("Serial: failed 0x%x\n", status));
WdfRequestComplete(Request, status);
return;
}
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = newRequest;
status = WdfMemoryCreate(&attributes, NonPagedPool, 'MyPl', 10, &newMem, &newBuf);
if (!NT_SUCCESS(status)) {
KdPrint(("Serial: failed 0x%x\n", status));
WdfRequestComplete(Request, status);
return;
}
/*Proessing request */
/*End Processing request */
WdfRequestFormatRequestUsingCurrentType(newRequest);
WdfIoTargetFormatRequestForWrite(WdfDeviceGetIoTarget(WdfIoQueueGetDevice(Queue)), newRequest, newMem, NULL , NULL);
ret = WdfRequestSend(newRequest, WdfDeviceGetIoTarget(WdfIoQueueGetDevice(Queue)), NULL);
if (ret == FALSE) {
status = WdfRequestGetStatus(newRequest);
KdPrint(("WdfRequestSend failed: 0x%x\n", status));
}
WdfRequestComplete(Request, status);
这是如何实现它的。