1

As the title suggest I have a trouble with following code:

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);
}

I cannot send the newRequest down the stack... the ret value is "FALSE" and status is STATUS_INVALID_DEVICE_STATE. How to make the device in the proper state?

I done everything right as link suggests. So summing up I cannot send request down the local IO stack, The Target IO is in not proper state and I do not know how to get it working?

Jak ttt
  • 33
  • 6

1 Answers1

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);

This is how to achieve it.

Jak ttt
  • 33
  • 6