From bd7d4f5a0dd0201bb4340f05291f0771551560e4 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Sun, 9 Jun 2024 22:26:01 +0200 Subject: [PATCH] Fix function type mismatch undefined behavior when calling through a pointer --- sdk/xtdk/bltypes.h | 2 +- xtldr/includes/xtldr.h | 2 +- xtldr/memory.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/xtdk/bltypes.h b/sdk/xtdk/bltypes.h index 7761edb..ce762c0 100644 --- a/sdk/xtdk/bltypes.h +++ b/sdk/xtdk/bltypes.h @@ -40,7 +40,7 @@ #define XTBL_TUI_MAX_DIALOG_WIDTH 100 /* XTLDR Routine pointers */ -typedef LONG (*PBL_GET_MEMTYPE_ROUTINE)(IN LONG EfiMemoryType); +typedef LONG (*PBL_GET_MEMTYPE_ROUTINE)(IN EFI_MEMORY_TYPE EfiMemoryType); /* Boot Loader protocol routine pointers */ typedef EFI_STATUS (*PBL_ALLOCATE_PAGES)(IN ULONGLONG Size, OUT PEFI_PHYSICAL_ADDRESS Memory); diff --git a/xtldr/includes/xtldr.h b/xtldr/includes/xtldr.h index a379014..cbaa68f 100644 --- a/xtldr/includes/xtldr.h +++ b/xtldr/includes/xtldr.h @@ -465,7 +465,7 @@ BlpFindParentBlockDevice(IN PLIST_ENTRY BlockDevices, OUT PEFI_BLOCK_DEVICE_DATA ParentNode); XTCDECL -LOADER_MEMORY_TYPE +LONG BlpGetLoaderMemoryType(IN EFI_MEMORY_TYPE EfiMemoryType); XTCDECL diff --git a/xtldr/memory.c b/xtldr/memory.c index 2b57d57..e9e391a 100644 --- a/xtldr/memory.c +++ b/xtldr/memory.c @@ -292,7 +292,7 @@ BlMapEfiMemory(IN OUT PXTBL_PAGE_MAPPING PageMap, if(GetMemoryTypeRoutine == NULL) { /* Use default memory type routine */ - GetMemoryTypeRoutine = (PBL_GET_MEMTYPE_ROUTINE)BlpGetLoaderMemoryType; + GetMemoryTypeRoutine = BlpGetLoaderMemoryType; } /* Allocate and zero-fill buffer for EFI memory map */ @@ -703,7 +703,7 @@ BlPhysicalListToVirtual(IN PXTBL_PAGE_MAPPING PageMap, * @since XT 1.0 */ XTCDECL -LOADER_MEMORY_TYPE +LONG BlpGetLoaderMemoryType(IN EFI_MEMORY_TYPE EfiMemoryType) { LOADER_MEMORY_TYPE MemoryType;