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

[misc] refactor the "operation in progress" detection

* Remove unused iso_op_in_progress and use a single op_in_progress that gets
  set when we disable the controls.
* Also fix an issue where Ctrl-L was being processed as Alt-L due yet another
  completely backwards Windows behaviour where the message that is meant to
  indicating whether Alt is pressed is also sometimes used to indicate that
  another key is being pressed if the dialog doesn't have keyboard focus...
This commit is contained in:
Pete Batard 2019-08-22 14:04:41 +01:00
parent af95de8198
commit 21351b9fbe
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
5 changed files with 303 additions and 310 deletions

View file

@ -641,7 +641,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
do { do {
for (i=0; (i<30) && (!force_update_check); i++) for (i=0; (i<30) && (!force_update_check); i++)
Sleep(500); Sleep(500);
} while ((!force_update_check) && ((iso_op_in_progress || format_op_in_progress || (dialog_showing>0)))); } while ((!force_update_check) && ((op_in_progress || (dialog_showing > 0))));
if (!force_update_check) { if (!force_update_check) {
if ((ReadSetting32(SETTING_UPDATE_INTERVAL) == -1)) { if ((ReadSetting32(SETTING_UPDATE_INTERVAL) == -1)) {
vuprintf("Check for updates disabled, as per settings."); vuprintf("Check for updates disabled, as per settings.");
@ -829,7 +829,7 @@ out:
// Start the new download after cleanup // Start the new download after cleanup
if (found_new_version) { if (found_new_version) {
// User may have started an operation while we were checking // User may have started an operation while we were checking
while ((!force_update_check) && (iso_op_in_progress || format_op_in_progress || (dialog_showing > 0))) { while ((!force_update_check) && (op_in_progress || (dialog_showing > 0))) {
Sleep(15000); Sleep(15000);
} }
DownloadNewVersion(); DownloadNewVersion();
@ -994,7 +994,6 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
// Download the ISO and report errors if any // Download the ISO and report errors if any
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0); SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
FormatStatus = 0; FormatStatus = 0;
format_op_in_progress = TRUE;
SendMessage(hMainDialog, UM_TIMER_START, 0, 0); SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
if (DownloadToFileOrBuffer(url, img_save.ImagePath, NULL, hMainDialog, TRUE) == 0) { if (DownloadToFileOrBuffer(url, img_save.ImagePath, NULL, hMainDialog, TRUE) == 0) {
SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0); SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0);
@ -1011,7 +1010,6 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
image_path = safe_strdup(img_save.ImagePath); image_path = safe_strdup(img_save.ImagePath);
PostMessage(hMainDialog, UM_SELECT_ISO, 0, 0); PostMessage(hMainDialog, UM_SELECT_ISO, 0, 0);
} }
format_op_in_progress = FALSE;
safe_free(img_save.ImagePath); safe_free(img_save.ImagePath);
} }
} }

View file

@ -103,7 +103,7 @@ HWND hDeviceList, hPartitionScheme, hTargetSystem, hFileSystem, hClusterSize, hL
HWND hLogDialog = NULL, hProgress = NULL, hDiskID; HWND hLogDialog = NULL, hProgress = NULL, hDiskID;
HANDLE dialog_handle = NULL; HANDLE dialog_handle = NULL;
BOOL is_x86_32, use_own_c32[NB_OLD_C32] = { FALSE, FALSE }, mbr_selected_by_user = FALSE; BOOL is_x86_32, use_own_c32[NB_OLD_C32] = { FALSE, FALSE }, mbr_selected_by_user = FALSE;
BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE, right_to_left_mode = FALSE, has_uefi_csm; BOOL op_in_progress = TRUE, right_to_left_mode = FALSE, has_uefi_csm;
BOOL enable_HDDs = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE, lock_drive = TRUE; BOOL enable_HDDs = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE, lock_drive = TRUE;
BOOL advanced_mode_device, advanced_mode_format, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug; 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 use_fake_units, preserve_timestamps = FALSE, fast_zeroing = FALSE, app_changed_size = FALSE;
@ -791,6 +791,8 @@ static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes)
// Toggle controls according to operation // Toggle controls according to operation
static void EnableControls(BOOL enable, BOOL remove_checkboxes) static void EnableControls(BOOL enable, BOOL remove_checkboxes)
{ {
op_in_progress = !enable;
// The following only get disabled on format/checksum and otherwise remain enabled, // The following only get disabled on format/checksum and otherwise remain enabled,
// even if no device or image are selected // even if no device or image are selected
EnableWindow(hDeviceList, enable); EnableWindow(hDeviceList, enable);
@ -1074,7 +1076,6 @@ DWORD WINAPI ISOScanThread(LPVOID param)
if (image_path == NULL) if (image_path == NULL)
goto out; goto out;
format_op_in_progress = TRUE;
PrintInfoDebug(0, MSG_202); PrintInfoDebug(0, MSG_202);
user_notified = FALSE; user_notified = FALSE;
EnableControls(FALSE, FALSE); EnableControls(FALSE, FALSE);
@ -1158,7 +1159,6 @@ DWORD WINAPI ISOScanThread(LPVOID param)
out: out:
dont_display_image_name = FALSE; dont_display_image_name = FALSE;
format_op_in_progress = FALSE;
PrintInfo(0, MSG_210); PrintInfo(0, MSG_210);
ExitThread(0); ExitThread(0);
} }
@ -1727,9 +1727,10 @@ static void SaveVHD(void)
EXT_DECL(img_ext, filename, __VA_GROUP__("*.vhd"), __VA_GROUP__(lmprintf(MSG_095))); EXT_DECL(img_ext, filename, __VA_GROUP__("*.vhd"), __VA_GROUP__(lmprintf(MSG_095)));
ULARGE_INTEGER free_space; ULARGE_INTEGER free_space;
if (DriveIndex >= 0) if ((DriveIndex < 0) || (format_thid != NULL))
return;
static_sprintf(filename, "%s.vhd", DriveLabel.String[DriveIndex]); static_sprintf(filename, "%s.vhd", DriveLabel.String[DriveIndex]);
if ((DriveIndex != CB_ERR) && (!format_op_in_progress) && (format_thid == NULL)) {
img_save.Type = IMG_SAVE_TYPE_VHD; img_save.Type = IMG_SAVE_TYPE_VHD;
img_save.DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, DriveIndex); img_save.DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, DriveIndex);
img_save.ImagePath = FileDialog(TRUE, NULL, &img_ext, 0); img_save.ImagePath = FileDialog(TRUE, NULL, &img_ext, 0);
@ -1739,7 +1740,6 @@ static void SaveVHD(void)
// Reset all progress bars // Reset all progress bars
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0); SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
FormatStatus = 0; FormatStatus = 0;
format_op_in_progress = TRUE;
free_space.QuadPart = 0; free_space.QuadPart = 0;
if ((GetVolumePathNameA(img_save.ImagePath, path, sizeof(path))) if ((GetVolumePathNameA(img_save.ImagePath, path, sizeof(path)))
&& (GetDiskFreeSpaceExA(path, &free_space, NULL, NULL)) && (GetDiskFreeSpaceExA(path, &free_space, NULL, NULL))
@ -1758,7 +1758,6 @@ static void SaveVHD(void)
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD); FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
safe_free(img_save.ImagePath); safe_free(img_save.ImagePath);
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0); PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
format_op_in_progress = FALSE;
} }
} else { } else {
if (free_space.QuadPart == 0) { if (free_space.QuadPart == 0) {
@ -1770,8 +1769,6 @@ static void SaveVHD(void)
} }
safe_free(img_save.ImagePath); safe_free(img_save.ImagePath);
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0); PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
format_op_in_progress = FALSE;
}
} }
} }
} }
@ -1782,7 +1779,7 @@ static void SaveISO(void)
char filename[33] = "disc_image.iso"; char filename[33] = "disc_image.iso";
EXT_DECL(img_ext, filename, __VA_GROUP__("*.iso"), __VA_GROUP__(lmprintf(MSG_036))); EXT_DECL(img_ext, filename, __VA_GROUP__("*.iso"), __VA_GROUP__(lmprintf(MSG_036)));
if ((format_op_in_progress) || (format_thid != NULL)) if (op_in_progress || (format_thid != NULL))
return; return;
img_save.Type = IMG_SAVE_TYPE_ISO; img_save.Type = IMG_SAVE_TYPE_ISO;
@ -1803,7 +1800,6 @@ static void SaveISO(void)
return; return;
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0); SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
FormatStatus = 0; FormatStatus = 0;
format_op_in_progress = TRUE;
// Disable all controls except cancel // Disable all controls except cancel
EnableControls(FALSE, FALSE); EnableControls(FALSE, FALSE);
InitProgress(TRUE); InitProgress(TRUE);
@ -1817,7 +1813,6 @@ static void SaveISO(void)
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD); FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
safe_free(img_save.ImagePath); safe_free(img_save.ImagePath);
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0); PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
format_op_in_progress = FALSE;
} }
} }
@ -1979,7 +1974,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
} }
no_confirmation_on_cancel = FALSE; no_confirmation_on_cancel = FALSE;
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
} else if (format_op_in_progress) { } else if (op_in_progress) {
// User might be trying to cancel during preliminary checks // User might be trying to cancel during preliminary checks
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED;
PrintInfo(0, MSG_201); PrintInfo(0, MSG_201);
@ -2228,7 +2223,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
} }
} }
FormatStatus = 0; FormatStatus = 0;
format_op_in_progress = FALSE;
if (CreateThread(NULL, 0, ISOScanThread, NULL, 0, NULL) == NULL) { if (CreateThread(NULL, 0, ISOScanThread, NULL, 0, NULL) == NULL) {
uprintf("Unable to start ISO scanning thread"); uprintf("Unable to start ISO scanning 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);
@ -2261,7 +2255,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
FormatStatus = 0; FormatStatus = 0;
LastWriteError = 0; LastWriteError = 0;
StrArrayClear(&BlockingProcess); StrArrayClear(&BlockingProcess);
format_op_in_progress = TRUE;
no_confirmation_on_cancel = FALSE; no_confirmation_on_cancel = FALSE;
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0); SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
selection_default = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); selection_default = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
@ -2286,7 +2279,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case IDC_HASH: case IDC_HASH:
if ((format_thid == NULL) && (image_path != NULL)) { if ((format_thid == NULL) && (image_path != NULL)) {
FormatStatus = 0; FormatStatus = 0;
format_op_in_progress = TRUE;
no_confirmation_on_cancel = TRUE; no_confirmation_on_cancel = TRUE;
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0); SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
// Disable all controls except cancel // Disable all controls except cancel
@ -2301,7 +2293,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
uprintf("Unable to start checksum thread"); uprintf("Unable to start checksum 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);
format_op_in_progress = FALSE;
} }
} }
break; break;
@ -2373,7 +2364,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case DBT_CUSTOMEVENT: // Sent by our timer refresh function or for card reader media change case DBT_CUSTOMEVENT: // Sent by our timer refresh function or for card reader media change
LastRefresh = GetTickCount64(); LastRefresh = GetTickCount64();
KillTimer(hMainDialog, TID_REFRESH_TIMER); KillTimer(hMainDialog, TID_REFRESH_TIMER);
if (!format_op_in_progress) { if (!op_in_progress) {
queued_hotplug_event = FALSE; queued_hotplug_event = FALSE;
GetDevices((DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList))); GetDevices((DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList)));
user_changed_label = FALSE; user_changed_label = FALSE;
@ -2564,7 +2555,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case WM_CLIENTSHUTDOWN: case WM_CLIENTSHUTDOWN:
case WM_QUERYENDSESSION: case WM_QUERYENDSESSION:
case WM_ENDSESSION: case WM_ENDSESSION:
if (format_op_in_progress) { if (op_in_progress) {
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
} }
if (message == WM_CLOSE) { if (message == WM_CLOSE) {
@ -2692,7 +2683,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
if (format_thid != NULL) if (format_thid != NULL)
break; break;
aborted_start: aborted_start:
format_op_in_progress = FALSE;
EnableControls(TRUE, FALSE); EnableControls(TRUE, FALSE);
zero_drive = FALSE; zero_drive = FALSE;
if (queued_hotplug_event) if (queued_hotplug_event)
@ -2781,7 +2771,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
} }
FormatStatus = 0; FormatStatus = 0;
LastWriteError = 0; LastWriteError = 0;
format_op_in_progress = FALSE;
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
} }
@ -3243,13 +3232,15 @@ relaunch:
// Do our own event processing and process "magic" commands // Do our own event processing and process "magic" commands
while(GetMessage(&msg, NULL, 0, 0)) { while(GetMessage(&msg, NULL, 0, 0)) {
static BOOL ctrl_without_focus = FALSE;
BOOL no_focus = (msg.message == WM_SYSKEYDOWN) && !(msg.lParam & 0x20000000);
// ** ***** **** ** ********** // ** ***** **** ** **********
// .,ABCDEFGHIJKLMNOPQRSTUVWXYZ // .,ABCDEFGHIJKLMNOPQRSTUVWXYZ
// Sigh... The things one need to do to detect standalone use of the 'Alt' key. // Sigh... The things one need to do to detect standalone use of the 'Alt' key.
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam != VK_MENU)) if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam != VK_MENU))
alt_command = TRUE; alt_command = TRUE;
else if (GetAsyncKeyState(VK_MENU)) else if (GetKeyState(VK_MENU) & 0x8000)
alt_pressed = TRUE; alt_pressed = TRUE;
// Ctrl-A => Select the log data // Ctrl-A => Select the log data
@ -3259,11 +3250,33 @@ relaunch:
Edit_SetSel(hLog, 0, -1); Edit_SetSel(hLog, 0, -1);
continue; continue;
} }
// Detecting Ctrl combination keypress while an operation is in progress is a super-mess
// because Windows considers that our dialog doesn't have keyboard focus (WHYYYYYY?!?!?)
// and therefore first sends a WM_SYSKEYDOWN (i.e. the message that is supposed to tell
// you that Alt is being pressed, because why not also use it for a COMPLETELY DIFFERENT
// FRIGGING KEY!!!) with bit 29 of msg.lParam cleared, along with the code for the Ctrl
// key and *THEN* a subsequent message (still using WM_SYSKEYDOWN without Alt) with the
// other key. So we need to detect both the messages in sequence...
if (no_focus && (msg.wParam == VK_CONTROL))
ctrl_without_focus = op_in_progress;
// Ctrl-L => Open/Close the log // Ctrl-L => Open/Close the log
if ((GetKeyState(VK_CONTROL) & 0x8000) && (msg.message == WM_KEYDOWN) && (msg.wParam == 'L')) { if ((ctrl_without_focus || ((GetKeyState(VK_CONTROL) & 0x8000) && (msg.message == WM_KEYDOWN)))
&& (msg.wParam == 'L')) {
ctrl_without_focus = FALSE;
SendMessage(hMainDialog, WM_COMMAND, IDC_LOG, 0); SendMessage(hMainDialog, WM_COMMAND, IDC_LOG, 0);
continue; continue;
} }
if (no_focus && (msg.wParam != VK_CONTROL))
ctrl_without_focus = FALSE;
if (no_focus)
continue;
// The following cheat modes should not be enacted when an operation is in progress
if (!op_in_progress) {
// Alt-. => Enable USB enumeration debug // Alt-. => Enable USB enumeration debug
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == VK_OEM_PERIOD)) { if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == VK_OEM_PERIOD)) {
usb_debug = !usb_debug; usb_debug = !usb_debug;
@ -3352,6 +3365,11 @@ relaunch:
} }
// Alt-L => Force Large FAT32 format to be used on < 32 GB drives // Alt-L => Force Large FAT32 format to be used on < 32 GB drives
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'L')) { if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'L')) {
uprintf("DAFUQ!?!? LPARAM = 0x%08X", msg.lParam);
if ((msg.message == WM_SYSKEYDOWN) && !(msg.lParam & 0x20000000)) {
uprintf("KIDDING ME?!?!.");
}
force_large_fat32 = !force_large_fat32; force_large_fat32 = !force_large_fat32;
WriteSettingBool(SETTING_FORCE_LARGE_FAT32_FORMAT, force_large_fat32); WriteSettingBool(SETTING_FORCE_LARGE_FAT32_FORMAT, force_large_fat32);
PrintStatusTimeout(lmprintf(MSG_254), force_large_fat32); PrintStatusTimeout(lmprintf(MSG_254), force_large_fat32);
@ -3484,10 +3502,11 @@ relaunch:
PrintStatusTimeout(lmprintf(MSG_259), force_update); PrintStatusTimeout(lmprintf(MSG_259), force_update);
continue; continue;
} }
}
// Standalone 'Alt' key toggles progress report between percent, rate (if available) // Standalone 'Alt' key toggles progress report between percent, rate (if available)
// and remaining time (if availabe) // and remaining time (if availabe)
if (alt_pressed && !GetAsyncKeyState(VK_MENU)) { if (alt_pressed && !(GetKeyState(VK_MENU) & 0x8000)) {
alt_pressed = FALSE; alt_pressed = FALSE;
if (!alt_command) if (!alt_command)
update_progress_type = (update_progress_type + 1) % UPT_MAX; update_progress_type = (update_progress_type + 1) % UPT_MAX;

View file

@ -444,7 +444,7 @@ extern HWND hPartitionScheme, hTargetSystem, hFileSystem, hClusterSize, hLabel,
extern HWND hInfo, hProgress, hDiskID; extern HWND hInfo, hProgress, hDiskID;
extern WORD selected_langid; extern WORD selected_langid;
extern DWORD FormatStatus, DownloadStatus, MainThreadId, LastWriteError; extern DWORD FormatStatus, DownloadStatus, MainThreadId, LastWriteError;
extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, iso_op_in_progress, format_op_in_progress, right_to_left_mode; extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, op_in_progress, right_to_left_mode;
extern BOOL allow_dual_uefi_bios, large_drive, usb_debug; extern BOOL allow_dual_uefi_bios, large_drive, usb_debug;
extern int64_t iso_blocking_status; extern int64_t iso_blocking_status;
extern uint8_t image_options; extern uint8_t image_options;
@ -481,7 +481,6 @@ extern const char* StrError(DWORD error_code, BOOL use_default_locale);
extern char* GuidToString(const GUID* guid); extern char* GuidToString(const GUID* guid);
extern char* SizeToHumanReadable(uint64_t size, BOOL copy_to_log, BOOL fake_units); extern char* SizeToHumanReadable(uint64_t size, BOOL copy_to_log, BOOL fake_units);
extern char* TimestampToHumanReadable(uint64_t ts); extern char* TimestampToHumanReadable(uint64_t ts);
extern char* RateToHumanReadable(uint64_t transferred, uint64_t total);
extern HWND MyCreateDialog(HINSTANCE hInstance, int Dialog_ID, HWND hWndParent, DLGPROC lpDialogFunc); extern HWND MyCreateDialog(HINSTANCE hInstance, int Dialog_ID, HWND hWndParent, DLGPROC lpDialogFunc);
extern INT_PTR MyDialogBox(HINSTANCE hInstance, int Dialog_ID, HWND hWndParent, DLGPROC lpDialogFunc); extern INT_PTR MyDialogBox(HINSTANCE hInstance, int Dialog_ID, HWND hWndParent, DLGPROC lpDialogFunc);
extern void CenterDialog(HWND hDlg, HWND hParent); extern void CenterDialog(HWND hDlg, HWND hParent);

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
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 3.7.1563" CAPTION "Rufus 3.7.1564"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -394,8 +394,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,7,1563,0 FILEVERSION 3,7,1564,0
PRODUCTVERSION 3,7,1563,0 PRODUCTVERSION 3,7,1564,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -413,13 +413,13 @@ BEGIN
VALUE "Comments", "https://akeo.ie" VALUE "Comments", "https://akeo.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.7.1563" VALUE "FileVersion", "3.7.1564"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus-3.7.exe" VALUE "OriginalFilename", "rufus-3.7.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.7.1563" VALUE "ProductVersion", "3.7.1564"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -695,29 +695,6 @@ char* TimestampToHumanReadable(uint64_t ts)
return str; return str;
} }
// TODO: Add granularity
char* RateToHumanReadable(uint64_t transferred, uint64_t total)
{
const uint64_t refresh_rate = 1000;
static uint64_t start_time, last_refresh = 0;
uint64_t current_time, rate;
if (total == 0) {
// init
start_time = GetTickCount64();
last_refresh = start_time;
} else {
current_time = GetTickCount64();
if (current_time <= start_time)
return NULL;
rate = (transferred * 1000) / (current_time - start_time);
if (current_time > last_refresh + refresh_rate) {
last_refresh = current_time;
uprintf("%s/s", SizeToHumanReadable(rate, FALSE, FALSE));
}
}
return NULL;
}
// Convert custom error code to messages // Convert custom error code to messages
const char* _StrError(DWORD error_code) const char* _StrError(DWORD error_code)
{ {