ReactOS  0.4.14-dev-55-g2da92ac
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  }
93  RegCloseKey(hKey);
94 } // end RegTCloseKeyHandle()
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423

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]) {
122  status = RegTGetKeyHandle(hRootKey, RegistryPath, &hKey);
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) {
146  RegTCloseKeyHandle(hKey);
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) {
183  RegTCloseKeyHandle(hKey);
184  }
185  return retval;
186 } // end RegTGetDwordValue()
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG NTSTATUS
Definition: precomp.h:26
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
#define MyFreePool__(addr)
Definition: mem_tools.h:152
VOID RegTCloseKeyHandle(IN HKEY hKey)
Definition: regtools.cpp:86
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
NTSTATUS RegTGetKeyHandle(IN HKEY hRootKey, IN PWCHAR KeyName, OUT HKEY *hKey)
Definition: regtools.cpp:59
static SERVICE_STATUS status
Definition: service.c:31
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
Definition: ps.c:97

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]) {
213  status = RegTGetKeyHandle(hRootKey, RegistryPath, &hKey);
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) {
234  RegTCloseKeyHandle(hKey);
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) {
275  RegTCloseKeyHandle(hKey);
276  }
277  return retval;
278 } // end RegTGetStringValue()
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG NTSTATUS
Definition: precomp.h:26
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
#define MyFreePool__(addr)
Definition: mem_tools.h:152
VOID RegTCloseKeyHandle(IN HKEY hKey)
Definition: regtools.cpp:86
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
NTSTATUS RegTGetKeyHandle(IN HKEY hRootKey, IN PWCHAR KeyName, OUT HKEY *hKey)
Definition: regtools.cpp:59
static SERVICE_STATUS status
Definition: service.c:31
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
Definition: ps.c:97