ReactOS 0.4.16-dev-2491-g3dc6630
misc.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Applications Manager
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Misc functions
5 * COPYRIGHT: Copyright 2009 Dmitry Chapyshev (dmitry@reactos.org)
6 * Copyright 2015 Ismael Ferreras Morezuelas (swyterzone+ros@gmail.com)
7 * Copyright 2017 Alexander Shaposhnikov (sanchaez@reactos.org)
8 */
9
10#include "rapps.h"
11#include "misc.h"
12
14
15static HANDLE hLog = NULL;
16
17UINT
19{
20 if (!Error)
21 Error = ERROR_INTERNAL_ERROR; // Note: geninst.cpp depends on this
22 WCHAR buf[400];
25 MessageBoxW(hOwner, buf, 0, MB_OK | MB_ICONSTOP);
26 return Error;
27}
28
29VOID
31{
32 if (!OpenClipboard(NULL))
33 {
34 return;
35 }
36
37 HRESULT hr;
38 HGLOBAL ClipBuffer;
41
43 cchBuffer = wcslen(lpszText) + 1;
44 ClipBuffer = GlobalAlloc(GMEM_DDESHARE, cchBuffer * sizeof(WCHAR));
45
46 Buffer = (PWCHAR)GlobalLock(ClipBuffer);
47 hr = StringCchCopyW(Buffer, cchBuffer, lpszText);
48 GlobalUnlock(ClipBuffer);
49
50 if (SUCCEEDED(hr))
52
54}
55
56static INT_PTR CALLBACK
58{
59 return uMsg == WM_CLOSE ? DestroyWindow(hDlg) : FALSE;
60}
61
62VOID
64{
65 static const DWORD DlgTmpl[] = { WS_POPUP | WS_CAPTION | WS_SYSMENU, 0, 0, 0, 0, 0 };
67 if (hDlg)
68 {
69 RECT r;
71 if (SetWindowPos(hDlg, hDlg, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE))
72 {
73 SendMessage(hDlg, DM_REPOSITION, 0, 0);
74 if (GetWindowRect(hDlg, &r))
75 SetWindowPos(hwnd, hwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE);
76 }
77 SendMessage(hDlg, WM_CLOSE, 0, 0);
78 }
79}
80
81VOID
82ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem, POINT *Point)
83{
84 HMENU hMenu = NULL;
85 HMENU hPopupMenu;
86 MENUITEMINFO ItemInfo;
87 POINT pt;
88
89 if (MenuID)
90 {
91 hMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(MenuID));
92 hPopupMenu = GetSubMenu(hMenu, 0);
93 }
94 else
95 {
96 hPopupMenu = GetMenu(hwnd);
97 }
98
99 ZeroMemory(&ItemInfo, sizeof(ItemInfo));
100 ItemInfo.cbSize = sizeof(ItemInfo);
101 ItemInfo.fMask = MIIM_STATE;
102
103 GetMenuItemInfoW(hPopupMenu, DefaultItem, FALSE, &ItemInfo);
104
105 if (!(ItemInfo.fState & MFS_GRAYED))
106 {
107 SetMenuDefaultItem(hPopupMenu, DefaultItem, FALSE);
108 }
109
110 if (!Point)
111 {
113 }
114
116 TrackPopupMenu(hPopupMenu, 0, Point->x, Point->y, 0, hwndOwner, NULL);
117
118 if (hMenu)
119 {
120 DestroyMenu(hMenu);
121 }
122}
123
124extern BOOL IsZipFile(PCWSTR Path);
125
126UINT
128{
132 {
133 BYTE buf[8];
134 DWORD io;
135 if (!ReadFile(hFile, buf, sizeof(buf), &io, NULL) || io != sizeof(buf))
136 buf[0] = 0;
138
139 if (buf[0] == 0xD0 && buf[1] == 0xCF && buf[2] == 0x11 && buf[3] == 0xE0 &&
140 buf[4] == 0xA1 && buf[5] == 0xB1 && buf[6] == 0x1A && buf[7] == 0xE1)
141 {
142 return MAKEWORD('M', PERCEIVED_TYPE_APPLICATION); // MSI
143 }
144 if (buf[0] == 'M' || buf[0] == 'Z')
145 {
146 SHFILEINFO shfi;
147 if (SHGetFileInfoW(Path, 0, &shfi, sizeof(shfi), SHGFI_EXETYPE))
149 }
150 if (buf[0] == 'M' && buf[1] == 'S' && buf[2] == 'C' && buf[3] == 'F')
151 {
152 return MAKEWORD('C', PERCEIVED_TYPE_COMPRESSED); // CAB
153 }
154 }
155
156 if (IsZipFile(Path)) // .zip last because we want to return SFX.exe with higher priority
157 {
159 }
161}
162
163BOOL
165{
166 WCHAR szCmd[MAX_PATH * 2];
167 DWORD cch = _countof(szCmd);
170 ASSOCSTR_COMMAND, pszExt, NULL, szCmd, &cch);
171 if (SUCCEEDED(hr) && StrStrIW(szCmd, L" zipfldr.dll,")) // .zip
172 return TRUE;
173 PathRemoveArgsW(szCmd);
174 return SUCCEEDED(hr) && !StrCmpIW(PathFindFileNameW(szCmd), L"explorer.exe"); // .cab
175}
176
177BOOL
179{
182 DWORD dwRet;
183 MSG msg;
184
185 ZeroMemory(&si, sizeof(si));
186 si.cb = sizeof(si);
187 si.dwFlags = STARTF_USESHOWWINDOW;
188 si.wShowWindow = SW_SHOW;
189
190 // The Unicode version of CreateProcess can modify the contents of this string.
191 CStringW Tmp = Path;
192 BOOL fSuccess = CreateProcessW(NULL, Tmp.GetBuffer(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
193 Tmp.ReleaseBuffer();
194 if (!fSuccess)
195 {
196 return FALSE;
197 }
198
200
201 if (Wait)
202 {
204 }
205
206 while (Wait)
207 {
209 if (dwRet == WAIT_OBJECT_0 + 1)
210 {
211 while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
212 {
215 }
216 }
217 else
218 {
219 if (dwRet == WAIT_OBJECT_0 || dwRet == WAIT_FAILED)
220 break;
221 }
222 }
223
225
226 if (Wait)
227 {
230 // We got the real activation message during MsgWaitForMultipleObjects while
231 // we were disabled, we need to set the focus again now.
233 }
234
235 return TRUE;
236}
237
238BOOL
240{
241 static CStringW CachedDirectory;
242 static BOOL CachedDirectoryInitialized = FALSE;
243
244 if (!CachedDirectoryInitialized)
245 {
246 LPWSTR DirectoryStr = CachedDirectory.GetBuffer(MAX_PATH);
247 BOOL bHasPath = SHGetSpecialFolderPathW(NULL, DirectoryStr, CSIDL_LOCAL_APPDATA, TRUE);
248 if (bHasPath)
249 {
250 PathAppendW(DirectoryStr, RAPPS_NAME);
251 }
252 CachedDirectory.ReleaseBuffer();
253
254 if (bHasPath)
255 {
256 if (!CreateDirectoryW(CachedDirectory, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
257 {
258 CachedDirectory.Empty();
259 }
260 }
261 else
262 {
263 CachedDirectory.Empty();
264 }
265
266 CachedDirectoryInitialized = TRUE;
267 }
268
269 Directory = CachedDirectory;
270 return !Directory.IsEmpty();
271}
272
273VOID
275{
277 {
278 return;
279 }
280
282 DWORD dwCategoryNum = 1;
283 DWORD dwDisp, dwData;
285
286 if (key.Create(
288 L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\ReactOS Application Manager", REG_NONE,
290 {
291 return;
292 }
293
295 {
296 return;
297 }
298
300
301 if ((key.SetStringValue(L"EventMessageFile", szPath, REG_EXPAND_SZ) == ERROR_SUCCESS) &&
302 (key.SetStringValue(L"CategoryMessageFile", szPath, REG_EXPAND_SZ) == ERROR_SUCCESS) &&
303 (key.SetDWORDValue(L"TypesSupported", dwData) == ERROR_SUCCESS) &&
304 (key.SetDWORDValue(L"CategoryCount", dwCategoryNum) == ERROR_SUCCESS))
305
306 {
307 hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager");
308 }
309}
310
311VOID
313{
314 if (hLog)
315 {
317 }
318}
319
320BOOL
321WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
322{
324 {
325 return TRUE;
326 }
327
328 if (!ReportEventW(hLog, wType, 0, dwEventID, NULL, 1, 0, &lpMsg, NULL))
329 {
330 return FALSE;
331 }
332
333 return TRUE;
334}
335
336BOOL
337GetInstalledVersion_WowUser(CStringW *szVersionResult, const CStringW &szRegName, BOOL IsUserKey, REGSAM keyWow)
338{
339 BOOL bHasSucceded = FALSE;
342 CStringW szPath = CStringW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\") + szRegName;
343
344 if (key.Open(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, szPath.GetString(), keyWow | KEY_READ) !=
346 {
347 return FALSE;
348 }
349
350 if (szVersionResult != NULL)
351 {
352 ULONG dwSize = MAX_PATH * sizeof(WCHAR);
353
354 if (key.QueryStringValue(L"DisplayVersion", szVersion.GetBuffer(MAX_PATH), &dwSize) == ERROR_SUCCESS)
355 {
356 szVersion.ReleaseBuffer();
357 *szVersionResult = szVersion;
358 bHasSucceded = TRUE;
359 }
360 else
361 {
362 szVersion.ReleaseBuffer();
363 }
364 }
365 else
366 {
367 bHasSucceded = TRUE;
368 }
369
370 return bHasSucceded;
371}
372
373BOOL
374GetInstalledVersion(CStringW *pszVersion, const CStringW &szRegName)
375{
376 return (
377 !szRegName.IsEmpty() && (GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY) ||
378 GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_32KEY) ||
379 GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_64KEY) ||
380 GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_64KEY)));
381}
382
383BOOL
385{
386#ifdef _WIN64
387 return TRUE;
388#else
389 static UINT cache = 0;
390 if (!cache)
391 cache = 1 + (IsOS(OS_WOW6432) != FALSE);
392 return cache - 1;
393#endif
394}
395
396ULONG
398{
400 osvi.dwOSVersionInfoSize = sizeof(osvi);
402
403 return (osvi.dwMajorVersion << 8) | (osvi.dwMinorVersion);
404}
405
406INT
408{
409 DEVMODEW pDevMode;
410 INT ColorDepth;
411
412 pDevMode.dmSize = sizeof(pDevMode);
413 pDevMode.dmDriverExtra = 0;
414
416 {
417 /* TODO: Error message */
418 return ILC_COLOR;
419 }
420
421 switch (pDevMode.dmBitsPerPel)
422 {
423 case 32:
424 ColorDepth = ILC_COLOR32;
425 break;
426 case 24:
427 ColorDepth = ILC_COLOR24;
428 break;
429 case 16:
430 ColorDepth = ILC_COLOR16;
431 break;
432 case 8:
433 ColorDepth = ILC_COLOR8;
434 break;
435 case 4:
436 ColorDepth = ILC_COLOR4;
437 break;
438 default:
439 ColorDepth = ILC_COLOR;
440 break;
441 }
442
443 return ColorDepth;
444}
445
446void
447UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
448{
449 // Note that LONGLONG is a 64-bit value
450 LONGLONG ll;
451
452 ll = Int32x32To64(dwUnixTime, 10000000) + 116444736000000000;
453 pFileTime->dwLowDateTime = (DWORD)ll;
454 pFileTime->dwHighDateTime = ll >> 32;
455}
456
457static BOOL
458IsSameRegKey(HKEY hKey1, HKEY hKey2)
459{
460 // CompareObjectHandles is Win10+ so we check the path instead.
461 struct NameInfo : UNICODE_STRING
462 {
464 NameInfo() { MaximumLength = sizeof(Allocation); Buffer = Allocation; }
465 };
466 NameInfo Name1, Name2;
468 return NT_SUCCESS(NtQueryObject(hKey1, ObjectNameInformation, &Name1, sizeof(Name1), &Length)) &&
470 RtlCompareUnicodeString(&Name1, &Name2, TRUE) == 0;
471}
472
473BOOL
475{
477 CRegKey key1, key2;
478 return key1.Open(hRoot, Path1, MAXIMUM_ALLOWED | (Sam1 & WowMask)) == ERROR_SUCCESS &&
479 key2.Open(hRoot, Path2, MAXIMUM_ALLOWED | (Sam2 & WowMask)) == ERROR_SUCCESS &&
480 IsSameRegKey(key1, key2);
481}
482
485{
486 CRegKey key;
487 LONG err = key.Open(hKey, Path, KEY_QUERY_VALUE | wowsam);
488 if (err == ERROR_SUCCESS)
489 {
490 WCHAR name[1];
491 DWORD cchname = _countof(name), cbsize = 0;
492 err = RegEnumValueW(key, 0, name, &cchname, NULL, NULL, NULL, &cbsize);
494 return S_FALSE;
495 if (err == ERROR_MORE_DATA)
497 }
498 return HRESULT_FROM_WIN32(err);
499}
500
503{
504 for (;;)
505 {
506 ULONG cb = 0, cch;
507 ULONG err = Key.QueryValue(Name, NULL, NULL, &cb);
508 if (err)
509 break;
510 cch = cb / sizeof(WCHAR);
511 LPWSTR p = Value.GetBuffer(cch + 1);
512 p[cch] = UNICODE_NULL;
513 err = Key.QueryValue(Name, NULL, (BYTE*)p, &cb);
514 if (err == ERROR_MORE_DATA)
515 continue;
516 if (err)
517 break;
518 Value.ReleaseBuffer();
519 return Value.GetString();
520 }
521 return NULL;
522}
523
524bool
526{
529 if (cch)
530 {
531 if (ExpandEnvironmentStringsW(Str, buf.GetBuffer(cch), cch) == cch)
532 {
533 buf.ReleaseBuffer(cch - 1);
534 Str = buf;
535 return true;
536 }
537 }
538 return false;
539}
540
541BOOL
542SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle)
543{
544 if (!*szNeedle)
545 return TRUE;
546 /* TODO: Improve pattern search beyond a simple case-insensitive substring search. */
547 return StrStrIW(szHaystack, szNeedle) != NULL;
548}
549
550BOOL
552{
553 CStringW from(Dir);
554 UINT cch = from.GetLength();
555 from.Append(L"00");
556 LPWSTR p = from.GetBuffer();
557 p[cch] = p[cch + 1] = L'\0'; // Double null-terminate
559 SHFILEOPSTRUCT shfos = { hwnd, FO_DELETE, p, NULL, (FILEOP_FLAGS)fof };
560 return SHFileOperationW(&shfos);
561}
562
563UINT
565{
567 return err == ERROR_ALREADY_EXISTS ? 0 : err;
568}
569
572{
573 CPathW dir = FullPath;
574 //int win = dir.ReverseFind(L'\\'), nix = dir.ReverseFind(L'/'), sep = max(win, nix);
575 int sep = dir.FindFileName();
576 CStringW file = dir.m_strPath.Mid(sep);
577 if (pDir)
578 *pDir = sep == -1 ? L"" : dir.m_strPath.Left(sep - 1);
579 return file;
580}
581
584{
585 if (!SHGetSpecialFolderPathW(hwnd, Path.GetBuffer(MAX_PATH), csidl, TRUE))
586 return E_FAIL;
587 Path.ReleaseBuffer();
588 return S_OK;
589}
590
593{
594 PWSTR p;
595 FARPROC f = GetProcAddress(LoadLibraryW(L"SHELL32"), "SHGetKnownFolderPath");
596 if (!f)
599 if (FAILED(hr))
600 return hr;
601 Path = p;
603 return hr;
604}
605
608{
609 if (!PerUser)
611
612 HRESULT hr = GetKnownPath(FOLDERID_UserProgramFiles, Path);
613 if (FAILED(hr))
614 {
616 // Use the correct path on NT6 (on NT5 the path becomes a bit long)
617 if (SUCCEEDED(hr) && LOBYTE(GetVersion()) >= 6)
618 {
619 Path = BuildPath(Path, L"Programs"); // Should not be localized
620 }
621 }
622 return hr;
623}
624
625static BOOL
627{
628 OVERLAPPED ol = {};
629 ol.Offset = Offset;
630 DWORD cb;
631 return ReadFile(Handle, Buffer, Size, &cb, &ol) && cb == Size;
632}
633
635GuessInstallerType(LPCWSTR Installer, UINT &ExtraInfo)
636{
637 ExtraInfo = 0;
639
642 return it;
643
644 BYTE buf[0x30 + 12];
645 if (!ReadAt(hFile, 0, buf, sizeof(buf)))
646 goto done;
647
648 if (buf[0] == 0xD0 && buf[1] == 0xCF && buf[2] == 0x11 && buf[3] == 0xE0)
649 {
650 if (!StrCmpIW(L".msi", PathFindExtensionW(Installer)))
651 {
652 it = INSTALLER_MSI;
653 goto done;
654 }
655 }
656
657 if (buf[0] != 'M' || buf[1] != 'Z')
658 goto done;
659
660 // <= Inno 5.1.4
661 {
662 UINT sig[3];
663 C_ASSERT(sizeof(buf) >= 0x30 + sizeof(sig));
664 CopyMemory(sig, buf + 0x30, sizeof(sig));
665 if (sig[0] == 0x6F6E6E49 && sig[1] == ~sig[2])
666 {
667 it = INSTALLER_INNO;
668 ExtraInfo = 1;
669 goto done;
670 }
671 }
672
673 // NSIS 1.6+
674 {
675 UINT nsis[1+1+3+1+1], nsisskip = 512;
676 for (UINT nsisoffset = nsisskip * 20; nsisoffset < 1024 * 1024 * 50; nsisoffset += nsisskip)
677 {
678 if (ReadAt(hFile, nsisoffset, nsis, sizeof(nsis)) && nsis[1] == 0xDEADBEEF)
679 {
680 if (nsis[2] == 0x6C6C754E && nsis[3] == 0x74666F73 && nsis[4] == 0x74736E49)
681 {
682 it = INSTALLER_NSIS;
683 goto done;
684 }
685 }
686 }
687 }
688
689 if (HMODULE hMod = LoadLibraryEx(Installer, NULL, LOAD_LIBRARY_AS_DATAFILE))
690 {
691 // Inno
692 enum { INNORCSETUPLDR = 11111 };
693 HGLOBAL hGlob;
694 HRSRC hRsrc = FindResourceW(hMod, MAKEINTRESOURCE(INNORCSETUPLDR), RT_RCDATA);
695 if (hRsrc && (hGlob = LoadResource(hMod, hRsrc)) != NULL)
696 {
697 if (BYTE *p = (BYTE*)LockResource(hGlob))
698 {
699 if (p[0] == 'r' && p[1] == 'D' && p[2] == 'l' && p[3] == 'P' && p[4] == 't' && p[5] == 'S')
700 it = INSTALLER_INNO;
701 UnlockResource((void*)p);
702 }
703 }
704 FreeLibrary(hMod);
705 }
706done:
708 return it;
709}
710
711BOOL
713{
714 switch (InstallerType)
715 {
716 case INSTALLER_MSI:
717 {
718 Parameters.Format(L"/i \"%s\" /qn", Installer);
719 return TRUE;
720 }
721
722 case INSTALLER_INNO:
723 {
724 LPCWSTR pszInnoParams = L"/SILENT /VERYSILENT /SP-";
725 if (ExtraInfo)
726 Parameters.Format(L"%s", pszInnoParams);
727 else
728 Parameters.Format(L"%s /SUPPRESSMSGBOXES", pszInnoParams); // https://jrsoftware.org/files/is5.5-whatsnew.htm
729 return TRUE;
730 }
731
732 case INSTALLER_NSIS:
733 {
734 Parameters = L"/S";
735 return TRUE;
736 }
737
738 default:
739 {
740 return FALSE;
741 }
742 }
743}
@ ObjectNameInformation
Definition: DriverTester.h:55
PRTL_UNICODE_STRING_BUFFER Path
InstallerType
Definition: appinfo.h:82
@ INSTALLER_NSIS
Definition: appinfo.h:88
@ INSTALLER_UNKNOWN
Definition: appinfo.h:83
@ INSTALLER_INNO
Definition: appinfo.h:87
@ INSTALLER_MSI
Definition: appinfo.h:86
unsigned int dir
Definition: maze.c:112
#define msg(x)
Definition: auth_time.c:54
LONG NTSTATUS
Definition: precomp.h:26
#define CF_UNICODETEXT
Definition: constants.h:408
#define RAPPS_NAME
Definition: defines.h:34
static CStringW BuildPath(const T &Base, LPCWSTR Append)
Definition: misc.h:111
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:21
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:321
bool ExpandEnvStrings(CStringW &Str)
Definition: misc.cpp:525
BOOL StartProcess(const CStringW &Path, BOOL Wait)
Definition: misc.cpp:178
static BOOL IsSameRegKey(HKEY hKey1, HKEY hKey2)
Definition: misc.cpp:458
BOOL GetInstalledVersion(CStringW *pszVersion, const CStringW &szRegName)
Definition: misc.cpp:374
BOOL OpensWithExplorer(PCWSTR Path)
Definition: misc.cpp:164
VOID EmulateDialogReposition(HWND hwnd)
Definition: misc.cpp:63
HRESULT GetProgramFilesPath(CStringW &Path, BOOL PerUser, HWND hwnd)
Definition: misc.cpp:607
BOOL GetSilentInstallParameters(InstallerType InstallerType, UINT ExtraInfo, LPCWSTR Installer, CStringW &Parameters)
Definition: misc.cpp:712
VOID ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem, POINT *Point)
Definition: misc.cpp:82
UINT ClassifyFile(PCWSTR Path)
Definition: misc.cpp:127
HRESULT GetKnownPath(REFKNOWNFOLDERID kfid, CStringW &Path, DWORD Flags)
Definition: misc.cpp:592
UINT CreateDirectoryTree(LPCWSTR Dir)
Definition: misc.cpp:564
static HANDLE hLog
Definition: misc.cpp:15
BOOL GetStorageDirectory(CStringW &Directory)
Definition: misc.cpp:239
EXTERN_C NTSTATUS WINAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG)
BOOL GetInstalledVersion_WowUser(CStringW *szVersionResult, const CStringW &szRegName, BOOL IsUserKey, REGSAM keyWow)
Definition: misc.cpp:337
InstallerType GuessInstallerType(LPCWSTR Installer, UINT &ExtraInfo)
Definition: misc.cpp:635
VOID InitLogs()
Definition: misc.cpp:274
VOID FreeLogs()
Definition: misc.cpp:312
INT GetSystemColorDepth()
Definition: misc.cpp:407
VOID CopyTextToClipboard(LPCWSTR lpszText)
Definition: misc.cpp:30
BOOL DeleteDirectoryTree(LPCWSTR Dir, HWND hwnd)
Definition: misc.cpp:551
BOOL SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle)
Definition: misc.cpp:542
LPCWSTR GetRegString(CRegKey &Key, LPCWSTR Name, CStringW &Value)
Definition: misc.cpp:502
HRESULT GetSpecialPath(UINT csidl, CStringW &Path, HWND hwnd)
Definition: misc.cpp:583
CStringW SplitFileAndDirectory(LPCWSTR FullPath, CStringW *pDir)
Definition: misc.cpp:571
BOOL IsSystem64Bit()
Definition: misc.cpp:384
BOOL IsZipFile(PCWSTR Path)
Definition: geninst.cpp:51
ULONG GetNTVersion()
Definition: misc.cpp:397
UINT ErrorBox(HWND hOwner, UINT Error)
Definition: misc.cpp:18
static INT_PTR CALLBACK NothingDlgProc(HWND hDlg, UINT uMsg, WPARAM, LPARAM)
Definition: misc.cpp:57
static BOOL ReadAt(HANDLE Handle, UINT Offset, LPVOID Buffer, UINT Size)
Definition: misc.cpp:626
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
Definition: misc.cpp:447
HRESULT RegKeyHasValues(HKEY hKey, LPCWSTR Path, REGSAM wowsam)
Definition: misc.cpp:484
BOOL Error
Definition: chkdsk.c:66
#define EXTERN_C
Definition: basetyps.h:12
w ll
Definition: byte_order.h:167
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE) noexcept
Definition: atlbase.h:1173
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:387
void Empty() noexcept
Definition: atlsimpstr.h:253
Definition: bufpool.h:45
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:573
#define ERROR_SUCCESS
Definition: deptool.c:10
LPWSTR Name
Definition: desk.c:124
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:182
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
BOOL WINAPI ReportEventW(IN HANDLE hEventLog, IN WORD wType, IN WORD wCategory, IN DWORD dwEventID, IN PSID lpUserSid, IN WORD wNumStrings, IN DWORD dwDataSize, IN LPCWSTR *lpStrings, IN LPVOID lpRawData)
Definition: eventlog.c:1516
BOOL WINAPI DeregisterEventSource(IN HANDLE hEventLog)
Definition: eventlog.c:473
HANDLE WINAPI RegisterEventSourceW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpSourceName)
Definition: eventlog.c:1295
LPWSTR WINAPI StrStrIW(LPCWSTR lpszStr, LPCWSTR lpszSearch)
Definition: string.c:380
#define CloseHandle
Definition: compat.h:739
int(* FARPROC)()
Definition: compat.h:36
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FreeLibrary(x)
Definition: compat.h:748
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define CALLBACK
Definition: compat.h:35
#define LoadLibraryW(x)
Definition: compat.h:747
#define FILE_SHARE_READ
Definition: compat.h:136
static DWORD cchBuffer
Definition: fusion.c:85
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:520
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:58
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4442
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1701
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1274
int WINAPI StrCmpIW(const WCHAR *str, const WCHAR *comp)
Definition: string.c:456
DWORD WINAPI GetVersion(void)
Definition: version.c:1458
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3219
HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
Definition: assoc.c:441
BOOL WINAPI IsOS(DWORD feature)
Definition: ordinal.c:4230
void WINAPI PathRemoveArgsW(LPWSTR lpszPath)
Definition: path.c:779
#define pt(x, y)
Definition: drawing.c:79
#define L(x)
Definition: resources.c:13
#define INFINITE
Definition: serial.h:102
HINSTANCE hInst
Definition: dxdiag.c:13
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_ PCUNICODE_STRING Name2
Definition: fsrtlfuncs.h:796
FxAutoRegKey hKey
ULONG Handle
Definition: gdb_input.c:15
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat f
Definition: glext.h:7540
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat GLfloat p
Definition: glext.h:8902
GLuint64EXT GLuint GLuint GLenum GLenum GLuint GLuint GLenum GLuint GLuint key1
Definition: glext.h:10608
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define C_ASSERT(e)
Definition: intsafe.h:73
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
#define LOBYTE(W)
Definition: jmemdos.c:487
#define f
Definition: ke_i.h:83
HWND hMainWnd
Definition: magnifier.c:32
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define ZeroMemory
Definition: minwinbase.h:31
#define CopyMemory
Definition: minwinbase.h:29
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR WPARAM
Definition: minwindef.h:174
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
LPCWSTR szPath
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static HTREEITEM hRoot
Definition: treeview.c:383
static LPCWSTR szVersion
Definition: asmcache.c:748
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
static SYSTEM_INFO si
Definition: virtual.c:39
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:100
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
_In_ HANDLE hFile
Definition: mswsock.h:90
CAtlStringW CStringW
Definition: atlstr.h:130
unsigned int UINT
Definition: ndis.h:50
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define KEY_READ
Definition: nt_native.h:1026
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define KEY_WRITE
Definition: nt_native.h:1034
#define DWORD
Definition: nt_native.h:44
#define REG_NONE
Definition: nt_native.h:1495
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define Int32x32To64(a, b)
#define UNICODE_NULL
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
static HANDLE ULONG_PTR dwData
Definition: pipe.c:83
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define PathAppendW
Definition: pathcch.h:310
#define WS_CAPTION
Definition: pedump.c:624
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_POPUP
Definition: pedump.c:616
#define RT_RCDATA
Definition: pedump.c:372
long LONG
Definition: pedump.c:60
#define ILC_COLOR4
Definition: commctrl.h:354
#define ILC_COLOR16
Definition: commctrl.h:356
#define ILC_COLOR8
Definition: commctrl.h:355
#define ILC_COLOR32
Definition: commctrl.h:358
#define ILC_COLOR24
Definition: commctrl.h:357
#define ILC_COLOR
Definition: commctrl.h:352
@ ASSOCSTR_COMMAND
Definition: shlwapi.h:886
#define OS_WOW6432
Definition: shlwapi.h:256
@ ASSOCF_INIT_IGNOREUNKNOWN
Definition: shlwapi.h:870
@ ASSOCF_NOTRUNCATE
Definition: shlwapi.h:865
enum _OBJECT_INFORMATION_CLASS OBJECT_INFORMATION_CLASS
#define err(...)
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:430
_In_ UINT _In_ UINT cch
Definition: shellapi.h:432
#define FO_DELETE
Definition: shellapi.h:138
#define FOF_NOERRORUI
Definition: shellapi.h:151
WORD FILEOP_FLAGS
Definition: shellapi.h:213
#define FOF_NOCONFIRMATION
Definition: shellapi.h:145
#define FOF_SILENT
Definition: shellapi.h:143
#define SHGFI_EXETYPE
Definition: shellapi.h:170
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:2200
int WINAPI SHCreateDirectory(HWND hWnd, LPCWSTR path)
Definition: shlfileop.cpp:948
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2218
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2208
@ PERCEIVED_TYPE_COMPRESSED
Definition: shtypes.idl:177
@ PERCEIVED_TYPE_UNKNOWN
Definition: shtypes.idl:172
@ PERCEIVED_TYPE_APPLICATION
Definition: shtypes.idl:180
KNOWNFOLDERID * REFKNOWNFOLDERID
Definition: shtypes.idl:147
#define _countof(array)
Definition: sndvol32.h:70
CardRegion * from
Definition: spigame.cpp:19
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
base for all directory entries
Definition: entries.h:138
BOOL bLogEnabled
Definition: settings.h:9
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:237
ULONG dwMajorVersion
Definition: rtltypes.h:238
ULONG dwMinorVersion
Definition: rtltypes.h:239
DWORD Offset
Definition: minwinbase.h:225
DWORD dmBitsPerPel
Definition: wingdi.h:2093
WORD dmDriverExtra
Definition: wingdi.h:2067
WORD dmSize
Definition: wingdi.h:2066
Definition: cache.c:49
Definition: fci.c:127
Definition: copy.c:22
Definition: name.c:39
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT_PTR
Definition: typedefs.h:64
uint32_t * PULONG
Definition: typedefs.h:59
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define MAKEWORD(a, b)
Definition: typedefs.h:248
int64_t LONGLONG
Definition: typedefs.h:68
PVOID HANDLE
Definition: typedefs.h:73
int32_t INT
Definition: typedefs.h:58
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
OSVERSIONINFO osvi
Definition: ver.c:28
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode)
Definition: display.c:408
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LoadLibraryEx
Definition: winbase.h:3612
#define STARTF_USESHOWWINDOW
Definition: winbase.h:468
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:397
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:400
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define WAIT_FAILED
Definition: winbase.h:390
#define GMEM_DDESHARE
Definition: winbase.h:322
#define UnlockResource(handle)
Definition: winbase.h:3125
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:3451
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_OLD_WIN_VERSION
Definition: winerror.h:996
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:1185
#define EVENTLOG_ERROR_TYPE
Definition: winnt_old.h:3075
#define EVENTLOG_INFORMATION_TYPE
Definition: winnt_old.h:3077
#define EVENTLOG_WARNING_TYPE
Definition: winnt_old.h:3076
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
ACCESS_MASK REGSAM
Definition: winreg.h:76
#define WM_CLOSE
Definition: winuser.h:1649
#define SWP_NOACTIVATE
Definition: winuser.h:1253
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
#define QS_ALLEVENTS
Definition: winuser.h:913
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:3064
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MIIM_STATE
Definition: winuser.h:732
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define MFS_GRAYED
Definition: winuser.h:762
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1207
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
#define SendMessage
Definition: winuser.h:6009
#define CreateDialogIndirectW(h, t, w, f)
Definition: winuser.h:4437
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define MB_OK
Definition: winuser.h:801
BOOL WINAPI DestroyMenu(_In_ HMENU)
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define MB_ICONSTOP
Definition: winuser.h:814
#define SW_SHOW
Definition: winuser.h:786
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define SWP_NOZORDER
Definition: winuser.h:1258
#define DM_REPOSITION
Definition: winuser.h:2136
BOOL WINAPI DestroyWindow(_In_ HWND)
HMENU WINAPI GetMenu(_In_ HWND)
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
Allocation
Definition: exfuncs.h:598
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned char BYTE
Definition: xxhash.c:193