mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Windows: Implement detection of Hibernate and Fast Startup and disable them if RAM encryption is activated.
This commit is contained in:
@@ -14896,3 +14896,76 @@ void PasswordEditDropTarget::GotDrop(CLIPFORMAT format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Query the status of Hibernate and Fast Startup
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef BOOLEAN (WINAPI *GetPwrCapabilitiesFn)(
|
||||||
|
PSYSTEM_POWER_CAPABILITIES lpspc
|
||||||
|
);
|
||||||
|
|
||||||
|
BOOL GetHibernateStatus (BOOL& bHibernateEnabled, BOOL& bHiberbootEnabled)
|
||||||
|
{
|
||||||
|
wchar_t szPowrProfPath[MAX_PATH] = {0};
|
||||||
|
HMODULE hPowrProf = NULL;
|
||||||
|
BOOL bResult = FALSE;
|
||||||
|
|
||||||
|
bHibernateEnabled = bHiberbootEnabled = FALSE;
|
||||||
|
|
||||||
|
if (GetSystemDirectory(szPowrProfPath, MAX_PATH))
|
||||||
|
StringCchCatW (szPowrProfPath, MAX_PATH, L"\\PowrProf.dll");
|
||||||
|
else
|
||||||
|
StringCchCopyW (szPowrProfPath, MAX_PATH, L"C:\\Windows\\System32\\PowrProf.dll");
|
||||||
|
|
||||||
|
hPowrProf = LoadLibrary (szPowrProfPath);
|
||||||
|
if (hPowrProf)
|
||||||
|
{
|
||||||
|
GetPwrCapabilitiesFn GetPwrCapabilitiesPtr = (GetPwrCapabilitiesFn) GetProcAddress (hPowrProf, "GetPwrCapabilities");
|
||||||
|
if ( GetPwrCapabilitiesPtr)
|
||||||
|
{
|
||||||
|
SYSTEM_POWER_CAPABILITIES spc;
|
||||||
|
BOOLEAN bRet = GetPwrCapabilitiesPtr (&spc);
|
||||||
|
if (bRet)
|
||||||
|
{
|
||||||
|
DWORD dwHibernateEnabled = 0;
|
||||||
|
DWORD dwHiberbootEnabled = 0;
|
||||||
|
|
||||||
|
if (spc.SystemS4)
|
||||||
|
{
|
||||||
|
dwHibernateEnabled = 1;
|
||||||
|
if(!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Control\\Power", L"HibernateEnabled", &dwHibernateEnabled))
|
||||||
|
{
|
||||||
|
// starting from Windows 10 1809 (Build 17763), HibernateEnabledDefault is used when HibernateEnabled is absent
|
||||||
|
if (IsOSVersionAtLeast (WIN_10, 0) && CurrentOSBuildNumber >= 17763)
|
||||||
|
ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Control\\Power", L"HibernateEnabledDefault", &dwHibernateEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if Fast Startup / Hybrid Boot is enabled
|
||||||
|
if (IsOSVersionAtLeast (WIN_8, 0) && spc.spare2[0])
|
||||||
|
{
|
||||||
|
dwHiberbootEnabled = 1;
|
||||||
|
ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", L"HiberbootEnabled", &dwHiberbootEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dwHibernateEnabled)
|
||||||
|
bHibernateEnabled = TRUE;
|
||||||
|
else
|
||||||
|
bHibernateEnabled = FALSE;
|
||||||
|
|
||||||
|
if (dwHiberbootEnabled)
|
||||||
|
bHiberbootEnabled = TRUE;
|
||||||
|
else
|
||||||
|
bHiberbootEnabled = FALSE;
|
||||||
|
|
||||||
|
bResult = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FreeLibrary (hPowrProf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -745,6 +745,7 @@ public:
|
|||||||
DWORD GotEnter(void);
|
DWORD GotEnter(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BOOL GetHibernateStatus (BOOL& bHibernateEnabled, BOOL& bHiberbootEnabled);
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
|||||||
@@ -1444,6 +1444,7 @@
|
|||||||
<entry lang="en" key="IDC_FORCE_NEXT_BOOT_VERACRYPT">Force machine to boot on VeraCrypt in the next startup</entry>
|
<entry lang="en" key="IDC_FORCE_NEXT_BOOT_VERACRYPT">Force machine to boot on VeraCrypt in the next startup</entry>
|
||||||
<entry lang="en" key="IDC_FORCE_VERACRYPT_BOOT_ENTRY">Force the presence of VeraCrypt entry in the EFI firmware boot menu</entry>
|
<entry lang="en" key="IDC_FORCE_VERACRYPT_BOOT_ENTRY">Force the presence of VeraCrypt entry in the EFI firmware boot menu</entry>
|
||||||
<entry lang="en" key="IDC_FORCE_VERACRYPT_FIRST_BOOT_ENTRY">Force VeraCrypt entry to be the first in the EFI firmware boot menu</entry>
|
<entry lang="en" key="IDC_FORCE_VERACRYPT_FIRST_BOOT_ENTRY">Force VeraCrypt entry to be the first in the EFI firmware boot menu</entry>
|
||||||
|
<entry lang="en" key="RAM_ENCRYPTION_DISABLE_HIBERNATE">WARNING: RAM encryption is not compatible with Windows Hibernate and Windows Fast Startup features. VeraCrypt needs to disable them before activating RAM encryption.\n\nContinue?</entry>
|
||||||
</localization>
|
</localization>
|
||||||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||||
<xs:element name="VeraCrypt">
|
<xs:element name="VeraCrypt">
|
||||||
|
|||||||
@@ -11462,7 +11462,26 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
|
|||||||
{
|
{
|
||||||
BOOL originalRamEncryptionEnabled = (driverConfig & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION)? TRUE : FALSE;
|
BOOL originalRamEncryptionEnabled = (driverConfig & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION)? TRUE : FALSE;
|
||||||
if (originalRamEncryptionEnabled != enableRamEncryption)
|
if (originalRamEncryptionEnabled != enableRamEncryption)
|
||||||
|
{
|
||||||
|
if (enableRamEncryption)
|
||||||
|
{
|
||||||
|
// Disable Hibernate and Fast Startup if they are enabled
|
||||||
|
BOOL bHibernateEnabled, bHiberbootEnabled;
|
||||||
|
if (GetHibernateStatus (bHibernateEnabled, bHiberbootEnabled))
|
||||||
|
{
|
||||||
|
if (bHibernateEnabled)
|
||||||
|
{
|
||||||
|
BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Control\\Power", L"HibernateEnabled", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bHiberbootEnabled)
|
||||||
|
{
|
||||||
|
BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", L"HiberbootEnabled", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
rebootRequired = true;
|
rebootRequired = true;
|
||||||
|
}
|
||||||
SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION, enableRamEncryption);
|
SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION, enableRamEncryption);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11538,8 +11557,26 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
|
|||||||
BOOL enableRamEncryption = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION);
|
BOOL enableRamEncryption = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION);
|
||||||
|
|
||||||
if (originalRamEncryptionEnabled != enableRamEncryption)
|
if (originalRamEncryptionEnabled != enableRamEncryption)
|
||||||
|
{
|
||||||
|
if (enableRamEncryption)
|
||||||
|
{
|
||||||
|
// check if Hibernate or Fast Startup are enabled
|
||||||
|
BOOL bHibernateEnabled, bHiberbootEnabled;
|
||||||
|
if (GetHibernateStatus (bHibernateEnabled, bHiberbootEnabled))
|
||||||
|
{
|
||||||
|
if (bHibernateEnabled || bHiberbootEnabled)
|
||||||
|
{
|
||||||
|
if (AskWarnYesNo ("RAM_ENCRYPTION_DISABLE_HIBERNATE", hwndDlg) == IDNO)
|
||||||
|
{
|
||||||
|
CheckDlgButton (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION, BST_UNCHECKED);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Warning ("SETTING_REQUIRES_REBOOT", hwndDlg);
|
Warning ("SETTING_REQUIRES_REBOOT", hwndDlg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case IDC_BENCHMARK:
|
case IDC_BENCHMARK:
|
||||||
|
|||||||
Reference in New Issue
Block a user