diff options
-rw-r--r-- | UsbDk/WdfRequest.cpp | 18 | ||||
-rw-r--r-- | UsbDk/WdfRequest.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/UsbDk/WdfRequest.cpp b/UsbDk/WdfRequest.cpp index a92a1b0..5881444 100644 --- a/UsbDk/WdfRequest.cpp +++ b/UsbDk/WdfRequest.cpp @@ -21,6 +21,24 @@ NTSTATUS CWdfRequest::SendAndForget(WDFIOTARGET Target) return status; } +NTSTATUS CWdfRequest::SendWithCompletion(WDFIOTARGET Target, PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionFunc) +{ + auto status = STATUS_SUCCESS; + + WdfRequestSetCompletionRoutine(m_Request, CompletionFunc, nullptr); + if (WdfRequestSend(m_Request, Target, WDF_NO_SEND_OPTIONS)) + { + Detach(); + } + else + { + status = WdfRequestGetStatus(m_Request); + SetStatus(status); + } + + return status; +} + NTSTATUS CWdfRequest::FetchSafeReadBuffer(WDFMEMORY *Buffer) const { PVOID Ptr; diff --git a/UsbDk/WdfRequest.h b/UsbDk/WdfRequest.h index 4b4376b..73921f7 100644 --- a/UsbDk/WdfRequest.h +++ b/UsbDk/WdfRequest.h @@ -92,6 +92,7 @@ public: } NTSTATUS SendAndForget(WDFIOTARGET Target); + NTSTATUS SendWithCompletion(WDFIOTARGET Target, PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionFunc); void Detach() { m_Request = WDF_NO_HANDLE; } |