uLib  User mode C/C++ extended API library for Win32 programmers.
RegFunc.cpp
Go to the documentation of this file.
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 // Project: uLib - User mode library.
3 // Module: Registry functions and support classes.
4 // Author: Copyright (c) Love Nystrom
5 // License: NNOSL (BSD descendant, see NNOSL.txt in the base directory).
6 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 
8 #include <uLib/RegFunc.h>
9 #include <StdIo.h>
10 
11 #define RNAME_CHUNK MAX_PATH
12 #define RDATA_CHUNK MAX_PATH
13 
14 #ifdef __GNUC__ // Omissions and quirks...
15  #ifndef LSTATUS
16  typedef LONG LSTATUS;
17  #endif // LSTATUS
18 #endif // __GNUC__
19 
20 //== RegCloseKeyEx ==----------------------------------------------------------
21 
22 HKEY RegCloseKeyEx( HKEY Key )
23 {
24  if (!Key) SetLastError( ERROR_INVALID_HANDLE );
25  else
26  {
27  LSTATUS rc = RegCloseKey( Key );
28  if (rc == 0) Key = NULL; else SetLastError( rc );
29  }
30  return Key;
31 }
32 
33 //== RegKeyExist ==------------------------------------------------------------
34 
35 BOOL RegKeyExist( HKEY BaseKey, CSTR RegPath )
36 {
37  HKEY hKey;
38  LSTATUS rc = RegOpenKey( BaseKey, RegPath, &hKey );
39  BOOL ok = (rc == 0);
40  if (ok) RegCloseKey( hKey );
41  return ok;
42 }
43 
44 //== RegValueExist ==----------------------------------------------------------
45 
46 BOOL RegValueExist( HKEY key, CSTR name )
47 {
48  LONG rc = RegQueryValueEx( key, name, 0,NULL,NULL,NULL );
49  return REG_OK( rc );
50 }
51 
52 //== Get registry value info ==------------------------------------------------
53 
54 LONG RegGetValueInfo( HKEY hKey, CSTR ValName, PDWORD pSize, PDWORD pType )
55 {
56  DWORD cbData = 0, dwData = 0;
57  // NOTE: lpData can not be NULL if we want to find out cbData reliably. Why?
58  LONG rc = RegQueryValueEx( hKey, ValName, NULL, pType, (PBYTE)&dwData, &cbData );
59  if (pSize && (rc == ERROR_MORE_DATA))
60  {
61  rc = NOERROR;
62  *pSize = cbData;
63  }
64  return rc;
65 }
66 
67 //-----------------------------------------------------------------------------
68 // Rename a registry value
69 //-----------------------------------------------------------------------------
70 
71 LONG RegRenameValue( HKEY hKey, CSTR OldName, CSTR NewName )
72 {
73  DWORD vType, cbData;
74  BYTE tmpBuf[MAX_PATH], useHeap;
75  LONG rc;
76 
77  rc = RegGetValueInfo( hKey, OldName, &cbData, NULL );
78  if (REG_OK( rc ))
79  {
80  useHeap = (cbData > sizeof(tmpBuf));
81  PBYTE pData = useHeap ? (PBYTE) mem_Alloc( cbData ) : tmpBuf;
82  rc = RegQueryValueEx( hKey, OldName, NULL, &vType, pData, &cbData );
83  if (REG_OK( rc ))
84  {
85  rc = RegSetValueEx( hKey, NewName, 0, vType, pData, cbData );
86  if (REG_OK( rc )) RegDeleteValue( hKey, OldName );
87  }
88  if (useHeap) mem_Free( pData );
89  }
90  return rc;
91 }
92 
93 //== REG_DWORD ==--------------------------------------------------------------
94 
95 LONG RegSetDWord( HKEY hKey, CSTR ValName, DWORD Val )
96 {
97  return RegSetValueEx( hKey, ValName, 0, REG_DWORD, (PBYTE)&Val, sizeof(DWORD) );
98 }
99 
100 LONG RegGetDWord( HKEY hKey, CSTR ValName, PDWORD pVal )
101 {
102  DWORD type, cbRd = sizeof(DWORD);
103  LONG rc = RegQueryValueEx( hKey, ValName, NULL, &type, (PBYTE)pVal, &cbRd );
104  if (REG_OK( rc ))
105  {
106  if (type != REG_DWORD || cbRd != sizeof(DWORD)) rc = ERROR_INVALID_DATA;
107  }
108  return rc;
109 }
110 
111 LONG RegGetUInt( HKEY hKey, CSTR ValName, PUINT pVal )
112 {
113  return RegGetDWord( hKey, ValName, (PDWORD)pVal );
114 }
115 
116 LONG RegGetBool( HKEY hKey, CSTR ValName, bool* pVal )
117 {
118  DWORD tmp = 0;
119  LONG rc = RegGetDWord( hKey, ValName, &tmp );
120  if (REG_OK( rc )) *pVal = bool_cast( tmp );
121  return rc;
122 }
123 
124 //== REG_BINARY ==-------------------------------------------------------------
125 
126 LONG RegSetBinary( HKEY hKey, CSTR ValName, PBYTE Val, DWORD Size )
127 {
128  return RegSetValueEx( hKey, ValName, 0, REG_BINARY, Val, Size );
129 }
130 
131 LONG RegGetBinary( HKEY hKey, CSTR ValName, PBYTE pVal, PDWORD pSize )
132 {
133  DWORD type;
134  LONG rc = RegQueryValueEx( hKey, ValName, NULL, &type, pVal, pSize );
135  if (REG_OK( rc ))
136  {
137  if (type != REG_BINARY) rc = ERROR_INVALID_DATA; // Check it's BINARY
138  }
139  return rc;
140 }
141 
142 //== REG_SZ ==-----------------------------------------------------------------
143 
144 LONG RegSetString( HKEY hKey, CSTR ValName, CSTR Str, DWORD Type )
145 {
146  DWORD size = (Type == REG_MULTI_SZ) ? MultiSzLength( Str ) : (1 + (DWORD)_tcslen( Str ));
147  size *= sizeof(TCHAR);
148  return RegSetValueEx( hKey, ValName, 0, Type, (PBYTE)Str, size );
149 }
150 
151 LONG RegGetString( HKEY hKey, CSTR ValName, TSTR Buf, PDWORD Size, PDWORD Type )
152 {
153  LONG rc = RegQueryValueEx( hKey, ValName, 0, Type, (PBYTE)Buf, Size );
154  if (REG_OK( rc ))
155  {
156  // Reg strings are not always NUL terminated, so terminate it.
157  DWORD type = *Type; // Avoid repeated ptr referencing..
158  if (type == REG_SZ || type == REG_EXPAND_SZ || type == REG_MULTI_SZ)
159  Buf[ *Size ] = 0;
160  else rc = ERROR_INVALID_DATA; // Reg value is not a string.
161  }
162  return rc;
163 }
164 
165 // Save/Restore window rectangle
166 
167 LONG SaveWindowRect( HWND hWnd, HKEY baseKey, CSTR regPath, CSTR valName )
168 {
169  HKEY Key; RECT R; LONG rc;
170  if (IsMinimized( hWnd )) rc = ERROR_INCORRECT_SIZE;
171  else
172  {
173  rc = RegCreateKeyEx( baseKey, regPath, 0, NULL, 0, KEY_WRITE, NULL, &Key, NULL );
174  if (rc == NOERROR)
175  {
176  GetWindowRect( hWnd, &R );
177  RegSetValueEx( Key, valName, 0, REG_BINARY, (PBYTE)&R, sizeof(RECT) );
178  RegCloseKey( Key );
179  }
180  }
181  return rc;
182 }
183 
184 LONG RestoreWindowRect( HWND hWnd, HKEY baseKey, CSTR regPath, CSTR valName )
185 {
186  HKEY Key; RECT R;
187  LONG rc = RegOpenKeyEx( baseKey, regPath, 0, KEY_READ, &Key );
188  if (rc == NOERROR)
189  {
190  DWORD type = 0, cb = sizeof(RECT);
191  rc = RegQueryValueEx( Key, valName, 0, &type, (PBYTE)&R, &cb );
192  if (rc == NOERROR)
193  {
194  // Constrain rect to stay on the visible screen.
195  SIZE scrSiz = { SYSMET( CXSCREEN ), SYSMET( CYSCREEN ) };
196  if ((R.left < 0) || (R.left > scrSiz.cx)) OffsetRect( &R, -R.left, 0 );
197  if ((R.top < 0) || (R.top > scrSiz.cy)) OffsetRect( &R, 0, -R.top );
198 
199  AbsToDimRect( &R ); //right/bottom = width/height
200  SetWindowPos( hWnd, NULL, R.left, R.top, R.right, R.bottom, SWP_NOZORDER );
201  }
202  RegCloseKey( Key );
203  }
204  return rc;
205 }
206 
207 //-----------------------------------------------------------------------------
208 // RegDeleteBranch - Recursively delete a key and it's sub-keys
209 // Parent - An open key
210 // SubkeyName - Name of a subkey to delete
211 //-----------------------------------------------------------------------------
212 
213 LONG RegDeleteBranch( HKEY Parent, CSTR SubkeyName )
214 {
215  DWORD nSubkeys, nRemain, ccKeyname, len;
216  TSTR pKeyname;
217  HKEY hSubkey;
218  FILETIME time;
219  LONG rc, bufSize;
220 
221  rc = RegOpenKeyEx( Parent, SubkeyName, 0,KEY_ALL_ACCESS, &hSubkey );
222  if (REG_ERR( rc ))
223  DPrint( DP_ERROR, _F("RegOpenKeyEx '%s' failed: %s\n"), SubkeyName, SysErrorMsg(rc) );
224  else
225  {
226  // The subkey exists - See if it has subkeys of it's own
227 
228  rc = RegQuerySubkeys( hSubkey, &nSubkeys, &ccKeyname );
229  if (REG_ERR( rc ))
230  DPrint( DP_ERROR, _F("RegQueryInfoKey '%s' failed: %s\n"), SubkeyName, SysErrorMsg(rc) );
231  else if (nSubkeys > 0)
232  {
233  // It does - Enumerate them
234 
235  bufSize = ccKeyname + 1;
236  pKeyname = (TSTR) mem_AllocStr( (WORD)bufSize ); // Get a name buffer
237  if (!pKeyname)
238  {
239  rc = ERROR_OUTOFMEMORY; // Give up
240  DPrint( DP_ERROR, _F("Alloc(%u) failed: %s\n"), bufSize, SysErrorMsg(rc) );
241  goto rdb_bailout; // RegDeleteKey will (NT/2000) fail but let it try
242  }
243 
244  // Now commence the recursive deletion loop
245 
246  nRemain = nSubkeys;
247  while( nRemain > 0 )
248  {
249  len = bufSize;
250  // Trick #9: Always retrieve index 0 and decrease count when deleting,
251  // instead of stepping the index up which would overrun after N/2..
252  rc = RegEnumKeyEx( hSubkey, 0, pKeyname,&len, NULL,NULL,NULL, &time );
253  if (REG_OK( rc ))
254  {
255  // Recurse with open key + subkey name
256 
257  rc = RegDeleteBranch( hSubkey, pKeyname ); // RECURSE ...
258 
259  if (REG_OK( rc )) nRemain--;
260  else if (rc == ERROR_NO_MORE_ITEMS) nRemain = 0;
261  }
262  else // RegEnumKey failed
263  {
264  DPrint( DP_ERROR, _F("Key '%s'. RegEnumKeyEx(%d) failed: %s\n"), SubkeyName, 0, SysErrorMsg(rc) );
265  IF_DEBUG( DebugBreak(); )
266  }
267  }
268  mem_FreeStr( pKeyname );
269  }
270  rdb_bailout:
271  RegCloseKey( hSubkey );
272  }
273 
274  // At this point, any and all subkeys have been deleted already.
275  // (Unless there was a memory allocation failure.. Let system try anyway)
276 
277  rc = RegDeleteKey( Parent, SubkeyName ); // Not recursive on Win NT.
278  if (REG_ERR( rc )) DPrint( DP_ERROR, _F(" RegDeleteKey '%s' failed: %s\n"), SubkeyName, SysErrorMsg(rc) );
279  return rc;
280 }
281 
282 //-----------------------------------------------------------------------------
283 // RegRenameKey - Synopsis
284 //
285 // 1) Adjust process priviledges
286 // 2) Open the existing source key
287 // 3) Save the source branch to a tempfile
288 // 4) Query source key class and security size
289 // 5) Allocate security descriptor
290 // 6) Create a new key with the new name, and equal security and class
291 // 7) Load the tempfile into the new key
292 // 8) On failure, delete the new key
293 // 9) On success, delete the old key
294 // 10) Clean up in reverse order (stack style)
295 //
296 //-----------------------------------------------------------------------------
297 
298 #define tempName TEXT("_RegKey_Temp_.bin") // Temporary file name
299 #define PRIVI_BUFSIZE 256
300 
301 LONG _RegRenameKey( HKEY BaseKey, CSTR Subkey, CSTR NewSubkeyName )
302 {
303  PISECURITY_DESCRIPTOR secDesc; // PI.. Internal (with fields)
304  SECURITY_ATTRIBUTES secAtt;
305  PTOKEN_PRIVILEGES savePriv;
306 
307  HANDLE hTok; // Process token
308  HKEY hKey; // Source key with security descriptor access
309  HKEY newKey;
310  BOOL privOk, allDone;
311  LONG err;
312  DWORD ccClass, cbSecDesc, dispo;
313  TCHAR szClass[ MAX_PATH ];
314  FILETIME ftWrit;
315 
316  savePriv = NULL;
317  secDesc = NULL;
318  allDone = FALSE;
319  privOk = FALSE;
320 
321  // Adjust process privileges
322 
323  if (!OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY| TOKEN_ADJUST_PRIVILEGES, &hTok )) {
324  TRACE( DP_ERROR, _F("OpenProcessToken failed: %s\n"), SysErrorMsg() );
325  hTok = NULL;
326  } else {
327  privOk = EnablePrivileges(
328  hTok, true, &savePriv, SE_BACKUP_NAME, SE_RESTORE_NAME, SE_SECURITY_NAME, 0
329  );
330  if (!privOk)
331  {
332  err = GetLastError();
333  privOk = (err == ERROR_NOT_ALL_ASSIGNED); // Possibly acceptable error..
334  IF_DEBUG( if (!privOk) DPrint(
335  DP_ERROR, _F("AdjustTokenPrivileges failed: %s\n"), SysErrorMsg( err )
336  );
337  )
338  }
339  }
340  // If it failed, try anyway, and fail out later if unsuccessful.
341 
342  // Open a source key with security access
343 
344  err = RegOpenKeyEx( BaseKey, Subkey, 0, KEY_ALL_ACCESS| ACCESS_SYSTEM_SECURITY, &hKey );
345  if (REG_ERR( err )) {
346  TRACE( DP_ERROR, _F("RegOpenKeyEx failed: %s\n"), SysErrorMsg( err ));
347  goto exit_RestorePriv;
348  }
349 
350  // Save branch to tempfile
351 
352  if (FileExist( tempName )) DeleteFile( tempName ); // Delete old file if any
353  err = RegSaveKey( hKey, tempName, 0 ); // Save to temp file
354  if (REG_ERR( err )) {
355  TRACE( DP_ERROR, _F("RegSaveKey failed: %s\n"), SysErrorMsg( err ));
356  goto exit_CloseSrc;
357  }
358 
359  // Get key class and security descriptor size
360 
361  ccClass = MAX_PATH;
362  err = RegQueryInfoKey( hKey, szClass, &ccClass, 0,0,0,0,0,0,0, &cbSecDesc, &ftWrit );
363  if (REG_ERR( err )) {
364  TRACE( DP_ERROR, _F("RegQueryInfoKey failed: %s\n"), SysErrorMsg( err ));
365  goto exit_DeleteTemp;
366  }
367 
368  // Get security descriptor (if step 1 was ok, we have sufficient privilege)
369 
370  secDesc = (PISECURITY_DESCRIPTOR) mem_Alloc( cbSecDesc );
371  if (secDesc) err = RegGetKeySecurity( hKey, ALL_SECURITY_INFO, secDesc, &cbSecDesc );
372  else err = ERROR_OUTOFMEMORY;
373  if (REG_ERR( err )) {
374  TRACE( DP_ERROR, _F("RegGetKeySecurity failed: %s\n"), SysErrorMsg( err ));
375  goto exit_DeleteTemp;
376  }
377 
378  // Create new key with the same class and security as the old
379 
380  secAtt.lpSecurityDescriptor = secDesc;
381  secAtt.bInheritHandle = FALSE;
382  secAtt.nLength = sizeof(secAtt);
383 
384  err = RegCreateKeyEx(
385  BaseKey, NewSubkeyName, 0, szClass, REG_OPTION_BACKUP_RESTORE, //| REG_OPTION_NON_VOLATILE
386  KEY_ALL_ACCESS| ACCESS_SYSTEM_SECURITY, &secAtt, &newKey, &dispo
387  );
388  if (REG_ERR( err )) {
389  TRACE( DP_ERROR, _F("RegCreateKeyEx failed: %s\n"), SysErrorMsg( err ));
390  goto exit_DeleteSec;
391  }
392 
393  // Load saved branch
394 
395  err = RegRestoreKey( newKey, tempName, REG_FORCE_RESTORE );
396  if (REG_OK( err ))
397  allDone = TRUE;
398  else { // Braced, since this is an empty statement in Release buils.
399  TRACE( DP_ERROR, _F("RegRestoreKey failed: %s\n"), SysErrorMsg( err ));
400  }
401 
402 //exit_CloseNew: // 6
403  RegCloseKey( newKey ); // Close it and ..
404  if (allDone == FALSE) RegDeleteBranch( BaseKey, NewSubkeyName ); // .. revert all parts done, if any
405 
406 exit_DeleteSec: // 5
407  mem_Free( secDesc );
408 
409 exit_DeleteTemp: // 3
410  if (FileExist( tempName )) DeleteFile( tempName );
411 
412 exit_CloseSrc: // 2 // Delete the source key and keep the new
413  err = RegCloseKey( hKey );
414  #if _DEBUG
415  if (REG_ERR( err ))
416  DPrint( DP_ERROR, _F("RegCloseKey failed: %s\n"), SysErrorMsg( err ));
417  #endif
418 
419  if (allDone)
420  {
421  err = RegDeleteBranch( BaseKey, Subkey ); // delete old key + subkeys
422  #if _DEBUG
423  if (REG_ERR( err ))
424  DPrint( DP_ERROR, _F("RegDeleteBranch failed: %s\n"), SysErrorMsg( err ));
425  #endif
426  }
427 
428 exit_RestorePriv: // 1
429  if (privOk) RestorePrivileges( hTok, savePriv, true );
430  if (hTok) CloseHandle( hTok );
431  return err;
432 }
433 
434 //-----------------------------------------------------------------------------
435 // String representations of registry types
436 //-----------------------------------------------------------------------------
437 
438 #define ULONG_HKCR ULONG_PTR( HKEY_CLASSES_ROOT )
439 
440 CSTR RegSysKeyName( HKEY hkey )
441 {
442  static CCSTR SysKey[ 9 ] = {
443  _T("HKEY_CLASSES_ROOT"), // 0
444  _T("HKEY_CURRENT_USER"), // 1
445  _T("HKEY_LOCAL_MACHINE"), // 2
446  _T("HKEY_USERS"), // 3
447  _T("HKEY_PERFORMANCE_DATA"), // 4 Only WinNT/2000
448  _T("HKEY_CURRENT_CONFIG"), // 5
449  _T("HKEY_DYN_DATA"), // 6 Only Win95/98
450  //
451  _T("HKEY_PERFORMANCE_TEXT"), // 0x50
452  _T("HKEY_PERFORMANCE_NLSTEXT") // 0x60
453  };
454 
455  // Compute the array index, skipping over the gap between 6 and x50
456  ULONG_PTR keyNr = ULONG_PTR( hkey ) - ULONG_HKCR;
457  if (keyNr > 6) keyNr = (keyNr >> 4) + 2;
458 
459  if (keyNr < 9) return SysKey[ keyNr ];
460 
461  static __thread_local TCHAR kname[ 24 ]; // %p == 8/16 char (x86/x64)
462  _stprintf_s( kname, dimof(kname), _T("HKEY_%p"), (PVOID) hkey );
463  TRACE( DP_WARNING, _T("Non-system key %p passed to RegSysKeyName.\n"), hkey );
464  return kname;
465 }
466 
467 CSTR RegSysKeyAcronym( HKEY hkey ) // Return 4 char acronym of predefined hkey, or NULL
468 {
469  static CCSTR SysAcro[ 9 ] = {
470  _T("HKCR"), // 0
471  _T("HKCU"), // 1
472  _T("HKLM"), // 2
473  _T("HKU"), // 3
474  _T("HKPD"), // 4 Only WinNT/2000
475  _T("HKCC"), // 5
476  _T("HKDD"), // 6 Only Win95/98
477  //
478  _T("HKPT"), // 0x50
479  _T("HKPN") // 0x60
480  };
481  // Compute the array index, skipping over the gap between 6 and x50
482  ULONG_PTR keyNr = ULONG_PTR( hkey ) - ULONG_HKCR;
483  if (keyNr > 6) keyNr = (keyNr >> 4) + 2;
484 
485  if (keyNr < 9) return SysAcro[ keyNr ];
486 
487  static __thread_local TCHAR kname[ 24 ]; // %p == 8/16 char (x86/x64)
488  _stprintf_s( kname, dimof(kname), _T("HK%p"), (PVOID) hkey );
489  TRACE( DP_WARNING, _T("Non-system key %p passed to RegSysKeyAcronym.\n"), hkey );
490  return kname;
491 }
492 
494 {
495  static CCSTR RegVType[ 12 ] = {
496  _T("REG_NONE"), // 0
497  _T("REG_SZ"), // 1
498  _T("REG_EXPAND_SZ"), // 2
499  _T("REG_BINARY"), // 3
500  _T("REG_DWORD"), // 4
501  _T("REG_DWORD_BIG_ENDIAN"), // 5
502  _T("REG_LINK"), // 6
503  _T("REG_MULTI_SZ"), // 7
504  _T("REG_RESOURCE_LIST"), // 8
505  _T("REG_FULL_RESOURCE_DESCRIPTOR"), // 9
506  _T("REG_RESOURCE_REQUIREMENTS_LIST"), // 10
507  _T("REG_QWORD") // 11
508  };
509  if (type <= REG_QWORD) return RegVType[ type ];
510 
511  static __thread_local TCHAR sbuf[ 16 ];
512  _stprintf_s( sbuf, dimof(sbuf), _T("REG_0x%lX"), type );
513  return sbuf; // User type
514 }
515 
517 {
518  if (!name) name = _T("(null)");
519  else if (!*name) name = _T("(default)");
520  return name;
521 }
522 
523 //-----------------------------------------------------------------------------
524 // EOF
unsigned long DWORD
Definition: Common.h:414
LONG RegSetString(HKEY hKey, CSTR ValName, CSTR Str, DWORD Type)
Definition: RegFunc.cpp:144
#define REG_OK(rc)
Definition: RegFunc.h:34
#define SYSMET(Id)
Definition: UtilFunc.h:923
LONG RestoreWindowRect(HWND hWnd, HKEY baseKey, CSTR regPath, CSTR valName)
Definition: RegFunc.cpp:184
#define CSTR
Definition: Common.h:329
CSTR mem_FreeStr(CSTR Dup)
Definition: StrFunc.cpp:270
unsigned short WORD
Definition: Common.h:413
#define IF_DEBUG(code)
Definition: Debug.h:236
HKEY RegCloseKeyEx(HKEY Key)
Definition: RegFunc.cpp:22
bool FileExist(CSTR PathName)
Definition: IoUtil.cpp:24
CSTR RegValueName(CSTR name)
Definition: RegFunc.cpp:516
LONG RegGetDWord(HKEY hKey, CSTR ValName, PDWORD pVal)
Definition: RegFunc.cpp:100
void * mem_Alloc(size_t Bytes)
Definition: MemFunc.cpp:33
LONG RegGetBool(HKEY hKey, CSTR ValName, bool *pVal)
Definition: RegFunc.cpp:116
bool EnablePrivileges(IN HANDLE hToken, IN bool Enable, OPTOUT PTOKEN_PRIVILEGES *ppSave,...)
#define TSTR
Definition: Common.h:328
unsigned char * PBYTE
Definition: Common.h:412
#define dimof(x)
Definition: Common.h:949
void __cdecl DPrint(int Level, CSTR Fmt,...)
Definition: Debug.cpp:134
BOOL RegKeyExist(HKEY BaseKey, CSTR RegPath)
Definition: RegFunc.cpp:35
#define TRACE(_lvl,...)
Definition: Debug.h:216
LONG RegGetString(HKEY hKey, CSTR ValName, TSTR Buf, PDWORD Size, PDWORD Type)
Definition: RegFunc.cpp:151
LONG RegGetUInt(HKEY hKey, CSTR ValName, PUINT pVal)
Definition: RegFunc.cpp:111
#define tempName
Definition: RegFunc.cpp:298
BOOL(WINAPI *SysImgList::Shell_GetImageLists)(HIMAGELIST *pimlLarge
const LPCTSTR CCSTR
Definition: Common.h:335
#define mem_AllocStr
Definition: StrFunc.h:142
#define ALL_SECURITY_INFO
Definition: RegFunc.h:29
void * mem_Free(void *pBlk)
Definition: MemFunc.cpp:124
CSTR SysErrorMsg(DWORD Err=0, TSTR Buf=NULL, UINT Length=0)
Definition: Debug.cpp:39
CSTR RegSysKeyName(HKEY hkey)
Definition: RegFunc.cpp:440
LONG _RegRenameKey(HKEY BaseKey, CSTR Subkey, CSTR NewSubkeyName)
Definition: RegFunc.cpp:301
bool __forceinline bool_cast(BOOL B52)
Definition: Common.h:767
#define DP_ERROR
Definition: Debug.h:82
CSTR RegSysKeyAcronym(HKEY hkey)
Definition: RegFunc.cpp:467
LONG RegSetBinary(HKEY hKey, CSTR ValName, PBYTE Val, DWORD Size)
Definition: RegFunc.cpp:126
#define ULONG_HKCR
Definition: RegFunc.cpp:438
LONG RegDeleteBranch(HKEY Parent, CSTR SubkeyName)
Definition: RegFunc.cpp:213
#define MultiSzLength
Definition: StrFunc.h:277
LONG RegGetBinary(HKEY hKey, CSTR ValName, PBYTE pVal, PDWORD pSize)
Definition: RegFunc.cpp:131
#define _F(s)
Definition: Debug.h:49
#define REG_ERR(rc)
Definition: RegFunc.h:35
BOOL RegValueExist(HKEY key, CSTR name)
Definition: RegFunc.cpp:46
LONG SaveWindowRect(HWND hWnd, HKEY baseKey, CSTR regPath, CSTR valName)
Definition: RegFunc.cpp:167
LONG RegRenameValue(HKEY hKey, CSTR OldName, CSTR NewName)
Definition: RegFunc.cpp:71
bool RestorePrivileges(HANDLE hToken, PTOKEN_PRIVILEGES pSaved, bool Dispose)
Definition: SecUtil.cpp:219
LPRECT AbsToDimRect(LPRECT pRect)
Definition: UtilFunc.cpp:86
#define DP_WARNING
Definition: Debug.h:83
LONG RegGetValueInfo(HKEY hKey, CSTR ValName, PDWORD pSize, PDWORD pType)
Definition: RegFunc.cpp:54
unsigned char BYTE
Definition: Common.h:412
#define RegQuerySubkeys(hKey, pNrKeys, pCcKeyname)
Definition: RegFunc.h:71
LONG RegSetDWord(HKEY hKey, CSTR ValName, DWORD Val)
Definition: RegFunc.cpp:95
CSTR RegTypeName(DWORD type)
Definition: RegFunc.cpp:493
unsigned long * PDWORD
Definition: Common.h:414