Skip to content

Commit

Permalink
Improve 'BootLogo' Handling
Browse files Browse the repository at this point in the history
dakanji committed Jan 10, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 65be5b9 commit adafab2
Showing 16 changed files with 476 additions and 162 deletions.
62 changes: 61 additions & 1 deletion BootMaster/config.c
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
*/
/*
* Modified for RefindPlus
* Copyright (c) 2020-2024 Dayo Akanji (sf.net/u/dakanji/profile)
* Copyright (c) 2020-2025 Dayo Akanji (sf.net/u/dakanji/profile)
* Portions Copyright (c) 2021 Joe van Tunen ([email protected])
*
* Modifications distributed under the preceding terms.
@@ -2362,6 +2362,9 @@ VOID ReadConfig (
BOOLEAN GotSyncTrustAll;
BOOLEAN GotNoneSyncTrust;
BOOLEAN OutLoopSyncTrust;
BOOLEAN GotNoBootLogoAll;
BOOLEAN GotNoneNoBootLogo;
BOOLEAN OutLoopNoBootLogo;
BOOLEAN GotGraphicsForAll;
BOOLEAN GotNoneGraphicsFor;
BOOLEAN OutLoopGraphicsFor;
@@ -2508,6 +2511,7 @@ VOID ReadConfig (
CheckManual = DoneManual = FALSE;
GotNoneHideui = OutLoopHideui = FALSE;
GotNoneSyncTrust = OutLoopSyncTrust = FALSE;
GotNoneNoBootLogo = OutLoopNoBootLogo = FALSE;
GotNoneGraphicsFor = OutLoopGraphicsFor = FALSE;
#if REFIT_DEBUG > 0
if (!OuterLoop) {
@@ -3745,6 +3749,62 @@ VOID ReadConfig (
TokenList, TokenCount
);
}
else if (MyStriCmp (TokenList[0], L"disable_bootlogo")) {
#if REFIT_DEBUG > 0
if (!OuterLoop && !OutLoopNoBootLogo) {
UpdatedToken = LogUpdate (
TokenList[0], NotRunBefore, TRUE
);
}
#endif

GotNoBootLogoAll = FALSE;
if (!OuterLoop && !OutLoopNoBootLogo) {
// DA-TAG: Allows reset/override in 'included' config files
OutLoopNoBootLogo = TRUE;
GlobalConfig.DisableBootLogo = DISABLE_BOOTLOGO_OFF;
}

for (i = 1; i < TokenCount; i++) {
Flag = TokenList[i];
if (MyStrBegins (Flag, L"Off")) {
// DA-TAG: Required despite earlier reset
// This will always be used if in token list
GotNoneNoBootLogo = TRUE;
GlobalConfig.DisableBootLogo = DISABLE_BOOTLOGO_OFF;
break;
}

if (!GotNoBootLogoAll) {
// DA-TAG: Arranged as so to prioritise 'Off' above
if (MyStrBegins (Flag, L"All")) {
GotNoBootLogoAll = TRUE;
GlobalConfig.DisableBootLogo = DISABLE_BOOTLOGO_ALL;
}
else {
if (0);
else if (MyStrBegins (Flag, L"Lin")) GlobalConfig.DisableBootLogo |= DISABLE_BOOTLOGO_LIN;
else if (MyStrBegins (Flag, L"Win")) GlobalConfig.DisableBootLogo |= DISABLE_BOOTLOGO_WIN;
else {
MsgStr = PoolPrint (
L"WARN: Invalid 'disable_bootlogo' Token:- '%s'", Flag
);

#if REFIT_DEBUG > 0
if (NotRunBefore) MuteLogger = FALSE;
LOG_MSG("%s - %s", OffsetNext, MsgStr);
if (NotRunBefore) MuteLogger = TRUE;
#endif

SwitchToText (FALSE);
PrintUglyText (MsgStr, NEXTLINE);
PauseForKey();
MY_FREE_POOL(MsgStr);
}
}
}
} // for
}
else if (MyStriCmp (TokenList[0], L"supply_nvme")) {
#if REFIT_DEBUG > 0
if (!OuterLoop) {
9 changes: 8 additions & 1 deletion BootMaster/global.h
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
*/
/*
* Modified for RefindPlus
* Copyright (c) 2020-2024 Dayo Akanji (sf.net/u/dakanji/profile)
* Copyright (c) 2020-2025 Dayo Akanji (sf.net/u/dakanji/profile)
*
* Modifications distributed under the preceding terms.
*/
@@ -294,6 +294,12 @@ EFI\\OEM\\Boot\\bootmgfw.efi"
#define REQUIRE_TRUST_VERIFY (64)
#define ENFORCE_TRUST_EVERY (127) // 1 + 2 + 4 + 8 + 16 + 32 + 64

// Bit codes (Actual Decimal) ... Used in GlobalConfig.DisableBootLogo
#define DISABLE_BOOTLOGO_OFF (0) // Binary: 0000 0000 0000
#define DISABLE_BOOTLOGO_LIN (1) // Binary: 0000 0000 0001
#define DISABLE_BOOTLOGO_WIN (2) // Binary: 0000 0000 0010
#define DISABLE_BOOTLOGO_ALL (3) // Binary: 0000 0000 0011 (1 + 2)

// Bit codes (Actual Decimal) ... Used in GlobalConfig.HideUIFlags
#define HIDEUI_FLAG_NONE (0)
#define HIDEUI_FLAG_BANNER (1)
@@ -531,6 +537,7 @@ typedef struct {
UINTN RequestedScreenWidth;
UINTN RequestedScreenHeight;
UINTN BannerBottomEdge;
UINTN DisableBootLogo;
UINTN HideUIFlags;
UINTN SyncTrust;
UINTN MaxTags;
107 changes: 75 additions & 32 deletions BootMaster/icns.c
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@
*/
/*
* Modified for RefindPlus
* Copyright (c) 2020-2024 Dayo Akanji (sf.net/u/dakanji/profile)
* Copyright (c) 2020-2025 Dayo Akanji (sf.net/u/dakanji/profile)
* Portions Copyright (c) 2021 Joe van Tunen ([email protected])
*
* Modifications distributed under the preceding terms.
@@ -261,6 +261,8 @@ EG_IMAGE * LoadOSIcon (
IN BOOLEAN BootLogo
) {
EG_IMAGE *Image;
BOOLEAN WinAltIcon;
BOOLEAN LoadCustom;
CHAR16 *CutoutName;
CHAR16 *BaseName;
UINTN Index2;
@@ -272,7 +274,14 @@ EG_IMAGE * LoadOSIcon (
return NULL;
}

// Try to find an icon from the OSIconName list
if (BootLogo && GlobalConfig.DisableBootLogo == DISABLE_BOOTLOGO_ALL) {
return NULL;
}

LoadCustom = MyStriCmp (FallbackIconName, EXIT_SPLASH);
WinAltIcon = MyStriCmp (FallbackIconName, L"windows");

// Try to find an icon from the OSIconName list.
Index = 0;
OurId = -1;
Image = NULL;
@@ -286,8 +295,8 @@ EG_IMAGE * LoadOSIcon (
CutoutName
);

// Skip cache check if BootLogo is set
// BootLogo is not cached
// Skip cache check if BootLogo is set.
// BootLogo is not cached.
if (GlobalConfig.HelpIcon && !BootLogo) {
for (Index2 = 0; Index2 < BASE_OS_ICON_COUNT; Index2++) {
Image = LoadIndexedIcon (BaseName, Index2);
@@ -306,10 +315,11 @@ EG_IMAGE * LoadOSIcon (
MY_FREE_POOL(CutoutName);
} // while

// Try again with "os_" if that fails and BootLogo was set
if (BootLogo && Image == NULL) {
Index = 0;
OurId = -1;
// Try again with 'os_' if that fails,
// BootLogo was set, but not 'LoadCustom'.
if (!LoadCustom && BootLogo && Image == NULL) {
Index = 0;
OurId = -1;
while (
Image == NULL &&
(CutoutName = FindCommaDelimited (OSIconName, Index++)) != NULL
@@ -319,37 +329,25 @@ EG_IMAGE * LoadOSIcon (
CutoutName
);

// Skip cache check if BootLogo is set
// BootLogo is not cached
if (GlobalConfig.HelpIcon && !BootLogo) {
for (Index2 = 0; Index2 < BASE_OS_ICON_COUNT; Index2++) {
Image = LoadIndexedIcon (BaseName, Index2);
if (Image != NULL) {
OurId = (Index2 < BASE_OS_ICON_COUNT)
? Index2 : (BASE_OS_ICON_COUNT - 1);

break;
}
} // for
}

// No cache check as BootLogo is set.
// BootLogo is not cached.
UpdateBaseIcon (BaseName, &Image);

MY_FREE_POOL(BaseName);
MY_FREE_POOL(CutoutName);
} // while
}

// Try again using "FallbackIconName" if that fails
// Try again using 'FallbackIconName' if that fails.
if (Image == NULL) {
BaseName = PoolPrint (
L"%s_%s",
(BootLogo) ? L"boot" : L"os",
FallbackIconName
);

// Skip cache check if BootLogo is set
// BootLogo is not cached
// Skip cache check if BootLogo is set.
// BootLogo is not cached.
if (GlobalConfig.HelpIcon && !BootLogo) {
for (Index2 = 0; Index2 < BASE_OS_ICON_COUNT; Index2++) {
Image = LoadIndexedIcon (BaseName, Index2);
@@ -364,10 +362,38 @@ EG_IMAGE * LoadOSIcon (

UpdateBaseIcon (BaseName, &Image);
MY_FREE_POOL(BaseName);

// If that fails and 'WinAltIcon' is set,
// try with 'win' as 'FallbackIconName'.
if (Image == NULL && WinAltIcon) {
BaseName = PoolPrint (
L"%s_%s",
(BootLogo) ? L"boot" : L"os",
L"win"
);

// Skip cache check if BootLogo is set.
// BootLogo is not cached.
if (GlobalConfig.HelpIcon && !BootLogo) {
for (Index2 = 0; Index2 < BASE_OS_ICON_COUNT; Index2++) {
Image = LoadIndexedIcon (BaseName, Index2);
if (Image != NULL) {
OurId = (Index2 < BASE_OS_ICON_COUNT)
? Index2 : (BASE_OS_ICON_COUNT - 1);

break;
}
} // for
}

UpdateBaseIcon (BaseName, &Image);
MY_FREE_POOL(BaseName);
}
}

// Try again with "os_" if that fails and BootLogo was set
if (BootLogo && Image == NULL) {
// Try again with 'os_' if that fails,
// BootLogo was set, but not 'LoadCustom'.
if (!LoadCustom && BootLogo && Image == NULL) {
BaseName = PoolPrint (L"os_%s", FallbackIconName);

if (GlobalConfig.HelpIcon) {
@@ -384,10 +410,27 @@ EG_IMAGE * LoadOSIcon (

UpdateBaseIcon (BaseName, &Image);
MY_FREE_POOL(BaseName);

// Try 'os_win' if that fails and 'WinAltIcon' is set.
if (Image == NULL && WinAltIcon) {
if (GlobalConfig.HelpIcon) {
for (Index2 = 0; Index2 < BASE_OS_ICON_COUNT; Index2++) {
Image = LoadIndexedIcon (L"os_win", Index2);
if (Image != NULL) {
OurId = (Index2 < BASE_OS_ICON_COUNT)
? Index2 : (BASE_OS_ICON_COUNT - 1);

break;
}
} // for
}

UpdateBaseIcon (L"os_win", &Image);
}
}

// Try again with the "unknown" icon specifically if that fails.
// Only if BootLogo is *NOT* set ... No "unknown" BootLogo icon
// Only if BootLogo is *NOT* set ... No "unknown" BootLogo icon.
if (!BootLogo &&
Image == NULL &&
!MyStriCmp (FallbackIconName, L"unknown")
@@ -406,8 +449,8 @@ EG_IMAGE * LoadOSIcon (
}
}

// Use the "dummy" image if still fails
if (Image == NULL) {
// Use the "dummy" image if still fails and BootLogo is *NOT* set.
if (!BootLogo && Image == NULL) {
#if REFIT_DEBUG > 0
ALT_LOG(1, LOG_LINE_NORMAL, L"Set Dummy Image");
#endif
@@ -425,12 +468,12 @@ EG_IMAGE * LoadOSIcon (
}
}

// Return NULL if all failed
// Return NULL if all failed.
if (Image == NULL) {
return NULL;
}

// Cache the image if appropriate and not BootLogo
// Cache the image if appropriate and not BootLogo.
if (GlobalConfig.HelpIcon && !BootLogo) {
if (OurId >= 0 && TableBuiltinIconOS[OurId].Image == NULL) {
TableBuiltinIconOS[OurId].Image = Image;
4 changes: 3 additions & 1 deletion BootMaster/icns.h
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
*/
/*
* Modified for RefindPlus
* Copyright (c) 2020-2024 Dayo Akanji (sf.net/u/dakanji/profile)
* Copyright (c) 2020-2025 Dayo Akanji (sf.net/u/dakanji/profile)
*
* Modifications distributed under the preceding terms.
*/
@@ -105,6 +105,8 @@ EG_IMAGE * BuiltinIcon (IN UINTN Id);
#define BASE_OS_ICON_UEFI (10)
#define BASE_OS_ICON_COUNT (11)

#define EXIT_SPLASH L"outlogo"

#endif

/* EOF */
Loading

0 comments on commit adafab2

Please sign in to comment.