mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[net] add automated update support for ARM/ARM64
This commit is contained in:
		
							parent
							
								
									e3fb899f12
								
							
						
					
					
						commit
						6109d91c38
					
				
					 6 changed files with 49 additions and 13 deletions
				
			
		|  | @ -1,7 +1,7 @@ | |||
| /*
 | ||||
|  * Rufus: The Reliable USB Formatting Utility | ||||
|  * Networking functionality (web file download, check for update, etc.) | ||||
|  * Copyright © 2012-2016 Pete Batard <pete@akeo.ie> | ||||
|  * Copyright © 2012-2018 Pete Batard <pete@akeo.ie> | ||||
|  * | ||||
|  * This program is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License as published by | ||||
|  | @ -531,7 +531,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param) | |||
| 	int status = 0; | ||||
| 	const char* server_url = RUFUS_URL "/"; | ||||
| 	int i, j, k, max_channel, verbose = 0, verpos[4]; | ||||
| 	static const char* archname[] = {"win_x86", "win_x64"}; | ||||
| 	static const char* archname[] = {"win_x86", "win_x64", "win_arm", "win_arm64", "win_none"}; | ||||
| 	static const char* channel[] = {"release", "beta", "test"};		// release channel
 | ||||
| 	const char* accept_types[] = {"*/*\0", NULL}; | ||||
| 	DWORD dwFlags, dwSize, dwDownloaded, dwTotalSize, dwStatus; | ||||
|  | @ -636,11 +636,11 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param) | |||
| 		uprintf("Checking %s channel...", channel[k]); | ||||
| 		// At this stage we can query the server for various update version files.
 | ||||
| 		// We first try to lookup for "<appname>_<os_arch>_<os_version_major>_<os_version_minor>.ver"
 | ||||
| 		// and then remove each each of the <os_> components until we find our match. For instance, we may first
 | ||||
| 		// and then remove each of the <os_> components until we find our match. For instance, we may first
 | ||||
| 		// look for rufus_win_x64_6.2.ver (Win8 x64) but only get a match for rufus_win_x64_6.ver (Vista x64 or later)
 | ||||
| 		// This allows sunsetting OS versions (eg XP) or providing different downloads for different archs/groups.
 | ||||
| 		static_sprintf(urlpath, "%s%s%s_%s_%lu.%lu.ver", APPLICATION_NAME, (k==0)?"":"_", | ||||
| 			(k==0)?"":channel[k], archname[is_x64()?1:0], os_version.dwMajorVersion, os_version.dwMinorVersion); | ||||
| 			(k==0)?"":channel[k], archname[GetCpuArch()], os_version.dwMajorVersion, os_version.dwMinorVersion); | ||||
| 		vuprintf("Base update check: %s", urlpath); | ||||
| 		for (i=0, j=(int)safe_strlen(urlpath)-5; (j>0)&&(i<ARRAYSIZE(verpos)); j--) { | ||||
| 			if ((urlpath[j] == '.') || (urlpath[j] == '_')) { | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| /*
 | ||||
|  * Rufus: The Reliable USB Formatting Utility | ||||
|  * Elementary Unicode compliant find/replace parser | ||||
|  * Copyright © 2012-2017 Pete Batard <pete@akeo.ie> | ||||
|  * Copyright © 2012-2018 Pete Batard <pete@akeo.ie> | ||||
|  * | ||||
|  * This program is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License as published by | ||||
|  | @ -903,6 +903,8 @@ void parse_update(char* buf, size_t len) | |||
| 	char *data = NULL, *token; | ||||
| 	char allowed_rtf_chars[] = "abcdefghijklmnopqrstuvwxyz|~-_:*'"; | ||||
| 	char allowed_std_chars[] = "\r\n ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"$%^&+=<>(){}[].,;#@/?"; | ||||
| 	char download_url_name[24]; | ||||
| 	char *arch_names[CPU_ARCH_MAX] = { "x86", "x64", "arm", "arm64", "none" }; | ||||
| 
 | ||||
| 	// strchr includes the NUL terminator in the search, so take care of backslash before NUL
 | ||||
| 	if ((buf == NULL) || (len < 2) || (len > 65536) || (buf[len-1] != 0) || (buf[len-2] == '\\')) | ||||
|  | @ -939,7 +941,10 @@ void parse_update(char* buf, size_t len) | |||
| 		} | ||||
| 		safe_free(data); | ||||
| 	} | ||||
| 	update.download_url = get_sanitized_token_data_buffer("download_url", 1, buf, len); | ||||
| 	static_sprintf(download_url_name, "download_url_%s", arch_names[GetCpuArch()]); | ||||
| 	update.download_url = get_sanitized_token_data_buffer(download_url_name, 1, buf, len); | ||||
| 	if (update.download_url == NULL) | ||||
| 		update.download_url = get_sanitized_token_data_buffer("download_url", 1, buf, len); | ||||
| 	update.release_notes = get_sanitized_token_data_buffer("release_notes", 1, buf, len); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1876,7 +1876,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 	case WM_COMMAND: | ||||
| #ifdef RUFUS_TEST | ||||
| 		if (LOWORD(wParam) == IDC_TEST) { | ||||
| 			DownloadSignedFile(FILES_URL "/gendb.sh", "C:\\Downloads\\gendb.sh", hProgress, TRUE); | ||||
| 			uprintf("CPU ARCH: %d", GetCpuArch()); | ||||
| 			break; | ||||
| 		} | ||||
| #endif | ||||
|  |  | |||
							
								
								
									
										13
									
								
								src/rufus.h
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								src/rufus.h
									
										
									
									
									
								
							|  | @ -82,7 +82,11 @@ | |||
| #define UBUFFER_SIZE                2048 | ||||
| #define RSA_SIGNATURE_SIZE          256 | ||||
| #define CBN_SELCHANGE_INTERNAL      (CBN_SELCHANGE + 256) | ||||
| #if defined(RUFUS_TEST) | ||||
| #define RUFUS_URL                   "http://pi3"
 | ||||
| #else | ||||
| #define RUFUS_URL                   "https://rufus.ie"
 | ||||
| #endif | ||||
| #define DOWNLOAD_URL                RUFUS_URL "/downloads" | ||||
| #define FILES_URL                   RUFUS_URL "/files" | ||||
| #define SEVENZIP_URL                "https://www.7-zip.org"
 | ||||
|  | @ -397,6 +401,14 @@ enum WindowsVersion { | |||
| 	WINDOWS_MAX | ||||
| }; | ||||
| 
 | ||||
| enum CpuArch { | ||||
| 	CPU_ARCH_X86_32 = 0, | ||||
| 	CPU_ARCH_X86_64, | ||||
| 	CPU_ARCH_ARM_32, | ||||
| 	CPU_ARCH_ARM_64, | ||||
| 	CPU_ARCH_UNDEFINED, | ||||
| 	CPU_ARCH_MAX | ||||
| }; | ||||
| 
 | ||||
| /*
 | ||||
|  * Globals | ||||
|  | @ -430,6 +442,7 @@ extern char* image_path; | |||
| extern uint8_t popcnt8(uint8_t val); | ||||
| extern void GetWindowsVersion(void); | ||||
| extern BOOL is_x64(void); | ||||
| extern BOOL GetCpuArch(void); | ||||
| extern const char *WindowsErrorString(void); | ||||
| extern void DumpBufferHex(void *buf, size_t size); | ||||
| extern void PrintStatusInfo(BOOL info, BOOL debug, unsigned int duration, int msg_id, ...); | ||||
|  |  | |||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								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.4.1411" | ||||
| CAPTION "Rufus 3.4.1412" | ||||
| FONT 9, "Segoe UI Symbol", 400, 0, 0x0 | ||||
| BEGIN | ||||
|     LTEXT           "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP | ||||
|  | @ -392,8 +392,8 @@ END | |||
| // | ||||
| 
 | ||||
| VS_VERSION_INFO VERSIONINFO | ||||
|  FILEVERSION 3,4,1411,0 | ||||
|  PRODUCTVERSION 3,4,1411,0 | ||||
|  FILEVERSION 3,4,1412,0 | ||||
|  PRODUCTVERSION 3,4,1412,0 | ||||
|  FILEFLAGSMASK 0x3fL | ||||
| #ifdef _DEBUG | ||||
|  FILEFLAGS 0x1L | ||||
|  | @ -411,13 +411,13 @@ BEGIN | |||
|             VALUE "Comments", "https://akeo.ie" | ||||
|             VALUE "CompanyName", "Akeo Consulting" | ||||
|             VALUE "FileDescription", "Rufus" | ||||
|             VALUE "FileVersion", "3.4.1411" | ||||
|             VALUE "FileVersion", "3.4.1412" | ||||
|             VALUE "InternalName", "Rufus" | ||||
|             VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" | ||||
|             VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" | ||||
|             VALUE "OriginalFilename", "rufus-3.4.exe" | ||||
|             VALUE "ProductName", "Rufus" | ||||
|             VALUE "ProductVersion", "3.4.1411" | ||||
|             VALUE "ProductVersion", "3.4.1412" | ||||
|         END | ||||
|     END | ||||
|     BLOCK "VarFileInfo" | ||||
|  |  | |||
							
								
								
									
										20
									
								
								src/stdfn.c
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								src/stdfn.c
									
										
									
									
									
								
							|  | @ -1,7 +1,7 @@ | |||
| /*
 | ||||
|  * Rufus: The Reliable USB Formatting Utility | ||||
|  * Standard Windows function calls | ||||
|  * Copyright © 2013-2017 Pete Batard <pete@akeo.ie> | ||||
|  * Copyright © 2013-2018 Pete Batard <pete@akeo.ie> | ||||
|  * | ||||
|  * This program is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License as published by | ||||
|  | @ -230,6 +230,24 @@ BOOL is_x64(void) | |||
| 	return ret; | ||||
| } | ||||
| 
 | ||||
| int GetCpuArch(void) | ||||
| { | ||||
| 	SYSTEM_INFO info = { 0 }; | ||||
| 	GetNativeSystemInfo(&info); | ||||
| 	switch (info.wProcessorArchitecture) { | ||||
| 	case PROCESSOR_ARCHITECTURE_AMD64: | ||||
| 		return CPU_ARCH_X86_64; | ||||
| 	case PROCESSOR_ARCHITECTURE_INTEL: | ||||
| 		return CPU_ARCH_X86_64; | ||||
| 	case PROCESSOR_ARCHITECTURE_ARM64: | ||||
| 		return CPU_ARCH_ARM_64; | ||||
| 	case PROCESSOR_ARCHITECTURE_ARM: | ||||
| 		return CPU_ARCH_ARM_32; | ||||
| 	default: | ||||
| 		return CPU_ARCH_UNDEFINED; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // From smartmontools os_win32.cpp
 | ||||
| void GetWindowsVersion(void) | ||||
| { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue