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

Compare commits

...

2 commits

Author SHA1 Message Date
Pete Batard
9727fd4342
[core] improve/fix file system selection according to current ISO
* Closes #2074.
* Also harmonize whitespaces.
2022-11-16 16:55:41 +00:00
Pete Batard
a6769e4fb2
[core] don't process DBT_DEVNODES_CHANGED when scanning an image
* Since 8814944c35 we may mount an ISO for the lookup of the Windows version,
  which produces DBT_DEVNODES_CHANGED messages being issued when the virtual DVD is being created or removed
* This in turn leads to unwanted device refreshes.
* This patch makes sure we ignore DBT_DEVNODES_CHANGED while scanning.
* Also improve comments in iso.c.
2022-11-16 16:50:53 +00:00
3 changed files with 32 additions and 35 deletions

View file

@ -368,8 +368,7 @@ static void fix_config(const char* psz_fullpath, const char* psz_path, const cha
// line to their grub.cfg, which means that their kernel option token is no longer
//'linux' but '$linux'... and we have to add a workaround for that.
// Finally, newer Arch and derivatives added an extra "search --label ..." command
// in GRUB which we need to cater for in supplement to the kernel line.
// in their GRUB conf, which we need to cater for in supplement of the kernel line.
static const char* grub_token[] = { "linux", "linuxefi", "$linux", "search" };
iso_label = replace_char(img_report.label, ' ', "\\x20");
usb_label = replace_char(img_report.usb_label, ' ', "\\x20");
@ -385,11 +384,9 @@ static void fix_config(const char* psz_fullpath, const char* psz_path, const cha
uprintf(" Patched %s: '%s' ➔ '%s'\n", src, iso_label, usb_label);
modified = TRUE;
}
//
// Since version 8.2, and https://github.com/rhinstaller/anaconda/commit/a7661019546ec1d8b0935f9cb0f151015f2e1d95,
// Red Hat derivatives have changed their CD-ROM detection policy which leads to the installation source
// not being found. So we need to use 'inst.repo' instead of 'inst.stage2' in the kernel options.
//
if (img_report.rh8_derivative && (replace_in_token_data(src, props->is_grub_cfg ?
"linuxefi" : "append", "inst.stage2", "inst.repo", TRUE) != NULL)) {
uprintf(" Patched %s: '%s' ➔ '%s'\n", src, "inst.stage2", "inst.repo");

View file

@ -75,6 +75,7 @@ static BOOL img_provided = FALSE;
static BOOL user_notified = FALSE;
static BOOL relaunch = FALSE;
static BOOL dont_display_image_name = FALSE;
static BOOL dont_process_dbt_devnodes = FALSE;
static BOOL user_changed_label = FALSE;
static BOOL user_deleted_rufus_dir = FALSE;
static BOOL app_changed_label = FALSE;
@ -482,7 +483,7 @@ static BOOL SetFileSystemAndClusterSize(char* fs_name)
// FAT 16
if (SelectedDrive.DiskSize < 4*GB) {
SelectedDrive.ClusterSize[FS_FAT16].Allowed = 0x00001E00;
for (i=32; i<=4096; i<<=1) { // 8 MB -> 4 GB
for (i = 32; i <= 4096; i <<= 1) { // 8 MB -> 4 GB
if (SelectedDrive.DiskSize < i*MB) {
SelectedDrive.ClusterSize[FS_FAT16].Default = 16*(ULONG)i;
break;
@ -612,7 +613,7 @@ static BOOL SetFileSystemAndClusterSize(char* fs_name)
SelectedDrive.FSType = selected_fs;
}
for (i = 0; i<ComboBox_GetCount(hFileSystem); i++) {
for (i = 0; i < ComboBox_GetCount(hFileSystem); i++) {
if (ComboBox_GetItemData(hFileSystem, i) == SelectedDrive.FSType) {
IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, i));
break;
@ -630,7 +631,7 @@ static BOOL SetFileSystemAndClusterSize(char* fs_name)
static void SetFSFromISO(void)
{
int i, fs_tmp, preferred_fs = FS_UNKNOWN;
uint32_t fs_mask = FS_FAT32 | FS_NTFS;
uint32_t fs_mask = FS_NTFS | (img_report.has_4GB_file ? 0 : FS_FAT32);
BOOL windows_to_go = (image_options & IMOP_WINTOGO) && (boot_type == BT_IMAGE) &&
HAS_WINTOGO(img_report) && (ComboBox_GetCurItemData(hImageOption) == IMOP_WIN_TO_GO);
@ -638,39 +639,30 @@ static void SetFSFromISO(void)
return;
// Create a mask of all the FS's available
for (i=0; i<ComboBox_GetCount(hFileSystem); i++) {
for (i = 0; i < ComboBox_GetCount(hFileSystem); i++) {
fs_tmp = (int)ComboBox_GetItemData(hFileSystem, i);
fs_mask |= 1<<fs_tmp;
fs_mask |= 1 << fs_tmp;
}
if ((preferred_fs == FS_UNKNOWN) && (preselected_fs != FS_UNKNOWN)) {
// If the FS requested from the command line is valid use it
if (fs_mask & (1 << preselected_fs)) {
preferred_fs = preselected_fs;
}
}
if (preferred_fs == FS_UNKNOWN) {
// If the FS requested from the command line is valid use it
if ((preselected_fs != FS_UNKNOWN) && (fs_mask & (1 << preselected_fs))) {
preferred_fs = preselected_fs;
} else {
// Syslinux and EFI have precedence over bootmgr (unless the user selected BIOS as target type)
if ((HAS_SYSLINUX(img_report)) || (HAS_REACTOS(img_report)) || HAS_KOLIBRIOS(img_report) ||
(IS_EFI_BOOTABLE(img_report) && (target_type == TT_UEFI) && (!windows_to_go))) {
if (fs_mask & (1 << FS_FAT32)) {
(IS_EFI_BOOTABLE(img_report) && (target_type == TT_UEFI) && (!windows_to_go) && (!img_report.has_4GB_file))) {
if (fs_mask & (1 << FS_FAT32))
preferred_fs = FS_FAT32;
} else if ((fs_mask & (1 << FS_FAT16)) && !HAS_KOLIBRIOS(img_report)) {
else if ((fs_mask & (1 << FS_FAT16)) && !HAS_KOLIBRIOS(img_report))
preferred_fs = FS_FAT16;
}
} else if ((windows_to_go) || HAS_BOOTMGR(img_report) || HAS_WINPE(img_report)) {
if (fs_mask & (1 << FS_NTFS)) {
if ((fs_mask & (1 << FS_FAT32)) && (!img_report.has_4GB_file) && (allow_dual_uefi_bios))
preferred_fs = FS_FAT32;
else if (fs_mask & (1 << FS_NTFS))
preferred_fs = FS_NTFS;
}
}
}
// The presence of a 4GB file forces the use of NTFS as default FS if available
if (img_report.has_4GB_file && (fs_mask & (1 << FS_NTFS))) {
preferred_fs = FS_NTFS;
}
// Try to select the FS
for (i = 0; i < ComboBox_GetCount(hFileSystem); i++) {
fs_tmp = (int)ComboBox_GetItemData(hFileSystem, i);
@ -682,7 +674,7 @@ static void SetFSFromISO(void)
if (selected_fs == FS_UNKNOWN)
selected_fs = preferred_fs;
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE_INTERNAL<<16) | IDC_FILE_SYSTEM,
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE_INTERNAL << 16) | IDC_FILE_SYSTEM,
ComboBox_GetCurSel(hFileSystem));
}
@ -1276,6 +1268,10 @@ DWORD WINAPI ImageScanThread(LPVOID param)
uint8_t arch;
char tmp_path[MAX_PATH], tmp_str[64];
// We may mount an ISO during the lookup of the Windows version, which
// produces DBT_DEVNODES_CHANGED messages that lead to unwanted device
// refreshes. So make sure to ignore DBT_DEVNODES_CHANGED while scanning.
dont_process_dbt_devnodes = TRUE;
if (image_path == NULL)
goto out;
PrintInfoDebug(0, MSG_202);
@ -1414,6 +1410,7 @@ DWORD WINAPI ImageScanThread(LPVOID param)
out:
dont_display_image_name = FALSE;
dont_process_dbt_devnodes = FALSE;
PrintInfo(0, MSG_210);
ExitThread(0);
}
@ -2791,7 +2788,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
return (INT_PTR)TRUE;
case DBT_DEVNODES_CHANGED:
// If it's been more than a second since last device refresh, arm a refresh timer
if (GetTickCount64() > LastRefresh + 1000) {
if (dont_process_dbt_devnodes) {
// This ensures we don't get unwanted refreshes while scanning an image.
LastRefresh = GetTickCount64();
} else if (GetTickCount64() > LastRefresh + 1000) {
LastRefresh = GetTickCount64();
SetTimer(hMainDialog, TID_REFRESH_TIMER, 1000, RefreshTimer);
}

View file

@ -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.21.1944"
CAPTION "Rufus 3.21.1946"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -396,8 +396,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,21,1944,0
PRODUCTVERSION 3,21,1944,0
FILEVERSION 3,21,1946,0
PRODUCTVERSION 3,21,1946,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -415,13 +415,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.21.1944"
VALUE "FileVersion", "3.21.1946"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.21.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.21.1944"
VALUE "ProductVersion", "3.21.1946"
END
END
BLOCK "VarFileInfo"