mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user