diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2018-04-16 23:48:54 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2018-04-23 16:59:33 +0200 |
commit | 4519bb494e7c88890aa0022d4aaabffb0b6d8faf (patch) | |
tree | 11e8d1fd8f8e300d851deddc697712e484e5506a /src/Common/BootEncryption.cpp | |
parent | cce74aaee0a96b13b5793de4f2f2099ea1d29338 (diff) | |
download | VeraCrypt-4519bb494e7c88890aa0022d4aaabffb0b6d8faf.tar.gz VeraCrypt-4519bb494e7c88890aa0022d4aaabffb0b6d8faf.zip |
Windows: implement compatibility for Windows 10 major updates using ReflectDrivers mechanism whose support started from Windows 10 version 1607.
Diffstat (limited to 'src/Common/BootEncryption.cpp')
-rw-r--r-- | src/Common/BootEncryption.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index 55eafb75..b57f5c28 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -396,6 +396,18 @@ namespace VeraCrypt } } + static void UpdateSetupConfigFile (bool bForInstall) + { + Elevate(); + + DWORD result = ElevatedComInstance->UpdateSetupConfigFile (bForInstall ? TRUE : FALSE); + if (result != ERROR_SUCCESS) + { + SetLastError (result); + throw SystemException(SRC_POS); + } + } + static void Release () { if (--ReferenceCount == 0 && ElevatedComInstance) @@ -470,6 +482,7 @@ namespace VeraCrypt static void RestoreEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); } static void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn) { throw ParameterIncorrect (SRC_POS); } static void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); } + static void UpdateSetupConfigFile (bool bForInstall) { throw ParameterIncorrect (SRC_POS); } }; #endif // SETUP @@ -2685,6 +2698,27 @@ namespace VeraCrypt return conf.Save (path.c_str(), hwndDlg); } + void BootEncryption::UpdateSetupConfigFile (bool bForInstall) + { + // starting from Windows 10 1607 (Build 14393), ReflectDrivers in Setupconfig.ini is supported + if (IsOSVersionAtLeast (WIN_10, 0) && CurrentOSBuildNumber >= 14393) + { + wchar_t szInstallPath [TC_MAX_PATH]; + wchar_t szSetupconfigLocation [TC_MAX_PATH + 20]; + + if (bForInstall) + GetInstallationPath (NULL, szInstallPath, ARRAYSIZE (szInstallPath), NULL); + if (GetSetupconfigLocation (szSetupconfigLocation, ARRAYSIZE (szSetupconfigLocation))) + { + ::CreateDirectoryW (szSetupconfigLocation, NULL); + + StringCchCatW (szSetupconfigLocation, ARRAYSIZE (szSetupconfigLocation), L"SetupConfig.ini"); + + WritePrivateProfileStringW (L"SetupConfig", L"ReflectDrivers", bForInstall? szInstallPath : NULL, szSetupconfigLocation); + } + } + } + void BootEncryption::InstallBootLoader (bool preserveUserConfig, bool hiddenOSCreation, int pim, int hashAlg) { Device device (GetSystemDriveConfiguration().DevicePath); @@ -2851,6 +2885,15 @@ namespace VeraCrypt device.SeekAt (TC_SECTOR_SIZE_BIOS); device.Write (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, sizeof (bootLoaderBuf) - TC_SECTOR_SIZE_BIOS); } + + if (!IsAdmin() && IsUacSupported()) + { + Elevator::UpdateSetupConfigFile (true); + } + else + { + UpdateSetupConfigFile (true); + } } #ifndef SETUP @@ -3786,6 +3829,22 @@ namespace VeraCrypt device.SeekAt (0); device.Write (bootLoaderBuf, sizeof (bootLoaderBuf)); } + + // starting from Windows 10 1607 (Build 14393), ReflectDrivers in Setupconfig.ini is supported + if (IsOSVersionAtLeast (WIN_10, 0) && CurrentOSBuildNumber >= 14393) + { + wchar_t szSetupconfigLocation [TC_MAX_PATH + 20]; + + if (GetSetupconfigLocation (szSetupconfigLocation, ARRAYSIZE (szSetupconfigLocation))) + { + StringCchCatW (szSetupconfigLocation, ARRAYSIZE (szSetupconfigLocation), L"SetupConfig.ini"); + + if (FileExists (szSetupconfigLocation)) + { + WritePrivateProfileStringW (L"SetupConfig", L"ReflectDrivers", NULL, szSetupconfigLocation); + } + } + } } #endif // SETUP |