1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[misc] revert to using the OS arch rather than app arch for the update download

* This means that someone running Rufus x64 or ARM64 should be
  proposed Rufus ARM64 rather than Rufus x64 as an upgrade.
* Also switch the BETA channel from x86 to x64.
* Also remove the _chdirU(app_dir) when using -i in commandline.
This commit is contained in:
Pete Batard 2023-04-24 20:50:53 +01:00
parent a354178239
commit 1e51385bed
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
7 changed files with 22 additions and 39 deletions

View file

@ -52,7 +52,7 @@ HANDLE update_check_thread = NULL;
extern loc_cmd* selected_locale; extern loc_cmd* selected_locale;
extern HANDLE dialog_handle; extern HANDLE dialog_handle;
extern BOOL is_x86_32; extern BOOL is_x86_64;
static DWORD error_code, fido_len = 0; static DWORD error_code, fido_len = 0;
static BOOL force_update_check = FALSE; static BOOL force_update_check = FALSE;
static const char* request_headers = "Accept-Encoding: gzip, deflate"; static const char* request_headers = "Accept-Encoding: gzip, deflate";
@ -669,7 +669,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
// It would of course be a lot nicer to use a timer and wake the thread, but my // It would of course be a lot nicer to use a timer and wake the thread, but my
// development time is limited and this is FASTER to implement. // development time is limited and this is FASTER to implement.
do { do {
for (i=0; (i<30) && (!force_update_check); i++) for (i = 0; ( i < 30) && (!force_update_check); i++)
Sleep(500); Sleep(500);
} while ((!force_update_check) && ((op_in_progress || (dialog_showing > 0)))); } while ((!force_update_check) && ((op_in_progress || (dialog_showing > 0))));
if (!force_update_check) { if (!force_update_check) {
@ -686,7 +686,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
GetSystemTime(&LocalTime); GetSystemTime(&LocalTime);
if (!SystemTimeToFileTime(&LocalTime, &FileTime)) if (!SystemTimeToFileTime(&LocalTime, &FileTime))
goto out; goto out;
local_time = ((((int64_t)FileTime.dwHighDateTime)<<32) + FileTime.dwLowDateTime) / 10000000; local_time = ((((int64_t)FileTime.dwHighDateTime) << 32) + FileTime.dwLowDateTime) / 10000000;
vvuprintf("Local time: %" PRId64, local_time); vvuprintf("Local time: %" PRId64, local_time);
if (local_time < reg_time + update_interval) { if (local_time < reg_time + update_interval) {
vuprintf("Next update check in %" PRId64 " seconds.", reg_time + update_interval - local_time); vuprintf("Next update check in %" PRId64 " seconds.", reg_time + update_interval - local_time);
@ -714,8 +714,8 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
goto out; goto out;
status++; // 2 status++; // 2
// BETAs are only made available for x86_32 // BETAs are only made available when the application arch is x86_64
if (is_x86_32) if (is_x86_64)
releases_only = !ReadSettingBool(SETTING_INCLUDE_BETAS); releases_only = !ReadSettingBool(SETTING_INCLUDE_BETAS);
// Test releases get their own distribution channel (and also force beta checks) // Test releases get their own distribution channel (and also force beta checks)
@ -735,8 +735,9 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
// and then remove 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) // 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. // This allows sunsetting OS versions (eg XP) or providing different downloads for different archs/groups.
// Note that for BETAs, we only catter for x64 regardless of the OS arch.
static_sprintf(urlpath, "%s%s%s_win_%s_%lu.%lu.ver", APPLICATION_NAME, (k == 0) ? "": "_", static_sprintf(urlpath, "%s%s%s_win_%s_%lu.%lu.ver", APPLICATION_NAME, (k == 0) ? "": "_",
(k == 0) ? "" : channel[k], GetAppArchName(), WindowsVersion.Major, WindowsVersion.Minor); (k == 0) ? "" : channel[k], GetArchName(WindowsVersion.Arch), WindowsVersion.Major, WindowsVersion.Minor);
vuprintf("Base update check: %s", urlpath); vuprintf("Base update check: %s", urlpath);
for (i = 0, j = (int)safe_strlen(urlpath) - 5; (j > 0) && (i < ARRAYSIZE(verpos)); j--) { for (i = 0, j = (int)safe_strlen(urlpath) - 5; (j > 0) && (i < ARRAYSIZE(verpos)); j--) {
if ((urlpath[j] == '.') || (urlpath[j] == '_')) { if ((urlpath[j] == '.') || (urlpath[j] == '_')) {

View file

@ -950,7 +950,7 @@ void parse_update(char* buf, size_t len)
} }
safe_free(data); safe_free(data);
} }
static_sprintf(download_url_name, "download_url_%s", GetAppArchName()); static_sprintf(download_url_name, "download_url_%s", GetArchName(WindowsVersion.Arch));
update.download_url = get_sanitized_token_data_buffer(download_url_name, 1, buf, len); update.download_url = get_sanitized_token_data_buffer(download_url_name, 1, buf, len);
if (update.download_url == NULL) if (update.download_url == NULL)
update.download_url = get_sanitized_token_data_buffer("download_url", 1, buf, len); update.download_url = get_sanitized_token_data_buffer("download_url", 1, buf, len);

View file

@ -121,7 +121,7 @@ DWORD MainThreadId;
HWND hDeviceList, hPartitionScheme, hTargetSystem, hFileSystem, hClusterSize, hLabel, hBootType, hNBPasses, hLog = NULL; HWND hDeviceList, hPartitionScheme, hTargetSystem, hFileSystem, hClusterSize, hLabel, hBootType, hNBPasses, hLog = NULL;
HWND hImageOption, hLogDialog = NULL, hProgress = NULL, hDiskID; HWND hImageOption, hLogDialog = NULL, hProgress = NULL, hDiskID;
HANDLE dialog_handle = NULL; HANDLE dialog_handle = NULL;
BOOL is_x86_32, use_own_c32[NB_OLD_C32] = { FALSE, FALSE }, mbr_selected_by_user = FALSE, lock_drive = TRUE; BOOL is_x86_64, use_own_c32[NB_OLD_C32] = { FALSE, FALSE }, mbr_selected_by_user = FALSE, lock_drive = TRUE;
BOOL op_in_progress = TRUE, right_to_left_mode = FALSE, has_uefi_csm = FALSE, its_a_me_mario = FALSE; BOOL op_in_progress = TRUE, right_to_left_mode = FALSE, has_uefi_csm = FALSE, its_a_me_mario = FALSE;
BOOL enable_HDDs = FALSE, enable_VHDs = TRUE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE; BOOL enable_HDDs = FALSE, enable_VHDs = TRUE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE;
BOOL advanced_mode_device, advanced_mode_format, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32; BOOL advanced_mode_device, advanced_mode_format, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32;
@ -3378,8 +3378,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
uprintf("*** " APPLICATION_NAME " init ***\n"); uprintf("*** " APPLICATION_NAME " init ***\n");
its_a_me_mario = GetUserNameA((char*)(uintptr_t)&u, &size) && (u == 7104878); its_a_me_mario = GetUserNameA((char*)(uintptr_t)&u, &size) && (u == 7104878);
// coverity[pointless_string_compare] // coverity[pointless_string_compare]
// TODO: We'll need to change this when/if we switch to x86_64 default binary is_x86_64 = (strcmp(APPLICATION_ARCH, "x64") == 0);
is_x86_32 = (strcmp(APPLICATION_ARCH, "x86") == 0);
// Retrieve various app & system directories. // Retrieve various app & system directories.
if (GetCurrentDirectoryU(sizeof(app_dir), app_dir) == 0) { if (GetCurrentDirectoryU(sizeof(app_dir), app_dir) == 0) {
@ -3502,7 +3501,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
image_path = calloc(1, MAX_PATH); image_path = calloc(1, MAX_PATH);
if (image_path == NULL) if (image_path == NULL)
break; break;
IGNORE_RETVAL(_chdirU(app_dir));
IGNORE_RETVAL(GetFullPathNameU(optarg, MAX_PATH, image_path, NULL)); IGNORE_RETVAL(GetFullPathNameU(optarg, MAX_PATH, image_path, NULL));
// FILE_ATTRIBUTE_DIRECTORY is set for both dir and access error // FILE_ATTRIBUTE_DIRECTORY is set for both dir and access error
if (GetFileAttributesU(image_path) & FILE_ATTRIBUTE_DIRECTORY) { if (GetFileAttributesU(image_path) & FILE_ATTRIBUTE_DIRECTORY) {

View file

@ -512,11 +512,11 @@ static __inline const char* GetArchName(USHORT uArch)
case IMAGE_FILE_MACHINE_I386: case IMAGE_FILE_MACHINE_I386:
return "x86"; return "x86";
case IMAGE_FILE_MACHINE_ARM64: case IMAGE_FILE_MACHINE_ARM64:
return "Arm64"; return "arm64";
case IMAGE_FILE_MACHINE_ARM: case IMAGE_FILE_MACHINE_ARM:
return "Arm"; return "arm";
default: default:
return "(Unknown Arch)"; return "unknown";
} }
} }
@ -595,7 +595,6 @@ extern char app_data_dir[MAX_PATH], *image_path, *fido_url;
* Shared prototypes * Shared prototypes
*/ */
extern void GetWindowsVersion(windows_version_t* WindowsVersion); extern void GetWindowsVersion(windows_version_t* WindowsVersion);
extern const char* GetAppArchName(void);
extern const char* WindowsErrorString(void); extern const char* WindowsErrorString(void);
extern void DumpBufferHex(void *buf, size_t size); extern void DumpBufferHex(void *buf, size_t size);
extern void PrintStatusInfo(BOOL info, BOOL debug, unsigned int duration, int msg_id, ...); extern void PrintStatusInfo(BOOL info, BOOL debug, unsigned int duration, int msg_id, ...);

View file

@ -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 4.0.2030" CAPTION "Rufus 4.0.2031"
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
@ -392,8 +392,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,0,2030,0 FILEVERSION 4,0,2031,0
PRODUCTVERSION 4,0,2030,0 PRODUCTVERSION 4,0,2031,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie" VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "4.0.2030" VALUE "FileVersion", "4.0.2031"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-4.0.exe" VALUE "OriginalFilename", "rufus-4.0.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "4.0.2030" VALUE "ProductVersion", "4.0.2031"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -204,21 +204,6 @@ uint32_t htab_hash(char* str, htab_table* htab)
return idx; return idx;
} }
const char* GetAppArchName(void) {
#if defined(_M_AMD64)
return "x64";
#elif defined(_M_IX86)
return "x86";
#elif defined(_M_ARM64)
return "arm64";
#elif defined(_M_ARM)
return "arm";
#else
// Keep in line with what we were doing in 3.x
return "none";
#endif
}
static const char* GetEdition(DWORD ProductType) static const char* GetEdition(DWORD ProductType)
{ {
static char unknown_edition_str[64]; static char unknown_edition_str[64];

View file

@ -45,7 +45,7 @@
#include "license.h" #include "license.h"
/* Globals */ /* Globals */
extern BOOL is_x86_32, appstore_version; extern BOOL is_x86_64, appstore_version;
extern char unattend_username[MAX_USERNAME_LENGTH]; extern char unattend_username[MAX_USERNAME_LENGTH];
static HICON hMessageIcon = (HICON)INVALID_HANDLE_VALUE; static HICON hMessageIcon = (HICON)INVALID_HANDLE_VALUE;
static char* szMessageText = NULL; static char* szMessageText = NULL;
@ -1494,7 +1494,7 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, lmprintf(MSG_016)), 2629800)); IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, lmprintf(MSG_016)), 2629800));
freq = ReadSetting32(SETTING_UPDATE_INTERVAL); freq = ReadSetting32(SETTING_UPDATE_INTERVAL);
EnableWindow(GetDlgItem(hDlg, IDC_CHECK_NOW), (freq != 0)); EnableWindow(GetDlgItem(hDlg, IDC_CHECK_NOW), (freq != 0));
EnableWindow(hBeta, (freq >= 0) && is_x86_32); EnableWindow(hBeta, (freq >= 0) && is_x86_64);
switch(freq) { switch(freq) {
case -1: case -1:
IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 0)); IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 0));
@ -1516,7 +1516,7 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
} }
IGNORE_RETVAL(ComboBox_AddStringU(hBeta, lmprintf(MSG_008))); IGNORE_RETVAL(ComboBox_AddStringU(hBeta, lmprintf(MSG_008)));
IGNORE_RETVAL(ComboBox_AddStringU(hBeta, lmprintf(MSG_009))); IGNORE_RETVAL(ComboBox_AddStringU(hBeta, lmprintf(MSG_009)));
IGNORE_RETVAL(ComboBox_SetCurSel(hBeta, (ReadSettingBool(SETTING_INCLUDE_BETAS) && is_x86_32) ? 0 : 1)); IGNORE_RETVAL(ComboBox_SetCurSel(hBeta, (ReadSettingBool(SETTING_INCLUDE_BETAS) && is_x86_64) ? 0 : 1));
hPolicy = GetDlgItem(hDlg, IDC_POLICY); hPolicy = GetDlgItem(hDlg, IDC_POLICY);
SendMessage(hPolicy, EM_AUTOURLDETECT, 1, 0); SendMessage(hPolicy, EM_AUTOURLDETECT, 1, 0);
static_sprintf(update_policy_text, update_policy, lmprintf(MSG_179|MSG_RTF), static_sprintf(update_policy_text, update_policy, lmprintf(MSG_179|MSG_RTF),
@ -1558,7 +1558,7 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
break; break;
freq = (int32_t)ComboBox_GetCurItemData(hFrequency); freq = (int32_t)ComboBox_GetCurItemData(hFrequency);
WriteSetting32(SETTING_UPDATE_INTERVAL, (DWORD)freq); WriteSetting32(SETTING_UPDATE_INTERVAL, (DWORD)freq);
EnableWindow(hBeta, (freq >= 0) && is_x86_32); EnableWindow(hBeta, (freq >= 0) && is_x86_64);
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
case IDC_INCLUDE_BETAS: case IDC_INCLUDE_BETAS:
if (HIWORD(wParam) != CBN_SELCHANGE) if (HIWORD(wParam) != CBN_SELCHANGE)