VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2024-09-17 18:25:52 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2024-09-17 18:25:52 +0200
commit380850787e59152100eed8c5c06d0e81a34e39e0 (patch)
tree444cb3c00aa81a6d40b0a6103f7eb34a1d997467
parent866fc8f5137925e684ea855111affe2d71612b88 (diff)
downloadVeraCrypt-380850787e59152100eed8c5c06d0e81a34e39e0.tar.gz
VeraCrypt-380850787e59152100eed8c5c06d0e81a34e39e0.zip
Windows: Simplify error message related to IsEfiBoot since it always fail with ERROR_INVALID_FUNCTION
Proposed by @kriegste on https://github.com/veracrypt/VeraCrypt/issues/360
-rw-r--r--src/Common/BootEncryption.cpp26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index bf7a0f64..f79e7339 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -2651,16 +2651,9 @@ namespace VeraCrypt
}
// Check EFI
if (!IsEfiBoot()) {
- dwLastError = GetLastError();
- if (dwLastError != ERROR_SUCCESS)
- {
- if (!bPrivilegesSet)
- SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE);
- // format message to append the error code to the exception message
- wchar_t szMsg[128];
- StringCchPrintfW(szMsg, ARRAYSIZE(szMsg), L"Failed to detect EFI environment (error code 0x%.8X)", dwLastError);
- throw ErrorException(szMsg, SRC_POS);
- }
+ if (!bPrivilegesSet)
+ SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE);
+ throw ErrorException(L"Failed to detect EFI environment (error ERROR_INVALID_FUNCTION)", SRC_POS);
}
wchar_t varName[256];
StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum);
@@ -2720,16 +2713,9 @@ namespace VeraCrypt
}
// Check EFI
if (!IsEfiBoot()) {
- dwLastError = GetLastError();
- if (dwLastError != ERROR_SUCCESS)
- {
- if (!bPrivilegesSet)
- SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE);
- // format message to append the error code to the exception message
- wchar_t szMsg[1024];
- StringCchPrintfW(szMsg, ARRAYSIZE(szMsg), L"Failed to detect EFI environment (error code 0x%.8X)", dwLastError);
- throw ErrorException(szMsg, SRC_POS);
- }
+ if (!bPrivilegesSet)
+ SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE);
+ throw ErrorException(L"Failed to detect EFI environment (error ERROR_INVALID_FUNCTION)", SRC_POS);
}
if (bDeviceInfoValid)