diff --git a/src/net.c b/src/net.c index 38eae5fe..48daea7f 100644 --- a/src/net.c +++ b/src/net.c @@ -232,13 +232,15 @@ static HINTERNET GetInternetSession(BOOL bRetry) int i; char agent[64]; BOOL r; - DWORD dwFlags; + DWORD dwFlags, dwTimeout = NET_SESSION_TIMEOUT; HINTERNET hSession = NULL; PF_TYPE_DECL(WINAPI, BOOL, InternetGetConnectedState, (LPDWORD, DWORD)); PF_TYPE_DECL(WINAPI, HINTERNET, InternetOpenA, (LPCSTR, DWORD, LPCSTR, LPCSTR, DWORD)); + PF_TYPE_DECL(WINAPI, BOOL, InternetSetOptionA, (HINTERNET, DWORD, LPVOID, DWORD)); PF_INIT_OR_OUT(InternetGetConnectedState, WinInet); PF_INIT_OR_OUT(InternetOpenA, WinInet); + PF_INIT_OR_OUT(InternetSetOptionA, WinInet); for (i = 0; i <= WRITE_RETRIES; i++) { r = pfInternetGetConnectedState(&dwFlags, 0); @@ -256,6 +258,10 @@ static HINTERNET GetInternetSession(BOOL bRetry) rufus_version[0], rufus_version[1], rufus_version[2], nWindowsVersion >> 4, nWindowsVersion & 0x0F, is_x64() ? "; WOW64" : ""); hSession = pfInternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); + // Set the timeouts + pfInternetSetOptionA(hSession, INTERNET_OPTION_CONNECT_TIMEOUT, (LPVOID)&dwTimeout, sizeof(dwTimeout)); + pfInternetSetOptionA(hSession, INTERNET_OPTION_SEND_TIMEOUT, (LPVOID)&dwTimeout, sizeof(dwTimeout)); + pfInternetSetOptionA(hSession, INTERNET_OPTION_RECEIVE_TIMEOUT, (LPVOID)&dwTimeout, sizeof(dwTimeout)); out: return hSession; @@ -896,7 +902,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) uprintf("Could not create pipe '%s': %s", pipe, WindowsErrorString); } - static_sprintf(cmdline, "%s -NonInteractive -NoProfile –ExecutionPolicy Bypass " + static_sprintf(cmdline, "%s -NonInteractive -Sta -NoProfile –ExecutionPolicy Bypass " "-File %s -PipeName %s -LocData \"%s\" -Icon %s -AppTitle \"%s\"", powershell_path, script_path, &pipe[9], locale_str, icon_path, lmprintf(MSG_143)); // Signal our Windows alerts hook that it should close the IE cookie prompts from Fido @@ -1110,7 +1116,7 @@ const char* ResolveRedirect(const char* url) hRequest = pfHttpOpenRequestA(hConnection, "GET", UrlParts.lpszUrlPath, NULL, NULL, accept_types, INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS | INTERNET_FLAG_NO_AUTO_REDIRECT | - INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_HYPERLINK | + INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI | INTERNET_FLAG_HYPERLINK | ((UrlParts.nScheme == INTERNET_SCHEME_HTTPS) ? INTERNET_FLAG_SECURE : 0), (DWORD_PTR)NULL); if (hRequest == NULL) goto out; @@ -1132,5 +1138,12 @@ const char* ResolveRedirect(const char* url) } out: + if (hRequest) + pfInternetCloseHandle(hRequest); + if (hConnection) + pfInternetCloseHandle(hConnection); + if (hSession) + pfInternetCloseHandle(hSession); + return r ? ret_url : url; } diff --git a/src/rufus.c b/src/rufus.c index 1e0cf62b..af574497 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -3153,7 +3153,7 @@ relaunch: // Set the hook to automatically close Windows' "You need to format the disk in drive..." prompt if (!SetAlertPromptHook()) - uprintf("Warning: Could not set 'Format Disk' prompt auto-close"); + uprintf("Warning: Could not set alert prompts hook"); ShowWindow(hDlg, SW_SHOWNORMAL); UpdateWindow(hDlg); diff --git a/src/rufus.h b/src/rufus.h index 88348b0f..e73ba962 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -78,6 +78,7 @@ #define WRITE_RETRIES 4 #define WRITE_TIMEOUT 5000 // How long we should wait between write retries (in ms) #define SEARCH_PROCESS_TIMEOUT 10000 // How long we should search for conflicting processes before giving up (in ms) +#define NET_SESSION_TIMEOUT 3500 // How long we should wait to connect, send or receive internet data #define MARQUEE_TIMER_REFRESH 10 // Time between progress bar marquee refreshes, in ms #define FS_DEFAULT FS_FAT32 #define SINGLE_CLUSTERSIZE_DEFAULT 0x00000100 diff --git a/src/rufus.rc b/src/rufus.rc index 1f29be16..d48dd5c6 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.5.1452" +CAPTION "Rufus 3.5.1453" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -394,8 +394,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,5,1452,0 - PRODUCTVERSION 3,5,1452,0 + FILEVERSION 3,5,1453,0 + PRODUCTVERSION 3,5,1453,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -413,13 +413,13 @@ BEGIN VALUE "Comments", "https://akeo.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.5.1452" + VALUE "FileVersion", "3.5.1453" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus-3.5.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.5.1452" + VALUE "ProductVersion", "3.5.1453" END END BLOCK "VarFileInfo"