VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount/Mount.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2023-09-20 09:39:22 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2023-09-20 09:39:22 +0200
commit0f3ae268a4b0dfac7090f4fbf969601a1c35c86f (patch)
tree7c0a8afeae852abc98f81d402e3889d526a6fe2c /src/Mount/Mount.c
parentb1657e88e4f7922cda6795d843b5b7723b27102f (diff)
downloadVeraCrypt-0f3ae268a4b0dfac7090f4fbf969601a1c35c86f.tar.gz
VeraCrypt-0f3ae268a4b0dfac7090f4fbf969601a1c35c86f.zip
Windows: Add setting in main UI and setup wizard to disable memory protection
This can be useful for users who need Accessibility software that may not work when memory protection is active in VeraCrypt
Diffstat (limited to 'src/Mount/Mount.c')
-rw-r--r--src/Mount/Mount.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 41672e1a..28418a44 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -11559,6 +11559,12 @@ void SetServiceConfigurationFlag (uint32 flag, BOOL state)
BootEncObj->SetServiceConfigurationFlag (flag, state ? true : false);
}
+void SetMemoryProtectionConfig (BOOL bEnable)
+{
+ DWORD config = bEnable? 1: 0;
+ if (BootEncObj)
+ BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", VC_ENABLE_MEMORY_PROTECTION, config);
+}
void NotifyService (DWORD dwNotifyCmd)
{
@@ -11611,6 +11617,8 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
EnableWindow (GetDlgItem (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION), FALSE);
}
+ CheckDlgButton (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION, ReadMemoryProtectionConfig() ? BST_UNCHECKED : BST_CHECKED);
+
size_t cpuCount = GetCpuCount(NULL);
HWND freeCpuCombo = GetDlgItem (hwndDlg, IDC_ENCRYPTION_FREE_CPU_COUNT);
@@ -11670,6 +11678,7 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
BOOL enableExtendedIOCTL = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_EXTENDED_IOCTL_SUPPORT);
BOOL allowTrimCommand = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_TRIM_NONSYS_SSD);
BOOL allowWindowsDefrag = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_WINDOWS_DEFRAG);
+ BOOL bDisableMemoryProtection = IsDlgButtonChecked (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION);
try
{
@@ -11738,6 +11747,11 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
}
SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION, enableRamEncryption);
+ BOOL originalDisableMemoryProtection = !ReadMemoryProtectionConfig();
+ if(originalDisableMemoryProtection != bDisableMemoryProtection)
+ rebootRequired = true;
+ SetMemoryProtectionConfig (!bDisableMemoryProtection);
+
DWORD bytesReturned;
if (!DeviceIoControl (hDriver, TC_IOCTL_REREAD_DRIVER_CONFIG, NULL, 0, NULL, 0, &bytesReturned, NULL))
handleWin32Error (hwndDlg, SRC_POS);
@@ -11832,6 +11846,16 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
}
return 1;
+ case IDC_DISABLE_MEMORY_PROTECTION:
+ {
+ BOOL disableMemoryProtection = IsDlgButtonChecked (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION);
+ BOOL originalDisableMemoryProtection = !ReadMemoryProtectionConfig();
+ if (disableMemoryProtection != originalDisableMemoryProtection)
+ {
+ Warning ("SETTING_REQUIRES_REBOOT", hwndDlg);
+ }
+ }
+ return 1;
case IDC_BENCHMARK:
Benchmark (hwndDlg);
return 1;