ReactOS 0.4.15-dev-8219-ge8b88cf
regtools.h File Reference
#include "check_env.h"
Include dependency graph for regtools.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NTSTATUS RegTGetKeyHandle (IN HKEY hRootKey, IN PCWSTR KeyName, OUT HKEY *hKey)
 
VOID RegTCloseKeyHandle (IN HKEY hKey)
 
BOOLEAN RegTGetDwordValue (IN HKEY hRootKey, IN PCWSTR RegistryPath, IN PCWSTR Name, IN PULONG pUlong)
 
BOOLEAN RegTGetStringValue (IN HKEY hRootKey, IN PCWSTR RegistryPath, IN PCWSTR Name, IN PWCHAR pStr, IN ULONG MaxLen)
 

Function Documentation

◆ RegTCloseKeyHandle()

VOID RegTCloseKeyHandle ( IN HKEY  hKey)

Definition at line 86 of file regtools.cpp.

89{
90 if(!hKey) {
91 return;
92 }
94} // end RegTCloseKeyHandle()
#define RegCloseKey(hKey)
Definition: registry.h:49
FxAutoRegKey hKey

Referenced by RegTGetDwordValue(), RegTGetStringValue(), and UDFRegCheckParameterValue().

◆ RegTGetDwordValue()

BOOLEAN RegTGetDwordValue ( IN HKEY  hRootKey,
IN PCWSTR  RegistryPath,
IN PCWSTR  Name,
IN PULONG  pUlong 
)

Definition at line 99 of file regtools.cpp.

105{
106#ifndef WIN_32_MODE
107 UNICODE_STRING NameString;
109#endif //WIN_32_MODE
110 ULONG len;
112 HKEY hKey;
113 BOOLEAN retval = FALSE;
114 BOOLEAN free_h = FALSE;
115
116#ifdef WIN_32_MODE
117 if(!hRootKey)
118 hRootKey = HKEY_LOCAL_MACHINE;
119#endif //WIN_32_MODE
120
121 if(RegistryPath && RegistryPath[0]) {
123#ifdef WIN_32_MODE
124 if(status != ERROR_SUCCESS)
125#else //WIN_32_MODE
126 if(!NT_SUCCESS(status))
127#endif //WIN_32_MODE
128 return FALSE;
129 free_h = TRUE;
130 } else {
131 hKey = hRootKey;
132 }
133 if(!hKey)
134 return FALSE;
135
136#ifndef WIN_32_MODE
137/*
138 UDFPrint(("h=%x|%S, %S (%x)\n",
139 hRootKey, RegistryPath, Name, *pUlong));
140*/
141 len = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG) + 0x20;
144 if(!ValInfo) {
145 if(free_h) {
147 }
148 return FALSE;
149 }
150
151 RtlInitUnicodeString(&NameString, Name);
152
153 status = ZwQueryValueKey(hKey,
154 &NameString,
156 ValInfo,
157 len,
158 &len);
159 if(NT_SUCCESS(status) &&
160 ValInfo->DataLength == sizeof(ULONG)) {
161 RtlCopyMemory(pUlong, ValInfo->Data, sizeof(ULONG));
162 retval = TRUE;
163 //UDFPrint((" -> %x\n",*pUlong));
164 } else {
165 //UDFPrint((" err %x\n",status));
166 }
167
168 MyFreePool__(ValInfo);
169#else //WIN_32_MODE
170 len = sizeof(ULONG);
172 hKey, // handle of key to query
173 Name, // address of name of value to query
174 0, // reserved
175 NULL, // address of buffer for value type
176 (BYTE *)pUlong, // address of data buffer
177 &len // address of data buffer size
178 ) && len == sizeof(ULONG)) {
179 retval = TRUE;
180 }
181#endif //WIN_32_MODE
182 if(free_h) {
184 }
185 return retval;
186} // end RegTGetDwordValue()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define NonPagedPool
Definition: env_spec_w32.h:307
GLenum GLsizei len
Definition: glext.h:6722
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
#define MyFreePool__(addr)
Definition: mem_tools.h:152
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
VOID RegTCloseKeyHandle(IN HKEY hKey)
Definition: regtools.cpp:86
NTSTATUS RegTGetKeyHandle(IN HKEY hRootKey, IN PWCHAR KeyName, OUT HKEY *hKey)
Definition: regtools.cpp:59
Definition: ps.c:97
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
unsigned char BYTE
Definition: xxhash.c:193

Referenced by UDFRegCheckParameterValue().

◆ RegTGetKeyHandle()

NTSTATUS RegTGetKeyHandle ( IN HKEY  hRootKey,
IN PCWSTR  KeyName,
OUT HKEY hKey 
)

◆ RegTGetStringValue()

BOOLEAN RegTGetStringValue ( IN HKEY  hRootKey,
IN PCWSTR  RegistryPath,
IN PCWSTR  Name,
IN PWCHAR  pStr,
IN ULONG  MaxLen 
)

Definition at line 189 of file regtools.cpp.

196{
197#ifndef WIN_32_MODE
198 UNICODE_STRING NameString;
200#endif //USER_MODE
201 ULONG len;
203 HKEY hKey;
204 BOOLEAN retval = FALSE;
205 BOOLEAN free_h = FALSE;
206
207#ifdef WIN_32_MODE
208 if(!hRootKey)
209 hRootKey = HKEY_LOCAL_MACHINE;
210#endif //WIN_32_MODE
211
212 if(RegistryPath && RegistryPath[0]) {
214#ifdef WIN_32_MODE
215 if(status != ERROR_SUCCESS)
216#else //WIN_32_MODE
217 if(!NT_SUCCESS(status))
218#endif //WIN_32_MODE
219 return FALSE;
220 free_h = TRUE;
221 } else {
222 hKey = hRootKey;
223 }
224 if(!hKey)
225 return FALSE;
226
227 pStr[0] = 0;
228#ifndef WIN_32_MODE
229 len = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + MaxLen + 0x20;
232 if(!ValInfo) {
233 if(free_h) {
235 }
236 return FALSE;
237 }
238
239 RtlInitUnicodeString(&NameString, Name);
240
241 status = ZwQueryValueKey(hKey,
242 &NameString,
244 ValInfo,
245 len,
246 &len);
247 if(NT_SUCCESS(status) &&
248 ValInfo->DataLength) {
249 RtlCopyMemory(pStr, ValInfo->Data, min(ValInfo->DataLength, MaxLen) );
250 if(pStr[(ValInfo->DataLength)/sizeof(WCHAR)-1]) {
251 pStr[(ValInfo->DataLength)/sizeof(WCHAR)-1] = 0;
252 }
253 retval = TRUE;
254 }
255
256 MyFreePool__(ValInfo);
257#else //WIN_32_MODE
258 len = MaxLen;
260 hKey, // handle of key to query
261 Name, // address of name of value to query
262 0, // reserved
263 NULL, // address of buffer for value type
264 (BYTE *)pStr, // address of data buffer
265 &len // address of data buffer size
266 ) && len) {
267 if(pStr[len-1]) {
268 pStr[len-1] = 0;
269 }
270 retval = TRUE;
271 }
272#endif //WIN_32_MODE
273
274 if(free_h) {
276 }
277 return retval;
278} // end RegTGetStringValue()
#define min(a, b)
Definition: monoChain.cc:55
__wchar_t WCHAR
Definition: xmlstorage.h:180