20#ifndef WINPR_REGISTRY_H
21#define WINPR_REGISTRY_H
23#include <winpr/windows.h>
25#if defined(_WIN32) && !defined(_UWP)
36#include <winpr/winpr.h>
37#include <winpr/wtypes.h>
41#include <winpr/error.h>
45#define OWNER_SECURITY_INFORMATION 0x00000001
46#define GROUP_SECURITY_INFORMATION 0x00000002
47#define DACL_SECURITY_INFORMATION 0x00000004
48#define SACL_SECURITY_INFORMATION 0x00000008
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
57#define REG_CREATED_NEW_KEY 0x00000001
58#define REG_OPENED_EXISTING_KEY 0x00000002
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
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
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
81 ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & \
84#define KEY_WRITE ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE))
86#define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
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) & \
100 REG_DWORD_LITTLE_ENDIAN = REG_DWORD,
101 REG_DWORD_BIG_ENDIAN = 5,
104 REG_RESOURCE_LIST = 8,
105 REG_FULL_RESOURCE_DESCRIPTOR = 9,
106 REG_RESOURCE_REQUIREMENTS_LIST = 10,
108 REG_QWORD_LITTLE_ENDIAN = REG_QWORD
112 typedef HANDLE* PHKEY;
116 typedef ACCESS_MASK REGSAM;
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)
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
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
141#define RRF_NOEXPAND 0x10000000
142#define RRF_ZEROONFAILURE 0x20000000
147 LPVOID value_context;
153 typedef struct pvalueA
157 LPVOID pv_value_context;
153 typedef struct pvalueA {
…};
161 typedef struct pvalueW
165 LPVOID pv_value_context;
161 typedef struct pvalueW {
…};
171 typedef PPVALUEW PPVALUE;
174typedef PPVALUEA PPVALUE;
177 typedef struct value_entA
181 DWORD_PTR ve_valueptr;
177 typedef struct value_entA {
…};
185 typedef struct value_entW
189 DWORD_PTR ve_valueptr;
185 typedef struct value_entW {
…};
195 typedef PVALENTW PVALENT;
198typedef PVALENTA PVALENT;
201 WINPR_API LONG RegCloseKey(HKEY hKey);
203 WINPR_API LONG RegCopyTreeW(HKEY hKeySrc, LPCWSTR lpSubKey, HKEY hKeyDest);
204 WINPR_API LONG RegCopyTreeA(HKEY hKeySrc, LPCSTR lpSubKey, HKEY hKeyDest);
207#define RegCopyTree RegCopyTreeW
209#define RegCopyTree RegCopyTreeA
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);
222#define RegCreateKeyEx RegCreateKeyExW
224#define RegCreateKeyEx RegCreateKeyExA
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);
231#define RegDeleteKeyEx RegDeleteKeyExW
233#define RegDeleteKeyEx RegDeleteKeyExA
236 WINPR_API LONG RegDeleteTreeW(HKEY hKey, LPCWSTR lpSubKey);
237 WINPR_API LONG RegDeleteTreeA(HKEY hKey, LPCSTR lpSubKey);
240#define RegDeleteTree RegDeleteTreeW
242#define RegDeleteTree RegDeleteTreeA
245 WINPR_API LONG RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName);
246 WINPR_API LONG RegDeleteValueA(HKEY hKey, LPCSTR lpValueName);
249#define RegDeleteValue RegDeleteValueW
251#define RegDeleteValue RegDeleteValueA
254 WINPR_API LONG RegDisablePredefinedCacheEx(
void);
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);
264#define RegEnumKeyEx RegEnumKeyExW
266#define RegEnumKeyEx RegEnumKeyExA
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);
277#define RegEnumValue RegEnumValueW
279#define RegEnumValue RegEnumValueA
282 WINPR_API LONG RegFlushKey(HKEY hKey);
284 WINPR_API LONG RegGetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation,
285 PSECURITY_DESCRIPTOR pSecurityDescriptor,
286 LPDWORD lpcbSecurityDescriptor);
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);
294#define RegGetValue RegGetValueW
296#define RegGetValue RegGetValueA
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);
305#define RegLoadAppKey RegLoadAppKeyW
307#define RegLoadAppKey RegLoadAppKeyA
310 WINPR_API LONG RegLoadKeyW(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile);
311 WINPR_API LONG RegLoadKeyA(HKEY hKey, LPCSTR lpSubKey, LPCSTR lpFile);
314#define RegLoadKey RegLoadKeyW
316#define RegLoadKey RegLoadKeyA
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);
325#define RegLoadMUIString RegLoadMUIStringW
327#define RegLoadMUIString RegLoadMUIStringA
330 WINPR_API LONG RegNotifyChangeKeyValue(HKEY hKey, BOOL bWatchSubtree, DWORD dwNotifyFilter,
331 HANDLE hEvent, BOOL fAsynchronous);
333 WINPR_API LONG RegOpenCurrentUser(REGSAM samDesired, PHKEY phkResult);
335 WINPR_API LONG RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired,
337 WINPR_API LONG RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired,
341#define RegOpenKeyEx RegOpenKeyExW
343#define RegOpenKeyEx RegOpenKeyExA
346 WINPR_API LONG RegOpenUserClassesRoot(HANDLE hToken, DWORD dwOptions, REGSAM samDesired,
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);
361#define RegQueryInfoKey RegQueryInfoKeyW
363#define RegQueryInfoKey RegQueryInfoKeyA
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);
372#define RegQueryValueEx RegQueryValueExW
374#define RegQueryValueEx RegQueryValueExA
377 WINPR_API LONG RegRestoreKeyW(HKEY hKey, LPCWSTR lpFile, DWORD dwFlags);
378 WINPR_API LONG RegRestoreKeyA(HKEY hKey, LPCSTR lpFile, DWORD dwFlags);
381#define RegRestoreKey RegRestoreKeyW
383#define RegRestoreKey RegRestoreKeyA
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);
392#define RegSaveKeyEx RegSaveKeyExW
394#define RegSaveKeyEx RegSaveKeyExA
397 WINPR_API LONG RegSetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation,
398 PSECURITY_DESCRIPTOR pSecurityDescriptor);
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);
406#define RegSetValueEx RegSetValueExW
408#define RegSetValueEx RegSetValueExA
411 WINPR_API LONG RegUnLoadKeyW(HKEY hKey, LPCWSTR lpSubKey);
412 WINPR_API LONG RegUnLoadKeyA(HKEY hKey, LPCSTR lpSubKey);
415#define RegUnLoadKey RegUnLoadKeyW
417#define RegUnLoadKey RegUnLoadKeyA