VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2019-09-23 15:38:14 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2019-09-23 20:01:24 +0200
commit5135d1a3579104b4c69994135c424c5a524c11f9 (patch)
tree16587c5e239a4e93b67b154b6f50c0778b93033d
parent88a01b0e79c241a008a8104baae650a3390c5e5f (diff)
downloadVeraCrypt-DCS-5135d1a3579104b4c69994135c424c5a524c11f9.tar.gz
VeraCrypt-DCS-5135d1a3579104b4c69994135c424c5a524c11f9.zip
Ensure that the correct Windows bootloader is executed when the user press ESCAPE
-rw-r--r--DcsBoot/DcsBoot.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/DcsBoot/DcsBoot.c b/DcsBoot/DcsBoot.c
index 18fb005..080b052 100644
--- a/DcsBoot/DcsBoot.c
+++ b/DcsBoot/DcsBoot.c
@@ -29,6 +29,7 @@ CHAR16 *gEfiExecCmdDefault = L"\\EFI\\Microsoft\\Boot\\Bootmgfw_ms.vc
CHAR16 *gEfiExecCmdMS = L"\\EFI\\Microsoft\\Boot\\Bootmgfw.efi";
CHAR16 *gEfiExecCmd = NULL;
CHAR8 gDoExecCmdMsg[256];
+CONST CHAR8* g_szMsBootString = "bootmgfw.pdb";
EFI_STATUS
DoExecCmd()
@@ -58,6 +59,39 @@ DoExecCmd()
return res;
}
+EFI_STATUS
+ExecMSWindowsLoader() {
+
+ if (!EFI_ERROR(FileExist(NULL, gEfiExecCmdDefault)))
+ return EfiExec(NULL, gEfiExecCmdDefault);
+ else
+ {
+ if (!EFI_ERROR(FileExist(NULL, gEfiExecCmdMS)))
+ {
+ /* check if it is Microsoft one */
+ UINT8* fileData = NULL;
+ UINTN fileSize = 0;
+ BOOLEAN bFound = FALSE;
+ if (!EFI_ERROR(FileLoad(NULL, gEfiExecCmdMS, &fileData, &fileSize)))
+ {
+ if ((fileSize > 32768) && !EFI_ERROR(MemoryHasPattern(fileData, fileSize, g_szMsBootString, AsciiStrLen(g_szMsBootString))))
+ {
+ bFound = TRUE;
+ }
+ }
+
+ MEM_FREE(fileData);
+
+ if (bFound)
+ return EfiExec(NULL, gEfiExecCmdMS);
+ }
+
+ ERR_PRINT(L"Could not find the original Windows loader\r\n");
+
+ return EFI_NOT_READY;
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
// BML
//////////////////////////////////////////////////////////////////////////
@@ -186,7 +220,7 @@ DcsBootMain(
else if (res == EFI_DCS_USER_CANCELED)
{
/* If user cancels password prompt, call original Windows loader */
- res = EfiExec(NULL, gEfiExecCmdDefault);
+ res = ExecMSWindowsLoader ();
}
return res;
}