From d200f27ac3b8a4f58e52a5ee798e11e3fdf74924 Mon Sep 17 00:00:00 2001 From: kavsrf Date: Thu, 2 Feb 2017 11:40:40 +0300 Subject: double reboot in pre-test phase force boot messages --- DcsBoot/DcsBoot.c | 52 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 21 deletions(-) (limited to 'DcsBoot') diff --git a/DcsBoot/DcsBoot.c b/DcsBoot/DcsBoot.c index 30bc4a9..4650ae6 100644 --- a/DcsBoot/DcsBoot.c +++ b/DcsBoot/DcsBoot.c @@ -17,6 +17,7 @@ https://opensource.org/licenses/LGPL-3.0 #include #include #include +#include #include "DcsConfig.h" #include #include @@ -25,6 +26,27 @@ EFI_GUID ImagePartGuid; EFI_GUID *gEfiExecPartGuid = &ImagePartGuid; CHAR16 *gEfiExecCmdDefault = L"\\EFI\\Microsoft\\Boot\\Bootmgfw.efi"; CHAR16 *gEfiExecCmd = NULL; +CHAR8 gDoExecCmdMsg[256]; + +EFI_STATUS +DoExecCmd() +{ + EFI_STATUS res; + gDoExecCmdMsg[0] = 0; + res = EfiFindPartByGUID(gEfiExecPartGuid, &gFileRootHandle); + if (!EFI_ERROR(res)) { + res = FileOpenRoot(gFileRootHandle, &gFileRoot); + if (!EFI_ERROR(res)) { + res = EfiExec(NULL, gEfiExecCmd); + AsciiSPrint(gDoExecCmdMsg, sizeof(gDoExecCmdMsg), "\nCan't exec %s start partition %g\n", gEfiExecCmd, gEfiExecPartGuid); + } else { + AsciiSPrint(gDoExecCmdMsg, sizeof(gDoExecCmdMsg), "\nCan't open start partition %g\n", gEfiExecPartGuid); + } + } else { + AsciiSPrint(gDoExecCmdMsg, sizeof(gDoExecCmdMsg), "\nCan't find start partition %g\n", gEfiExecPartGuid); + } + return res; +} CHAR16* sDcsBootEfi = L"EFI\\VeraCrypt\\DcsBoot.efi"; CHAR16* sDcsDriverEfiDesc = L"VeraCrypt(DCS) driver"; @@ -106,6 +128,10 @@ DcsBootMain( if (EFI_ERROR(FileExist(NULL, L"\\EFI\\VeraCrypt\\PlatformInfo")) && !EFI_ERROR(FileExist(NULL, L"\\EFI\\VeraCrypt\\DcsInfo.dcs"))) { res = EfiExec(NULL, L"\\EFI\\VeraCrypt\\DcsInfo.dcs"); + if (!EFI_ERROR(res) && + !EFI_ERROR(FileExist(NULL, L"\\EFI\\VeraCrypt\\PlatformInfo"))) { + gST->RuntimeServices->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); + } } // Load all drivers @@ -161,34 +187,18 @@ DcsBootMain( if (CompareGuid(&gptEntry[i].PartitionTypeGUID, &gEfiPartTypeSystemPartGuid)) { // select ESP GUID CopyGuid(gEfiExecPartGuid, &gptEntry[i].UniquePartitionGUID); - break; + res = DoExecCmd(); + if(EFI_ERROR(res)) continue; } } } } } + } else { + res = DoExecCmd(); } - // OUT_PRINT(L"."); - res = EfiFindPartByGUID(gEfiExecPartGuid, &gFileRootHandle); - if (EFI_ERROR(res)) { - ERR_PRINT(L"\nCan't find start partition %g\n", gEfiExecPartGuid); - EfiCpuHalt(); - } -// OUT_PRINT(L"."); - res = FileOpenRoot(gFileRootHandle, &gFileRoot); - if (EFI_ERROR(res)) { - ERR_PRINT(L"\nCan't open start partition\n"); - EfiCpuHalt(); - } -// OUT_PRINT(L"."); - // Try to exec windows loader... - res = EfiExec(NULL, gEfiExecCmd); - if (EFI_ERROR(res)) { - ERR_PRINT(L"\nStart %s - %r\n", gEfiExecCmd, res); - EfiCpuHalt(); - } - ERR_PRINT(L"???%r"); + ERR_PRINT(L"%a\nStatus - %r", gDoExecCmdMsg, res); EfiCpuHalt(); return EFI_INVALID_PARAMETER; } -- cgit v1.2.3