I am currently trying to write a serial filter driver that would be able to modify the data on read wdf requests.
The idea is to create a new WDFREQUEST object in the read callback function, here is what I do :
- Create a new request
WdfRequestCreate(WDF_NO_OBJECT_ATTRIBUTES, target, &newRequest);
- Create new WDFMEMORY
WdfMemoryCreate(WDF_NO_OBJECT_ATTRIBUTES, NonPagedPool, 'MyPi', Length, &newMemory, &newBuffer);
- Get the request memory and buffer
WdfRequestRetrieveOutputMemory(Request, &outputMemory);outputBuffer = WdfMemoryGetBuffer(outputMemory, NULL);
- Copy the data
WdfMemoryCopyFromBuffer(newMemory, 0, outputBuffer, Length);
- Format the new request with the new memory
WdfIoTargetFormatRequestForRead(target, newRequest, newMemory, NULL, NULL);
- Finally, set completion routine and send the new request
WdfRequestSetCompletionRoutine(newRequest, FilterEvtIoReadCompletionRoutine, filterContext);WdfRequestSend(newRequest, target, WDF_NO_SEND_OPTIONS);
But this code yields me a BSOD...If I replace newRequest by Request and newMemory by outputMemory in 5) and 6) the data is correclty transmitted and no error is produced.
Does anyone know where could be the problem ?Thank you in advance,Axel