From 76c03c23a1f985efebcb76e3b56a2c1b3b01af52 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Fri, 8 Mar 2019 00:56:47 +0100 Subject: Windows: inform user that RAM encryption setting requires reboot to take effect --- src/Mount/Mount.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 467f4962..5f96afba 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -11219,6 +11219,9 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM try { VOLUME_PROPERTIES_STRUCT prop; + bool rebootRequired = false; + uint32 driverConfig = ReadDriverConfigurationFlags(); + try { BootEncStatus = BootEncObj->GetStatus(); @@ -11256,7 +11259,12 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ALLOW_WINDOWS_DEFRAG, allowWindowsDefrag); SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_CPU_RNG, enableCpuRng); if (IsOSAtLeast (WIN_7)) + { + BOOL originalRamEncryptionEnabled = (driverConfig & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION)? TRUE : FALSE; + if (originalRamEncryptionEnabled != enableRamEncryption) + rebootRequired = true; SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION, enableRamEncryption); + } DWORD bytesReturned; if (!DeviceIoControl (hDriver, TC_IOCTL_REREAD_DRIVER_CONFIG, NULL, 0, NULL, 0, &bytesReturned, NULL)) @@ -11276,9 +11284,12 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM if (ReadEncryptionThreadPoolFreeCpuCountLimit() != cpuFreeCount) { BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME, cpuFreeCount); - Warning ("SETTING_REQUIRES_REBOOT", hwndDlg); + rebootRequired = true; } + if (rebootRequired) + Warning ("SETTING_REQUIRES_REBOOT", hwndDlg); + EndDialog (hwndDlg, lw); return 1; } @@ -11320,6 +11331,17 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM EnableWindow (GetDlgItem (hwndDlg, IDC_ENCRYPTION_FREE_CPU_COUNT), IsDlgButtonChecked (hwndDlg, IDC_LIMIT_ENC_THREAD_POOL)); return 1; + case IDC_ENABLE_RAM_ENCRYPTION: + { + uint32 driverConfig = ReadDriverConfigurationFlags(); + BOOL originalRamEncryptionEnabled = (driverConfig & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION)? TRUE : FALSE; + BOOL enableRamEncryption = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION); + + if (originalRamEncryptionEnabled != enableRamEncryption) + Warning ("SETTING_REQUIRES_REBOOT", hwndDlg); + } + return 1; + case IDC_BENCHMARK: Benchmark (hwndDlg); return 1; -- cgit v1.2.3