mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-01-22 21:01:31 +01:00
Refactor the hidden flag. All menu entries are now created, allowing to
toogle hidden flag on and off after creation.
This commit is contained in:
parent
bc04c86a93
commit
f6903b7579
@ -37,6 +37,12 @@ bool i_have_panicked = false;
|
||||
*
|
||||
* Function panic_ seems useless. It's same as panic(). It's to be able to put a breakpoint in gdb with br panic_(). This is done in gdb_launch script in Qemu
|
||||
*/
|
||||
static void panic_(const char* format, VA_LIST va)
|
||||
#ifndef PANIC_CAN_RETURN
|
||||
__attribute__ ((noreturn));
|
||||
#endif
|
||||
;
|
||||
|
||||
static void panic_(const char* format, VA_LIST va)
|
||||
{
|
||||
if ( format ) {
|
||||
@ -50,6 +56,7 @@ static void panic_(const char* format, VA_LIST va)
|
||||
|
||||
void panic(const char* format, ...)
|
||||
{
|
||||
#ifdef PANIC_CAN_RETURN
|
||||
if ( stop_at_panic ) {
|
||||
VA_LIST va;
|
||||
VA_START(va, format);
|
||||
@ -58,6 +65,11 @@ void panic(const char* format, ...)
|
||||
}else{
|
||||
i_have_panicked = true;
|
||||
}
|
||||
#else
|
||||
VA_LIST va;
|
||||
VA_START(va, format);
|
||||
panic_(format, va); // panic doesn't return
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,8 +8,17 @@
|
||||
extern bool stop_at_panic;
|
||||
extern bool i_have_panicked;
|
||||
|
||||
void panic(void);
|
||||
void panic(const char* format, ...) __attribute__((__format__(__printf__, 1, 2)));
|
||||
void panic(void)
|
||||
#ifndef PANIC_CAN_RETURN
|
||||
__attribute__ ((noreturn));
|
||||
#endif
|
||||
;
|
||||
|
||||
void panic(const char* format, ...) __attribute__((__format__(__printf__, 1, 2)))
|
||||
#ifndef PANIC_CAN_RETURN
|
||||
__attribute__ ((noreturn));
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
class DontStopAtPanic
|
||||
|
@ -1659,9 +1659,9 @@ FillinCustomEntry (
|
||||
(Prop->string.equalIC("Always"))) {
|
||||
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_DISABLED);
|
||||
} else if (IsPropertyTrue(Prop)) {
|
||||
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_HIDDEN);
|
||||
Entry->Hidden = true;
|
||||
} else {
|
||||
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_HIDDEN);
|
||||
Entry->Hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1911,9 +1911,9 @@ FillingCustomLegacy (
|
||||
(Prop->string.equalIC("Always"))) {
|
||||
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_DISABLED);
|
||||
} else if (IsPropertyTrue(Prop)) {
|
||||
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_HIDDEN);
|
||||
Entry->Hidden = true;
|
||||
} else {
|
||||
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_HIDDEN);
|
||||
Entry->Hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2007,9 +2007,9 @@ FillingCustomTool (IN OUT CUSTOM_TOOL_ENTRY *Entry, TagPtr DictPointer)
|
||||
(Prop->string.equalIC("Always"))) {
|
||||
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_DISABLED);
|
||||
} else if (IsPropertyTrue(Prop)) {
|
||||
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_HIDDEN);
|
||||
Entry->Hidden = true;
|
||||
} else {
|
||||
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_HIDDEN);
|
||||
Entry->Hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2557,25 +2557,17 @@ GetEarlyUserSettings (
|
||||
if (Prop != NULL) {
|
||||
INTN i, Count = GetTagCount (Prop);
|
||||
if (Count > 0) {
|
||||
gSettings.HVCount = 0;
|
||||
gSettings.HVHideStrings = (__typeof__(gSettings.HVHideStrings))AllocateZeroPool(Count * sizeof(CHAR16 *));
|
||||
if (gSettings.HVHideStrings) {
|
||||
for (i = 0; i < Count; i++) {
|
||||
if (EFI_ERROR(GetElement(Prop, i, &Dict2))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Dict2 == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((Dict2->type == kTagTypeString) && Dict2->string.notEmpty() ) {
|
||||
gSettings.HVHideStrings[gSettings.HVCount] = SWPrintf("%s", Dict2->string.c_str()).forgetDataWithoutFreeing();
|
||||
if (gSettings.HVHideStrings[gSettings.HVCount]) {
|
||||
DBG("Hiding entries with string %ls\n", gSettings.HVHideStrings[gSettings.HVCount]);
|
||||
gSettings.HVCount++;
|
||||
}
|
||||
}
|
||||
gSettings.HVHideStrings.setEmpty();
|
||||
for (i = 0; i < Count; i++) {
|
||||
if (EFI_ERROR(GetElement(Prop, i, &Dict2))) {
|
||||
continue;
|
||||
}
|
||||
if (Dict2 == NULL) {
|
||||
break;
|
||||
}
|
||||
if ((Dict2->type == kTagTypeString) && Dict2->string.notEmpty() ) {
|
||||
gSettings.HVHideStrings.Add(Dict2->string);
|
||||
DBG("Hiding entries with string %s\n", Dict2->string.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8018,7 +8010,7 @@ checkOffset(CpuType);
|
||||
WriteOldFixLengthString(Language, 16);
|
||||
checkOffset(BootArgs);
|
||||
WriteOldFixLengthString(BootArgs, 256);
|
||||
xb.cat((char)0);
|
||||
xb.memsetAtPos(xb.size(), 0, 1);
|
||||
checkOffset(CustomUuid);
|
||||
WriteOldFixLengthString(CustomUuid, 40);
|
||||
xb.ncat(&pad20, sizeof(pad20));
|
||||
@ -8182,8 +8174,8 @@ checkOffset(LegacyBoot);
|
||||
xb.cat(HWPValue);
|
||||
|
||||
//Volumes hiding
|
||||
xb.cat(HVHideStrings);
|
||||
xb.cat(HVCount);
|
||||
xb.cat(uintptr_t(0)); // HVHideStrings was **
|
||||
xb.cat((INTN)0);
|
||||
|
||||
// KernelAndKextPatches
|
||||
xb.memsetAtPos(xb.size(), 0, 112); //KernelAndKextPatches was 112 bytes
|
||||
@ -8263,7 +8255,7 @@ checkOffset(Rtc8Allowed);
|
||||
// Custom entries
|
||||
xb.cat(DisableEntryScan);
|
||||
xb.cat(DisableToolScan);
|
||||
xb.cat(ShowHiddenEntries);
|
||||
xb.cat((BOOLEAN)0); // was ShowHiddenEntries (BOOLEAN)
|
||||
xb.cat(KernelScan);
|
||||
xb.cat(LinuxScan);
|
||||
// UINT8 pad84[3]);
|
||||
|
@ -94,8 +94,9 @@ public:
|
||||
~ACPI_DROP_TABLE() {}
|
||||
};
|
||||
|
||||
typedef struct CUSTOM_LOADER_ENTRY CUSTOM_LOADER_ENTRY;
|
||||
struct CUSTOM_LOADER_ENTRY {
|
||||
class CUSTOM_LOADER_ENTRY
|
||||
{
|
||||
public:
|
||||
CUSTOM_LOADER_ENTRY *Next;
|
||||
CUSTOM_LOADER_ENTRY *SubEntries;
|
||||
XIcon Image;
|
||||
@ -112,6 +113,7 @@ struct CUSTOM_LOADER_ENTRY {
|
||||
CHAR16 Hotkey;
|
||||
BOOLEAN CommonSettings;
|
||||
UINT8 Flags;
|
||||
bool Hidden;
|
||||
UINT8 Type;
|
||||
UINT8 VolumeType;
|
||||
UINT8 KernelScan;
|
||||
@ -121,7 +123,7 @@ struct CUSTOM_LOADER_ENTRY {
|
||||
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches;
|
||||
|
||||
CUSTOM_LOADER_ENTRY() : Next(0), SubEntries(0), Image(), DriveImage(), ImagePath(), DriveImagePath(), Volume(), Path(), LoadOptions(),
|
||||
FullTitle(), Title(), Settings(), Hotkey(0), CommonSettings(0), Flags(0), Type(0), VolumeType(0),
|
||||
FullTitle(), Title(), Settings(), Hotkey(0), CommonSettings(0), Flags(0), Hidden(0), Type(0), VolumeType(0),
|
||||
KernelScan(0), CustomBoot(0), CustomLogo(), BootBgColor({0,0,0,0}), KernelAndKextPatches()
|
||||
{ }
|
||||
|
||||
@ -144,10 +146,11 @@ public:
|
||||
XStringW Title;
|
||||
CHAR16 Hotkey;
|
||||
UINT8 Flags;
|
||||
bool Hidden;
|
||||
UINT8 Type;
|
||||
UINT8 VolumeType;
|
||||
|
||||
CUSTOM_LEGACY_ENTRY() : Next(0), Image(), DriveImage(), ImagePath(), DriveImagePath(), Volume(), FullTitle(), Title(), Hotkey(0), Flags(0), Type(0), VolumeType(0) { }
|
||||
CUSTOM_LEGACY_ENTRY() : Next(0), Image(), DriveImage(), ImagePath(), DriveImagePath(), Volume(), FullTitle(), Title(), Hotkey(0), Flags(0), Hidden(0), Type(0), VolumeType(0) { }
|
||||
|
||||
// Not sure if default are valid. Delete them. If needed, proper ones can be created
|
||||
CUSTOM_LEGACY_ENTRY(const CUSTOM_LEGACY_ENTRY&) = delete;
|
||||
@ -167,9 +170,10 @@ public:
|
||||
XStringW Title;
|
||||
CHAR16 Hotkey;
|
||||
UINT8 Flags;
|
||||
bool Hidden;
|
||||
UINT8 VolumeType;
|
||||
|
||||
CUSTOM_TOOL_ENTRY() : Next(0), Image(), ImagePath(), Volume(), Path(), LoadOptions(), FullTitle(), Title(), Hotkey(0), Flags(0), VolumeType(0) { }
|
||||
CUSTOM_TOOL_ENTRY() : Next(0), Image(), ImagePath(), Volume(), Path(), LoadOptions(), FullTitle(), Title(), Hotkey(0), Flags(0), Hidden(0), VolumeType(0) { }
|
||||
|
||||
// Not sure if default are valid. Delete them. If needed, proper ones can be created
|
||||
CUSTOM_TOOL_ENTRY(const CUSTOM_TOOL_ENTRY&) = delete;
|
||||
@ -446,9 +450,7 @@ public:
|
||||
UINT32 HWPValue;
|
||||
|
||||
//Volumes hiding
|
||||
CHAR16 **HVHideStrings;
|
||||
|
||||
INTN HVCount;
|
||||
XString8Array HVHideStrings;
|
||||
|
||||
// KernelAndKextPatches
|
||||
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches; //zzzz
|
||||
@ -531,7 +533,6 @@ public:
|
||||
// Custom entries
|
||||
BOOLEAN DisableEntryScan;
|
||||
BOOLEAN DisableToolScan;
|
||||
BOOLEAN ShowHiddenEntries;
|
||||
UINT8 KernelScan;
|
||||
BOOLEAN LinuxScan;
|
||||
UINT8 pad35[3];
|
||||
@ -600,12 +601,12 @@ public:
|
||||
NvidiaNoEFI(0), NvidiaSingle(0), VRAM(0), Dcfg{0}, NVCAP{0}, BootDisplay(0), NvidiaWeb(0), pad41{0}, DualLink(0),
|
||||
IgPlatform(0), SecureBootWhiteListCount(0), SecureBootBlackListCount(0), SecureBootWhiteList(0), SecureBootBlackList(0), SecureBoot(0), SecureBootSetupMode(0), SecureBootPolicy(0), HDAInjection(0),
|
||||
HDALayoutId(0), USBInjection(0), USBFixOwnership(0), InjectClockID(0), HighCurrent(0), NameEH00(0), NameXH00(0), LANInjection(0), HDMIInjection(0),
|
||||
LegacyBoot{0}, LegacyBiosDefaultEntry(0), HWP(0), TDP(0), HWPValue(0), HVHideStrings(0), HVCount(0), KernelAndKextPatches(), KextPatchesAllowed(0),
|
||||
LegacyBoot{0}, LegacyBiosDefaultEntry(0), HWP(0), TDP(0), HWPValue(0), HVHideStrings(), KernelAndKextPatches(), KextPatchesAllowed(0),
|
||||
KernelPatchesAllowed(0), AirportBridgeDeviceName{0}, KbdPrevLang(0), PointerEnabled(0), PointerSpeed(0), DoubleClickTime(0), PointerMirror(0), CustomBoot(0), CustomLogo(0),
|
||||
RefCLK(0), RtMLB(0), RtROM(0), RtROMLen(0), CsrActiveConfig(0), BooterConfig(0), BooterCfgStr{0}, DisableCloverHotkeys(0), NeverDoRecovery(0),
|
||||
ConfigName{0}, /*MainConfigName(0),*/ BlackListCount(0), BlackList(0), RPlt{0}, RBr{0}, EPCI{0}, REV{0}, Rtc8Allowed(0),
|
||||
ForceHPET(0), ResetHDA(0), PlayAsync(0), DisableFunctions(0), PatchDsdtNum(0), PatchDsdtFind(0), LenToFind(0), PatchDsdtReplace(0), LenToReplace(0), DebugDSDT(0), SlpWak(0), UseIntelHDMI(0),
|
||||
AFGLowPowerState(0), PNLF_UID(0), ACPIDropTables(0), DisableEntryScan(0), DisableToolScan(0), ShowHiddenEntries(0), KernelScan(0), LinuxScan(0), CustomEntries(0),
|
||||
AFGLowPowerState(0), PNLF_UID(0), ACPIDropTables(0), DisableEntryScan(0), DisableToolScan(0), KernelScan(0), LinuxScan(0), CustomEntries(0),
|
||||
CustomLegacy(0), CustomTool(0), NrAddProperties(0), AddProperties(0), BlockKexts{0}, SortedACPICount(0), SortedACPI(0), DisabledAMLCount(0), DisabledAML(0),
|
||||
PatchDsdtLabel(0), PatchDsdtTgt(0), PatchDsdtMenuItem(0), IntelMaxValue(0), OptionsBits(0), FlagsBits(0), UIScale(0), EFILoginHiDPI(0), flagstate{0},
|
||||
ArbProperties(0), QuirksMask(0), MaxSlide(0)
|
||||
|
@ -69,38 +69,11 @@ BOOLEAN AddLegacyEntry(IN const XStringW& FullTitle, IN const XStringW& LoaderTi
|
||||
// DBG("entry %lld\n", i);
|
||||
// Only want legacy
|
||||
if (MainEntry.getLEGACY_ENTRY()) {
|
||||
if (StriCmp(MainEntry.getLEGACY_ENTRY()->DevicePathString.wc_str(), Volume->DevicePathString.wc_str()) == 0) {
|
||||
if ( MainEntry.getLEGACY_ENTRY()->DevicePathString.equalIC(Volume->DevicePathString) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this isn't a custom entry make sure it's not hidden by a custom entry
|
||||
if (!CustomEntry) {
|
||||
CUSTOM_LEGACY_ENTRY *Custom = gSettings.CustomLegacy;
|
||||
while (Custom) {
|
||||
if (OSFLAG_ISSET(Custom->Flags, OSFLAG_DISABLED) ||
|
||||
(OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN) && !gSettings.ShowHiddenEntries)) {
|
||||
if (Custom->Volume.notEmpty()) {
|
||||
if ((StrStr(Volume->DevicePathString.wc_str(), Custom->Volume.wc_str()) == NULL) &&
|
||||
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom->Volume.wc_str()) == NULL))) {
|
||||
if (Custom->Type != 0) {
|
||||
if (Custom->Type == Volume->LegacyOS->Type) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (Custom->Type != 0) {
|
||||
if (Custom->Type == Volume->LegacyOS->Type) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Custom = Custom->Next;
|
||||
}
|
||||
}
|
||||
XStringW LTitle;
|
||||
if (LoaderTitle.isEmpty()) {
|
||||
if (Volume->LegacyOS->Name.notEmpty()) {
|
||||
@ -165,6 +138,32 @@ BOOLEAN AddLegacyEntry(IN const XStringW& FullTitle, IN const XStringW& LoaderTi
|
||||
// Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? "CD"_XS8 : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? "USB"_XS8 : "HD"_XS8);
|
||||
Entry->LoadOptions.setEmpty();
|
||||
Entry->LoadOptions.Add((Volume->DiskKind == DISK_KIND_OPTICAL) ? "CD" : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? "USB" : "HD"));
|
||||
|
||||
// If this isn't a custom entry make sure it's not hidden by a custom entry
|
||||
if (!CustomEntry) {
|
||||
CUSTOM_LEGACY_ENTRY *Custom = gSettings.CustomLegacy;
|
||||
while (Custom) {
|
||||
if ( OSFLAG_ISSET(Custom->Flags, OSFLAG_DISABLED) || Custom->Hidden ) {
|
||||
if (Custom->Volume.notEmpty()) {
|
||||
if ( !Volume->DevicePathString.contains(Custom->Volume) && !Volume->VolName.contains(Custom->Volume) ) {
|
||||
if (Custom->Type != 0) {
|
||||
if (Custom->Type == Volume->LegacyOS->Type) {
|
||||
Entry->Hidden = true;
|
||||
}
|
||||
} else {
|
||||
Entry->Hidden = true;
|
||||
}
|
||||
}
|
||||
} else if (Custom->Type != 0) {
|
||||
if (Custom->Type == Volume->LegacyOS->Type) {
|
||||
Entry->Hidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Custom = Custom->Next;
|
||||
}
|
||||
}
|
||||
|
||||
// create the submenu
|
||||
SubScreen = new REFIT_MENU_SCREEN();
|
||||
// SubScreen->Title = L"Boot Options for "_XSW + LoaderTitle + L" on "_XSW + VolDesc;
|
||||
@ -292,10 +291,10 @@ VOID AddCustomLegacy(VOID)
|
||||
DBG("Custom legacy %llu skipped because it is disabled.\n", i);
|
||||
continue;
|
||||
}
|
||||
if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN)) {
|
||||
DBG("Custom legacy %llu skipped because it is hidden.\n", i);
|
||||
continue;
|
||||
}
|
||||
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN)) {
|
||||
// DBG("Custom legacy %llu skipped because it is hidden.\n", i);
|
||||
// continue;
|
||||
// }
|
||||
if (Custom->Volume.notEmpty()) {
|
||||
DBG("Custom legacy %llu matching \"%ls\" ...\n", i, Custom->Volume.wc_str());
|
||||
}
|
||||
|
@ -488,6 +488,10 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
|
||||
}
|
||||
}
|
||||
// DBG("OSType =%d\n", OSType);
|
||||
// DBG("prepare the menu entry\n");
|
||||
// prepare the menu entry
|
||||
Entry = new LOADER_ENTRY();
|
||||
|
||||
if (!CustomEntry) {
|
||||
CUSTOM_LOADER_ENTRY *Custom;
|
||||
UINTN CustomIndex = 0;
|
||||
@ -507,8 +511,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
|
||||
Custom = gSettings.CustomEntries;
|
||||
while (Custom) {
|
||||
// Check if the custom entry is hidden or disabled
|
||||
if ((OSFLAG_ISSET(Custom->Flags, OSFLAG_DISABLED) ||
|
||||
(OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN) && !gSettings.ShowHiddenEntries))) {
|
||||
if ( OSFLAG_ISSET(Custom->Flags, OSFLAG_DISABLED) || Custom->Hidden ) {
|
||||
|
||||
INTN volume_match=0;
|
||||
INTN volume_type_match=0;
|
||||
@ -568,16 +571,13 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
|
||||
} else {
|
||||
// Custom entry match
|
||||
DBG("%sSkipped because matching custom entry %llu!\n", indent, CustomIndex);
|
||||
return NULL;
|
||||
Entry->Hidden = true;
|
||||
}
|
||||
}
|
||||
Custom = Custom->Next;
|
||||
++CustomIndex;
|
||||
}
|
||||
}
|
||||
// DBG("prepare the menu entry\n");
|
||||
// prepare the menu entry
|
||||
Entry = new LOADER_ENTRY();
|
||||
Entry->Row = 0;
|
||||
Entry->Volume = Volume;
|
||||
Entry->APFSTargetUUID = APFSTargetUUID;
|
||||
@ -999,7 +999,6 @@ LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Arr
|
||||
IN UINT8 OSType, IN UINT8 Flags)
|
||||
{
|
||||
LOADER_ENTRY *Entry;
|
||||
INTN HVi;
|
||||
|
||||
if ((LoaderPath.isEmpty()) || (Volume == NULL) || (Volume->RootDir == NULL) || !FileExists(Volume->RootDir, LoaderPath)) {
|
||||
return NULL;
|
||||
@ -1010,19 +1009,19 @@ LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Arr
|
||||
DBG(" skipped because entry is disabled\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Flags, OSFLAG_HIDDEN)) {
|
||||
DBG(" skipped because entry is hidden\n");
|
||||
return NULL;
|
||||
}
|
||||
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Flags, OSFLAG_HIDDEN)) {
|
||||
// DBG(" skipped because entry is hidden\n");
|
||||
// return NULL;
|
||||
// }
|
||||
//don't add hided entries
|
||||
if (!gSettings.ShowHiddenEntries) {
|
||||
for (HVi = 0; HVi < gSettings.HVCount; HVi++) {
|
||||
if ( LoaderPath.containsIC(gSettings.HVHideStrings[HVi]) ) {
|
||||
DBG(" hiding entry: %ls\n", LoaderPath.s());
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (!gSettings.ShowHiddenEntries) {
|
||||
// for (HVi = 0; HVi < gSettings.HVCount; HVi++) {
|
||||
// if ( LoaderPath.containsIC(gSettings.HVHideStrings[HVi]) ) {
|
||||
// DBG(" hiding entry: %ls\n", LoaderPath.s());
|
||||
// return NULL;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, FullTitle, LoaderTitle, Volume, APFSTargetUUID, Image, NULL, OSType, Flags, 0, MenuBackgroundPixel, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE);
|
||||
if (Entry != NULL) {
|
||||
if ((Entry->LoaderType == OSTYPE_OSX) ||
|
||||
@ -1039,6 +1038,16 @@ LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Arr
|
||||
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NOCACHES);
|
||||
}
|
||||
}
|
||||
if ( Volume->Hidden ) {
|
||||
Entry->Hidden = true;
|
||||
}else{
|
||||
for (size_t HVi = 0; HVi < gSettings.HVHideStrings.size(); HVi++) {
|
||||
if ( LoaderPath.containsIC(gSettings.HVHideStrings[HVi]) ) {
|
||||
DBG(" hiding entry: %ls\n", LoaderPath.s());
|
||||
Entry->Hidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO there is a problem that Entry->Flags is unique while InputItems are global ;(
|
||||
// InputItems[69].IValue = Entry->Flags;
|
||||
Entry->AddDefaultMenu();
|
||||
@ -1342,10 +1351,10 @@ VOID ScanLoader(VOID)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Volume->Hidden) {
|
||||
DBG(", hidden\n");
|
||||
continue;
|
||||
}
|
||||
// if (Volume->Hidden) {
|
||||
// DBG(", hidden\n");
|
||||
// continue;
|
||||
// }
|
||||
DBG("\n");
|
||||
|
||||
// check for Mac OS X Install Data
|
||||
@ -1435,6 +1444,7 @@ VOID ScanLoader(VOID)
|
||||
AddLoaderEntry(L"\\EFI\\MICROSOF\\BOOT\\CDBOOT.EFI"_XSW, NullXString8Array, L""_XSW, L"Microsoft EFI CDBOOT"_XSW, Volume, L""_XSW, NULL, OSTYPE_WINEFI, 0);
|
||||
}
|
||||
|
||||
|
||||
#if defined(ANDX86)
|
||||
if (TRUE) { //gSettings.AndroidScan
|
||||
// check for Android loaders
|
||||
@ -1467,40 +1477,14 @@ VOID ScanLoader(VOID)
|
||||
}
|
||||
// DBG("search for internal UEFI\n");
|
||||
if (Volume->DiskKind == DISK_KIND_INTERNAL) {
|
||||
AddLoaderEntry(BOOT_LOADER_PATH, NullXString8Array, L""_XSW, L"UEFI internal"_XSW, Volume, L""_XSW, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
|
||||
LOADER_ENTRY* le = AddLoaderEntry(BOOT_LOADER_PATH, NullXString8Array, L""_XSW, L"UEFI internal"_XSW, Volume, L""_XSW, NULL, OSTYPE_OTHER, 0);
|
||||
le->Hidden = true;
|
||||
}
|
||||
// DBG("search for external UEFI\n");
|
||||
if (Volume->DiskKind == DISK_KIND_EXTERNAL) {
|
||||
AddLoaderEntry(BOOT_LOADER_PATH, NullXString8Array, L""_XSW, L"UEFI external"_XSW, Volume, L""_XSW, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
|
||||
LOADER_ENTRY* le = AddLoaderEntry(BOOT_LOADER_PATH, NullXString8Array, L""_XSW, L"UEFI external"_XSW, Volume, L""_XSW, NULL, OSTYPE_OTHER, 0);
|
||||
le->Hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Pass to add non redundant Preboot volume AND redundant as hidden */
|
||||
|
||||
for (UINTN VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
||||
REFIT_VOLUME* Volume = &Volumes[VolumeIndex];
|
||||
if (Volume->RootDir == NULL) { // || Volume->VolName == NULL)
|
||||
//DBG(", no file system\n", VolumeIndex);
|
||||
continue;
|
||||
}
|
||||
DBG("- [%02llu]: '%ls'", VolumeIndex, Volume->VolName.wc_str());
|
||||
if (Volume->VolName.isEmpty()) {
|
||||
Volume->VolName = L"Unknown"_XSW;
|
||||
}
|
||||
|
||||
// skip volume if its kind is configured as disabled
|
||||
if (((1ull<<Volume->DiskKind) & GlobalConfig.DisableFlags) != 0)
|
||||
{
|
||||
DBG(", flagged disable\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Volume->Hidden) {
|
||||
DBG(", hidden\n");
|
||||
continue;
|
||||
}
|
||||
DBG("\n");
|
||||
|
||||
if ( Volume->ApfsTargetUUIDArray.size() > 0 ) {
|
||||
|
||||
@ -1508,7 +1492,6 @@ VOID ScanLoader(VOID)
|
||||
{
|
||||
const XString8& ApfsTargetUUID = Volume->ApfsTargetUUIDArray[i];
|
||||
|
||||
int flag = 0;
|
||||
const LOADER_ENTRY* targetLoaderEntry = NULL;
|
||||
for ( size_t entryIdx = 0 ; entryIdx < MainMenu.Entries.size() ; entryIdx ++ )
|
||||
{
|
||||
@ -1516,12 +1499,11 @@ VOID ScanLoader(VOID)
|
||||
const LOADER_ENTRY* loaderEntry = MainMenu.Entries[entryIdx].getLOADER_ENTRY();
|
||||
if ( loaderEntry->Volume->ApfsFileSystemUUID == ApfsTargetUUID ) {
|
||||
targetLoaderEntry = loaderEntry;
|
||||
flag = OSFLAG_HIDDEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( targetLoaderEntry ) {
|
||||
AddLoaderEntry(SWPrintf("\\%s\\System\\Library\\CoreServices\\boot.efi", ApfsTargetUUID.c_str()), NullXString8Array, SWPrintf("Boot Mac OS X from %ls via %ls", targetLoaderEntry->VolName.wc_str(), Volume->VolName.wc_str()), L""_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_OSX, OSFLAG_HIDDEN);
|
||||
AddLoaderEntry(SWPrintf("\\%s\\System\\Library\\CoreServices\\boot.efi", ApfsTargetUUID.c_str()), NullXString8Array, SWPrintf("Boot Mac OS X from %ls via %ls", targetLoaderEntry->VolName.wc_str(), Volume->VolName.wc_str()), L""_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_OSX, 0);
|
||||
//Try to add Recovery APFS entry
|
||||
AddLoaderEntry(SWPrintf("\\%s\\boot.efi", Volume->ApfsTargetUUIDArray[i].c_str()), NullXString8Array, SWPrintf("Boot Mac OS X Recovery for %ls via %ls", targetLoaderEntry->VolName.wc_str(), Volume->VolName.wc_str()), L""_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_RECOVERY, 0);
|
||||
//Try to add macOS install entry
|
||||
@ -1554,6 +1536,28 @@ VOID ScanLoader(VOID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t entryIdx1 = 0; entryIdx1 < MainMenu.Entries.sizeIncludingHidden(); entryIdx1++)
|
||||
{
|
||||
LOADER_ENTRY* loaderEntry1Ptr = MainMenu.Entries.ElementAt(entryIdx1).getLOADER_ENTRY();
|
||||
if ( !loaderEntry1Ptr ) continue;
|
||||
LOADER_ENTRY& loaderEntry1 = *loaderEntry1Ptr;
|
||||
|
||||
if ( loaderEntry1.LoaderType == OSTYPE_OSX && loaderEntry1.APFSTargetUUID.notEmpty() )
|
||||
{
|
||||
for ( size_t entryIdx2 = 0 ; entryIdx2 < MainMenu.Entries.sizeIncludingHidden() ; entryIdx2 ++ )
|
||||
{
|
||||
if ( MainMenu.Entries.ElementAt(entryIdx2).getLOADER_ENTRY() ) {
|
||||
LOADER_ENTRY& loaderEntry2 = *MainMenu.Entries.ElementAt(entryIdx2).getLOADER_ENTRY();
|
||||
if ( loaderEntry2.Volume->ApfsFileSystemUUID == loaderEntry1.APFSTargetUUID ) {
|
||||
loaderEntry1.Hidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
|
||||
@ -1588,10 +1592,10 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN)) {
|
||||
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN)) {
|
||||
// DBG("Custom %lsentry %llu skipped because it is hidden.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
|
||||
return;
|
||||
}
|
||||
// return;
|
||||
// }
|
||||
|
||||
#if 0 //if someone want to debug this
|
||||
DBG("Custom %lsentry %llu ", IsSubEntry ? L"sub " : L"", CustomIndex);
|
||||
|
@ -247,10 +247,10 @@ VOID AddCustomTool(VOID)
|
||||
DBG("Custom tool %llu skipped because it is disabled.\n", i);
|
||||
continue;
|
||||
}
|
||||
if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN)) {
|
||||
DBG("Custom tool %llu skipped because it is hidden.\n", i);
|
||||
continue;
|
||||
}
|
||||
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN)) {
|
||||
// DBG("Custom tool %llu skipped because it is hidden.\n", i);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if (Custom->Volume.notEmpty()) {
|
||||
DBG("Custom tool %llu matching \"%ls\" ...\n", i, Custom->Volume);
|
||||
|
@ -68,6 +68,62 @@ class REFIT_ABSTRACT_MENU_ENTRY;
|
||||
|
||||
typedef VOID (REFIT_MENU_SCREEN::*MENU_STYLE_FUNC)(IN UINTN Function, IN CONST CHAR16 *ParamText);
|
||||
|
||||
class EntryArray : public XObjArray<REFIT_ABSTRACT_MENU_ENTRY>
|
||||
{
|
||||
public:
|
||||
bool includeHidden = false;
|
||||
|
||||
size_t sizeIncludingHidden() const { return XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::size(); }
|
||||
|
||||
size_t size() const
|
||||
{
|
||||
if ( includeHidden ) return sizeIncludingHidden();
|
||||
size_t size = 0;
|
||||
for ( size_t i=0 ; i < XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::size() ; i++ ) {
|
||||
const REFIT_ABSTRACT_MENU_ENTRY& entry = XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::ElementAt(i);
|
||||
if ( !entry.Hidden ) {
|
||||
size++;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
size_t length() const { return size(); }
|
||||
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
REFIT_ABSTRACT_MENU_ENTRY& operator[](IntegralType nIndex)
|
||||
{
|
||||
if ( includeHidden ) return XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::operator [] (nIndex);
|
||||
if (nIndex < 0) {
|
||||
panic("EntryArray::operator[] : i < 0. System halted\n");
|
||||
}
|
||||
size_t size = 0;
|
||||
for ( size_t i=0 ; i < XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::size() ; i++ ) {
|
||||
if ( !XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::ElementAt(i).Hidden ) {
|
||||
if ( size == (unsigned_type(IntegralType))nIndex ) return XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::ElementAt(i);
|
||||
size++;
|
||||
}
|
||||
}
|
||||
panic("EntryArray::operator[] nIndex > size()");
|
||||
}
|
||||
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
const REFIT_ABSTRACT_MENU_ENTRY& operator[](IntegralType nIndex) const
|
||||
{
|
||||
if ( includeHidden ) return XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::operator [] (nIndex);
|
||||
if (nIndex < 0) {
|
||||
panic("EntryArray::operator[] : i < 0. System halted\n");
|
||||
}
|
||||
size_t size = 0;
|
||||
for ( size_t i=0 ; i < XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::size() ; i++ ) {
|
||||
if ( !XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::ElementAt(i).Hidden ) {
|
||||
if ( size == (unsigned_type(IntegralType))nIndex ) return XObjArray<REFIT_ABSTRACT_MENU_ENTRY>::ElementAt(i);
|
||||
size++;
|
||||
}
|
||||
}
|
||||
panic("EntryArray::operator[] nIndex > size()");
|
||||
}
|
||||
};
|
||||
|
||||
class REFIT_MENU_SCREEN
|
||||
{
|
||||
public:
|
||||
@ -78,7 +134,7 @@ public:
|
||||
XIcon TitleImage;
|
||||
XStringWArray InfoLines;
|
||||
|
||||
XObjArray<REFIT_ABSTRACT_MENU_ENTRY> Entries;
|
||||
EntryArray Entries;
|
||||
|
||||
INTN TimeoutSeconds;
|
||||
bool Daylight;
|
||||
|
@ -98,7 +98,8 @@ class XPointer;
|
||||
class REFIT_ABSTRACT_MENU_ENTRY
|
||||
{
|
||||
public:
|
||||
XStringW Title;
|
||||
XStringW Title;
|
||||
bool Hidden;
|
||||
UINTN Row;
|
||||
CHAR16 ShortcutDigit;
|
||||
CHAR16 ShortcutLetter;
|
||||
@ -136,16 +137,16 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
virtual void StartTool() {};
|
||||
|
||||
REFIT_ABSTRACT_MENU_ENTRY()
|
||||
: Title(), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), Place(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
: Title(), Hidden(0), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), Place(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_)
|
||||
: Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), Place(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
: Title(Title_), Hidden(0), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), Place(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, ACTION AtClick_)
|
||||
: Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), Place(), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
: Title(Title_), Hidden(0), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), Place(), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_)
|
||||
: Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_), Image(), Place(), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
: Title(Title_), Hidden(0), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_), Image(), Place(), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
// REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, UINTN Row_,
|
||||
// CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, const XIcon& Icon_,
|
||||
|
@ -1087,7 +1087,6 @@ VOID ScanVolumes(VOID)
|
||||
// EFI_DEVICE_PATH_PROTOCOL *VolumeDevicePath;
|
||||
// EFI_GUID *Guid; //for debug only
|
||||
// EFI_INPUT_KEY Key;
|
||||
INT32 HVi;
|
||||
|
||||
// DBG("Scanning volumes...\n");
|
||||
DbgHeader("ScanVolumes");
|
||||
@ -1114,15 +1113,12 @@ VOID ScanVolumes(VOID)
|
||||
Status = ScanVolume(Volume);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Volumes.AddReference(Volume, false);
|
||||
// AddListElement((VOID ***) &Volumes, &VolumesCount, Volume);
|
||||
if (!gSettings.ShowHiddenEntries) {
|
||||
for (HVi = 0; HVi < gSettings.HVCount; HVi++) {
|
||||
if (StriStr(Volume->DevicePathString.wc_str(), gSettings.HVHideStrings[HVi]) ||
|
||||
(Volume->VolName.notEmpty() && StriStr(Volume->VolName.wc_str(), gSettings.HVHideStrings[HVi]))) {
|
||||
Volume->Hidden = TRUE;
|
||||
DBG(" hiding this volume\n");
|
||||
break;
|
||||
}
|
||||
for (size_t HVi = 0; HVi < gSettings.HVHideStrings.size(); HVi++) {
|
||||
if ( Volume->DevicePathString.containsIC(gSettings.HVHideStrings[HVi]) ||
|
||||
Volume->VolName.containsIC(gSettings.HVHideStrings[HVi])
|
||||
) {
|
||||
Volume->Hidden = TRUE;
|
||||
DBG(" hiding this volume\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ OSTYPE_COMPARE_IMP(OSTYPE_IS_LINUX, type1, type2) || OSTYPE_COMPARE_IMP(OSTYPE_I
|
||||
#define OSFLAG_NOCACHES (1 << 3)
|
||||
#define OSFLAG_NODEFAULTARGS (1 << 4)
|
||||
#define OSFLAG_NODEFAULTMENU (1 << 5)
|
||||
#define OSFLAG_HIDDEN (1 << 6)
|
||||
//#define OSFLAG_HIDDEN (1 << 6)
|
||||
#define OSFLAG_DISABLED (1 << 7)
|
||||
#define OSFLAG_HIBERNATED (1 << 8)
|
||||
#define OSFLAG_NOSIP (1 << 9)
|
||||
|
@ -2479,9 +2479,8 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
|
||||
// Hide toggle
|
||||
if (MenuExit == MENU_EXIT_HIDE_TOGGLE) {
|
||||
gSettings.ShowHiddenEntries = !gSettings.ShowHiddenEntries;
|
||||
AfterTool = TRUE;
|
||||
break;
|
||||
MainMenu.Entries.includeHidden = !MainMenu.Entries.includeHidden;
|
||||
continue;
|
||||
}
|
||||
|
||||
// We don't allow exiting the main menu with the Escape key.
|
||||
|
Loading…
Reference in New Issue
Block a user