From f8a120a24c339d0ecdf608a0f853f8e38bc5560e Mon Sep 17 00:00:00 2001 From: belliash Date: Tue, 18 Oct 2022 15:44:21 +0200 Subject: [PATCH] Allow BlGetXtLoaderProtocol() routine to store loader protocol in a specified variable --- xtldr/blproto.c | 6 +++--- xtldr/includes/blmod.h | 2 +- xtldr/modules/dummy/dummy.c | 12 +++++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/xtldr/blproto.c b/xtldr/blproto.c index d46105e..a642556 100644 --- a/xtldr/blproto.c +++ b/xtldr/blproto.c @@ -18,7 +18,7 @@ * @since XT 1.0 */ EFI_STATUS -BlGetXtLoaderProtocol() +BlGetXtLoaderProtocol(PXT_BOOT_LOADER_PROTOCOL *LdrProtocol) { EFI_GUID Guid = XT_BOOT_LOADER_PROTOCOL_GUID; PEFI_HANDLE Handles = NULL; @@ -41,7 +41,7 @@ BlGetXtLoaderProtocol() for(Index = 0; Index < Count; Index++) { /* Try to open protocol */ - Status = EfiSystemTable->BootServices->OpenProtocol(Handles[Index], &Guid, (PVOID*)&EfiXtLdrProtocol, + Status = EfiSystemTable->BootServices->OpenProtocol(Handles[Index], &Guid, (PVOID*)LdrProtocol, EfiImageHandle, NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); /* Check if successfully opened the loader protocol */ @@ -57,7 +57,7 @@ BlGetXtLoaderProtocol() EfiSystemTable->BootServices->FreePool(Handles); /* Make sure the loaded protocol has been found */ - if(EfiXtLdrProtocol == NULL) + if(*LdrProtocol == NULL) { /* Protocol not found */ return STATUS_EFI_NOT_FOUND; diff --git a/xtldr/includes/blmod.h b/xtldr/includes/blmod.h index 0f6fcf3..8383a06 100644 --- a/xtldr/includes/blmod.h +++ b/xtldr/includes/blmod.h @@ -17,6 +17,6 @@ EXTERN PXT_BOOT_LOADER_PROTOCOL EfiXtLdrProtocol; EFI_STATUS -BlGetXtLoaderProtocol(); +BlGetXtLoaderProtocol(PXT_BOOT_LOADER_PROTOCOL *LdrProtocol); #endif /* __XTLDR_BLMOD_H */ diff --git a/xtldr/modules/dummy/dummy.c b/xtldr/modules/dummy/dummy.c index b2f6d2c..8de7fcf 100644 --- a/xtldr/modules/dummy/dummy.c +++ b/xtldr/modules/dummy/dummy.c @@ -36,14 +36,20 @@ EFI_STATUS BlXtLoaderModuleMain(EFI_HANDLE ImageHandle, PEFI_SYSTEM_TABLE SystemTable) { + EFI_STATUS Status; + /* Set the system table and image handle */ EfiImageHandle = ImageHandle; EfiSystemTable = SystemTable; /* Open the XTLDR protocol */ - BlGetXtLoaderProtocol(); + Status = BlGetXtLoaderProtocol(&EfiXtLdrProtocol); + if(Status != STATUS_EFI_SUCCESS) + { + /* Failed to open loader protocol */ + return STATUS_EFI_PROTOCOL_ERROR; + } - /* Print message and return success */ - EfiXtLdrProtocol->EfiPrint(L"XTLDR dummy module initialized\n"); + /* Return success */ return STATUS_EFI_SUCCESS; }