diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Common/BootEncryption.cpp | 2 |
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 @@ -2604,71 +2604,71 @@ namespace VeraCrypt void EfiBoot::PrepareBootPartition(bool bDisableException) { GetVolumeESP (EfiBootPartPath, BootVolumePath); std::wstring devicePath = L"\\\\?\\GLOBALROOT"; devicePath += BootVolumePath; Device dev(devicePath.c_str(), TRUE); try { dev.CheckOpened(SRC_POS); } catch (...) { if (!bDisableException) 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 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]; StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum); SetFirmwareEnvironmentVariable(varName, EfiVarGuid, NULL, 0); wstring order = L"Order"; order.insert(0, type == NULL ? L"Boot" : type); uint32 startOrderLen = GetFirmwareEnvironmentVariable(order.c_str(), EfiVarGuid, tempBuf, sizeof(tempBuf)); uint32 startOrderNumPos = UINT_MAX; bool startOrderUpdate = false; uint16* startOrder = (uint16*)tempBuf; |