mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[ui] perform ISO download feature check in a background thread
This commit is contained in:
parent
a1d605f206
commit
94a2699640
5 changed files with 67 additions and 41 deletions
|
@ -6,6 +6,7 @@ o Version 3.11 (2020.06.??)
|
|||
Add a cheat mode (Alt-P) to toggle a GPT ESP to Basic Data (Windows 10 only)
|
||||
Fix improper x86 32-bit NTFS driver being used for UEFI:NTFS
|
||||
Improve UEFI:NTFS compatibility with older UEFI firmwares
|
||||
Improve startup time by running the ISO download feature check in the background
|
||||
Remove Ubuntu's splash screen for persistent UEFI drives
|
||||
Enable ASLR for the Rufus executable
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ BOOL enable_HDDs = FALSE, enable_VHDs = TRUE, enable_ntfs_compression = FALSE, n
|
|||
BOOL advanced_mode_device, advanced_mode_format, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug;
|
||||
BOOL use_fake_units, preserve_timestamps = FALSE, fast_zeroing = FALSE, app_changed_size = FALSE;
|
||||
BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, enable_file_indexing, large_drive = FALSE;
|
||||
BOOL write_as_image = FALSE, write_as_esp = FALSE, installed_uefi_ntfs = FALSE, enable_fido = FALSE, use_vds = FALSE;
|
||||
BOOL write_as_image = FALSE, write_as_esp = FALSE, installed_uefi_ntfs = FALSE, use_vds = FALSE;
|
||||
float fScale = 1.0f;
|
||||
int dialog_showing = 0, selection_default = BT_IMAGE, windows_to_go_selection = 0, persistence_unit_selection = -1;
|
||||
int default_fs, fs_type, boot_type, partition_type, target_type; // file system, boot type, partition type, target type
|
||||
|
@ -3286,8 +3286,7 @@ relaunch:
|
|||
image_option_txt[0] = 0;
|
||||
select_index = 0;
|
||||
safe_free(fido_url);
|
||||
enable_fido = FALSE;
|
||||
SetProcessDefaultLayout(right_to_left_mode?LAYOUT_RTL:0);
|
||||
SetProcessDefaultLayout(right_to_left_mode ? LAYOUT_RTL : 0);
|
||||
if (get_loc_data_file(loc_file, selected_locale))
|
||||
WriteSettingStr(SETTING_LOCALE, selected_locale->txt[0]);
|
||||
|
||||
|
|
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.11.1675"
|
||||
CAPTION "Rufus 3.11.1676"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -395,8 +395,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,11,1675,0
|
||||
PRODUCTVERSION 3,11,1675,0
|
||||
FILEVERSION 3,11,1676,0
|
||||
PRODUCTVERSION 3,11,1676,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -414,13 +414,13 @@ BEGIN
|
|||
VALUE "Comments", "https://rufus.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "3.11.1675"
|
||||
VALUE "FileVersion", "3.11.1676"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||
VALUE "OriginalFilename", "rufus-3.11.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "3.11.1675"
|
||||
VALUE "ProductVersion", "3.11.1676"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
76
src/stdlg.c
76
src/stdlg.c
|
@ -45,7 +45,7 @@
|
|||
#include "license.h"
|
||||
|
||||
/* Globals */
|
||||
extern BOOL is_x86_32, enable_fido;
|
||||
extern BOOL is_x86_32;
|
||||
static HICON hMessageIcon = (HICON)INVALID_HANDLE_VALUE;
|
||||
static char* szMessageText = NULL;
|
||||
static char* szMessageTitle = NULL;
|
||||
|
@ -1497,6 +1497,55 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
|
|||
return (INT_PTR)FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Use a thread to enable the download button as this may be a lengthy
|
||||
* operation due to the external download check.
|
||||
*/
|
||||
static DWORD WINAPI CheckForFidoThread(LPVOID param)
|
||||
{
|
||||
static BOOL is_active = FALSE;
|
||||
LONG_PTR style;
|
||||
char* loc = NULL;
|
||||
uint64_t len;
|
||||
HWND hCtrl;
|
||||
|
||||
// Because a user may switch language before this thread has completed,
|
||||
// we need to detect concurrency.
|
||||
// Checking on a static boolean is more than good enough for our purpose.
|
||||
if (is_active)
|
||||
return -1;
|
||||
is_active = TRUE;
|
||||
safe_free(fido_url);
|
||||
|
||||
// Get the Fido URL from parsing a 'Fido.ver' on our server. This enables the use of different
|
||||
// Fido versions from different versions of Rufus, if needed, as opposed to always downloading
|
||||
// the latest release from GitHub, which may contain incompatible changes...
|
||||
len = DownloadToFileOrBuffer(RUFUS_URL "/Fido.ver", NULL, (BYTE**)&loc, NULL, FALSE);
|
||||
if ((len == 0) || (len >= 4 * KB))
|
||||
goto out;
|
||||
|
||||
len++; // DownloadToFileOrBuffer allocated an extra NUL character if needed
|
||||
fido_url = get_token_data_buffer(FIDO_VERSION, 1, loc, (size_t)len);
|
||||
if (safe_strncmp(fido_url, "https://github.com/pbatard/Fido", 31) != 0) {
|
||||
uprintf("WARNING: Download script URL %s is invalid ✗", fido_url);
|
||||
safe_free(fido_url);
|
||||
goto out;
|
||||
}
|
||||
if (IsDownloadable(fido_url)) {
|
||||
hCtrl = GetDlgItem(hMainDialog, IDC_SELECT);
|
||||
style = GetWindowLongPtr(hCtrl, GWL_STYLE);
|
||||
style |= BS_SPLITBUTTON;
|
||||
SetWindowLongPtr(hCtrl, GWL_STYLE, style);
|
||||
RedrawWindow(hCtrl, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW);
|
||||
InvalidateRect(hCtrl, NULL, TRUE);
|
||||
}
|
||||
|
||||
out:
|
||||
safe_free(loc);
|
||||
is_active = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initial update check setup
|
||||
*/
|
||||
|
@ -1549,27 +1598,10 @@ BOOL SetUpdateCheck(void)
|
|||
if (((ReadRegistryKey32(REGKEY_HKLM, "Microsoft\\PowerShell\\1\\Install") > 0) ||
|
||||
(ReadRegistryKey32(REGKEY_HKLM, "Microsoft\\PowerShell\\3\\Install") > 0)) &&
|
||||
(ReadSetting32(SETTING_UPDATE_INTERVAL) > 0)) {
|
||||
char *loc = NULL;
|
||||
// Get the Fido URL from parsing a 'Fido.ver' on our server. This enables the use of different
|
||||
// Fido versions from different versions of Rufus, if needed, as opposed to always downloading
|
||||
// the latest release from GitHub, which may contain incompatible changes...
|
||||
uint64_t loc_len = DownloadToFileOrBuffer(RUFUS_URL "/Fido.ver", NULL, (BYTE**)&loc, NULL, FALSE);
|
||||
if ((loc_len != 0) && (loc_len < 4 * KB)) {
|
||||
loc_len++; // DownloadToFileOrBuffer allocated an extra NUL character if needed
|
||||
fido_url = get_token_data_buffer(FIDO_VERSION, 1, loc, (size_t)loc_len);
|
||||
if (safe_strncmp(fido_url, "https://github.com/pbatard/Fido", 31) != 0) {
|
||||
ubprintf("WARNING: Download script URL %s is invalid ✗", fido_url);
|
||||
safe_free(fido_url);
|
||||
} else {
|
||||
uprintf("Fido URL is %s", fido_url);
|
||||
enable_fido = IsDownloadable(fido_url);
|
||||
}
|
||||
}
|
||||
safe_free(loc);
|
||||
}
|
||||
if (!enable_fido) {
|
||||
ubprintf("Notice: The ISO download feature has been deactivated because %s", (ReadSetting32(SETTING_UPDATE_INTERVAL) <= 0) ?
|
||||
"'Check for updates' is disabled in your settings." : "the remote download script can not be accessed.");
|
||||
CreateThread(NULL, 0, CheckForFidoThread, NULL, 0, NULL);
|
||||
} else {
|
||||
ubprintf("Notice: The ISO download feature has been deactivated because "
|
||||
"'Check for updates' is disabled in your settings.");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
16
src/ui.c
16
src/ui.c
|
@ -43,7 +43,7 @@
|
|||
|
||||
UINT_PTR UM_LANGUAGE_MENU_MAX = UM_LANGUAGE_MENU;
|
||||
HIMAGELIST hUpImageList, hDownImageList;
|
||||
extern BOOL enable_fido, use_vds;
|
||||
extern BOOL use_vds;
|
||||
int update_progress_type = UPT_PERCENT;
|
||||
int advanced_device_section_height, advanced_format_section_height;
|
||||
// (empty) check box width, (empty) drop down width, button height (for and without dropdown match)
|
||||
|
@ -149,7 +149,6 @@ void GetMainButtonsWidth(HWND hDlg)
|
|||
{
|
||||
unsigned int i;
|
||||
RECT rc;
|
||||
LONG_PTR style;
|
||||
char download[64];
|
||||
|
||||
GetWindowRect(GetDlgItem(hDlg, main_button_ids[0]), &rc);
|
||||
|
@ -158,19 +157,14 @@ void GetMainButtonsWidth(HWND hDlg)
|
|||
|
||||
for (i = 0; i < ARRAYSIZE(main_button_ids); i++) {
|
||||
// Make sure we add extra space for the SELECT split button (i == 0) if Fido is enabled
|
||||
bw = max(bw, GetTextWidth(hDlg, main_button_ids[i]) + ((enable_fido && i == 0) ? (3 * cbw) / 2 : cbw));
|
||||
bw = max(bw, GetTextWidth(hDlg, main_button_ids[i]) + ((i == 0) ? (3 * cbw) / 2 : cbw));
|
||||
}
|
||||
// The 'CLOSE' button is also be used to display 'CANCEL' and we sometimes
|
||||
// want to add "DOWNLOAD" into the Select split button => measure that too.
|
||||
bw = max(bw, GetTextSize(GetDlgItem(hDlg, IDCANCEL), lmprintf(MSG_007)).cx + cbw);
|
||||
if (enable_fido) {
|
||||
static_strcpy(download, lmprintf(MSG_040));
|
||||
CharUpperBuffU(download, sizeof(download));
|
||||
bw = max(bw, GetTextSize(GetDlgItem(hDlg, IDC_SELECT), download).cx + (3 * cbw) / 2);
|
||||
style = GetWindowLongPtr(GetDlgItem(hDlg, IDC_SELECT), GWL_STYLE);
|
||||
style |= BS_SPLITBUTTON;
|
||||
SetWindowLongPtr(GetDlgItem(hDlg, IDC_SELECT), GWL_STYLE, style);
|
||||
}
|
||||
static_strcpy(download, lmprintf(MSG_040));
|
||||
CharUpperBuffU(download, sizeof(download));
|
||||
bw = max(bw, GetTextSize(GetDlgItem(hDlg, IDC_SELECT), download).cx + (3 * cbw) / 2);
|
||||
}
|
||||
|
||||
// The following goes over the data that gets populated into the half-width dropdowns
|
||||
|
|
Loading…
Reference in a new issue