Create REFIT_MAINMENU_SCREEN class

Create CUSTOM_LOADER_SUBENTRY_SETTINGS, CUSTOM_LOADER_SUBENTRY_SETTINGS
and CUSTOM_LOADER_SUBENTRY.
Clean the sub entries config.plist fields.
Comment unused KernelAndKextPatcherInit, KernelAndKextsPatcherStart,
CheckForFakeSMC
Comment unused OSFLAG_WITHKEXTS and OSFLAG_CHECKFAKESMC
This commit is contained in:
jief666 2021-03-22 15:40:01 +03:00
parent c93da72714
commit 829fd040dc
22 changed files with 2575 additions and 1826 deletions

View File

@ -51,6 +51,8 @@
9A36E51F24F3B82A007A1107 /* b64cdecode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A36E51E24F3B82A007A1107 /* b64cdecode.cpp */; };
9A36E52624F3BB6B007A1107 /* FloatLib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A36E52424F3BB6B007A1107 /* FloatLib.cpp */; };
9A36E53C24F3EDED007A1107 /* base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A36E53B24F3EDED007A1107 /* base64.cpp */; };
9A414767260545FD00440186 /* OpenCore.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEFD25CD9DC100EEAF06 /* OpenCore.lib */; };
9A4147682605493600440186 /* BaseLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEB025CD9B7400EEAF06 /* BaseLib.lib */; };
9A4185C02439F73A00BEAFB8 /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185BE2439F73A00BEAFB8 /* XStringArray.cpp */; };
9A4C576B255AAD07004F0B21 /* MacOsVersion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4C5769255AAD07004F0B21 /* MacOsVersion.cpp */; };
9A4FFA7E2451C8330050B38B /* XString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4FFA7C2451C8330050B38B /* XString.cpp */; };
@ -151,13 +153,13 @@
9AA9E53D25CD306700BD5E8B /* loader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA9E51B25CD306700BD5E8B /* loader.cpp */; };
9AD0358C25C57A4500E58351 /* MemoryAllocationLib.c in Sources */ = {isa = PBXBuildFile; fileRef = 9AD0358B25C57A4500E58351 /* MemoryAllocationLib.c */; };
9AD0359425C57C8A00E58351 /* PrintLib.c in Sources */ = {isa = PBXBuildFile; fileRef = 9AD0359325C57C8A00E58351 /* PrintLib.c */; };
9AD7B15026079F5D00E850D1 /* REFIT_MAINMENU_SCREEN.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AD7B14F26079F5D00E850D1 /* REFIT_MAINMENU_SCREEN.cpp */; };
9AFDCEA325CD9A3300EEAF06 /* OcDevicePathLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEA225CD9A3200EEAF06 /* OcDevicePathLib.lib */; };
9AFDCEA525CD9B1C00EEAF06 /* BaseCpuLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEA425CD9B1C00EEAF06 /* BaseCpuLib.lib */; };
9AFDCEA725CD9B2C00EEAF06 /* BaseSerialPortLib16550.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEA625CD9B2B00EEAF06 /* BaseSerialPortLib16550.lib */; };
9AFDCEA925CD9B3700EEAF06 /* FrameBufferBltLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEA825CD9B3700EEAF06 /* FrameBufferBltLib.lib */; };
9AFDCEAD25CD9B5800EEAF06 /* BaseDebugPrintErrorLevelLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEAC25CD9B5700EEAF06 /* BaseDebugPrintErrorLevelLib.lib */; };
9AFDCEAF25CD9B6500EEAF06 /* BaseIoLibIntrinsic.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEAE25CD9B6500EEAF06 /* BaseIoLibIntrinsic.lib */; };
9AFDCEB125CD9B7400EEAF06 /* BaseLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEB025CD9B7400EEAF06 /* BaseLib.lib */; };
9AFDCEB625CD9BC400EEAF06 /* BasePciCf8Lib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEB525CD9BC400EEAF06 /* BasePciCf8Lib.lib */; };
9AFDCEC225CD9D0700EEAF06 /* BasePciLibCf8.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEC125CD9D0700EEAF06 /* BasePciLibCf8.lib */; };
9AFDCEC725CD9D1600EEAF06 /* PeCoffExtraActionLibNull.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEC625CD9D1500EEAF06 /* PeCoffExtraActionLibNull.lib */; };
@ -170,7 +172,6 @@
9AFDCEEA25CD9D6B00EEAF06 /* UefiFileHandleLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEE925CD9D6B00EEAF06 /* UefiFileHandleLib.lib */; };
9AFDCEEF25CD9D7700EEAF06 /* UefiLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEEE25CD9D7700EEAF06 /* UefiLib.lib */; };
9AFDCEF925CD9D9500EEAF06 /* UefiRuntimeServicesTableLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEF825CD9D9500EEAF06 /* UefiRuntimeServicesTableLib.lib */; };
9AFDCEFE25CD9DC200EEAF06 /* OpenCore.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCEFD25CD9DC100EEAF06 /* OpenCore.lib */; };
9AFDCF0425CD9DFA00EEAF06 /* OcXmlLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCF0325CD9DFA00EEAF06 /* OcXmlLib.lib */; };
9AFDCF0925CD9E0800EEAF06 /* OcVirtualFsLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCF0825CD9E0800EEAF06 /* OcVirtualFsLib.lib */; };
9AFDCF0E25CD9E2100EEAF06 /* OcUnicodeCollationEngGenericLib.lib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFDCF0D25CD9E2100EEAF06 /* OcUnicodeCollationEngGenericLib.lib */; };
@ -5015,6 +5016,8 @@
9AD0359325C57C8A00E58351 /* PrintLib.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = PrintLib.c; sourceTree = "<group>"; };
9AD469472452B33700D6D0DB /* shared_with_menu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shared_with_menu.cpp; sourceTree = "<group>"; };
9AD469482452B33700D6D0DB /* shared_with_menu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shared_with_menu.h; sourceTree = "<group>"; };
9AD7B14E26079F5C00E850D1 /* REFIT_MAINMENU_SCREEN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = REFIT_MAINMENU_SCREEN.h; sourceTree = "<group>"; };
9AD7B14F26079F5D00E850D1 /* REFIT_MAINMENU_SCREEN.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = REFIT_MAINMENU_SCREEN.cpp; sourceTree = "<group>"; };
9AFDCEA225CD9A3200EEAF06 /* OcDevicePathLib.lib */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = OcDevicePathLib.lib; path = ../../../../Build/Clover/DEBUGMACOS_XCODE8/X64/OpenCorePkg/Library/OcDevicePathLib/OcDevicePathLib/OUTPUT/OcDevicePathLib.lib; sourceTree = "<group>"; };
9AFDCEA425CD9B1C00EEAF06 /* BaseCpuLib.lib */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = BaseCpuLib.lib; path = ../../../../Build/Clover/DEBUGMACOS_XCODE8/X64/MdePkg/Library/BaseCpuLib/BaseCpuLib/OUTPUT/BaseCpuLib.lib; sourceTree = "<group>"; };
9AFDCEA625CD9B2B00EEAF06 /* BaseSerialPortLib16550.lib */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = BaseSerialPortLib16550.lib; path = ../../../../Build/Clover/DEBUGMACOS_XCODE8/X64/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550/OUTPUT/BaseSerialPortLib16550.lib; sourceTree = "<group>"; };
@ -5159,7 +5162,6 @@
9AFDCFC425CDA04100EEAF06 /* OcAppleSecureBootLib.lib in Frameworks */,
9AFDCF4A25CD9F3500EEAF06 /* OcMemoryLib.lib in Frameworks */,
9AFDCF9C25CD9FFA00EEAF06 /* OcCryptoLib.lib in Frameworks */,
9AFDCEB125CD9B7400EEAF06 /* BaseLib.lib in Frameworks */,
9AFDCEE525CD9D6000EEAF06 /* UefiDevicePathLib.lib in Frameworks */,
9AFDCFE725CDA07F00EEAF06 /* OcAppleEventLib.lib in Frameworks */,
9AFDCFB525CDA02500EEAF06 /* OcBootManagementLib.lib in Frameworks */,
@ -5172,8 +5174,8 @@
9AFDCEAF25CD9B6500EEAF06 /* BaseIoLibIntrinsic.lib in Frameworks */,
9AFDCFF125CDA09200EEAF06 /* OcAppleChunklistLib.lib in Frameworks */,
9AFDD02625CDA33800EEAF06 /* OpensslLib.lib in Frameworks */,
9A414767260545FD00440186 /* OpenCore.lib in Frameworks */,
9AFDCF0925CD9E0800EEAF06 /* OcVirtualFsLib.lib in Frameworks */,
9AFDCEFE25CD9DC200EEAF06 /* OpenCore.lib in Frameworks */,
9AFDCFC925CDA04900EEAF06 /* OcAppleRamDiskLib.lib in Frameworks */,
9AFDCFA125CDA00300EEAF06 /* OcCpuLib.lib in Frameworks */,
9AFDCFAB25CDA01500EEAF06 /* OcConfigurationLib.lib in Frameworks */,
@ -5186,6 +5188,7 @@
9AFDCEE025CD9D5300EEAF06 /* UefiBootServicesTableLib.lib in Frameworks */,
9AFDCF7225CD9F8800EEAF06 /* OcDriverConnectionLib.lib in Frameworks */,
9AFDCF6825CD9F7500EEAF06 /* OcFirmwareVolumeLib.lib in Frameworks */,
9A4147682605493600440186 /* BaseLib.lib in Frameworks */,
9AFDCFEC25CDA08800EEAF06 /* OcAppleDiskImageLib.lib in Frameworks */,
9AFDD03725CDA3F900EEAF06 /* AutoGen.obj in Frameworks */,
9AFDCFA625CDA00C00EEAF06 /* OcConsoleLib.lib in Frameworks */,
@ -15616,6 +15619,8 @@
isa = PBXGroup;
children = (
9AA9253525CD764800BD5E8B /* menu_items */,
9AD7B14F26079F5D00E850D1 /* REFIT_MAINMENU_SCREEN.cpp */,
9AD7B14E26079F5C00E850D1 /* REFIT_MAINMENU_SCREEN.h */,
9AA9253925CD764800BD5E8B /* REFIT_MENU_SCREEN.cpp */,
9AA9253425CD764800BD5E8B /* REFIT_MENU_SCREEN.h */,
9AD469472452B33700D6D0DB /* shared_with_menu.cpp */,
@ -16053,6 +16058,7 @@
9A358B2A25CF115200A3850D /* Config_Devices_AddProperties.cpp in Sources */,
9A36E51424F3B537007A1107 /* TagFloat.cpp in Sources */,
9AA9259525CD770F00BD5E8B /* image.cpp in Sources */,
9AD7B15026079F5D00E850D1 /* REFIT_MAINMENU_SCREEN.cpp in Sources */,
9A0B085E240300E000E2B470 /* Platform.cpp in Sources */,
9AFDD04725CDB0F900EEAF06 /* Globals.cpp in Sources */,
9AA9E4FA25CD283400BD5E8B /* XPointer.cpp in Sources */,

View File

@ -11,5 +11,5 @@
#include <Efi.h>
#include "../../../rEFIt_UEFI/include/OC.h"
OC_GLOBAL_CONFIG mOpenCoreConfiguration = {{{0},{0},{0},{0}},{{0},{0}},{{0},{0}},{{0},{0},{{0},{0}},{0},{0},{0},{{0},{0},0}},{{0},{{0},{0},0,0,0,0,0,0,0,0},{0},{{0},{0},{0},0,0,0,0,0,0,{0},{0},{0},0,0},{0},{0}},{{0},{0},{0},0,0,0},{0},{0}};
OC_STORAGE_CONTEXT mOpenCoreStorage = {0};
//OC_GLOBAL_CONFIG mOpenCoreConfiguration = {{{0},{0},{0},{0}},{{0},{0}},{{0},{0}},{{0},{0},{{0},{0}},{0},{0},{0},{{0},{0},0}},{{0},{{0},{0},0,0,0,0,0,0,0,0},{0},{{0},{0},{0},0,0,0,0,0,0,{0},{0},{0},0,0},{0},{0}},{{0},{0},{0},0,0,0},{0},{0}};
//OC_STORAGE_CONTEXT mOpenCoreStorage = {0};

View File

@ -511,7 +511,7 @@
<key>CustomLogo</key>
<string>Apple</string>
<key>Disabled</key>
<true/>
<false/>
<key>DriveImage</key>
<string>driveimage</string>
<key>FullTitle</key>
@ -529,10 +529,12 @@
<key>SubEntries</key>
<array>
<dict>
<key>CustomLogo</key>
<string>WinRepairTool128x128.png</string>
<key>AddArguments</key>
<string>arg2</string>
<key>FullTitle</key>
<string>title1</string>
<string>title111</string>
<key>Settings</key>
<string>settingsSub</string>
<key>SubEntries</key>
@ -560,7 +562,7 @@
<string>title2</string>
</dict>
<dict>
<key>AddArguments</key>
<key>Arguments</key>
<string>arg4</string>
<key>FullTitle</key>
<string>title3</string>

View File

@ -187,6 +187,58 @@ CONST CHAR8* AudioOutputNames[] = {
"Other"
};
XString8Array CUSTOM_LOADER_SUBENTRY::getLoadOptions() const
{
if ( settings.m_Arguments.isDefined() ) return Split<XString8Array>(settings.m_Arguments.value(), " ");
XString8Array LoadOptions = parent.getLoadOptions();
LoadOptions.import(Split<XString8Array>(settings.m_AddArguments, " "));
if (LoadOptions.isEmpty() && OSTYPE_IS_WINDOWS(parent.settings.Type)) {
LoadOptions.Add("-s");
LoadOptions.Add("-h");
}
return LoadOptions;
}
UINT8 CUSTOM_LOADER_SUBENTRY::getFlags(bool NoCachesDefault) const
{
UINT8 Flags = parent.getFlags(NoCachesDefault);
if ( settings.m_Arguments.isDefined() ) Flags = OSFLAG_SET(Flags, OSFLAG_NODEFAULTARGS);
return Flags;
}
XString8Array CUSTOM_LOADER_ENTRY::getLoadOptions() const
{
if ( settings.Arguments.isDefined() ) return Split<XString8Array>(settings.Arguments.value(), " ");
XString8Array LoadOptions;
LoadOptions.import(Split<XString8Array>(settings.AddArguments, " "));
if (LoadOptions.isEmpty() && OSTYPE_IS_WINDOWS(settings.Type)) {
LoadOptions.Add("-s");
LoadOptions.Add("-h");
}
return LoadOptions;
}
const XString8& CUSTOM_LOADER_SUBENTRY::getTitle() const {
if ( settings.m_Title.isDefined() ) return settings.m_Title.value();
if ( settings.m_FullTitle.isDefined() ) return NullXString8;
return parent.settings.Title;
};
const XString8& CUSTOM_LOADER_SUBENTRY::getFullTitle() const {
if ( settings.m_FullTitle.isDefined() ) return settings.m_FullTitle.value();
if ( settings.m_Title.isDefined() ) return NullXString8;
return parent.settings.FullTitle;
};
EFI_STATUS
SaveSettings ();
@ -594,44 +646,41 @@ LoadUserSettings (
// return TRUE;
//}
STATIC
CUSTOM_LOADER_ENTRY
*DuplicateCustomEntry (
IN CUSTOM_LOADER_ENTRY *Entry
)
{
if (Entry == NULL) {
return NULL;
}
CUSTOM_LOADER_ENTRY* DuplicateEntry = new CUSTOM_LOADER_ENTRY;
if (DuplicateEntry != NULL) {
DuplicateEntry->Volume = Entry->Volume;
DuplicateEntry->Path = Entry->Path;
DuplicateEntry->LoadOptions = Entry->LoadOptions;
DuplicateEntry->FullTitle = Entry->FullTitle;
DuplicateEntry->Title = Entry->Title;
DuplicateEntry->ImagePath = Entry->ImagePath;
DuplicateEntry->DriveImagePath = Entry->DriveImagePath;
DuplicateEntry->BootBgColor = Entry->BootBgColor;
DuplicateEntry->Image = Entry->Image;
DuplicateEntry->DriveImage = Entry->DriveImage;
DuplicateEntry->Hotkey = Entry->Hotkey;
DuplicateEntry->Flags = Entry->Flags;
DuplicateEntry->Type = Entry->Type;
DuplicateEntry->VolumeType = Entry->VolumeType;
DuplicateEntry->KernelScan = Entry->KernelScan;
DuplicateEntry->CustomLogoType = Entry->CustomLogoType;
DuplicateEntry->CustomLogoAsXString8 = Entry->CustomLogoAsXString8;
DuplicateEntry->CustomLogoAsData = Entry->CustomLogoAsData;
DuplicateEntry->CustomLogoImage = Entry->CustomLogoImage;
// CopyKernelAndKextPatches (&DuplicateEntry->KernelAndKextPatches, &Entry->KernelAndKextPatches);
DuplicateEntry->KernelAndKextPatches = Entry->KernelAndKextPatches;
}
return DuplicateEntry;
}
//
//STATIC
//CUSTOM_LOADER_SUBENTRY_SETTINGS
//*DuplicateCustomEntryToSubEntry (
// IN CUSTOM_LOADER_ENTRY_SETTINGS *Entry
// )
//{
// if (Entry == NULL) {
// return NULL;
// }
//
// CUSTOM_LOADER_SUBENTRY_SETTINGS* DuplicateEntry = new CUSTOM_LOADER_SUBENTRY_SETTINGS;
// if (DuplicateEntry != NULL) {
//// DuplicateEntry->Volume = Entry->Volume; //ok
//// DuplicateEntry->Path = Entry->Path; //ok
//// DuplicateEntry->LoadOptions = Entry->LoadOptions;
// DuplicateEntry->FullTitle = Entry->FullTitle; //ok
// DuplicateEntry->Title = Entry->Title; //ok
//// DuplicateEntry->ImagePath = Entry->ImagePath; //ok
//// DuplicateEntry->BootBgColor = Entry->BootBgColor; //ok
//// DuplicateEntry->Image = Entry->Image;
//// DuplicateEntry->Hotkey = Entry->Hotkey; //ok
//// DuplicateEntry->Flags = Entry->Flags;
//// DuplicateEntry->Type = Entry->Type; //ok
//// DuplicateEntry->VolumeType = Entry->VolumeType; //ok
//// DuplicateEntry->KernelScan = Entry->KernelScan; //ok
//// DuplicateEntry->CustomLogoType = Entry->CustomLogoType;
//// DuplicateEntry->CustomLogoAsXString8 = Entry->CustomLogoAsXString8; //ok
//// DuplicateEntry->CustomLogoAsData = Entry->CustomLogoAsData; //ok
//// DuplicateEntry->CustomLogoImage = Entry->CustomLogoImage;
//// DuplicateEntry->KernelAndKextPatches = Entry->KernelAndKextPatches;
// }
//
// return DuplicateEntry;
//}
STATIC
BOOLEAN
@ -1412,10 +1461,337 @@ static UINT8 GetVolumeType(const TagDict* DictPointer)
}
BOOLEAN
FillinCustomSubEntry (
UINT8 parentType,
IN OUT CUSTOM_LOADER_SUBENTRY_SETTINGS *Entry,
const TagDict* DictPointer,
IN BOOLEAN SubEntry
)
{
const TagStruct* Prop;
if ( Entry == NULL ) panic("Entry == NULL");
if ( DictPointer == NULL ) panic("DictPointer == NULL");
Prop = DictPointer->propertyForKey("Disabled");
Entry->Disabled = IsPropertyNotNullAndTrue(Prop);
// Prop = DictPointer->propertyForKey("Volume");
// if (Prop != NULL && (Prop->isString())) {
// Entry->Volume = Prop->getString()->stringValue();
// }
// Prop = DictPointer->propertyForKey("Path");
// if (Prop != NULL && (Prop->isString())) {
// Entry->Path = Prop->getString()->stringValue();
// }
// Prop = DictPointer->propertyForKey("Settings");
// if (Prop != NULL && (Prop->isString())) {
// Entry->Settings = Prop->getString()->stringValue();
// }
// Prop = DictPointer->propertyForKey("CommonSettings");
// Entry->CommonSettings = IsPropertyNotNullAndTrue(Prop);
Prop = DictPointer->propertyForKey("AddArguments");
if (Prop != NULL && (Prop->isString())) {
// if (Entry->LoadOptions.notEmpty()) {
// Entry->Options.SPrintf("%s %s", Entry->Options.c_str(), Prop->getString()->stringValue());
// } else {
// Entry->Options.SPrintf("%s", Prop->getString()->stringValue());
// }
Entry->m_AddArguments = Prop->getString()->stringValue();
// Entry->LoadOptions.import(Split<XString8Array>(Prop->getString()->stringValue(), " "));
} else {
Prop = DictPointer->propertyForKey("Arguments");
if (Prop != NULL && (Prop->isString())) {
// Entry->Options.SPrintf("%s", Prop->getString()->stringValue());
Entry->m_Arguments = Prop->getString()->stringValue();
// Entry->LoadOptions = Split<XString8Array>(Prop->getString()->stringValue(), " ");
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTARGS);
}
}
Prop = DictPointer->propertyForKey("Title");
if (Prop != NULL && (Prop->isString())) {
Entry->m_Title = Prop->getString()->stringValue();
// Entry->FullTitle.setEmpty(); // jief : erase the copy from the parent
}
Prop = DictPointer->propertyForKey("FullTitle");
if (Prop != NULL && (Prop->isString())) {
Entry->m_FullTitle = Prop->getString()->stringValue();
// Entry->Title.setEmpty(); // jief : erase the copy from the parent. Could also be the previous settings, but Title is not used when FullTitle exists.
}
// Entry->ImageData.setEmpty();
// Prop = DictPointer->propertyForKey("Image");
// if (Prop != NULL) {
// Entry->ImagePath.setEmpty();
// Entry->Image.setEmpty();
// if (Prop->isString()) {
// Entry->ImagePath = SWPrintf("%s", Prop->getString()->stringValue().c_str());
// }
// // we can't load the file yet, as ThemeDir is not initialized
// } else {
// UINTN DataLen = 0;
// UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen);
// if (TmpData) {
// Entry->ImageData.stealValueFrom(TmpData, DataLen);
//// TODO remove from settings
// if (!EFI_ERROR(Entry->Image.Image.FromPNG(TmpData, DataLen))) {
// Entry->Image.setFilled();
// }
// }
// }
//
// Prop = DictPointer->propertyForKey("Hotkey");
// if (Prop != NULL && (Prop->isString()) && Prop->getString()->stringValue().notEmpty()) {
// if ( Prop->getString()->stringValue()[0] < __WCHAR_MAX__ ) {
// Entry->Hotkey = (wchar_t)(Prop->getString()->stringValue()[0]);
// }
// }
// // Whether or not to draw boot screen
// Prop = DictPointer->propertyForKey("CustomLogo");
// if (Prop != NULL) {
// if (IsPropertyNotNullAndTrue(Prop)) {
// Entry->CustomLogoType = CUSTOM_BOOT_APPLE;
// } else if ((Prop->isString()) && Prop->getString()->stringValue().notEmpty()) {
// Entry->CustomLogoAsXString8 = Prop->getString()->stringValue();
// if (Prop->getString()->stringValue().equalIC("Apple")) {
// Entry->CustomLogoType = CUSTOM_BOOT_APPLE;
// } else if (Prop->getString()->stringValue().equalIC("Alternate")) {
// Entry->CustomLogoType = CUSTOM_BOOT_ALT_APPLE;
// } else if (Prop->getString()->stringValue().equalIC("Theme")) {
// Entry->CustomLogoType = CUSTOM_BOOT_THEME;
// } else {
// XStringW customLogo = XStringW() = Prop->getString()->stringValue();
// Entry->CustomLogoType = CUSTOM_BOOT_USER;
//// TODO : remove reading of image from settings
// Entry->CustomLogoImage.LoadXImage(&self.getSelfVolumeRootDir(), customLogo);
// if (Entry->CustomLogoImage.isEmpty()) {
// DBG("Custom boot logo not found at path `%ls`!\n", customLogo.wc_str());
// Entry->CustomLogoType = CUSTOM_BOOT_DISABLED;
// }
// }
// } else if ( Prop->isData() && Prop->getData()->dataLenValue() > 0 ) {
// Entry->CustomLogoType = CUSTOM_BOOT_USER;
// Entry->CustomLogoAsData = Prop->getData()->data();
//// TODO : remove reading of image from settings
// Entry->CustomLogoImage.FromPNG(Prop->getData()->dataValue(), Prop->getData()->dataLenValue());
// if (Entry->CustomLogoImage.isEmpty()) {
// DBG("Custom boot logo not decoded from data!\n"/*, Prop->getString()->stringValue().c_str()*/);
// Entry->CustomLogoType = CUSTOM_BOOT_DISABLED;
// }
// } else {
// Entry->CustomLogoType = CUSTOM_BOOT_USER_DISABLED;
// }
// DBG("Custom entry boot %s LogoWidth = (0x%lld)\n", CustomBootModeToStr(Entry->CustomLogoType), Entry->CustomLogoImage.GetWidth());
// } else {
// Entry->CustomLogoType = CUSTOM_BOOT_DISABLED;
// }
// Prop = DictPointer->propertyForKey("BootBgColor");
// if (Prop != NULL && Prop->isString()) {
// UINTN Color;
// Color = AsciiStrHexToUintn(Prop->getString()->stringValue());
//
// Entry->BootBgColor.Red = (Color >> 24) & 0xFF;
// Entry->BootBgColor.Green = (Color >> 16) & 0xFF;
// Entry->BootBgColor.Blue = (Color >> 8) & 0xFF;
// Entry->BootBgColor.Reserved = (Color >> 0) & 0xFF;
// }
//
// // Hidden Property, Values:
// // - No (show the entry)
// // - Yes (hide the entry but can be show with F3)
// // - Always (always hide the entry)
// Prop = DictPointer->propertyForKey("Hidden");
// if (Prop != NULL) {
// if ((Prop->isString()) &&
// (Prop->getString()->stringValue().equalIC("Always"))) {
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_DISABLED);
// } else if (IsPropertyNotNullAndTrue(Prop)) {
// DBG(" hiding entry because Hidden flag is YES\n");
// Entry->Hidden = true;
// } else {
// Entry->Hidden = false;
// }
// }
//
// Prop = DictPointer->propertyForKey("Type");
// if (Prop != NULL && (Prop->isString())) {
// if ((Prop->getString()->stringValue().equalIC("OSX")) ||
// (Prop->getString()->stringValue().equalIC("macOS"))) {
// Entry->Type = OSTYPE_OSX;
// } else if (Prop->getString()->stringValue().equalIC("OSXInstaller")) {
// Entry->Type = OSTYPE_OSX_INSTALLER;
// } else if (Prop->getString()->stringValue().equalIC("OSXRecovery")) {
// Entry->Type = OSTYPE_RECOVERY;
// } else if (Prop->getString()->stringValue().equalIC("Windows")) {
// Entry->Type = OSTYPE_WINEFI;
// } else if (Prop->getString()->stringValue().equalIC("Linux")) {
// Entry->Type = OSTYPE_LIN;
//// TODO remove from here
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTARGS);
// } else if (Prop->getString()->stringValue().equalIC("LinuxKernel")) {
// Entry->Type = OSTYPE_LINEFI;
// } else {
// DBG("** Warning: unknown custom entry Type '%s'\n", Prop->getString()->stringValue().c_str());
// Entry->Type = OSTYPE_OTHER;
// }
// } else {
// if (Entry->Type == 0 && Entry->Path.notEmpty()) {
// // Try to set Entry->type from Entry->Path
// Entry->Type = GetOSTypeFromPath(Entry->Path);
// }
// }
// Entry->VolumeType = GetVolumeType(DictPointer);
// if (Entry->LoadOptions.isEmpty() && OSTYPE_IS_WINDOWS(parentType)) {
// Entry->LoadOptions.Add("-s");
// Entry->LoadOptions.Add("-h");
// }
if (Entry->m_Title.dgetValue().isEmpty()) {
if (OSTYPE_IS_OSX_RECOVERY(parentType)) {
Entry->m_Title = "Recovery"_XS8;
} else if (OSTYPE_IS_OSX_INSTALLER(parentType)) {
Entry->m_Title = "Install macOS"_XS8;
}
}
// if (Entry->Image.isEmpty() && (Entry->ImagePath.isEmpty())) {
// if (OSTYPE_IS_OSX_RECOVERY(parentType)) {
// Entry->ImagePath = L"mac"_XSW;
// }
// }
// OS Specific flags
if (OSTYPE_IS_OSX(parentType) || OSTYPE_IS_OSX_RECOVERY(parentType) || OSTYPE_IS_OSX_INSTALLER(parentType)) {
// InjectKexts default values
// Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_CHECKFAKESMC);
// Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_WITHKEXTS);
// Prop = DictPointer->propertyForKey("InjectKexts");
// if (Prop != NULL) {
// if ( Prop->isTrueOrYes() ) {
// Entry->InjectKexts = 1;
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// } else if ( Prop->isFalseOrNn() ) {
// Entry->InjectKexts = 0;
// // nothing to do
// } else if ( Prop->isString() && Prop->getString()->stringValue().equalIC("Detect") ) {
// Entry->InjectKexts = 2;
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_CHECKFAKESMC);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// } else {
// Entry->InjectKexts = -1;
// DBG("** Warning: unknown custom entry InjectKexts value '%s'\n", Prop->getString()->stringValue().c_str());
// }
// } else {
// Entry->InjectKexts = -1;
// // Use global settings
// if (gSettings.WithKexts) {
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// }
// if (gSettings.WithKextsIfNoFakeSMC) {
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_CHECKFAKESMC);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// }
// }
// NoCaches default value
// Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_NOCACHES);
Prop = DictPointer->propertyForKey("NoCaches");
if (Prop != NULL) {
if (IsPropertyNotNullAndTrue(Prop)) {
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NOCACHES);
} else {
// Use global settings
if (gSettings.NoCaches) {
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NOCACHES);
}
}
}
// // KernelAndKextPatches
// if (!SubEntry) { // CopyKernelAndKextPatches already in: DuplicateCustomEntry if SubEntry == TRUE
// //DBG("Copying global patch settings\n");
//// CopyKernelAndKextPatches ((KERNEL_AND_KEXT_PATCHES *)(((UINTN)Entry) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches)),
// // (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches)));
//
//// CopyKernelAndKextPatches(&Entry->KernelAndKextPatches, &gSettings.KernelAndKextPatches);
// Entry->KernelAndKextPatches = gSettings.KernelAndKextPatches;
//
// //#ifdef DUMP_KERNEL_KEXT_PATCHES
// // DumpKernelAndKextPatches ((KERNEL_AND_KEXT_PATCHES *)(((UINTN)Entry) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches)));
// //#endif
//
// }
}
// if (Entry->Type == OSTYPE_LINEFI) {
// Prop = DictPointer->propertyForKey("Kernel");
// if (Prop != NULL) {
// if ((Prop->isString()) && Prop->getString()->stringValue().notEmpty()) {
// if ((Prop->getString()->stringValue()[0] == 'N') || (Prop->getString()->stringValue()[0] == 'n')) {
// Entry->KernelScan = KERNEL_SCAN_NEWEST;
// } else if ((Prop->getString()->stringValue()[0] == 'O') || (Prop->getString()->stringValue()[0] == 'o')) {
// Entry->KernelScan = KERNEL_SCAN_OLDEST;
// } else if ((Prop->getString()->stringValue()[0] == 'F') || (Prop->getString()->stringValue()[0] == 'f')) {
// Entry->KernelScan = KERNEL_SCAN_FIRST;
// } else if ((Prop->getString()->stringValue()[0] == 'L') || (Prop->getString()->stringValue()[0] == 'l')) {
// Entry->KernelScan = KERNEL_SCAN_LAST;
// } else if ((Prop->getString()->stringValue()[0] == 'M') || (Prop->getString()->stringValue()[0] == 'm')) {
// Entry->KernelScan = KERNEL_SCAN_MOSTRECENT;
// } else if ((Prop->getString()->stringValue()[0] == 'E') || (Prop->getString()->stringValue()[0] == 'e')) {
// Entry->KernelScan = KERNEL_SCAN_EARLIEST;
// }
// }
// }
// }
// /*
// * Sub entries
// * an array of dict OR a bool
// */
// Prop = DictPointer->propertyForKey("SubEntries");
// if (Prop != NULL) {
// if ( Prop->isBool() && Prop->getBool()->boolValue() ) {
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTMENU);
// } else if ( Prop->isArray() ) {
// CUSTOM_LOADER_SUBENTRY_SETTINGS *CustomSubEntry;
// INTN i;
// INTN Count = Prop->getArray()->arrayContent().size();
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTMENU);
// for (i = 0; i < Count; i++) {
// const TagDict* Dict = Prop->getArray()->dictElementAt(i, "SubEntries"_XS8);
// // Allocate a sub entry
// CustomSubEntry = DuplicateCustomSubEntry(Entry);
// if (CustomSubEntry) {
// if ( FillinCustomSubEntry(CustomSubEntry, Dict, TRUE) ) {
// Entry->SubEntriesSettings.AddReference(CustomSubEntry, true);
// }else{
// delete CustomSubEntry;
// }
// }
// }
// }else{
// MsgLog("MALFORMED PLIST : SubEntries must be a bool OR an array of dict");
// }
// }
return TRUE;
}
STATIC
BOOLEAN
FillinCustomEntry (
IN OUT CUSTOM_LOADER_ENTRY *Entry,
IN OUT CUSTOM_LOADER_ENTRY_SETTINGS *Entry,
const TagDict* DictPointer,
IN BOOLEAN SubEntry
)
@ -1454,13 +1830,15 @@ FillinCustomEntry (
// } else {
// Entry->Options.SPrintf("%s", Prop->getString()->stringValue());
// }
Entry->LoadOptions.import(Split<XString8Array>(Prop->getString()->stringValue(), " "));
Entry->AddArguments = Prop->getString()->stringValue();
// Entry->LoadOptions.import(Split<XString8Array>(Prop->getString()->stringValue(), " "));
} else {
Prop = DictPointer->propertyForKey("Arguments");
if (Prop != NULL && (Prop->isString())) {
Entry->Arguments = Prop->getString()->stringValue();
// Entry->Options.SPrintf("%s", Prop->getString()->stringValue());
Entry->LoadOptions = Split<XString8Array>(Prop->getString()->stringValue(), " ");
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTARGS);
// Entry->LoadOptions = Split<XString8Array>(Prop->getString()->stringValue(), " ");
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTARGS);
}
}
Prop = DictPointer->propertyForKey("Title");
@ -1577,16 +1955,17 @@ FillinCustomEntry (
// - No (show the entry)
// - Yes (hide the entry but can be show with F3)
// - Always (always hide the entry)
Entry->AlwaysHidden = false;
Entry->Hidden = false;
Prop = DictPointer->propertyForKey("Hidden");
if (Prop != NULL) {
if ((Prop->isString()) &&
(Prop->getString()->stringValue().equalIC("Always"))) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_DISABLED);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_DISABLED);
Entry->AlwaysHidden = true;
} else if (IsPropertyNotNullAndTrue(Prop)) {
DBG(" hiding entry because Hidden flag is YES\n");
Entry->Hidden = true;
} else {
Entry->Hidden = false;
}
}
@ -1604,7 +1983,7 @@ FillinCustomEntry (
} else if (Prop->getString()->stringValue().equalIC("Linux")) {
Entry->Type = OSTYPE_LIN;
// TODO remove from here
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTARGS);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTARGS);
} else if (Prop->getString()->stringValue().equalIC("LinuxKernel")) {
Entry->Type = OSTYPE_LINEFI;
} else {
@ -1620,10 +1999,10 @@ FillinCustomEntry (
Entry->VolumeType = GetVolumeType(DictPointer);
if (Entry->LoadOptions.isEmpty() && OSTYPE_IS_WINDOWS(Entry->Type)) {
Entry->LoadOptions.Add("-s");
Entry->LoadOptions.Add("-h");
}
// if (Entry->LoadOptions.isEmpty() && OSTYPE_IS_WINDOWS(Entry->Type)) {
// Entry->LoadOptions.Add("-s");
// Entry->LoadOptions.Add("-h");
// }
if (Entry->Title.isEmpty()) {
if (OSTYPE_IS_OSX_RECOVERY(Entry->Type)) {
Entry->Title = L"Recovery"_XSW;
@ -1645,48 +2024,49 @@ FillinCustomEntry (
if (OSTYPE_IS_OSX(Entry->Type) || OSTYPE_IS_OSX_RECOVERY(Entry->Type) || OSTYPE_IS_OSX_INSTALLER(Entry->Type)) {
// InjectKexts default values
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_CHECKFAKESMC);
// Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_CHECKFAKESMC);
// Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_WITHKEXTS);
Prop = DictPointer->propertyForKey("InjectKexts");
if (Prop != NULL) {
if ( Prop->isTrueOrYes() ) {
Entry->InjectKexts = 1;
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
} else if ( Prop->isFalseOrNn() ) {
Entry->InjectKexts = 0;
// nothing to do
} else if ( Prop->isString() && Prop->getString()->stringValue().equalIC("Detect") ) {
Entry->InjectKexts = 2;
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_CHECKFAKESMC);
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_CHECKFAKESMC);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
} else {
Entry->InjectKexts = -1;
Entry->InjectKexts = -2;
DBG("** Warning: unknown custom entry InjectKexts value '%s'\n", Prop->getString()->stringValue().c_str());
}
} else {
Entry->InjectKexts = -1;
// Use global settings
if (gSettings.WithKexts) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
}
if (gSettings.WithKextsIfNoFakeSMC) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_CHECKFAKESMC);
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_CHECKFAKESMC);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
}
}
// NoCaches default value
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_NOCACHES);
// Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_NOCACHES);
Prop = DictPointer->propertyForKey("NoCaches");
if (Prop != NULL) {
if (IsPropertyNotNullAndTrue(Prop)) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NOCACHES);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NOCACHES);
Entry->NoCaches = true;
} else {
// Use global settings
if (gSettings.NoCaches) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NOCACHES);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NOCACHES);
}
}
}
@ -1735,27 +2115,26 @@ FillinCustomEntry (
*/
Prop = DictPointer->propertyForKey("SubEntries");
if (Prop != NULL) {
if ( Prop->isBool() && Prop->getBool()->boolValue() ) {
/*if ( Prop->isBool() && Prop->getBool()->boolValue() ) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTMENU);
} else if ( Prop->isArray() ) {
CUSTOM_LOADER_ENTRY *CustomSubEntry;
INTN i;
} else*/ if ( Prop->isArray() ) {
INTN Count = Prop->getArray()->arrayContent().size();
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTMENU);
for (i = 0; i < Count; i++) {
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTMENU);
for (INTN i = 0; i < Count; i++) {
const TagDict* Dict = Prop->getArray()->dictElementAt(i, "SubEntries"_XS8);
// Allocate a sub entry
CustomSubEntry = DuplicateCustomEntry (Entry);
// CustomSubEntry = DuplicateCustomEntryToSubEntry(Entry);
CUSTOM_LOADER_SUBENTRY_SETTINGS* CustomSubEntry = new CUSTOM_LOADER_SUBENTRY_SETTINGS;
if (CustomSubEntry) {
if ( FillinCustomEntry(CustomSubEntry, Dict, TRUE) ) {
Entry->SubEntries.AddReference(CustomSubEntry, true);
if ( FillinCustomSubEntry(Entry->Type, CustomSubEntry, Dict, TRUE) ) {
Entry->SubEntriesSettings.AddReference(CustomSubEntry, true);
}else{
delete CustomSubEntry;
}
}
}
}else{
MsgLog("MALFORMED PLIST : SubEntries must be a bool OR an array of dict");
MsgLog("MALFORMED PLIST : SubEntries must be an array of dict");
}
}
return TRUE;
@ -2603,10 +2982,10 @@ EFI_STATUS GetEarlyUserSettings (
for (INTN i = 0; i < Count; i++) {
const TagDict* Dict3 = arrayProp->dictElementAt(i, "Custom/Entries"_XS8);
// Allocate an entry
CUSTOM_LOADER_ENTRY* Entry = new CUSTOM_LOADER_ENTRY;
CUSTOM_LOADER_ENTRY_SETTINGS* Entry = new CUSTOM_LOADER_ENTRY_SETTINGS;
// Fill it in
if ( FillinCustomEntry(Entry, Dict3, FALSE) ) {
gSettings.GUI.CustomEntries.AddReference(Entry, true);
gSettings.GUI.CustomEntriesSettings.AddReference(Entry, true);
}else{
delete Entry;
}
@ -7188,137 +7567,138 @@ InjectKextsFromDir (
return Status;
}
EFI_STATUS LOADER_ENTRY::SetFSInjection()
{
EFI_STATUS Status;
FSINJECTION_PROTOCOL *FSInject;
XStringW SrcDir;
//BOOLEAN InjectionNeeded = FALSE;
//BOOLEAN BlockCaches = FALSE;
FSI_STRING_LIST *Blacklist = 0;
FSI_STRING_LIST *ForceLoadKexts = NULL;
MsgLog ("Beginning FSInjection\n");
// get FSINJECTION_PROTOCOL
Status = gBS->LocateProtocol(&gFSInjectProtocolGuid, NULL, (void **)&FSInject);
if (EFI_ERROR(Status)) {
//Print (L"- No FSINJECTION_PROTOCOL, Status = %s\n", efiStrError(Status));
MsgLog (" - ERROR: gFSInjectProtocolGuid not found!\n");
return EFI_NOT_STARTED;
}
// check if blocking of caches is needed
if ( OSFLAG_ISSET(Flags, OSFLAG_NOCACHES) || LoadOptions.contains("-f") ) {
MsgLog ("Blocking kext caches\n");
// BlockCaches = TRUE;
// add caches to blacklist
Blacklist = FSInject->CreateStringList();
if (Blacklist == NULL) {
MsgLog (" - ERROR: Not enough memory!\n");
return EFI_NOT_STARTED;
}
/*
From 10.7 to 10.9, status of directly restoring ESD files or update from Appstore cannot block kernel cache. because there are boot.efi and kernelcache file without kernel file.
After macOS installed, boot.efi can call kernel file from S/L/Kernels.
For this reason, long time ago, chameleon's user restored Base System.dmg to made USB installer and added kernel file in root and custom kexts in S/L/E. then used "-f" option.
From 10.10+, boot.efi call only prelinkedkernel file without kernel file. we can never block only kernelcache.
The use of these block caches is meaningless in modern macOS. Unlike the old days, we do not have to do the tedious task of putting the files needed for booting into the S/L/E.
Caution! Do not add this list. If add this list, will see "Kernel cache load error (0xe)". This is just a guideline.
by Sherlocks, 2017.11
*/
// Installed/createinstallmedia
//FSInject->AddStringToList(Blacklist, L"\\System\\Library\\PrelinkedKernels\\prelinkedkernel"); // 10.10+/10.13.4+
// Recovery
//FSInject->AddStringToList(Blacklist, L"\\com.apple.recovery.boot\\kernelcache"); // 10.7 - 10.10
//FSInject->AddStringToList(Blacklist, L"\\com.apple.recovery.boot\\prelinkedkernel"); // 10.11+
// BaseSytem/InstallESD
//FSInject->AddStringToList(Blacklist, L"\\kernelcache"); // 10.7 - 10.9/(10.7/10.8)
// 1st stage - createinstallmedia
//FSInject->AddStringToList(Blacklist, L"\\.IABootFiles\\kernelcache"); // 10.9/10.10
//FSInject->AddStringToList(Blacklist, L"\\.IABootFiles\\prelinkedkernel"); // 10.11 - 10.13.3
// 2nd stage - InstallESD/AppStore/startosinstall
//FSInject->AddStringToList(Blacklist, L"\\Mac OS X Install Data\\kernelcache"); // 10.7
//FSInject->AddStringToList(Blacklist, L"\\OS X Install Data\\kernelcache"); // 10.8 - 10.10
//FSInject->AddStringToList(Blacklist, L"\\OS X Install Data\\prelinkedkernel"); // 10.11
//FSInject->AddStringToList(Blacklist, L"\\macOS Install Data\\prelinkedkernel"); // 10.12 - 10.12.3
//FSInject->AddStringToList(Blacklist, L"\\macOS Install Data\\Locked Files\\Boot Files\\prelinkedkernel");// 10.12.4+
// 2nd stage - Fusion Drive
//FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.R\\System\\Library\\PrelinkedKernels\\prelinkedkernel"); // 10.11
//FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.P\\System\\Library\\PrelinkedKernels\\prelinkedkernel"); // 10.11
//FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.S\\System\\Library\\PrelinkedKernels\\prelinkedkernel"); // 10.11
//FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.R\\prelinkedkernel"); // 10.12+
//FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.P\\prelinkedkernel"); // 10.12+
//FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.S\\prelinkedkernel"); // 10.12+
// NetInstall
//FSInject->AddStringToList(Blacklist, L"\\NetInstall macOS High Sierra.nbi\\i386\\x86_64\\kernelcache");
// Block Caches list
// InstallDVD/Installed
FSInject->AddStringToList(Blacklist, L"\\System\\Library\\Caches\\com.apple.kext.caches\\Startup\\Extensions.mkext"); // 10.6
FSInject->AddStringToList(Blacklist, L"\\System\\Library\\Extensions.mkext"); // 10.6
FSInject->AddStringToList(Blacklist, L"\\System\\Library\\Caches\\com.apple.kext.caches\\Startup\\kernelcache"); // 10.6/10.6 - 10.9
if (gSettings.BlockKexts[0] != L'\0') {
FSInject->AddStringToList(Blacklist, SWPrintf("\\System\\Library\\Extensions\\%ls", gSettings.BlockKexts).wc_str());
}
}
// check if kext injection is needed
// (will be done only if caches are blocked or if boot.efi refuses to load kernelcache)
//SrcDir = NULL;
if (OSFLAG_ISSET(Flags, OSFLAG_WITHKEXTS)) {
SrcDir = GetOtherKextsDir(TRUE);
Status = FSInject->Install(
Volume->DeviceHandle,
L"\\System\\Library\\Extensions",
SelfVolume->DeviceHandle,
//GetOtherKextsDir (),
SrcDir.wc_str(),
Blacklist,
ForceLoadKexts
);
//InjectKextsFromDir(Status, GetOtherKextsDir());
InjectKextsFromDir(Status, SrcDir.wc_str());
SrcDir = GetOSVersionKextsDir(macOSVersion);
Status = FSInject->Install(
Volume->DeviceHandle,
L"\\System\\Library\\Extensions",
SelfVolume->DeviceHandle,
//GetOSVersionKextsDir(OSVersion),
SrcDir.wc_str(),
Blacklist,
ForceLoadKexts
);
//InjectKextsFromDir(Status, GetOSVersionKextsDir(OSVersion));
InjectKextsFromDir(Status, SrcDir.wc_str());
} else {
MsgLog("skipping kext injection (not requested)\n");
}
// prepare list of kext that will be forced to load
ForceLoadKexts = FSInject->CreateStringList();
if (ForceLoadKexts == NULL) {
MsgLog(" - Error: not enough memory!\n");
return EFI_NOT_STARTED;
}
KextPatcherRegisterKexts(FSInject, ForceLoadKexts);
// reinit Volume->RootDir? it seems it's not needed.
return Status;
}
// Do we need that with OC ? For old version ?
//EFI_STATUS LOADER_ENTRY::SetFSInjection()
//{
// EFI_STATUS Status;
// FSINJECTION_PROTOCOL *FSInject;
// XStringW SrcDir;
// //BOOLEAN InjectionNeeded = FALSE;
// //BOOLEAN BlockCaches = FALSE;
// FSI_STRING_LIST *Blacklist = 0;
// FSI_STRING_LIST *ForceLoadKexts = NULL;
//
// MsgLog ("Beginning FSInjection\n");
//
// // get FSINJECTION_PROTOCOL
// Status = gBS->LocateProtocol(&gFSInjectProtocolGuid, NULL, (void **)&FSInject);
// if (EFI_ERROR(Status)) {
// //Print (L"- No FSINJECTION_PROTOCOL, Status = %s\n", efiStrError(Status));
// MsgLog (" - ERROR: gFSInjectProtocolGuid not found!\n");
// return EFI_NOT_STARTED;
// }
//
// // check if blocking of caches is needed
// if ( OSFLAG_ISSET(Flags, OSFLAG_NOCACHES) || LoadOptions.contains("-f") ) {
// MsgLog ("Blocking kext caches\n");
// // BlockCaches = TRUE;
// // add caches to blacklist
// Blacklist = FSInject->CreateStringList();
// if (Blacklist == NULL) {
// MsgLog (" - ERROR: Not enough memory!\n");
// return EFI_NOT_STARTED;
// }
//
// /*
// From 10.7 to 10.9, status of directly restoring ESD files or update from Appstore cannot block kernel cache. because there are boot.efi and kernelcache file without kernel file.
// After macOS installed, boot.efi can call kernel file from S/L/Kernels.
// For this reason, long time ago, chameleon's user restored Base System.dmg to made USB installer and added kernel file in root and custom kexts in S/L/E. then used "-f" option.
// From 10.10+, boot.efi call only prelinkedkernel file without kernel file. we can never block only kernelcache.
// The use of these block caches is meaningless in modern macOS. Unlike the old days, we do not have to do the tedious task of putting the files needed for booting into the S/L/E.
// Caution! Do not add this list. If add this list, will see "Kernel cache load error (0xe)". This is just a guideline.
// by Sherlocks, 2017.11
// */
//
// // Installed/createinstallmedia
// //FSInject->AddStringToList(Blacklist, L"\\System\\Library\\PrelinkedKernels\\prelinkedkernel"); // 10.10+/10.13.4+
//
// // Recovery
// //FSInject->AddStringToList(Blacklist, L"\\com.apple.recovery.boot\\kernelcache"); // 10.7 - 10.10
// //FSInject->AddStringToList(Blacklist, L"\\com.apple.recovery.boot\\prelinkedkernel"); // 10.11+
//
// // BaseSytem/InstallESD
// //FSInject->AddStringToList(Blacklist, L"\\kernelcache"); // 10.7 - 10.9/(10.7/10.8)
//
// // 1st stage - createinstallmedia
// //FSInject->AddStringToList(Blacklist, L"\\.IABootFiles\\kernelcache"); // 10.9/10.10
// //FSInject->AddStringToList(Blacklist, L"\\.IABootFiles\\prelinkedkernel"); // 10.11 - 10.13.3
//
// // 2nd stage - InstallESD/AppStore/startosinstall
// //FSInject->AddStringToList(Blacklist, L"\\Mac OS X Install Data\\kernelcache"); // 10.7
// //FSInject->AddStringToList(Blacklist, L"\\OS X Install Data\\kernelcache"); // 10.8 - 10.10
// //FSInject->AddStringToList(Blacklist, L"\\OS X Install Data\\prelinkedkernel"); // 10.11
// //FSInject->AddStringToList(Blacklist, L"\\macOS Install Data\\prelinkedkernel"); // 10.12 - 10.12.3
// //FSInject->AddStringToList(Blacklist, L"\\macOS Install Data\\Locked Files\\Boot Files\\prelinkedkernel");// 10.12.4+
//
// // 2nd stage - Fusion Drive
// //FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.R\\System\\Library\\PrelinkedKernels\\prelinkedkernel"); // 10.11
// //FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.P\\System\\Library\\PrelinkedKernels\\prelinkedkernel"); // 10.11
// //FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.S\\System\\Library\\PrelinkedKernels\\prelinkedkernel"); // 10.11
// //FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.R\\prelinkedkernel"); // 10.12+
// //FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.P\\prelinkedkernel"); // 10.12+
// //FSInject->AddStringToList(Blacklist, L"\\com.apple.boot.S\\prelinkedkernel"); // 10.12+
//
// // NetInstall
// //FSInject->AddStringToList(Blacklist, L"\\NetInstall macOS High Sierra.nbi\\i386\\x86_64\\kernelcache");
//
//
// // Block Caches list
// // InstallDVD/Installed
// FSInject->AddStringToList(Blacklist, L"\\System\\Library\\Caches\\com.apple.kext.caches\\Startup\\Extensions.mkext"); // 10.6
// FSInject->AddStringToList(Blacklist, L"\\System\\Library\\Extensions.mkext"); // 10.6
// FSInject->AddStringToList(Blacklist, L"\\System\\Library\\Caches\\com.apple.kext.caches\\Startup\\kernelcache"); // 10.6/10.6 - 10.9
//
// if (gSettings.BlockKexts[0] != L'\0') {
// FSInject->AddStringToList(Blacklist, SWPrintf("\\System\\Library\\Extensions\\%ls", gSettings.BlockKexts).wc_str());
// }
// }
//
// // check if kext injection is needed
// // (will be done only if caches are blocked or if boot.efi refuses to load kernelcache)
// //SrcDir = NULL;
// if (OSFLAG_ISSET(Flags, OSFLAG_WITHKEXTS)) {
// SrcDir = GetOtherKextsDir(TRUE);
// Status = FSInject->Install(
// Volume->DeviceHandle,
// L"\\System\\Library\\Extensions",
// SelfVolume->DeviceHandle,
// //GetOtherKextsDir (),
// SrcDir.wc_str(),
// Blacklist,
// ForceLoadKexts
// );
// //InjectKextsFromDir(Status, GetOtherKextsDir());
// InjectKextsFromDir(Status, SrcDir.wc_str());
//
// SrcDir = GetOSVersionKextsDir(macOSVersion);
// Status = FSInject->Install(
// Volume->DeviceHandle,
// L"\\System\\Library\\Extensions",
// SelfVolume->DeviceHandle,
// //GetOSVersionKextsDir(OSVersion),
// SrcDir.wc_str(),
// Blacklist,
// ForceLoadKexts
// );
// //InjectKextsFromDir(Status, GetOSVersionKextsDir(OSVersion));
// InjectKextsFromDir(Status, SrcDir.wc_str());
// } else {
// MsgLog("skipping kext injection (not requested)\n");
// }
//
// // prepare list of kext that will be forced to load
// ForceLoadKexts = FSInject->CreateStringList();
// if (ForceLoadKexts == NULL) {
// MsgLog(" - Error: not enough memory!\n");
// return EFI_NOT_STARTED;
// }
//
// KextPatcherRegisterKexts(FSInject, ForceLoadKexts);
//
// // reinit Volume->RootDir? it seems it's not needed.
//
// return Status;
//}
EFI_GUID nullUUID = {0,0,0,{0}};

View File

@ -3,7 +3,8 @@
#include <Efi.h>
#include "../gui/menu_items/menu_items.h"
#include "../include/OSFlags.h"
#include "../include/OSTypes.h"
#include "../Platform/plist/plist.h"
#include "../Platform/guid.h"
#include "MacOsVersion.h"
@ -150,32 +151,78 @@ public:
~ACPI_DROP_TABLE() {}
};
class CUSTOM_LOADER_ENTRY
class GUI_Custom_SubEntry_Class;
template<class C> class XmlArray;
//class XmlArray<GUI_Custom_SubEntry_Class>;
class CUSTOM_LOADER_SUBENTRY_SETTINGS;
void CompareCustomSubEntries(const XString8& label, const XObjArray<CUSTOM_LOADER_SUBENTRY_SETTINGS>& olDCustomEntries, const XmlArray<GUI_Custom_SubEntry_Class>& newCustomEntries);
class CUSTOM_LOADER_SUBENTRY;
BOOLEAN FillinCustomSubEntry(UINT8 parentType, IN OUT CUSTOM_LOADER_SUBENTRY_SETTINGS *Entry, const TagDict* DictPointer, IN BOOLEAN SubEntry);
class CUSTOM_LOADER_SUBENTRY_SETTINGS
{
public:
bool Disabled = 0;
XObjArray<CUSTOM_LOADER_ENTRY> SubEntries = XObjArray<CUSTOM_LOADER_ENTRY>();
XIcon Image = XIcon(); // todo remove
XStringW ImagePath = XStringW();
XBuffer<UINT8> ImageData = XBuffer<UINT8>();
XIcon DriveImage = XIcon();
XStringW DriveImagePath = XStringW();
XBuffer<UINT8> DriveImageData = XBuffer<UINT8>();
XStringW Volume = XStringW();
XStringW Path = XStringW();
XString8Array LoadOptions = XString8Array();
protected:
// member defined with m_ prefix should not be accessed from outside. I left them public for now for CompareCustomEntries()
undefinable_XString8 m_Arguments = undefinable_XString8();
XString8 m_AddArguments = XString8();
XStringW FullTitle = XStringW();
XStringW Title = XStringW();
XStringW Settings = XStringW();
undefinable_XString8 m_FullTitle = undefinable_XString8();
undefinable_XString8 m_Title = undefinable_XString8();
public:
friend void ::CompareCustomSubEntries(const XString8& label, const XObjArray<CUSTOM_LOADER_SUBENTRY_SETTINGS>& olDCustomEntries, const XmlArray<GUI_Custom_SubEntry_Class>& newCustomEntries);
friend BOOLEAN FillinCustomSubEntry(UINT8 parentType, IN OUT CUSTOM_LOADER_SUBENTRY_SETTINGS *Entry, const TagDict* DictPointer, IN BOOLEAN SubEntry);
friend class ::CUSTOM_LOADER_SUBENTRY;
};
class CUSTOM_LOADER_ENTRY;
class CUSTOM_LOADER_SUBENTRY
{
public:
const CUSTOM_LOADER_ENTRY& parent;
const CUSTOM_LOADER_SUBENTRY_SETTINGS& settings = CUSTOM_LOADER_SUBENTRY_SETTINGS();
CUSTOM_LOADER_SUBENTRY(const CUSTOM_LOADER_ENTRY& _customLoaderEntry, const CUSTOM_LOADER_SUBENTRY_SETTINGS& _settings) : parent(_customLoaderEntry), settings(_settings) {}
XString8Array getLoadOptions() const;
UINT8 getFlags(bool NoCachesDefault) const;
const XString8& getTitle() const;
const XString8& getFullTitle() const;
};
class CUSTOM_LOADER_ENTRY_SETTINGS
{
public:
bool Disabled = 0;
XObjArray<CUSTOM_LOADER_SUBENTRY_SETTINGS> SubEntriesSettings = XObjArray<CUSTOM_LOADER_SUBENTRY_SETTINGS>();
XIcon Image = XIcon(); // todo remove
XStringW ImagePath = XStringW();
XBuffer<UINT8> ImageData = XBuffer<UINT8>();
XIcon DriveImage = XIcon();
XStringW DriveImagePath = XStringW();
XBuffer<UINT8> DriveImageData = XBuffer<UINT8>();
XStringW Volume = XStringW();
XStringW Path = XStringW();
undefinable_XString8 Arguments = undefinable_XString8();
XString8 AddArguments = XString8();
// XString8Array LoadOptions = XString8Array();
XString8 FullTitle = XStringW();
XString8 Title = XStringW();
XStringW Settings = XStringW(); // path of a config.plist that'll be read at the beginning of startloader
CHAR16 Hotkey = 0;
BOOLEAN CommonSettings = 0;
UINT8 Flags = 0;
// UINT8 Flags = 0;
bool Hidden = 0;
bool AlwaysHidden = 0;
UINT8 Type = 0;
UINT8 VolumeType = 0;
UINT8 KernelScan = KERNEL_SCAN_ALL;
// UINT8 CustomBoot = 0;
UINT8 CustomLogoType = 0;
XString8 CustomLogoAsXString8 = XString8();
XBuffer<UINT8> CustomLogoAsData = XBuffer<UINT8>();
@ -183,6 +230,8 @@ public:
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor = EFI_GRAPHICS_OUTPUT_BLT_PIXEL({0,0,0,0});
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches = KERNEL_AND_KEXT_PATCHES();
INT8 InjectKexts = -1;
undefinable_bool NoCaches = undefinable_bool();
// CUSTOM_LOADER_ENTRY() {}
//
// // Not sure if default are valid. Delete them. If needed, proper ones can be created
@ -191,6 +240,40 @@ public:
};
class CUSTOM_LOADER_ENTRY
{
public:
const CUSTOM_LOADER_ENTRY_SETTINGS& settings = CUSTOM_LOADER_ENTRY_SETTINGS();
XObjArray<CUSTOM_LOADER_SUBENTRY> SubEntries = XObjArray<CUSTOM_LOADER_SUBENTRY>();
CUSTOM_LOADER_ENTRY(const CUSTOM_LOADER_ENTRY_SETTINGS& _settings) : settings(_settings) {
for ( size_t idx = 0 ; idx < settings.SubEntriesSettings.size() ; ++idx ) {
const CUSTOM_LOADER_SUBENTRY_SETTINGS& CustomEntrySettings = settings.SubEntriesSettings[idx];
CUSTOM_LOADER_SUBENTRY* entry = new CUSTOM_LOADER_SUBENTRY(*this, CustomEntrySettings);
SubEntries.AddReference(entry, true);
}
}
XString8Array getLoadOptions() const;
UINT8 getFlags(bool NoCachesDefault) const {
UINT8 Flags = 0;
if ( settings.Arguments.isDefined() ) Flags = OSFLAG_SET(Flags, OSFLAG_NODEFAULTARGS);
if ( settings.AlwaysHidden ) Flags = OSFLAG_SET(Flags, OSFLAG_DISABLED);
if ( settings.Type == OSTYPE_LIN ) Flags = OSFLAG_SET(Flags, OSFLAG_NODEFAULTARGS);
if (OSTYPE_IS_OSX(settings.Type) || OSTYPE_IS_OSX_RECOVERY(settings.Type) || OSTYPE_IS_OSX_INSTALLER(settings.Type)) {
Flags = OSFLAG_UNSET(Flags, OSFLAG_NOCACHES);
}
if ( settings.NoCaches.isDefined() ) {
if ( settings.NoCaches ) Flags = OSFLAG_SET(Flags, OSFLAG_NOCACHES);
}else{
if (NoCachesDefault) {
Flags = OSFLAG_SET(Flags, OSFLAG_NOCACHES);
}
}
if ( SubEntries.notEmpty() ) Flags = OSFLAG_SET(Flags, OSFLAG_NODEFAULTMENU);
return Flags;
}
};
class CUSTOM_LEGACY_ENTRY
{
public:
@ -427,7 +510,7 @@ public:
bool LegacyFirst = false;
bool NoLegacy = false;
} Scan = ScanClass();
XObjArray<CUSTOM_LOADER_ENTRY> CustomEntries = XObjArray<CUSTOM_LOADER_ENTRY>();
XObjArray<CUSTOM_LOADER_ENTRY_SETTINGS> CustomEntriesSettings = XObjArray<CUSTOM_LOADER_ENTRY_SETTINGS>();
XObjArray<CUSTOM_LEGACY_ENTRY> CustomLegacy = XObjArray<CUSTOM_LEGACY_ENTRY>();
XObjArray<CUSTOM_TOOL_ENTRY> CustomTool = XObjArray<CUSTOM_TOOL_ENTRY>();
@ -932,29 +1015,9 @@ extern EMU_VARIABLE_CONTROL_PROTOCOL *gEmuVariableControl;
class REFIT_CONFIG
{
public:
// INTN Timeout;
UINTN DisableFlags; //to disable some volume types (optical, firewire etc)
// BOOLEAN TextOnly;
BOOLEAN Quiet;
// BOOLEAN LegacyFirst;
// BOOLEAN NoLegacy;
// BOOLEAN DebugLog;
BOOLEAN SpecialBootMode; // content of nvram var "aptiofixflag"
// BOOLEAN NeverHibernate;
// BOOLEAN StrictHibernate;
// BOOLEAN RtcHibernateAware;
// BOOLEAN HibernationFixup;
// BOOLEAN SignatureFixup;
// XStringW Theme;
// XStringW ScreenResolution;
// INTN ConsoleMode;
// BOOLEAN CustomIcons;
// INTN IconFormat = ICON_FORMAT_DEF; // not used anymore
// BOOLEAN NoEarlyProgress;
// INT32 Timezone;
// BOOLEAN ShowOptimus;
// INTN Codepage;
// INTN CodepageSize;
UINTN DisableFlags = 0; //to disable some volume types (optical, firewire etc)
BOOLEAN Quiet = true;
BOOLEAN SpecialBootMode = false; // content of nvram var "aptiofixflag"
BOOLEAN gBootChanged = FALSE;
BOOLEAN gThemeChanged = FALSE;
@ -977,37 +1040,10 @@ public:
bool EnableC2 = 0;
uint16_t C3Latency = 0;
/*
* Defqult ctor :
* -1, // INTN Timeout;
* 0, // UINTN DisableFlags;
* FALSE, // BOOLEAN TextOnly;
* TRUE, // BOOLEAN Quiet;
* FALSE, // BOOLEAN LegacyFirst;
* FALSE, // BOOLEAN NoLegacy;
* FALSE, // BOOLEAN DebugLog;
* FALSE, // BOOLEAN FastBoot;
* FALSE, // BOOLEAN NeverHibernate;
* FALSE, // BOOLEAN StrictHibernate;
* FALSE, // BOOLEAN RtcHibernateAware;
* FALSE, // BOOLEAN HibernationFixup;
* FALSE, // BOOLEAN SignatureFixup;
* L""_XSW, // XStringW Theme;
* L""_XSW, // XStringW ScreenResolution;
* 0, // INTN ConsoleMode;
* FALSE, // BOOLEAN CustomIcons;
* ICON_FORMAT_DEF, // INTN IconFormat;
* FALSE, // BOOLEAN NoEarlyProgress;
* 0xFF, // INT32 Timezone; / 0xFF - not set
* FALSE, // BOOLEAN ShowOptimus;
* 0xC0, // INTN Codepage;
* 0xC0, // INTN CodepageSize; //extended latin
};
*
*/
REFIT_CONFIG() : DisableFlags(0), Quiet(TRUE),
SpecialBootMode(FALSE)
{};
XObjArray<CUSTOM_LOADER_ENTRY> CustomEntries = XObjArray<CUSTOM_LOADER_ENTRY>();
REFIT_CONFIG() {};
REFIT_CONFIG(const REFIT_CONFIG& other) = delete; // Can be defined if needed
const REFIT_CONFIG& operator = ( const REFIT_CONFIG & ) = delete; // Can be defined if needed
~REFIT_CONFIG() { }

View File

@ -2483,374 +2483,374 @@ LOADER_ENTRY::BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize)
return (y != 0);
}
void
LOADER_ENTRY::KernelAndKextPatcherInit()
{
if (PatcherInited) {
DBG("patcher inited\n");
return;
}
PatcherInited = TRUE;
// KernelRelocBase will normally be 0
// but if OsxAptioFixDrv is used, then it will be > 0
SetKernelRelocBase();
DBG("KernelRelocBase = %llx\n", KernelRelocBase);
// Find bootArgs - we need then for proper detection
// of kernel Mach-O header
FindBootArgs();
if (bootArgs1 == NULL && bootArgs2 == NULL) {
DBG_RT("BootArgs not found - skipping patches!\n");
return;
}
// Find kernel Mach-O header:
// for 10.4 - 10.5: 0x00111000
// for 10.6 - 10.7: 0x00200000
// for ML: bootArgs2->kslide + 0x00200000
// for AptioFix booting - it's always at KernelRelocBase + 0x00200000
// UINT64 os_version = AsciiOSVersionToUint64(macOSVersion);
DBG("macOSVersion=%s\n", macOSVersion.asString().c_str());
// if (macOSVersion.notEmpty() && macOSVersion < AsciiOSVersionToUint64("10.6")) {
// KernelData = (UINT8*)(UINTN)(KernelSlide + KernelRelocBase + 0x00111000);
// } else {
KernelData = (UINT8*)(UINTN)(KernelSlide + KernelRelocBase + 0x00200000);
//void
//LOADER_ENTRY::KernelAndKextPatcherInit()
//{
// if (PatcherInited) {
// DBG("patcher inited\n");
// return;
// }
// check that it is Mach-O header and detect architecture
if(MACH_GET_MAGIC(KernelData) == MH_MAGIC || MACH_GET_MAGIC(KernelData) == MH_CIGAM) {
DBG("Found 32 bit kernel at 0x%llx\n", (UINTN)KernelData);
is64BitKernel = FALSE;
} else if (MACH_GET_MAGIC(KernelData) == MH_MAGIC_64 || MACH_GET_MAGIC(KernelData) == MH_CIGAM_64) {
DBG( "Found 64 bit kernel at 0x%llx\n", (UINTN)KernelData);
// DBG_RT("text section is: %s\n", (const char*)&KernelData[0x28]);
/*
KernelOffset = 0;
while (KernelOffset < KERNEL_MAX_SIZE) {
if ((MACH_GET_MAGIC(KernelData+KernelOffset) == MH_MAGIC_64 ) || (MACH_GET_MAGIC(KernelData+KernelOffset) == MH_CIGAM_64)) {
DBG("dump at offset 0x%x\n", KernelOffset);
for (int j = 0; j<20; ++j) {
DBG("%02x ", KernelData[KernelOffset+j]);
}
DBG("\n");
if ((((struct mach_header_64*)(KernelData+KernelOffset))->filetype) == MH_EXECUTE) {
DBG("execute found\n");
break;
}
}
KernelOffset += 4;
}
*/
if ((((struct mach_header_64*)KernelData)->filetype) == MH_KERNEL_COLLECTION) {
// BigSur
KernelOffset = GetTextExec();
// DBG("BigSur: KernelOffset =0x%X\n", KernelOffset);
}
is64BitKernel = TRUE;
} else {
// not valid Mach-O header - exiting
DBG( "Kernel not found at 0x%llx - skipping patches!\n", (UINTN)KernelData);
KernelData = NULL;
return;
}
DBG( " kernel offset at 0x%x\n", KernelOffset);
// find __PRELINK_TEXT and __PRELINK_INFO
if ((((struct mach_header_64*)KernelData)->filetype) == MH_KERNEL_COLLECTION) {
Get_PreLink(); // BigSur
} else {
Get_PreLink();
}
//find symbol tables
struct symtab_command *symCmd = NULL;
UINT32 symCmdOffset = Get_Symtab(&KernelData[KernelOffset]);
if (symCmdOffset != 0) {
symCmd = (struct symtab_command *)&KernelData[KernelOffset + symCmdOffset];
AddrVtable = symCmd->symoff; //this offset relative to KernelData+0
SizeVtable = symCmd->nsyms;
NamesTable = symCmd->stroff;
DBG("Kernel: AddrVtable=0x%x SizeVtable=0x%x NamesTable=0x%x\n", AddrVtable, SizeVtable, NamesTable);
}
/*
for (UINTN i=0x00200000; i<0x30000000; i+=4) {
UINT32 *KD = (UINT32 *)i;
if ((KD[0] == MH_MAGIC_64) && (KD[0x0a] == 0x45545F5F)){
DBG_RT( "Found MAGIC at %llx, text=%s\n", i, (const char*)&KD[0x0a]);
DBG( "Found MAGIC at %llx, text=%s\n", i, (const char*)&KD[0x0a]);
KernelData = (UINT8*)KD;
DBG( "Found new kernel at 0x%llx\n", (UINTN)KernelData);
break;
}
}
*/
if (EFI_ERROR(getVTable())) {
DBG("error getting vtable: \n");
}
isKernelcache = (PrelinkTextSize > 0) && (PrelinkInfoSize > 0);
DBG( "isKernelcache: %ls\n", isKernelcache ? L"Yes" : L"No");
}
void
LOADER_ENTRY::KernelAndKextsPatcherStart()
{
BOOLEAN KextPatchesNeeded, patchedOk;
/*
* it was intended for custom entries but not work if no custom entries used
* so set common until better solution invented
*/
//KernelAndKextPatches = (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches));
// CopyKernelAndKextPatches(&KernelAndKextPatches, &gSettings.KernelAndKextPatches);
KernelAndKextPatches = gSettings.KernelAndKextPatches;
PatcherInited = false;
KernelAndKextPatcherInit();
KextPatchesNeeded = (
KernelAndKextPatches.KPAppleIntelCPUPM ||
KernelAndKextPatches.KPAppleRTC ||
KernelAndKextPatches.EightApple ||
KernelAndKextPatches.KPDELLSMBIOS ||
KernelAndKextPatches.KPATIConnectorsPatch.notEmpty() ||
KernelAndKextPatches.KextPatches.size() > 0
);
// DBG_RT("\nKernelToPatch: ");
// DBG_RT("Kernels patches: %d\n", KernelAndKextPatches.KernelPatches.size());
if (gSettings.KernelPatchesAllowed && KernelAndKextPatches.KernelPatches.notEmpty()) {
// DBG_RT("Enabled: \n");
DBG("Kernels patches: enabled \n");
// KernelAndKextPatcherInit();
// if (KernelData == NULL) goto NoKernelData;
if (EFI_ERROR(getVTable())) {
// DBG_RT("error getting vtable: \n");
goto NoKernelData;
}
patchedOk = KernelUserPatch();
// DBG_RT(patchedOk ? " OK\n" : " FAILED!\n");
// gBS->Stall(5000000);
} else {
// DBG_RT("Disabled\n");
}
/*
DBG_RT( "\nKernelCpu patch: ");
if (KernelAndKextPatches.KPKernelCpu) {
//
// Kernel patches
//
DBG_RT( "Enabled: \n");
KernelAndKextPatcherInit();
if (KernelData == NULL) goto NoKernelData;
if(is64BitKernel) {
DBG_RT( "64 bit patch ...\n");
KernelPatcher_64();
} else {
DBG_RT( "32 bit patch ...\n");
KernelPatcher_32();
}
DBG_RT( " OK\n");
} else {
DBG_RT( "Disabled\n");
}
*/
//other method for KernelCPU patch is FakeCPUID
DBG_RT( "\nFakeCPUID patch: ");
if (KernelAndKextPatches.FakeCPUID) {
DBG_RT( "Enabled: 0x%06x\n", KernelAndKextPatches.FakeCPUID);
// KernelAndKextPatcherInit();
// if (KernelData == NULL) goto NoKernelData;
KernelCPUIDPatch();
} else {
DBG_RT( "Disabled\n");
}
// CPU power management patch for CPU with locked msr
DBG_RT( "\nKernelPm patch: ");
if (KernelAndKextPatches.KPKernelPm || KernelAndKextPatches.KPKernelXCPM) {
DBG_RT( "Enabled: \n");
DBG( "KernelPm patch: Enabled\n");
// KernelAndKextPatcherInit();
// if (KernelData == NULL) goto NoKernelData;
patchedOk = FALSE;
if (is64BitKernel) {
patchedOk = KernelPatchPm();
}
DBG_RT( patchedOk ? " OK\n" : " FAILED!\n");
} else {
DBG_RT( "Disabled\n");
}
// Patch to not dump kext at panic (c)vit9696
DBG_RT( "\nPanicNoKextDump patch: ");
if (KernelAndKextPatches.KPPanicNoKextDump) {
DBG_RT( "Enabled: \n");
// KernelAndKextPatcherInit();
// if (KernelData == NULL) goto NoKernelData;
patchedOk = KernelPanicNoKextDump();
DBG_RT( patchedOk ? " OK\n" : " FAILED!\n");
} else {
DBG_RT( "Disabled\n");
}
// Lapic Panic Kernel Patch
DBG_RT( "\nKernelLapic patch: ");
if (KernelAndKextPatches.KPKernelLapic) {
DBG_RT( "Enabled: \n");
// KernelAndKextPatcherInit();
// if (KernelData == NULL) goto NoKernelData;
if(is64BitKernel) {
DBG_RT( "64-bit patch ...\n");
patchedOk = KernelLapicPatch_64();
} else {
DBG_RT( "32-bit patch ...\n");
patchedOk = KernelLapicPatch_32();
}
DBG_RT( patchedOk ? " OK\n" : " FAILED!\n");
} else {
DBG_RT( "Disabled\n");
}
if (KernelAndKextPatches.KPKernelXCPM) {
//
// syscl - EnableExtCpuXCPM: Enable unsupported CPU's PowerManagement
//
// EnableExtCpuXCPM = NULL;
patchedOk = FALSE;
// BOOLEAN apply_idle_patch = (gCPUStructure.Model >= CPU_MODEL_SKYLAKE_U) && gSettings.HWP;
// KernelAndKextPatcherInit();
// if (KernelData == NULL) goto NoKernelData;
// syscl - now enable extra Cpu's PowerManagement
// only Intel support this feature till now
// move below code outside the if condition if AMD supports
// XCPM later on
if (gCPUStructure.Vendor == CPU_VENDOR_INTEL) {
switch (gCPUStructure.Model) {
case CPU_MODEL_JAKETOWN:
// SandyBridge-E LGA2011
patchedOk = SandyBridgeEPM();
gSNBEAICPUFixRequire = TRUE; // turn on SandyBridge-E AppleIntelCPUPowerManagement Fix
break;
case CPU_MODEL_IVY_BRIDGE:
// IvyBridge
patchedOk = KernelIvyBridgeXCPM();
break;
case CPU_MODEL_IVY_BRIDGE_E5:
// IvyBridge-E
patchedOk = KernelIvyE5XCPM();
break;
case CPU_MODEL_HASWELL_E:
// Haswell-E
patchedOk = HaswellEXCPM();
break;
case CPU_MODEL_BROADWELL_E5:
case CPU_MODEL_BROADWELL_DE:
// Broadwell-E/EP
patchedOk = BroadwellEPM();
gBDWEIOPCIFixRequire = TRUE;
break;
default:
if (gCPUStructure.Model >= CPU_MODEL_HASWELL &&
(AsciiStrStr(gCPUStructure.BrandString, "Celeron") ||
AsciiStrStr(gCPUStructure.BrandString, "Pentium"))) {
// Haswell+ low-end CPU
patchedOk = HaswellLowEndXCPM();
}
break;
}
}
DBG_RT( "EnableExtCpuXCPM - %s!\n", patchedOk? "OK" : "FAILED");
}
Stall(2000000);
//
// Kext patches
//
// we need to scan kexts if "InjectKexts true and CheckFakeSMC"
if (/*OSFLAG_ISSET(Flags, OSFLAG_WITHKEXTS) || */
OSFLAG_ISSET(Flags, OSFLAG_CHECKFAKESMC)) {
DBG_RT( "\nAllowing kext patching to check if FakeSMC is present\n");
gSettings.KextPatchesAllowed = TRUE;
KextPatchesNeeded = TRUE;
}
DBG_RT( "\nKextPatches Needed: %c, Allowed: %c ... ",
(KextPatchesNeeded ? L'Y' : L'n'),
(gSettings.KextPatchesAllowed ? L'Y' : L'n')
);
if (KextPatchesNeeded && gSettings.KextPatchesAllowed) {
// DBG_RT( "\nKext patching INIT\n");
// KernelAndKextPatcherInit();
// if (KernelData == NULL) goto NoKernelData;
DBG_RT( "\nKext patching STARTED\n");
KextPatcherStart(); //is FakeSMC found in cache then inject will be disabled
DBG_RT( "\nKext patching ENDED\n");
} else {
DBG_RT( "Disabled\n");
}
Stall(1000000);
//
// Kext add
//
// if (KernelAndKextPatches.KPDebug) {
// if (OSFLAG_ISSET(Entry->Flags, OSFLAG_CHECKFAKESMC) &&
// OSFLAG_ISUNSET(Entry->Flags, OSFLAG_WITHKEXTS)) {
// disabled kext injection if FakeSMC is already present
// Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_WITHKEXTS); //Slice - we are already here
//
// DBG_RT( "\nInjectKexts: disabled because FakeSMC is already present and InjectKexts option set to Detect\n");
// gBS->Stall(500000);
// PatcherInited = TRUE;
//
// // KernelRelocBase will normally be 0
// // but if OsxAptioFixDrv is used, then it will be > 0
// SetKernelRelocBase();
// DBG("KernelRelocBase = %llx\n", KernelRelocBase);
//
// // Find bootArgs - we need then for proper detection
// // of kernel Mach-O header
// FindBootArgs();
// if (bootArgs1 == NULL && bootArgs2 == NULL) {
// DBG_RT("BootArgs not found - skipping patches!\n");
// return;
// }
//
// // Find kernel Mach-O header:
// // for 10.4 - 10.5: 0x00111000
// // for 10.6 - 10.7: 0x00200000
// // for ML: bootArgs2->kslide + 0x00200000
// // for AptioFix booting - it's always at KernelRelocBase + 0x00200000
//
//// UINT64 os_version = AsciiOSVersionToUint64(macOSVersion);
// DBG("macOSVersion=%s\n", macOSVersion.asString().c_str());
//
//// if (macOSVersion.notEmpty() && macOSVersion < AsciiOSVersionToUint64("10.6")) {
//// KernelData = (UINT8*)(UINTN)(KernelSlide + KernelRelocBase + 0x00111000);
//// } else {
// KernelData = (UINT8*)(UINTN)(KernelSlide + KernelRelocBase + 0x00200000);
//// }
//
// // check that it is Mach-O header and detect architecture
// if(MACH_GET_MAGIC(KernelData) == MH_MAGIC || MACH_GET_MAGIC(KernelData) == MH_CIGAM) {
// DBG("Found 32 bit kernel at 0x%llx\n", (UINTN)KernelData);
// is64BitKernel = FALSE;
// } else if (MACH_GET_MAGIC(KernelData) == MH_MAGIC_64 || MACH_GET_MAGIC(KernelData) == MH_CIGAM_64) {
// DBG( "Found 64 bit kernel at 0x%llx\n", (UINTN)KernelData);
//// DBG_RT("text section is: %s\n", (const char*)&KernelData[0x28]);
///*
// KernelOffset = 0;
// while (KernelOffset < KERNEL_MAX_SIZE) {
// if ((MACH_GET_MAGIC(KernelData+KernelOffset) == MH_MAGIC_64 ) || (MACH_GET_MAGIC(KernelData+KernelOffset) == MH_CIGAM_64)) {
// DBG("dump at offset 0x%x\n", KernelOffset);
// for (int j = 0; j<20; ++j) {
// DBG("%02x ", KernelData[KernelOffset+j]);
// }
// DBG("\n");
// if ((((struct mach_header_64*)(KernelData+KernelOffset))->filetype) == MH_EXECUTE) {
// DBG("execute found\n");
// break;
// }
// }
// KernelOffset += 4;
// }
// */
// if ((((struct mach_header_64*)KernelData)->filetype) == MH_KERNEL_COLLECTION) {
// // BigSur
// KernelOffset = GetTextExec();
//// DBG("BigSur: KernelOffset =0x%X\n", KernelOffset);
// }
// is64BitKernel = TRUE;
// } else {
// // not valid Mach-O header - exiting
// DBG( "Kernel not found at 0x%llx - skipping patches!\n", (UINTN)KernelData);
// KernelData = NULL;
// return;
// }
// DBG( " kernel offset at 0x%x\n", KernelOffset);
// // find __PRELINK_TEXT and __PRELINK_INFO
// if ((((struct mach_header_64*)KernelData)->filetype) == MH_KERNEL_COLLECTION) {
// Get_PreLink(); // BigSur
// } else {
// Get_PreLink();
// }
// //find symbol tables
// struct symtab_command *symCmd = NULL;
// UINT32 symCmdOffset = Get_Symtab(&KernelData[KernelOffset]);
// if (symCmdOffset != 0) {
// symCmd = (struct symtab_command *)&KernelData[KernelOffset + symCmdOffset];
// AddrVtable = symCmd->symoff; //this offset relative to KernelData+0
// SizeVtable = symCmd->nsyms;
// NamesTable = symCmd->stroff;
// DBG("Kernel: AddrVtable=0x%x SizeVtable=0x%x NamesTable=0x%x\n", AddrVtable, SizeVtable, NamesTable);
// }
///*
// for (UINTN i=0x00200000; i<0x30000000; i+=4) {
// UINT32 *KD = (UINT32 *)i;
// if ((KD[0] == MH_MAGIC_64) && (KD[0x0a] == 0x45545F5F)){
// DBG_RT( "Found MAGIC at %llx, text=%s\n", i, (const char*)&KD[0x0a]);
// DBG( "Found MAGIC at %llx, text=%s\n", i, (const char*)&KD[0x0a]);
// KernelData = (UINT8*)KD;
// DBG( "Found new kernel at 0x%llx\n", (UINTN)KernelData);
// break;
// }
// }
if (OSFLAG_ISSET(Flags, OSFLAG_WITHKEXTS)) {
UINT32 deviceTreeP;
UINT32 *deviceTreeLength;
EFI_STATUS Status;
UINTN DataSize;
// check if FSInject already injected kexts
DataSize = 0;
Status = gRT->GetVariable (L"FSInject.KextsInjected", &gEfiGlobalVariableGuid, NULL, &DataSize, NULL);
if (Status == EFI_BUFFER_TOO_SMALL) {
// var exists - just exit
DBG_RT( "\nInjectKexts: skipping, FSInject already injected them\n");
Stall(500000);
return;
}
//*/
// if (EFI_ERROR(getVTable())) {
// DBG("error getting vtable: \n");
// }
//
// isKernelcache = (PrelinkTextSize > 0) && (PrelinkInfoSize > 0);
// DBG( "isKernelcache: %ls\n", isKernelcache ? L"Yes" : L"No");
//}
//
//void
//LOADER_ENTRY::KernelAndKextsPatcherStart()
//{
// BOOLEAN KextPatchesNeeded, patchedOk;
// /*
// * it was intended for custom entries but not work if no custom entries used
// * so set common until better solution invented
// */
// //KernelAndKextPatches = (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches));
//// CopyKernelAndKextPatches(&KernelAndKextPatches, &gSettings.KernelAndKextPatches);
// KernelAndKextPatches = gSettings.KernelAndKextPatches;
//
// PatcherInited = false;
// KernelAndKextPatcherInit();
//
// KextPatchesNeeded = (
// KernelAndKextPatches.KPAppleIntelCPUPM ||
// KernelAndKextPatches.KPAppleRTC ||
// KernelAndKextPatches.EightApple ||
// KernelAndKextPatches.KPDELLSMBIOS ||
// KernelAndKextPatches.KPATIConnectorsPatch.notEmpty() ||
// KernelAndKextPatches.KextPatches.size() > 0
// );
//
//// DBG_RT("\nKernelToPatch: ");
//// DBG_RT("Kernels patches: %d\n", KernelAndKextPatches.KernelPatches.size());
// if (gSettings.KernelPatchesAllowed && KernelAndKextPatches.KernelPatches.notEmpty()) {
//// DBG_RT("Enabled: \n");
// DBG("Kernels patches: enabled \n");
//// KernelAndKextPatcherInit();
//// if (KernelData == NULL) goto NoKernelData;
// if (EFI_ERROR(getVTable())) {
//// DBG_RT("error getting vtable: \n");
// goto NoKernelData;
// }
// patchedOk = KernelUserPatch();
//// DBG_RT(patchedOk ? " OK\n" : " FAILED!\n");
//// gBS->Stall(5000000);
// } else {
//// DBG_RT("Disabled\n");
// }
///*
// DBG_RT( "\nKernelCpu patch: ");
// if (KernelAndKextPatches.KPKernelCpu) {
// //
// // Kernel patches
// //
// DBG_RT( "Enabled: \n");
// KernelAndKextPatcherInit();
// if (KernelData == NULL) goto NoKernelData;
if (bootArgs1 != NULL) {
deviceTreeP = bootArgs1->deviceTreeP;
deviceTreeLength = &bootArgs1->deviceTreeLength;
} else if (bootArgs2 != NULL) {
deviceTreeP = bootArgs2->deviceTreeP;
deviceTreeLength = &bootArgs2->deviceTreeLength;
} else return;
Status = InjectKexts(deviceTreeP, deviceTreeLength);
DBG_RT("Inject kexts done at 0x%llx\n", (UINTN)deviceTreeP);
if (!EFI_ERROR(Status)) KernelBooterExtensionsPatch();
}
return;
NoKernelData:
Stall(5000000);
}
// if(is64BitKernel) {
// DBG_RT( "64 bit patch ...\n");
// KernelPatcher_64();
// } else {
// DBG_RT( "32 bit patch ...\n");
// KernelPatcher_32();
// }
// DBG_RT( " OK\n");
// } else {
// DBG_RT( "Disabled\n");
// }
//*/
// //other method for KernelCPU patch is FakeCPUID
// DBG_RT( "\nFakeCPUID patch: ");
// if (KernelAndKextPatches.FakeCPUID) {
// DBG_RT( "Enabled: 0x%06x\n", KernelAndKextPatches.FakeCPUID);
//// KernelAndKextPatcherInit();
//// if (KernelData == NULL) goto NoKernelData;
// KernelCPUIDPatch();
// } else {
// DBG_RT( "Disabled\n");
// }
//
// // CPU power management patch for CPU with locked msr
// DBG_RT( "\nKernelPm patch: ");
// if (KernelAndKextPatches.KPKernelPm || KernelAndKextPatches.KPKernelXCPM) {
// DBG_RT( "Enabled: \n");
// DBG( "KernelPm patch: Enabled\n");
//// KernelAndKextPatcherInit();
//// if (KernelData == NULL) goto NoKernelData;
// patchedOk = FALSE;
// if (is64BitKernel) {
// patchedOk = KernelPatchPm();
// }
// DBG_RT( patchedOk ? " OK\n" : " FAILED!\n");
// } else {
// DBG_RT( "Disabled\n");
// }
//
// // Patch to not dump kext at panic (c)vit9696
// DBG_RT( "\nPanicNoKextDump patch: ");
// if (KernelAndKextPatches.KPPanicNoKextDump) {
// DBG_RT( "Enabled: \n");
//// KernelAndKextPatcherInit();
//// if (KernelData == NULL) goto NoKernelData;
// patchedOk = KernelPanicNoKextDump();
// DBG_RT( patchedOk ? " OK\n" : " FAILED!\n");
// } else {
// DBG_RT( "Disabled\n");
// }
//
//
// // Lapic Panic Kernel Patch
// DBG_RT( "\nKernelLapic patch: ");
// if (KernelAndKextPatches.KPKernelLapic) {
// DBG_RT( "Enabled: \n");
//// KernelAndKextPatcherInit();
//// if (KernelData == NULL) goto NoKernelData;
// if(is64BitKernel) {
// DBG_RT( "64-bit patch ...\n");
// patchedOk = KernelLapicPatch_64();
// } else {
// DBG_RT( "32-bit patch ...\n");
// patchedOk = KernelLapicPatch_32();
// }
// DBG_RT( patchedOk ? " OK\n" : " FAILED!\n");
// } else {
// DBG_RT( "Disabled\n");
// }
//
// if (KernelAndKextPatches.KPKernelXCPM) {
// //
// // syscl - EnableExtCpuXCPM: Enable unsupported CPU's PowerManagement
// //
//// EnableExtCpuXCPM = NULL;
// patchedOk = FALSE;
//// BOOLEAN apply_idle_patch = (gCPUStructure.Model >= CPU_MODEL_SKYLAKE_U) && gSettings.HWP;
//// KernelAndKextPatcherInit();
//// if (KernelData == NULL) goto NoKernelData;
//
// // syscl - now enable extra Cpu's PowerManagement
// // only Intel support this feature till now
// // move below code outside the if condition if AMD supports
// // XCPM later on
//
// if (gCPUStructure.Vendor == CPU_VENDOR_INTEL) {
// switch (gCPUStructure.Model) {
// case CPU_MODEL_JAKETOWN:
// // SandyBridge-E LGA2011
// patchedOk = SandyBridgeEPM();
// gSNBEAICPUFixRequire = TRUE; // turn on SandyBridge-E AppleIntelCPUPowerManagement Fix
// break;
//
// case CPU_MODEL_IVY_BRIDGE:
// // IvyBridge
// patchedOk = KernelIvyBridgeXCPM();
// break;
//
// case CPU_MODEL_IVY_BRIDGE_E5:
// // IvyBridge-E
// patchedOk = KernelIvyE5XCPM();
// break;
//
// case CPU_MODEL_HASWELL_E:
// // Haswell-E
// patchedOk = HaswellEXCPM();
// break;
//
// case CPU_MODEL_BROADWELL_E5:
// case CPU_MODEL_BROADWELL_DE:
// // Broadwell-E/EP
// patchedOk = BroadwellEPM();
// gBDWEIOPCIFixRequire = TRUE;
// break;
//
// default:
// if (gCPUStructure.Model >= CPU_MODEL_HASWELL &&
// (AsciiStrStr(gCPUStructure.BrandString, "Celeron") ||
// AsciiStrStr(gCPUStructure.BrandString, "Pentium"))) {
// // Haswell+ low-end CPU
// patchedOk = HaswellLowEndXCPM();
// }
// break;
// }
// }
// DBG_RT( "EnableExtCpuXCPM - %s!\n", patchedOk? "OK" : "FAILED");
// }
//
// Stall(2000000);
// //
// // Kext patches
// //
//
// // we need to scan kexts if "InjectKexts true and CheckFakeSMC"
// if (/*OSFLAG_ISSET(Flags, OSFLAG_WITHKEXTS) || */
// OSFLAG_ISSET(Flags, OSFLAG_CHECKFAKESMC)) {
// DBG_RT( "\nAllowing kext patching to check if FakeSMC is present\n");
// gSettings.KextPatchesAllowed = TRUE;
// KextPatchesNeeded = TRUE;
// }
//
// DBG_RT( "\nKextPatches Needed: %c, Allowed: %c ... ",
// (KextPatchesNeeded ? L'Y' : L'n'),
// (gSettings.KextPatchesAllowed ? L'Y' : L'n')
// );
//
// if (KextPatchesNeeded && gSettings.KextPatchesAllowed) {
//// DBG_RT( "\nKext patching INIT\n");
//// KernelAndKextPatcherInit();
//// if (KernelData == NULL) goto NoKernelData;
// DBG_RT( "\nKext patching STARTED\n");
// KextPatcherStart(); //is FakeSMC found in cache then inject will be disabled
// DBG_RT( "\nKext patching ENDED\n");
// } else {
// DBG_RT( "Disabled\n");
// }
//
// Stall(1000000);
//
// //
// // Kext add
// //
//// if (KernelAndKextPatches.KPDebug) {
//// if (OSFLAG_ISSET(Entry->Flags, OSFLAG_CHECKFAKESMC) &&
//// OSFLAG_ISUNSET(Entry->Flags, OSFLAG_WITHKEXTS)) {
//// disabled kext injection if FakeSMC is already present
//// Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_WITHKEXTS); //Slice - we are already here
////
//// DBG_RT( "\nInjectKexts: disabled because FakeSMC is already present and InjectKexts option set to Detect\n");
//// gBS->Stall(500000);
//// }
//// }
//
// if (OSFLAG_ISSET(Flags, OSFLAG_WITHKEXTS)) {
// UINT32 deviceTreeP;
// UINT32 *deviceTreeLength;
// EFI_STATUS Status;
// UINTN DataSize;
//
// // check if FSInject already injected kexts
// DataSize = 0;
// Status = gRT->GetVariable (L"FSInject.KextsInjected", &gEfiGlobalVariableGuid, NULL, &DataSize, NULL);
// if (Status == EFI_BUFFER_TOO_SMALL) {
// // var exists - just exit
//
// DBG_RT( "\nInjectKexts: skipping, FSInject already injected them\n");
// Stall(500000);
// return;
// }
//
//// KernelAndKextPatcherInit();
//// if (KernelData == NULL) goto NoKernelData;
// if (bootArgs1 != NULL) {
// deviceTreeP = bootArgs1->deviceTreeP;
// deviceTreeLength = &bootArgs1->deviceTreeLength;
// } else if (bootArgs2 != NULL) {
// deviceTreeP = bootArgs2->deviceTreeP;
// deviceTreeLength = &bootArgs2->deviceTreeLength;
// } else return;
//
// Status = InjectKexts(deviceTreeP, deviceTreeLength);
// DBG_RT("Inject kexts done at 0x%llx\n", (UINTN)deviceTreeP);
// if (!EFI_ERROR(Status)) KernelBooterExtensionsPatch();
// }
//
// return;
//
//NoKernelData:
// Stall(5000000);
//}

View File

@ -482,20 +482,20 @@ void LOADER_ENTRY::AppleRTCPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPl
//
// not used since 4242
#if 0
void LOADER_ENTRY::CheckForFakeSMC(CHAR8 *InfoPlist)
{
if (OSFLAG_ISSET(Flags, OSFLAG_CHECKFAKESMC) &&
OSFLAG_ISSET(Flags, OSFLAG_WITHKEXTS)) {
if (AsciiStrStr(InfoPlist, "<string>org.netkas.driver.FakeSMC</string>") != NULL
|| AsciiStrStr(InfoPlist, "<string>org.netkas.FakeSMC</string>") != NULL
|| AsciiStrStr(InfoPlist, "<string>as.vit9696.VirtualSMC</string>") != NULL)
{
Flags = OSFLAG_UNSET(Flags, OSFLAG_WITHKEXTS);
DBG_RT("\nFakeSMC or VirtualSMC found, UNSET WITHKEXTS\n");
Stall(5000000);
}
}
}
//void LOADER_ENTRY::CheckForFakeSMC(CHAR8 *InfoPlist)
//{
// if (OSFLAG_ISSET(Flags, OSFLAG_CHECKFAKESMC) &&
// OSFLAG_ISSET(Flags, OSFLAG_WITHKEXTS)) {
// if (AsciiStrStr(InfoPlist, "<string>org.netkas.driver.FakeSMC</string>") != NULL
// || AsciiStrStr(InfoPlist, "<string>org.netkas.FakeSMC</string>") != NULL
// || AsciiStrStr(InfoPlist, "<string>as.vit9696.VirtualSMC</string>") != NULL)
// {
// Flags = OSFLAG_UNSET(Flags, OSFLAG_WITHKEXTS);
// DBG_RT("\nFakeSMC or VirtualSMC found, UNSET WITHKEXTS\n");
// Stall(5000000);
// }
// }
//}
#endif

View File

@ -13,14 +13,23 @@ class undefinable
{
protected:
bool m_defined = false;
T m_value = false;
T m_value = T();
public:
bool isDefined() const { return m_defined; }
void setDefined(bool b) { m_defined = b; }
operator T() const {
if ( !isDefined() ) panic("def_type is not defined");
// T& value() { return m_value; } // never allow to return a modifiable value. We need to hook ever assignment possible.
const T& value() const {
if ( !isDefined() ) {
panic("get value of an undefined undefinable type");
}
return m_value;
}
const T& dgetValue() const { return m_value; } // if !m_defined, m_value = T()
operator const T&() const {
if ( !isDefined() ) panic("get value of an undefined undefinable type");
return m_value;
}
undefinable<T>& operator = (T value) {
@ -34,23 +43,29 @@ class undefinable_bool : public undefinable<bool>
{
using super = undefinable<bool>;
public:
undefinable_bool& operator = (bool b) { super::operator=(b); return *this; }
undefinable_bool& operator = (bool newValue) { super::operator=(newValue); return *this; }
};
class undefinable_uint16 : public undefinable<uint16_t>
{
using super = undefinable<uint16_t>;
public:
undefinable_uint16& operator = (uint16_t b) { super::operator=(b); return *this; }
undefinable_uint16& operator = (uint16_t newValue) { super::operator=(newValue); return *this; }
};
class undefinable_uint32 : public undefinable<uint32_t>
{
using super = undefinable<uint32_t>;
public:
undefinable_uint32& operator = (uint32_t b) { super::operator=(b); return *this; }
undefinable_uint32& operator = (uint32_t newValue) { super::operator=(newValue); return *this; }
};
class undefinable_XString8 : public undefinable<XString8>
{
using super = undefinable<XString8>;
public:
undefinable_XString8& operator = (XString8 newValue) { super::operator=(newValue); return *this; }
};
#endif /* CPP_LIB_DEF_TYPES_H_ */

View File

@ -42,7 +42,6 @@ extern REFIT_MENU_ITEM_RESET MenuEntryReset;
extern REFIT_MENU_ITEM_SHUTDOWN MenuEntryShutdown;
//extern REFIT_MENU_ENTRY MenuEntryHelp;
//extern REFIT_MENU_ENTRY MenuEntryExit;
extern REFIT_MENU_SCREEN MainMenu;
// common
const XIcon& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, const EFI_DEVICE_PATH_PROTOCOL *DevicePath);

View File

@ -38,6 +38,7 @@
#include "../refit/screen.h"
#include "../refit/menu.h"
#include "../gui/REFIT_MENU_SCREEN.h"
#include "../gui/REFIT_MAINMENU_SCREEN.h"
#include "../Platform/Volumes.h"
#include "../libeg/XTheme.h"
#include "../include/OSFlags.h"

View File

@ -48,6 +48,7 @@
#include "../Platform/guid.h"
#include "../refit/lib.h"
#include "../gui/REFIT_MENU_SCREEN.h"
#include "../gui/REFIT_MAINMENU_SCREEN.h"
#include "../Platform/Self.h"
#include "../include/OSTypes.h"
#include "../Platform/BootOptions.h"
@ -449,8 +450,8 @@ STATIC EFI_STATUS GetOSXVolumeName(LOADER_ENTRY *Entry)
STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
IN CONST XString8Array& LoaderOptions,
IN CONST XStringW& FullTitle,
IN CONST XStringW& LoaderTitle,
IN CONST XString8& FullTitle,
IN CONST XString8& LoaderTitle,
IN REFIT_VOLUME *Volume,
IN XIcon *Image,
IN XIcon *DriveImage,
@ -510,11 +511,11 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
}
}
// If this isn't a custom entry make sure it's not hidden by a custom entry
for (size_t CustomIndex = 0 ; CustomIndex < gSettings.GUI.CustomEntries.size() ; ++CustomIndex ) {
CUSTOM_LOADER_ENTRY& Custom = gSettings.GUI.CustomEntries[CustomIndex];
if ( Custom.Disabled ) continue; // before, disabled entries settings weren't loaded.
for (size_t CustomIndex = 0 ; CustomIndex < GlobalConfig.CustomEntries.size() ; ++CustomIndex ) {
CUSTOM_LOADER_ENTRY& Custom = GlobalConfig.CustomEntries[CustomIndex];
if ( Custom.settings.Disabled ) continue; // before, disabled entries settings weren't loaded.
// Check if the custom entry is hidden or disabled
if ( OSFLAG_ISSET(Custom.Flags, OSFLAG_DISABLED) || Custom.Hidden ) {
if ( OSFLAG_ISSET(Custom.getFlags(gSettings.NoCaches), OSFLAG_DISABLED) || Custom.settings.Hidden ) {
INTN volume_match=0;
INTN volume_type_match=0;
@ -522,27 +523,27 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
INTN type_match=0;
// Check if volume match
if (Custom.Volume.notEmpty()) {
if (Custom.settings.Volume.notEmpty()) {
// Check if the string matches the volume
volume_match =
((StrStr(Volume->DevicePathString.wc_str(), Custom.Volume.wc_str()) != NULL) ||
((Volume->VolName.notEmpty()) && (StrStr(Volume->VolName.wc_str(), Custom.Volume.wc_str()) != NULL))) ? 1 : -1;
((StrStr(Volume->DevicePathString.wc_str(), Custom.settings.Volume.wc_str()) != NULL) ||
((Volume->VolName.notEmpty()) && (StrStr(Volume->VolName.wc_str(), Custom.settings.Volume.wc_str()) != NULL))) ? 1 : -1;
}
// Check if the volume_type match
if (Custom.VolumeType != 0) {
volume_type_match = (((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0) ? 1 : -1;
if (Custom.settings.VolumeType != 0) {
volume_type_match = (((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) != 0) ? 1 : -1;
}
// Check if the path match
if (Custom.Path.notEmpty()) {
if (Custom.settings.Path.notEmpty()) {
// Check if the loader path match
path_match = (Custom.Path.equalIC(LoaderPath)) ? 1 : -1;
path_match = (Custom.settings.Path.equalIC(LoaderPath)) ? 1 : -1;
}
// Check if the type match
if (Custom.Type != 0) {
type_match = OSTYPE_COMPARE(Custom.Type, OSType) ? 1 : -1;
if (Custom.settings.Type != 0) {
type_match = OSTYPE_COMPARE(Custom.settings.Type, OSType) ? 1 : -1;
}
if (volume_match == -1 || volume_type_match == -1 || path_match == -1 || type_match == -1 ) {
@ -645,8 +646,8 @@ if ( Entry->APFSTargetUUID.startWith("99999999") ) {
}
//always unset checkFakeSmc for installer
if (OSType == OSTYPE_OSX_INSTALLER){
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_CHECKFAKESMC);
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_CHECKFAKESMC);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
}
ShortcutLetter = 'M';
if ( Entry->DisplayedVolName.isEmpty() ) {
@ -689,9 +690,9 @@ if ( Entry->APFSTargetUUID.startWith("99999999") ) {
Entry->Title = FullTitle;
if (Entry->Title.isEmpty() && Volume->VolLabel.notEmpty()) {
if (Volume->VolLabel[0] == L'#') {
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? LoaderTitle.wc_str() : LoaderPath.basename().wc_str(), Volume->VolLabel.data(1));
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? XStringW(LoaderTitle).wc_str() : LoaderPath.basename().wc_str(), Volume->VolLabel.data(1));
}else{
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? LoaderTitle.wc_str() : LoaderPath.basename().wc_str(), Volume->VolLabel.wc_str());
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? XStringW(LoaderTitle).wc_str() : LoaderPath.basename().wc_str(), Volume->VolLabel.wc_str());
}
}
@ -707,7 +708,7 @@ if ( Entry->APFSTargetUUID.startWith("99999999") ) {
Entry->Title = (BasenameXW.contains(L"-")) ? BasenameXW.subString(0,BasenameXW.indexOf(L"-") + 1) + L"..)" : BasenameXW;
}
} else {
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? LoaderTitle.wc_str() : LoaderPath.basename().wc_str(),
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? XStringW(LoaderTitle).wc_str() : LoaderPath.basename().wc_str(),
(BasenameXW.contains(L"-")) ? (BasenameXW.subString(0,BasenameXW.indexOf(L"-") + 1) + L"..)").wc_str() : BasenameXW.wc_str());
}
}
@ -715,7 +716,7 @@ if ( Entry->APFSTargetUUID.startWith("99999999") ) {
if ( Entry->Title.isEmpty() ) {
// DBG("encounter LoaderTitle ==%ls and Entry->VolName ==%ls\n", LoaderTitle.wc_str(), Entry->VolName);
if (BootCampStyle) {
if ((StriCmp(LoaderTitle.wc_str(), L"macOS") == 0) || (StriCmp(LoaderTitle.wc_str(), L"Recovery") == 0)) {
if ((StriCmp(XStringW(LoaderTitle).wc_str(), L"macOS") == 0) || (StriCmp(XStringW(LoaderTitle).wc_str(), L"Recovery") == 0)) {
Entry->Title.takeValueFrom(Entry->DisplayedVolName);
} else {
if (!LoaderTitle.isEmpty()) {
@ -725,7 +726,7 @@ if ( Entry->APFSTargetUUID.startWith("99999999") ) {
}
}
} else {
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? LoaderTitle.wc_str() : LoaderPath.basename().wc_str(),
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? XStringW(LoaderTitle).wc_str() : LoaderPath.basename().wc_str(),
Entry->DisplayedVolName.wc_str());
}
}
@ -1047,13 +1048,13 @@ LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Arr
if ((Entry->LoaderType == OSTYPE_OSX) ||
(Entry->LoaderType == OSTYPE_OSX_INSTALLER ) ||
(Entry->LoaderType == OSTYPE_RECOVERY)) {
if (gSettings.WithKexts) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
}
if (gSettings.WithKextsIfNoFakeSMC) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_CHECKFAKESMC);
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
}
// if (gSettings.WithKexts) {
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// }
// if (gSettings.WithKextsIfNoFakeSMC) {
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_CHECKFAKESMC);
// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
// }
if (gSettings.NoCaches) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NOCACHES);
}
@ -1816,6 +1817,138 @@ void ScanLoader(void)
}
STATIC void AddCustomSubEntry(REFIT_VOLUME *Volume,
IN UINTN CustomIndex,
IN const XStringW& CustomPath,
UINT8 parentType,
IN const CUSTOM_LOADER_SUBENTRY& Custom,
IN const XStringW& DefaultEntrySettings,
IN REFIT_MENU_SCREEN *SubMenu)
{
// UINTN VolumeIndex;
// REFIT_VOLUME *Volume;
// REFIT_DIR_ITER SIter;
// REFIT_DIR_ITER *Iter = &SIter;
// CHAR16 PartUUID[40];
// XStringW CustomPath = _CustomPath;
if ( CustomPath.isEmpty() ) panic("BUG : CustomPath is empty");
if ( SubMenu == NULL ) panic("BUG : this must be a sub entry");
// if (FindCustomPath && (Custom.settings.Type != OSTYPE_LINEFI) && (Custom.settings.Type != OSTYPE_LIN)) {
//// DBG("Custom %lsentry %llu skipped because it didn't have a ", IsSubEntry ? L"sub " : L"", CustomIndex);
//// if (Custom.Type == 0) {
//// DBG("Type.\n");
//// } else {
//// DBG("Path.\n");
//// }
// return;
// }
if ( Custom.settings.Disabled ) {
// DBG("Custom %lsentry %llu skipped because it is disabled.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
return;
}
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom.settings.Flags, OSFLAG_HIDDEN)) {
// DBG("Custom %lsentry %llu skipped because it is hidden.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
// return;
// }
#if 0 //if someone want to debug this
DBG("Custom %lsentry %llu ", IsSubEntry ? L"sub " : L"", CustomIndex);
// if (Custom.settings.Title) {
DBG("Title:\"%ls\" ", Custom.settings.Title.wc_str());
// }
// if (Custom.settings.FullTitle) {
DBG("FullTitle:\"%ls\" ", Custom.settings.FullTitle.wc_str());
// }
if (CustomPath) {
DBG("Path:\"%ls\" ", CustomPath);
}
if (Custom.settings.Options != NULL) {
DBG("Options:\"%ls\" ", Custom.settings.Options);
}
DBG("Type:%d Flags:0x%hhX matching ", Custom.settings.Type, Custom.settings.Flags);
if (Custom.settings.Volume) {
DBG("Volume:\"%ls\"\n", Custom.settings.Volume);
} else {
DBG("all volumes\n");
}
#endif
// for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
LOADER_ENTRY *Entry = NULL;
// EFI_GUID *Guid = NULL;
// UINT64 VolumeSize;
// Volume = &Volumes[VolumeIndex];
if ((Volume == NULL) || (Volume->RootDir == NULL)) {
return;
}
if (Volume->VolName.isEmpty()) {
Volume->VolName = L"Unknown"_XSW;
}
// do { // when not scanning for kernels, this loop will execute only once
XString8Array CustomOptions = Custom.getLoadOptions();
UINT8 newCustomFlags = Custom.getFlags(gSettings.NoCaches);
// Create an entry for this volume
Entry = CreateLoaderEntry(CustomPath, CustomOptions, Custom.getFullTitle(), Custom.getTitle(), Volume,
NULL, NULL,
parentType, newCustomFlags, 0, {0,0,0,0}, 0, NullXImage,
/*(KERNEL_AND_KEXT_PATCHES *)(((UINTN)Custom) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches))*/ NULL, TRUE);
if (Entry != NULL) {
// if ( Custom.settings.Settings.notEmpty() ) DBG("Custom settings: %ls.plist will %s be applied\n", Custom.settings.Settings.wc_str(), Custom.settings.CommonSettings?"not":"");
// if (!Custom.settings.CommonSettings) {
// Entry->Settings = DefaultEntrySettings;
// }
if (OSFLAG_ISUNSET(newCustomFlags, OSFLAG_NODEFAULTMENU)) {
Entry->AddDefaultMenu();
// } else if (Custom.SubEntries.notEmpty()) {
// UINTN CustomSubIndex = 0;
// // Add subscreen
// REFIT_MENU_SCREEN *SubScreen = new REFIT_MENU_SCREEN;
// SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", (Custom.settings.Title.notEmpty()) ? Custom.settings.Title.wc_str() : CustomPath.wc_str(), Entry->DisplayedVolName.wc_str());
// SubScreen->TitleImage = Entry->Image;
// SubScreen->ID = Custom.settings.Type + 20;
// SubScreen->GetAnime();
// VolumeSize = RShiftU64(MultU64x32(Volume->BlockIO->Media->LastBlock, Volume->BlockIO->Media->BlockSize), 20);
// SubScreen->AddMenuInfoLine_f("Volume size: %lldMb", VolumeSize);
// SubScreen->AddMenuInfoLine_f("%ls", FileDevicePathToXStringW(Entry->DevicePath).wc_str());
// if (Guid) {
// SubScreen->AddMenuInfoLine_f("UUID: %s", strguid(Guid));
// }
// SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.ConcatAll(" "_XS8).c_str());
// DBG("Create sub entries\n");
// for (size_t CustomSubEntryIndex = 0 ; CustomSubEntryIndex < Custom.SubEntries.size() ; ++CustomSubEntryIndex ) {
// const CUSTOM_LOADER_SUBENTRY& CustomSubEntry = Custom.SubEntries[CustomSubEntryIndex];
// if ( CustomSubEntry.settings.Settings.isEmpty() ) {
// AddCustomSubEntry(Volume, CustomSubIndex++, CustomSubEntry.settings.Path.notEmpty() ? CustomSubEntry.settings.Path : CustomPath, CustomSubEntry, Custom.settings.Settings, SubScreen);
// }else{
// AddCustomSubEntry(Volume, CustomSubIndex++, CustomSubEntry.settings.Path.notEmpty() ? CustomSubEntry.settings.Path : CustomPath, CustomSubEntry, CustomSubEntry.settings.Settings, SubScreen);
// }
// }
// SubScreen->AddMenuEntry(&MenuEntryReturn, true);
// Entry->SubScreen = SubScreen;
}
SubMenu->AddMenuEntry(Entry, true);
// Entry->Hidden = Custom.settings.Hidden;
// if ( Custom.settings.Hidden ) DBG(" hiding entry because Custom.settings.Hidden\n");
}
// } while (FindCustomPath && Custom.settings.Type == OSTYPE_LINEFI && Custom.settings.KernelScan == KERNEL_SCAN_ALL); // repeat loop only for kernel scanning
// // Close the kernel boot directory
// if (FindCustomPath && Custom.settings.Type == OSTYPE_LINEFI) {
// DirIterClose(Iter);
// }
// }
}
STATIC void AddCustomEntry(IN UINTN CustomIndex,
IN const XStringW& _CustomPath,
IN const CUSTOM_LOADER_ENTRY& Custom,
@ -1827,12 +1960,12 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
REFIT_DIR_ITER SIter;
REFIT_DIR_ITER *Iter = &SIter;
CHAR16 PartUUID[40];
BOOLEAN IsSubEntry = (SubMenu != NULL);
XStringW CustomPath = _CustomPath;
BOOLEAN FindCustomPath = (CustomPath.isEmpty());
if (FindCustomPath && (Custom.Type != OSTYPE_LINEFI) && (Custom.Type != OSTYPE_LIN)) {
if ( SubMenu != NULL ) panic("Call AddCustomSubEntry instead");
if (FindCustomPath && (Custom.settings.Type != OSTYPE_LINEFI) && (Custom.settings.Type != OSTYPE_LIN)) {
// DBG("Custom %lsentry %llu skipped because it didn't have a ", IsSubEntry ? L"sub " : L"", CustomIndex);
// if (Custom.Type == 0) {
// DBG("Type.\n");
@ -1842,33 +1975,33 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
return;
}
if (OSFLAG_ISSET(Custom.Flags, OSFLAG_DISABLED)) {
if (OSFLAG_ISSET(Custom.getFlags(gSettings.NoCaches), OSFLAG_DISABLED)) {
// DBG("Custom %lsentry %llu skipped because it is disabled.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
return;
}
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom.Flags, OSFLAG_HIDDEN)) {
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom.settings.Flags, OSFLAG_HIDDEN)) {
// DBG("Custom %lsentry %llu skipped because it is hidden.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
// return;
// }
#if 0 //if someone want to debug this
DBG("Custom %lsentry %llu ", IsSubEntry ? L"sub " : L"", CustomIndex);
// if (Custom.Title) {
DBG("Title:\"%ls\" ", Custom.Title.wc_str());
// if (Custom.settings.Title) {
DBG("Title:\"%ls\" ", Custom.settings.Title.wc_str());
// }
// if (Custom.FullTitle) {
DBG("FullTitle:\"%ls\" ", Custom.FullTitle.wc_str());
// if (Custom.settings.FullTitle) {
DBG("FullTitle:\"%ls\" ", Custom.settings.FullTitle.wc_str());
// }
if (CustomPath) {
DBG("Path:\"%ls\" ", CustomPath);
}
if (Custom.Options != NULL) {
DBG("Options:\"%ls\" ", Custom.Options);
if (Custom.settings.Options != NULL) {
DBG("Options:\"%ls\" ", Custom.settings.Options);
}
DBG("Type:%d Flags:0x%hhX matching ", Custom.Type, Custom.Flags);
if (Custom.Volume) {
DBG("Volume:\"%ls\"\n", Custom.Volume);
DBG("Type:%d Flags:0x%hhX matching ", Custom.settings.Type, Custom.settings.Flags);
if (Custom.settings.Volume) {
DBG("Volume:\"%ls\"\n", Custom.settings.Volume);
} else {
DBG("all volumes\n");
}
@ -1876,8 +2009,8 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
LOADER_ENTRY *Entry = NULL;
XIcon Image = Custom.Image;
XIcon DriveImage = Custom.DriveImage;
XIcon Image = Custom.settings.Image;
XIcon DriveImage = Custom.settings.DriveImage;
EFI_GUID *Guid = NULL;
UINT64 VolumeSize;
@ -1898,7 +2031,7 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
continue;
}
if (Custom.VolumeType != 0 && ((1<<Volume->DiskKind) & Custom.VolumeType) == 0) {
if (Custom.settings.VolumeType != 0 && ((1<<Volume->DiskKind) & Custom.settings.VolumeType) == 0) {
DBG("skipped because media is ignored\n");
continue;
}
@ -1916,9 +2049,9 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
// Check for exact volume matches (devicepath / volumelabel)
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.settings.Volume.notEmpty()) {
if ((StrStr(Volume->DevicePathString.wc_str(), Custom.settings.Volume.wc_str()) == NULL) &&
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom.settings.Volume.wc_str()) == NULL))) {
bool CustomEntryFound = false;
//..\VenMedia(BE74FCF7-0B7C-49F3-9147-01F4042E6842,E97E25EA28F4DF46AAD44CC3F12E28D3)
EFI_DEVICE_PATH *MediaPath = Clover_FindDevicePathNodeWithType(Volume->DevicePath, MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP);
@ -1926,11 +2059,11 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
EFI_GUID *MediaPathGuid = (EFI_GUID *)&((VENDOR_DEVICE_PATH_WITH_DATA*)MediaPath)->VendorDefinedData;
XStringW MediaPathGuidStr = GuidLEToXStringW(*MediaPathGuid);
// DBG(" checking '%ls'\n", MediaPathGuidStr.wc_str());
if (StrStr(Custom.Volume.wc_str(), MediaPathGuidStr.wc_str())) {
DBG(" - found entry for volume '%ls', '%ls'\n", Custom.Volume.wc_str(), MediaPathGuidStr.wc_str());
if (StrStr(Custom.settings.Volume.wc_str(), MediaPathGuidStr.wc_str())) {
DBG(" - found entry for volume '%ls', '%ls'\n", Custom.settings.Volume.wc_str(), MediaPathGuidStr.wc_str());
CustomEntryFound = true;
} else {
DBG(" - search volume '%ls', but MediaPath '%ls' \n", Custom.Volume.wc_str(), MediaPathGuidStr.wc_str());
DBG(" - search volume '%ls', but MediaPath '%ls' \n", Custom.settings.Volume.wc_str(), MediaPathGuidStr.wc_str());
}
}
if (!CustomEntryFound) {
@ -1952,29 +2085,29 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
StrToLower(PartUUID);
// search for standard/nonstandard linux uefi paths, and all kernel scan options that != KERNEL_SCAN_ALL
if (Custom.Type == OSTYPE_LIN || Custom.KernelScan != KERNEL_SCAN_ALL) {
LinuxScan(Volume, Custom.KernelScan, Custom.Type, &CustomPath, &Image);
if (Custom.settings.Type == OSTYPE_LIN || Custom.settings.KernelScan != KERNEL_SCAN_ALL) {
LinuxScan(Volume, Custom.settings.KernelScan, Custom.settings.Type, &CustomPath, &Image);
}
if (Custom.Type == OSTYPE_LINEFI) {
if (Custom.settings.Type == OSTYPE_LINEFI) {
// Open the boot directory to determine linux loadoptions when found item, or kernels when KERNEL_SCAN_ALL
DirIterOpen(Volume->RootDir, LINUX_BOOT_PATH, Iter);
}
} else if (!FileExists(Volume->RootDir, CustomPath)) {
DBG("skipped because path does not exist\n");
DBG("skipped because path '%ls' does not exist\n", CustomPath.wc_str());
continue;
}
// Change to custom image if needed
if (Image.isEmpty() && Custom.ImagePath.notEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), Custom.ImagePath);
if (Image.isEmpty() && Custom.settings.ImagePath.notEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), Custom.settings.ImagePath);
if (Image.isEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), L"os_"_XSW + Custom.ImagePath);
Image.LoadXImage(&ThemeX.getThemeDir(), L"os_"_XSW + Custom.settings.ImagePath);
if (Image.isEmpty()) {
Image.LoadXImage(&self.getCloverDir(), Custom.ImagePath);
Image.LoadXImage(&self.getCloverDir(), Custom.settings.ImagePath);
if (Image.isEmpty()) {
Image.LoadXImage(&self.getSelfVolumeRootDir(), Custom.ImagePath);
Image.LoadXImage(&self.getSelfVolumeRootDir(), Custom.settings.ImagePath);
if (Image.isEmpty()) {
Image.LoadXImage(Volume->RootDir, Custom.ImagePath);
Image.LoadXImage(Volume->RootDir, Custom.settings.ImagePath);
}
}
}
@ -1982,24 +2115,24 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
}
// Change to custom drive image if needed
if (DriveImage.isEmpty() && Custom.DriveImagePath.notEmpty()) {
DriveImage.LoadXImage(&ThemeX.getThemeDir(), Custom.DriveImagePath);
if (DriveImage.isEmpty() && Custom.settings.DriveImagePath.notEmpty()) {
DriveImage.LoadXImage(&ThemeX.getThemeDir(), Custom.settings.DriveImagePath);
if (DriveImage.isEmpty()) {
DriveImage.LoadXImage(&self.getCloverDir(), Custom.ImagePath);
DriveImage.LoadXImage(&self.getCloverDir(), Custom.settings.ImagePath);
if (DriveImage.isEmpty()) {
DriveImage.LoadXImage(&self.getSelfVolumeRootDir(), Custom.ImagePath);
DriveImage.LoadXImage(&self.getSelfVolumeRootDir(), Custom.settings.ImagePath);
if (DriveImage.isEmpty()) {
DriveImage.LoadXImage(Volume->RootDir, Custom.ImagePath);
DriveImage.LoadXImage(Volume->RootDir, Custom.settings.ImagePath);
}
}
}
}
do { // when not scanning for kernels, this loop will execute only once
XString8Array CustomOptions = Custom.LoadOptions;
XString8Array CustomOptions = Custom.getLoadOptions();
// for LINEFI with option KERNEL_SCAN_ALL, use this loop to search for kernels
if (FindCustomPath && Custom.Type == OSTYPE_LINEFI && Custom.KernelScan == KERNEL_SCAN_ALL) {
if (FindCustomPath && Custom.settings.Type == OSTYPE_LINEFI && Custom.settings.KernelScan == KERNEL_SCAN_ALL) {
EFI_FILE_INFO *FileInfo = NULL;
// Get the next kernel path or stop looking
if (!DirIterNext(Iter, 2, LINUX_LOADER_SEARCH_PATH, &FileInfo) || (FileInfo == NULL)) {
@ -2018,97 +2151,97 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
break;
}
UINT8 newCustomFlags = Custom.Flags;
UINT8 newCustomFlags = Custom.getFlags(gSettings.NoCaches);
// Check to make sure if we should update linux custom options or not
if (FindCustomPath && Custom.Type == OSTYPE_LINEFI && OSFLAG_ISUNSET(Custom.Flags, OSFLAG_NODEFAULTARGS)) {
if (FindCustomPath && Custom.settings.Type == OSTYPE_LINEFI && OSFLAG_ISUNSET(Custom.getFlags(gSettings.NoCaches), OSFLAG_NODEFAULTARGS)) {
// Find the init ram image and select root
CustomOptions = LinuxKernelOptions(Iter->DirHandle, Basename(CustomPath.wc_str()) + LINUX_LOADER_PATH.length(), PartUUID, Custom.LoadOptions);
newCustomFlags = OSFLAG_SET(Custom.Flags, OSFLAG_NODEFAULTARGS);
CustomOptions = LinuxKernelOptions(Iter->DirHandle, Basename(CustomPath.wc_str()) + LINUX_LOADER_PATH.length(), PartUUID, Custom.getLoadOptions());
newCustomFlags = OSFLAG_SET(Custom.getFlags(gSettings.NoCaches), OSFLAG_NODEFAULTARGS);
}
// Check to make sure that this entry is not hidden or disabled by another custom entry
if (!IsSubEntry) {
if (true) {
BOOLEAN BetterMatch = FALSE;
for (size_t i = 0 ; i < gSettings.GUI.CustomEntries.size() ; ++i ) {
CUSTOM_LOADER_ENTRY& CustomEntry = gSettings.GUI.CustomEntries[i];
if ( CustomEntry.Disabled ) continue; // before, disabled entries settings weren't loaded.
for (size_t i = 0 ; i < GlobalConfig.CustomEntries.size() ; ++i ) {
CUSTOM_LOADER_ENTRY& CustomEntry = GlobalConfig.CustomEntries[i];
if ( CustomEntry.settings.Disabled ) continue; // before, disabled entries settings weren't loaded.
// Don't match against this custom
if (&CustomEntry == &Custom) {
continue;
}
// Can only match the same types
if (Custom.Type != CustomEntry.Type) {
if (Custom.settings.Type != CustomEntry.settings.Type) {
continue;
}
// Check if the volume string matches
if (Custom.Volume != CustomEntry.Volume) {
if (CustomEntry.Volume.isEmpty()) {
if (Custom.settings.Volume != CustomEntry.settings.Volume) {
if (CustomEntry.settings.Volume.isEmpty()) {
// Less precise volume match
if (Custom.Path != CustomEntry.Path) {
if (Custom.settings.Path != CustomEntry.settings.Path) {
// Better path match
BetterMatch = ((CustomEntry.Path.notEmpty()) && CustomPath.equal(CustomEntry.Path) &&
((Custom.VolumeType == CustomEntry.VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0));
BetterMatch = ((CustomEntry.settings.Path.notEmpty()) && CustomPath.equal(CustomEntry.settings.Path) &&
((Custom.settings.VolumeType == CustomEntry.settings.VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) != 0));
}
} else 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.Volume.isEmpty()) {
} else if ((StrStr(Volume->DevicePathString.wc_str(), Custom.settings.Volume.wc_str()) == NULL) &&
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom.settings.Volume.wc_str()) == NULL))) {
if (Custom.settings.Volume.isEmpty()) {
// More precise volume match
if (Custom.Path != CustomEntry.Path) {
if (Custom.settings.Path != CustomEntry.settings.Path) {
// Better path match
BetterMatch = ((CustomEntry.Path.notEmpty()) && CustomPath.equal(CustomEntry.Path) &&
((Custom.VolumeType == CustomEntry.VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0));
} else if (Custom.VolumeType != CustomEntry.VolumeType) {
BetterMatch = ((CustomEntry.settings.Path.notEmpty()) && CustomPath.equal(CustomEntry.settings.Path) &&
((Custom.settings.VolumeType == CustomEntry.settings.VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) != 0));
} else if (Custom.settings.VolumeType != CustomEntry.settings.VolumeType) {
// More precise volume type match
BetterMatch = ((Custom.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
BetterMatch = ((Custom.settings.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) != 0);
} else {
// Better match
BetterMatch = TRUE;
}
// Duplicate volume match
} else if (Custom.Path != CustomEntry.Path) {
} else if (Custom.settings.Path != CustomEntry.settings.Path) {
// Better path match
BetterMatch = ((CustomEntry.Path.notEmpty()) && CustomPath.equal(CustomEntry.Path) &&
((Custom.VolumeType == CustomEntry.VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0));
BetterMatch = ((CustomEntry.settings.Path.notEmpty()) && CustomPath.equal(CustomEntry.settings.Path) &&
((Custom.settings.VolumeType == CustomEntry.settings.VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) != 0));
// Duplicate path match
} else if (Custom.VolumeType != CustomEntry.VolumeType) {
} else if (Custom.settings.VolumeType != CustomEntry.settings.VolumeType) {
// More precise volume type match
BetterMatch = ((Custom.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
BetterMatch = ((Custom.settings.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) != 0);
} else {
// Duplicate entry
BetterMatch = (i <= CustomIndex);
}
}
// Duplicate volume match
} else if (Custom.Path != CustomEntry.Path) {
if (CustomEntry.Path.isEmpty()) {
} else if (Custom.settings.Path != CustomEntry.settings.Path) {
if (CustomEntry.settings.Path.isEmpty()) {
// Less precise path match
BetterMatch = ((Custom.VolumeType != CustomEntry.VolumeType) &&
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
} else if (CustomPath.equal(CustomEntry.Path)) {
if (Custom.Path.isEmpty()) {
BetterMatch = ((Custom.settings.VolumeType != CustomEntry.settings.VolumeType) &&
((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) != 0);
} else if (CustomPath.equal(CustomEntry.settings.Path)) {
if (Custom.settings.Path.isEmpty()) {
// More precise path and volume type match
BetterMatch = ((Custom.VolumeType == CustomEntry.VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
} else if (Custom.VolumeType != CustomEntry.VolumeType) {
BetterMatch = ((Custom.settings.VolumeType == CustomEntry.settings.VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) != 0);
} else if (Custom.settings.VolumeType != CustomEntry.settings.VolumeType) {
// More precise volume type match
BetterMatch = ((Custom.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
BetterMatch = ((Custom.settings.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) != 0);
} else {
// Duplicate entry
BetterMatch = (i <= CustomIndex);
}
}
// Duplicate path match
} else if (Custom.VolumeType != CustomEntry.VolumeType) {
} else if (Custom.settings.VolumeType != CustomEntry.settings.VolumeType) {
// More precise volume type match
BetterMatch = ((Custom.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
BetterMatch = ((Custom.settings.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) != 0);
} else {
// Duplicate entry
BetterMatch = (i <= CustomIndex);
@ -2125,13 +2258,13 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
DBG("match!\n");
// Create an entry for this volume
Entry = CreateLoaderEntry(CustomPath, CustomOptions, Custom.FullTitle, Custom.Title, Volume,
Entry = CreateLoaderEntry(CustomPath, CustomOptions, Custom.settings.FullTitle, Custom.settings.Title, Volume,
(Image.isEmpty() ? NULL : &Image), (DriveImage.isEmpty() ? NULL : &DriveImage),
Custom.Type, newCustomFlags, Custom.Hotkey, Custom.BootBgColor, Custom.CustomLogoType, Custom.CustomLogoImage,
Custom.settings.Type, newCustomFlags, Custom.settings.Hotkey, Custom.settings.BootBgColor, Custom.settings.CustomLogoType, Custom.settings.CustomLogoImage,
/*(KERNEL_AND_KEXT_PATCHES *)(((UINTN)Custom) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches))*/ NULL, TRUE);
if (Entry != NULL) {
DBG("Custom settings: %ls.plist will %s be applied\n", Custom.Settings.wc_str(), Custom.CommonSettings?"not":"");
if (!Custom.CommonSettings) {
if ( Custom.settings.Settings.notEmpty() ) DBG("Custom settings: %ls.plist will %s be applied\n", Custom.settings.Settings.wc_str(), Custom.settings.CommonSettings?"not":"");
if (!Custom.settings.CommonSettings) {
Entry->Settings = DefaultEntrySettings;
}
if (OSFLAG_ISUNSET(newCustomFlags, OSFLAG_NODEFAULTMENU)) {
@ -2140,42 +2273,41 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
UINTN CustomSubIndex = 0;
// Add subscreen
REFIT_MENU_SCREEN *SubScreen = new REFIT_MENU_SCREEN;
if (SubScreen) {
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", (Custom.Title.notEmpty()) ? Custom.Title.wc_str() : CustomPath.wc_str(), Entry->DisplayedVolName.wc_str());
SubScreen->TitleImage = Entry->Image;
SubScreen->ID = Custom.Type + 20;
SubScreen->GetAnime();
VolumeSize = RShiftU64(MultU64x32(Volume->BlockIO->Media->LastBlock, Volume->BlockIO->Media->BlockSize), 20);
SubScreen->AddMenuInfoLine_f("Volume size: %lldMb", VolumeSize);
SubScreen->AddMenuInfoLine_f("%ls", FileDevicePathToXStringW(Entry->DevicePath).wc_str());
if (Guid) {
SubScreen->AddMenuInfoLine_f("UUID: %s", strguid(Guid));
}
SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.ConcatAll(" "_XS8).c_str());
DBG("Create sub entries\n");
for (size_t CustomSubEntryIndex = 0 ; CustomSubEntryIndex < Custom.SubEntries.size() ; ++CustomSubEntryIndex ) {
const CUSTOM_LOADER_ENTRY& CustomSubEntry = Custom.SubEntries[CustomSubEntryIndex];
if ( CustomSubEntry.Settings.isEmpty() ) {
AddCustomEntry(CustomSubIndex++, (CustomSubEntry.Path.notEmpty()) ? CustomSubEntry.Path : CustomPath, CustomSubEntry, Custom.Settings, SubScreen);
}else{
AddCustomEntry(CustomSubIndex++, (CustomSubEntry.Path.notEmpty()) ? CustomSubEntry.Path : CustomPath, CustomSubEntry, CustomSubEntry.Settings, SubScreen);
}
}
SubScreen->AddMenuEntry(&MenuEntryReturn, true);
Entry->SubScreen = SubScreen;
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", (Custom.settings.Title.notEmpty()) ? XStringW(Custom.settings.Title).wc_str() : CustomPath.wc_str(), Entry->DisplayedVolName.wc_str());
SubScreen->TitleImage = Entry->Image;
SubScreen->ID = Custom.settings.Type + 20;
SubScreen->GetAnime();
VolumeSize = RShiftU64(MultU64x32(Volume->BlockIO->Media->LastBlock, Volume->BlockIO->Media->BlockSize), 20);
SubScreen->AddMenuInfoLine_f("Volume size: %lldMb", VolumeSize);
SubScreen->AddMenuInfoLine_f("%ls", FileDevicePathToXStringW(Entry->DevicePath).wc_str());
if (Guid) {
SubScreen->AddMenuInfoLine_f("UUID: %s", strguid(Guid));
}
SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.ConcatAll(" "_XS8).c_str());
DBG("Create sub entries\n");
for (size_t CustomSubEntryIndex = 0 ; CustomSubEntryIndex < Custom.SubEntries.size() ; ++CustomSubEntryIndex ) {
const CUSTOM_LOADER_SUBENTRY& CustomSubEntry = Custom.SubEntries[CustomSubEntryIndex];
// if ( CustomSubEntry.settings.Settings.isEmpty() ) {
AddCustomSubEntry(Volume, CustomSubIndex++, Custom.settings.Path.notEmpty() ? Custom.settings.Path : CustomPath, Custom.settings.Type, CustomSubEntry, Custom.settings.Settings, SubScreen);
// }else{
// AddCustomSubEntry(Volume, CustomSubIndex++, CustomSubEntry.settings.Path.notEmpty() ? CustomSubEntry.settings.Path : CustomPath, CustomSubEntry, CustomSubEntry.settings.Settings, SubScreen);
// }
}
SubScreen->AddMenuEntry(&MenuEntryReturn, true);
Entry->SubScreen = SubScreen;
}
if (IsSubEntry)
SubMenu->AddMenuEntry(Entry, true);
else
// if (IsSubEntry)
// SubMenu->AddMenuEntry(Entry, true);
// else
MainMenu.AddMenuEntry(Entry, true);
DBG(" hiding entry because Custom.Hidden: %ls\n", Entry->LoaderPath.s());
Entry->Hidden = Custom.Hidden;
Entry->Hidden = Custom.settings.Hidden;
if ( Custom.settings.Hidden ) DBG(" hiding entry because Custom.settings.Hidden\n");
}
} while (FindCustomPath && Custom.Type == OSTYPE_LINEFI && Custom.KernelScan == KERNEL_SCAN_ALL); // repeat loop only for kernel scanning
} while (FindCustomPath && Custom.settings.Type == OSTYPE_LINEFI && Custom.settings.KernelScan == KERNEL_SCAN_ALL); // repeat loop only for kernel scanning
// Close the kernel boot directory
if (FindCustomPath && Custom.Type == OSTYPE_LINEFI) {
if (FindCustomPath && Custom.settings.Type == OSTYPE_LINEFI) {
DirIterClose(Iter);
}
}
@ -2185,40 +2317,44 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
// Add custom entries
void AddCustomEntries(void)
{
if (gSettings.GUI.CustomEntries.isEmpty()) return;
if (GlobalConfig.CustomEntries.isEmpty()) return;
//DBG("Custom entries start\n");
DbgHeader("AddCustomEntries");
// Traverse the custom entries
for (size_t i = 0 ; i < gSettings.GUI.CustomEntries.size(); ++i) {
CUSTOM_LOADER_ENTRY& Custom = gSettings.GUI.CustomEntries[i];
if ( Custom.Disabled ) continue; // before, disabled entries settings weren't loaded.
if ((Custom.Path.isEmpty()) && (Custom.Type != 0)) {
if (OSTYPE_IS_OSX(Custom.Type)) {
AddCustomEntry(i, MACOSX_LOADER_PATH, Custom, Custom.Settings, NULL);
} else if (OSTYPE_IS_OSX_RECOVERY(Custom.Type)) {
AddCustomEntry(i, L"\\com.apple.recovery.boot\\boot.efi"_XSW, Custom, Custom.Settings, NULL);
} else if (OSTYPE_IS_OSX_INSTALLER(Custom.Type)) {
for (size_t i = 0 ; i < GlobalConfig.CustomEntries.size(); ++i) {
CUSTOM_LOADER_ENTRY& Custom = GlobalConfig.CustomEntries[i];
DBG("- [00]: '%s'\n", Custom.settings.FullTitle.isEmpty() ? Custom.settings.Title.c_str() : Custom.settings.FullTitle.c_str() );
if ( Custom.settings.Disabled ) {
DBG(" Disabled\n");
continue; // before, disabled entries settings weren't loaded.
}
if ((Custom.settings.Path.isEmpty()) && (Custom.settings.Type != 0)) {
if (OSTYPE_IS_OSX(Custom.settings.Type)) {
AddCustomEntry(i, MACOSX_LOADER_PATH, Custom, Custom.settings.Settings, NULL);
} else if (OSTYPE_IS_OSX_RECOVERY(Custom.settings.Type)) {
AddCustomEntry(i, L"\\com.apple.recovery.boot\\boot.efi"_XSW, Custom, Custom.settings.Settings, NULL);
} else if (OSTYPE_IS_OSX_INSTALLER(Custom.settings.Type)) {
UINTN Index = 0;
while (Index < OSXInstallerPathsCount) {
AddCustomEntry(i, OSXInstallerPaths[Index++], Custom, Custom.Settings, NULL);
AddCustomEntry(i, OSXInstallerPaths[Index++], Custom, Custom.settings.Settings, NULL);
}
} else if (OSTYPE_IS_WINDOWS(Custom.Type)) {
AddCustomEntry(i, L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"_XSW, Custom, Custom.Settings, NULL);
} else if (OSTYPE_IS_LINUX(Custom.Type)) {
} else if (OSTYPE_IS_WINDOWS(Custom.settings.Type)) {
AddCustomEntry(i, L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"_XSW, Custom, Custom.settings.Settings, NULL);
} else if (OSTYPE_IS_LINUX(Custom.settings.Type)) {
#if defined(ANDX86)
for (UINTN Index = 0; Index < AndroidEntryDataCount; ++Index) {
AddCustomEntry(i, AndroidEntryData[Index].Path, Custom, Custom.Settings, NULL);
AddCustomEntry(i, AndroidEntryData[Index].Path, Custom, Custom.settings.Settings, NULL);
}
#endif
AddCustomEntry(i, NullXStringW, Custom, Custom.Settings, NULL);
} else if (Custom.Type == OSTYPE_LINEFI) {
AddCustomEntry(i, NullXStringW, Custom, Custom.Settings, NULL);
AddCustomEntry(i, NullXStringW, Custom, Custom.settings.Settings, NULL);
} else if (Custom.settings.Type == OSTYPE_LINEFI) {
AddCustomEntry(i, NullXStringW, Custom, Custom.settings.Settings, NULL);
} else {
AddCustomEntry(i, BOOT_LOADER_PATH, Custom, Custom.Settings, NULL);
AddCustomEntry(i, BOOT_LOADER_PATH, Custom, Custom.settings.Settings, NULL);
}
} else {
AddCustomEntry(i, Custom.Path, Custom, Custom.Settings, NULL);
AddCustomEntry(i, Custom.settings.Path, Custom, Custom.settings.Settings, NULL);
}
}
//DBG("Custom entries finish\n");

View File

@ -40,6 +40,7 @@
#include "../libeg/XImage.h"
#include "../refit/lib.h"
#include "../gui/REFIT_MENU_SCREEN.h"
#include "../gui/REFIT_MAINMENU_SCREEN.h"
#include "../Platform/Self.h"
#include "../Platform/Volumes.h"
#include "../libeg/XTheme.h"
@ -299,7 +300,7 @@ void AddCustomTool(void)
}
// Check the tool exists on the volume
if (!FileExists(Volume->RootDir, Custom.Path)) {
DBG("skipped because path does not exist\n");
DBG("skipped because path '%s' does not exist\n", Custom.Path.wc_str());
continue;
}
// Change to custom image if needed

View File

@ -0,0 +1,876 @@
/*
* refit/menu.c
* Menu functions
*
* Copyright (c) 2006 Christoph Pfisterer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Christoph Pfisterer nor the names of the
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "./REFIT_MAINMENU_SCREEN.h"
#include <Platform.h>
#include "../Platform/BasicIO.h"
#include "../libeg/libegint.h" //this includes platform.h
//#include "../include/scroll_images.h"
//#include "colors.h"
#include "../libeg/nanosvg.h"
#include "../libeg/FloatLib.h"
#include "../Platform/HdaCodecDump.h"
#include "REFIT_MENU_SCREEN.h"
//#include "screen.h"
#include "../cpp_foundation/XString.h"
#include "../libeg/XTheme.h"
#include "../libeg/VectorGraphics.h" // for testSVG
#include "shared_with_menu.h"
#include "../refit/menu.h" // for DrawTextXY. Must disappear soon.
#include "../Platform/AcpiPatcher.h"
#include "../Platform/Nvram.h"
#include "../refit/screen.h"
#include "../Platform/Events.h"
#include "../Platform/Self.h"
#include "../Platform/Volumes.h"
#include "../include/OSFlags.h"
#ifndef DEBUG_ALL
#define DEBUG_MENU 1
#else
#define DEBUG_MENU DEBUG_ALL
#endif
#if DEBUG_MENU == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_MENU, __VA_ARGS__)
#endif
INTN row0PosXRunning;
INTN row1PosXRunning;
INTN *itemPosX = NULL;
INTN *itemPosY = NULL;
INTN row1PosY, textPosY, FunctextPosY;
INTN OldTimeoutTextWidth = 0;
INTN EntriesWidth, EntriesHeight, EntriesGap;
INTN MaxItemOnScreen = -1;
REFIT_MAINMENU_SCREEN::REFIT_MAINMENU_SCREEN(UINTN ID, XStringW TTitle, XStringW TTimeoutText) : REFIT_MENU_SCREEN(ID, TTitle, TTimeoutText)
{
};
/**
* Draw entries for GUI.
*/
void REFIT_MAINMENU_SCREEN::DrawMainMenuLabel(IN CONST XStringW& Text, IN INTN XPos, IN INTN YPos)
{
INTN TextWidth = 0;
INTN BadgeDim = (INTN)(BADGE_DIMENSION * ThemeX.Scale);
ThemeX.MeasureText(Text, &TextWidth, NULL);
//Clear old text
ThemeX.FillRectAreaOfScreen(OldX, OldY, OldTextWidth, OldTextHeight);
if (!(ThemeX.BootCampStyle)
&& (ThemeX.HideBadges & HDBADGES_INLINE) && (!OldRow)
&& (OldTextWidth) && (OldTextWidth != TextWidth)
) {
//Clear badge
ThemeX.FillRectAreaOfScreen((OldX - (OldTextWidth >> 1) - (BadgeDim + 16)),
(OldY - ((BadgeDim - ThemeX.TextHeight) >> 1)), 128, 128);
}
DrawTextXY(Text, XPos, YPos, X_IS_CENTER);
//show inline badge
if (!(ThemeX.BootCampStyle) &&
(ThemeX.HideBadges & HDBADGES_INLINE) &&
(Entries[ScrollState.CurrentSelection].Row == 0)) {
// Display Inline Badge: small icon before the text
XImage Back(BadgeDim, BadgeDim);
INTN X = XPos - (TextWidth >> 1) - (BadgeDim + 16);
INTN Y = YPos - ((BadgeDim - ThemeX.TextHeight) >> 1);
Back.CopyRect(ThemeX.Background, X, Y);
bool free = false;
XImage *CurrSel = Entries[ScrollState.CurrentSelection].Image.GetBest(!Daylight, &free);
Back.Compose(0, 0, *CurrSel, false, BadgeDim/128.f);
Back.DrawOnBack(X, Y, Back);
if (free) {
delete CurrSel;
}
}
OldX = XPos;
OldY = YPos;
OldTextWidth = TextWidth;
OldRow = Entries[ScrollState.CurrentSelection].Row;
}
void REFIT_MENU_SCREEN::CountItems()
{
row0PosX = 0;
row1PosX = Entries.size();
// layout
row0Count = 0; //Nr items in row0
row1Count = 0;
for (INTN i = 0; i < (INTN)Entries.size(); i++) {
if (Entries[i].Row == 0) {
row0Count++;
CONSTRAIN_MIN(row0PosX, i);
} else {
row1Count++;
CONSTRAIN_MAX(row1PosX, i);
}
}
}
void REFIT_MENU_SCREEN::DrawTextCorner(UINTN TextC, UINT8 Align)
{
INTN Xpos;
// CHAR16 *Text = NULL;
XStringW Text;
if (
// HIDEUI_ALL - included
((TextC == TEXT_CORNER_REVISION) && ((ThemeX.HideUIFlags & HIDEUI_FLAG_REVISION) != 0)) ||
((TextC == TEXT_CORNER_HELP) && ((ThemeX.HideUIFlags & HIDEUI_FLAG_HELP) != 0)) ||
((TextC == TEXT_CORNER_OPTIMUS) && (gSettings.GUI.ShowOptimus == FALSE))
) {
return;
}
switch (TextC) {
case TEXT_CORNER_REVISION:
// Display Clover boot volume
if (SelfVolume->VolLabel.notEmpty() && SelfVolume->VolLabel[0] != L'#') {
Text = SWPrintf("%ls, booted from %ls %ls", gFirmwareRevision, SelfVolume->VolLabel.wc_str(), self.getCloverDirFullPath().wc_str());
}
if (Text.isEmpty()) {
Text = SWPrintf("%ls %ls %ls", gFirmwareRevision, SelfVolume->VolName.wc_str(), self.getCloverDirFullPath().wc_str());
}
break;
case TEXT_CORNER_HELP:
Text = L"F1:Help"_XSW;
break;
case TEXT_CORNER_OPTIMUS:
if (gGraphics[0].Vendor != Intel) {
Text = L"Discrete"_XSW;
} else {
Text = L"Intel"_XSW;
}
// Text = (NGFX == 2)?L"Intel":L"Discrete";
break;
default:
return;
}
switch (Align) {
case X_IS_LEFT:
Xpos = (INTN)(ThemeX.TextHeight * 0.75f);
break;
case X_IS_RIGHT:
Xpos = UGAWidth - (INTN)(ThemeX.TextHeight * 0.75f);//2
break;
case X_IS_CENTER:
Xpos = UGAWidth >> 1;
break;
default:
Text.setEmpty();
return;
}
// DBG("draw text %ls at (%d, %d)\n", Text, Xpos, UGAHeight - 5 - TextHeight),
// clovy DrawTextXY(Text, Xpos, UGAHeight - 5 - TextHeight, Align);
DrawTextXY(Text, Xpos, UGAHeight - (INTN)(ThemeX.TextHeight * 1.5f), Align);
}
void REFIT_MAINMENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN XPos, INTN YPos)
{
INTN MainSize = ThemeX.MainEntriesSize;
// XImage MainImage(MainSize, MainSize);
// XImage* BadgeImage;
XIcon MainIcon; //it can be changed here
XIcon* BadgeIcon = NULL;
if (Entry->Row == 0 && Entry->getDriveImage() && !(ThemeX.HideBadges & HDBADGES_SWAP)) {
MainIcon = *Entry->getDriveImage();
} else {
MainIcon = Entry->Image; // XIcon*
}
//this should be inited by the Theme
if (MainIcon.isEmpty()) {
// DBG(" why MainImage is empty? Report to devs\n");
if (!ThemeX.IsEmbeddedTheme()) {
MainIcon = ThemeX.GetIcon("os_mac"_XS8);
}
if (MainIcon.Image.isEmpty()) {
MainIcon.Image.DummyImage(MainSize);
MainIcon.setFilled();
}
}
// const XImage& MainImage = (!ThemeX.Daylight && !MainIcon.ImageNight.isEmpty())? MainIcon.ImageNight : MainIcon.Image;
bool free = false;
XImage *MainImage = MainIcon.GetBest(!Daylight, &free);
INTN CompWidth = (Entry->Row == 0) ? ThemeX.row0TileSize : ThemeX.row1TileSize;
INTN CompHeight = CompWidth;
// float fScale;
// if (ThemeX.TypeSVG) {
// fScale = (selected ? 1.f : -1.f);
// } else {
// fScale = ((Entry->Row == 0) ? (ThemeX.MainEntriesSize/128.f * (selected ? 1.f : -1.f)): 1.f) ;
// }
if (Entry->Row == 0) {
BadgeIcon = Entry->getBadgeImage();
}
const XImage& TopImage = ThemeX.SelectionImages[((Entry->Row == 0) ? 0 : 2) + (selected ? 0 : 1)];
// DBG(" SelectionWidth=%lld\n", TopImage.GetWidth());
if (TopImage.GetWidth() > CompWidth) {
CompWidth = TopImage.GetWidth();
CompHeight = CompWidth;
}
XImage Back(CompWidth, CompHeight);
Back.CopyRect(ThemeX.Background, XPos, YPos);
INTN OffsetX = (CompWidth - MainImage->GetWidth()) / 2;
OffsetX = (OffsetX > 0) ? OffsetX: 0;
INTN OffsetY = (CompHeight - MainImage->GetHeight()) / 2;
OffsetY = (OffsetY > 0) ? OffsetY: 0;
INTN OffsetTX = (CompWidth - TopImage.GetWidth()) / 2;
OffsetTX = (OffsetTX > 0) ? OffsetTX: 0;
INTN OffsetTY = (CompHeight - TopImage.GetHeight()) / 2;
OffsetTY = (OffsetTY > 0) ? OffsetTY: 0;
// DBG(" Comp=[%lld,%lld], offset=[%lld,%lld]\n", CompWidth, CompHeight, OffsetX, OffsetY);
float composeScale = (ThemeX.NonSelectedGrey && !selected)? -1.f: 1.f;
if(ThemeX.SelectionOnTop) {
//place main image in centre. It may be OS or Drive
Back.Compose(OffsetX, OffsetY, *MainImage, false, composeScale);
} else {
Back.Compose(OffsetTX, OffsetTY, TopImage, false); //selection first
Back.Compose(OffsetX, OffsetY, *MainImage, false, composeScale);
}
Entry->Place.XPos = XPos;
Entry->Place.YPos = YPos;
Entry->Place.Width = MainImage->GetWidth();
Entry->Place.Height = MainImage->GetHeight();
if (free) {
delete MainImage;
}
// place the badge image
float fBadgeScale = ThemeX.BadgeScale/16.f;
if ((Entry->Row == 0) && BadgeIcon && !BadgeIcon->isEmpty()) {
// const XImage& BadgeImage = (!ThemeX.Daylight && !BadgeIcon->ImageNight.isEmpty()) ? &BadgeIcon->ImageNight : BadgeImage = &BadgeIcon->Image;
free = false;
XImage* BadgeImage = BadgeIcon->GetBest(!Daylight, &free);
INTN BadgeWidth = (INTN)(BadgeImage->GetWidth() * fBadgeScale);
INTN BadgeHeight = (INTN)(BadgeImage->GetHeight() * fBadgeScale);
if ((BadgeWidth + 8) < CompWidth && (BadgeHeight + 8) < CompHeight) {
// Check for user badge x offset from theme.plist
if (ThemeX.BadgeOffsetX != 0xFFFF) {
OffsetX += ThemeX.BadgeOffsetX;
} else {
// Set default position
OffsetX += CompWidth - 8 - BadgeWidth;
}
// Check for user badge y offset from theme.plist
if (ThemeX.BadgeOffsetY != 0xFFFF) {
OffsetY += ThemeX.BadgeOffsetY;
} else {
// Set default position
OffsetY += CompHeight - 8 - BadgeHeight;
}
// DBG(" badge offset=[%lld,%lld]\n", OffsetX, OffsetY);
Back.Compose(OffsetX, OffsetY, *BadgeImage, false, fBadgeScale);
if (free) delete BadgeImage;
}
}
if(ThemeX.SelectionOnTop) {
Back.Compose(OffsetTX, OffsetTY, TopImage, false); //selection at the top
}
Back.DrawWithoutCompose(XPos, YPos);
// draw BCS indicator
// Needy: if Labels (Titles) are hidden there is no point to draw the indicator
if (ThemeX.BootCampStyle && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
// indicator is for row 0, main entries, only
if (Entry->Row == 0) {
const XImage& SelImage = ThemeX.SelectionImages[4 + (selected ? 0 : 1)];
XPos = XPos + (ThemeX.row0TileSize / 2) - (INTN)(INDICATOR_SIZE * 0.5f * ThemeX.Scale);
YPos = row0PosY + ThemeX.row0TileSize + ThemeX.TextHeight + (INTN)((BCSMargin * 2) * ThemeX.Scale);
CompWidth = (INTN)(INDICATOR_SIZE * ThemeX.Scale);
CompHeight = (INTN)(INDICATOR_SIZE * ThemeX.Scale);
Back = XImage(CompWidth, CompHeight);
Back.CopyRect(ThemeX.Background, XPos, YPos);
Back.Compose(0, 0, SelImage, false);
Back.DrawWithoutCompose(XPos, YPos);
}
}
}
/**
* Main screen text.
*/
void REFIT_MAINMENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText)
{
EFI_STATUS Status = EFI_SUCCESS;
// INTN i = 0;
INTN MessageHeight = 0;
// clovy
if (ThemeX.TypeSVG && textFace[1].valid) {
MessageHeight = (INTN)(textFace[1].size * RowHeightFromTextHeight * ThemeX.Scale);
} else {
MessageHeight = (INTN)(ThemeX.TextHeight * RowHeightFromTextHeight * ThemeX.Scale);
}
switch (Function) {
case MENU_FUNCTION_INIT:
egGetScreenSize(&UGAWidth, &UGAHeight);
InitAnime();
SwitchToGraphicsAndClear();
//BltClearScreen(FALSE);
EntriesGap = (int)(ThemeX.TileXSpace * ThemeX.Scale);
EntriesWidth = ThemeX.row0TileSize;
EntriesHeight = ThemeX.MainEntriesSize + (int)(16.f * ThemeX.Scale);
MaxItemOnScreen = (UGAWidth - (int)((ROW0_SCROLLSIZE * 2)* ThemeX.Scale)) / (EntriesWidth + EntriesGap); //8
CountItems();
InitScroll(row0Count, Entries.size(), MaxItemOnScreen, 0);
row0PosX = EntriesWidth + EntriesGap;
row0PosX = row0PosX * ((MaxItemOnScreen < row0Count)?MaxItemOnScreen:row0Count);
row0PosX = row0PosX - EntriesGap;
row0PosX = UGAWidth - row0PosX;
row0PosX = row0PosX >> 1;
row0PosY = (int)(((float)UGAHeight - ThemeX.LayoutHeight * ThemeX.Scale) * 0.5f +
ThemeX.LayoutBannerOffset * ThemeX.Scale);
row1PosX = (UGAWidth + 8 - (ThemeX.row1TileSize + (INTN)(8.0f * ThemeX.Scale)) * row1Count) >> 1;
if (ThemeX.BootCampStyle && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
row1PosY = row0PosY + ThemeX.row0TileSize + (INTN)((BCSMargin * 2) * ThemeX.Scale) + ThemeX.TextHeight +
(INTN)(INDICATOR_SIZE * ThemeX.Scale) +
(INTN)((ThemeX.LayoutButtonOffset + ThemeX.TileYSpace) * ThemeX.Scale);
} else {
row1PosY = row0PosY + EntriesHeight +
(INTN)((ThemeX.TileYSpace + ThemeX.LayoutButtonOffset) * ThemeX.Scale);
}
if (row1Count > 0) {
textPosY = row1PosY + MAX(ThemeX.row1TileSize, MessageHeight) + (INTN)((ThemeX.TileYSpace + ThemeX.LayoutTextOffset) * ThemeX.Scale);
} else {
textPosY = row1PosY;
}
if (ThemeX.BootCampStyle) {
textPosY = row0PosY + ThemeX.row0TileSize + (INTN)((TEXT_YMARGIN + BCSMargin) * ThemeX.Scale);
}
FunctextPosY = row1PosY + ThemeX.row1TileSize + (INTN)((ThemeX.TileYSpace + ThemeX.LayoutTextOffset) * ThemeX.Scale);
if (!itemPosX) {
itemPosX = (__typeof__(itemPosX))AllocatePool(sizeof(UINT64) * Entries.size());
}
row0PosXRunning = row0PosX;
row1PosXRunning = row1PosX;
//DBG("EntryCount =%d\n", Entries.size());
for (INTN i = 0; i < (INTN)Entries.size(); i++) {
if (Entries[i].Row == 0) {
itemPosX[i] = row0PosXRunning;
row0PosXRunning += EntriesWidth + EntriesGap;
} else {
itemPosX[i] = row1PosXRunning;
row1PosXRunning += ThemeX.row1TileSize + (INTN)(TILE1_XSPACING * ThemeX.Scale);
//DBG("next item in row1 at x=%d\n", row1PosXRunning);
}
}
// initial painting
// ThemeX.InitSelection(); //not needed to do here
// Update FilmPlace only if not set by InitAnime
if (FilmC->FilmPlace.Width == 0 || FilmC->FilmPlace.Height == 0) {
// CopyMem(&FilmPlace, &BannerPlace, sizeof(BannerPlace));
FilmC->FilmPlace = ThemeX.BannerPlace;
}
//DBG("main menu inited\n");
break;
case MENU_FUNCTION_CLEANUP:
FreePool(itemPosX);
itemPosX = NULL;
HidePointer();
break;
case MENU_FUNCTION_PAINT_ALL:
for (INTN i = 0; i <= ScrollState.MaxIndex; i++) {
if (Entries[i].Row == 0) {
if ((i >= ScrollState.FirstVisible) && (i <= ScrollState.LastVisible)) {
DrawMainMenuEntry(&Entries[i], (i == ScrollState.CurrentSelection)?1:0,
itemPosX[i - ScrollState.FirstVisible], row0PosY);
// draw static text for the boot options, BootCampStyle
if (ThemeX.BootCampStyle && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
INTN textPosX = itemPosX[i - ScrollState.FirstVisible] + (ThemeX.row0TileSize / 2);
// clear the screen
ThemeX.FillRectAreaOfScreen(textPosX, textPosY, EntriesWidth + ThemeX.TileXSpace,
MessageHeight);
DrawBCSText(Entries[i].Title.wc_str(), textPosX, textPosY, X_IS_CENTER);
}
}
} else {
DrawMainMenuEntry(&Entries[i], (i == ScrollState.CurrentSelection)?1:0,
itemPosX[i], row1PosY);
}
}
// clear the text from the second row, required by the BootCampStyle
if ((ThemeX.BootCampStyle) && (Entries[ScrollState.LastSelection].Row == 1)
&& (Entries[ScrollState.CurrentSelection].Row == 0) && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
ThemeX.FillRectAreaOfScreen((UGAWidth >> 1), FunctextPosY,
OldTextWidth, MessageHeight);
}
if ((Entries[ScrollState.LastSelection].Row == 0) && (Entries[ScrollState.CurrentSelection].Row == 1)
&& ThemeX.BootCampStyle && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), FunctextPosY);
}
if (!(ThemeX.BootCampStyle) && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), textPosY);
}
// DBG("draw TEXT_CORNER_HELP\n");
DrawTextCorner(TEXT_CORNER_HELP, X_IS_LEFT);
// DBG("draw TEXT_CORNER_OPTIMUS\n");
DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER);
// DBG("draw TEXT_CORNER_REVISION\n");
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT);
// DBG("MouseBirth\n");
Status = MouseBirth();
if(EFI_ERROR(Status)) {
DBG("can't bear mouse at all! Status=%s\n", efiStrError(Status));
}
break;
case MENU_FUNCTION_PAINT_SELECTION:
HidePointer();
if (Entries[ScrollState.LastSelection].Row == 0) {
DrawMainMenuEntry(&Entries[ScrollState.LastSelection], FALSE,
itemPosX[ScrollState.LastSelection - ScrollState.FirstVisible], row0PosY);
} else {
DrawMainMenuEntry(&Entries[ScrollState.LastSelection], FALSE,
itemPosX[ScrollState.LastSelection], row1PosY);
}
if (Entries[ScrollState.CurrentSelection].Row == 0) {
DrawMainMenuEntry(&Entries[ScrollState.CurrentSelection], TRUE,
itemPosX[ScrollState.CurrentSelection - ScrollState.FirstVisible], row0PosY);
} else {
DrawMainMenuEntry(&Entries[ScrollState.CurrentSelection], TRUE,
itemPosX[ScrollState.CurrentSelection], row1PosY);
}
if ((ThemeX.BootCampStyle) && (!(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL))
&& Entries[ScrollState.CurrentSelection].Row == 1) {
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), FunctextPosY);
}
if ((!(ThemeX.BootCampStyle)) && (!(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL))) {
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), textPosY);
}
DrawTextCorner(TEXT_CORNER_HELP, X_IS_LEFT);
DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER);
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT);
Status = MouseBirth();
if(EFI_ERROR(Status)) {
DBG("can't bear mouse at sel! Status=%s\n", efiStrError(Status));
}
break;
case MENU_FUNCTION_PAINT_TIMEOUT:
INTN hi = MessageHeight * ((ThemeX.HideBadges & HDBADGES_INLINE)?3:1);
HidePointer();
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)){
ThemeX.FillRectAreaOfScreen((UGAWidth >> 1), FunctextPosY + hi,
OldTimeoutTextWidth, MessageHeight);
XStringW TextX;
TextX.takeValueFrom(ParamText);
OldTimeoutTextWidth = DrawTextXY(TextX, (UGAWidth >> 1), FunctextPosY + hi, X_IS_CENTER);
}
DrawTextCorner(TEXT_CORNER_HELP, X_IS_LEFT);
DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER);
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT);
Status = MouseBirth();
if(EFI_ERROR(Status)) {
DBG("can't bear mouse at timeout! Status=%s\n", efiStrError(Status));
}
break;
}
}
void REFIT_MAINMENU_SCREEN::MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16 *ParamText)
{
// INTN i;
// INTN row0PosYRunning;
// INTN VisibleHeight = 0; //assume vertical layout
switch (Function) {
case MENU_FUNCTION_INIT:
{
egGetScreenSize(&UGAWidth, &UGAHeight); //do this when needed
InitAnime();
SwitchToGraphicsAndClear();
//BltClearScreen(FALSE);
//adjustable by theme.plist?
EntriesPosY = (int)(LAYOUT_Y_EDGE * ThemeX.Scale);
EntriesGap = (int)(ThemeX.TileYSpace * ThemeX.Scale);
EntriesWidth = ThemeX.MainEntriesSize + (int)(16 * ThemeX.Scale);
EntriesHeight = ThemeX.MainEntriesSize + (int)(16 * ThemeX.Scale);
//
INTN VisibleHeight = (UGAHeight - EntriesPosY - (int)(LAYOUT_Y_EDGE * ThemeX.Scale) + EntriesGap) / (EntriesHeight + EntriesGap);
EntriesPosX = UGAWidth - EntriesWidth - (int)((BAR_WIDTH + LAYOUT_X_EDGE) * ThemeX.Scale);
INTN MessageHeight = 20;
if (ThemeX.TypeSVG && textFace[1].valid) {
MessageHeight = (INTN)(textFace[1].size * RowHeightFromTextHeight * ThemeX.Scale);
} else {
MessageHeight = (INTN)(ThemeX.TextHeight * RowHeightFromTextHeight * ThemeX.Scale);
}
TimeoutPosY = UGAHeight - (int)(LAYOUT_Y_EDGE * ThemeX.Scale) - MessageHeight * 2; //optimus + timeout texts
CountItems();
InitScroll(row0Count, Entries.size(), VisibleHeight, 0);
row0PosX = EntriesPosX;
row0PosY = EntriesPosY;
row1PosX = (UGAWidth + EntriesGap - (ThemeX.row1TileSize + (int)(TILE1_XSPACING * ThemeX.Scale)) * row1Count) >> 1;
textPosY = TimeoutPosY - (int)(ThemeX.TileYSpace * ThemeX.Scale) - MessageHeight; //message text
row1PosY = textPosY - ThemeX.row1TileSize - (int)(ThemeX.TileYSpace * ThemeX.Scale) - ThemeX.LayoutTextOffset;
if (!itemPosX) {
itemPosX = (__typeof__(itemPosX))AllocatePool(sizeof(UINT64) * Entries.size());
itemPosY = (__typeof__(itemPosY))AllocatePool(sizeof(UINT64) * Entries.size());
}
INTN row0PosYRunning = row0PosY;
row1PosXRunning = row1PosX;
// DBG("EntryCount =%d\n", Entries.size());
for (INTN i = 0; i < (INTN)Entries.size(); i++) {
if (Entries[i].Row == 0) {
itemPosX[i] = row0PosX;
itemPosY[i] = row0PosYRunning;
row0PosYRunning += EntriesHeight + EntriesGap;
} else {
itemPosX[i] = row1PosXRunning;
itemPosY[i] = row1PosY;
row1PosXRunning += ThemeX.row1TileSize + (int)(ThemeX.TileXSpace * ThemeX.Scale);
// DBG("next item in row1 at x=%d\n", row1PosXRunning);
}
}
// Update FilmPlace only if not set by InitAnime
if (FilmC->FilmPlace.Width == 0 || FilmC->FilmPlace.Height == 0) {
FilmC->FilmPlace = ThemeX.BannerPlace;
}
ThemeX.InitBar(); //not sure
break;
}
case MENU_FUNCTION_CLEANUP:
FreePool(itemPosX);
itemPosX = NULL;
FreePool(itemPosY);
itemPosY = NULL;
HidePointer();
break;
case MENU_FUNCTION_PAINT_ALL:
SetBar(EntriesPosX + EntriesWidth + (int)(10 * ThemeX.Scale),
EntriesPosY, UGAHeight - (int)(LAYOUT_Y_EDGE * ThemeX.Scale), &ScrollState);
for (INTN i = 0; i <= ScrollState.MaxIndex; i++) {
if (Entries[i].Row == 0) {
if ((i >= ScrollState.FirstVisible) && (i <= ScrollState.LastVisible)) {
DrawMainMenuEntry(&Entries[i], (i == ScrollState.CurrentSelection)?1:0,
itemPosX[i - ScrollState.FirstVisible], itemPosY[i - ScrollState.FirstVisible]);
}
} else { //row1
DrawMainMenuEntry(&Entries[i], (i == ScrollState.CurrentSelection)?1:0,
itemPosX[i], itemPosY[i]);
}
}
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)){
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), textPosY);
}
ScrollingBar(); //&ScrollState);
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_LEFT);
DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER);
MouseBirth();
break;
case MENU_FUNCTION_PAINT_SELECTION:
HidePointer();
if (Entries[ScrollState.LastSelection].Row == 0) {
DrawMainMenuEntry(&Entries[ScrollState.LastSelection], FALSE,
itemPosX[ScrollState.LastSelection - ScrollState.FirstVisible],
itemPosY[ScrollState.LastSelection - ScrollState.FirstVisible]);
} else {
DrawMainMenuEntry(&Entries[ScrollState.LastSelection], FALSE,
itemPosX[ScrollState.LastSelection],
itemPosY[ScrollState.LastSelection]);
}
if (Entries[ScrollState.CurrentSelection].Row == 0) {
DrawMainMenuEntry(&Entries[ScrollState.CurrentSelection], TRUE,
itemPosX[ScrollState.CurrentSelection - ScrollState.FirstVisible],
itemPosY[ScrollState.CurrentSelection - ScrollState.FirstVisible]);
} else {
DrawMainMenuEntry(&Entries[ScrollState.CurrentSelection], TRUE,
itemPosX[ScrollState.CurrentSelection],
itemPosY[ScrollState.CurrentSelection]);
}
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title,
(UGAWidth >> 1), textPosY);
}
ScrollingBar(); //&ScrollState);
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_LEFT);
DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER);
MouseBirth();
break;
case MENU_FUNCTION_PAINT_TIMEOUT:
INTN MessageHeight = 20;
if (ThemeX.TypeSVG && textFace[1].valid) {
MessageHeight = (INTN)(textFace[1].size * RowHeightFromTextHeight * ThemeX.Scale);
} else {
MessageHeight = (INTN)(ThemeX.TextHeight * RowHeightFromTextHeight * ThemeX.Scale);
}
INTN hi = MessageHeight * ((ThemeX.HideBadges & HDBADGES_INLINE)?3:1);
HidePointer();
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
ThemeX.FillRectAreaOfScreen((UGAWidth >> 1), textPosY + hi,
OldTimeoutTextWidth, ThemeX.TextHeight);
XStringW TextX;
TextX.takeValueFrom(ParamText);
OldTimeoutTextWidth = DrawTextXY(TextX, (UGAWidth >> 1), textPosY + hi, X_IS_CENTER);
}
DrawTextCorner(TEXT_CORNER_REVISION, X_IS_LEFT);
break;
}
}
UINTN REFIT_MAINMENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
{
// MENU_STYLE_FUNC Style = &REFIT_MENU_SCREEN::TextMenuStyle;
// MENU_STYLE_FUNC MainStyle = &REFIT_MENU_SCREEN::TextMenuStyle;
REFIT_ABSTRACT_MENU_ENTRY *TempChosenEntry = 0;
REFIT_ABSTRACT_MENU_ENTRY *MainChosenEntry = 0;
REFIT_ABSTRACT_MENU_ENTRY *NextChosenEntry = NULL;
UINTN MenuExit = 0, SubMenuExit = 0;
INTN DefaultEntryIndex = DefaultSelection;
INTN SubMenuIndex;
// initialize static variables when menu runs so that values from previos sessions won't be used
OldX = 0;
OldY = 0;
OldTextWidth = 0;
OldTextHeight = 0;
OldRow = 0;
OldTimeoutTextWidth = 0;
if (AllowGraphicsMode) {
// Style = &REFIT_MENU_SCREEN::GraphicsMenuStyle;
if (ThemeX.VerticalLayout) {
m_MainStyle = &REFIT_MAINMENU_SCREEN::MainMenuVerticalStyle;
} else {
m_MainStyle = &REFIT_MAINMENU_SCREEN::MainMenuStyle;
}
}else{
m_MainStyle = &REFIT_MAINMENU_SCREEN::TextMenuStyle;
}
while (!MenuExit) {
GetAnime();
DBG("AnimeRun=%d\n", (FilmC && FilmC->AnimeRun)?1:0);
MenuExit = RunGenericMenu(&DefaultEntryIndex, &MainChosenEntry);
TimeoutSeconds = 0;
if (MenuExit == MENU_EXIT_DETAILS && MainChosenEntry->SubScreen != NULL) {
XString8Array TmpArgs;
if ( gSettings.Boot.BootArgs.length() > 0) {
TmpArgs = Split<XString8Array>(gSettings.Boot.BootArgs, " ");
}
SubMenuIndex = -1;
gSettings.OptionsBits = EncodeOptions(TmpArgs);
// DBG("main OptionsBits = 0x%X\n", gSettings.OptionsBits);
if (MainChosenEntry->getLOADER_ENTRY()) {
gSettings.OptionsBits |= EncodeOptions(MainChosenEntry->getLOADER_ENTRY()->LoadOptions);
// DBG("add OptionsBits = 0x%X\n", gSettings.OptionsBits);
}
if (MainChosenEntry->getREFIT_MENU_ITEM_BOOTNUM()) {
DecodeOptions(MainChosenEntry->getREFIT_MENU_ITEM_BOOTNUM());
}
// DBG(" enter menu with LoadOptions: %ls\n", ((LOADER_ENTRY*)MainChosenEntry)->LoadOptions);
if (MainChosenEntry->getLOADER_ENTRY()) {
// Only for non-legacy entries, as LEGACY_ENTRY doesn't have Flags
gSettings.FlagsBits = MainChosenEntry->getLOADER_ENTRY()->Flags;
}
// DBG(" MainChosenEntry with FlagsBits = 0x%X\n", gSettings.FlagsBits);
SubMenuExit = 0;
while (!SubMenuExit) {
//
//running details menu
//
SubMenuExit = MainChosenEntry->SubScreen->RunGenericMenu(&SubMenuIndex, &TempChosenEntry);
if (SubMenuExit == MENU_EXIT_ESCAPE || TempChosenEntry->getREFIT_MENU_ITEM_RETURN() ) {
SubMenuExit = MENU_EXIT_ENTER;
MenuExit = 0;
break;
}
if (MainChosenEntry->getREFIT_MENU_ENTRY_CLOVER()) {
MainChosenEntry->getREFIT_MENU_ENTRY_CLOVER()->LoadOptions = (((REFIT_MENU_ENTRY_CLOVER*)TempChosenEntry)->LoadOptions);
}
if (SubMenuExit == MENU_EXIT_DETAILS) {
SubMenuExit = 0;
continue;
}
// DBG(" exit menu with LoadOptions: %ls\n", ((LOADER_ENTRY*)MainChosenEntry)->LoadOptions);
if (SubMenuExit == MENU_EXIT_ENTER && MainChosenEntry->getLOADER_ENTRY() && TempChosenEntry->getLOADER_ENTRY()) {
// Only for non-legacy entries, as LEGACY_ENTRY doesn't have Flags/Options
MainChosenEntry->getLOADER_ENTRY()->Flags = TempChosenEntry->getLOADER_ENTRY()->Flags;
DBG(" get MainChosenEntry FlagsBits = 0x%X\n", ((LOADER_ENTRY*)MainChosenEntry)->Flags);
if (OSFLAG_ISUNSET(TempChosenEntry->getLOADER_ENTRY()->Flags, OSFLAG_NODEFAULTARGS)) {
DecodeOptions(TempChosenEntry->getLOADER_ENTRY());
// DBG("get OptionsBits = 0x%X\n", gSettings.OptionsBits);
// DBG(" TempChosenEntry FlagsBits = 0x%X\n", ((LOADER_ENTRY*)TempChosenEntry)->Flags);
}
// copy also loadoptions from subentry to mainentry
MainChosenEntry->getLOADER_ENTRY()->LoadOptions = TempChosenEntry->getLOADER_ENTRY()->LoadOptions;
}
if (/*MenuExit == MENU_EXIT_ENTER &&*/ TempChosenEntry->getLOADER_ENTRY()) {
if (TempChosenEntry->getLOADER_ENTRY()->LoadOptions.notEmpty()) {
gSettings.Boot.BootArgs = TempChosenEntry->getLOADER_ENTRY()->LoadOptions.ConcatAll(" "_XS8);
} else {
gSettings.Boot.BootArgs.setEmpty();
}
DBG(" boot with args: %s\n", gSettings.Boot.BootArgs.c_str());
}
//---- Details submenu (kexts disabling etc)
if (SubMenuExit == MENU_EXIT_ENTER /*|| MenuExit == MENU_EXIT_DETAILS*/) {
if (TempChosenEntry->SubScreen != NULL) {
UINTN NextMenuExit = 0;
INTN NextEntryIndex = -1;
while (!NextMenuExit) {
//
// running submenu
//
NextMenuExit = TempChosenEntry->SubScreen->RunGenericMenu(&NextEntryIndex, &NextChosenEntry);
if (NextMenuExit == MENU_EXIT_ESCAPE || NextChosenEntry->getREFIT_MENU_ITEM_RETURN() ) {
SubMenuExit = 0;
NextMenuExit = MENU_EXIT_ENTER;
break;
}
DBG(" get NextChosenEntry FlagsBits = 0x%X\n", ((LOADER_ENTRY*)NextChosenEntry)->Flags);
//---- Details submenu (kexts disabling etc) second level
if (NextMenuExit == MENU_EXIT_ENTER /*|| MenuExit == MENU_EXIT_DETAILS*/) {
if (NextChosenEntry->SubScreen != NULL) {
UINTN DeepMenuExit = 0;
INTN DeepEntryIndex = -1;
REFIT_ABSTRACT_MENU_ENTRY *DeepChosenEntry = NULL;
while (!DeepMenuExit) {
//
// run deep submenu
//
DeepMenuExit = NextChosenEntry->SubScreen->RunGenericMenu(&DeepEntryIndex, &DeepChosenEntry);
if (DeepMenuExit == MENU_EXIT_ESCAPE || DeepChosenEntry->getREFIT_MENU_ITEM_RETURN() ) {
DeepMenuExit = MENU_EXIT_ENTER;
NextMenuExit = 0;
break;
}
DBG(" get DeepChosenEntry FlagsBits = 0x%X\n", ((LOADER_ENTRY*)DeepChosenEntry)->Flags);
} //while(!DeepMenuExit)
}
}
} //while(!NextMenuExit)
}
}
//---------
}
}
}
if (ChosenEntry) {
*ChosenEntry = MainChosenEntry;
}
return MenuExit;
}

View File

@ -0,0 +1,86 @@
/*
*
* Copyright (c) 2020 Jief
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Christoph Pfisterer nor the names of the
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __REFIT_MAINMENU_SCREEN_H__
#define __REFIT_MAINMENU_SCREEN_H__
#include "REFIT_MENU_SCREEN.h"
//#include "../Platform/Settings.h"
//#include "../libeg/libegint.h"
////#include "../libeg/libeg.h"
//#include "../refit/lib.h"
//
//
//#include "../cpp_foundation/XObjArray.h"
//#include "../cpp_foundation/XString.h"
//#include "../cpp_foundation/XStringArray.h"
//#include "../libeg/XPointer.h"
//#include "../libeg/XCinema.h"
//#include "menu_items/menu_items.h"
//
//
//#ifdef _MSC_VER
//#define __attribute__(x)
//#endif
class REFIT_MAINMENU_SCREEN : public REFIT_MENU_SCREEN
{
public:
typedef void (REFIT_MAINMENU_SCREEN::*MAINMENU_STYLE_FUNC)(IN UINTN Function, IN CONST CHAR16 *ParamText);
MAINMENU_STYLE_FUNC m_MainStyle = NULL;
REFIT_MAINMENU_SCREEN(UINTN ID, XStringW TTitle, XStringW TTimeoutText);
UINTN RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
virtual void TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText) { REFIT_MENU_SCREEN::TextMenuStyle(Function, ParamText); }
virtual void MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText); // cannot remove from here because the use of pointer to member function
virtual void MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16 *ParamText); // cannot remove from here because the use of pointer to member function
void DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN XPos, INTN YPos);
void DrawMainMenuLabel(IN CONST XStringW& Text, IN INTN XPos, IN INTN YPos);
virtual void call_MENU_FUNCTION_INIT(IN CONST CHAR16 *ParamText) { ((*this).*(m_MainStyle))(MENU_FUNCTION_INIT, ParamText); }
virtual void call_MENU_FUNCTION_PAINT_ALL(IN CONST CHAR16 *ParamText) { ((*this).*(m_MainStyle))(MENU_FUNCTION_PAINT_ALL, ParamText); }
virtual void call_MENU_FUNCTION_PAINT_SELECTION(IN CONST CHAR16 *ParamText) { ((*this).*(m_MainStyle))(MENU_FUNCTION_PAINT_SELECTION, ParamText); }
virtual void call_MENU_FUNCTION_PAINT_TIMEOUT(IN CONST CHAR16 *ParamText) { ((*this).*(m_MainStyle))(MENU_FUNCTION_PAINT_TIMEOUT, ParamText); }
virtual void call_MENU_FUNCTION_CLEANUP(IN CONST CHAR16 *ParamText) { ((*this).*(m_MainStyle))(MENU_FUNCTION_CLEANUP, ParamText); }
};
#endif
/*
EOF */

File diff suppressed because it is too large Load Diff

View File

@ -54,6 +54,38 @@
#define __attribute__(x)
#endif
#define SCROLL_LINE_UP (0)
#define SCROLL_LINE_DOWN (1)
#define SCROLL_PAGE_UP (2)
#define SCROLL_PAGE_DOWN (3)
#define SCROLL_FIRST (4)
#define SCROLL_LAST (5)
#define SCROLL_NONE (6)
#define SCROLL_SCROLL_DOWN (7)
#define SCROLL_SCROLL_UP (8)
#define SCROLL_SCROLLBAR_MOVE (9)
//
#define TEXT_CORNER_REVISION (1)
#define TEXT_CORNER_HELP (2)
#define TEXT_CORNER_OPTIMUS (3)
//
#define TITLE_MAX_LEN (SVALUE_MAX_SIZE / sizeof(CHAR16) + 128)
//TODO spacing must be a part of layout in XTheme
#define TITLEICON_SPACING (16)
//#define ROW0__TILESIZE (144)
//#define ROW1_TILESIZE (64)
#define TILE1_XSPACING (8)
//#define TILE_YSPACING (24)
#define ROW0_SCROLLSIZE (100)
#define MENU_FUNCTION_INIT (0)
#define MENU_FUNCTION_CLEANUP (1)
#define MENU_FUNCTION_PAINT_ALL (2)
#define MENU_FUNCTION_PAINT_SELECTION (3)
#define MENU_FUNCTION_PAINT_TIMEOUT (4)
//some unreal values
#define FILM_CENTRE 40000
//#define FILM_LEFT 50000
@ -63,6 +95,24 @@
//#define FILM_PERCENT 100000
#define INITVALUE 40000
#define CONSTRAIN_MIN(Variable, MinValue) if (Variable < MinValue) Variable = MinValue
#define CONSTRAIN_MAX(Variable, MaxValue) if (Variable > MaxValue) Variable = MaxValue
extern INTN row0Count, row0PosX;
extern INTN row1Count, row1PosX;
extern INTN row0PosY;
extern INTN OldX, OldY;
extern INTN OldTextWidth, OldTextHeight;
extern UINTN OldRow;
extern INTN MenuWidth , TimeoutPosY;
extern UINTN MenuMaxTextLen;
extern INTN EntriesPosX, EntriesPosY;
class REFIT_MENU_ENTRY_ITEM_ABSTRACT;
class REFIT_MENU_ENTRY;
class REFIT_ABSTRACT_MENU_ENTRY;
@ -271,52 +321,48 @@ class REFIT_MENU_SCREEN
public:
static XPointer mPointer;
// XPointer mPointer;
UINTN ID;
XStringW Title;
XIcon TitleImage;
XStringWArray InfoLines;
UINTN ID = 0;
XStringW Title = XStringW();
XIcon TitleImage = XIcon();
XStringWArray InfoLines = XStringWArray();
EntryArray Entries;
EntryArray Entries = EntryArray();
INTN TimeoutSeconds;
bool Daylight;
XStringW TimeoutText;
XStringW ThemeName; //?
EG_RECT OldTextBufferRect;
XImage OldTextBufferImage;
BOOLEAN isBootScreen;
FILM *FilmC;
INTN TimeoutSeconds = 0;
bool Daylight = true;
XStringW TimeoutText = XStringW();
XStringW ThemeName = XStringW(); //?
EG_RECT OldTextBufferRect = EG_RECT();
XImage OldTextBufferImage = XImage();
BOOLEAN isBootScreen = 0;
FILM *FilmC = 0;
ACTION mAction;
UINTN mItemID;
SCROLL_STATE ScrollState;
BOOLEAN ScrollEnabled;
INTN TextStyle;
BOOLEAN IsDragging;
ACTION mAction = ActionNone;
UINTN mItemID = 0;
SCROLL_STATE ScrollState = {0,0,0,0,0,0,0,0,0,0,0};
BOOLEAN ScrollEnabled = 0;
INTN TextStyle = 0;
BOOLEAN IsDragging = 0;
//TODO scroll positions should depends on REFIT_SCREEN?
// Or it just currently calculated to be global variables?
EG_RECT BarStart;
EG_RECT BarEnd;
EG_RECT ScrollStart;
EG_RECT ScrollEnd;
EG_RECT ScrollTotal;
EG_RECT UpButton;
EG_RECT DownButton;
EG_RECT ScrollbarBackground;
EG_RECT Scrollbar;
EG_RECT ScrollbarOldPointerPlace;
EG_RECT ScrollbarNewPointerPlace;
EG_RECT BarStart = EG_RECT();
EG_RECT BarEnd = EG_RECT();
EG_RECT ScrollStart = EG_RECT();
EG_RECT ScrollEnd = EG_RECT();
EG_RECT ScrollTotal = EG_RECT();
EG_RECT UpButton = EG_RECT();
EG_RECT DownButton = EG_RECT();
EG_RECT ScrollbarBackground = EG_RECT();
EG_RECT Scrollbar = EG_RECT();
EG_RECT ScrollbarOldPointerPlace = EG_RECT();
EG_RECT ScrollbarNewPointerPlace = EG_RECT();
REFIT_MENU_SCREEN()
: ID(0), Title(), TitleImage(), InfoLines(), Entries(),
TimeoutSeconds(0), Daylight(true), TimeoutText(), ThemeName(),
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false), FilmC(),
mAction(ActionNone), mItemID(0), ScrollState{0,0,0,0,0,0,0,0,0,0,0}, ScrollEnabled(0), TextStyle(0), IsDragging(0),
BarStart(), BarEnd(), ScrollStart(), ScrollEnd(), ScrollTotal(), UpButton(), DownButton(), ScrollbarBackground(), Scrollbar(), ScrollbarOldPointerPlace(), ScrollbarNewPointerPlace()
{
void common_init() {
if (AllowGraphicsMode) m_StyleFunc = &REFIT_MENU_SCREEN::GraphicsMenuStyle;
else m_StyleFunc = &REFIT_MENU_SCREEN::TextMenuStyle;
#ifdef CLOVER_BUILD
EFI_TIME Now;
gRT->GetTime(&Now, NULL);
if (gSettings.GUI.Timezone != 0xFF) {
@ -327,35 +373,27 @@ public:
} else {
Daylight = true;
}
#endif
}
REFIT_MENU_SCREEN()
{
common_init();
};
REFIT_MENU_SCREEN(UINTN ID, XStringW TTitle, XStringW TTimeoutText)
: ID(ID), Title(TTitle), TitleImage(), InfoLines(), Entries(),
TimeoutSeconds(0), Daylight(true), TimeoutText(TTimeoutText), ThemeName(),
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false), FilmC(),
mAction(ActionNone), mItemID(0), ScrollState{0,0,0,0,0,0,0,0,0,0,0}, ScrollEnabled(0), TextStyle(0), IsDragging(0),
BarStart(), BarEnd(), ScrollStart(), ScrollEnd(), ScrollTotal(), UpButton(), DownButton(), ScrollbarBackground(), Scrollbar(), ScrollbarOldPointerPlace(), ScrollbarNewPointerPlace()
{};
REFIT_MENU_SCREEN(UINTN ID, XStringW TTitle, XStringW TTimeoutText) : ID(ID), Title(TTitle), TimeoutText(TTimeoutText) { common_init(); };
//TODO exclude CHAR16
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* TitleC, CONST CHAR16* TimeoutTextC)
: ID(ID), Title(), TitleImage(), InfoLines(), Entries(),
TimeoutSeconds(0), Daylight(true), TimeoutText(), ThemeName(),
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false), FilmC(),
mAction(ActionNone), mItemID(0), ScrollState{0,0,0,0,0,0,0,0,0,0,0}, ScrollEnabled(0), TextStyle(0), IsDragging(0),
BarStart(), BarEnd(), ScrollStart(), ScrollEnd(), ScrollTotal(), UpButton(), DownButton(), ScrollbarBackground(), Scrollbar(), ScrollbarOldPointerPlace(), ScrollbarNewPointerPlace()
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* TitleC, CONST CHAR16* TimeoutTextC) : ID(ID)
{
common_init();
Title.takeValueFrom(TitleC);
TimeoutText.takeValueFrom(TimeoutTextC);
};
REFIT_MENU_SCREEN(UINTN ID, XStringW TTitle, XStringW TTimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
: ID(ID), Title(TTitle), TitleImage(), InfoLines(), Entries(),
TimeoutSeconds(0), Daylight(true), TimeoutText(TTimeoutText), ThemeName(),
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false), FilmC(),
mAction(ActionNone), mItemID(0), ScrollState{0,0,0,0,0,0,0,0,0,0,0}, ScrollEnabled(0), TextStyle(0), IsDragging(0),
BarStart(), BarEnd(), ScrollStart(), ScrollEnd(), ScrollTotal(), UpButton(), DownButton(), ScrollbarBackground(), Scrollbar(), ScrollbarOldPointerPlace(), ScrollbarNewPointerPlace()
REFIT_MENU_SCREEN(UINTN ID, XStringW TTitle, XStringW TTimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2) : ID(ID), Title(TTitle), TimeoutText(TTimeoutText)
{
common_init();
Entries.AddReference(entry1, false);
Entries.AddReference(entry2, false);
};
@ -389,14 +427,11 @@ public:
void AddMenuItemInput(INTN Inx, CONST CHAR8 *Title, BOOLEAN Cursor);
void FreeMenu();
INTN FindMenuShortcutEntry(IN CHAR16 Shortcut);
UINTN RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INTN *DefaultEntryIndex, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
UINTN RunGenericMenu(IN OUT INTN *DefaultEntryIndex, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
UINTN RunMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
UINTN RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
UINTN InputDialog(IN MENU_STYLE_FUNC StyleFunc);
UINTN InputDialog();
void DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN XPos, INTN YPos);
void DrawMainMenuLabel(IN CONST XStringW& Text, IN INTN XPos, IN INTN YPos);
INTN DrawTextXY(IN CONST XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
void EraseTextXY();
void DrawTextCorner(UINTN TextC, UINT8 Align);
@ -409,14 +444,21 @@ public:
//Style functions
virtual void MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
virtual void MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
virtual void GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
virtual void TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
MENU_STYLE_FUNC m_StyleFunc = NULL;
virtual void call_MENU_FUNCTION_INIT(IN CONST CHAR16 *ParamText) { ((*this).*(m_StyleFunc))(MENU_FUNCTION_INIT, ParamText); }
virtual void call_MENU_FUNCTION_PAINT_ALL(IN CONST CHAR16 *ParamText) { ((*this).*(m_StyleFunc))(MENU_FUNCTION_PAINT_ALL, ParamText); }
virtual void call_MENU_FUNCTION_PAINT_SELECTION(IN CONST CHAR16 *ParamText) { ((*this).*(m_StyleFunc))(MENU_FUNCTION_PAINT_SELECTION, ParamText); }
virtual void call_MENU_FUNCTION_PAINT_TIMEOUT(IN CONST CHAR16 *ParamText) { ((*this).*(m_StyleFunc))(MENU_FUNCTION_PAINT_TIMEOUT, ParamText); }
virtual void call_MENU_FUNCTION_CLEANUP(IN CONST CHAR16 *ParamText) { ((*this).*(m_StyleFunc))(MENU_FUNCTION_CLEANUP, ParamText); }
virtual ~REFIT_MENU_SCREEN() {};
};
#endif
/*

View File

@ -104,18 +104,18 @@ class SIDELOAD_KEXT;
class REFIT_ABSTRACT_MENU_ENTRY
{
public:
XStringW Title;
bool Hidden;
UINTN Row;
CHAR16 ShortcutDigit;
CHAR16 ShortcutLetter;
XIcon Image;
EG_RECT Place;
ACTION AtClick;
ACTION AtDoubleClick;
ACTION AtRightClick;
ACTION AtMouseOver;
REFIT_MENU_SCREEN *SubScreen;
XStringW Title = XStringW();
bool Hidden = 0;
UINTN Row = 0;
CHAR16 ShortcutDigit = 0;
CHAR16 ShortcutLetter = 0;
XIcon Image = 0;
EG_RECT Place = EG_RECT();
ACTION AtClick = ActionNone;
ACTION AtDoubleClick = ActionNone;
ACTION AtRightClick = ActionNone;
ACTION AtMouseOver = ActionNone;
REFIT_MENU_SCREEN *SubScreen = NULL;
virtual XIcon* getDriveImage() { return nullptr; };
virtual XIcon* getBadgeImage() { return nullptr; };
@ -142,30 +142,13 @@ class REFIT_ABSTRACT_MENU_ENTRY
virtual void StartLegacy() {};
virtual void StartTool() {};
REFIT_ABSTRACT_MENU_ENTRY()
: 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_), 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_), 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_), 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_,
// EG_RECT Place_, ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_,
// REFIT_MENU_SCREEN *SubScreen_)
// : Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_),
// Image(Icon_), Place(Place_),
// AtClick(AtClick_), AtDoubleClick(AtDoubleClick_), AtRightClick(AtRightClick_), AtMouseOver(AtMouseOver_),
// SubScreen(SubScreen_)
// {};
REFIT_ABSTRACT_MENU_ENTRY() {};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_) : Title(Title_) {};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, ACTION AtClick_) : Title(Title_), AtClick(AtClick_) {};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_) : Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_), AtClick(AtClick_) {};
REFIT_ABSTRACT_MENU_ENTRY(const REFIT_ABSTRACT_MENU_ENTRY&) = delete;
REFIT_ABSTRACT_MENU_ENTRY& operator=(const REFIT_ABSTRACT_MENU_ENTRY&) = delete;
REFIT_ABSTRACT_MENU_ENTRY(const REFIT_ABSTRACT_MENU_ENTRY&) { panic("not yet defined"); }
REFIT_ABSTRACT_MENU_ENTRY& operator=(const REFIT_ABSTRACT_MENU_ENTRY&) { panic("not yet defined"); }
virtual ~REFIT_ABSTRACT_MENU_ENTRY() {}; // virtual destructor : this is vital
};
@ -441,8 +424,8 @@ class REFIT_ABSTRACT_MENU_ENTRY
UINTN searchProc(const XString8& procedure);
UINTN searchProcInDriver(UINT8 * driver, UINT32 driverLen, const XString8& procedure);
UINT32 searchSectionByNum(UINT8 * Binary, UINT32 Num);
void KernelAndKextsPatcherStart();
void KernelAndKextPatcherInit();
// void KernelAndKextsPatcherStart();
// void KernelAndKextPatcherInit();
BOOLEAN KernelUserPatch();
BOOLEAN KernelPatchPm();
BOOLEAN KernelLapicPatch_32();

View File

@ -16,8 +16,8 @@
#define OSFLAG_UNSET(flags, flag) (flags & (~flag))
#define OSFLAG_TOGGLE(flags, flag) (flags ^ flag)
#define OSFLAG_USEGRAPHICS (1 << 0)
#define OSFLAG_WITHKEXTS (1 << 1)
#define OSFLAG_CHECKFAKESMC (1 << 2)
//#define OSFLAG_WITHKEXTS (1 << 1) // Jief not used, maybe sincee OC integration
//#define OSFLAG_CHECKFAKESMC (1 << 2) // Jief : not used since 4202, I think
#define OSFLAG_NOCACHES (1 << 3)
#define OSFLAG_NODEFAULTARGS (1 << 4)
#define OSFLAG_NODEFAULTMENU (1 << 5)

View File

@ -85,6 +85,8 @@
gui/menu_items/menu_globals.h
gui/REFIT_MENU_SCREEN.cpp
gui/REFIT_MENU_SCREEN.h
gui/REFIT_MAINMENU_SCREEN.cpp
gui/REFIT_MAINMENU_SCREEN.h
gui/shared_with_menu.cpp
gui/shared_with_menu.h
libeg/egemb_icons.cpp

View File

@ -72,6 +72,7 @@
#include "../Platform/kext_inject.h"
#include "../Platform/KextList.h"
#include "../gui/REFIT_MENU_SCREEN.h"
#include "../gui/REFIT_MAINMENU_SCREEN.h"
#include "../Platform/Self.h"
#include "../Platform/SelfOem.h"
#include "../Platform/Net.h"
@ -1190,6 +1191,10 @@ void LOADER_ENTRY::StartLoader()
0,
&ImageHandle
);
if ( EFI_ERROR(Status) ) {
DBG("LoadImage at '%ls' failed. Status = %s\n", DevicePathAsString.wc_str(), efiStrError(Status));
return;
}
}else
{
// NOTE : OpenCore ignore the name of the dmg.
@ -1230,8 +1235,11 @@ void LOADER_ENTRY::StartLoader()
0,
&ImageHandle
);
if ( EFI_ERROR(Status) ) {
DBG("LoadImage at '%ls' failed. Status = %s\n", DevicePathToXStringW(BootEfiFromDmgDevicePath).wc_str(), efiStrError(Status));
return;
}
}
if ( EFI_ERROR(Status) ) return; // TODO message ?
EFI_STATUS OptionalStatus = gBS->HandleProtocol (
ImageHandle,
@ -2590,7 +2598,7 @@ void afterGetUserSettings(const SETTINGS_DATA& gSettings)
// Whether or not to draw boot screen
GlobalConfig.CustomLogoType = gSettings.Boot.CustomLogoType;
if ( gSettings.Boot.CustomLogoAsXString8.notEmpty() ) {
if ( gSettings.Boot.CustomLogoType == CUSTOM_BOOT_USER && gSettings.Boot.CustomLogoAsXString8.notEmpty() ) {
if (GlobalConfig.CustomLogo != NULL) {
delete GlobalConfig.CustomLogo;
}
@ -2600,7 +2608,7 @@ void afterGetUserSettings(const SETTINGS_DATA& gSettings)
DBG("Custom boot logo not found at path '%s'!\n", gSettings.Boot.CustomLogoAsXString8.c_str());
GlobalConfig.CustomLogoType = CUSTOM_BOOT_DISABLED;
}
} else if ( gSettings.Boot.CustomLogoAsData.notEmpty() ) {
} else if ( gSettings.Boot.CustomLogoType == CUSTOM_BOOT_USER && gSettings.Boot.CustomLogoAsData.notEmpty() ) {
if (GlobalConfig.CustomLogo != NULL) {
delete GlobalConfig.CustomLogo;
}
@ -2627,6 +2635,12 @@ void afterGetUserSettings(const SETTINGS_DATA& gSettings)
}
ThemeX.DarkEmbedded = gSettings.GUI.DarkEmbedded;
for ( size_t idx = 0 ; idx < gSettings.GUI.CustomEntriesSettings.size() ; ++idx ) {
const CUSTOM_LOADER_ENTRY_SETTINGS& CustomEntrySettings = gSettings.GUI.CustomEntriesSettings[idx];
CUSTOM_LOADER_ENTRY* entry = new CUSTOM_LOADER_ENTRY(CustomEntrySettings);
GlobalConfig.CustomEntries.AddReference(entry, true);
}
}
#pragma GCC diagnostic pop

View File

@ -60,6 +60,7 @@
#include "../Platform/Injectors.h"
#include "../Platform/KextList.h"
#include "../gui/REFIT_MENU_SCREEN.h"
#include "../gui/REFIT_MAINMENU_SCREEN.h"
#include "../Platform/Self.h"
#include "../Platform/VersionString.h"
@ -119,7 +120,7 @@ REFIT_MENU_ITEM_RESET MenuEntryReset (L"Restart Computer"_XSW, 1, 0, 'R', A
REFIT_MENU_ITEM_SHUTDOWN MenuEntryShutdown(L"Exit Clover"_XSW, 1, 0, 'U', ActionSelect);
REFIT_MENU_ITEM_RETURN MenuEntryReturn (L"Return"_XSW, 0, 0, 0, ActionEnter);
REFIT_MENU_SCREEN MainMenu(1, L"Main Menu"_XSW, L"Automatic boot"_XSW);
REFIT_MAINMENU_SCREEN MainMenu(1, L"Main Menu"_XSW, L"Automatic boot"_XSW);
REFIT_MENU_SCREEN AboutMenu(2, L"About"_XSW, L""_XSW);
REFIT_MENU_SCREEN HelpMenu(3, L"Help"_XSW, L""_XSW);
REFIT_MENU_SCREEN OptionMenu(4, L"Options"_XSW, L""_XSW);
@ -1523,11 +1524,6 @@ void HelpRefit(void)
[2] checkbox
[3] checkbox_checked
*/
//
// Scrolling functions
//
#define CONSTRAIN_MIN(Variable, MinValue) if (Variable < MinValue) Variable = MinValue
#define CONSTRAIN_MAX(Variable, MaxValue) if (Variable > MaxValue) Variable = MaxValue
//
@ -2501,7 +2497,7 @@ void OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
UINTN NextMenuExit;
//CHAR16* Flags;
MENU_STYLE_FUNC Style = &REFIT_MENU_SCREEN::TextMenuStyle;
// MENU_STYLE_FUNC Style = &REFIT_MENU_SCREEN::TextMenuStyle;
INTN EntryIndex = 0;
INTN SubEntryIndex = -1; //value -1 means old position to remember
@ -2510,9 +2506,9 @@ void OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
BOOLEAN OldFontStyle = ThemeX.Proportional;
ThemeX.Proportional = FALSE; //temporary disable proportional
if (AllowGraphicsMode) {
Style = &REFIT_MENU_SCREEN::GraphicsMenuStyle;
}
// if (AllowGraphicsMode) {
// Style = &REFIT_MENU_SCREEN::GraphicsMenuStyle;
// }
// remember, if you extended this menu then change procedures
// FillInputs and ApplyInputs
@ -2553,7 +2549,7 @@ void OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
}
while (!MenuExit) {
MenuExit = OptionMenu.RunGenericMenu(Style, &EntryIndex, ChosenEntry);
MenuExit = OptionMenu.RunGenericMenu(&EntryIndex, ChosenEntry);
if (MenuExit == MENU_EXIT_ESCAPE || (*ChosenEntry)->getREFIT_MENU_ITEM_RETURN())
break;
if (MenuExit == MENU_EXIT_ENTER || MenuExit == MENU_EXIT_DETAILS) {
@ -2561,7 +2557,7 @@ void OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
if ((*ChosenEntry)->SubScreen != NULL) {
SubMenuExit = 0;
while (!SubMenuExit) {
SubMenuExit = (*ChosenEntry)->SubScreen->RunGenericMenu(Style, &SubEntryIndex, &TmpChosenEntry);
SubMenuExit = (*ChosenEntry)->SubScreen->RunGenericMenu(&SubEntryIndex, &TmpChosenEntry);
if (SubMenuExit == MENU_EXIT_ESCAPE || TmpChosenEntry->getREFIT_MENU_ITEM_RETURN() ){
ApplyInputs();
ModifyTitles(*ChosenEntry);
@ -2571,7 +2567,7 @@ void OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
if (TmpChosenEntry->SubScreen != NULL) {
NextMenuExit = 0;
while (!NextMenuExit) {
NextMenuExit = TmpChosenEntry->SubScreen->RunGenericMenu(Style, &NextEntryIndex, &NextChosenEntry);
NextMenuExit = TmpChosenEntry->SubScreen->RunGenericMenu(&NextEntryIndex, &NextChosenEntry);
if (NextMenuExit == MENU_EXIT_ESCAPE || NextChosenEntry->getREFIT_MENU_ITEM_RETURN() ){
ApplyInputs();
ModifyTitles(TmpChosenEntry);

View File

@ -3,6 +3,8 @@
#include "../cpp_foundation/XString.h"
#include "../gui/menu_items/menu_items.h"
//#include "../gui/REFIT_MAINMENU_SCREEN.h"
class REFIT_MAINMENU_SCREEN;
//void AddMenuInfoLine(IN REFIT_MENU_SCREEN *Screen, IN CONST CHAR16 *InfoLine);
//void AddMenuInfo(IN REFIT_MENU_SCREEN *SubScreen, IN CONST CHAR16 *Line);
@ -29,6 +31,7 @@ extern EG_RECT ScrollbarNewPointerPlace;
extern INTN LayoutAnimMoveForMenuX;
extern INTN LayoutMainMenuHeight;
extern REFIT_MAINMENU_SCREEN MainMenu;
void OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
void FreeScrollBar(void);