From bcc1bca3d09dd1db020cd90fef6b646499111d92 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Sun, 14 Nov 2021 21:03:39 +0200 Subject: [PATCH] Fixed automatic updates; improved setup --- ExplorerPatcher/updates.c | 18 +++++++++++------- ep_setup/ep_setup.c | 11 +++++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ExplorerPatcher/updates.c b/ExplorerPatcher/updates.c index 512909d..07bc8a3 100644 --- a/ExplorerPatcher/updates.c +++ b/ExplorerPatcher/updates.c @@ -71,11 +71,11 @@ BOOL IsUpdateAvailableHelper(char* url, char* szCheckAgainst, DWORD dwUpdateTime INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, - INTERNET_FLAG_ASYNC + 0 //INTERNET_FLAG_ASYNC )) { - InternetSetOptionA(hInternet, INTERNET_OPTION_CONNECT_TIMEOUT, &dwUpdateTimeout, sizeof(DWORD)); - if (InternetSetStatusCallbackA(hInternet, IsUpdateAvailableHelperCallback) != INTERNET_INVALID_STATUS_CALLBACK) + //InternetSetOptionA(hInternet, INTERNET_OPTION_CONNECT_TIMEOUT, &dwUpdateTimeout, sizeof(DWORD)); + //if (InternetSetStatusCallbackA(hInternet, IsUpdateAvailableHelperCallback) != INTERNET_INVALID_STATUS_CALLBACK) { HINTERNET hConnect = InternetOpenUrlA( hInternet, @@ -87,16 +87,17 @@ BOOL IsUpdateAvailableHelper(char* url, char* szCheckAgainst, DWORD dwUpdateTime INTERNET_FLAG_RESYNCHRONIZE | INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI | - INTERNET_FLAG_NO_CACHE_WRITE, + INTERNET_FLAG_NO_CACHE_WRITE | + INTERNET_FLAG_DONT_CACHE, ¶ms ); - if (!hConnect && GetLastError() == ERROR_IO_PENDING) + /*if (!hConnect && GetLastError() == ERROR_IO_PENDING) { if (WaitForSingleObject(params.hEvent, dwUpdateTimeout) == WAIT_OBJECT_0) { hConnect = params.hInternet; } - } + }*/ if (hConnect) { if (szCheckAgainst) @@ -122,6 +123,9 @@ BOOL IsUpdateAvailableHelper(char* url, char* szCheckAgainst, DWORD dwUpdateTime } else { +#ifdef UPDATES_VERBOSE_OUTPUT + printf("[Updates] Failed. Read %d bytes.\n"); +#endif if (lpFail) *lpFail = TRUE; } } @@ -129,7 +133,7 @@ BOOL IsUpdateAvailableHelper(char* url, char* szCheckAgainst, DWORD dwUpdateTime { WCHAR wszPath[MAX_PATH]; ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR)); - SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath); + SHGetFolderPathW(NULL, SPECIAL_FOLDER_LEGACY, NULL, SHGFP_TYPE_CURRENT, wszPath); wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH)); BOOL bRet = CreateDirectoryW(wszPath, NULL); if (bRet || (!bRet && GetLastError() == ERROR_ALREADY_EXISTS)) diff --git a/ep_setup/ep_setup.c b/ep_setup/ep_setup.c index 29edfb0..8aa765c 100644 --- a/ep_setup/ep_setup.c +++ b/ep_setup/ep_setup.c @@ -498,11 +498,18 @@ int WINAPI wWinMain( //ZZRestartExplorer(0, 0, 0, 0); } } - if (!bOk && !(argc >= 1 && !_wcsicmp(wargv[0], L"/update_silent"))) + if (!bOk) // && !(argc >= 1 && !_wcsicmp(wargv[0], L"/update_silent")) { MessageBoxW( NULL, - L"An error has occured when attempting to service the product. Please reboot the computer and try again.", + L"An error has occured while servicing this product.\n" + L"Most likely, this is caused by one or more of the backup files still being in use (from" + L"a previous update). Unlocking the files will most likely fix this issue.\n\n" + L"Troubleshooting steps:\n" + L"* Close and reopen the \"Properties\" dialog, if you have it currently open.\n" + L"* Kill and restart all \"explorer.exe\" processes.\n" + L"* If you have registered this as shell extension, restarting the computer will probably fix this.\n" + L"* After everything else, reboot the computer and try again.", _T(PRODUCT_NAME), MB_ICONERROR | MB_OK | MB_DEFBUTTON1 );