summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx26
1 files changed, 23 insertions, 3 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx b/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx
index 0d44086b..9174293e 100644
--- a/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx
@@ -11,13 +11,33 @@
#include <BootKit/Processor.hxx>
#include <BootKit/Protocol.hxx>
+// don't remove EfiGUID, it will call initializer_list!
+
EFI_EXTERN_C int EfiMain(EfiHandlePtr ImageHandle,
- EfiSystemTable *SystemTable) {
+ EfiSystemTable* SystemTable) {
SystemTable->ConOut->OutputString(SystemTable->ConOut,
L"HCoreLdr: Starting \\EPM\\HCore...\r\n");
- if (SystemTable->BootServices->ExitBootServices(
- ImageHandle, kBaseHandoverStruct) != kEfiOk) {
+ EfiLoadImageProtocol* protocol{};
+
+ EfiGUID guid = EfiGUID EFI_LOADED_IMAGE_PROTOCOL_GUID;
+
+ SystemTable->BootServices->LocateProtocol(&guid, nullptr,
+ (VoidPtr*)&protocol);
+
+ if (!protocol) {
+ SystemTable->ConOut->OutputString(
+ SystemTable->ConOut,
+ L"HCoreLdr: Could not locate EfiLoadImageProtocol! Aborting...\r\n");
+
+ return kEfiFail;
+ }
+
+ SystemTable->BootServices->OpenProtocol(
+ ImageHandle, &guid, (VoidPtr*)&protocol, ImageHandle, ImageHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+
+ if (SystemTable->BootServices->ExitBootServices(ImageHandle, 0) != kEfiOk) {
SystemTable->ConOut->OutputString(
SystemTable->ConOut,
L"HCoreLdr: Could not Exit UEFI!\r\nHanging...\r\n");