VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/BootEncryption.cpp
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2019-11-27 00:13:25 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2019-11-27 00:15:51 +0100
commit14a477026d6c9f3a549ba0dcc07955a8c70becfb (patch)
tree07604b56730190a4e0a9109e68e1b3cc9fbed295 /src/Common/BootEncryption.cpp
parent79eea6e5b1fd1300729d31b7ccda6a4718b4b81b (diff)
downloadVeraCrypt-14a477026d6c9f3a549ba0dcc07955a8c70becfb.tar.gz
VeraCrypt-14a477026d6c9f3a549ba0dcc07955a8c70becfb.zip
Windows: compatibility with multi-OS boot configuration by only setting VeraCrypt as first bootloader of the system if the current first bootloader is Windows one.
Diffstat (limited to 'src/Common/BootEncryption.cpp')
-rw-r--r--src/Common/BootEncryption.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index ccf3ac2f..e9566951 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -2824,11 +2824,30 @@ namespace VeraCrypt
if (setBootEntry)
{
+ // check if first entry in BootOrder is Windows one
+ bool bFirstEntryIsWindows = false;
+ if (startOrderNumPos != 0)
+ {
+ wchar_t varName[256];
+ StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, startOrder[0]);
+
+ byte* existingVar = new byte[512];
+ DWORD existingVarLen = GetFirmwareEnvironmentVariableW (varName, EfiVarGuid, existingVar, 512);
+ if (existingVarLen > 0)
+ {
+ if (BufferContainsWideString (existingVar, existingVarLen, L"EFI\\Microsoft\\Boot\\bootmgfw.efi"))
+ bFirstEntryIsWindows = true;
+ }
+
+ delete [] existingVar;
+ }
+
+
// Create new entry if absent
if (startOrderNumPos == UINT_MAX) {
if (bDeviceInfoValid)
{
- if (forceFirstBootEntry)
+ if (forceFirstBootEntry && bFirstEntryIsWindows)
{
for (uint32 i = startOrderLen / 2; i > 0; --i) {
startOrder[i] = startOrder[i - 1];
@@ -2842,7 +2861,7 @@ namespace VeraCrypt
startOrderLen += 2;
startOrderUpdate = true;
}
- } else if ((startOrderNumPos > 0) && forceFirstBootEntry) {
+ } else if ((startOrderNumPos > 0) && forceFirstBootEntry && bFirstEntryIsWindows) {
for (uint32 i = startOrderNumPos; i > 0; --i) {
startOrder[i] = startOrder[i - 1];
}