Skip to content

Commit

Permalink
Windows: Simplify error message related to IsEfiBoot since it always …
Browse files Browse the repository at this point in the history
…fail with ERROR_INVALID_FUNCTION

Proposed by @kriegste on #360
  • Loading branch information
idrassi committed Sep 17, 2024
1 parent 866fc8f commit 3808507
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions src/Common/BootEncryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3808507

Please sign in to comment.