mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[misc] fix ISO label being used on non-bootable format
* Closes #490 * Closes #668
This commit is contained in:
		
							parent
							
								
									92631d1204
								
							
						
					
					
						commit
						4b3969e475
					
				
					 2 changed files with 65 additions and 45 deletions
				
			
		
							
								
								
									
										100
									
								
								src/rufus.c
									
										
									
									
									
								
							
							
						
						
									
										100
									
								
								src/rufus.c
									
										
									
									
									
								
							|  | @ -107,6 +107,8 @@ static BOOL iso_provided = FALSE; | ||||||
| static BOOL user_notified = FALSE; | static BOOL user_notified = FALSE; | ||||||
| static BOOL relaunch = FALSE; | static BOOL relaunch = FALSE; | ||||||
| static BOOL dont_display_image_name = FALSE; | static BOOL dont_display_image_name = FALSE; | ||||||
|  | static BOOL user_changed_label = FALSE; | ||||||
|  | static BOOL app_changed_label = FALSE; | ||||||
| extern BOOL enable_iso, enable_joliet, enable_rockridge, enable_ntfs_compression; | extern BOOL enable_iso, enable_joliet, enable_rockridge, enable_ntfs_compression; | ||||||
| extern uint8_t* grub2_buf; | extern uint8_t* grub2_buf; | ||||||
| extern long grub2_len; | extern long grub2_len; | ||||||
|  | @ -641,19 +643,53 @@ static void SetTargetSystem(void) | ||||||
| 	SetPartitionSchemeTooltip(); | 	SetPartitionSchemeTooltip(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static void SetProposedLabel(int ComboIndex) | ||||||
|  | { | ||||||
|  | 	const char no_label[] = STR_NO_LABEL; | ||||||
|  | 	int bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); | ||||||
|  | 
 | ||||||
|  | 	app_changed_label = TRUE; | ||||||
|  | 	// If bootable ISO creation is selected, and we have an ISO selected with a valid name, use that
 | ||||||
|  | 	// Also some distros (eg. Arch) require the USB to have the same label as the ISO
 | ||||||
|  | 	if (IsChecked(IDC_BOOT) && (bt == BT_ISO) && (image_path != NULL) && (img_report.label[0] != 0)) { | ||||||
|  | 		SetWindowTextU(hLabel, img_report.label); | ||||||
|  | 		// If we force the ISO label, we need to reset the user_changed_label flag
 | ||||||
|  | 		user_changed_label = FALSE; | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// If the user manually changed the label, try to preserve it
 | ||||||
|  | 	if (user_changed_label) { | ||||||
|  | 		app_changed_label = FALSE; | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// Empty the label if no device is currently selected
 | ||||||
|  | 	if (ComboIndex < 0) { | ||||||
|  | 		SetWindowTextU(hLabel, ""); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// Else if no existing label is available, propose one according to the size (eg: "256MB", "8GB")
 | ||||||
|  | 	if ((safe_stricmp(no_label, DriveLabel.String[ComboIndex]) == 0) || (safe_stricmp(no_label, "") == 0) | ||||||
|  | 		|| (safe_stricmp(lmprintf(MSG_207), DriveLabel.String[ComboIndex]) == 0)) { | ||||||
|  | 		SetWindowTextU(hLabel, SelectedDrive.proposed_label); | ||||||
|  | 	} else { | ||||||
|  | 		SetWindowTextU(hLabel, DriveLabel.String[ComboIndex]); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Populate the UI properties |  * Populate the UI properties | ||||||
|  */ |  */ | ||||||
| static BOOL PopulateProperties(int ComboIndex) | static BOOL PopulateProperties(int ComboIndex) | ||||||
| { | { | ||||||
| 	const char no_label[] = STR_NO_LABEL; |  | ||||||
| 	char* device_tooltip; | 	char* device_tooltip; | ||||||
| 
 | 
 | ||||||
| 	IGNORE_RETVAL(ComboBox_ResetContent(hPartitionScheme)); | 	IGNORE_RETVAL(ComboBox_ResetContent(hPartitionScheme)); | ||||||
| 	IGNORE_RETVAL(ComboBox_ResetContent(hFileSystem)); | 	IGNORE_RETVAL(ComboBox_ResetContent(hFileSystem)); | ||||||
| 	IGNORE_RETVAL(ComboBox_ResetContent(hClusterSize)); | 	IGNORE_RETVAL(ComboBox_ResetContent(hClusterSize)); | ||||||
| 	EnableWindow(hStart, FALSE); | 	EnableWindow(hStart, FALSE); | ||||||
| 	SetWindowTextA(hLabel, ""); |  | ||||||
| 	memset(&SelectedDrive, 0, sizeof(SelectedDrive)); | 	memset(&SelectedDrive, 0, sizeof(SelectedDrive)); | ||||||
| 
 | 
 | ||||||
| 	if (ComboIndex < 0) | 	if (ComboIndex < 0) | ||||||
|  | @ -678,17 +714,7 @@ static BOOL PopulateProperties(int ComboIndex) | ||||||
| 		free(device_tooltip); | 		free(device_tooltip); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// If no existing label is available and no ISO is selected, propose one according to the size (eg: "256MB", "8GB")
 | 	SetProposedLabel(ComboIndex); | ||||||
| 	if ((image_path == NULL) || (img_report.label[0] == 0)) { |  | ||||||
| 		if ( (safe_stricmp(no_label, DriveLabel.String[ComboIndex]) == 0) |  | ||||||
| 		  || (safe_stricmp(lmprintf(MSG_207), DriveLabel.String[ComboIndex]) == 0) ) { |  | ||||||
| 			SetWindowTextU(hLabel, SelectedDrive.proposed_label); |  | ||||||
| 		} else { |  | ||||||
| 			SetWindowTextU(hLabel, DriveLabel.String[ComboIndex]); |  | ||||||
| 		} |  | ||||||
| 	} else { |  | ||||||
| 		SetWindowTextU(hLabel, img_report.label); |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	return TRUE; | 	return TRUE; | ||||||
| } | } | ||||||
|  | @ -1071,11 +1097,7 @@ DWORD WINAPI ISOScanThread(LPVOID param) | ||||||
| 			SetTargetSystem(); | 			SetTargetSystem(); | ||||||
| 			SetFSFromISO(); | 			SetFSFromISO(); | ||||||
| 			SetMBRProps(); | 			SetMBRProps(); | ||||||
| 			// Some Linux distros, such as Arch Linux, require the USB drive to have
 | 			SetProposedLabel(ComboBox_GetCurSel(hDeviceList)); | ||||||
| 			// a specific label => copy the one we got from the ISO image
 |  | ||||||
| 			if (img_report.label[0] != 0) { |  | ||||||
| 				SetWindowTextU(hLabel, img_report.label); |  | ||||||
| 			} |  | ||||||
| 		} else { | 		} else { | ||||||
| 			SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM, | 			SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM, | ||||||
| 				ComboBox_GetCurSel(hFileSystem)); | 				ComboBox_GetCurSel(hFileSystem)); | ||||||
|  | @ -2064,7 +2086,7 @@ void SaveVHD(void) | ||||||
| static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) | static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) | ||||||
| { | { | ||||||
| 	static DWORD DeviceNum = 0, LastRefresh = 0; | 	static DWORD DeviceNum = 0, LastRefresh = 0; | ||||||
| 	static BOOL first_log_display = TRUE, user_changed_label = FALSE, isMarquee = FALSE; | 	static BOOL first_log_display = TRUE, isMarquee = FALSE; | ||||||
| 	static ULONG ulRegister = 0; | 	static ULONG ulRegister = 0; | ||||||
| 	static LPITEMIDLIST pidlDesktop = NULL; | 	static LPITEMIDLIST pidlDesktop = NULL; | ||||||
| 	static MY_SHChangeNotifyEntry NotifyEntry; | 	static MY_SHChangeNotifyEntry NotifyEntry; | ||||||
|  | @ -2290,8 +2312,12 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 				ComboBox_GetCurSel(hFileSystem)); | 				ComboBox_GetCurSel(hFileSystem)); | ||||||
| 			break; | 			break; | ||||||
| 		case IDC_LABEL: | 		case IDC_LABEL: | ||||||
| 			if (HIWORD(wParam) == EN_CHANGE) | 			if (HIWORD(wParam) == EN_CHANGE) { | ||||||
| 				user_changed_label = TRUE; | 				// We will get EN_CHANGE when we change the label automatically, so we need to detect that
 | ||||||
|  | 				if (!app_changed_label) | ||||||
|  | 					user_changed_label = TRUE; | ||||||
|  | 				app_changed_label = FALSE; | ||||||
|  | 			} | ||||||
| 			break; | 			break; | ||||||
| 		case IDC_DEVICE: | 		case IDC_DEVICE: | ||||||
| 			if (HIWORD(wParam) != CBN_SELCHANGE) | 			if (HIWORD(wParam) != CBN_SELCHANGE) | ||||||
|  | @ -2373,6 +2399,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 			EnableAdvancedBootOptions(TRUE, TRUE); | 			EnableAdvancedBootOptions(TRUE, TRUE); | ||||||
| 			if (selection_default == BT_IMG) | 			if (selection_default == BT_IMG) | ||||||
| 				ToggleImage(!IsChecked(IDC_BOOT)); | 				ToggleImage(!IsChecked(IDC_BOOT)); | ||||||
|  | 			SetProposedLabel(ComboBox_GetCurSel(hDeviceList)); | ||||||
| 			break; | 			break; | ||||||
| 		case IDC_BOOTTYPE: | 		case IDC_BOOTTYPE: | ||||||
| 			if (HIWORD(wParam) != CBN_SELCHANGE) | 			if (HIWORD(wParam) != CBN_SELCHANGE) | ||||||
|  | @ -2381,26 +2408,19 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 			EnableAdvancedBootOptions(TRUE, TRUE); | 			EnableAdvancedBootOptions(TRUE, TRUE); | ||||||
| 			ToggleImage(!IsChecked(IDC_BOOT) || (selection_default != BT_IMG)); | 			ToggleImage(!IsChecked(IDC_BOOT) || (selection_default != BT_IMG)); | ||||||
| 			SetToGo(); | 			SetToGo(); | ||||||
| 			if ((selection_default == BT_ISO) || (selection_default == BT_IMG)) { | 			SetProposedLabel(ComboBox_GetCurSel(hDeviceList)); | ||||||
| 				if ((image_path != NULL) && (img_report.label[0] != 0)) { | 			if (selection_default == BT_UEFI_NTFS) { | ||||||
| 					// Some distros (eg. Arch Linux) want to see a specific label => ignore user one
 | 				// Try to select NTFS as default
 | ||||||
| 					SetWindowTextU(hLabel, img_report.label); | 				for (i=0; i<ComboBox_GetCount(hFileSystem); i++) { | ||||||
|  | 					fs = (int)ComboBox_GetItemData(hFileSystem, i); | ||||||
|  | 					if (fs == FS_NTFS) | ||||||
|  | 						IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, i)); | ||||||
| 				} | 				} | ||||||
| 			} else { | 				SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM, | ||||||
| 				if (selection_default == BT_UEFI_NTFS) { | 					ComboBox_GetCurSel(hFileSystem)); | ||||||
| 					// Try to select NTFS as default
 | 			} | ||||||
| 					for (i=0; i<ComboBox_GetCount(hFileSystem); i++) { | 			// Reset disk ID to 0x80 if Rufus MBR is used
 | ||||||
| 						fs = (int)ComboBox_GetItemData(hFileSystem, i); | 			if ((selection_default != BT_ISO) && (selection_default != BT_IMG)) { | ||||||
| 						if (fs == FS_NTFS) |  | ||||||
| 							IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, i)); |  | ||||||
| 					} |  | ||||||
| 					SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM, |  | ||||||
| 						ComboBox_GetCurSel(hFileSystem)); |  | ||||||
| 				} |  | ||||||
| 				// For non ISO, if the user manually set a label, try to preserve it
 |  | ||||||
| 				if (!user_changed_label) |  | ||||||
| 					SetWindowTextU(hLabel, SelectedDrive.proposed_label); |  | ||||||
| 				// Reset disk ID to 0x80 if Rufus MBR is used
 |  | ||||||
| 				IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0)); | 				IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0)); | ||||||
| 			} | 			} | ||||||
| 			return (INT_PTR)TRUE; | 			return (INT_PTR)TRUE; | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | ||||||
| 
 | 
 | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 242, 376 | IDD_DIALOG DIALOGEX 12, 12, 242, 376 | ||||||
| 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 | ||||||
| CAPTION "Rufus 2.7.825" | CAPTION "Rufus 2.7.826" | ||||||
| FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | ||||||
| BEGIN | BEGIN | ||||||
|     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 |     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 | ||||||
|  | @ -319,8 +319,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 2,7,825,0 |  FILEVERSION 2,7,826,0 | ||||||
|  PRODUCTVERSION 2,7,825,0 |  PRODUCTVERSION 2,7,826,0 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -337,13 +337,13 @@ BEGIN | ||||||
|         BEGIN |         BEGIN | ||||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" |             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "2.7.825" |             VALUE "FileVersion", "2.7.826" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" | ||||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" |             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||||
|             VALUE "OriginalFilename", "rufus.exe" |             VALUE "OriginalFilename", "rufus.exe" | ||||||
|             VALUE "ProductName", "Rufus" |             VALUE "ProductName", "Rufus" | ||||||
|             VALUE "ProductVersion", "2.7.825" |             VALUE "ProductVersion", "2.7.826" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue