winprefs 0.4.1
Dump a registry path to a series of 'reg add' commands.
Loading...
Searching...
No Matches
wrappers.h
1#ifndef TESTS_WRAPPERS_H
2#define TESTS_WRAPPERS_H
3
4#ifndef check_expected_int
5#define check_expected_int(parameter) check_expected(parameter)
6#define check_expected_uint(parameter) check_expected(parameter)
7#define expect_int_value(function, parameter, value) expect_value(function, parameter, value)
8#define expect_uint_value(function, parameter, value) expect_value(function, parameter, value)
9#define expect_uint_value_count(function, parameter, value, count) \
10 expect_value_count(function, parameter, value, (int)(count))
11#define will_return_uint_always(function, value) will_return_always(function, value)
12#define will_return_ptr_always(function, value) will_return_always(function, value)
13#define will_return_uint_count(function, value, count) will_return_count(function, value, count)
14#endif
15
16#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
17
18#define UINT64 uint64_t
19typedef short WORD;
20typedef char CHAR;
21typedef CHAR *LPSTR, *LPCCH;
22typedef bool BOOL;
23typedef struct _SYSTEMTIME {
24 WORD wYear;
25 WORD wMonth;
26 WORD wDayOfWeek;
27 WORD wDay;
28 WORD wHour;
29 WORD wMinute;
30 WORD wSecond;
31 WORD wMilliseconds;
32} SYSTEMTIME;
33typedef char byte, BYTE, *PBYTE, *LPBYTE;
34typedef unsigned long DWORD, LCID, *LPDWORD, REGSAM;
35typedef unsigned long long QWORD;
36typedef long LONG;
37typedef LONG HRESULT, LSTATUS;
38typedef wchar_t WCHAR;
39typedef WCHAR *LPWSTR;
40typedef const WCHAR *LPCWSTR;
41typedef const WCHAR *LPCWCH, *PCWCH, *LMCSTR, *LPCWSTR, *PCWSTR;
42typedef unsigned int UINT;
43typedef void *HANDLE, *PHANDLE, *LPVOID, *LPOVERLAPPED, *HWND;
44typedef const void *LPCVOID;
45typedef struct _SECURITY_ATTRIBUTES {
46 DWORD nLength;
47 LPVOID lpSecurityDescriptor;
48 bool bInheritHandle;
49} SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
50typedef struct _STARTUPINFO {
51 DWORD cb;
52 LPWSTR lpReserved;
53 LPWSTR lpDesktop;
54 LPWSTR lpTitle;
55 DWORD dwX;
56 DWORD dwY;
57 DWORD dwXSize;
58 DWORD dwYSize;
59 DWORD dwXCountChars;
60 DWORD dwYCountChars;
61 DWORD dwFillAttribute;
62 DWORD dwFlags;
63 WORD wShowWindow;
64 WORD cbReserved2;
65 LPBYTE lpReserved2;
66 HANDLE hStdInput;
67 HANDLE hStdOutput;
68 HANDLE hStdError;
69} STARTUPINFO, *LPSTARTUPINFO;
70typedef struct _PROCESS_INFORMATION {
71 HANDLE hProcess;
72 HANDLE hThread;
73 DWORD dwProcessId;
74 DWORD dwThreadId;
75} PROCESS_INFORMATION, *PPROCESS_INFORMATION, *LPPROCESS_INFORMATION;
76typedef HANDLE HKEY, *PHKEY;
77typedef struct _FILETIME {
78 DWORD dwLowDateTime;
79 DWORD dwHighDateTime;
80} FILETIME;
81typedef struct _FILETIME *PFILETIME;
82typedef WCHAR *LPTSTR;
83const enum REG_TYPES {
84 REG_BINARY,
85 REG_DWORD,
86 REG_EXPAND_SZ,
87 REG_MULTI_SZ,
88 REG_NONE,
89 REG_QWORD,
90 REG_SZ,
91};
93 BYTE Value[6];
94} SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
95typedef void *PSID;
96
97#define CP_UTF8 0
98#define CREATE_ALWAYS 2
99#define CREATE_NO_WINDOW 0
100#define CSIDL_APPDATA 0
101#define ERROR_ACCESS_DENIED 802
102#define ERROR_ALREADY_EXISTS 803
103#define ERROR_MORE_DATA 800
104#define ERROR_NO_MORE_ITEMS 801
105#define ERROR_SUCCESS 0
106
107#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
108#define FILE_ATTRIBUTE_NORMAL 0x00000080
109#define FORMAT_MESSAGE_FROM_SYSTEM 2
110#define FORMAT_MESSAGE_IGNORE_INSERTS 1
111#define GENERIC_READ 0
112#define GENERIC_WRITE 1
113#define HKEY_CLASSES_ROOT (HKEY)2
114#define HKEY_CURRENT_CONFIG (HKEY)4
115#define HKEY_CURRENT_USER (HKEY)1
116#define HKEY_DYN_DATA (HKEY)6
117#define HKEY_LOCAL_MACHINE (HKEY)3
118#define HKEY_USERS (HKEY)5
119#define INFINITE 0xFFFFFFFF
120#define INVALID_FILE_ATTRIBUTES ((DWORD) - 1)
121#define INVALID_HANDLE_VALUE (void *)3
122#define IsWindowsVistaOrGreater() 0
123#define KEY_READ 0
124#define KEY_WRITE 1
125#define LOCALE_USER_DEFAULT 0
126#define MAKELANGID(x, y) 0
127#define MAX_PATH 260
128#define P_WAIT 0
129#define STARTF_USESHOWWINDOW 1
130#define STARTF_USESTDHANDLES 2
131#define STD_OUTPUT_HANDLE 0
132#define SUCCEEDED(x) x == 0
133#define SW_HIDE 0
134#define WAIT_OBJECT_0 0
135// clang-format 18.1.3 (the CI runner) and newer releases format this braced list differently.
136// clang-format off
137#define SECURITY_NT_AUTHORITY {0, 0, 0, 0, 0, 5}
138// clang-format on
139#define SECURITY_BUILTIN_DOMAIN_RID 0x00000020
140#define DOMAIN_ALIAS_RID_ADMINS 0x00000220
141
142#ifndef min
143#define min(a, b) (((a) < (b)) ? (a) : (b))
144#endif
145#ifndef TEXT
146#define TEXT(quote) L##quote
147#endif
148
149DWORD GetFileAttributes(wchar_t *path);
150int GetTimeFormat(LCID Locale,
151 DWORD dwFlags,
152 const SYSTEMTIME *lpTime,
153 LPCWSTR lpFormat,
154 LPWSTR lpTimeStr,
155 int cchTime);
156int GetDateFormat(LCID Locale,
157 DWORD dwFlags,
158 const SYSTEMTIME *lpDate,
159 LPCWSTR lpFormat,
160 LPWSTR lpDateStr,
161 int cchDate);
162bool CreatePipe(PHANDLE hReadPipe,
163 PHANDLE hWritePipe,
164 LPSECURITY_ATTRIBUTES lpPipeAttributes,
165 DWORD nSize);
166bool CloseHandle(HANDLE hObject);
167DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
168bool PeekNamedPipe(HANDLE hNamedPipe,
169 LPVOID lpBuffer,
170 DWORD nBufferSize,
171 LPDWORD lpBytesRead,
172 LPDWORD lpTotalBytesAvail,
173 LPDWORD lpBytesLeftThisMessage);
174bool ReadFile(HANDLE hFile,
175 LPVOID lpBuffer,
176 DWORD nNumberOfBytesToRead,
177 LPDWORD lpNumberOfBytesRead,
178 LPOVERLAPPED lpOverlapped);
179int MultiByteToWideChar(UINT CodePage,
180 DWORD dwFlags,
181 LPCCH lpMultiByteStr,
182 int cbMultiByte,
183 LPWSTR lpWideCharStr,
184 int cchWideChar);
185int WideCharToMultiByte(UINT CodePage,
186 DWORD dwFlags,
187 LPCWCH lpWideCharStr,
188 int cchWideChar,
189 LPSTR lpMultiByteStr,
190 int cbMultiByte,
191 LPCCH lpDefaultChar,
192 bool *lpUsedDefaultChar);
193void PathStripPath(LPWSTR pszPath);
194bool CreateProcess(LPCWSTR lpApplicationName,
195 LPWSTR lpCommandLine,
196 SECURITY_ATTRIBUTES *lpProcessAttributes,
197 SECURITY_ATTRIBUTES *lpThreadAttributes,
198 bool bInheritHandles,
199 DWORD dwCreationFlags,
200 void *lpEnvironment,
201 LPCWSTR lpCurrentDirectory,
202 LPSTARTUPINFO lpStartupInfo,
203 LPPROCESS_INFORMATION lpProcessInformation);
204bool WriteFile(HANDLE hFile,
205 LPCVOID lpBuffer,
206 DWORD nNumberOfBytesToWrite,
207 LPDWORD lpNumberOfBytesWritten,
208 LPOVERLAPPED lpOverlapped);
209LSTATUS RegEnumValue(HKEY hKey,
210 DWORD dwIndex,
211 LPWSTR lpValueName,
212 LPDWORD lpcchValueName,
213 LPDWORD lpReserved,
214 LPDWORD lpType,
215 LPBYTE lpData,
216 LPDWORD lpcbData);
217DWORD GetLastError();
218bool CreateDirectory(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
219bool PathAppend(LPWSTR pszPath, LPCWSTR pszMore);
220HANDLE GetStdHandle(DWORD nStdHandle);
221LSTATUS
222RegOpenKeyEx(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
223LSTATUS RegEnumKeyEx(HKEY hKey,
224 DWORD dwIndex,
225 LPWSTR lpName,
226 LPDWORD lpcchName,
227 LPDWORD lpReserved,
228 LPWSTR lpClass,
229 LPDWORD lpcchClass,
230 PFILETIME lpftLastWriteTime);
231LSTATUS RegCloseKey(HKEY hKey);
232HANDLE CreateFile(LPCWSTR lpFileName,
233 DWORD dwDesiredAccess,
234 DWORD dwShareMode,
235 LPSECURITY_ATTRIBUTES lpSecurityAttributes,
236 DWORD dwCreationDisposition,
237 DWORD dwFlagsAndAttributes,
238 HANDLE hTemplateFile);
239LSTATUS RegQueryInfoKey(HKEY hKey,
240 LPWSTR lpClass,
241 LPDWORD lpcchClass,
242 LPDWORD lpReserved,
243 LPDWORD lpcSubKeys,
244 LPDWORD lpcbMaxSubKeyLen,
245 LPDWORD lpcbMaxClassLen,
246 LPDWORD lpcValues,
247 LPDWORD lpcbMaxValueNameLen,
248 LPDWORD lpcbMaxValueLen,
249 LPDWORD lpcbSecurityDescriptor,
250 PFILETIME lpftLastWriteTime);
251LSTATUS RegQueryValueEx(HKEY hKey,
252 LPCWSTR lpValueName,
253 LPDWORD lpReserved,
254 LPDWORD lpType,
255 LPBYTE lpData,
256 LPDWORD lpcbData);
257HRESULT SHGetFolderPath(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
258wchar_t *_wfullpath(wchar_t *absPath, const wchar_t *relPath, size_t maxLength);
259wchar_t *_wgetcwd(wchar_t *buffer, int maxlen);
260int _wchdir(const wchar_t *dirname);
261int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format, ...);
262int _wcsicmp(const wchar_t *a, const wchar_t *b);
263bool _CrtDumpMemoryLeaks();
264DWORD FormatMessage(DWORD dwFlags,
265 LPCVOID lpSource,
266 DWORD dwMessageId,
267 DWORD dwLanguageId,
268 LPWSTR lpBuffer,
269 DWORD nSize,
270 va_list *Arguments);
271bool GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode);
272bool StrTrim(wchar_t *str, const wchar_t *trimChars);
273bool PathMatchSpec(const wchar_t *pszFile, const wchar_t *pszSpec);
274LSTATUS RegSetValueEx(
275 HKEY hKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType, const BYTE *lpData, DWORD cbData);
276LSTATUS RegCreateKeyEx(HKEY hKey,
277 LPCWSTR lpSubKey,
278 DWORD Reserved,
279 LPWSTR lpClass,
280 DWORD dwOptions,
281 REGSAM samDesired,
282 LPSECURITY_ATTRIBUTES lpSecurityAttributes,
283 PHKEY phkResult,
284 LPDWORD disposition);
285bool AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
286 BYTE nSubAuthorityCount,
287 DWORD nSubAuthority0,
288 DWORD nSubAuthority1,
289 DWORD nSubAuthority2,
290 DWORD nSubAuthority3,
291 DWORD nSubAuthority4,
292 DWORD nSubAuthority5,
293 DWORD nSubAuthority6,
294 DWORD nSubAuthority7,
295 PSID *pSid);
296bool CheckTokenMembership(HANDLE TokenHandle, PSID SidToCheck, bool *IsMember);
297void FreeSid(PSID pSid);
298
299#endif // TESTS_WRAPPERS_H
Definition wrappers.h:77
Definition wrappers.h:70
Definition wrappers.h:45
Definition wrappers.h:92
Definition wrappers.h:50
Definition wrappers.h:23