mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[ui] better bad blocks reports
* improved status bar printout (priority messages with timeout) * report with abort/retry/cancel on bad block detection * also MinGW warning fixes
This commit is contained in:
		
							parent
							
								
									f93a85ab83
								
							
						
					
					
						commit
						b006e6a837
					
				
					 8 changed files with 85 additions and 45 deletions
				
			
		
							
								
								
									
										6
									
								
								TODO
									
										
									
									
									
								
							
							
						
						
									
										6
									
								
								TODO
									
										
									
									
									
								
							|  | @ -1,12 +1,10 @@ | ||||||
| o backblock check | o create a report file with failed block details when bad blocks are found | ||||||
|   http://git.kernel.org/?p=fs/ext2/e2fsprogs.git;a=blob;f=misc/badblocks.c |  | ||||||
| o progress bar during quick format / partitioning / MS-DOS files copy | o progress bar during quick format / partitioning / MS-DOS files copy | ||||||
| o use the umount/remount trick to make the volume reappear post formatting | o use the umount/remount trick to make the volume reappear post formatting | ||||||
| o set keyboard according to locale in DOS | o set keyboard according to locale in DOS | ||||||
| o allow selection of one of the existing compatible volume (keep existing MBR) / full repartitioning (overwrite MBR) | o allow selection of one of the existing compatible volume (keep existing MBR) / full repartitioning (overwrite MBR) | ||||||
| o FreeDOS integration | o FreeDOS integration | ||||||
| o Enable compression for NTFS | o Enable compression for NTFS | ||||||
| o Bootable NTFS/exFAT? | o Bootable NTFS/exFAT (http://sourceforge.net/projects/grub4dos)? | ||||||
|   http://sourceforge.net/projects/grub4dos/ |  | ||||||
| o GPT support? | o GPT support? | ||||||
| o disable indexing support on NTFS? | o disable indexing support on NTFS? | ||||||
|  |  | ||||||
|  | @ -363,10 +363,10 @@ static void print_status(void) | ||||||
| 	time_end = GetTickCount(); | 	time_end = GetTickCount(); | ||||||
| 	percent = calc_percent((unsigned long) currently_testing, | 	percent = calc_percent((unsigned long) currently_testing, | ||||||
| 					(unsigned long) num_blocks); | 					(unsigned long) num_blocks); | ||||||
| 	PrintStatus("%d/%d(%c): %6.2f%% done, %.0fs elapsed. " | 	percent = (percent/2.0f) + ((cur_op==OP_READ)? 50.0f : 0.0f); | ||||||
|  | 	PrintStatus(0, "PASS %d/%d(%c): %6.2f%% done, %.0fs elapsed. " | ||||||
| 					"(%d/%d/%d errors)", | 					"(%d/%d/%d errors)", | ||||||
| 				2*cur_pattern - ((cur_op==OP_WRITE)?1:0), | 				cur_pattern, nr_pattern, | ||||||
| 				2*nr_pattern, |  | ||||||
| 				(cur_op==OP_READ)?'R':'W', | 				(cur_op==OP_READ)?'R':'W', | ||||||
| 				percent,  | 				percent,  | ||||||
| 				(time_end - time_start)/1000.0, | 				(time_end - time_start)/1000.0, | ||||||
|  | @ -398,7 +398,8 @@ static void pattern_fill(unsigned char *buffer, unsigned int pattern, | ||||||
| 		for (ptr = buffer; ptr < buffer + n; ptr++) { | 		for (ptr = buffer; ptr < buffer + n; ptr++) { | ||||||
| 			(*ptr) = rand() % (1 << (8 * sizeof(char))); | 			(*ptr) = rand() % (1 << (8 * sizeof(char))); | ||||||
| 		} | 		} | ||||||
| 		PrintStatus("Testing with random pattern: "); | 		PrintStatus(3500, "Testing with random pattern: "); | ||||||
|  | 		uprintf("Testing with random pattern: "); | ||||||
| 	} else { | 	} else { | ||||||
| 		bpattern[0] = 0; | 		bpattern[0] = 0; | ||||||
| 		for (i = 0; i < sizeof(bpattern); i++) { | 		for (i = 0; i < sizeof(bpattern); i++) { | ||||||
|  | @ -415,7 +416,8 @@ static void pattern_fill(unsigned char *buffer, unsigned int pattern, | ||||||
| 			else | 			else | ||||||
| 				i--; | 				i--; | ||||||
| 		} | 		} | ||||||
| 		PrintStatus("Testing with pattern 0x%02X", bpattern[i]); | 		PrintStatus(3500, "Testing with pattern 0x%02X", bpattern[i]); | ||||||
|  | 		uprintf("Testing with pattern 0x%02X", bpattern[i]); | ||||||
| 		cur_pattern++; | 		cur_pattern++; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | @ -700,7 +702,7 @@ static unsigned int test_nd(HANDLE hDrive, blk_t last_block, | ||||||
| 	int tryout, i; | 	int tryout, i; | ||||||
| 	const unsigned int patterns[] = { ~0 }; | 	const unsigned int patterns[] = { ~0 }; | ||||||
| 	const unsigned int *pattern; | 	const unsigned int *pattern; | ||||||
| 	int nr_pattern, pat_idx; | 	int pat_idx; | ||||||
| 	int got, used2, written; | 	int got, used2, written; | ||||||
| 	blk_t save_currently_testing; | 	blk_t save_currently_testing; | ||||||
| 	struct saved_blk_record *test_record; | 	struct saved_blk_record *test_record; | ||||||
|  | @ -965,13 +967,13 @@ BOOL BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int block_size, | ||||||
| 	time_start = GetTickCount(); | 	time_start = GetTickCount(); | ||||||
| 	cancel_ops = 0; | 	cancel_ops = 0; | ||||||
| 	/* use a timer to update status every second */ | 	/* use a timer to update status every second */ | ||||||
| 	SetTimer(hMainDialog, EXT2_TIMER_ID, 1000, alarm_intr); | 	SetTimer(hMainDialog, BADBLOCK_TIMER_ID, 1000, alarm_intr); | ||||||
| 	report->bb_count = test_func(hPhysicalDrive, last_block, block_size, first_block, EXT2_BLOCKS_AT_ONCE); | 	report->bb_count = test_func(hPhysicalDrive, last_block, block_size, first_block, EXT2_BLOCKS_AT_ONCE); | ||||||
| 	KillTimer(hMainDialog, EXT2_TIMER_ID); | 	KillTimer(hMainDialog, BADBLOCK_TIMER_ID); | ||||||
| 	free(t_patts); | 	free(t_patts); | ||||||
| 	free(bb_list->list); | 	free(bb_list->list); | ||||||
| 	free(bb_list); | 	free(bb_list); | ||||||
| 	// TODO: report first problem block for each error
 | 	// TODO: report first problem block for each error or create a report file
 | ||||||
| 	report->num_read_errors = num_read_errors; | 	report->num_read_errors = num_read_errors; | ||||||
| 	report->num_write_errors = num_write_errors; | 	report->num_write_errors = num_write_errors; | ||||||
| 	report->num_corruption_errors = num_corruption_errors; | 	report->num_corruption_errors = num_corruption_errors; | ||||||
|  |  | ||||||
|  | @ -41,7 +41,6 @@ typedef struct ext2_struct_u32_iterate      *ext2_u32_iterate; | ||||||
| #define EXT2_BAD_BLOCKS_THRESHOLD           32 | #define EXT2_BAD_BLOCKS_THRESHOLD           32 | ||||||
| #define EXT2_BLOCKS_AT_ONCE                 64 | #define EXT2_BLOCKS_AT_ONCE                 64 | ||||||
| #define EXT2_SYS_PAGE_SIZE                  4096 | #define EXT2_SYS_PAGE_SIZE                  4096 | ||||||
| #define EXT2_TIMER_ID                       0x1000 |  | ||||||
| 
 | 
 | ||||||
| enum test_types { | enum test_types { | ||||||
| 	BADBLOCKS_RO,		/* Read-only */ | 	BADBLOCKS_RO,		/* Read-only */ | ||||||
|  |  | ||||||
							
								
								
									
										31
									
								
								src/format.c
									
										
									
									
									
								
							
							
						
						
									
										31
									
								
								src/format.c
									
										
									
									
									
								
							|  | @ -138,7 +138,7 @@ static BOOL FormatDrive(char DriveLetter) | ||||||
| 	size_t i; | 	size_t i; | ||||||
| 
 | 
 | ||||||
| 	wDriveRoot[0] = (WCHAR)DriveLetter; | 	wDriveRoot[0] = (WCHAR)DriveLetter; | ||||||
| 	PrintStatus("Formatting..."); | 	PrintStatus(0, "Formatting..."); | ||||||
| 	PF_INIT_OR_OUT(FormatEx, fmifs); | 	PF_INIT_OR_OUT(FormatEx, fmifs); | ||||||
| 
 | 
 | ||||||
| 	GetWindowTextW(hFileSystem, wFSType, ARRAYSIZE(wFSType)); | 	GetWindowTextW(hFileSystem, wFSType, ARRAYSIZE(wFSType)); | ||||||
|  | @ -323,6 +323,7 @@ void __cdecl FormatThread(void* param) | ||||||
| 	HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE; | 	HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE; | ||||||
| 	HANDLE hLogicalVolume = INVALID_HANDLE_VALUE; | 	HANDLE hLogicalVolume = INVALID_HANDLE_VALUE; | ||||||
| 	char drive_name[] = "?:"; | 	char drive_name[] = "?:"; | ||||||
|  | 	char bb_msg[256]; | ||||||
| 	int i; | 	int i; | ||||||
| 
 | 
 | ||||||
| 	hPhysicalDrive = GetDriveHandle(num, NULL, TRUE, TRUE); | 	hPhysicalDrive = GetDriveHandle(num, NULL, TRUE, TRUE); | ||||||
|  | @ -341,7 +342,7 @@ void __cdecl FormatThread(void* param) | ||||||
| 			FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; | 			FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; | ||||||
| 			goto out; | 			goto out; | ||||||
| 		} | 		} | ||||||
| 
 | bb_retry: | ||||||
| 		if (!BadBlocks(hPhysicalDrive, SelectedDrive.DiskSize, | 		if (!BadBlocks(hPhysicalDrive, SelectedDrive.DiskSize, | ||||||
| 			SelectedDrive.Geometry.BytesPerSector, BADBLOCKS_RW, &report)) { | 			SelectedDrive.Geometry.BytesPerSector, BADBLOCKS_RW, &report)) { | ||||||
| 			uprintf("Bad blocks check failed.\n"); | 			uprintf("Bad blocks check failed.\n"); | ||||||
|  | @ -351,11 +352,23 @@ void __cdecl FormatThread(void* param) | ||||||
| 			// TODO: should probably ClearMBR here as well
 | 			// TODO: should probably ClearMBR here as well
 | ||||||
| 			goto out; | 			goto out; | ||||||
| 		} | 		} | ||||||
| 		uprintf("Check completed, %u bad blocks found. (%d/%d/%d errors)\n", | 		uprintf("Check completed, %u bad block%s found. (%d/%d/%d errors)\n", | ||||||
| 			report.bb_count, report.num_read_errors, report.num_write_errors, report.num_corruption_errors); | 			report.bb_count, (report.bb_count==1)?"":"s", | ||||||
|  | 			report.num_read_errors, report.num_write_errors, report.num_corruption_errors); | ||||||
|  | 		safe_sprintf(bb_msg, sizeof(bb_msg), "Check completed - %u bad block%s found:\n" | ||||||
|  | 			"  %d read errors\n  %d write errors\n  %d corruption errors", | ||||||
|  | 			report.bb_count, (report.bb_count==1)?"":"s", | ||||||
|  | 			report.num_read_errors, report.num_write_errors,  | ||||||
|  | 			report.num_corruption_errors); | ||||||
|  | 		switch(MessageBoxA(hMainDialog, bb_msg, "Bad blocks check", | ||||||
|  | 			report.bb_count?(MB_ABORTRETRYIGNORE|MB_ICONWARNING):(MB_OK|MB_ICONINFORMATION))) { | ||||||
|  | 		case IDRETRY:  | ||||||
|  | 			goto bb_retry; | ||||||
|  | 		case IDABORT: | ||||||
|  | 			FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED; | ||||||
|  | 			goto out; | ||||||
|  | 		} | ||||||
| 		safe_unlockclose(hLogicalVolume); | 		safe_unlockclose(hLogicalVolume); | ||||||
| 
 |  | ||||||
| 		// TODO: check bb_count and ask user if they want to continue
 |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Especially after destructive badblocks test, you must zero the MBR completely
 | 	// Especially after destructive badblocks test, you must zero the MBR completely
 | ||||||
|  | @ -398,7 +411,7 @@ void __cdecl FormatThread(void* param) | ||||||
| 	// TODO: use progress bar during MBR/FSBR/MSDOS copy
 | 	// TODO: use progress bar during MBR/FSBR/MSDOS copy
 | ||||||
| 	// TODO: unlock/remount trick to make the volume reappear
 | 	// TODO: unlock/remount trick to make the volume reappear
 | ||||||
| 
 | 
 | ||||||
| 	PrintStatus("Writing master boot record...\n"); | 	PrintStatus(0, "Writing master boot record...\n"); | ||||||
| 	if (!WriteMBR(hPhysicalDrive)) { | 	if (!WriteMBR(hPhysicalDrive)) { | ||||||
| 		// Errorcode has already been set
 | 		// Errorcode has already been set
 | ||||||
| 		goto out; | 		goto out; | ||||||
|  | @ -412,14 +425,14 @@ void __cdecl FormatThread(void* param) | ||||||
| 			FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; | 			FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; | ||||||
| 			goto out; | 			goto out; | ||||||
| 		} | 		} | ||||||
| 		PrintStatus("Writing partition boot record...\n"); | 		PrintStatus(0, "Writing partition boot record...\n"); | ||||||
| 		if (!WritePBR(hLogicalVolume)) { | 		if (!WritePBR(hLogicalVolume)) { | ||||||
| 			// Errorcode has already been set
 | 			// Errorcode has already been set
 | ||||||
| 			goto out; | 			goto out; | ||||||
| 		} | 		} | ||||||
| 		// ... and we must have relinquished that lock to write the MS-DOS files 
 | 		// ... and we must have relinquished that lock to write the MS-DOS files 
 | ||||||
| 		safe_unlockclose(hLogicalVolume); | 		safe_unlockclose(hLogicalVolume); | ||||||
| 		PrintStatus("Copying MS-DOS files...\n"); | 		PrintStatus(0, "Copying MS-DOS files...\n"); | ||||||
| 		if (!ExtractMSDOS(drive_name)) { | 		if (!ExtractMSDOS(drive_name)) { | ||||||
| 			FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANNOT_COPY; | 			FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANNOT_COPY; | ||||||
| 			goto out; | 			goto out; | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								src/rufus.c
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								src/rufus.c
									
										
									
									
									
								
							|  | @ -396,7 +396,7 @@ BOOL CreatePartition(HANDLE hDrive) | ||||||
| 	BOOL r; | 	BOOL r; | ||||||
| 	DWORD size; | 	DWORD size; | ||||||
| 
 | 
 | ||||||
| 	PrintStatus("Partitioning..."); | 	PrintStatus(0, "Partitioning..."); | ||||||
| 	DriveLayoutEx->PartitionStyle = PARTITION_STYLE_MBR; | 	DriveLayoutEx->PartitionStyle = PARTITION_STYLE_MBR; | ||||||
| 	DriveLayoutEx->PartitionCount = 4;	// Must be multiple of 4 for MBR
 | 	DriveLayoutEx->PartitionCount = 4;	// Must be multiple of 4 for MBR
 | ||||||
| 	DriveLayoutEx->Mbr.Signature = GetTickCount(); | 	DriveLayoutEx->Mbr.Signature = GetTickCount(); | ||||||
|  | @ -591,7 +591,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 	char str[MAX_PATH], tmp[128]; | 	char str[MAX_PATH], tmp[128]; | ||||||
| 	static uintptr_t format_thid = -1L; | 	static uintptr_t format_thid = -1L; | ||||||
| 	static HWND hProgress, hDOS; | 	static HWND hProgress, hDOS; | ||||||
| 	static LONG ProgressStyle = 0; | //	static LONG ProgressStyle = 0;
 | ||||||
| 	static UINT uDOSChecked = BST_CHECKED; | 	static UINT uDOSChecked = BST_CHECKED; | ||||||
| 
 | 
 | ||||||
| 	switch (message) { | 	switch (message) { | ||||||
|  | @ -626,7 +626,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 		hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, | 		hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, | ||||||
| 			0, 0, 0, 0, hMainDialog, (HMENU)IDC_STATUS,  hMainInstance, NULL); | 			0, 0, 0, 0, hMainDialog, (HMENU)IDC_STATUS,  hMainInstance, NULL); | ||||||
| 		// We'll switch the progressbar to marquee and back => keep a copy of current style
 | 		// We'll switch the progressbar to marquee and back => keep a copy of current style
 | ||||||
| 		ProgressStyle = GetWindowLong(hProgress, GWL_STYLE); | //		ProgressStyle = GetWindowLong(hProgress, GWL_STYLE);
 | ||||||
| 		// Create the string array
 | 		// Create the string array
 | ||||||
| 		StrArrayCreate(&DriveID, MAX_DRIVES); | 		StrArrayCreate(&DriveID, MAX_DRIVES); | ||||||
| 		StrArrayCreate(&DriveLabel, MAX_DRIVES); | 		StrArrayCreate(&DriveLabel, MAX_DRIVES); | ||||||
|  | @ -647,7 +647,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 					// Operation may have completed in the meantime
 | 					// Operation may have completed in the meantime
 | ||||||
| 					if (format_thid != -1L) { | 					if (format_thid != -1L) { | ||||||
| 						FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED; | 						FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED; | ||||||
| 						PrintStatus("Cancelling - please wait..."); | 						PrintStatus(0, "Cancelling - please wait..."); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				return (INT_PTR)TRUE; | 				return (INT_PTR)TRUE; | ||||||
|  | @ -664,7 +664,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 		case IDC_DEVICE: | 		case IDC_DEVICE: | ||||||
| 			switch (HIWORD(wParam)) { | 			switch (HIWORD(wParam)) { | ||||||
| 			case CBN_SELCHANGE: | 			case CBN_SELCHANGE: | ||||||
| 				PrintStatus("%d device%s found.", ComboBox_GetCount(hDeviceList), | 				PrintStatus(0, "%d device%s found.", ComboBox_GetCount(hDeviceList), | ||||||
| 					(ComboBox_GetCount(hDeviceList)!=1)?"s":""); | 					(ComboBox_GetCount(hDeviceList)!=1)?"s":""); | ||||||
| 				PopulateProperties(ComboBox_GetCurSel(hDeviceList)); | 				PopulateProperties(ComboBox_GetCurSel(hDeviceList)); | ||||||
| 				break; | 				break; | ||||||
|  | @ -755,12 +755,12 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 		EnableControls(TRUE); | 		EnableControls(TRUE); | ||||||
| 		GetUSBDevices(); | 		GetUSBDevices(); | ||||||
| 		if (!IS_ERROR(FormatStatus)) { | 		if (!IS_ERROR(FormatStatus)) { | ||||||
| 			PrintStatus("DONE"); | 			PrintStatus(0, "DONE"); | ||||||
| 		} else if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) { | 		} else if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) { | ||||||
| 			PrintStatus("Cancelled"); | 			PrintStatus(0, "Cancelled"); | ||||||
| 			Notification(MSG_INFO, "Cancelled", "Operation cancelled by the user."); | 			Notification(MSG_INFO, "Cancelled", "Operation cancelled by the user."); | ||||||
| 		} else { | 		} else { | ||||||
| 			PrintStatus("FAILED"); | 			PrintStatus(0, "FAILED"); | ||||||
| 			Notification(MSG_ERROR, "Error", "Error: %s", StrError(FormatStatus)); | 			Notification(MSG_ERROR, "Error", "Error: %s", StrError(FormatStatus)); | ||||||
| 		} | 		} | ||||||
| 		return (INT_PTR)TRUE; | 		return (INT_PTR)TRUE; | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.h
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.h
									
										
									
									
									
								
							|  | @ -76,12 +76,18 @@ enum user_message_type { | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /* Custom notifications */ | /* Custom notifications */ | ||||||
| enum MessageType { | enum notification_type { | ||||||
| 	MSG_INFO, | 	MSG_INFO, | ||||||
| 	MSG_WARNING, | 	MSG_WARNING, | ||||||
| 	MSG_ERROR | 	MSG_ERROR | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | /* Timers used throughout the program */ | ||||||
|  | enum timer_id { | ||||||
|  | 	PRINTSTATUS_TIMER_ID = 0x1000, | ||||||
|  | 	BADBLOCK_TIMER_ID | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| /* File system indexes in our FS combobox */ | /* File system indexes in our FS combobox */ | ||||||
| // TODO: FormatEx should support "NTFS", "FAT", "FAT32", "UDF", and "EXFAT" as per
 | // TODO: FormatEx should support "NTFS", "FAT", "FAT32", "UDF", and "EXFAT" as per
 | ||||||
| // http://msdn.microsoft.com/en-us/library/windows/desktop/aa819439.aspx
 | // http://msdn.microsoft.com/en-us/library/windows/desktop/aa819439.aspx
 | ||||||
|  | @ -124,7 +130,7 @@ extern RUFUS_DRIVE_INFO SelectedDrive; | ||||||
|  */ |  */ | ||||||
| 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 PrintStatus(const char *format, ...); | extern void PrintStatus(unsigned int duration, const char *format, ...); | ||||||
| extern const char* StrError(DWORD error_code); | extern const char* StrError(DWORD error_code); | ||||||
| extern void CenterDialog(HWND hDlg); | extern void CenterDialog(HWND hDlg); | ||||||
| extern void CreateStatusBar(void); | extern void CreateStatusBar(void); | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 206, 278 | IDD_DIALOG DIALOGEX 12, 12, 206, 278 | ||||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||||
| EXSTYLE WS_EX_APPWINDOW | EXSTYLE WS_EX_APPWINDOW | ||||||
| CAPTION "Rufus v1.0.2.82 (Beta)" | CAPTION "Rufus v1.0.2.83 (Beta)" | ||||||
| FONT 8, "MS Shell Dlg", 400, 0, 0x1 | FONT 8, "MS Shell Dlg", 400, 0, 0x1 | ||||||
| BEGIN | BEGIN | ||||||
|     DEFPUSHBUTTON   "Start",IDC_START,94,236,50,14 |     DEFPUSHBUTTON   "Start",IDC_START,94,236,50,14 | ||||||
|  | @ -65,7 +65,7 @@ BEGIN | ||||||
|     DEFPUSHBUTTON   "OK",IDOK,231,175,50,14,WS_GROUP |     DEFPUSHBUTTON   "OK",IDOK,231,175,50,14,WS_GROUP | ||||||
|     CONTROL         "<a href=""https://github.com/pbatard/rufus/wiki/Rufus"">https://github.com/pbatard/rufus</a>",IDC_ABOUT_RUFUS_URL, |     CONTROL         "<a href=""https://github.com/pbatard/rufus/wiki/Rufus"">https://github.com/pbatard/rufus</a>",IDC_ABOUT_RUFUS_URL, | ||||||
|                     "SysLink",WS_TABSTOP,46,47,114,9 |                     "SysLink",WS_TABSTOP,46,47,114,9 | ||||||
|     LTEXT           "Version 1.0.2 (Build 82)",IDC_STATIC,46,19,78,8 |     LTEXT           "Version 1.0.2 (Build 83)",IDC_STATIC,46,19,78,8 | ||||||
|     PUSHBUTTON      "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP |     PUSHBUTTON      "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP | ||||||
|     EDITTEXT        IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL |     EDITTEXT        IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL | ||||||
|     LTEXT           "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 |     LTEXT           "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 | ||||||
|  | @ -164,8 +164,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 1,0,2,82 |  FILEVERSION 1,0,2,83 | ||||||
|  PRODUCTVERSION 1,0,2,82 |  PRODUCTVERSION 1,0,2,83 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -182,13 +182,13 @@ BEGIN | ||||||
|         BEGIN |         BEGIN | ||||||
|             VALUE "CompanyName", "akeo.ie" |             VALUE "CompanyName", "akeo.ie" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "1.0.2.82" |             VALUE "FileVersion", "1.0.2.83" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011 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", "1.0.2.82" |             VALUE "ProductVersion", "1.0.2.83" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
							
								
								
									
										34
									
								
								src/stdio.c
									
										
									
									
									
								
							
							
						
						
									
										34
									
								
								src/stdio.c
									
										
									
									
									
								
							|  | @ -122,24 +122,46 @@ static char err_string[256]; | ||||||
| 	return err_string; | 	return err_string; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PrintStatus(const char *format, ...) | /*
 | ||||||
|  |  * Display a message on the status bar. If duration is non zero, ensures that message | ||||||
|  |  * is displayed for at least duration ms regardless, regardless of any other incoming | ||||||
|  |  * message | ||||||
|  |  */ | ||||||
|  | static BOOL bStatusTimerArmed = FALSE; | ||||||
|  | static char szStatusMessage[256] = { 0 }; | ||||||
|  | static void CALLBACK PrintStatusTimeout(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) | ||||||
| { | { | ||||||
| 	char buf[256], *p = buf; | 	bStatusTimerArmed = FALSE; | ||||||
|  | 	// potentially display lower priority message that was overridden
 | ||||||
|  | 	SetDlgItemTextU(hMainDialog, IDC_STATUS, szStatusMessage); | ||||||
|  | 	KillTimer(hMainDialog, PRINTSTATUS_TIMER_ID); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void PrintStatus(unsigned int duration, const char *format, ...) | ||||||
|  | { | ||||||
|  | 	char *p = szStatusMessage; | ||||||
| 	va_list args; | 	va_list args; | ||||||
| 	int n; | 	int n; | ||||||
| 
 | 
 | ||||||
| 	va_start(args, format); | 	va_start(args, format); | ||||||
| 	n = safe_vsnprintf(p, sizeof(buf)-1, format, args); // room for NUL
 | 	n = safe_vsnprintf(p, sizeof(szStatusMessage)-1, format, args); // room for NUL
 | ||||||
| 	va_end(args); | 	va_end(args); | ||||||
| 
 | 
 | ||||||
| 	p += (n < 0)?sizeof(buf)-1:n; | 	p += (n < 0)?sizeof(szStatusMessage)-1:n; | ||||||
| 
 | 
 | ||||||
| 	while((p>buf) && (isspace(p[-1]))) | 	while((p>szStatusMessage) && (isspace(p[-1]))) | ||||||
| 		*--p = '\0'; | 		*--p = '\0'; | ||||||
| 
 | 
 | ||||||
| 	*p   = '\0'; | 	*p   = '\0'; | ||||||
| 
 | 
 | ||||||
| 	SetDlgItemTextU(hMainDialog, IDC_STATUS, buf); | 	if ((duration) || (!bStatusTimerArmed)) { | ||||||
|  | 		SetDlgItemTextU(hMainDialog, IDC_STATUS, szStatusMessage); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if (duration) { | ||||||
|  | 		SetTimer(hMainDialog, PRINTSTATUS_TIMER_ID, duration, PrintStatusTimeout); | ||||||
|  | 		bStatusTimerArmed = TRUE; | ||||||
|  | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const char* StrError(DWORD error_code) | const char* StrError(DWORD error_code) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue