driver: fix driver verifier assertion in FileCreate callback

Previous commit 4de57a9ff causes driver verifier assertion with
latest Windows builds. Note that this assertion is not in latest
WDF sources on GitHub. The verifier does not allow to forward
the MJ_CREATE requestto local IO target using "send-and-forget".
It requires the request to set completion callback.
There is an option to remove the file create callback at all, but
we prefer to have printout on file open for better diagnostics.
So we add completion callback for forwarded request and complete
the request in it.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
This commit is contained in:
Yuri Benditovich 2020-01-25 19:57:57 +02:00
parent 617f89695e
commit 7d373dbb8d

View file

@ -481,11 +481,19 @@ bool CUsbDkChildDevice::AttachToDeviceStack()
void CUsbDkFilterDevice::OnFileCreate(WDFREQUEST Request)
{
WDF_REQUEST_SEND_OPTIONS options;
WDF_REQUEST_SEND_OPTIONS_INIT(&options, WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET);
CWdfRequest r(Request);
WdfRequestFormatRequestUsingCurrentType(Request);
// in the log we'll see which process created the file
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC!");
WdfRequestSend(Request, IOTarget(), &options);
r.SendWithCompletion(IOTarget(), [](WDFREQUEST Request, WDFIOTARGET Target, PWDF_REQUEST_COMPLETION_PARAMS Params, WDFCONTEXT Context)
{
UNREFERENCED_PARAMETER(Target);
CWdfRequest r(Request);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%s: completed", (LPCSTR)Context);
r.SetStatus(Params->IoStatus.Status);
r.SetBytesWritten(Params->IoStatus.Information);
},
__FUNCTION__);
}
NTSTATUS CUsbDkFilterDevice::AttachToStack(WDFDRIVER Driver)