From af53d117180c0c2c3663923b89052f759d7dccee Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 1 Oct 2015 22:22:20 +0100 Subject: [PATCH] [misc] add a cheat mode to not lock the physical drive during partitioning and formatting * In some circumstances, this *might* help with the infamous #312 issue, though I will still recommend to figure out which application is keeping a lock instead of trying to cheat... --- res/localization/rufus.loc | 1 + src/format.c | 4 ++-- src/localization_data.h | 1 + src/resource.h | 3 ++- src/rufus.c | 8 +++++++- src/rufus.rc | 10 +++++----- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/res/localization/rufus.loc b/res/localization/rufus.loc index ab175977..aeefd7c5 100644 --- a/res/localization/rufus.loc +++ b/res/localization/rufus.loc @@ -538,6 +538,7 @@ t MSG_278 "Boot type" t MSG_279 "Non bootable" t MSG_280 "Image selection" t MSG_281 "(Please select an image)" +t MSG_282 "Drive locking" ################################################################################ ############################# TRANSLATOR END COPY ############################## diff --git a/src/format.c b/src/format.c index 28540048..86b5d136 100644 --- a/src/format.c +++ b/src/format.c @@ -59,7 +59,7 @@ static int task_number = 0; extern const int nb_steps[FS_MAX]; extern uint32_t dur_mins, dur_secs; static int fs_index = 0; -extern BOOL force_large_fat32, enable_ntfs_compression; +extern BOOL force_large_fat32, enable_ntfs_compression, lock_drive; uint8_t *grub2_buf = NULL; long grub2_len; static BOOL WritePBR(HANDLE hLogicalDrive); @@ -1522,7 +1522,7 @@ DWORD WINAPI FormatThread(void* param) extra_partitions = XP_COMPAT; PrintInfoDebug(0, MSG_225); - hPhysicalDrive = GetPhysicalHandle(DriveIndex, TRUE, TRUE); + hPhysicalDrive = GetPhysicalHandle(DriveIndex, TRUE, lock_drive); if (hPhysicalDrive == INVALID_HANDLE_VALUE) { FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; goto out; diff --git a/src/localization_data.h b/src/localization_data.h index 52596676..c63d47d9 100644 --- a/src/localization_data.h +++ b/src/localization_data.h @@ -391,6 +391,7 @@ const loc_control_id control_id[] = { LOC_CTRL(MSG_279), LOC_CTRL(MSG_280), LOC_CTRL(MSG_281), + LOC_CTRL(MSG_282), LOC_CTRL(MSG_MAX), LOC_CTRL(IDOK), LOC_CTRL(IDCANCEL), diff --git a/src/resource.h b/src/resource.h index 9d41a04c..7ebe5847 100644 --- a/src/resource.h +++ b/src/resource.h @@ -429,7 +429,8 @@ #define MSG_279 3279 #define MSG_280 3280 #define MSG_281 3281 -#define MSG_MAX 3282 +#define MSG_282 3282 +#define MSG_MAX 3283 // Next default values for new objects // diff --git a/src/rufus.c b/src/rufus.c index d4f7214f..64a2db98 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -138,7 +138,7 @@ HWND hDeviceList, hPartitionScheme, hFileSystem, hClusterSize, hLabel, hBootType HWND hLogDlg = NULL, hProgress = NULL, hInfo, hDiskID, hStatusToolbar; BOOL use_own_c32[NB_OLD_C32] = {FALSE, FALSE}, mbr_selected_by_user = FALSE, togo_mode; BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE, right_to_left_mode = FALSE; -BOOL enable_HDDs = FALSE, force_update = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE; +BOOL enable_HDDs = FALSE, force_update = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE, lock_drive = TRUE; BOOL advanced_mode, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug, use_fake_units, preserve_timestamps; int dialog_showing = 0, lang_button_id = 0; uint16_t rufus_version[3], embedded_sl_version[2]; @@ -3018,6 +3018,12 @@ relaunch: GetUSBDevices(0); continue; } + // Alt-, => Disable physical drive locking + if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == VK_OEM_COMMA)) { + lock_drive = !lock_drive; + PrintStatus2000(lmprintf(MSG_282), lock_drive); + continue; + } // Alt-B => Toggle fake drive detection during bad blocks check // By default, Rufus will check for fake USB flash drives that mistakenly present // more capacity than they already have by looping over the flash. This check which diff --git a/src/rufus.rc b/src/rufus.rc index 24703274..22d12266 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rufus 2.5.762" +CAPTION "Rufus 2.5.763" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -319,8 +319,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,5,762,0 - PRODUCTVERSION 2,5,762,0 + FILEVERSION 2,5,763,0 + PRODUCTVERSION 2,5,763,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -337,13 +337,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.5.762" + VALUE "FileVersion", "2.5.763" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.5.762" + VALUE "ProductVersion", "2.5.763" END END BLOCK "VarFileInfo"