From 767f5137520015b873804a38837b0aa70e97d8bd Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Fri, 9 Jun 2017 12:34:41 +0200 Subject: Windows: Disable button for EFI PlatformInfo if the file is missing --- src/Mount/Mount.c | 57 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'src/Mount') diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 63dd199c..f678123c 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -11023,6 +11023,7 @@ void SecurityTokenPreferencesDialog (HWND hwndDlg) static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WORD lw = LOWORD (wParam); + static std::string platforminfo; switch (msg) { @@ -11059,6 +11060,35 @@ static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARA if (bSystemIsGPT) { CheckDlgButton (hwndDlg, IDC_DISABLE_BOOT_LOADER_HASH_PROMPT, (userConfig & TC_BOOT_USER_CFG_FLAG_STORE_HASH) ? BST_CHECKED : BST_UNCHECKED); + // read PlatformInfo file if it exists + try + { + ByteArray fileContent; + DWORD sz, offset; + std::wstring path; + GetVolumeESP(path); + path += L"\\EFI\\VeraCrypt\\PlatformInfo"; + File fPlatformInfo(path); + fPlatformInfo.GetFileSize(sz); + fileContent.resize(sz + 1); + fileContent[sz] = 0; + fPlatformInfo.Read((byte*)&fileContent[0], sz); + // remove UTF-8 BOM if any + if (0 == memcmp (fileContent.data(), "\xEF\xBB\xBF", 3)) + { + offset = 3; + } + else + offset = 0; + platforminfo = (const char*) &fileContent[offset]; + } + catch (Exception &e) {} + + if (platforminfo.length() == 0) + { + // could not read PlatformInfo file. Disable corresponding button in UI + EnableWindow (GetDlgItem (hwndDlg, IDC_SHOW_PLATFORMINFO), FALSE); + } } else { @@ -11092,32 +11122,7 @@ static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARA EndDialog (hwndDlg, lw); return 1; case IDC_SHOW_PLATFORMINFO: - { - try - { - std::string platforminfo; - ByteArray fileContent; - DWORD sz, offset; - std::wstring path; - GetVolumeESP(path); - path += L"\\EFI\\VeraCrypt\\PlatformInfo"; - File fPlatformInfo(path); - fPlatformInfo.GetFileSize(sz); - fileContent.resize(sz + 1); - fileContent[sz] = 0; - fPlatformInfo.Read((byte*)&fileContent[0], sz); - // remove UTF-8 BOM if any - if (0 == memcmp (fileContent.data(), "\xEF\xBB\xBF", 3)) - { - offset = 3; - } - else - offset = 0; - platforminfo = (const char*) &fileContent[offset]; - TextEditDialogBox(TRUE, hwndDlg, GetString ("EFI_PLATFORM_INFORMATION"), platforminfo); - } - catch (Exception &e) { e.Show(hwndDlg); } - } + TextEditDialogBox(TRUE, hwndDlg, GetString ("EFI_PLATFORM_INFORMATION"), platforminfo); return 0; case IDC_EDIT_DCSPROP: -- cgit v1.2.3