From 0256353e4523b96bc314e85486ce3289a5c002a0 Mon Sep 17 00:00:00 2001 From: Mattiwatti Date: Thu, 28 May 2020 18:53:20 +0200 Subject: [PATCH] Loader: call BmSetMemoryTypeInformationVariable Note that BmSetMemoryTypeInformationVariable() is told by the loader that the image being loaded is *not* a boot application, which is a blatant lie. The reason for doing this is to prevent BmSetMemoryTypeInformationVariable() from performing a warm reset of the system due to a change in the memory type info. (Again, and again, and again...) This is an attempt to fix S4 (hibernate) entry/resume issues; see #12. --- Application/Loader/Loader.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Application/Loader/Loader.c b/Application/Loader/Loader.c index eba4f56..d240c5d 100644 --- a/Application/Loader/Loader.c +++ b/Application/Loader/Loader.c @@ -36,6 +36,14 @@ STATIC CHAR16* mDriverPaths[] = { }; +extern +EFI_STATUS +EFIAPI +BmSetMemoryTypeInformationVariable( + IN BOOLEAN Boot + ); + + STATIC BOOLEAN EFIAPI @@ -511,6 +519,10 @@ TryBootOptionsInOrder( // So again, DO NOT call this abortion: //BmSetMemoryTypeInformationVariable((BOOLEAN)((BootOptions[Index].Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_BOOT)); + // + // OK, maybe call it after all, but pretend this is *not* a boot entry, so that the system will not go into an infinite boot (reset) loop. + // This may or may not fix hibernation related issues (S4 entry/resume). See https://github.com/Mattiwatti/EfiGuard/issues/12 + BmSetMemoryTypeInformationVariable(FALSE); // Ensure the image path is connected end-to-end by Dispatch()ing any required drivers through DXE services EfiBootManagerConnectDevicePath(BootOptions[Index].FilePath, NULL);