ReactOS 0.4.16-dev-306-g647d351
fxregkey.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxRegKey.hpp
8
9Abstract:
10
11 This is the C++ header for FxRegKey which represents a key into the registry
12
13Author:
14
15
16
17
18Revision History:
19
20--*/
21
22#ifndef _FXREGKEY_H_
23#define _FXREGKEY_H_
24
25class FxRegKey : public FxPagedObject {
26
27public:
29 PFX_DRIVER_GLOBALS FxDriverGlobals
30 );
31
34 VOID
35 );
36
40 Create(
46 )
47 {
48 return _Create(ParentKey,
49 KeyName,
50 &m_Key,
54 }
55
56 static
60 _Create(
63 __out HANDLE* NewKey,
67 );
68
72 Open(
76 )
77 {
78 return _OpenKey(ParentKey, KeyName, &m_Key, DesiredAccess);
79 }
80
81 static
85 _OpenKey(
90 );
91
92 __inline
93 VOID
96 )
97 {
98 m_Key = Key;
99 }
100
101 __inline
102 HANDLE
104 VOID
105 )
106 {
107 return m_Key;
108 }
109
112 Close(
113 VOID
114 )
115 {
116 HANDLE key;
117
118 key = m_Key;
119 m_Key = NULL;
120
121#if (FX_CORE_MODE == FX_CORE_USER_MODE)
122 //
123 // For special cases where, due to user-mode restrictions,
124 // we cannot open a specific handle for write access,
125 // so we reuse a pre-opened one multiple times.
126 //
127 // In this case we do not want to close it when we close
128 // the FxRegKey object.
129 //
130 if (m_CanCloseHandle == FALSE) {
131 return STATUS_SUCCESS;
132 }
133#endif
134 return _Close(key);
135 }
136
137 static
140 _Close(
142 );
143
147 SetValue(
152 )
153 {
154 return _SetValue(m_Key,
155 ValueName,
156 ValueType,
157 Value,
159 }
160
161 static
165 _SetValue(
171 );
172
182 )
183 {
184 return _QueryValue(m_Globals,
185 m_Key,
186 ValueName,
188 Value,
190 ValueType);
191 }
192
193 static
197 _QueryValue(
198 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
205 );
206
207 static
211 _QueryULong(
215 );
216
217 static
221 _QueryQuadWord(
225 );
226
227 static
228 BOOLEAN
229 __inline
231 __in ULONG RegValueType
232 )
233 {
234 return (RegValueType == REG_SZ) || (RegValueType == REG_EXPAND_SZ);
235 }
236
237 static
241 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
242 __in PCUNICODE_STRING RegValueName,
243 __in_bcount(DataLength) PWCHAR DataString,
245 );
246
247private:
248
249 static
251 ULONG
252 _ComputePartialSize(
254 )
255 {
257 }
258
259protected:
260
263
264#if (FX_CORE_MODE == FX_CORE_USER_MODE)
265private:
266
267 //
268 // If FALSE, then closing or destroying the FxRegKey
269 // will have no effect on the HKEY m_Key.
270 //
272
273public:
274
275 VOID
276 __inline
278 BOOLEAN CanCloseHandle
279 )
280 {
281 m_CanCloseHandle = CanCloseHandle;
282 }
283#endif
284};
285
286#endif // _FXREGKEY_H_
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
@ Create
Definition: registry.c:563
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
static _Must_inspect_result_ NTSTATUS _VerifyMultiSzString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING RegValueName, __in_bcount(DataLength) PWCHAR DataString, __in ULONG DataLength)
Definition: fxregkey.cpp:14
HANDLE m_Key
Definition: fxregkey.hpp:261
static _Must_inspect_result_ __in HANDLE Key
Definition: fxregkey.hpp:199
PFX_DRIVER_GLOBALS m_Globals
Definition: fxregkey.hpp:262
BOOLEAN m_CanCloseHandle
Definition: fxregkey.hpp:271
static _Must_inspect_result_ __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS _QueryQuadWord(__in HANDLE Key
__inline VOID SetHandle(__in HANDLE Key)
Definition: fxregkey.hpp:94
static _Must_inspect_result_ _In_ PCUNICODE_STRING _In_ ULONG _In_reads_bytes_(ValueLength) PVOID Value
_Must_inspect_result_ __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS QueryValue(__in PCUNICODE_STRING ValueName
static _Must_inspect_result_ __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS _SetValue(_In_ HANDLE Key
VOID __inline SetCanCloseHandle(BOOLEAN CanCloseHandle)
Definition: fxregkey.hpp:277
static BOOLEAN __inline _IsValidSzType(__in ULONG RegValueType)
Definition: fxregkey.hpp:230
_Must_inspect_result_ __in ULONG __out_bcount_opt(ValueLength) PVOID Value
__inline HANDLE GetHandle(VOID)
Definition: fxregkey.hpp:103
_Must_inspect_result_ __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS Open(__in_opt HANDLE ParentKey
_Must_inspect_result_ __in ULONG __in_bcount(ValueLength) PVOID Value
static _Must_inspect_result_ __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS _QueryValue(__in PFX_DRIVER_GLOBALS FxDriverGlobals
_Must_inspect_result_ __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS SetValue(__in PCUNICODE_STRING ValueName
__drv_maxIRQL(PASSIVE_LEVEL) ~FxRegKey(VOID)
static _Must_inspect_result_ __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS _QueryULong(__in HANDLE Key
__drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS Close(VOID)
Definition: fxregkey.hpp:110
static __out_range(Length,(Length+sizeof(KEY_VALUE_PARTIAL_INFORMATION) -1)) ULONG _ComputePartialSize(__in_bound ULONG Length)
Definition: fxregkey.hpp:250
static _Must_inspect_result_ __in HANDLE __in PCUNICODE_STRING __in ULONG __out_bcount_opt(ValueLength) PVOID Value
_Must_inspect_result_ __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS Create(__in_opt HANDLE ParentKey
static __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS _Close(__in HANDLE Key)
#define __out_opt
Definition: dbghelp.h:65
#define __in
Definition: dbghelp.h:35
#define __in_bcount(x)
Definition: dbghelp.h:41
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define REG_SZ
Definition: layer.c:22
#define Open
Definition: syshdrs.h:62
static LONG WINAPI QueryValue(HANDLE hcKey, LPCWSTR pszValue, PDWORD pType, PBYTE pData, PDWORD pcbData, HANDLE hSpooler)
Definition: localmon.c:206
@ SetValue
Definition: shader.c:1968
#define _Must_inspect_result_
Definition: no_sal2.h:62
#define _In_
Definition: no_sal2.h:158
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ Close
Definition: sacdrv.h:268
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __in_bound
Definition: specstrings.h:332
Definition: copy.c:22
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG _Out_opt_ PULONG CreateDisposition
Definition: wdfregistry.h:120
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG ValueLengthQueried
Definition: wdfregistry.h:279
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG CreateOptions
Definition: wdfregistry.h:118
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey
Definition: wdfregistry.h:69
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:282
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:275
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413