0

how to send the request to the next driver in the stack to further completion?

In my filter driver driver I register a queue for EventWrite with callback EvtDeviceIoWrite as follows:

VOID
EvtDeviceIoWrite(
    IN WDFQUEUE  Queue,
    IN WDFREQUEST  Request,
    IN size_t Length
)
{
    WDFMEMORY memory;
    NTSTATUS status;
    PUCHAR characters;
    UCHAR currentChar;
    UNREFERENCED_PARAMETER(Queue);

    status = WdfRequestRetrieveInputMemory(Request, &memory);
    if (!NT_SUCCESS(status)) {
        KdPrint(("RetreiveInputMemo:  failed 0x%x\n", status));
        return;
    }
    characters = (PUCHAR)WdfMemoryGetBuffer(memory, NULL);
    while (Length != 0) {
        Length--;
        currentChar = *(characters++);
        // Here I would like to edit the buffer
        // copy it to output buffer WdfMemoryCopyFromBuffer
    }
  **// what should be here for send** 
}

I just want do something like this, but for the request.

Sorry I am newbiee in kernel developing, and it will be greatful if someone could point me to the right way to achieve this. Any sugestions will be appreciated.

Jak ttt
  • 33
  • 6

1 Answers1

0

in Windows-driver-samples exist huge count of examples how do Forwarding I/O Requests. take for example first simply code like in filter.c - here this done by FilterForwardRequest or FilterForwardRequestWithCompletionRoutine - so in general called

WdfRequestSend(Request, WdfDeviceGetIoTarget(WdfIoQueueGetDevice(Queue)),WDF_NO_SEND_OPTIONS);
RbMm
  • 31,280
  • 3
  • 35
  • 56
  • I have tried this that way, but unfortunately that does not work. To test it I configured that connection and send data: `echo 'a' -> virual machnie com2 <-> host port -com3 com4 <- Termite (serial termial)`, and without the driver the data packets are sent properly. As I installed this driver with your proposal any packets are received on com4 – Jak ttt Feb 02 '17 at 20:40
  • I checked also that the WdfRequestSend command is called when data is send to com2 – Jak ttt Feb 02 '17 at 20:46
  • WdfRequestSend returns false, so I checked WdfRequestStatus, and the status is equal (printf "%x", status) 1f82d524, everything would be great if that number had been in microsoft documetation.... – Jak ttt Feb 02 '17 at 23:35
  • @Jakttt - `WdfRequestGetStatus` never return this code `1f82d524`. this is 100%. on error always `0 > status` error in your code – RbMm Feb 03 '17 at 00:01
  • Ok, that was my mistake,by the way the status is now equal STATUS_INVALID_DEVICE_REQUEST. So It still not working. – Jak ttt Feb 04 '17 at 22:05
  • Ok, it should be added completion routine or `WDF_REQUEST_SEND_OPTIONS_INIT(&options, WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET);` before send, as there is in filter.c provided by you. Thanks for help. – Jak ttt Feb 06 '17 at 00:02