VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2024-09-16 23:11:37 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2024-09-16 23:11:37 +0200
commiteb0eec7b39534b0bec5566ef92985f163e1f7025 (patch)
treef5d9ccc139399318d033ee1973eb0a9589dd1feb
parent3a1c8bac59b4afa364b8371ce65f0dd4c8236472 (diff)
downloadVeraCrypt-eb0eec7b39534b0bec5566ef92985f163e1f7025.tar.gz
VeraCrypt-eb0eec7b39534b0bec5566ef92985f163e1f7025.zip
Windows: Fix failed EFI detection on some PCs where BootOrder variable is not defined.
we now report that EFI is not support only when GetFirmwareEnvironmentVariable fails with error ERROR_INVALID_FUNCTION. Proposed by @kriegste on https://github.com/veracrypt/VeraCrypt/issues/360
-rw-r--r--src/Common/BootEncryption.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index c9b275dc..bf7a0f64 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -2619,41 +2619,41 @@ namespace VeraCrypt
throw;
}
if (dev.IsOpened())
{
bDeviceInfoValid = dev.IoCtl(IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &sdn, sizeof(sdn))
&& dev.IoCtl(IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0, &partInfo, sizeof(partInfo));
DWORD dwLastError = GetLastError ();
dev.Close();
if (!bDeviceInfoValid && !bDisableException)
{
SetLastError (dwLastError);
throw SystemException(SRC_POS);
}
}
}
bool EfiBoot::IsEfiBoot() {
DWORD BootOrderLen;
BootOrderLen = GetFirmwareEnvironmentVariable(L"BootOrder", EfiVarGuid, tempBuf, sizeof(tempBuf));
- return BootOrderLen != 0;
+ return (BootOrderLen != 0) || (GetLastError() != ERROR_INVALID_FUNCTION);
}
void EfiBoot::DeleteStartExec(uint16 statrtOrderNum, wchar_t* type) {
DWORD dwLastError;
BOOL bPrivilegesSet = IsPrivilegeEnabled (SE_SYSTEM_ENVIRONMENT_NAME);
if (!bPrivilegesSet && !SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, TRUE))
{
dwLastError = GetLastError();
wchar_t szMsg[128];
StringCchPrintfW(szMsg, ARRAYSIZE(szMsg), L"Failed to set SE_SYSTEM_ENVIRONMENT_NAME privilege (error code 0x%.8X)", dwLastError);
throw ErrorException(szMsg, SRC_POS);
}
// 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