FreeRDP
registry.h
1 
20 #ifndef WINPR_REGISTRY_H
21 #define WINPR_REGISTRY_H
22 
23 #include <winpr/windows.h>
24 
25 #if defined(_WIN32) && !defined(_UWP)
26 
27 #include <winreg.h>
28 
29 #else
30 
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35 
36 #include <winpr/winpr.h>
37 #include <winpr/wtypes.h>
38 
39 #include <winpr/nt.h>
40 #include <winpr/io.h>
41 #include <winpr/error.h>
42 
43 #ifndef _WIN32
44 
45 #define OWNER_SECURITY_INFORMATION 0x00000001
46 #define GROUP_SECURITY_INFORMATION 0x00000002
47 #define DACL_SECURITY_INFORMATION 0x00000004
48 #define SACL_SECURITY_INFORMATION 0x00000008
49 
50 #define REG_OPTION_RESERVED 0x00000000
51 #define REG_OPTION_NON_VOLATILE 0x00000000
52 #define REG_OPTION_VOLATILE 0x00000001
53 #define REG_OPTION_CREATE_LINK 0x00000002
54 #define REG_OPTION_BACKUP_RESTORE 0x00000004
55 #define REG_OPTION_OPEN_LINK 0x00000008
56 
57 #define REG_CREATED_NEW_KEY 0x00000001
58 #define REG_OPENED_EXISTING_KEY 0x00000002
59 
60 #define REG_NOTIFY_CHANGE_NAME 0x01
61 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
62 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
63 #define REG_NOTIFY_CHANGE_SECURITY 0x08
64 
65 #define KEY_QUERY_VALUE 0x00000001
66 #define KEY_SET_VALUE 0x00000002
67 #define KEY_CREATE_SUB_KEY 0x00000004
68 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
69 #define KEY_NOTIFY 0x00000010
70 #define KEY_CREATE_LINK 0x00000020
71 #define KEY_WOW64_64KEY 0x00000100
72 #define KEY_WOW64_32KEY 0x00000200
73 #define KEY_WOW64_RES 0x00000300
74 
75 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
76 #define REG_REFRESH_HIVE 0x00000002
77 #define REG_NO_LAZY_FLUSH 0x00000004
78 #define REG_FORCE_RESTORE 0x00000008
79 
80 #define KEY_READ \
81  ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & \
82  (~SYNCHRONIZE))
83 
84 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE))
85 
86 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
87 
88 #define KEY_ALL_ACCESS \
89  ((STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | \
90  KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & \
91  (~SYNCHRONIZE))
92 
93  typedef enum
94  {
95  REG_NONE = 0,
96  REG_SZ = 1,
97  REG_EXPAND_SZ = 2,
98  REG_BINARY = 3,
99  REG_DWORD = 4,
100  REG_DWORD_LITTLE_ENDIAN = REG_DWORD,
101  REG_DWORD_BIG_ENDIAN = 5,
102  REG_LINK = 6,
103  REG_MULTI_SZ = 7,
104  REG_RESOURCE_LIST = 8,
105  REG_FULL_RESOURCE_DESCRIPTOR = 9,
106  REG_RESOURCE_REQUIREMENTS_LIST = 10,
107  REG_QWORD = 11,
108  REG_QWORD_LITTLE_ENDIAN = REG_QWORD
109  } eRegTypes;
110 
111  typedef HANDLE HKEY;
112  typedef HANDLE* PHKEY;
113 
114 #endif
115 
116  typedef ACCESS_MASK REGSAM;
117 
118 #define HKEY_CLASSES_ROOT ((HKEY)(LONG_PTR)(LONG)0x80000000)
119 #define HKEY_CURRENT_USER ((HKEY)(LONG_PTR)(LONG)0x80000001)
120 #define HKEY_LOCAL_MACHINE ((HKEY)(LONG_PTR)(LONG)0x80000002)
121 #define HKEY_USERS ((HKEY)(LONG_PTR)(LONG)0x80000003)
122 #define HKEY_PERFORMANCE_DATA ((HKEY)(LONG_PTR)(LONG)0x80000004)
123 #define HKEY_PERFORMANCE_TEXT ((HKEY)(LONG_PTR)(LONG)0x80000050)
124 #define HKEY_PERFORMANCE_NLSTEXT ((HKEY)(LONG_PTR)(LONG)0x80000060)
125 #define HKEY_CURRENT_CONFIG ((HKEY)(LONG_PTR)(LONG)0x80000005)
126 #define HKEY_DYN_DATA ((HKEY)(LONG_PTR)(LONG)0x80000006)
127 #define HKEY_CURRENT_USER_LOCAL_SETTINGS ((HKEY)(LONG_PTR)(LONG)0x80000007)
128 
129 #define RRF_RT_REG_NONE 0x00000001
130 #define RRF_RT_REG_SZ 0x00000002
131 #define RRF_RT_REG_EXPAND_SZ 0x00000004
132 #define RRF_RT_REG_BINARY 0x00000008
133 #define RRF_RT_REG_DWORD 0x00000010
134 #define RRF_RT_REG_MULTI_SZ 0x00000020
135 #define RRF_RT_REG_QWORD 0x00000040
136 
137 #define RRF_RT_DWORD (RRF_RT_REG_BINARY | RRF_RT_REG_DWORD)
138 #define RRF_RT_QWORD (RRF_RT_REG_BINARY | RRF_RT_REG_QWORD)
139 #define RRF_RT_ANY 0x0000FFFF
140 
141 #define RRF_NOEXPAND 0x10000000
142 #define RRF_ZEROONFAILURE 0x20000000
143 
144  struct val_context
145  {
146  int valuelen;
147  LPVOID value_context;
148  LPVOID val_buff_ptr;
149  };
150 
151  typedef struct val_context* PVALCONTEXT;
152 
153  typedef struct pvalueA
154  {
155  LPSTR pv_valuename;
156  int pv_valuelen;
157  LPVOID pv_value_context;
158  DWORD pv_type;
159  } PVALUEA, *PPVALUEA;
160 
161  typedef struct pvalueW
162  {
163  LPWSTR pv_valuename;
164  int pv_valuelen;
165  LPVOID pv_value_context;
166  DWORD pv_type;
167  } PVALUEW, *PPVALUEW;
168 
169 #ifdef UNICODE
170  typedef PVALUEW PVALUE;
171  typedef PPVALUEW PPVALUE;
172 #else
173 typedef PVALUEA PVALUE;
174 typedef PPVALUEA PPVALUE;
175 #endif
176 
177  typedef struct value_entA
178  {
179  LPSTR ve_valuename;
180  DWORD ve_valuelen;
181  DWORD_PTR ve_valueptr;
182  DWORD ve_type;
183  } VALENTA, *PVALENTA;
184 
185  typedef struct value_entW
186  {
187  LPWSTR ve_valuename;
188  DWORD ve_valuelen;
189  DWORD_PTR ve_valueptr;
190  DWORD ve_type;
191  } VALENTW, *PVALENTW;
192 
193 #ifdef UNICODE
194  typedef VALENTW VALENT;
195  typedef PVALENTW PVALENT;
196 #else
197 typedef VALENTA VALENT;
198 typedef PVALENTA PVALENT;
199 #endif
200 
201  WINPR_API LONG RegCloseKey(HKEY hKey);
202 
203  WINPR_API LONG RegCopyTreeW(HKEY hKeySrc, LPCWSTR lpSubKey, HKEY hKeyDest);
204  WINPR_API LONG RegCopyTreeA(HKEY hKeySrc, LPCSTR lpSubKey, HKEY hKeyDest);
205 
206 #ifdef UNICODE
207 #define RegCopyTree RegCopyTreeW
208 #else
209 #define RegCopyTree RegCopyTreeA
210 #endif
211 
212  WINPR_API LONG RegCreateKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass,
213  DWORD dwOptions, REGSAM samDesired,
214  LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult,
215  LPDWORD lpdwDisposition);
216  WINPR_API LONG RegCreateKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass,
217  DWORD dwOptions, REGSAM samDesired,
218  LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult,
219  LPDWORD lpdwDisposition);
220 
221 #ifdef UNICODE
222 #define RegCreateKeyEx RegCreateKeyExW
223 #else
224 #define RegCreateKeyEx RegCreateKeyExA
225 #endif
226 
227  WINPR_API LONG RegDeleteKeyExW(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired, DWORD Reserved);
228  WINPR_API LONG RegDeleteKeyExA(HKEY hKey, LPCSTR lpSubKey, REGSAM samDesired, DWORD Reserved);
229 
230 #ifdef UNICODE
231 #define RegDeleteKeyEx RegDeleteKeyExW
232 #else
233 #define RegDeleteKeyEx RegDeleteKeyExA
234 #endif
235 
236  WINPR_API LONG RegDeleteTreeW(HKEY hKey, LPCWSTR lpSubKey);
237  WINPR_API LONG RegDeleteTreeA(HKEY hKey, LPCSTR lpSubKey);
238 
239 #ifdef UNICODE
240 #define RegDeleteTree RegDeleteTreeW
241 #else
242 #define RegDeleteTree RegDeleteTreeA
243 #endif
244 
245  WINPR_API LONG RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName);
246  WINPR_API LONG RegDeleteValueA(HKEY hKey, LPCSTR lpValueName);
247 
248 #ifdef UNICODE
249 #define RegDeleteValue RegDeleteValueW
250 #else
251 #define RegDeleteValue RegDeleteValueA
252 #endif
253 
254  WINPR_API LONG RegDisablePredefinedCacheEx(void);
255 
256  WINPR_API LONG RegEnumKeyExW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, LPDWORD lpcName,
257  LPDWORD lpReserved, LPWSTR lpClass, LPDWORD lpcClass,
258  PFILETIME lpftLastWriteTime);
259  WINPR_API LONG RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcName,
260  LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcClass,
261  PFILETIME lpftLastWriteTime);
262 
263 #ifdef UNICODE
264 #define RegEnumKeyEx RegEnumKeyExW
265 #else
266 #define RegEnumKeyEx RegEnumKeyExA
267 #endif
268 
269  WINPR_API LONG RegEnumValueW(HKEY hKey, DWORD dwIndex, LPWSTR lpValueName,
270  LPDWORD lpcchValueName, LPDWORD lpReserved, LPDWORD lpType,
271  LPBYTE lpData, LPDWORD lpcbData);
272  WINPR_API LONG RegEnumValueA(HKEY hKey, DWORD dwIndex, LPSTR lpValueName,
273  LPDWORD lpcchValueName, LPDWORD lpReserved, LPDWORD lpType,
274  LPBYTE lpData, LPDWORD lpcbData);
275 
276 #ifdef UNICODE
277 #define RegEnumValue RegEnumValueW
278 #else
279 #define RegEnumValue RegEnumValueA
280 #endif
281 
282  WINPR_API LONG RegFlushKey(HKEY hKey);
283 
284  WINPR_API LONG RegGetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation,
285  PSECURITY_DESCRIPTOR pSecurityDescriptor,
286  LPDWORD lpcbSecurityDescriptor);
287 
288  WINPR_API LONG RegGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue, DWORD dwFlags,
289  LPDWORD pdwType, PVOID pvData, LPDWORD pcbData);
290  WINPR_API LONG RegGetValueA(HKEY hkey, LPCSTR lpSubKey, LPCSTR lpValue, DWORD dwFlags,
291  LPDWORD pdwType, PVOID pvData, LPDWORD pcbData);
292 
293 #ifdef UNICODE
294 #define RegGetValue RegGetValueW
295 #else
296 #define RegGetValue RegGetValueA
297 #endif
298 
299  WINPR_API LONG RegLoadAppKeyW(LPCWSTR lpFile, PHKEY phkResult, REGSAM samDesired,
300  DWORD dwOptions, DWORD Reserved);
301  WINPR_API LONG RegLoadAppKeyA(LPCSTR lpFile, PHKEY phkResult, REGSAM samDesired,
302  DWORD dwOptions, DWORD Reserved);
303 
304 #ifdef UNICODE
305 #define RegLoadAppKey RegLoadAppKeyW
306 #else
307 #define RegLoadAppKey RegLoadAppKeyA
308 #endif
309 
310  WINPR_API LONG RegLoadKeyW(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile);
311  WINPR_API LONG RegLoadKeyA(HKEY hKey, LPCSTR lpSubKey, LPCSTR lpFile);
312 
313 #ifdef UNICODE
314 #define RegLoadKey RegLoadKeyW
315 #else
316 #define RegLoadKey RegLoadKeyA
317 #endif
318 
319  WINPR_API LONG RegLoadMUIStringW(HKEY hKey, LPCWSTR pszValue, LPWSTR pszOutBuf, DWORD cbOutBuf,
320  LPDWORD pcbData, DWORD Flags, LPCWSTR pszDirectory);
321  WINPR_API LONG RegLoadMUIStringA(HKEY hKey, LPCSTR pszValue, LPSTR pszOutBuf, DWORD cbOutBuf,
322  LPDWORD pcbData, DWORD Flags, LPCSTR pszDirectory);
323 
324 #ifdef UNICODE
325 #define RegLoadMUIString RegLoadMUIStringW
326 #else
327 #define RegLoadMUIString RegLoadMUIStringA
328 #endif
329 
330  WINPR_API LONG RegNotifyChangeKeyValue(HKEY hKey, BOOL bWatchSubtree, DWORD dwNotifyFilter,
331  HANDLE hEvent, BOOL fAsynchronous);
332 
333  WINPR_API LONG RegOpenCurrentUser(REGSAM samDesired, PHKEY phkResult);
334 
335  WINPR_API LONG RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired,
336  PHKEY phkResult);
337  WINPR_API LONG RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired,
338  PHKEY phkResult);
339 
340 #ifdef UNICODE
341 #define RegOpenKeyEx RegOpenKeyExW
342 #else
343 #define RegOpenKeyEx RegOpenKeyExA
344 #endif
345 
346  WINPR_API LONG RegOpenUserClassesRoot(HANDLE hToken, DWORD dwOptions, REGSAM samDesired,
347  PHKEY phkResult);
348 
349  WINPR_API LONG RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved,
350  LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen,
351  LPDWORD lpcMaxClassLen, LPDWORD lpcValues,
352  LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen,
353  LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime);
354  WINPR_API LONG RegQueryInfoKeyA(HKEY hKey, LPSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved,
355  LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen,
356  LPDWORD lpcMaxClassLen, LPDWORD lpcValues,
357  LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen,
358  LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime);
359 
360 #ifdef UNICODE
361 #define RegQueryInfoKey RegQueryInfoKeyW
362 #else
363 #define RegQueryInfoKey RegQueryInfoKeyA
364 #endif
365 
366  WINPR_API LONG RegQueryValueExW(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved,
367  LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
368  WINPR_API LONG RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved,
369  LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
370 
371 #ifdef UNICODE
372 #define RegQueryValueEx RegQueryValueExW
373 #else
374 #define RegQueryValueEx RegQueryValueExA
375 #endif
376 
377  WINPR_API LONG RegRestoreKeyW(HKEY hKey, LPCWSTR lpFile, DWORD dwFlags);
378  WINPR_API LONG RegRestoreKeyA(HKEY hKey, LPCSTR lpFile, DWORD dwFlags);
379 
380 #ifdef UNICODE
381 #define RegRestoreKey RegRestoreKeyW
382 #else
383 #define RegRestoreKey RegRestoreKeyA
384 #endif
385 
386  WINPR_API LONG RegSaveKeyExW(HKEY hKey, LPCWSTR lpFile,
387  LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD Flags);
388  WINPR_API LONG RegSaveKeyExA(HKEY hKey, LPCSTR lpFile,
389  LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD Flags);
390 
391 #ifdef UNICODE
392 #define RegSaveKeyEx RegSaveKeyExW
393 #else
394 #define RegSaveKeyEx RegSaveKeyExA
395 #endif
396 
397  WINPR_API LONG RegSetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation,
398  PSECURITY_DESCRIPTOR pSecurityDescriptor);
399 
400  WINPR_API LONG RegSetValueExW(HKEY hKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType,
401  const BYTE* lpData, DWORD cbData);
402  WINPR_API LONG RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType,
403  const BYTE* lpData, DWORD cbData);
404 
405 #ifdef UNICODE
406 #define RegSetValueEx RegSetValueExW
407 #else
408 #define RegSetValueEx RegSetValueExA
409 #endif
410 
411  WINPR_API LONG RegUnLoadKeyW(HKEY hKey, LPCWSTR lpSubKey);
412  WINPR_API LONG RegUnLoadKeyA(HKEY hKey, LPCSTR lpSubKey);
413 
414 #ifdef UNICODE
415 #define RegUnLoadKey RegUnLoadKeyW
416 #else
417 #define RegUnLoadKey RegUnLoadKeyA
418 #endif
419 
420 #ifdef __cplusplus
421 }
422 #endif
423 
424 #endif
425 
426 #endif /* WINPR_REGISTRY_H */