2020-02-29 08:30:21 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* 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 __menu_items_H__
|
|
|
|
#define __menu_items_H__
|
|
|
|
|
2021-02-06 18:16:46 +01:00
|
|
|
#include <Efi.h>
|
|
|
|
#include "../../Platform/KERNEL_AND_KEXT_PATCHES.h"
|
|
|
|
#include "../../Platform/plist/plist.h"
|
2020-03-28 16:14:18 +01:00
|
|
|
#include "../../libeg/libeg.h"
|
2021-02-06 18:16:46 +01:00
|
|
|
#include "../../libeg/XIcon.h"
|
2020-03-02 13:00:24 +01:00
|
|
|
#include "../../refit/lib.h"
|
2021-02-06 18:16:46 +01:00
|
|
|
#include <UefiLoader.h> // for cpu_type_t
|
2020-05-11 17:44:00 +02:00
|
|
|
#include "../../Platform/boot.h"
|
2021-02-06 18:16:46 +01:00
|
|
|
#include "../../Platform/Volumes.h"
|
2020-05-01 18:26:28 +02:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
#include "../../cpp_foundation/XObjArray.h"
|
2020-04-26 12:12:05 +02:00
|
|
|
#include "../../cpp_foundation/XStringArray.h"
|
2020-04-05 14:25:39 +02:00
|
|
|
#include "../../cpp_foundation/XString.h"
|
2020-03-02 13:00:24 +01:00
|
|
|
#include "../../libeg/XPointer.h"
|
2020-11-12 22:25:56 +01:00
|
|
|
#include "../../Platform/MacOsVersion.h"
|
2020-05-01 18:26:28 +02:00
|
|
|
|
2020-03-03 21:44:07 +01:00
|
|
|
|
2020-02-29 08:30:21 +01:00
|
|
|
//
|
|
|
|
//#define REFIT_DEBUG (2)
|
2021-02-02 10:02:21 +01:00
|
|
|
//#define Print if ((!GlobalConfig.Quiet) || (gSettings.GUI.TextOnly)) Print
|
2020-02-29 08:30:21 +01:00
|
|
|
////#include "GenericBdsLib.h"
|
|
|
|
|
|
|
|
|
|
|
|
//#define TAG_ABOUT_OLD (1)
|
|
|
|
//#define TAG_RESET_OLD (2)
|
|
|
|
//#define TAG_SHUTDOWN_OLD (3)
|
|
|
|
//#define TAG_TOOL_OLD (4)
|
|
|
|
////#define TAG_LOADER (5)
|
|
|
|
////#define TAG_LEGACY (6)
|
|
|
|
//#define TAG_INFO_OLD (7)
|
|
|
|
//#define TAG_OPTIONS (8)
|
|
|
|
//#define TAG_INPUT_OLD (9)
|
|
|
|
//#define TAG_HELP_OLD (10) // wasn't used ?
|
|
|
|
//#define TAG_SWITCH_OLD (11)
|
|
|
|
//#define TAG_CHECKBIT_OLD (12)
|
|
|
|
//#define TAG_SECURE_BOOT_OLD (13)
|
|
|
|
//#define TAG_SECURE_BOOT_CONFIG_OLD (14)
|
|
|
|
//#define TAG_CLOVER_OLD (100)
|
|
|
|
//#define TAG_EXIT_OLD (101)
|
|
|
|
//#define TAG_RETURN_OLD ((UINTN)(-1))
|
|
|
|
|
|
|
|
//typedef struct _refit_menu_screen REFIT_MENU_SCREEN;
|
|
|
|
class REFIT_MENU_SCREEN;
|
|
|
|
class REFIT_MENU_SWITCH;
|
|
|
|
class REFIT_MENU_CHECKBIT;
|
|
|
|
class REFIT_MENU_ENTRY_CLOVER;
|
|
|
|
class REFIT_MENU_ITEM_RETURN;
|
|
|
|
class REFIT_INPUT_DIALOG;
|
|
|
|
class REFIT_INFO_DIALOG;
|
|
|
|
class REFIT_MENU_ENTRY_LOADER_TOOL;
|
|
|
|
class REFIT_MENU_ITEM_SHUTDOWN;
|
|
|
|
class REFIT_MENU_ITEM_RESET;
|
|
|
|
class REFIT_MENU_ITEM_ABOUT;
|
|
|
|
class REFIT_MENU_ITEM_OPTIONS;
|
2020-02-29 13:56:36 +01:00
|
|
|
class REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER;
|
2020-02-29 08:30:21 +01:00
|
|
|
class LOADER_ENTRY;
|
|
|
|
class LEGACY_ENTRY;
|
|
|
|
class REFIT_MENU_ENTRY_OTHER;
|
|
|
|
class REFIT_SIMPLE_MENU_ENTRY_TAG;
|
2020-03-10 10:45:17 +01:00
|
|
|
class REFIT_MENU_ENTRY_ITEM_ABSTRACT;
|
|
|
|
class REFIT_MENU_ITEM_BOOTNUM;
|
2020-03-02 13:00:24 +01:00
|
|
|
class XPointer;
|
2020-09-07 00:19:48 +02:00
|
|
|
class SIDELOAD_KEXT;
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
/********************************************************** REFIT_ABSTRACT_MENU_ENTRY *************************************************************/
|
|
|
|
|
2020-02-29 08:30:21 +01:00
|
|
|
class REFIT_ABSTRACT_MENU_ENTRY
|
|
|
|
{
|
|
|
|
public:
|
2021-03-22 13:40:01 +01:00
|
|
|
XStringW Title = XStringW();
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool Hidden = false;
|
2021-03-22 13:40:01 +01:00
|
|
|
UINTN Row = 0;
|
|
|
|
CHAR16 ShortcutDigit = 0;
|
2021-05-08 11:34:17 +02:00
|
|
|
char32_t ShortcutLetter = 0;
|
2021-03-22 13:40:01 +01:00
|
|
|
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;
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-05-16 21:30:29 +02:00
|
|
|
virtual XIcon* getDriveImage() { return nullptr; };
|
|
|
|
virtual XIcon* getBadgeImage() { return nullptr; };
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-02-29 13:56:36 +01:00
|
|
|
virtual REFIT_SIMPLE_MENU_ENTRY_TAG* getREFIT_SIMPLE_MENU_ENTRY_TAG() { return nullptr; };
|
2020-02-29 08:30:21 +01:00
|
|
|
virtual REFIT_MENU_SWITCH* getREFIT_MENU_SWITCH() { return nullptr; };
|
|
|
|
virtual REFIT_MENU_CHECKBIT* getREFIT_MENU_CHECKBIT() { return nullptr; };
|
|
|
|
virtual REFIT_MENU_ENTRY_CLOVER* getREFIT_MENU_ENTRY_CLOVER() { return nullptr; };
|
|
|
|
virtual REFIT_MENU_ITEM_RETURN* getREFIT_MENU_ITEM_RETURN() { return nullptr; };
|
|
|
|
virtual REFIT_INPUT_DIALOG* getREFIT_INPUT_DIALOG() { return nullptr; };
|
|
|
|
virtual REFIT_INFO_DIALOG* getREFIT_INFO_DIALOG() { return nullptr; };
|
|
|
|
virtual REFIT_MENU_ENTRY_LOADER_TOOL* getREFIT_MENU_ENTRY_LOADER_TOOL() { return nullptr; };
|
|
|
|
virtual REFIT_MENU_ITEM_SHUTDOWN* getREFIT_MENU_ITEM_SHUTDOWN() { return nullptr; };
|
|
|
|
virtual REFIT_MENU_ITEM_RESET* getREFIT_MENU_ITEM_RESET() { return nullptr; };
|
|
|
|
virtual REFIT_MENU_ITEM_ABOUT* getREFIT_MENU_ITEM_ABOUT() { return nullptr; };
|
|
|
|
virtual REFIT_MENU_ITEM_OPTIONS* getREFIT_MENU_ITEM_OPTIONS() { return nullptr; };
|
2020-02-29 13:56:36 +01:00
|
|
|
virtual REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER* getREFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER() { return nullptr; };
|
2020-02-29 08:30:21 +01:00
|
|
|
virtual LOADER_ENTRY* getLOADER_ENTRY() { return nullptr; };
|
|
|
|
virtual LEGACY_ENTRY* getLEGACY_ENTRY() { return nullptr; };
|
|
|
|
virtual REFIT_MENU_ENTRY_OTHER* getREFIT_MENU_ENTRY_OTHER() { return nullptr; };
|
2020-03-10 10:45:17 +01:00
|
|
|
virtual REFIT_MENU_ENTRY_ITEM_ABSTRACT* getREFIT_MENU_ITEM_IEM_ABSTRACT() { return nullptr; };
|
|
|
|
virtual REFIT_MENU_ITEM_BOOTNUM* getREFIT_MENU_ITEM_BOOTNUM() { return nullptr; };
|
2020-05-01 18:26:28 +02:00
|
|
|
virtual void StartLoader() {};
|
|
|
|
virtual void StartLegacy() {};
|
|
|
|
virtual void StartTool() {};
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2021-03-22 13:40:01 +01:00
|
|
|
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&) { panic("not yet defined"); }
|
|
|
|
REFIT_ABSTRACT_MENU_ENTRY& operator=(const REFIT_ABSTRACT_MENU_ENTRY&) { panic("not yet defined"); }
|
2020-04-03 22:00:42 +02:00
|
|
|
|
2020-02-29 08:30:21 +01:00
|
|
|
virtual ~REFIT_ABSTRACT_MENU_ENTRY() {}; // virtual destructor : this is vital
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
/********************************************************** REFIT_ABSTRACT_MENU_ENTRY *************************************************************/
|
|
|
|
|
|
|
|
class REFIT_SIMPLE_MENU_ENTRY_TAG : public REFIT_ABSTRACT_MENU_ENTRY
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UINTN Tag;
|
|
|
|
|
2020-03-10 17:50:55 +01:00
|
|
|
REFIT_SIMPLE_MENU_ENTRY_TAG(const XStringW& Title_, UINTN Tag_, ACTION AtClick_)
|
2020-03-10 10:45:17 +01:00
|
|
|
: REFIT_ABSTRACT_MENU_ENTRY(Title_, AtClick_), Tag(Tag_)
|
|
|
|
{};
|
|
|
|
|
|
|
|
virtual REFIT_SIMPLE_MENU_ENTRY_TAG* getREFIT_SIMPLE_MENU_ENTRY_TAG() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************** Simple entries. Inherit from REFIT_ABSTRACT_MENU_ENTRY *************************************************************/
|
|
|
|
|
|
|
|
class REFIT_MENU_ITEM_RETURN : public REFIT_ABSTRACT_MENU_ENTRY
|
|
|
|
{
|
|
|
|
public:
|
2020-03-10 11:27:05 +01:00
|
|
|
REFIT_MENU_ITEM_RETURN() : REFIT_ABSTRACT_MENU_ENTRY() {};
|
2020-03-10 17:50:55 +01:00
|
|
|
REFIT_MENU_ITEM_RETURN(const XStringW& Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_)
|
2020-03-10 11:27:05 +01:00
|
|
|
: REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, AtClick_)
|
2020-03-10 10:45:17 +01:00
|
|
|
{};
|
|
|
|
virtual REFIT_MENU_ITEM_RETURN* getREFIT_MENU_ITEM_RETURN() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
class REFIT_MENU_ITEM_SHUTDOWN : public REFIT_ABSTRACT_MENU_ENTRY
|
|
|
|
{
|
|
|
|
public:
|
2020-03-10 11:27:05 +01:00
|
|
|
REFIT_MENU_ITEM_SHUTDOWN() : REFIT_ABSTRACT_MENU_ENTRY() {};
|
2020-03-10 17:50:55 +01:00
|
|
|
REFIT_MENU_ITEM_SHUTDOWN(const XStringW& Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_)
|
2020-03-10 11:27:05 +01:00
|
|
|
: REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, AtClick_)
|
2020-03-10 10:45:17 +01:00
|
|
|
{};
|
|
|
|
virtual REFIT_MENU_ITEM_SHUTDOWN* getREFIT_MENU_ITEM_SHUTDOWN() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
class REFIT_MENU_ITEM_RESET : public REFIT_ABSTRACT_MENU_ENTRY {
|
|
|
|
public:
|
2020-03-10 11:27:05 +01:00
|
|
|
REFIT_MENU_ITEM_RESET() : REFIT_ABSTRACT_MENU_ENTRY() {};
|
2020-03-10 17:50:55 +01:00
|
|
|
REFIT_MENU_ITEM_RESET(const XStringW& Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_)
|
2020-03-10 11:27:05 +01:00
|
|
|
: REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, AtClick_)
|
2020-03-10 10:45:17 +01:00
|
|
|
{};
|
|
|
|
virtual REFIT_MENU_ITEM_RESET* getREFIT_MENU_ITEM_RESET() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
class REFIT_MENU_ITEM_ABOUT : public REFIT_ABSTRACT_MENU_ENTRY
|
|
|
|
{
|
|
|
|
public:
|
2020-03-10 11:27:05 +01:00
|
|
|
REFIT_MENU_ITEM_ABOUT() : REFIT_ABSTRACT_MENU_ENTRY() {};
|
2020-03-10 17:50:55 +01:00
|
|
|
REFIT_MENU_ITEM_ABOUT(const XStringW& Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_)
|
2020-03-10 11:27:05 +01:00
|
|
|
: REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, AtClick_)
|
2020-03-10 10:45:17 +01:00
|
|
|
{};
|
|
|
|
virtual REFIT_MENU_ITEM_ABOUT* getREFIT_MENU_ITEM_ABOUT() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
class REFIT_MENU_ITEM_OPTIONS : public REFIT_ABSTRACT_MENU_ENTRY {
|
|
|
|
public:
|
|
|
|
REFIT_MENU_ITEM_OPTIONS() : REFIT_ABSTRACT_MENU_ENTRY() {};
|
2020-03-10 17:50:55 +01:00
|
|
|
REFIT_MENU_ITEM_OPTIONS(const XStringW& Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_)
|
2020-03-10 11:27:05 +01:00
|
|
|
: REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, AtClick_)
|
2020-03-10 10:45:17 +01:00
|
|
|
{};
|
|
|
|
virtual REFIT_MENU_ITEM_OPTIONS* getREFIT_MENU_ITEM_OPTIONS() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class REFIT_INFO_DIALOG : public REFIT_ABSTRACT_MENU_ENTRY {
|
|
|
|
public:
|
|
|
|
virtual REFIT_INFO_DIALOG* getREFIT_INFO_DIALOG() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************** *************************************************************/
|
|
|
|
|
|
|
|
class REFIT_MENU_ENTRY_ITEM_ABSTRACT : public REFIT_ABSTRACT_MENU_ENTRY {
|
|
|
|
public:
|
|
|
|
INPUT_ITEM *Item;
|
|
|
|
REFIT_MENU_ENTRY_ITEM_ABSTRACT() : Item(0) {}
|
2020-08-11 14:43:53 +02:00
|
|
|
REFIT_MENU_ENTRY_ITEM_ABSTRACT(const REFIT_MENU_ENTRY_ITEM_ABSTRACT&) = delete;
|
|
|
|
REFIT_MENU_ENTRY_ITEM_ABSTRACT& operator=(const REFIT_MENU_ENTRY_ITEM_ABSTRACT&) = delete;
|
2020-03-10 10:45:17 +01:00
|
|
|
virtual REFIT_MENU_ENTRY_ITEM_ABSTRACT* getREFIT_MENU_ITEM_IEM_ABSTRACT() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Classes that needs a Item member */
|
|
|
|
class REFIT_INPUT_DIALOG : public REFIT_MENU_ENTRY_ITEM_ABSTRACT {
|
|
|
|
public:
|
|
|
|
virtual REFIT_INPUT_DIALOG* getREFIT_INPUT_DIALOG() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
class REFIT_MENU_SWITCH : public REFIT_MENU_ENTRY_ITEM_ABSTRACT {
|
|
|
|
public:
|
|
|
|
virtual REFIT_MENU_SWITCH* getREFIT_MENU_SWITCH() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
class REFIT_MENU_CHECKBIT : public REFIT_MENU_ENTRY_ITEM_ABSTRACT {
|
|
|
|
public:
|
|
|
|
virtual REFIT_MENU_CHECKBIT* getREFIT_MENU_CHECKBIT() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
/********************************************************** Loader entries *************************************************************/
|
|
|
|
/*
|
|
|
|
* Super class of LOADER_ENTRY & LEGACY_ENTRY
|
|
|
|
*/
|
|
|
|
class REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER : public REFIT_ABSTRACT_MENU_ENTRY
|
|
|
|
{
|
|
|
|
public:
|
2020-08-09 17:55:30 +02:00
|
|
|
XStringW DevicePathString;
|
2020-08-11 08:00:19 +02:00
|
|
|
XString8Array LoadOptions; //moved here for compatibility with legacy
|
2020-08-09 17:55:30 +02:00
|
|
|
XStringW LoaderPath;
|
2020-05-16 21:30:29 +02:00
|
|
|
XIcon DriveImage;
|
|
|
|
XIcon BadgeImage;
|
2020-03-10 10:45:17 +01:00
|
|
|
|
2020-04-03 22:00:42 +02:00
|
|
|
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER()
|
2021-04-08 17:07:05 +02:00
|
|
|
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(), LoadOptions(), LoaderPath(), DriveImage(), BadgeImage()
|
2020-08-11 14:43:53 +02:00
|
|
|
{}
|
|
|
|
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(const REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER&) = delete;
|
|
|
|
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER& operator=(const REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER&) = delete;
|
|
|
|
|
2020-05-16 21:30:29 +02:00
|
|
|
virtual XIcon* getDriveImage() { return &DriveImage; };
|
|
|
|
virtual XIcon* getBadgeImage() { return &BadgeImage; };
|
2020-04-03 22:00:42 +02:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
virtual REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER* getREFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER() { return this; };
|
|
|
|
};
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
//--------------------------------------- REFIT_MENU_ENTRY_LOADER_TOOL ---------------------------------------//
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
class REFIT_MENU_ENTRY_LOADER_TOOL : public REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER
|
|
|
|
{
|
|
|
|
public:
|
2020-05-16 21:30:29 +02:00
|
|
|
UINT8 NoMemset; //HACK - some non zero value
|
2020-03-10 10:45:17 +01:00
|
|
|
UINT16 Flags;
|
|
|
|
EFI_DEVICE_PATH *DevicePath;
|
2020-05-01 18:26:28 +02:00
|
|
|
|
2020-05-16 22:07:27 +02:00
|
|
|
void StartTool();
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 11:00:17 +01:00
|
|
|
REFIT_MENU_ENTRY_LOADER_TOOL() : REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(), NoMemset(1), Flags(0), DevicePath(0) {};
|
2020-08-11 14:43:53 +02:00
|
|
|
REFIT_MENU_ENTRY_LOADER_TOOL(const REFIT_MENU_ENTRY_LOADER_TOOL&) = delete;
|
|
|
|
REFIT_MENU_ENTRY_LOADER_TOOL& operator=(const REFIT_MENU_ENTRY_LOADER_TOOL&) = delete;
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
virtual REFIT_MENU_ENTRY_LOADER_TOOL* getREFIT_MENU_ENTRY_LOADER_TOOL() { return this; };
|
|
|
|
};
|
2020-02-29 08:30:21 +01:00
|
|
|
|
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
//--------------------------------------- REFIT_MENU_ENTRY_CLOVER ---------------------------------------//
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
class REFIT_MENU_ENTRY_CLOVER : public REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
REFIT_VOLUME *Volume;
|
2020-08-09 17:55:30 +02:00
|
|
|
XStringW VolName;
|
2020-03-10 10:45:17 +01:00
|
|
|
EFI_DEVICE_PATH *DevicePath;
|
|
|
|
UINT16 Flags;
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-08-11 14:43:53 +02:00
|
|
|
REFIT_MENU_ENTRY_CLOVER() : REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(), Volume(NULL), VolName(), DevicePath(NULL), Flags(0) {};
|
|
|
|
REFIT_MENU_ENTRY_CLOVER(const REFIT_MENU_ENTRY_CLOVER&) = delete;
|
|
|
|
REFIT_MENU_ENTRY_CLOVER& operator=(const REFIT_MENU_ENTRY_CLOVER&) = delete;
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
REFIT_MENU_ENTRY_CLOVER* getPartiallyDuplicatedEntry() const;
|
|
|
|
virtual REFIT_MENU_ENTRY_CLOVER* getREFIT_MENU_ENTRY_CLOVER() { return this; };
|
|
|
|
};
|
2020-02-29 08:30:21 +01:00
|
|
|
|
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
//--------------------------------------- REFIT_MENU_ITEM_BOOTNUM ---------------------------------------//
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
class REFIT_MENU_ITEM_BOOTNUM : public REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
REFIT_VOLUME *Volume;
|
|
|
|
UINTN BootNum;
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 11:00:17 +01:00
|
|
|
REFIT_MENU_ITEM_BOOTNUM() : REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(), Volume(NULL), BootNum(0) {};
|
2020-08-11 14:43:53 +02:00
|
|
|
REFIT_MENU_ITEM_BOOTNUM(const REFIT_MENU_ITEM_BOOTNUM&) = delete;
|
|
|
|
REFIT_MENU_ITEM_BOOTNUM& operator=(const REFIT_MENU_ITEM_BOOTNUM&) = delete;
|
2020-03-10 10:45:17 +01:00
|
|
|
virtual REFIT_MENU_ITEM_BOOTNUM* getREFIT_MENU_ITEM_BOOTNUM() { return this; };
|
|
|
|
} ;
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-05 12:49:47 +01:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
//--------------------------------------- LEGACY_ENTRY ---------------------------------------//
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
class LEGACY_ENTRY : public REFIT_MENU_ITEM_BOOTNUM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LEGACY_ENTRY() : REFIT_MENU_ITEM_BOOTNUM() {};
|
2020-05-01 18:26:28 +02:00
|
|
|
|
2020-05-16 22:07:27 +02:00
|
|
|
void StartLegacy();
|
2020-02-29 08:30:21 +01:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
virtual LEGACY_ENTRY* getLEGACY_ENTRY() { return this; };
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------- LOADER_ENTRY ---------------------------------------//
|
|
|
|
|
|
|
|
class LOADER_ENTRY : public REFIT_MENU_ITEM_BOOTNUM
|
|
|
|
{
|
|
|
|
public:
|
2020-08-07 10:23:46 +02:00
|
|
|
XStringW APFSTargetUUID;
|
|
|
|
|
2020-08-27 20:47:56 +02:00
|
|
|
XStringW DisplayedVolName;
|
2020-03-10 10:45:17 +01:00
|
|
|
EFI_DEVICE_PATH *DevicePath;
|
|
|
|
UINT16 Flags;
|
|
|
|
UINT8 LoaderType;
|
2021-01-31 10:50:23 +01:00
|
|
|
MacOsVersion macOSVersion;
|
2020-08-12 17:15:47 +02:00
|
|
|
XString8 BuildVersion;
|
2022-03-06 11:42:12 +01:00
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor;
|
2020-04-01 14:57:32 +02:00
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
UINT8 CustomBoot;
|
2020-04-11 14:34:59 +02:00
|
|
|
XImage CustomLogo;
|
2020-08-11 14:43:53 +02:00
|
|
|
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches;
|
2020-08-09 17:55:30 +02:00
|
|
|
XStringW Settings;
|
2020-05-09 09:56:30 +02:00
|
|
|
UINT8 *KernelData;
|
2020-05-01 18:26:28 +02:00
|
|
|
UINT32 AddrVtable;
|
|
|
|
UINT32 SizeVtable;
|
|
|
|
UINT32 NamesTable;
|
2020-05-02 05:38:38 +02:00
|
|
|
INT32 SegVAddr;
|
|
|
|
INT32 shift;
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool PatcherInited;
|
|
|
|
XBool gSNBEAICPUFixRequire; // SandyBridge-E AppleIntelCpuPowerManagement patch require or not
|
|
|
|
XBool gBDWEIOPCIFixRequire; // Broadwell-E IOPCIFamily fix require or not
|
|
|
|
XBool isKernelcache;
|
|
|
|
XBool is64BitKernel;
|
2020-05-11 17:44:00 +02:00
|
|
|
UINT32 KernelSlide;
|
2020-07-17 22:45:01 +02:00
|
|
|
UINT32 KernelOffset;
|
2020-05-11 17:44:00 +02:00
|
|
|
// notes:
|
|
|
|
// - 64bit segCmd64->vmaddr is 0xffffff80xxxxxxxx and we are taking
|
|
|
|
// only lower 32bit part into PrelinkTextAddr
|
|
|
|
// - PrelinkTextAddr is segCmd64->vmaddr + KernelRelocBase
|
|
|
|
UINT32 PrelinkTextLoadCmdAddr;
|
|
|
|
UINT32 PrelinkTextAddr;
|
|
|
|
UINT32 PrelinkTextSize;
|
|
|
|
|
|
|
|
// notes:
|
|
|
|
// - 64bit sect->addr is 0xffffff80xxxxxxxx and we are taking
|
2020-07-24 20:59:51 +02:00
|
|
|
// only lower 32bit part into PrelinkInfoAddr ... Why???
|
2020-05-11 17:44:00 +02:00
|
|
|
// - PrelinkInfoAddr is sect->addr + KernelRelocBase
|
|
|
|
UINT32 PrelinkInfoLoadCmdAddr;
|
|
|
|
UINT32 PrelinkInfoAddr;
|
|
|
|
UINT32 PrelinkInfoSize;
|
|
|
|
EFI_PHYSICAL_ADDRESS KernelRelocBase;
|
|
|
|
BootArgs1 *bootArgs1;
|
|
|
|
BootArgs2 *bootArgs2;
|
|
|
|
CHAR8 *dtRoot;
|
|
|
|
UINT32 *dtLength;
|
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
|
2020-03-10 11:00:17 +01:00
|
|
|
LOADER_ENTRY()
|
2021-01-31 10:50:23 +01:00
|
|
|
: REFIT_MENU_ITEM_BOOTNUM(), APFSTargetUUID(), DisplayedVolName(), DevicePath(0), Flags(0), LoaderType(0), macOSVersion(), BuildVersion(),
|
2020-04-10 12:04:21 +02:00
|
|
|
BootBgColor({0,0,0,0}),
|
2020-08-27 20:47:56 +02:00
|
|
|
CustomBoot(0), CustomLogo(), KernelAndKextPatches(), Settings(), KernelData(0),
|
2020-08-11 14:43:53 +02:00
|
|
|
AddrVtable(0), SizeVtable(0), NamesTable(0), SegVAddr(0), shift(0),
|
2020-05-11 17:44:00 +02:00
|
|
|
PatcherInited(false), gSNBEAICPUFixRequire(false), gBDWEIOPCIFixRequire(false), isKernelcache(false), is64BitKernel(false),
|
2020-07-17 22:45:01 +02:00
|
|
|
KernelSlide(0), KernelOffset(0), PrelinkTextLoadCmdAddr(0), PrelinkTextAddr(0), PrelinkTextSize(0),
|
2020-05-11 17:44:00 +02:00
|
|
|
PrelinkInfoLoadCmdAddr(0), PrelinkInfoAddr(0), PrelinkInfoSize(0),
|
|
|
|
KernelRelocBase(0), bootArgs1(0), bootArgs2(0), dtRoot(0), dtLength(0)
|
2020-03-10 11:00:17 +01:00
|
|
|
{};
|
2020-08-11 14:43:53 +02:00
|
|
|
LOADER_ENTRY(const LOADER_ENTRY&) = delete;
|
|
|
|
LOADER_ENTRY& operator=(const LOADER_ENTRY&) = delete;
|
2020-10-03 19:02:31 +02:00
|
|
|
~LOADER_ENTRY() {};
|
2020-05-01 18:26:28 +02:00
|
|
|
|
2020-05-16 22:07:27 +02:00
|
|
|
void SetKernelRelocBase();
|
|
|
|
void FindBootArgs();
|
2020-05-09 09:56:30 +02:00
|
|
|
EFI_STATUS getVTable();
|
2020-05-16 22:07:27 +02:00
|
|
|
void Get_PreLink();
|
2020-07-24 20:59:51 +02:00
|
|
|
UINT32 Get_Symtab(UINT8* binary);
|
|
|
|
UINT32 GetTextExec();
|
2020-08-12 17:15:47 +02:00
|
|
|
UINTN searchProc(const XString8& procedure);
|
|
|
|
UINTN searchProcInDriver(UINT8 * driver, UINT32 driverLen, const XString8& procedure);
|
2020-07-23 21:14:20 +02:00
|
|
|
UINT32 searchSectionByNum(UINT8 * Binary, UINT32 Num);
|
2021-03-22 13:40:01 +01:00
|
|
|
// void KernelAndKextsPatcherStart();
|
|
|
|
// void KernelAndKextPatcherInit();
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool KernelUserPatch();
|
|
|
|
XBool KernelPatchPm();
|
|
|
|
XBool KernelLapicPatch_32();
|
|
|
|
XBool KernelLapicPatch_64();
|
|
|
|
XBool BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize);
|
2020-05-16 22:07:27 +02:00
|
|
|
void EFIAPI KernelBooterExtensionsPatch();
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool KernelPanicNoKextDump();
|
2020-05-16 22:07:27 +02:00
|
|
|
void KernelCPUIDPatch();
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool PatchCPUID(const UINT8* Location, INT32 LenLoc,
|
2020-05-06 08:21:30 +02:00
|
|
|
const UINT8* Search4, const UINT8* Search10, const UINT8* ReplaceModel,
|
|
|
|
const UINT8* ReplaceExt, INT32 Len);
|
2020-05-16 22:07:27 +02:00
|
|
|
void KernelPatcher_32();
|
|
|
|
// void KernelPatcher_64();
|
|
|
|
void FilterKernelPatches();
|
|
|
|
void FilterKextPatches();
|
|
|
|
void FilterBootPatches();
|
|
|
|
void applyKernPatch(const UINT8 *find, UINTN size, const UINT8 *repl, const CHAR8 *comment);
|
2020-05-01 18:26:28 +02:00
|
|
|
|
|
|
|
EFI_STATUS SetFSInjection();
|
2022-03-06 07:42:49 +01:00
|
|
|
// EFI_STATUS InjectKexts(IN UINT32 deviceTreeP, IN UINT32 *deviceTreeLength);
|
2020-11-12 22:25:56 +01:00
|
|
|
// EFI_STATUS LoadKexts();
|
2020-07-20 10:52:36 +02:00
|
|
|
// int is_mkext_v1(UINT8* drvPtr);
|
|
|
|
// void patch_mkext_v1(UINT8 *drvPtr); //not used
|
2020-05-16 21:30:29 +02:00
|
|
|
|
2022-03-06 07:42:49 +01:00
|
|
|
// EFI_STATUS LoadKext(const EFI_FILE *RootDir, const XString8& FileName, IN cpu_type_t archCpuType, IN OUT void *kext);
|
|
|
|
// EFI_STATUS AddKext(const EFI_FILE *RootDir, const XString8& FileName, IN cpu_type_t archCpuType);
|
|
|
|
// void LoadPlugInKexts(const EFI_FILE *RootDir, const XString8& DirName, IN cpu_type_t archCpuType, IN XBool Force);
|
2020-09-14 15:01:30 +02:00
|
|
|
// void AddKexts(const XStringW& SrcDir, const XStringW& Path, cpu_type_t archCpuType);
|
2021-01-31 10:50:23 +01:00
|
|
|
void AddKextsFromDirInArray(const XString8& SrcDir, cpu_type_t archCpuType, XObjArray<SIDELOAD_KEXT>* kextArray);
|
2020-09-16 01:01:53 +02:00
|
|
|
void AddKextsInArray(XObjArray<SIDELOAD_KEXT>* kextArray);
|
2022-03-06 07:42:49 +01:00
|
|
|
void AddForceKextsInArray(XObjArray<SIDELOAD_KEXT>* kextArray);
|
2020-05-16 22:07:27 +02:00
|
|
|
void KextPatcherRegisterKexts(void *FSInject, void *ForceLoadKexts);
|
|
|
|
void KextPatcherStart();
|
|
|
|
void PatchPrelinkedKexts();
|
|
|
|
void PatchLoadedKexts();
|
|
|
|
void PatchKext(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
|
2020-08-12 17:15:47 +02:00
|
|
|
void AnyKextPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize, size_t N);
|
2020-05-16 22:07:27 +02:00
|
|
|
void ATIConnectorsPatchInit();
|
|
|
|
void ATIConnectorsPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
|
|
|
|
void ATIConnectorsPatchRegisterKexts(void *FSInject_v, void *ForceLoadKexts_v);
|
|
|
|
void AppleIntelCPUPMPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
|
|
|
|
void AppleRTCPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize);
|
2020-07-21 11:17:02 +02:00
|
|
|
// void CheckForFakeSMC(CHAR8 *InfoPlist);
|
2020-05-16 22:07:27 +02:00
|
|
|
void DellSMBIOSPatch(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);
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool SandyBridgeEPM();
|
|
|
|
XBool HaswellEXCPM();
|
|
|
|
XBool HaswellLowEndXCPM();
|
|
|
|
XBool BroadwellEPM();
|
|
|
|
XBool KernelIvyBridgeXCPM();
|
|
|
|
XBool KernelIvyE5XCPM();
|
2020-05-27 20:04:31 +02:00
|
|
|
void EightApplePatch(UINT8 *Driver, UINT32 DriverSize);
|
2020-05-01 18:26:28 +02:00
|
|
|
|
2020-08-11 14:43:53 +02:00
|
|
|
void Stall(int Pause) { if ( KernelAndKextPatches.KPDebug ) { gBS->Stall(Pause); } };
|
2020-05-16 22:07:27 +02:00
|
|
|
void StartLoader();
|
|
|
|
void AddDefaultMenu();
|
2020-03-10 10:45:17 +01:00
|
|
|
LOADER_ENTRY* getPartiallyDuplicatedEntry() const;
|
|
|
|
virtual LOADER_ENTRY* getLOADER_ENTRY() { return this; };
|
2020-05-17 20:56:10 +02:00
|
|
|
LOADER_ENTRY* SubMenuKextInjectMgmt();
|
2020-10-12 13:48:50 +02:00
|
|
|
void DelegateKernelPatches();
|
2020-10-14 18:08:32 +02:00
|
|
|
|
2021-09-28 10:28:45 +02:00
|
|
|
XBool checkOSBundleRequired(const TagDict* dict);
|
2022-03-08 17:48:52 +01:00
|
|
|
XStringW getKextPlist(const EFI_FILE* Root, const XStringW& dirPath, const XStringW& FileName, XBool* NoContents);
|
|
|
|
TagDict* getInfoPlist(const EFI_FILE* Root, const XStringW& infoPlistPath);
|
|
|
|
XString8 getKextExecPath(const EFI_FILE* Root, const XStringW& dirPath, const XStringW& FileName, TagDict* dict, XBool NoContents);
|
2020-03-10 10:45:17 +01:00
|
|
|
} ;
|
2020-02-29 08:30:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
|
|
|
|
EOF */
|