diff options
-rwxr-xr-x | GNU_efi_HelloWorld/analyse_hello.sh | 2 | ||||
-rw-r--r-- | GNU_efi_HelloWorld/hello.c | 21 | ||||
-rwxr-xr-x | GNU_efi_HelloWorld/hello.efi | bin | 45555 -> 46888 bytes | |||
-rw-r--r-- | GNU_efi_HelloWorld/hello.o | bin | 1664 -> 2112 bytes | |||
-rwxr-xr-x | GNU_efi_HelloWorld/hello.so | bin | 2170968 -> 2171456 bytes | |||
-rw-r--r-- | documentation/GNU-efi | 4 | ||||
-rw-r--r-- | test_code/OVMF_VARS.fd | bin | 540672 -> 540672 bytes |
7 files changed, 23 insertions, 4 deletions
diff --git a/GNU_efi_HelloWorld/analyse_hello.sh b/GNU_efi_HelloWorld/analyse_hello.sh index cfaad73..c8b3103 100755 --- a/GNU_efi_HelloWorld/analyse_hello.sh +++ b/GNU_efi_HelloWorld/analyse_hello.sh @@ -5,4 +5,4 @@ objdump -h hello.efi echo "########################################################################" echo "peinfo hello.efi | grep text -A 5" -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 817c135..171db1e 100644 --- a/GNU_efi_HelloWorld/hello.c +++ b/GNU_efi_HelloWorld/hello.c @@ -5,11 +5,28 @@ EFI_STATUS EFIAPI efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { + EFI_LOADED_IMAGE *loaded_image = NULL; + EFI_STATUS status; + InitializeLib(ImageHandle, SystemTable); Print(L"Hello, world!\n"); - // TODO: get SystemTable-> ... -> ImageBase - // Print ImageBase + status = uefi_call_wrapper(SystemTable->BootServices->HandleProtocol, + 3, + ImageHandle, + &LoadedImageProtocol, + (void **)&loaded_image); + + if (EFI_ERROR(status)) { + Print(L"handleprotocol: %r\n", status); + } + + Print(L"Image base: 0x%lx\n", loaded_image->ImageBase); + + int wait = 1; + while(wait) { + __asm__ __volatile__("pause"); + } return EFI_SUCCESS; } diff --git a/GNU_efi_HelloWorld/hello.efi b/GNU_efi_HelloWorld/hello.efi Binary files differindex 27145e5..c8399c0 100755 --- a/GNU_efi_HelloWorld/hello.efi +++ b/GNU_efi_HelloWorld/hello.efi diff --git a/GNU_efi_HelloWorld/hello.o b/GNU_efi_HelloWorld/hello.o Binary files differindex 22a8362..21583fe 100644 --- a/GNU_efi_HelloWorld/hello.o +++ b/GNU_efi_HelloWorld/hello.o diff --git a/GNU_efi_HelloWorld/hello.so b/GNU_efi_HelloWorld/hello.so Binary files differindex bc418e3..b64f729 100755 --- a/GNU_efi_HelloWorld/hello.so +++ b/GNU_efi_HelloWorld/hello.so diff --git a/documentation/GNU-efi b/documentation/GNU-efi index 27c77e3..5d75960 100644 --- a/documentation/GNU-efi +++ b/documentation/GNU-efi @@ -186,5 +186,7 @@ make the same call as: ST->ConOut->OutputString(ST->ConOut, buffer); - +################################################################################# +# https://wiki.osdev.org/Debugging_UEFI_applications_with_GDB # +################################################################################# diff --git a/test_code/OVMF_VARS.fd b/test_code/OVMF_VARS.fd Binary files differindex 9883b80..852d584 100644 --- a/test_code/OVMF_VARS.fd +++ b/test_code/OVMF_VARS.fd |