mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-01-06 21:58:11 -06:00
Windows: add more checks to correctly identify Microsoft original bootloader.
This commit is contained in:
@@ -3203,12 +3203,22 @@ namespace VeraCrypt
|
|||||||
{
|
{
|
||||||
// check that it is not bootmgfw.efi
|
// check that it is not bootmgfw.efi
|
||||||
if (0 != _wcsicmp (loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"))
|
if (0 != _wcsicmp (loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"))
|
||||||
|
{
|
||||||
|
// look for bootmgfw.efi identifiant string
|
||||||
|
EfiBootInst.GetFileSize(loaderPath.c_str(), loaderSize);
|
||||||
|
std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
|
||||||
|
|
||||||
|
EfiBootInst.ReadFile(loaderPath.c_str(), &bootLoaderBuf[0], (DWORD) loaderSize);
|
||||||
|
|
||||||
|
// look for bootmgfw.efi identifiant string
|
||||||
|
if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString)))
|
||||||
{
|
{
|
||||||
bFound = true;
|
bFound = true;
|
||||||
EfiBootInst.RenameFile(loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc", TRUE);
|
EfiBootInst.RenameFile(loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc", TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!bFound)
|
if (!bFound)
|
||||||
throw ErrorException ("WINDOWS_EFI_BOOT_LOADER_MISSING", SRC_POS);
|
throw ErrorException ("WINDOWS_EFI_BOOT_LOADER_MISSING", SRC_POS);
|
||||||
@@ -4306,12 +4316,23 @@ namespace VeraCrypt
|
|||||||
if ( (0 != _wcsicmp (loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc"))
|
if ( (0 != _wcsicmp (loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc"))
|
||||||
&& (0 != _wcsicmp (loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"))
|
&& (0 != _wcsicmp (loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"))
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
const char* g_szMsBootString = "bootmgfw.pdb";
|
||||||
|
unsigned __int64 loaderSize = 0;
|
||||||
|
EfiBootInst.GetFileSize(loaderPath.c_str(), loaderSize);
|
||||||
|
std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
|
||||||
|
|
||||||
|
EfiBootInst.ReadFile(loaderPath.c_str(), &bootLoaderBuf[0], (DWORD) loaderSize);
|
||||||
|
|
||||||
|
// look for bootmgfw.efi identifiant string
|
||||||
|
if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString)))
|
||||||
{
|
{
|
||||||
EfiBootInst.RenameFile(loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", TRUE);
|
EfiBootInst.RenameFile(loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EfiBootInst.DelFile(L"\\DcsBoot.efi");
|
EfiBootInst.DelFile(L"\\DcsBoot.efi");
|
||||||
|
|||||||
Reference in New Issue
Block a user