From a20b3083b058901572953364dccbdd4cad8f3c5a Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sat, 26 Jan 2019 01:18:03 +0100 Subject: Windows: Add a build configuration containing EFI bootloader signed with custom SecureBoot key instead --- src/Setup/Setup.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'src/Setup/Setup.c') diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c index bd073d9a..7d17962c 100644 --- a/src/Setup/Setup.c +++ b/src/Setup/Setup.c @@ -658,6 +658,53 @@ void IconMessage (HWND hwndDlg, const wchar_t *txt) StatusMessageParam (hwndDlg, "ADDING_ICON", txt); } +#ifdef VC_EFI_CUSTOM_MODE +BOOL CheckSecureBootCompatibility (HWND hWnd) +{ + BOOL bRet = FALSE; + BOOL bDriverAttached = FALSE; + if (hDriver == INVALID_HANDLE_VALUE) + { + int status = DriverAttach(); + if (status || (hDriver == INVALID_HANDLE_VALUE)) + return FALSE; + bDriverAttached = TRUE; + } + + try + { + BootEncryption bootEnc (hWnd); + if (bootEnc.GetDriverServiceStartType() == SERVICE_BOOT_START) + { + SystemDriveConfiguration config = bootEnc.GetSystemDriveConfiguration (); + if (config.SystemPartition.IsGPT) + { + BOOL bSecureBootEnabled = FALSE, bVeraCryptKeysLoaded = FALSE; + bootEnc.GetSecureBootConfig (&bSecureBootEnabled, &bVeraCryptKeysLoaded); + if (!bSecureBootEnabled || bVeraCryptKeysLoaded) + { + bRet = TRUE; + } + } + else + bRet = TRUE; + } + else + bRet = TRUE; + } + catch (...) + { + } + + if (bDriverAttached) + { + CloseHandle (hDriver); + hDriver = INVALID_HANDLE_VALUE; + } + return bRet; +} +#endif + void DetermineUpgradeDowngradeStatus (BOOL bCloseDriverHandle, LONG *driverVersionPtr) { LONG driverVersion = VERSION_NUM; @@ -1133,7 +1180,7 @@ BOOL DoRegInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bInstallType) if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_WOW64_32KEY, NULL, &hkey, &dw) == ERROR_SUCCESS) { - StringCbCopyW (szTmp, sizeof(szTmp), _T(VERSION_STRING)); + StringCbCopyW (szTmp, sizeof(szTmp), _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX)); RegSetValueEx (hkey, L"DisplayVersion", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)); StringCbCopyW (szTmp, sizeof(szTmp), TC_HOMEPAGE); @@ -1249,7 +1296,7 @@ BOOL DoRegInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bInstallType) if (RegSetValueEx (hkey, L"DisplayIcon", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS) goto error; - StringCbCopyW (szTmp, sizeof(szTmp), _T(VERSION_STRING)); + StringCbCopyW (szTmp, sizeof(szTmp), _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX)); if (RegSetValueEx (hkey, L"DisplayVersion", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS) goto error; -- cgit v1.2.3