blob: 89a8747c7b133fb295e5a76b0f1c2a7797eda508 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) Microsoft Corporation. All rights reserved
Module Name:
RequestHelper.h
Abstract:
This module contains the class definition and implementation
of an RAII Request object helper class.
Environment:
Windows User-Mode Driver Framework (WUDF)
--*/
#pragma once
//
// This class handles RAII for IWdfIoRequest pointers.
// A function can declare this class at the beginning, and
// set the HRESULT for the request completion.
//
// The destructor is always called on function exit.
// It will complete the request only if the HRESULT
// is something besides HRESULT_FROM_WIN32(ERROR_IO_PENDING)
//
// If the function does not want to complete the request,
// it should not call SetCompletionHr. Then the request
// will remain pending.
//
class CRequestHelper
{
//
// Public methods
//
public:
CRequestHelper(
IWDFIoRequest *FxRequest
)
{
m_Request = FxRequest;
m_Hr = HRESULT_FROM_WIN32(ERROR_IO_PENDING);
}
~CRequestHelper()
{
if (m_Hr != HRESULT_FROM_WIN32(ERROR_IO_PENDING))
{
m_Request->Complete(m_Hr);
}
}
void
SetCompletionHr(
HRESULT Hr
)
{
m_Hr = Hr;
}
void
SetInformation(
SIZE_T Information
)
{
m_Request->SetInformation(Information);
}
//
// Private members
//
private:
IWDFIoRequest * m_Request;
HRESULT m_Hr;
};
|