From 5d3be6ca51c0ccf22381de2131b6a71dc36bf289 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sat, 27 Aug 2016 18:04:54 +0100 Subject: [PATCH] [misc] add a cheat mode to disable file indexing after format * New cheat mode is Alt-Q, and gets preserved between sessions * Only for file systems that support it (NTFS, UDF and ReFS) --- res/localization/rufus.loc | 1 + src/format.c | 10 +++++++++- src/localization_data.h | 12 +++++++++++- src/resource.h | 12 +++++++++++- src/rufus.c | 13 ++++++++++++- src/rufus.rc | 10 +++++----- src/settings.h | 1 + 7 files changed, 50 insertions(+), 9 deletions(-) diff --git a/res/localization/rufus.loc b/res/localization/rufus.loc index de361dd6..99972a03 100644 --- a/res/localization/rufus.loc +++ b/res/localization/rufus.loc @@ -551,6 +551,7 @@ t MSG_286 "Zeroing drive: %0.1f%% completed" t MSG_287 "Detection of non-USB removable drives" t MSG_288 "Missing elevated privileges" t MSG_289 "This application can only run with elevated privileges" +t MSG_290 "File Indexing" ################################################################################ ############################# TRANSLATOR END COPY ############################## diff --git a/src/format.c b/src/format.c index 3d163ab7..bbfb0678 100644 --- a/src/format.c +++ b/src/format.c @@ -61,7 +61,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, lock_drive, zero_drive; +extern BOOL force_large_fat32, enable_ntfs_compression, lock_drive, zero_drive, disable_file_indexing; uint8_t *grub2_buf = NULL; long grub2_len; static BOOL WritePBR(HANDLE hLogicalDrive); @@ -1811,6 +1811,14 @@ DWORD WINAPI FormatThread(void* param) } CHECK_FOR_USER_CANCEL; + // Disable file indexing if the option was selected by the user + if ((disable_file_indexing) && ((fs == FS_NTFS) || (fs == FS_UDF) || (fs == FS_REFS))) { + if (SetFileAttributesA(guid_volume, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)) + uprintf("File indexing has been set to: Disabled"); + else + uprintf("Could not disable file indexing: %s", WindowsErrorString()); + } else + // Refresh the drive label - This is needed as Windows may have altered it from // the name we proposed, and we require an exact label, to patch config files. if (!GetVolumeInformationU(drive_name, img_report.usb_label, ARRAYSIZE(img_report.usb_label), diff --git a/src/localization_data.h b/src/localization_data.h index b277d29f..c6442fd6 100644 --- a/src/localization_data.h +++ b/src/localization_data.h @@ -1,7 +1,7 @@ /* * Rufus: The Reliable USB Formatting Utility * Localization tables - autogenerated from resource.h - * Copyright © 2013-2015 Pete Batard + * Copyright © 2013-2016 Pete Batard * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -399,6 +399,16 @@ const loc_control_id control_id[] = { LOC_CTRL(MSG_287), LOC_CTRL(MSG_288), LOC_CTRL(MSG_289), + LOC_CTRL(MSG_290), + LOC_CTRL(MSG_291), + LOC_CTRL(MSG_292), + LOC_CTRL(MSG_293), + LOC_CTRL(MSG_294), + LOC_CTRL(MSG_295), + LOC_CTRL(MSG_296), + LOC_CTRL(MSG_297), + LOC_CTRL(MSG_298), + LOC_CTRL(MSG_299), LOC_CTRL(MSG_MAX), LOC_CTRL(IDOK), LOC_CTRL(IDCANCEL), diff --git a/src/resource.h b/src/resource.h index b5fa74e2..1f1f9622 100644 --- a/src/resource.h +++ b/src/resource.h @@ -437,7 +437,17 @@ #define MSG_287 3287 #define MSG_288 3288 #define MSG_289 3289 -#define MSG_MAX 3290 +#define MSG_290 3290 +#define MSG_291 3291 +#define MSG_292 3292 +#define MSG_293 3293 +#define MSG_294 3294 +#define MSG_295 3295 +#define MSG_296 3296 +#define MSG_297 3297 +#define MSG_298 3298 +#define MSG_299 3299 +#define MSG_MAX 3300 // Next default values for new objects // diff --git a/src/rufus.c b/src/rufus.c index 7b9a2c42..579aa477 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -109,7 +109,7 @@ BOOL use_own_c32[NB_OLD_C32] = {FALSE, FALSE}, mbr_selected_by_user = FALSE, tog 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, lock_drive = TRUE; BOOL advanced_mode, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug, use_fake_units, preserve_timestamps; -BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE; +BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, disable_file_indexing; int dialog_showing = 0, lang_button_id = 0; uint16_t rufus_version[3], embedded_sl_version[2]; char embedded_sl_version_str[2][12] = { "?.??", "?.??" }; @@ -2964,6 +2964,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine allow_dual_uefi_bios = ReadSettingBool(SETTING_ENABLE_WIN_DUAL_EFI_BIOS); force_large_fat32 = ReadSettingBool(SETTING_FORCE_LARGE_FAT32_FORMAT); enable_vmdk = ReadSettingBool(SETTING_ENABLE_VMDK_DETECTION); + disable_file_indexing = ReadSettingBool(SETTING_DISABLE_FILE_INDEXING); // Initialize the global scaling, in case we need it before we initialize the dialog hDC = GetDC(NULL); @@ -3112,6 +3113,8 @@ relaunch: // Do our own event processing and process "magic" commands while(GetMessage(&msg, NULL, 0, 0)) { + // ** ***** **** * ******** * + // .,ABCDEFGHIJKLMNOPQRSTUVWXYZ // Ctrl-A => Select the log data if ( (IsWindowVisible(hLogDlg)) && (GetKeyState(VK_CONTROL) & 0x8000) && @@ -3220,6 +3223,14 @@ relaunch: PrintStatusTimeout(lmprintf(MSG_260), enable_ntfs_compression); continue; } + // Alt-Q => Disable file indexing (for file systems that support it) + if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'Q')) { + disable_file_indexing = !disable_file_indexing; + WriteSettingBool(SETTING_DISABLE_FILE_INDEXING, disable_file_indexing); + PrintStatusTimeout(lmprintf(MSG_290), !disable_file_indexing); + continue; + } + // Alt-R => Remove all the registry keys that may have been created by Rufus if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'R')) { PrintStatus(2000, DeleteRegistryKey(REGKEY_HKCU, COMPANY_NAME "\\" APPLICATION_NAME)?MSG_248:MSG_249); diff --git a/src/rufus.rc b/src/rufus.rc index 0a05ee24..702ef327 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,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 EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.11.988" +CAPTION "Rufus 2.11.989" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -320,8 +320,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,11,988,0 - PRODUCTVERSION 2,11,988,0 + FILEVERSION 2,11,989,0 + PRODUCTVERSION 2,11,989,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -338,13 +338,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.11.988" + VALUE "FileVersion", "2.11.989" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.11.988" + VALUE "ProductVersion", "2.11.989" END END BLOCK "VarFileInfo" diff --git a/src/settings.h b/src/settings.h index c65682f5..9b2a57c5 100644 --- a/src/settings.h +++ b/src/settings.h @@ -43,6 +43,7 @@ extern char* ini_file; #define SETTING_ENABLE_WIN_DUAL_EFI_BIOS "EnableWindowsDualUefiBiosMode" #define SETTING_FORCE_LARGE_FAT32_FORMAT "ForceLargeFat32Formatting" #define SETTING_ENABLE_VMDK_DETECTION "EnableVmdkDetection" +#define SETTING_DISABLE_FILE_INDEXING "DisableFileIndexing"