From cd59d5364f5b32ac136e4a91b8534f2410059cde Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 4 Mar 2018 18:48:16 +0100 Subject: Windows: Implement TRIM support for non-system SSD partitions/drives and add driver option to enable it (TRIM is disabled by default for non-system SSD partitions/drives) --- src/Mount/Mount.c | 3 +++ src/Mount/Mount.rc | 22 ++++++++++++---------- src/Mount/Resource.h | 3 ++- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src/Mount') diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 6eb49a1b..61ce4f77 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -10687,6 +10687,7 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM uint32 driverConfig = ReadDriverConfigurationFlags(); CheckDlgButton (hwndDlg, IDC_ENABLE_HARDWARE_ENCRYPTION, (driverConfig & TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION) ? BST_UNCHECKED : BST_CHECKED); CheckDlgButton (hwndDlg, IDC_ENABLE_EXTENDED_IOCTL_SUPPORT, (driverConfig & TC_DRIVER_CONFIG_ENABLE_EXTENDED_IOCTL) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton (hwndDlg, IDC_ALLOW_TRIM_NONSYS_SSD, (driverConfig & VC_DRIVER_CONFIG_ALLOW_NONSYS_TRIM) ? BST_CHECKED : BST_UNCHECKED); SYSTEM_INFO sysInfo; GetSystemInfo (&sysInfo); @@ -10744,6 +10745,7 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM BOOL disableHW = !IsDlgButtonChecked (hwndDlg, IDC_ENABLE_HARDWARE_ENCRYPTION); BOOL enableExtendedIOCTL = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_EXTENDED_IOCTL_SUPPORT); + BOOL allowTrimCommand = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_TRIM_NONSYS_SSD); try { @@ -10780,6 +10782,7 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM SetDriverConfigurationFlag (TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION, disableHW); SetDriverConfigurationFlag (TC_DRIVER_CONFIG_ENABLE_EXTENDED_IOCTL, enableExtendedIOCTL); + SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ALLOW_NONSYS_TRIM, allowTrimCommand); DWORD bytesReturned; if (!DeviceIoControl (hDriver, TC_IOCTL_REREAD_DRIVER_CONFIG, NULL, 0, NULL, 0, &bytesReturned, NULL)) diff --git a/src/Mount/Mount.rc b/src/Mount/Mount.rc index 972fe5a0..9024b0d6 100644 --- a/src/Mount/Mount.rc +++ b/src/Mount/Mount.rc @@ -307,7 +307,7 @@ BEGIN GROUPBOX "Advanced Options",IDT_ADVANCED_OPTIONS,7,99,355,36 END -IDD_PERFORMANCE_SETTINGS DIALOGEX 0, 0, 370, 248 +IDD_PERFORMANCE_SETTINGS DIALOGEX 0, 0, 371, 253 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "VeraCrypt - Performance Options" FONT 8, "MS Shell Dlg", 400, 0, 0x1 @@ -319,17 +319,19 @@ BEGIN CONTROL "Do not use the following number of processors for encryption/decryption:",IDC_LIMIT_ENC_THREAD_POOL, "Button",BS_AUTOCHECKBOX | BS_TOP | WS_TABSTOP,18,103,283,11 COMBOBOX IDC_ENCRYPTION_FREE_CPU_COUNT,304,101,48,51,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "",IDT_LIMIT_ENC_THREAD_POOL_NOTE,18,126,334,33 LTEXT "More information",IDC_MORE_INFO_ON_THREAD_BASED_PARALLELIZATION,18,159,165,10,SS_NOTIFY - PUSHBUTTON "&Benchmark",IDC_BENCHMARK,7,227,59,14 - DEFPUSHBUTTON "OK",IDOK,257,227,50,14 - PUSHBUTTON "Cancel",IDCANCEL,313,227,50,14 + CONTROL "Enable extended disk control codes support",IDC_ENABLE_EXTENDED_IOCTL_SUPPORT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,198,337,10 + CONTROL "Allow TRIM operation for non-system SSD partition/drive",IDC_ALLOW_TRIM_NONSYS_SSD, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,212,337,10 + PUSHBUTTON "&Benchmark",IDC_BENCHMARK,7,232,59,14 + DEFPUSHBUTTON "OK",IDOK,257,232,50,14 + PUSHBUTTON "Cancel",IDCANCEL,314,232,50,14 LTEXT "Processor (CPU) in this computer supports hardware acceleration for AES:",IDT_HW_AES_SUPPORTED_BY_CPU,18,23,273,9 GROUPBOX "Hardware Acceleration",IDT_ACCELERATION_OPTIONS,7,6,355,74 GROUPBOX "Thread-Based Parallelization",IDT_PARALLELIZATION_OPTIONS,7,84,355,93 - LTEXT "",IDT_LIMIT_ENC_THREAD_POOL_NOTE,18,126,334,33 - GROUPBOX "Driver Configuration",IDT_DRIVER_OPTIONS,7,183,356,36 - CONTROL "Enable extended disk control codes support",IDC_ENABLE_EXTENDED_IOCTL_SUPPORT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,198,337,10 + GROUPBOX "Driver Configuration",IDT_DRIVER_OPTIONS,7,183,357,44 END IDD_FAVORITE_VOLUMES DIALOGEX 0, 0, 380, 368 @@ -492,9 +494,9 @@ BEGIN IDD_PERFORMANCE_SETTINGS, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 363 + RIGHTMARGIN, 364 TOPMARGIN, 7 - BOTTOMMARGIN, 241 + BOTTOMMARGIN, 246 END IDD_FAVORITE_VOLUMES, DIALOG diff --git a/src/Mount/Resource.h b/src/Mount/Resource.h index 907e5ad3..2cefbdad 100644 --- a/src/Mount/Resource.h +++ b/src/Mount/Resource.h @@ -187,6 +187,7 @@ #define IDC_SHOW_PLATFORMINFO 1164 #define IDC_EDIT_DCSPROP 1165 #define IDT_ADVANCED_OPTIONS 1166 +#define IDC_ALLOW_TRIM_NONSYS_SSD 1167 #define IDM_HELP 40001 #define IDM_ABOUT 40002 #define IDM_UNMOUNT_VOLUME 40003 @@ -263,7 +264,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 120 #define _APS_NEXT_COMMAND_VALUE 40069 -#define _APS_NEXT_CONTROL_VALUE 1167 +#define _APS_NEXT_CONTROL_VALUE 1168 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif -- cgit v1.2.3