From 32042ef643bca462fdfd516509e0334c94d51fc8 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Fri, 22 Dec 2023 22:37:33 +0100 Subject: [PATCH] Initialize XTLDR configuration list and check if EFI LoadedImage protocol opened successfully --- xtldr2/config.c | 2 +- xtldr2/efiutils.c | 32 +++++++++++++++++++------------- xtldr2/globals.c | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/xtldr2/config.c b/xtldr2/config.c index 7a34cf1..c6c8958 100644 --- a/xtldr2/config.c +++ b/xtldr2/config.c @@ -564,7 +564,7 @@ BlpUpdateConfiguration(IN PLIST_ENTRY NewConfig) /* Make sure config entry does not exist yet */ if(BlGetConfigValue(ConfigEntry->Name) == NULL) { - /* Remove new config entry from input list and put it into global config list */ + /* Put new config entry into global config list */ RtlInsertTailList(BlpConfig, &ConfigEntry->Flink); } diff --git a/xtldr2/efiutils.c b/xtldr2/efiutils.c index d6124f3..c61b606 100644 --- a/xtldr2/efiutils.c +++ b/xtldr2/efiutils.c @@ -143,22 +143,28 @@ BlpInitializeEfiBootLoader() /* Print XTLDR version */ BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION); + /* Initialize XTLDR configuration list */ + RtlInitializeListHead(BlpConfig); + /* Check if debug is enabled */ if(DEBUG) { + /* Attempt to open EFI LoadedImage protocol */ Status = BlOpenXtProtocol((PVOID *)&LoadedImage, &LipGuid); - - /* Print useful debug information */ - BlConsolePrint(L"\n---------- BOOTLOADER DEBUG ----------\n" - L"Pointer Size : %d\n" - L"Image Base Address: 0x%lx\n" - L"Image Base Size : 0x%lx\n" - L"Image Revision : 0x%lx\n" - L"--------------------------------------\n", - sizeof(PVOID), - LoadedImage->ImageBase, - LoadedImage->ImageSize, - LoadedImage->Revision); - BlSleepExecution(5000); + if(Status == STATUS_EFI_SUCCESS) + { + /* Protocol opened successfully, print useful debug information */ + BlConsolePrint(L"\n---------- BOOTLOADER DEBUG ----------\n" + L"Pointer Size : %d\n" + L"Image Base Address: 0x%lx\n" + L"Image Base Size : 0x%lx\n" + L"Image Revision : 0x%lx\n" + L"--------------------------------------\n", + sizeof(PVOID), + LoadedImage->ImageBase, + LoadedImage->ImageSize, + LoadedImage->Revision); + BlSleepExecution(3000); + } } } diff --git a/xtldr2/globals.c b/xtldr2/globals.c index bbcc200..7292295 100644 --- a/xtldr2/globals.c +++ b/xtldr2/globals.c @@ -10,7 +10,7 @@ /* XT Boot Loader configuration list */ -PLIST_ENTRY BlpConfig = NULL; +PLIST_ENTRY BlpConfig; /* XT Boot Loader loaded configuration */ LIST_ENTRY BlpConfigSections;