From 8c16a9a0d932240cf554a6b591aac5df488bf71e Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 14 Jul 2024 19:02:58 +0700 Subject: [PATCH] Updates: Re-add changes in 80592f6 --- ExplorerPatcher-L10N | 2 +- ExplorerPatcher/updates.cpp | 21 ++++++++++++++++----- ep_setup/ep_setup.c | 12 ------------ 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/ExplorerPatcher-L10N b/ExplorerPatcher-L10N index 441d665..b099ad6 160000 --- a/ExplorerPatcher-L10N +++ b/ExplorerPatcher-L10N @@ -1 +1 @@ -Subproject commit 441d6658a540fdbf44dfaad5ebe34114e5736d11 +Subproject commit b099ad61561b9463eb69ce86c4d8d2977bd16903 diff --git a/ExplorerPatcher/updates.cpp b/ExplorerPatcher/updates.cpp index 4c10328..40bf8e7 100644 --- a/ExplorerPatcher/updates.cpp +++ b/ExplorerPatcher/updates.cpp @@ -603,8 +603,15 @@ BOOL IsUpdateAvailableHelper( BOOL bRet = DeleteFileW(wszPath); if (bRet || (!bRet && GetLastError() == ERROR_FILE_NOT_FOUND)) { + DWORD bIsUsingEpMake = 0, dwSize = sizeof(DWORD); + RegGetValueW(HKEY_CURRENT_USER, TEXT(REGPATH), L"UpdateUseLocal", RRF_RT_DWORD, nullptr, &bIsUsingEpMake, &dwSize); + if (bIsUsingEpMake) { + GetSystemDirectoryW(wszPath, MAX_PATH); + wcscat_s(wszPath, MAX_PATH, L"\\WindowsPowerShell\\v1.0\\powershell.exe"); + } + FILE* f = nullptr; - if (!_wfopen_s( + if (!bIsUsingEpMake && !_wfopen_s( &f, wszPath, L"wb" @@ -657,7 +664,7 @@ BOOL IsUpdateAvailableHelper( } fclose(f); } - if (bIsUpdateAvailable) + if (bIsUsingEpMake || bIsUpdateAvailable) { bIsUpdateAvailable = FALSE; #ifdef UPDATES_VERBOSE_OUTPUT @@ -749,9 +756,9 @@ BOOL IsUpdateAvailableHelper( ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; ShExecInfo.hwnd = nullptr; - ShExecInfo.lpVerb = L"runas"; + ShExecInfo.lpVerb = bIsUsingEpMake ? L"open" : L"runas"; ShExecInfo.lpFile = wszPath; - ShExecInfo.lpParameters = L"/update_silent"; + ShExecInfo.lpParameters = bIsUsingEpMake ? L"iex (irm 'https://raw.githubusercontent.com/valinet/ep_make/master/ep_make_safe.ps1')" : L"/update_silent"; ShExecInfo.lpDirectory = nullptr; ShExecInfo.nShow = SW_SHOW; ShExecInfo.hInstApp = nullptr; @@ -1176,7 +1183,11 @@ BOOL InstallUpdatesIfAvailable( wprintf(L"[Updates] Path to module: %s\n", dllName); CHAR hash[100] = {}; - ComputeFileHash2(hModule, dllName, hash, 100); + GetHardcodedHash(dllName, hash, 100); + if (!strcmp(hash, "This")) + ComputeFileHash2(hModule, dllName, hash, 100); + else + printf("[Updates] Using hardcoded hash.\n"); BOOL bFail = FALSE, bReturnValue = FALSE; dwLeftMost = 0; dwSecondLeft = 0; dwSecondRight = 0; dwRightMost = 0; diff --git a/ep_setup/ep_setup.c b/ep_setup/ep_setup.c index 827bb43..695a901 100644 --- a/ep_setup/ep_setup.c +++ b/ep_setup/ep_setup.c @@ -902,11 +902,7 @@ int WINAPI wWinMain( // C:\Windows // + dxgi.dll if (bOk) GetWindowsDirectoryW(wszPath, MAX_PATH); -#if defined(_M_X64) if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, L"dxgi.dll"); -#elif defined(_M_ARM64) - if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, L"dxgi.dll"); -#endif // -------------------------------------------------------------------------------- @@ -921,11 +917,7 @@ int WINAPI wWinMain( // - pris2\Windows.UI.ShellCommon.en-US.pri if (bOk) GetWindowsDirectoryW(wszPath, MAX_PATH); if (bOk) wcscat_s(wszPath, MAX_PATH, L"\\SystemApps\\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy"); -#if defined(_M_X64) if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, L"dxgi.dll"); -#elif defined(_M_ARM64) - if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, L"dxgi.dll"); -#endif if (bOk) bOk = InstallResource(bInstall && IsWindows11(), hInstance, IDR_EP_STARTMENU, wszPath, L"wincorlib.dll"); if (bOk) bOk = DeleteResource(wszPath, L"wincorlib_orig.dll"); if (bOk && IsWindows11() && bInstall) @@ -980,11 +972,7 @@ int WINAPI wWinMain( // + dxgi.dll if (bOk) GetWindowsDirectoryW(wszPath, MAX_PATH); if (bOk) wcscat_s(wszPath, MAX_PATH, L"\\SystemApps\\ShellExperienceHost_cw5n1h2txyewy"); -#if defined(_M_X64) if (bOk && IsWindows11()) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, L"dxgi.dll"); -#elif defined(_M_ARM64) - if (bOk && IsWindows11()) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, L"dxgi.dll"); -#endif // --------------------------------------------------------------------------------