diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2017-06-09 12:34:41 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2017-06-09 17:23:38 +0200 |
commit | 767f5137520015b873804a38837b0aa70e97d8bd (patch) | |
tree | 0a61dfbdd60e26c782aa0a5e158de161c25d3ca8 /src | |
parent | 3764f7e8b9a931ab212b0cda728de40d379ae53f (diff) | |
download | VeraCrypt-767f5137520015b873804a38837b0aa70e97d8bd.tar.gz VeraCrypt-767f5137520015b873804a38837b0aa70e97d8bd.zip |
Windows: Disable button for EFI PlatformInfo if the file is missing
Diffstat (limited to 'src')
-rw-r--r-- | src/Mount/Mount.c | 57 |
1 files changed, 31 insertions, 26 deletions
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: |