ReactOS  0.4.15-dev-3175-g222acf5
fxregkey.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxRegKey.hpp
8 
9 Abstract:
10 
11  This is the C++ header for FxRegKey which represents a key into the registry
12 
13 Author:
14 
15 
16 
17 
18 Revision History:
19 
20 --*/
21 
22 #ifndef _FXREGKEY_H_
23 #define _FXREGKEY_H_
24 
25 class FxRegKey : public FxPagedObject {
26 
27 public:
28  FxRegKey(
29  PFX_DRIVER_GLOBALS FxDriverGlobals
30  );
31 
33  ~FxRegKey(
34  VOID
35  );
36 
39  NTSTATUS
40  Create(
46  )
47  {
48  return _Create(ParentKey,
49  KeyName,
50  &m_Key,
54  }
55 
56  static
59  NTSTATUS
60  _Create(
63  __out HANDLE* NewKey,
67  );
68 
71  NTSTATUS
72  Open(
76  )
77  {
78  return _OpenKey(ParentKey, KeyName, &m_Key, DesiredAccess);
79  }
80 
81  static
84  NTSTATUS
85  _OpenKey(
88  __out HANDLE* Key,
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 
111  NTSTATUS
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
139  NTSTATUS
140  _Close(
141  __in HANDLE Key
142  );
143 
146  NTSTATUS
147  SetValue(
152  )
153  {
154  return _SetValue(m_Key,
155  ValueName,
156  ValueType,
157  Value,
158  ValueLength);
159  }
160 
161  static
164  NTSTATUS
165  _SetValue(
166  _In_ HANDLE Key,
171  );
172 
175  NTSTATUS
176  QueryValue(
182  )
183  {
184  return _QueryValue(m_Globals,
185  m_Key,
186  ValueName,
187  ValueLength,
188  Value,
190  ValueType);
191  }
192 
193  static
196  NTSTATUS
197  _QueryValue(
198  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
205  );
206 
207  static
210  NTSTATUS
211  _QueryULong(
212  __in HANDLE Key,
215  );
216 
217  static
220  NTSTATUS
221  _QueryQuadWord(
222  __in HANDLE Key,
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
239  NTSTATUS
241  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
242  __in PCUNICODE_STRING RegValueName,
243  __in_bcount(DataLength) PWCHAR DataString,
245  );
246 
247 private:
248 
249  static
251  ULONG
252  _ComputePartialSize(
254  )
255  {
257  }
258 
259 protected:
260 
263 
264 #if (FX_CORE_MODE == FX_CORE_USER_MODE)
265 private:
266 
267  //
268  // If FALSE, then closing or destroying the FxRegKey
269  // will have no effect on the HKEY m_Key.
270  //
272 
273 public:
274 
275  VOID
276  __inline
278  BOOLEAN CanCloseHandle
279  )
280  {
281  m_CanCloseHandle = CanCloseHandle;
282  }
283 #endif
284 };
285 
286 #endif // _FXREGKEY_H_
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
PFX_DRIVER_GLOBALS m_Globals
Definition: fxregkey.hpp:262
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define __in_opt
Definition: dbghelp.h:38
_In_ BOOLEAN Create
Definition: pstypes.h:527
_Must_inspect_result_ __in ULONG __in_bcount(ValueLength) PVOID Value
__inline HANDLE GetHandle(VOID)
Definition: fxregkey.hpp:103
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:56
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:279
#define Open
Definition: syshdrs.h:62
#define __out_opt
Definition: dbghelp.h:65
#define FALSE
Definition: types.h:117
static _Must_inspect_result_ _In_ PCUNICODE_STRING _In_ ULONG _In_reads_bytes_(ValueLength) PVOID Value
#define __out
Definition: dbghelp.h:62
unsigned char BOOLEAN
#define _In_
Definition: ms_sal.h:308
VOID __inline SetCanCloseHandle(BOOLEAN CanCloseHandle)
Definition: fxregkey.hpp:277
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
__drv_maxIRQL(PASSIVE_LEVEL) ~FxRegKey(VOID)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
BOOLEAN m_CanCloseHandle
Definition: fxregkey.hpp:271
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG _Out_opt_ PULONG CreateDisposition
Definition: wdfregistry.h:112
HANDLE m_Key
Definition: fxregkey.hpp:261
static LONG WINAPI QueryValue(HANDLE hcKey, LPCWSTR pszValue, PDWORD pType, PBYTE pData, PDWORD pcbData, HANDLE hSpooler)
Definition: localmon.c:206
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
HKEY key
Definition: reg.c:42
_Must_inspect_result_ __in ULONG __out_bcount_opt(ValueLength) PVOID Value
__inline VOID SetHandle(__in HANDLE Key)
Definition: fxregkey.hpp:94
static __out_range(Length,(Length+sizeof(KEY_VALUE_PARTIAL_INFORMATION) -1)) ULONG _ComputePartialSize(__in_bound ULONG Length)
Definition: fxregkey.hpp:250
FxRegKey(PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: fxregkeykm.cpp:29
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define __in_bound
Definition: specstrings.h:332
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG CreateOptions
Definition: wdfregistry.h:112
static _Must_inspect_result_ __in HANDLE Key
Definition: fxregkey.hpp:199
static BOOLEAN __inline _IsValidSzType(__in ULONG RegValueType)
Definition: fxregkey.hpp:230
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey
Definition: wdfregistry.h:69
Definition: sacdrv.h:267
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
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
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG ValueLengthQueried
Definition: wdfregistry.h:279
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __in
Definition: dbghelp.h:35
ULONG ACCESS_MASK
Definition: nt_native.h:40
__drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS Close(VOID)
Definition: fxregkey.hpp:110
Definition: path.c:41
#define REG_SZ
Definition: layer.c:22
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:271