mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[ui] disable controls prior to format checks
* Also send Unicode strings to the debug output facility, since Windows 10 *FINALLY* added Unicode processing support there...
This commit is contained in:
		
							parent
							
								
									39e418fbe9
								
							
						
					
					
						commit
						d5babb5e72
					
				
					 3 changed files with 39 additions and 51 deletions
				
			
		
							
								
								
									
										71
									
								
								src/rufus.c
									
										
									
									
									
								
							
							
						
						
									
										71
									
								
								src/rufus.c
									
										
									
									
									
								
							|  | @ -2515,6 +2515,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 			if (format_thid != NULL) { | 			if (format_thid != NULL) { | ||||||
| 				return (INT_PTR)TRUE; | 				return (INT_PTR)TRUE; | ||||||
| 			} | 			} | ||||||
|  | 			// Disable all controls except Cancel
 | ||||||
|  | 			EnableControls(FALSE); | ||||||
| 			FormatStatus = 0; | 			FormatStatus = 0; | ||||||
| 			StrArrayClear(&BlockingProcess); | 			StrArrayClear(&BlockingProcess); | ||||||
| 			format_op_in_progress = TRUE; | 			format_op_in_progress = TRUE; | ||||||
|  | @ -2528,11 +2530,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 			nDeviceIndex = ComboBox_GetCurSel(hDeviceList); | 			nDeviceIndex = ComboBox_GetCurSel(hDeviceList); | ||||||
| 			if (nDeviceIndex != CB_ERR) { | 			if (nDeviceIndex != CB_ERR) { | ||||||
| 				if (!zero_drive) { | 				if (!zero_drive) { | ||||||
| 					if ((IsChecked(IDC_BOOT)) && (!BootCheck())) { | 					if ((IsChecked(IDC_BOOT)) && (!BootCheck())) | ||||||
| 						format_op_in_progress = FALSE; | 						goto aborted_start; | ||||||
| 						PROCESS_QUEUED_EVENTS; |  | ||||||
| 						break; |  | ||||||
| 					} |  | ||||||
| 
 | 
 | ||||||
| 					// Display a warning about UDF formatting times
 | 					// Display a warning about UDF formatting times
 | ||||||
| 					fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); | 					fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); | ||||||
|  | @ -2558,9 +2557,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 						i = SelectionDialog(lmprintf(MSG_274), lmprintf(MSG_275, iso_image, dd_image, iso_image, dd_image), | 						i = SelectionDialog(lmprintf(MSG_274), lmprintf(MSG_275, iso_image, dd_image, iso_image, dd_image), | ||||||
| 							choices, 2); | 							choices, 2); | ||||||
| 						if (i < 0) {	// Cancel
 | 						if (i < 0) {	// Cancel
 | ||||||
| 							format_op_in_progress = FALSE; | 							goto aborted_start; | ||||||
| 							PROCESS_QUEUED_EVENTS; |  | ||||||
| 							break; |  | ||||||
| 						} else if (i == 2) { | 						} else if (i == 2) { | ||||||
| 							selection_default = BT_IMG; | 							selection_default = BT_IMG; | ||||||
| 							SetComboEntry(hBootType, selection_default); | 							SetComboEntry(hBootType, selection_default); | ||||||
|  | @ -2568,38 +2565,21 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 
 | 
 | ||||||
| 				if (!CheckDriveAccess()) { | 				if (!CheckDriveAccess()) | ||||||
| 					format_op_in_progress = FALSE; | 					goto aborted_start; | ||||||
| 					zero_drive = FALSE; |  | ||||||
| 					PROCESS_QUEUED_EVENTS; |  | ||||||
| 					break; |  | ||||||
| 				} |  | ||||||
| 
 | 
 | ||||||
| 				GetWindowTextU(hDeviceList, tmp, ARRAYSIZE(tmp)); | 				GetWindowTextU(hDeviceList, tmp, ARRAYSIZE(tmp)); | ||||||
| 				if (MessageBoxExU(hMainDialog, lmprintf(MSG_003, tmp), | 				if (MessageBoxExU(hMainDialog, lmprintf(MSG_003, tmp), | ||||||
| 					APPLICATION_NAME, MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL) { | 					APPLICATION_NAME, MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)  | ||||||
| 					format_op_in_progress = FALSE; | 					goto aborted_start; | ||||||
| 					zero_drive = FALSE; |  | ||||||
| 					PROCESS_QUEUED_EVENTS; |  | ||||||
| 					break; |  | ||||||
| 				} |  | ||||||
| 				if ((SelectedDrive.nPartitions > 1) && (MessageBoxExU(hMainDialog, lmprintf(MSG_093), | 				if ((SelectedDrive.nPartitions > 1) && (MessageBoxExU(hMainDialog, lmprintf(MSG_093), | ||||||
| 					lmprintf(MSG_094), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) { | 					lmprintf(MSG_094), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) | ||||||
| 					format_op_in_progress = FALSE; | 					goto aborted_start; | ||||||
| 					zero_drive = FALSE; |  | ||||||
| 					PROCESS_QUEUED_EVENTS; |  | ||||||
| 					break; |  | ||||||
| 				} |  | ||||||
| 				if ((!zero_drive) && (IsChecked(IDC_BOOT)) && (SelectedDrive.SectorSize != 512) && | 				if ((!zero_drive) && (IsChecked(IDC_BOOT)) && (SelectedDrive.SectorSize != 512) && | ||||||
| 					(MessageBoxExU(hMainDialog, lmprintf(MSG_196, SelectedDrive.SectorSize), | 					(MessageBoxExU(hMainDialog, lmprintf(MSG_196, SelectedDrive.SectorSize), | ||||||
| 						lmprintf(MSG_197), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) { | 						lmprintf(MSG_197), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) | ||||||
| 					format_op_in_progress = FALSE; | 					goto aborted_start; | ||||||
| 					PROCESS_QUEUED_EVENTS; |  | ||||||
| 					break; |  | ||||||
| 				} |  | ||||||
| 
 | 
 | ||||||
| 				// Disable all controls except Cancel
 |  | ||||||
| 				EnableControls(FALSE); |  | ||||||
| 				DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex); | 				DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex); | ||||||
| 				InitProgress(zero_drive); | 				InitProgress(zero_drive); | ||||||
| 				format_thid = CreateThread(NULL, 0, FormatThread, (LPVOID)(uintptr_t)DeviceNum, 0, NULL); | 				format_thid = CreateThread(NULL, 0, FormatThread, (LPVOID)(uintptr_t)DeviceNum, 0, NULL); | ||||||
|  | @ -2607,19 +2587,22 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 					uprintf("Unable to start formatting thread"); | 					uprintf("Unable to start formatting thread"); | ||||||
| 					FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_START_THREAD); | 					FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_START_THREAD); | ||||||
| 					PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0); | 					PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0); | ||||||
|  | 				} else { | ||||||
|  | 					uprintf("\r\nFormat operation started"); | ||||||
|  | 					PrintInfo(0, -1); | ||||||
|  | 					timer = 0; | ||||||
|  | 					safe_sprintf(szTimer, sizeof(szTimer), "00:00:00"); | ||||||
|  | 					SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); | ||||||
|  | 					SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); | ||||||
| 				} | 				} | ||||||
| 				uprintf("\r\nFormat operation started"); |  | ||||||
| 				PrintInfo(0, -1); |  | ||||||
| 				timer = 0; |  | ||||||
| 				safe_sprintf(szTimer, sizeof(szTimer), "00:00:00"); |  | ||||||
| 				SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); |  | ||||||
| 				SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); |  | ||||||
| 			} |  | ||||||
| 			if (format_thid == NULL) { |  | ||||||
| 				format_op_in_progress = FALSE; |  | ||||||
| 				zero_drive = FALSE; |  | ||||||
| 				PROCESS_QUEUED_EVENTS; |  | ||||||
| 			} | 			} | ||||||
|  | 			if (format_thid != NULL) | ||||||
|  | 				break; | ||||||
|  | 		aborted_start: | ||||||
|  | 			format_op_in_progress = FALSE; | ||||||
|  | 			EnableControls(TRUE); | ||||||
|  | 			zero_drive = FALSE; | ||||||
|  | 			PROCESS_QUEUED_EVENTS; | ||||||
| 			break; | 			break; | ||||||
| 		case IDC_HASH: | 		case IDC_HASH: | ||||||
| 			if ((format_thid == NULL) && (image_path != NULL)) { | 			if ((format_thid == NULL) && (image_path != NULL)) { | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,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 | ||||||
| EXSTYLE WS_EX_ACCEPTFILES | EXSTYLE WS_EX_ACCEPTFILES | ||||||
| CAPTION "Rufus 2.16.1148" | CAPTION "Rufus 2.16.1149" | ||||||
| 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 | ||||||
|  | @ -366,8 +366,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 2,16,1148,0 |  FILEVERSION 2,16,1149,0 | ||||||
|  PRODUCTVERSION 2,16,1148,0 |  PRODUCTVERSION 2,16,1149,0 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -384,13 +384,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.16.1148" |             VALUE "FileVersion", "2.16.1149" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011-2017 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.16.1148" |             VALUE "ProductVersion", "2.16.1149" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
|  | @ -42,10 +42,12 @@ size_t ubuffer_pos = 0; | ||||||
| char ubuffer[UBUFFER_SIZE];	// Buffer for ubpushf() messages we don't log right away
 | char ubuffer[UBUFFER_SIZE];	// Buffer for ubpushf() messages we don't log right away
 | ||||||
| 
 | 
 | ||||||
| #ifdef RUFUS_LOGGING | #ifdef RUFUS_LOGGING | ||||||
|  | #define Edit_ReplaceSelW(hCtrl, wstr) ((void)SendMessageW(hCtrl, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)wstr)) | ||||||
| void _uprintf(const char *format, ...) | void _uprintf(const char *format, ...) | ||||||
| { | { | ||||||
| 	static char buf[4096]; | 	static char buf[4096]; | ||||||
| 	char* p = buf; | 	char* p = buf; | ||||||
|  | 	wchar_t* wbuf; | ||||||
| 	va_list args; | 	va_list args; | ||||||
| 	int n; | 	int n; | ||||||
| 
 | 
 | ||||||
|  | @ -62,16 +64,19 @@ void _uprintf(const char *format, ...) | ||||||
| 	*p++ = '\n'; | 	*p++ = '\n'; | ||||||
| 	*p   = '\0'; | 	*p   = '\0'; | ||||||
| 
 | 
 | ||||||
|  | 	// Yay, Windows 10 *FINALLY* added actual Unicode support for OutputDebugStringW()!
 | ||||||
|  | 	wbuf = utf8_to_wchar(buf); | ||||||
| 	// Send output to Windows debug facility
 | 	// Send output to Windows debug facility
 | ||||||
| 	OutputDebugStringA(buf); | 	OutputDebugStringW(wbuf); | ||||||
| 	if ((hLog != NULL) && (hLog != INVALID_HANDLE_VALUE)) { | 	if ((hLog != NULL) && (hLog != INVALID_HANDLE_VALUE)) { | ||||||
| 		// Send output to our log Window
 | 		// Send output to our log Window
 | ||||||
| 		Edit_SetSel(hLog, MAX_LOG_SIZE, MAX_LOG_SIZE); | 		Edit_SetSel(hLog, MAX_LOG_SIZE, MAX_LOG_SIZE); | ||||||
| 		Edit_ReplaceSelU(hLog, buf); | 		Edit_ReplaceSelW(hLog, wbuf); | ||||||
| 		// Make sure the message scrolls into view
 | 		// Make sure the message scrolls into view
 | ||||||
| 		// (Or see code commented in LogProc:WM_SHOWWINDOW for a less forceful scroll)
 | 		// (Or see code commented in LogProc:WM_SHOWWINDOW for a less forceful scroll)
 | ||||||
| 		SendMessage(hLog, EM_LINESCROLL, 0, SendMessage(hLog, EM_GETLINECOUNT, 0, 0)); | 		SendMessage(hLog, EM_LINESCROLL, 0, SendMessage(hLog, EM_GETLINECOUNT, 0, 0)); | ||||||
| 	} | 	} | ||||||
|  | 	free(wbuf); | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue