From d46d26a260f5882b2559949aa43e8fb47bd16a7e Mon Sep 17 00:00:00 2001 From: Regia König Date: Tue, 16 Aug 2022 16:37:50 +0200 Subject: New script to analyze efi executable --- GNU_efi_HelloWorld/analyse_hello.sh | 8 ++++++++ GNU_efi_HelloWorld/hello.c | 3 +++ GNU_efi_HelloWorld/peinfo | Bin 0 -> 27600 bytes documentation/GNU-efi | 9 +++++++++ 4 files changed, 20 insertions(+) create mode 100755 GNU_efi_HelloWorld/analyse_hello.sh create mode 100755 GNU_efi_HelloWorld/peinfo diff --git a/GNU_efi_HelloWorld/analyse_hello.sh b/GNU_efi_HelloWorld/analyse_hello.sh new file mode 100755 index 0000000..cfaad73 --- /dev/null +++ b/GNU_efi_HelloWorld/analyse_hello.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +echo "objdump -h hello.efi" +objdump -h hello.efi + +echo "########################################################################" +echo "peinfo hello.efi | grep text -A 5" +peinfo hello.efi | grep text -A 5 diff --git a/GNU_efi_HelloWorld/hello.c b/GNU_efi_HelloWorld/hello.c index 52c05b3..817c135 100644 --- a/GNU_efi_HelloWorld/hello.c +++ b/GNU_efi_HelloWorld/hello.c @@ -8,5 +8,8 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { InitializeLib(ImageHandle, SystemTable); Print(L"Hello, world!\n"); + // TODO: get SystemTable-> ... -> ImageBase + // Print ImageBase + return EFI_SUCCESS; } diff --git a/GNU_efi_HelloWorld/peinfo b/GNU_efi_HelloWorld/peinfo new file mode 100755 index 0000000..4645ea4 Binary files /dev/null and b/GNU_efi_HelloWorld/peinfo differ diff --git a/documentation/GNU-efi b/documentation/GNU-efi index bb22b9e..63097fe 100644 --- a/documentation/GNU-efi +++ b/documentation/GNU-efi @@ -166,8 +166,17 @@ from the EFI Shell. Or you can rename it to EFI\BOOT\BOOTX64.EFI and it should be executed automatically on boot. +LIBEFI.A +Has wrappers for the most common UEFI functions, but you might need to call +something not covered. For completeness, it provides: +uefi_call_wrapper(func, numarg, ...); + +For example, the "Print" function used in our main.c and which accepts printf +compatible arguments, is under the hood nothing else than a call to: + +uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, buffer); -- cgit v1.2.3-55-g7522