Forwarding WDF requests from virtual KMDF drivers.

Hello,

I have a simple KMDF virtual driver (no physical device) which receives WDF requests via its file interface from a user space app and should forward them to a second driver by using I/O Target api.

The problem that I see is that if I try to forward a request, WdfIoTargetFormatRequestForInternalIoctl fails with the error code STATUS_REQUEST_NOT_ACCEPTED.

However, if I create a new request inside my driver and send it to the second driver - it works fine.

Do you have any advice why this could happen?

Thank you!
Gregory

what does !wdfkd.wdflogdump say in the error case?

The IRP sent to the 1st driver probably has no free stack locations, because the 2nd driver is not related to the 1st (not in same device stack), correct?

– pa

Yes, this is the case - these two drivers are not related between them.
The drivers find each other by a GUID and then open I/O target.
Our flow is that user app calls WriteFile(), then driver A gets a Request and should forward it to driver B.

Is it possible to add a location to a stack? Is there any other way to forward a request without creating new request and copying input buffer from the original one?

Thanks!

>Is it possible to add a location to a stack?

No

Is there any other way to forward a
request without creating new request and copying input buffer from the original
one?

Copying the buffer is not needed. All you need is A. make a new IRP for the 2nd driver, B. copy the MDL and/or system buffer address from the original request. Call the 2nd driver; on completion of the new IRP complete also the 1st.
I am not sure how to do this in WDF though.

Regards,
P.

If you know the stack size of the driver B (ie the one that you open by guid) at the time you create driver A, in EvtDriverDeviceAdd() after you create the WDFDEVICE, get the WDM PDEVICE_OBJECT and adjust the StackSize field accordingly. this will increase driver a’s stack size for incoming irps so that there are enough stack locations to send it to driver b

d