include AddDefaultMenu to class

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2020-05-16 23:07:27 +03:00
parent 22f9adcbc9
commit 6236534ec4
3 changed files with 93 additions and 105 deletions

View File

@ -767,14 +767,14 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
return Entry; return Entry;
} }
STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) void LOADER_ENTRY::AddDefaultMenu()
{ {
XStringW FileName; XStringW FileName;
// CHAR16* TempOptions; // CHAR16* TempOptions;
// CHAR16 DiagsFileName[256]; // CHAR16 DiagsFileName[256];
LOADER_ENTRY *SubEntry; LOADER_ENTRY *SubEntry;
REFIT_MENU_SCREEN *SubScreen; // REFIT_MENU_SCREEN *SubScreen;
REFIT_VOLUME *Volume; // REFIT_VOLUME *Volume;
UINT64 VolumeSize; UINT64 VolumeSize;
EFI_GUID *Guid = NULL; EFI_GUID *Guid = NULL;
BOOLEAN KernelIs64BitOnly; BOOLEAN KernelIs64BitOnly;
@ -783,51 +783,43 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
constexpr LString8 quietLitteral = "quiet"; constexpr LString8 quietLitteral = "quiet";
constexpr LString8 splashLitteral = "splash"; constexpr LString8 splashLitteral = "splash";
if (Entry == NULL) {
return;
}
Volume = Entry->Volume;
if (Volume == NULL) {
return;
}
// Only kernels up to 10.7 have 32-bit mode // Only kernels up to 10.7 have 32-bit mode
KernelIs64BitOnly = (Entry->OSVersion == NULL || KernelIs64BitOnly = (OSVersion == NULL ||
AsciiOSVersionToUint64(Entry->OSVersion) >= AsciiOSVersionToUint64("10.8")); AsciiOSVersionToUint64(OSVersion) >= AsciiOSVersionToUint64("10.8"));
FileName = Entry->LoaderPath.basename(); FileName = LoaderPath.basename();
// create the submenu // create the submenu
// SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); // SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
SubScreen = new REFIT_MENU_SCREEN; SubScreen = new REFIT_MENU_SCREEN;
SubScreen->Title.SWPrintf("Options for %ls on %ls", Entry->Title.wc_str(), Entry->VolName); SubScreen->Title.SWPrintf("Options for %ls on %ls", Title.wc_str(), VolName);
SubScreen->TitleImage = Entry->Image; SubScreen->TitleImage = Image;
SubScreen->ID = Entry->LoaderType + 20; //wow SubScreen->ID = LoaderType + 20; //wow
// DBG("get anime for os=%lld\n", SubScreen->ID); // DBG("get anime for os=%lld\n", SubScreen->ID);
SubScreen->GetAnime(); SubScreen->GetAnime();
VolumeSize = RShiftU64(MultU64x32(Volume->BlockIO->Media->LastBlock, Volume->BlockIO->Media->BlockSize), 20); VolumeSize = RShiftU64(MultU64x32(Volume->BlockIO->Media->LastBlock, Volume->BlockIO->Media->BlockSize), 20);
SubScreen->AddMenuInfoLine_f("Volume size: %lluMb", VolumeSize); SubScreen->AddMenuInfoLine_f("Volume size: %lluMb", VolumeSize);
SubScreen->AddMenuInfoLine_f("%ls", FileDevicePathToStr(Entry->DevicePath)); SubScreen->AddMenuInfoLine_f("%ls", FileDevicePathToStr(DevicePath));
Guid = FindGPTPartitionGuidInDevicePath(Volume->DevicePath); Guid = FindGPTPartitionGuidInDevicePath(Volume->DevicePath);
if (Guid) { if (Guid) {
SubScreen->AddMenuInfoLine_f("UUID: %s", strguid(Guid)); SubScreen->AddMenuInfoLine_f("UUID: %s", strguid(Guid));
} }
SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.ConcatAll(" "_XS8).c_str()); SubScreen->AddMenuInfoLine_f("Options: %s", LoadOptions.ConcatAll(" "_XS8).c_str());
// loader-specific submenu entries // loader-specific submenu entries
if (Entry->LoaderType == OSTYPE_OSX || if (LoaderType == OSTYPE_OSX ||
Entry->LoaderType == OSTYPE_OSX_INSTALLER || LoaderType == OSTYPE_OSX_INSTALLER ||
Entry->LoaderType == OSTYPE_RECOVERY) { // entries for Mac OS X LoaderType == OSTYPE_RECOVERY) { // entries for Mac OS X
if (os_version < AsciiOSVersionToUint64("10.8")) { if (os_version < AsciiOSVersionToUint64("10.8")) {
SubScreen->AddMenuInfoLine_f("Mac OS X: %s", Entry->OSVersion); SubScreen->AddMenuInfoLine_f("Mac OS X: %s", OSVersion);
} else if (os_version < AsciiOSVersionToUint64("10.12")) { } else if (os_version < AsciiOSVersionToUint64("10.12")) {
SubScreen->AddMenuInfoLine_f("OS X: %s", Entry->OSVersion); SubScreen->AddMenuInfoLine_f("OS X: %s", OSVersion);
} else { } else {
SubScreen->AddMenuInfoLine_f("macOS: %s", Entry->OSVersion); SubScreen->AddMenuInfoLine_f("macOS: %s", OSVersion);
} }
if (OSFLAG_ISSET(Entry->Flags, OSFLAG_HIBERNATED)) { if (OSFLAG_ISSET(Flags, OSFLAG_HIBERNATED)) {
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry = getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
SubEntry->Title.takeValueFrom("Cancel hibernate wake"); SubEntry->Title.takeValueFrom("Cancel hibernate wake");
SubEntry->Flags = OSFLAG_UNSET(SubEntry->Flags, OSFLAG_HIBERNATED); SubEntry->Flags = OSFLAG_UNSET(SubEntry->Flags, OSFLAG_HIBERNATED);
@ -835,7 +827,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
} }
} }
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry = getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
if (os_version < AsciiOSVersionToUint64("10.8")) { if (os_version < AsciiOSVersionToUint64("10.8")) {
SubEntry->Title.takeValueFrom("Boot Mac OS X with selected options"); SubEntry->Title.takeValueFrom("Boot Mac OS X with selected options");
@ -847,7 +839,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
SubScreen->AddMenuEntry(SubEntry, true); SubScreen->AddMenuEntry(SubEntry, true);
} }
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry = getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
if (os_version < AsciiOSVersionToUint64("10.8")) { if (os_version < AsciiOSVersionToUint64("10.8")) {
SubEntry->Title.takeValueFrom("Boot Mac OS X with injected kexts"); SubEntry->Title.takeValueFrom("Boot Mac OS X with injected kexts");
@ -861,7 +853,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
SubScreen->AddMenuEntry(SubEntry, true); SubScreen->AddMenuEntry(SubEntry, true);
} }
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry = getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
if (os_version < AsciiOSVersionToUint64("10.8")) { if (os_version < AsciiOSVersionToUint64("10.8")) {
SubEntry->Title.takeValueFrom("Boot Mac OS X without injected kexts"); SubEntry->Title.takeValueFrom("Boot Mac OS X without injected kexts");
@ -915,59 +907,59 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
SubScreen->AddMenuCheck("No SIP", OSFLAG_NOSIP, 69); SubScreen->AddMenuCheck("No SIP", OSFLAG_NOSIP, 69);
} }
} else if (Entry->LoaderType == OSTYPE_LINEFI) { } else if (LoaderType == OSTYPE_LINEFI) {
BOOLEAN Quiet = Entry->LoadOptions.contains(quietLitteral); BOOLEAN Quiet = LoadOptions.contains(quietLitteral);
BOOLEAN WithSplash = Entry->LoadOptions.contains(splashLitteral); BOOLEAN WithSplash = LoadOptions.contains(splashLitteral);
// default entry // default entry
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry = getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
SubEntry->Title.SWPrintf("Run %ls", FileName.wc_str()); SubEntry->Title.SWPrintf("Run %ls", FileName.wc_str());
SubScreen->AddMenuEntry(SubEntry, true); SubScreen->AddMenuEntry(SubEntry, true);
} }
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry = getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
if (Quiet) { if (Quiet) {
SubEntry->Title.SWPrintf("%ls verbose", Entry->Title.s()); SubEntry->Title.SWPrintf("%ls verbose", Title.s());
SubEntry->LoadOptions.removeIC(quietLitteral); SubEntry->LoadOptions.removeIC(quietLitteral);
} else { } else {
SubEntry->Title.SWPrintf("%ls quiet", Entry->Title.s()); SubEntry->Title.SWPrintf("%ls quiet", Title.s());
SubEntry->LoadOptions.AddID(quietLitteral); SubEntry->LoadOptions.AddID(quietLitteral);
} }
SubScreen->AddMenuEntry(SubEntry, true); SubScreen->AddMenuEntry(SubEntry, true);
} }
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry = getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
if (WithSplash) { if (WithSplash) {
SubEntry->Title.SWPrintf("%ls without splash", Entry->Title.s()); SubEntry->Title.SWPrintf("%ls without splash", Title.s());
SubEntry->LoadOptions.removeIC(splashLitteral); SubEntry->LoadOptions.removeIC(splashLitteral);
} else { } else {
SubEntry->Title.SWPrintf("%ls with splash", Entry->Title.s()); SubEntry->Title.SWPrintf("%ls with splash", Title.s());
SubEntry->LoadOptions.AddID(splashLitteral); SubEntry->LoadOptions.AddID(splashLitteral);
} }
SubScreen->AddMenuEntry(SubEntry, true); SubScreen->AddMenuEntry(SubEntry, true);
} }
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry = getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
if (WithSplash) { if (WithSplash) {
if (Quiet) { if (Quiet) {
SubEntry->Title.SWPrintf("%ls verbose without splash", Entry->Title.s()); SubEntry->Title.SWPrintf("%ls verbose without splash", Title.s());
SubEntry->LoadOptions.removeIC(splashLitteral); SubEntry->LoadOptions.removeIC(splashLitteral);
SubEntry->LoadOptions.removeIC(quietLitteral); SubEntry->LoadOptions.removeIC(quietLitteral);
} else { } else {
SubEntry->Title.SWPrintf("%ls quiet without splash", Entry->Title.s()); SubEntry->Title.SWPrintf("%ls quiet without splash",Title.s());
SubEntry->LoadOptions.removeIC(splashLitteral); SubEntry->LoadOptions.removeIC(splashLitteral);
SubEntry->LoadOptions.Add(quietLitteral); SubEntry->LoadOptions.Add(quietLitteral);
} }
} else if (Quiet) { } else if (Quiet) {
SubEntry->Title.SWPrintf("%ls verbose with splash", Entry->Title.s()); SubEntry->Title.SWPrintf("%ls verbose with splash",Title.s());
SubEntry->LoadOptions.removeIC(quietLitteral); // SubEntry->LoadOptions.removeIC(quietLitteral); //
SubEntry->LoadOptions.AddID(splashLitteral); SubEntry->LoadOptions.AddID(splashLitteral);
} else { } else {
SubEntry->Title.SWPrintf("%ls quiet with splash", Entry->Title.s()); SubEntry->Title.SWPrintf("%ls quiet with splash",Title.s());
SubEntry->LoadOptions.AddID(quietLitteral); SubEntry->LoadOptions.AddID(quietLitteral);
SubEntry->LoadOptions.AddID(splashLitteral); SubEntry->LoadOptions.AddID(splashLitteral);
} }
@ -976,38 +968,38 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
} else if ((Entry->LoaderType == OSTYPE_WIN) || (Entry->LoaderType == OSTYPE_WINEFI)) { } else if ((Entry->LoaderType == OSTYPE_WIN) || (Entry->LoaderType == OSTYPE_WINEFI)) {
// by default, skip the built-in selection and boot from hard disk only // by default, skip the built-in selection and boot from hard disk only
Entry->LoadOptions.setEmpty(); LoadOptions.setEmpty();
Entry->LoadOptions.Add("-s"_XS8); LoadOptions.Add("-s"_XS8);
Entry->LoadOptions.Add("-h"_XS8); LoadOptions.Add("-h"_XS8);
// default entry // default entry
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry =getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
SubEntry->Title.SWPrintf("Run %ls", FileName.wc_str()); SubEntry->Title.SWPrintf("Run %ls", FileName.wc_str());
SubScreen->AddMenuEntry(SubEntry, true); SubScreen->AddMenuEntry(SubEntry, true);
} }
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry =getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
SubEntry->Title.takeValueFrom("Boot Windows from Hard Disk"); SubEntry->Title.takeValueFrom("Boot Windows from Hard Disk");
SubScreen->AddMenuEntry(SubEntry, true); SubScreen->AddMenuEntry(SubEntry, true);
} }
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry =getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
SubEntry->Title.takeValueFrom("Boot Windows from CD-ROM"); SubEntry->Title.takeValueFrom("Boot Windows from CD-ROM");
Entry->LoadOptions.setEmpty(); LoadOptions.setEmpty();
Entry->LoadOptions.Add("-s"_XS8); LoadOptions.Add("-s"_XS8);
Entry->LoadOptions.Add("-c"_XS8); LoadOptions.Add("-c"_XS8);
SubScreen->AddMenuEntry(SubEntry, true); SubScreen->AddMenuEntry(SubEntry, true);
} }
SubEntry = Entry->getPartiallyDuplicatedEntry(); SubEntry =getPartiallyDuplicatedEntry();
if (SubEntry) { if (SubEntry) {
SubEntry->Title.SWPrintf("Run %ls in text mode", FileName.wc_str()); SubEntry->Title.SWPrintf("Run %ls in text mode", FileName.wc_str());
SubEntry->Flags = OSFLAG_UNSET(SubEntry->Flags, OSFLAG_USEGRAPHICS); SubEntry->Flags = OSFLAG_UNSET(SubEntry->Flags, OSFLAG_USEGRAPHICS);
Entry->LoadOptions.setEmpty(); LoadOptions.setEmpty();
Entry->LoadOptions.Add("-v"_XS8); LoadOptions.Add("-v"_XS8);
SubEntry->LoaderType = OSTYPE_OTHER; // Sothor - Why are we using OSTYPE_OTHER here? SubEntry->LoaderType = OSTYPE_OTHER; // Sothor - Why are we using OSTYPE_OTHER here?
SubScreen->AddMenuEntry(SubEntry, true); SubScreen->AddMenuEntry(SubEntry, true);
} }
@ -1015,8 +1007,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
} }
SubScreen->AddMenuEntry(&MenuEntryReturn, false); SubScreen->AddMenuEntry(&MenuEntryReturn, false);
Entry->SubScreen = SubScreen; // DBG(" Added '%ls': OSType='%d', OSVersion='%s'\n",Title,LoaderType,OSVersion);
// DBG(" Added '%ls': OSType='%d', OSVersion='%s'\n", Entry->Title, Entry->LoaderType, Entry->OSVersion);
} }
BOOLEAN AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XStringArray& LoaderOptions, BOOLEAN AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XStringArray& LoaderOptions,
@ -1067,7 +1058,7 @@ BOOLEAN AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XStringArray& Loa
} }
//TODO there is a problem that Entry->Flags is unique while InputItems are global ;( //TODO there is a problem that Entry->Flags is unique while InputItems are global ;(
// InputItems[69].IValue = Entry->Flags; // InputItems[69].IValue = Entry->Flags;
AddDefaultMenu(Entry); Entry->AddDefaultMenu();
MainMenu.AddMenuEntry(Entry, true); MainMenu.AddMenuEntry(Entry, true);
return TRUE; return TRUE;
} }
@ -1839,7 +1830,7 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
Entry->Settings = Custom->Settings; Entry->Settings = Custom->Settings;
} }
if (OSFLAG_ISUNSET(Custom->Flags, OSFLAG_NODEFAULTMENU)) { if (OSFLAG_ISUNSET(Custom->Flags, OSFLAG_NODEFAULTMENU)) {
AddDefaultMenu(Entry); Entry->AddDefaultMenu();
} else if (Custom->SubEntries != NULL) { } else if (Custom->SubEntries != NULL) {
UINTN CustomSubIndex = 0; UINTN CustomSubIndex = 0;
// Add subscreen // Add subscreen

View File

@ -288,7 +288,7 @@ class REFIT_ABSTRACT_MENU_ENTRY
UINT16 Flags; UINT16 Flags;
EFI_DEVICE_PATH *DevicePath; EFI_DEVICE_PATH *DevicePath;
VOID StartTool(); void StartTool();
REFIT_MENU_ENTRY_LOADER_TOOL() : REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(), NoMemset(1), Flags(0), DevicePath(0) {}; REFIT_MENU_ENTRY_LOADER_TOOL() : REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(), NoMemset(1), Flags(0), DevicePath(0) {};
@ -333,7 +333,7 @@ class REFIT_ABSTRACT_MENU_ENTRY
public: public:
LEGACY_ENTRY() : REFIT_MENU_ITEM_BOOTNUM() {}; LEGACY_ENTRY() : REFIT_MENU_ITEM_BOOTNUM() {};
VOID StartLegacy(); void StartLegacy();
virtual LEGACY_ENTRY* getLEGACY_ENTRY() { return this; }; virtual LEGACY_ENTRY* getLEGACY_ENTRY() { return this; };
}; };
@ -403,31 +403,31 @@ class REFIT_ABSTRACT_MENU_ENTRY
KernelRelocBase(0), bootArgs1(0), bootArgs2(0), dtRoot(0), dtLength(0) KernelRelocBase(0), bootArgs1(0), bootArgs2(0), dtRoot(0), dtLength(0)
{}; {};
VOID SetKernelRelocBase(); void SetKernelRelocBase();
VOID FindBootArgs(); void FindBootArgs();
EFI_STATUS getVTable(); EFI_STATUS getVTable();
VOID Get_PreLink(); void Get_PreLink();
UINTN searchProc(const char *procedure); UINTN searchProc(const char *procedure);
UINTN searchProcInDriver(UINT8 * driver, UINT32 driverLen, const char *procedure); UINTN searchProcInDriver(UINT8 * driver, UINT32 driverLen, const char *procedure);
VOID KernelAndKextsPatcherStart(); void KernelAndKextsPatcherStart();
VOID KernelAndKextPatcherInit(); void KernelAndKextPatcherInit();
BOOLEAN KernelUserPatch(); BOOLEAN KernelUserPatch();
BOOLEAN KernelPatchPm(); BOOLEAN KernelPatchPm();
BOOLEAN KernelLapicPatch_32(); BOOLEAN KernelLapicPatch_32();
BOOLEAN KernelLapicPatch_64(); BOOLEAN KernelLapicPatch_64();
BOOLEAN BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize); BOOLEAN BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize);
VOID EFIAPI KernelBooterExtensionsPatch(); void EFIAPI KernelBooterExtensionsPatch();
BOOLEAN KernelPanicNoKextDump(); BOOLEAN KernelPanicNoKextDump();
VOID KernelCPUIDPatch(); void KernelCPUIDPatch();
BOOLEAN PatchCPUID(const UINT8* Location, INT32 LenLoc, BOOLEAN PatchCPUID(const UINT8* Location, INT32 LenLoc,
const UINT8* Search4, const UINT8* Search10, const UINT8* ReplaceModel, const UINT8* Search4, const UINT8* Search10, const UINT8* ReplaceModel,
const UINT8* ReplaceExt, INT32 Len); const UINT8* ReplaceExt, INT32 Len);
VOID KernelPatcher_32(); void KernelPatcher_32();
// VOID KernelPatcher_64(); // void KernelPatcher_64();
VOID FilterKernelPatches(); void FilterKernelPatches();
VOID FilterKextPatches(); void FilterKextPatches();
VOID FilterBootPatches(); void FilterBootPatches();
VOID applyKernPatch(const UINT8 *find, UINTN size, const UINT8 *repl, const CHAR8 *comment); void applyKernPatch(const UINT8 *find, UINTN size, const UINT8 *repl, const CHAR8 *comment);
EFI_STATUS SetFSInjection(); EFI_STATUS SetFSInjection();
EFI_STATUS InjectKexts(IN UINT32 deviceTreeP, IN UINT32 *deviceTreeLength); EFI_STATUS InjectKexts(IN UINT32 deviceTreeP, IN UINT32 *deviceTreeLength);
@ -435,25 +435,25 @@ class REFIT_ABSTRACT_MENU_ENTRY
int is_mkext_v1(UINT8* drvPtr); int is_mkext_v1(UINT8* drvPtr);
void patch_mkext_v1(UINT8 *drvPtr); void patch_mkext_v1(UINT8 *drvPtr);
EFI_STATUS LoadKext(IN EFI_FILE *RootDir, IN CHAR16 *FileName, IN cpu_type_t archCpuType, IN OUT VOID *kext); EFI_STATUS LoadKext(IN EFI_FILE *RootDir, IN CHAR16 *FileName, IN cpu_type_t archCpuType, IN OUT void *kext);
EFI_STATUS AddKext(IN EFI_FILE *RootDir, IN CHAR16 *FileName, IN cpu_type_t archCpuType); EFI_STATUS AddKext(IN EFI_FILE *RootDir, IN CHAR16 *FileName, IN cpu_type_t archCpuType);
VOID LoadPlugInKexts(IN EFI_FILE *RootDir, IN CHAR16 *DirName, IN cpu_type_t archCpuType, IN BOOLEAN Force); void LoadPlugInKexts(IN EFI_FILE *RootDir, IN CHAR16 *DirName, IN cpu_type_t archCpuType, IN BOOLEAN Force);
VOID AddKexts(CONST CHAR16 *SrcDir, CONST CHAR16 *Path, cpu_type_t archCpuType); void AddKexts(CONST CHAR16 *SrcDir, CONST CHAR16 *Path, cpu_type_t archCpuType);
VOID KextPatcherRegisterKexts(void *FSInject, void *ForceLoadKexts); void KextPatcherRegisterKexts(void *FSInject, void *ForceLoadKexts);
VOID KextPatcherStart(); void KextPatcherStart();
VOID PatchPrelinkedKexts(); void PatchPrelinkedKexts();
VOID PatchLoadedKexts(); void PatchLoadedKexts();
VOID PatchKext(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize); void PatchKext(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
VOID AnyKextPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize, INT32 N); void AnyKextPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize, INT32 N);
VOID ATIConnectorsPatchInit(); void ATIConnectorsPatchInit();
VOID ATIConnectorsPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize); void ATIConnectorsPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
VOID ATIConnectorsPatchRegisterKexts(void *FSInject_v, void *ForceLoadKexts_v); void ATIConnectorsPatchRegisterKexts(void *FSInject_v, void *ForceLoadKexts_v);
VOID AppleIntelCPUPMPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize); void AppleIntelCPUPMPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
VOID AppleRTCPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize); void AppleRTCPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
VOID CheckForFakeSMC(CHAR8 *InfoPlist); void CheckForFakeSMC(CHAR8 *InfoPlist);
VOID DellSMBIOSPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize); void DellSMBIOSPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
VOID SNBE_AICPUPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize); void SNBE_AICPUPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
VOID BDWE_IOPCIPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize); void BDWE_IOPCIPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
BOOLEAN SandyBridgeEPM(); BOOLEAN SandyBridgeEPM();
BOOLEAN HaswellEXCPM(); BOOLEAN HaswellEXCPM();
BOOLEAN HaswellLowEndXCPM(); BOOLEAN HaswellLowEndXCPM();
@ -461,8 +461,9 @@ class REFIT_ABSTRACT_MENU_ENTRY
BOOLEAN KernelIvyBridgeXCPM(); BOOLEAN KernelIvyBridgeXCPM();
BOOLEAN KernelIvyE5XCPM(); BOOLEAN KernelIvyE5XCPM();
VOID Stall(int Pause) { if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPDebug) { gBS->Stall(Pause); } }; void Stall(int Pause) { if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPDebug) { gBS->Stall(Pause); } };
VOID StartLoader(); void StartLoader();
void AddDefaultMenu();
LOADER_ENTRY* getPartiallyDuplicatedEntry() const; LOADER_ENTRY* getPartiallyDuplicatedEntry() const;
virtual LOADER_ENTRY* getLOADER_ENTRY() { return this; }; virtual LOADER_ENTRY* getLOADER_ENTRY() { return this; };
} ; } ;

View File

@ -64,7 +64,6 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString8& IconNameX, OUT XImage*
NSVGgroup *group; NSVGgroup *group;
NSVGimage *IconImage; NSVGimage *IconImage;
NSVGshape *shapeNext, *shapesTail = NULL, *shapePrev; NSVGshape *shapeNext, *shapesTail = NULL, *shapePrev;
// CONST CHAR8 *IconName = IconNameX.c_str();
NSVGparser* p2 = nsvg__createParser(); NSVGparser* p2 = nsvg__createParser();
IconImage = p2->image; IconImage = p2->image;
@ -106,7 +105,7 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString8& IconNameX, OUT XImage*
if (IconNameX.contains("selection_big") && (!SelectionOnTop)) { if (IconNameX.contains("selection_big") && (!SelectionOnTop)) {
MainEntriesSize = (int)(IconImage->width * Scale); //xxx MainEntriesSize = (int)(IconImage->width * Scale); //xxx
row0TileSize = MainEntriesSize + (int)(16.f * Scale); row0TileSize = MainEntriesSize + (int)(16.f * Scale);
DBG("main entry size = %lld\n", MainEntriesSize); // DBG("main entry size = %lld\n", MainEntriesSize);
} }
if (IconNameX.contains("selection_small") && (!SelectionOnTop)) { if (IconNameX.contains("selection_small") && (!SelectionOnTop)) {
row1TileSize = (int)(IconImage->width * Scale); row1TileSize = (int)(IconImage->width * Scale);
@ -245,7 +244,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
SVGParser = (void *)mainParser; //store the pointer for future use SVGParser = (void *)mainParser; //store the pointer for future use
NSVGimage *SVGimage = mainParser->image; NSVGimage *SVGimage = mainParser->image;
if (!SVGimage) { if (!SVGimage) {
DBG("Theme not parsed!\n"); // DBG("Theme not parsed!\n");
return EFI_NOT_STARTED; return EFI_NOT_STARTED;
} }
@ -297,7 +296,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
} }
XIcon* NewIcon = new XIcon(i, false); //initialize without embedded XIcon* NewIcon = new XIcon(i, false); //initialize without embedded
Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image, &NewIcon->ImageSVG); Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image, &NewIcon->ImageSVG);
DBG("parse %s status %s\n", NewIcon->Name.c_str(), strerror(Status)); // DBG("parse %s status %s\n", NewIcon->Name.c_str(), strerror(Status));
NewIcon->Native = !EFI_ERROR(Status); NewIcon->Native = !EFI_ERROR(Status);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
NewIcon->setFilled(); NewIcon->setFilled();
@ -320,14 +319,13 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
if (AsciiStrLen(IconsNames[i]) == 0) break; if (AsciiStrLen(IconsNames[i]) == 0) break;
XIcon* NewIcon = new XIcon(i, false); //initialize without embedded XIcon* NewIcon = new XIcon(i, false); //initialize without embedded
Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image, &NewIcon->ImageSVG); Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image, &NewIcon->ImageSVG);
DBG("parse %s i=%lld status %s\n", NewIcon->Name.c_str(), i, strerror(Status)); // DBG("parse %s i=%lld status %s\n", NewIcon->Name.c_str(), i, strerror(Status));
NewIcon->Native = !EFI_ERROR(Status); NewIcon->Native = !EFI_ERROR(Status);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
ParseSVGXIcon(i, NewIcon->Name + "_night"_XS8, &NewIcon->ImageNight, &NewIcon->ImageSVGnight); ParseSVGXIcon(i, NewIcon->Name + "_night"_XS8, &NewIcon->ImageNight, &NewIcon->ImageSVGnight);
} }
Icons.AddReference(NewIcon, true); Icons.AddReference(NewIcon, true);
} }
DBG("parse icon_selection\n");
//selection for bootcampstyle //selection for bootcampstyle
XIcon *NewIcon = new XIcon(BUILTIN_ICON_SELECTION); XIcon *NewIcon = new XIcon(BUILTIN_ICON_SELECTION);
Status = ParseSVGXIcon(BUILTIN_ICON_SELECTION, "selection_indicator"_XS8, &NewIcon->Image, &NewIcon->ImageSVG); Status = ParseSVGXIcon(BUILTIN_ICON_SELECTION, "selection_indicator"_XS8, &NewIcon->Image, &NewIcon->ImageSVG);
@ -342,17 +340,14 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
SelectionBackgroundPixel.Blue = (SelectionColor >> 8) & 0xFF; SelectionBackgroundPixel.Blue = (SelectionColor >> 8) & 0xFF;
SelectionBackgroundPixel.Reserved = (SelectionColor >> 0) & 0xFF; SelectionBackgroundPixel.Reserved = (SelectionColor >> 0) & 0xFF;
//TODO make SelectionImages to be XIcon //TODO make SelectionImages to be XIcon
DBG("assign selections\n");
SelectionImages[0] = GetIcon(BUILTIN_SELECTION_BIG).GetBest(!Daylight); SelectionImages[0] = GetIcon(BUILTIN_SELECTION_BIG).GetBest(!Daylight);
SelectionImages[2] = GetIcon(BUILTIN_SELECTION_SMALL).GetBest(!Daylight); SelectionImages[2] = GetIcon(BUILTIN_SELECTION_SMALL).GetBest(!Daylight);
SelectionImages[4] = GetIcon(BUILTIN_ICON_SELECTION).GetBest(!Daylight); SelectionImages[4] = GetIcon(BUILTIN_ICON_SELECTION).GetBest(!Daylight);
DBG("assign buttons\n");
//buttons //buttons
for (INTN i = BUILTIN_RADIO_BUTTON; i <= BUILTIN_CHECKBOX_CHECKED; ++i) { for (INTN i = BUILTIN_RADIO_BUTTON; i <= BUILTIN_CHECKBOX_CHECKED; ++i) {
Buttons[i - BUILTIN_RADIO_BUTTON] = GetIcon(i).GetBest(!Daylight); Buttons[i - BUILTIN_RADIO_BUTTON] = GetIcon(i).GetBest(!Daylight);
} }
DBG("done!\n");
//for (int i=0 ; i<6 ; i+=2 ) { //for (int i=0 ; i<6 ; i+=2 ) {
//SelectionImages[i].Draw(i*100, 0); //SelectionImages[i].Draw(i*100, 0);
//} //}
@ -545,6 +540,7 @@ INTN renderSVGtext(XImage* TextBufferXY_ptr, INTN posX, INTN posY, INTN textType
nsvgDelete(p->image); nsvgDelete(p->image);
return (INTN)RealWidth; //x; return (INTN)RealWidth; //x;
} }
VOID testSVG() VOID testSVG()
{ {
do { do {