diff options
author | Mattiwatti <mattiwatti@gmail.com> | 2020-04-25 06:33:56 +0200 |
---|---|---|
committer | Mattiwatti <mattiwatti@gmail.com> | 2020-04-25 06:33:56 +0200 |
commit | 9947a9fbc20f5c0ec0acd002209693081fe8d5ff (patch) | |
tree | acf3d68eed01ee5e355ad947b96bf99be615d521 | |
parent | fd5517c379a7e7bb22bcc14b26c0230bfc71f389 (diff) |
Loader: support legacy BIOS boot entries in the fallback pathv1.0.3
Fixes #9
-rw-r--r-- | Application/Loader/Loader.c | 43 | ||||
-rw-r--r-- | Application/Loader/Loader.inf | 2 | ||||
-rw-r--r-- | Application/Loader/Loader.vcxproj | 2 |
3 files changed, 42 insertions, 5 deletions
diff --git a/Application/Loader/Loader.c b/Application/Loader/Loader.c index ae4ded5..eba4f56 100644 --- a/Application/Loader/Loader.c +++ b/Application/Loader/Loader.c @@ -4,6 +4,7 @@ #include <Protocol/EfiGuard.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/LoadedImage.h> +#include <Protocol/LegacyBios.h> #include <Library/UefiLib.h> #include <Library/DebugLib.h> #include <Library/MemoryAllocationLib.h> @@ -413,6 +414,14 @@ TryBootOptionsInOrder( continue; // + // Ignore legacy (BBS) entries, unless non-Windows entries are allowed (second boot attempt) + // + const BOOLEAN IsLegacy = DevicePathType(BootOptions[Index].FilePath) == BBS_DEVICE_PATH && + DevicePathSubType(BootOptions[Index].FilePath) == BBS_BBS_DP; + if (OnlyBootWindows && IsLegacy) + continue; + + // // Filter out non-Windows boot entries. // Apply some heuristics based on the device path, which must end in "bootmgfw.efi" or "bootx64.efi". // In the latter case we may get false positives, but for some types of boots (WinPE, Windows To Go, @@ -442,18 +451,24 @@ TryBootOptionsInOrder( MaybeWindows = TRUE; } - if (ConvertedPath != NULL) - FreePool(ConvertedPath); - if (OnlyBootWindows && !MaybeWindows) { if (FullPath != BootOptions[Index].FilePath) FreePool(FullPath); - + if (ConvertedPath != NULL) + FreePool(ConvertedPath); + // Not Windows; skip this entry continue; } + // Print what we're booting + if (ConvertedPath != NULL) + { + Print(L"Booting %Sdevice path %S...\r\n", IsLegacy ? L"legacy " : L"", ConvertedPath); + FreePool(ConvertedPath); + } + // // Boot this image. // @@ -474,6 +489,26 @@ TryBootOptionsInOrder( // Signal the EVT_SIGNAL_READY_TO_BOOT event EfiSignalEventReadyToBoot(); + // Handle BBS entries + if (IsLegacy) + { + Print(L"\r\nNOTE: EfiGuard does not support legacy (non-UEFI) Windows installations.\r\n" + L"The legacy OS will be booted, but EfiGuard will not work.\r\nPress any key to acknowledge...\r\n"); + WaitForKey(); + + EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; + Status = gBS->LocateProtocol(&gEfiLegacyBiosProtocolGuid, + NULL, + (VOID**)&LegacyBios); + ASSERT_EFI_ERROR(Status); + + BootOptions[Index].Status = LegacyBios->LegacyBoot(LegacyBios, + (BBS_BBS_DEVICE_PATH*)BootOptions[Index].FilePath, + BootOptions[Index].OptionalDataSize, + BootOptions[Index].OptionalData); + return !EFI_ERROR(BootOptions[Index].Status); + } + // So again, DO NOT call this abortion: //BmSetMemoryTypeInformationVariable((BOOLEAN)((BootOptions[Index].Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_BOOT)); diff --git a/Application/Loader/Loader.inf b/Application/Loader/Loader.inf index 1e8e902..e817bd5 100644 --- a/Application/Loader/Loader.inf +++ b/Application/Loader/Loader.inf @@ -14,6 +14,7 @@ MdePkg/MdePkg.dec EfiGuardPkg/EfiGuardPkg.dec MdeModulePkg/MdeModulePkg.dec + OvmfPkg/OvmfPkg.dec [LibraryClasses] UefiApplicationEntryPoint @@ -52,6 +53,7 @@ gEfiFirmwareVolume2ProtocolGuid ## CONSUMES gEfiSimpleTextInProtocolGuid ## CONSUMES gEfiSimpleTextOutProtocolGuid ## CONSUMES + gEfiLegacyBiosProtocolGuid ## CONSUMES [BuildOptions.Common] *:DEBUG_*_*_PP_FLAGS = -D EFI_DEBUG diff --git a/Application/Loader/Loader.vcxproj b/Application/Loader/Loader.vcxproj index c6aaa95..512b624 100644 --- a/Application/Loader/Loader.vcxproj +++ b/Application/Loader/Loader.vcxproj @@ -26,7 +26,7 @@ <ItemDefinitionGroup> <ClCompile> <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CONFIGURE_DRIVER=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)Include</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)Include;$(EDK_PATH)\OvmfPkg\Csm\Include</AdditionalIncludeDirectories> </ClCompile> <Link> <AdditionalDependencies>UefiApplicationEntryPoint.lib;BaseMemoryLib.lib;%(AdditionalDependencies)</AdditionalDependencies> |