Skip to content

Commit

Permalink
Updates: Re-add changes in 80592f6
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrsatrio committed Jul 14, 2024
1 parent 5d0d218 commit 8c16a9a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
21 changes: 16 additions & 5 deletions ExplorerPatcher/updates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -657,7 +664,7 @@ BOOL IsUpdateAvailableHelper(
}
fclose(f);
}
if (bIsUpdateAvailable)
if (bIsUsingEpMake || bIsUpdateAvailable)
{
bIsUpdateAvailable = FALSE;
#ifdef UPDATES_VERBOSE_OUTPUT
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 0 additions & 12 deletions ep_setup/ep_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

// --------------------------------------------------------------------------------

Expand All @@ -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)
Expand Down Expand Up @@ -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

// --------------------------------------------------------------------------------

Expand Down

0 comments on commit 8c16a9a

Please sign in to comment.