ReactOS 0.4.16-dev-2357-g35d0dfe
misc.cpp File Reference
#include "rapps.h"
#include "misc.h"
Include dependency graph for misc.cpp:

Go to the source code of this file.

Functions

EXTERN_C NTSTATUS WINAPI NtQueryObject (HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG)
 
UINT ErrorBox (HWND hOwner, UINT Error)
 
VOID CopyTextToClipboard (LPCWSTR lpszText)
 
static INT_PTR CALLBACK NothingDlgProc (HWND hDlg, UINT uMsg, WPARAM, LPARAM)
 
VOID EmulateDialogReposition (HWND hwnd)
 
VOID ShowPopupMenuEx (HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem, POINT *Point)
 
BOOL IsZipFile (PCWSTR Path)
 
UINT ClassifyFile (PCWSTR Path)
 
BOOL OpensWithExplorer (PCWSTR Path)
 
BOOL StartProcess (const CStringW &Path, BOOL Wait)
 
BOOL GetStorageDirectory (CStringW &Directory)
 
VOID InitLogs ()
 
VOID FreeLogs ()
 
BOOL WriteLogMessage (WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
 
BOOL GetInstalledVersion_WowUser (CStringW *szVersionResult, const CStringW &szRegName, BOOL IsUserKey, REGSAM keyWow)
 
BOOL GetInstalledVersion (CStringW *pszVersion, const CStringW &szRegName)
 
BOOL IsSystem64Bit ()
 
ULONG GetNTVersion ()
 
INT GetSystemColorDepth ()
 
void UnixTimeToFileTime (DWORD dwUnixTime, LPFILETIME pFileTime)
 
static BOOL IsSameRegKey (HKEY hKey1, HKEY hKey2)
 
BOOL IsSameRegKey (HKEY hRoot, LPCWSTR Path1, REGSAM Sam1, LPCWSTR Path2, REGSAM Sam2)
 
HRESULT RegKeyHasValues (HKEY hKey, LPCWSTR Path, REGSAM wowsam)
 
LPCWSTR GetRegString (CRegKey &Key, LPCWSTR Name, CStringW &Value)
 
bool ExpandEnvStrings (CStringW &Str)
 
BOOL SearchPatternMatch (LPCWSTR szHaystack, LPCWSTR szNeedle)
 
BOOL DeleteDirectoryTree (LPCWSTR Dir, HWND hwnd)
 
UINT CreateDirectoryTree (LPCWSTR Dir)
 
CStringW SplitFileAndDirectory (LPCWSTR FullPath, CStringW *pDir)
 
HRESULT GetSpecialPath (UINT csidl, CStringW &Path, HWND hwnd)
 
HRESULT GetKnownPath (REFKNOWNFOLDERID kfid, CStringW &Path, DWORD Flags)
 
HRESULT GetProgramFilesPath (CStringW &Path, BOOL PerUser, HWND hwnd)
 
static BOOL ReadAt (HANDLE Handle, UINT Offset, LPVOID Buffer, UINT Size)
 
InstallerType GuessInstallerType (LPCWSTR Installer, UINT &ExtraInfo)
 
BOOL GetSilentInstallParameters (InstallerType InstallerType, UINT ExtraInfo, LPCWSTR Installer, CStringW &Parameters)
 

Variables

static HANDLE hLog = NULL
 

Function Documentation

◆ ClassifyFile()

UINT ClassifyFile ( PCWSTR  Path)

Definition at line 127 of file misc.cpp.

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}
PRTL_UNICODE_STRING_BUFFER Path
BOOL IsZipFile(PCWSTR Path)
Definition: geninst.cpp:51
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:100
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned int UINT
Definition: ndis.h:50
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:430
#define SHGFI_EXETYPE
Definition: shellapi.h:170
@ PERCEIVED_TYPE_COMPRESSED
Definition: shtypes.idl:177
@ PERCEIVED_TYPE_UNKNOWN
Definition: shtypes.idl:172
@ PERCEIVED_TYPE_APPLICATION
Definition: shtypes.idl:180
#define MAKEWORD(a, b)
Definition: typedefs.h:248
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ExtractArchive(), and CDownloadManager::PerformDownloadAndInstall().

◆ CopyTextToClipboard()

VOID CopyTextToClipboard ( LPCWSTR  lpszText)

Definition at line 30 of file misc.cpp.

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}
#define CF_UNICODETEXT
Definition: constants.h:408
Definition: bufpool.h:45
static DWORD cchBuffer
Definition: fusion.c:85
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
HRESULT hr
Definition: shlfolder.c:183
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
uint16_t * PWCHAR
Definition: typedefs.h:56
#define GMEM_DDESHARE
Definition: winbase.h:322
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CAppInfoDisplay::OnCommand().

◆ CreateDirectoryTree()

UINT CreateDirectoryTree ( LPCWSTR  Dir)

Definition at line 564 of file misc.cpp.

565{
567 return err == ERROR_ALREADY_EXISTS ? 0 : err;
568}
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define err(...)
int WINAPI SHCreateDirectory(HWND hWnd, LPCWSTR path)
Definition: shlfileop.cpp:948

Referenced by ExtractAndInstallThread(), ExtractArchiveForExecution(), ExtractFilesFromZip(), and InstallFiles().

◆ DeleteDirectoryTree()

BOOL DeleteDirectoryTree ( LPCWSTR  Dir,
HWND  hwnd 
)

Definition at line 551 of file misc.cpp.

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}
#define L(x)
Definition: resources.c:13
GLfloat GLfloat p
Definition: glext.h:8902
_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
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:2200
CardRegion * from
Definition: spigame.cpp:19
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by ExtractAndInstallThread(), ExtractArchiveForExecution(), CDownloadManager::PerformDownloadAndInstall(), and UninstallThread().

◆ EmulateDialogReposition()

VOID EmulateDialogReposition ( HWND  hwnd)

Definition at line 63 of file misc.cpp.

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}
static INT_PTR CALLBACK NothingDlgProc(HWND hDlg, UINT uMsg, WPARAM, LPARAM)
Definition: misc.cpp:57
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WS_CAPTION
Definition: pedump.c:624
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_POPUP
Definition: pedump.c:616
#define WM_CLOSE
Definition: winuser.h:1649
#define SWP_NOACTIVATE
Definition: winuser.h:1253
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)
#define SendMessage
Definition: winuser.h:5954
#define CreateDialogIndirectW(h, t, w, f)
Definition: winuser.h:4385
#define SWP_NOZORDER
Definition: winuser.h:1258
#define DM_REPOSITION
Definition: winuser.h:2136

Referenced by CMainWindow::ProcessWindowMessage().

◆ ErrorBox()

UINT ErrorBox ( HWND  hOwner,
UINT  Error 
)

Definition at line 18 of file misc.cpp.

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}
BOOL Error
Definition: chkdsk.c:66
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define _countof(array)
Definition: sndvol32.h:70
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:397
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:400
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:1185
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:801
#define MB_ICONSTOP
Definition: winuser.h:814

◆ ExpandEnvStrings()

bool ExpandEnvStrings ( CStringW Str)

Definition at line 525 of file misc.cpp.

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}
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:520

Referenced by ExtractAndInstallThread().

◆ FreeLogs()

VOID FreeLogs ( )

Definition at line 312 of file misc.cpp.

313{
314 if (hLog)
315 {
317 }
318}
static HANDLE hLog
Definition: misc.cpp:15
BOOL WINAPI DeregisterEventSource(IN HANDLE hEventLog)
Definition: eventlog.c:473

Referenced by CMainWindow::ProcessWindowMessage(), and wmain().

◆ GetInstalledVersion()

BOOL GetInstalledVersion ( CStringW pszVersion,
const CStringW szRegName 
)

Definition at line 374 of file misc.cpp.

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}
BOOL GetInstalledVersion_WowUser(CStringW *szVersionResult, const CStringW &szRegName, BOOL IsUserKey, REGSAM keyWow)
Definition: misc.cpp:337
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46

Referenced by CAvailableApplicationInfo::InsertVersionInfo().

◆ GetInstalledVersion_WowUser()

BOOL GetInstalledVersion_WowUser ( CStringW szVersionResult,
const CStringW szRegName,
BOOL  IsUserKey,
REGSAM  keyWow 
)

Definition at line 337 of file misc.cpp.

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}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAX_PATH
Definition: compat.h:34
unsigned int BOOL
Definition: ntddk_ex.h:94
LPCWSTR szPath
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static LPCWSTR szVersion
Definition: asmcache.c:748
CAtlStringW CStringW
Definition: atlstr.h:130
#define KEY_READ
Definition: nt_native.h:1026
Definition: copy.c:22
uint32_t ULONG
Definition: typedefs.h:59
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by GetInstalledVersion().

◆ GetKnownPath()

HRESULT GetKnownPath ( REFKNOWNFOLDERID  kfid,
CStringW Path,
DWORD  Flags 
)

Definition at line 592 of file misc.cpp.

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}
int(* FARPROC)()
Definition: compat.h:36
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
GLfloat f
Definition: glext.h:7540
#define FAILED(hr)
Definition: intsafe.h:51
#define f
Definition: ke_i.h:83
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
KNOWNFOLDERID * REFKNOWNFOLDERID
Definition: shtypes.idl:147
uint16_t * PWSTR
Definition: typedefs.h:56
PVOID HANDLE
Definition: typedefs.h:73
#define WINAPI
Definition: msvc.h:6
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_OLD_WIN_VERSION
Definition: winerror.h:996
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by GetProgramFilesPath().

◆ GetNTVersion()

ULONG GetNTVersion ( )

Definition at line 397 of file misc.cpp.

398{
400 osvi.dwOSVersionInfoSize = sizeof(osvi);
402
403 return (osvi.dwMajorVersion << 8) | (osvi.dwMinorVersion);
404}
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:182
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:237
ULONG dwMajorVersion
Definition: rtltypes.h:238
ULONG dwMinorVersion
Definition: rtltypes.h:239
OSVERSIONINFO osvi
Definition: ver.c:28

◆ GetProgramFilesPath()

HRESULT GetProgramFilesPath ( CStringW Path,
BOOL  PerUser,
HWND  hwnd 
)

Definition at line 607 of file misc.cpp.

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}
static CStringW BuildPath(const T &Base, LPCWSTR Append)
Definition: misc.h:111
HRESULT GetKnownPath(REFKNOWNFOLDERID kfid, CStringW &Path, DWORD Flags)
Definition: misc.cpp:592
HRESULT GetSpecialPath(UINT csidl, CStringW &Path, HWND hwnd)
Definition: misc.cpp:583
DWORD WINAPI GetVersion(void)
Definition: version.c:1458
#define LOBYTE(W)
Definition: jmemdos.c:487
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2218
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2208

Referenced by ExtractAndInstallThread().

◆ GetRegString()

LPCWSTR GetRegString ( CRegKey Key,
LPCWSTR  Name,
CStringW Value 
)

Definition at line 502 of file misc.cpp.

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}
#define ERROR_MORE_DATA
Definition: dderror.h:13
LPWSTR Name
Definition: desk.c:124
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
#define UNICODE_NULL
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by CRegTreeOptions::AddItemsFromRegistry(), GetLocalizedSMFolderName(), CRegTreeOptions::GetSetState(), and UninstallThread().

◆ GetSilentInstallParameters()

BOOL GetSilentInstallParameters ( InstallerType  InstallerType,
UINT  ExtraInfo,
LPCWSTR  Installer,
CStringW Parameters 
)

Definition at line 712 of file misc.cpp.

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}
InstallerType
Definition: appinfo.h:82
@ INSTALLER_NSIS
Definition: appinfo.h:88
@ INSTALLER_INNO
Definition: appinfo.h:87
@ INSTALLER_MSI
Definition: appinfo.h:86
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by CDownloadManager::PerformDownloadAndInstall().

◆ GetSpecialPath()

HRESULT GetSpecialPath ( UINT  csidl,
CStringW Path,
HWND  hwnd 
)

Definition at line 583 of file misc.cpp.

584{
585 if (!SHGetSpecialFolderPathW(hwnd, Path.GetBuffer(MAX_PATH), csidl, TRUE))
586 return E_FAIL;
587 Path.ReleaseBuffer();
588 return S_OK;
589}
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3219
#define S_OK
Definition: intsafe.h:52

Referenced by CreateMainShortcut(), and GetProgramFilesPath().

◆ GetStorageDirectory()

BOOL GetStorageDirectory ( CStringW Directory)

Definition at line 239 of file misc.cpp.

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}
#define RAPPS_NAME
Definition: defines.h:34
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:387
void Empty() noexcept
Definition: atlsimpstr.h:253
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:58
#define PathAppendW
Definition: pathcch.h:310
base for all directory entries
Definition: entries.h:138
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by CAppDB::GetDefaultPath(), CDownloadManager::PerformDownloadAndInstall(), and CAppInfoDisplay::ProcessWindowMessage().

◆ GetSystemColorDepth()

INT GetSystemColorDepth ( )

Definition at line 407 of file misc.cpp.

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}
#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
DWORD dmBitsPerPel
Definition: wingdi.h:2093
WORD dmDriverExtra
Definition: wingdi.h:2067
WORD dmSize
Definition: wingdi.h:2066
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode)
Definition: display.c:408
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179

Referenced by ApplicationPageWndProc(), CMainToolbar::InitImageList(), and CAppsListView::SetDisplayAppType().

◆ GuessInstallerType()

InstallerType GuessInstallerType ( LPCWSTR  Installer,
UINT ExtraInfo 
)

Definition at line 635 of file misc.cpp.

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}
@ INSTALLER_UNKNOWN
Definition: appinfo.h:83
static BOOL ReadAt(HANDLE Handle, UINT Offset, LPVOID Buffer, UINT Size)
Definition: misc.cpp:626
#define FreeLibrary(x)
Definition: compat.h:748
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
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1274
int WINAPI StrCmpIW(const WCHAR *str, const WCHAR *comp)
Definition: string.c:456
#define C_ASSERT(e)
Definition: intsafe.h:73
#define CopyMemory
Definition: minwinbase.h:29
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define RT_RCDATA
Definition: pedump.c:372
#define LoadLibraryEx
Definition: winbase.h:3612
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
#define UnlockResource(handle)
Definition: winbase.h:3125

Referenced by CDownloadManager::PerformDownloadAndInstall().

◆ InitLogs()

VOID InitLogs ( )

Definition at line 274 of file misc.cpp.

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}
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:21
HANDLE WINAPI RegisterEventSourceW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpSourceName)
Definition: eventlog.c:1295
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define KEY_WRITE
Definition: nt_native.h:1034
#define REG_NONE
Definition: nt_native.h:1495
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
static HANDLE ULONG_PTR dwData
Definition: pipe.c:83
BOOL bLogEnabled
Definition: settings.h:9
#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

Referenced by wmain(), and wWinMain().

◆ IsSameRegKey() [1/2]

static BOOL IsSameRegKey ( HKEY  hKey1,
HKEY  hKey2 
)
static

Definition at line 458 of file misc.cpp.

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}
@ ObjectNameInformation
Definition: DriverTester.h:55
EXTERN_C NTSTATUS WINAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
_Must_inspect_result_ _In_ PCUNICODE_STRING Name2
Definition: fsrtlfuncs.h:796
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
Allocation
Definition: exfuncs.h:598

Referenced by IsSameRegKey().

◆ IsSameRegKey() [2/2]

BOOL IsSameRegKey ( HKEY  hRoot,
LPCWSTR  Path1,
REGSAM  Sam1,
LPCWSTR  Path2,
REGSAM  Sam2 
)

Definition at line 474 of file misc.cpp.

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}
static BOOL IsSameRegKey(HKEY hKey1, HKEY hKey2)
Definition: misc.cpp:458
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE) noexcept
Definition: atlbase.h:1173
GLuint64EXT GLuint GLuint GLenum GLenum GLuint GLuint GLenum GLuint GLuint key1
Definition: glext.h:10608
static HTREEITEM hRoot
Definition: treeview.c:383
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
ACCESS_MASK REGSAM
Definition: winreg.h:76

Referenced by CEnumInstalledRootKey::CEnumInstalledRootKey().

◆ IsSystem64Bit()

BOOL IsSystem64Bit ( )

Definition at line 384 of file misc.cpp.

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}
BOOL WINAPI IsOS(DWORD feature)
Definition: ordinal.c:4230
#define OS_WOW6432
Definition: shlwapi.h:256
Definition: cache.c:49

Referenced by ExtractAndInstallThread().

◆ IsZipFile()

BOOL IsZipFile ( PCWSTR  Path)

Definition at line 51 of file geninst.cpp.

52{
55 unzFile hzf = unzOpen2_64(Path, &zff);
56 if (!hzf)
57 return FALSE;
58 unzClose(hzf);
59 return TRUE;
60}
void fill_win32_filefunc64W(zlib_filefunc64_def *pzlib_filefunc_def)
Definition: iowin32.c:457
unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def)
Definition: unzip.c:783
int ZEXPORT unzClose(unzFile file)
Definition: unzip.c:813
voidp unzFile
Definition: unzip.h:70

Referenced by ClassifyFile().

◆ NothingDlgProc()

static INT_PTR CALLBACK NothingDlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  ,
LPARAM   
)
static

Definition at line 57 of file misc.cpp.

58{
59 return uMsg == WM_CLOSE ? DestroyWindow(hDlg) : FALSE;
60}
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by EmulateDialogReposition().

◆ NtQueryObject()

◆ OpensWithExplorer()

BOOL OpensWithExplorer ( PCWSTR  Path)

Definition at line 164 of file misc.cpp.

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}
LPWSTR WINAPI StrStrIW(LPCWSTR lpszStr, LPCWSTR lpszSearch)
Definition: string.c:380
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1701
HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
Definition: assoc.c:441
void WINAPI PathRemoveArgsW(LPWSTR lpszPath)
Definition: path.c:779
@ ASSOCF_INIT_IGNOREUNKNOWN
Definition: shlwapi.h:870
@ ASSOCF_NOTRUNCATE
Definition: shlwapi.h:865
@ ASSOCSTR_COMMAND
Definition: shlwapi.h:886
const uint16_t * PCWSTR
Definition: typedefs.h:57

Referenced by CDownloadManager::PerformDownloadAndInstall().

◆ ReadAt()

static BOOL ReadAt ( HANDLE  Handle,
UINT  Offset,
LPVOID  Buffer,
UINT  Size 
)
static

Definition at line 626 of file misc.cpp.

627{
628 OVERLAPPED ol = {};
629 ol.Offset = Offset;
630 DWORD cb;
631 return ReadFile(Handle, Buffer, Size, &cb, &ol) && cb == Size;
632}
ULONG Handle
Definition: gdb_input.c:15
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
DWORD Offset
Definition: minwinbase.h:225
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539

Referenced by GuessInstallerType().

◆ RegKeyHasValues()

HRESULT RegKeyHasValues ( HKEY  hKey,
LPCWSTR  Path,
REGSAM  wowsam 
)

Definition at line 484 of file misc.cpp.

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}
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
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
long LONG
Definition: pedump.c:60
Definition: name.c:39
#define S_FALSE
Definition: winerror.h:3451

Referenced by UninstallThread().

◆ SearchPatternMatch()

BOOL SearchPatternMatch ( LPCWSTR  szHaystack,
LPCWSTR  szNeedle 
)

Definition at line 542 of file misc.cpp.

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}

Referenced by CMainWindow::AddApplicationsToView(), HandleFindCommand(), and SearchForAppWithDisplayName().

◆ ShowPopupMenuEx()

VOID ShowPopupMenuEx ( HWND  hwnd,
HWND  hwndOwner,
UINT  MenuID,
UINT  DefaultItem,
POINT Point 
)

Definition at line 82 of file misc.cpp.

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}
#define pt(x, y)
Definition: drawing.c:79
HINSTANCE hInst
Definition: dxdiag.c:13
#define ZeroMemory
Definition: minwinbase.h:31
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:3064
#define MIIM_STATE
Definition: winuser.h:732
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MFS_GRAYED
Definition: winuser.h:762
BOOL WINAPI DestroyMenu(_In_ HMENU)
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
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)
HMENU WINAPI GetMenu(_In_ HWND)

Referenced by CAppInfoDisplay::OnLink(), and CApplicationView::ProcessWindowMessage().

◆ SplitFileAndDirectory()

CStringW SplitFileAndDirectory ( LPCWSTR  FullPath,
CStringW pDir 
)

Definition at line 571 of file misc.cpp.

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}
unsigned int dir
Definition: maze.c:112
Definition: fci.c:127

Referenced by CreateMainShortcut(), ExtractFilesFromCab(), ExtractFilesFromZip(), InstallFiles(), and UninstallThread().

◆ StartProcess()

BOOL StartProcess ( const CStringW Path,
BOOL  Wait 
)

Definition at line 178 of file misc.cpp.

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}
#define msg(x)
Definition: auth_time.c:54
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
#define INFINITE
Definition: serial.h:102
HWND hMainWnd
Definition: magnifier.c:32
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
static SYSTEM_INFO si
Definition: virtual.c:39
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
#define STARTF_USESHOWWINDOW
Definition: winbase.h:468
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define WAIT_FAILED
Definition: winbase.h:390
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define QS_ALLEVENTS
Definition: winuser.h:913
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1207
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define SW_SHOW
Definition: winuser.h:786

Referenced by CInstalledApplicationInfo::UninstallApplication().

◆ UnixTimeToFileTime()

void UnixTimeToFileTime ( DWORD  dwUnixTime,
LPFILETIME  pFileTime 
)

Definition at line 447 of file misc.cpp.

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}
w ll
Definition: byte_order.h:167
#define DWORD
Definition: nt_native.h:44
#define Int32x32To64(a, b)
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
int64_t LONGLONG
Definition: typedefs.h:68

Referenced by CInstalledApplicationInfo::RetrieveInstallDate().

◆ WriteLogMessage()

BOOL WriteLogMessage ( WORD  wType,
DWORD  dwEventID,
LPCWSTR  lpMsg 
)

Definition at line 321 of file misc.cpp.

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}
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

Referenced by CDownloadManager::PerformDownloadAndInstall(), and CInstalledApplicationInfo::UninstallApplication().

Variable Documentation

◆ hLog