ReactOS 0.4.17-dev-243-g1369312
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
177UINT
179{
181 for (;;)
182 {
184 if (wait == WAIT_OBJECT_0 + 1)
185 {
186 MSG msg;
187 while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
188 {
191 }
192 }
193 else
194 {
195 // TODO: if (wait == WAIT_OBJECT_0) GetExitCodeProcess for MSI reboot codes
196 break;
197 }
198 }
199 return code;
200}
201
202BOOL
204{
207
208 ZeroMemory(&si, sizeof(si));
209 si.cb = sizeof(si);
210 si.dwFlags = STARTF_USESHOWWINDOW;
211 si.wShowWindow = SW_SHOW;
212
213 // The Unicode version of CreateProcess can modify the contents of this string.
214 CStringW Tmp = Path;
215 BOOL fSuccess = CreateProcessW(NULL, Tmp.GetBuffer(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
216 Tmp.ReleaseBuffer();
217 if (!fSuccess)
218 {
219 return FALSE;
220 }
221
223
224 if (Wait)
225 {
227
229
232 // We got the real activation message during MsgWaitForMultipleObjects while
233 // we were disabled, we need to set the focus again now.
235 }
237 return TRUE;
238}
239
240BOOL
242{
243 static CStringW CachedDirectory;
244 static BOOL CachedDirectoryInitialized = FALSE;
245
246 if (!CachedDirectoryInitialized)
247 {
248 LPWSTR DirectoryStr = CachedDirectory.GetBuffer(MAX_PATH);
249 BOOL bHasPath = SHGetSpecialFolderPathW(NULL, DirectoryStr, CSIDL_LOCAL_APPDATA, TRUE);
250 if (bHasPath)
251 {
252 PathAppendW(DirectoryStr, RAPPS_NAME);
253 }
254 CachedDirectory.ReleaseBuffer();
255
256 if (bHasPath)
257 {
258 if (!CreateDirectoryW(CachedDirectory, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
259 {
260 CachedDirectory.Empty();
261 }
262 }
263 else
264 {
265 CachedDirectory.Empty();
266 }
267
268 CachedDirectoryInitialized = TRUE;
269 }
270
271 Directory = CachedDirectory;
272 return !Directory.IsEmpty();
273}
274
275VOID
277{
279 {
280 return;
281 }
282
284 DWORD dwCategoryNum = 1;
285 DWORD dwDisp, dwData;
287
288 if (key.Create(
290 L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\ReactOS Application Manager", REG_NONE,
292 {
293 return;
294 }
295
297 {
298 return;
299 }
300
302
303 if ((key.SetStringValue(L"EventMessageFile", szPath, REG_EXPAND_SZ) == ERROR_SUCCESS) &&
304 (key.SetStringValue(L"CategoryMessageFile", szPath, REG_EXPAND_SZ) == ERROR_SUCCESS) &&
305 (key.SetDWORDValue(L"TypesSupported", dwData) == ERROR_SUCCESS) &&
306 (key.SetDWORDValue(L"CategoryCount", dwCategoryNum) == ERROR_SUCCESS))
307
308 {
309 hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager");
310 }
311}
312
313VOID
315{
316 if (hLog)
317 {
319 }
320}
321
322BOOL
323WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
324{
326 {
327 return TRUE;
328 }
329
330 if (!ReportEventW(hLog, wType, 0, dwEventID, NULL, 1, 0, &lpMsg, NULL))
331 {
332 return FALSE;
333 }
334
335 return TRUE;
336}
337
338BOOL
339GetInstalledVersion_WowUser(CStringW *szVersionResult, const CStringW &szRegName, BOOL IsUserKey, REGSAM keyWow)
340{
341 BOOL bHasSucceded = FALSE;
344 CStringW szPath = CStringW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\") + szRegName;
345
346 if (key.Open(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, szPath.GetString(), keyWow | KEY_READ) !=
348 {
349 return FALSE;
350 }
351
352 if (szVersionResult != NULL)
353 {
354 ULONG dwSize = MAX_PATH * sizeof(WCHAR);
355
356 if (key.QueryStringValue(L"DisplayVersion", szVersion.GetBuffer(MAX_PATH), &dwSize) == ERROR_SUCCESS)
357 {
358 szVersion.ReleaseBuffer();
359 *szVersionResult = szVersion;
360 bHasSucceded = TRUE;
361 }
362 else
363 {
364 szVersion.ReleaseBuffer();
365 }
366 }
367 else
368 {
369 bHasSucceded = TRUE;
370 }
371
372 return bHasSucceded;
373}
374
375BOOL
376GetInstalledVersion(CStringW *pszVersion, const CStringW &szRegName)
377{
378 return (
379 !szRegName.IsEmpty() && (GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY) ||
380 GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_32KEY) ||
381 GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_64KEY) ||
382 GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_64KEY)));
383}
384
385BOOL
387{
388#ifdef _WIN64
389 return TRUE;
390#else
391 static UINT cache = 0;
392 if (!cache)
393 cache = 1 + (IsOS(OS_WOW6432) != FALSE);
394 return cache - 1;
395#endif
396}
397
398ULONG
400{
402 osvi.dwOSVersionInfoSize = sizeof(osvi);
404
405 return (osvi.dwMajorVersion << 8) | (osvi.dwMinorVersion);
406}
407
408INT
410{
411 DEVMODEW pDevMode;
412 INT ColorDepth;
413
414 pDevMode.dmSize = sizeof(pDevMode);
415 pDevMode.dmDriverExtra = 0;
416
418 {
419 /* TODO: Error message */
420 return ILC_COLOR;
421 }
422
423 switch (pDevMode.dmBitsPerPel)
424 {
425 case 32:
426 ColorDepth = ILC_COLOR32;
427 break;
428 case 24:
429 ColorDepth = ILC_COLOR24;
430 break;
431 case 16:
432 ColorDepth = ILC_COLOR16;
433 break;
434 case 8:
435 ColorDepth = ILC_COLOR8;
436 break;
437 case 4:
438 ColorDepth = ILC_COLOR4;
439 break;
440 default:
441 ColorDepth = ILC_COLOR;
442 break;
443 }
444
445 return ColorDepth;
446}
447
448void
449UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
450{
451 // Note that LONGLONG is a 64-bit value
452 LONGLONG ll;
453
454 ll = Int32x32To64(dwUnixTime, 10000000) + 116444736000000000;
455 pFileTime->dwLowDateTime = (DWORD)ll;
456 pFileTime->dwHighDateTime = ll >> 32;
457}
458
459static BOOL
460IsSameRegKey(HKEY hKey1, HKEY hKey2)
461{
462 // CompareObjectHandles is Win10+ so we check the path instead.
463 struct NameInfo : UNICODE_STRING
464 {
466 NameInfo() { MaximumLength = sizeof(Allocation); Buffer = Allocation; }
467 };
468 NameInfo Name1, Name2;
470 return NT_SUCCESS(NtQueryObject(hKey1, ObjectNameInformation, &Name1, sizeof(Name1), &Length)) &&
472 RtlCompareUnicodeString(&Name1, &Name2, TRUE) == 0;
473}
474
475BOOL
477{
479 CRegKey key1, key2;
480 return key1.Open(hRoot, Path1, MAXIMUM_ALLOWED | (Sam1 & WowMask)) == ERROR_SUCCESS &&
481 key2.Open(hRoot, Path2, MAXIMUM_ALLOWED | (Sam2 & WowMask)) == ERROR_SUCCESS &&
482 IsSameRegKey(key1, key2);
483}
484
487{
488 CRegKey key;
489 LONG err = key.Open(hKey, Path, KEY_QUERY_VALUE | wowsam);
490 if (err == ERROR_SUCCESS)
491 {
492 WCHAR name[1];
493 DWORD cchname = _countof(name), cbsize = 0;
494 err = RegEnumValueW(key, 0, name, &cchname, NULL, NULL, NULL, &cbsize);
496 return S_FALSE;
497 if (err == ERROR_MORE_DATA)
499 }
500 return HRESULT_FROM_WIN32(err);
501}
502
505{
506 for (;;)
507 {
508 ULONG cb = 0, cch;
509 ULONG err = Key.QueryValue(Name, NULL, NULL, &cb);
510 if (err)
511 break;
512 cch = cb / sizeof(WCHAR);
513 LPWSTR p = Value.GetBuffer(cch + 1);
514 p[cch] = UNICODE_NULL;
515 err = Key.QueryValue(Name, NULL, (BYTE*)p, &cb);
516 if (err == ERROR_MORE_DATA)
517 continue;
518 if (err)
519 break;
520 Value.ReleaseBuffer();
521 return Value.GetString();
522 }
523 return NULL;
524}
525
526bool
528{
531 if (cch)
532 {
533 if (ExpandEnvironmentStringsW(Str, buf.GetBuffer(cch), cch) == cch)
534 {
535 buf.ReleaseBuffer(cch - 1);
536 Str = buf;
537 return true;
538 }
539 }
540 return false;
541}
542
543BOOL
544SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle)
545{
546 if (!*szNeedle)
547 return TRUE;
548 /* TODO: Improve pattern search beyond a simple case-insensitive substring search. */
549 return StrStrIW(szHaystack, szNeedle) != NULL;
550}
551
552BOOL
554{
555 CStringW from(Dir);
556 UINT cch = from.GetLength();
557 from.Append(L"00");
558 LPWSTR p = from.GetBuffer();
559 p[cch] = p[cch + 1] = L'\0'; // Double null-terminate
561 SHFILEOPSTRUCT shfos = { hwnd, FO_DELETE, p, NULL, (FILEOP_FLAGS)fof };
562 return SHFileOperationW(&shfos);
563}
564
565UINT
567{
569 return err == ERROR_ALREADY_EXISTS ? 0 : err;
570}
571
574{
575 CPathW dir = FullPath;
576 //int win = dir.ReverseFind(L'\\'), nix = dir.ReverseFind(L'/'), sep = max(win, nix);
577 int sep = dir.FindFileName();
578 CStringW file = dir.m_strPath.Mid(sep);
579 if (pDir)
580 *pDir = sep == -1 ? L"" : dir.m_strPath.Left(sep - 1);
581 return file;
582}
583
586{
587 if (!SHGetSpecialFolderPathW(hwnd, Path.GetBuffer(MAX_PATH), csidl, TRUE))
588 return E_FAIL;
589 Path.ReleaseBuffer();
590 return S_OK;
591}
592
595{
596 PWSTR p;
597 FARPROC f = GetProcAddress(LoadLibraryW(L"SHELL32"), "SHGetKnownFolderPath");
598 if (!f)
601 if (FAILED(hr))
602 return hr;
603 Path = p;
605 return hr;
606}
607
610{
611 if (!PerUser)
613
614 HRESULT hr = GetKnownPath(FOLDERID_UserProgramFiles, Path);
615 if (FAILED(hr))
616 {
618 // Use the correct path on NT6 (on NT5 the path becomes a bit long)
619 if (SUCCEEDED(hr) && LOBYTE(GetVersion()) >= 6)
620 {
621 Path = BuildPath(Path, L"Programs"); // Should not be localized
622 }
623 }
624 return hr;
625}
626
627static BOOL
629{
630 OVERLAPPED ol = {};
631 ol.Offset = Offset;
632 DWORD cb;
633 return ReadFile(Handle, Buffer, Size, &cb, &ol) && cb == Size;
634}
635
637GuessInstallerType(LPCWSTR Installer, UINT &ExtraInfo)
638{
639 ExtraInfo = 0;
641
644 return it;
645
646 BYTE buf[0x30 + 12];
647 if (!ReadAt(hFile, 0, buf, sizeof(buf)))
648 goto done;
649
650 if (buf[0] == 0xD0 && buf[1] == 0xCF && buf[2] == 0x11 && buf[3] == 0xE0)
651 {
652 if (!StrCmpIW(L".msi", PathFindExtensionW(Installer)))
653 {
654 it = INSTALLER_MSI;
655 goto done;
656 }
657 }
658
659 if (buf[0] != 'M' || buf[1] != 'Z')
660 goto done;
661
662 // <= Inno 5.1.4
663 {
664 UINT sig[3];
665 C_ASSERT(sizeof(buf) >= 0x30 + sizeof(sig));
666 CopyMemory(sig, buf + 0x30, sizeof(sig));
667 if (sig[0] == 0x6F6E6E49 && sig[1] == ~sig[2])
668 {
669 it = INSTALLER_INNO;
670 ExtraInfo = 1;
671 goto done;
672 }
673 }
674
675 // NSIS 1.6+
676 {
677 UINT nsis[1+1+3+1+1], nsisskip = 512;
678 for (UINT nsisoffset = nsisskip * 20; nsisoffset < 1024 * 1024 * 50; nsisoffset += nsisskip)
679 {
680 if (ReadAt(hFile, nsisoffset, nsis, sizeof(nsis)) && nsis[1] == 0xDEADBEEF)
681 {
682 if (nsis[2] == 0x6C6C754E && nsis[3] == 0x74666F73 && nsis[4] == 0x74736E49)
683 {
684 it = INSTALLER_NSIS;
685 goto done;
686 }
687 }
688 }
689 }
690
691 if (HMODULE hMod = LoadLibraryEx(Installer, NULL, LOAD_LIBRARY_AS_DATAFILE))
692 {
693 // Inno
694 enum { INNORCSETUPLDR = 11111 };
695 HGLOBAL hGlob;
696 HRSRC hRsrc = FindResourceW(hMod, MAKEINTRESOURCE(INNORCSETUPLDR), RT_RCDATA);
697 if (hRsrc && (hGlob = LoadResource(hMod, hRsrc)) != NULL)
698 {
699 if (BYTE *p = (BYTE*)LockResource(hGlob))
700 {
701 if (p[0] == 'r' && p[1] == 'D' && p[2] == 'l' && p[3] == 'P' && p[4] == 't' && p[5] == 'S')
702 it = INSTALLER_INNO;
703 UnlockResource((void*)p);
704 }
705 }
706 FreeLibrary(hMod);
707 }
708done:
710 return it;
711}
712
713BOOL
715{
716 switch (InstallerType)
717 {
718 case INSTALLER_MSI:
719 {
720 Parameters.Format(L"/i \"%s\" /qn", Installer);
721 return TRUE;
722 }
723
724 case INSTALLER_INNO:
725 {
726 LPCWSTR pszInnoParams = L"/SILENT /VERYSILENT /SP-";
727 if (ExtraInfo)
728 Parameters.Format(L"%s", pszInnoParams);
729 else
730 Parameters.Format(L"%s /SUPPRESSMSGBOXES", pszInnoParams); // https://jrsoftware.org/files/is5.5-whatsnew.htm
731 return TRUE;
732 }
733
734 case INSTALLER_NSIS:
735 {
736 Parameters = L"/S";
737 return TRUE;
738 }
739
740 default:
741 {
742 return FALSE;
743 }
744 }
745}
@ 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:120
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:21
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:323
bool ExpandEnvStrings(CStringW &Str)
Definition: misc.cpp:527
UINT WaitForProcess(HANDLE hProcess)
Definition: misc.cpp:178
BOOL StartProcess(const CStringW &Path, BOOL Wait)
Definition: misc.cpp:203
static BOOL IsSameRegKey(HKEY hKey1, HKEY hKey2)
Definition: misc.cpp:460
BOOL GetInstalledVersion(CStringW *pszVersion, const CStringW &szRegName)
Definition: misc.cpp:376
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:609
BOOL GetSilentInstallParameters(InstallerType InstallerType, UINT ExtraInfo, LPCWSTR Installer, CStringW &Parameters)
Definition: misc.cpp:714
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:594
UINT CreateDirectoryTree(LPCWSTR Dir)
Definition: misc.cpp:566
static HANDLE hLog
Definition: misc.cpp:15
BOOL GetStorageDirectory(CStringW &Directory)
Definition: misc.cpp:241
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:339
InstallerType GuessInstallerType(LPCWSTR Installer, UINT &ExtraInfo)
Definition: misc.cpp:637
VOID InitLogs()
Definition: misc.cpp:276
VOID FreeLogs()
Definition: misc.cpp:314
INT GetSystemColorDepth()
Definition: misc.cpp:409
VOID CopyTextToClipboard(LPCWSTR lpszText)
Definition: misc.cpp:30
BOOL DeleteDirectoryTree(LPCWSTR Dir, HWND hwnd)
Definition: misc.cpp:553
BOOL SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle)
Definition: misc.cpp:544
LPCWSTR GetRegString(CRegKey &Key, LPCWSTR Name, CStringW &Value)
Definition: misc.cpp:504
HRESULT GetSpecialPath(UINT csidl, CStringW &Path, HWND hwnd)
Definition: misc.cpp:585
CStringW SplitFileAndDirectory(LPCWSTR FullPath, CStringW *pDir)
Definition: misc.cpp:573
BOOL IsSystem64Bit()
Definition: misc.cpp:386
BOOL IsZipFile(PCWSTR Path)
Definition: geninst.cpp:51
ULONG GetNTVersion()
Definition: misc.cpp:399
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:628
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
Definition: misc.cpp:449
HRESULT RegKeyHasValues(HKEY hKey, LPCWSTR Path, REGSAM wowsam)
Definition: misc.cpp:486
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:582
#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:492
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:4441
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:782
#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
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define ZeroMemory
Definition: minwinbase.h:31
#define STILL_ACTIVE
Definition: minwinbase.h:43
#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:72
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
_In_ BOOLEAN _In_ USHORT Directory
Definition: rtlfuncs.h:3942
#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:111
#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
short WCHAR
Definition: pedump.c:58
#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
@ ASSOCF_INIT_IGNOREUNKNOWN
Definition: shlwapi.h:870
@ ASSOCF_NOTRUNCATE
Definition: shlwapi.h:865
@ ASSOCSTR_COMMAND
Definition: shlwapi.h:886
#define OS_WOW6432
Definition: shlwapi.h:256
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
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: inflate.c:139
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
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define MAKEWORD(a, b)
Definition: typedefs.h:248
uint16_t * LPWSTR
Definition: typedefs.h:56
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 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
unsigned char BYTE
Definition: xxhash.c:193