mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[net] fix session variables not being cleared in ResolveRedirect()
* Also set default network timeouts to 3500ms * Also add '-Sta' option when running Fido so that at at least the UI can display on Windows 7
This commit is contained in:
		
							parent
							
								
									db68bcd7f9
								
							
						
					
					
						commit
						9d1a2bc25e
					
				
					 4 changed files with 23 additions and 9 deletions
				
			
		
							
								
								
									
										19
									
								
								src/net.c
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								src/net.c
									
										
									
									
									
								
							|  | @ -232,13 +232,15 @@ static HINTERNET GetInternetSession(BOOL bRetry) | ||||||
| 	int i; | 	int i; | ||||||
| 	char agent[64]; | 	char agent[64]; | ||||||
| 	BOOL r; | 	BOOL r; | ||||||
| 	DWORD dwFlags; | 	DWORD dwFlags, dwTimeout = NET_SESSION_TIMEOUT; | ||||||
| 	HINTERNET hSession = NULL; | 	HINTERNET hSession = NULL; | ||||||
| 
 | 
 | ||||||
| 	PF_TYPE_DECL(WINAPI, BOOL, InternetGetConnectedState, (LPDWORD, DWORD)); | 	PF_TYPE_DECL(WINAPI, BOOL, InternetGetConnectedState, (LPDWORD, DWORD)); | ||||||
| 	PF_TYPE_DECL(WINAPI, HINTERNET, InternetOpenA, (LPCSTR, DWORD, LPCSTR, LPCSTR, 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(InternetGetConnectedState, WinInet); | ||||||
| 	PF_INIT_OR_OUT(InternetOpenA, WinInet); | 	PF_INIT_OR_OUT(InternetOpenA, WinInet); | ||||||
|  | 	PF_INIT_OR_OUT(InternetSetOptionA, WinInet); | ||||||
| 
 | 
 | ||||||
| 	for (i = 0; i <= WRITE_RETRIES; i++) { | 	for (i = 0; i <= WRITE_RETRIES; i++) { | ||||||
| 		r = pfInternetGetConnectedState(&dwFlags, 0); | 		r = pfInternetGetConnectedState(&dwFlags, 0); | ||||||
|  | @ -256,6 +258,10 @@ static HINTERNET GetInternetSession(BOOL bRetry) | ||||||
| 		rufus_version[0], rufus_version[1], rufus_version[2], | 		rufus_version[0], rufus_version[1], rufus_version[2], | ||||||
| 		nWindowsVersion >> 4, nWindowsVersion & 0x0F, is_x64() ? "; WOW64" : ""); | 		nWindowsVersion >> 4, nWindowsVersion & 0x0F, is_x64() ? "; WOW64" : ""); | ||||||
| 	hSession = pfInternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); | 	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: | out: | ||||||
| 	return hSession; | 	return hSession; | ||||||
|  | @ -896,7 +902,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) | ||||||
| 		uprintf("Could not create pipe '%s': %s", pipe, WindowsErrorString); | 		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\"", | 		"-File %s -PipeName %s -LocData \"%s\" -Icon %s -AppTitle \"%s\"", | ||||||
| 		powershell_path, script_path, &pipe[9], locale_str, icon_path, lmprintf(MSG_143)); | 		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
 | 	// 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, | 	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_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); | 		((UrlParts.nScheme == INTERNET_SCHEME_HTTPS) ? INTERNET_FLAG_SECURE : 0), (DWORD_PTR)NULL); | ||||||
| 	if (hRequest == NULL) | 	if (hRequest == NULL) | ||||||
| 		goto out; | 		goto out; | ||||||
|  | @ -1132,5 +1138,12 @@ const char* ResolveRedirect(const char* url) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| out: | out: | ||||||
|  | 	if (hRequest) | ||||||
|  | 		pfInternetCloseHandle(hRequest); | ||||||
|  | 	if (hConnection) | ||||||
|  | 		pfInternetCloseHandle(hConnection); | ||||||
|  | 	if (hSession) | ||||||
|  | 		pfInternetCloseHandle(hSession); | ||||||
|  | 
 | ||||||
| 	return r ? ret_url : url; | 	return r ? ret_url : url; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -3153,7 +3153,7 @@ relaunch: | ||||||
| 
 | 
 | ||||||
| 	// Set the hook to automatically close Windows' "You need to format the disk in drive..." prompt
 | 	// Set the hook to automatically close Windows' "You need to format the disk in drive..." prompt
 | ||||||
| 	if (!SetAlertPromptHook()) | 	if (!SetAlertPromptHook()) | ||||||
| 		uprintf("Warning: Could not set 'Format Disk' prompt auto-close"); | 		uprintf("Warning: Could not set alert prompts hook"); | ||||||
| 
 | 
 | ||||||
| 	ShowWindow(hDlg, SW_SHOWNORMAL); | 	ShowWindow(hDlg, SW_SHOWNORMAL); | ||||||
| 	UpdateWindow(hDlg); | 	UpdateWindow(hDlg); | ||||||
|  |  | ||||||
|  | @ -78,6 +78,7 @@ | ||||||
| #define WRITE_RETRIES               4 | #define WRITE_RETRIES               4 | ||||||
| #define WRITE_TIMEOUT               5000		// How long we should wait between write retries (in ms)
 | #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 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 MARQUEE_TIMER_REFRESH       10			// Time between progress bar marquee refreshes, in ms
 | ||||||
| #define FS_DEFAULT                  FS_FAT32 | #define FS_DEFAULT                  FS_FAT32 | ||||||
| #define SINGLE_CLUSTERSIZE_DEFAULT  0x00000100 | #define SINGLE_CLUSTERSIZE_DEFAULT  0x00000100 | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 232, 326 | IDD_DIALOG DIALOGEX 12, 12, 232, 326 | ||||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||||
| EXSTYLE WS_EX_ACCEPTFILES | EXSTYLE WS_EX_ACCEPTFILES | ||||||
| CAPTION "Rufus 3.5.1452" | CAPTION "Rufus 3.5.1453" | ||||||
| FONT 9, "Segoe UI Symbol", 400, 0, 0x0 | FONT 9, "Segoe UI Symbol", 400, 0, 0x0 | ||||||
| BEGIN | BEGIN | ||||||
|     LTEXT           "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP |     LTEXT           "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP | ||||||
|  | @ -394,8 +394,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 3,5,1452,0 |  FILEVERSION 3,5,1453,0 | ||||||
|  PRODUCTVERSION 3,5,1452,0 |  PRODUCTVERSION 3,5,1453,0 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -413,13 +413,13 @@ BEGIN | ||||||
|             VALUE "Comments", "https://akeo.ie" |             VALUE "Comments", "https://akeo.ie" | ||||||
|             VALUE "CompanyName", "Akeo Consulting" |             VALUE "CompanyName", "Akeo Consulting" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "3.5.1452" |             VALUE "FileVersion", "3.5.1453" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)" | ||||||
|             VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" |             VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" | ||||||
|             VALUE "OriginalFilename", "rufus-3.5.exe" |             VALUE "OriginalFilename", "rufus-3.5.exe" | ||||||
|             VALUE "ProductName", "Rufus" |             VALUE "ProductName", "Rufus" | ||||||
|             VALUE "ProductVersion", "3.5.1452" |             VALUE "ProductVersion", "3.5.1453" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue