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
This commit is contained in:
Mounir IDRASSI 2024-09-17 18:25:52 +02:00
parent 866fc8f513
commit 380850787e
No known key found for this signature in database
GPG Key ID: FC1B00364B3FE937

View File

@ -2651,16 +2651,9 @@ namespace VeraCrypt
} }
// Check EFI // Check EFI
if (!IsEfiBoot()) { if (!IsEfiBoot()) {
dwLastError = GetLastError();
if (dwLastError != ERROR_SUCCESS)
{
if (!bPrivilegesSet) if (!bPrivilegesSet)
SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE); SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE);
// format message to append the error code to the exception message throw ErrorException(L"Failed to detect EFI environment (error ERROR_INVALID_FUNCTION)", SRC_POS);
wchar_t szMsg[128];
StringCchPrintfW(szMsg, ARRAYSIZE(szMsg), L"Failed to detect EFI environment (error code 0x%.8X)", dwLastError);
throw ErrorException(szMsg, SRC_POS);
}
} }
wchar_t varName[256]; wchar_t varName[256];
StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum); StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum);
@ -2720,16 +2713,9 @@ namespace VeraCrypt
} }
// Check EFI // Check EFI
if (!IsEfiBoot()) { if (!IsEfiBoot()) {
dwLastError = GetLastError();
if (dwLastError != ERROR_SUCCESS)
{
if (!bPrivilegesSet) if (!bPrivilegesSet)
SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE); SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE);
// format message to append the error code to the exception message throw ErrorException(L"Failed to detect EFI environment (error ERROR_INVALID_FUNCTION)", SRC_POS);
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 (bDeviceInfoValid) if (bDeviceInfoValid)