diff options
author | Dmitry Fleytman <dfleytma@redhat.com> | 2014-04-26 23:07:05 +0300 |
---|---|---|
committer | Dmitry Fleytman <dfleytma@redhat.com> | 2014-05-11 19:26:15 +0300 |
commit | b50b2eddb847e41944ae7d4a4d5af5c89c57d007 (patch) | |
tree | 612d8e42c0e93d3d97de36ecc8f81fca4fcda6ce /UsbDk | |
parent | 46cac03bc65b3157eb8b76a61c8eff0206921b90 (diff) |
UsbDk: Method for sending request with completion
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Diffstat (limited to 'UsbDk')
-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; } |