Skip to content

Commit e8afa4c

Browse files
committed
KernelAndKextPatches will be global only now
Signed-off-by: Slice <sergey.slice@gmail.com>
1 parent 956ee0a commit e8afa4c

20 files changed

Lines changed: 299 additions & 258 deletions

File tree

Clover.dsc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@
641641
}
642642
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
643643
MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
644-
MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
644+
#MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
645645
#MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
646646
CloverEFI/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
647647
#MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
@@ -1026,7 +1026,6 @@ rEFIt_UEFI/refit.inf {
10261026
DEFINE XLTO_FLAG = -flto -DUSING_LTO
10271027
!endif
10281028

1029-
10301029
!ifdef EXIT_USBKB
10311030
DEFINE EXIT_USBKB_FLAG = -DEXIT_USBKB
10321031
!endif
@@ -1039,8 +1038,6 @@ DEFINE JIEF_DEBUG_FLAG = -DJIEF_DEBUG
10391038
DEFINE LESS_DEBUG_FLAG = -DLESS_DEBUG
10401039
!endif
10411040

1042-
1043-
10441041
!ifdef ENABLE_MODERN_CPU_QUIRKS
10451042
DEFINE ENABLE_MODERN_CPU_QUIRKS_FLAG = -DENABLE_MODERN_CPU_QUIRKS
10461043
!endif
@@ -1056,7 +1053,7 @@ DEFINE BUILD_OPTIONS=-DIS_UEFI_MODULE -DMDEPKG_NDEBUG -DCLOVER_BUILD -DLESS_DEBU
10561053

10571054
XCODE:*_*_*_CC_FLAGS = -std=c11 -fno-unwind-tables $(BUILD_OPTIONS) $(XLTO_FLAG)
10581055
XCODE:*_*_*_CXX_FLAGS = -std=c++11 -fno-unwind-tables $(BUILD_OPTIONS) $(XLTO_FLAG)
1059-
GCC:*_*_*_CC_FLAGS = -std=c11 $(BUILD_OPTIONS) $(LTO_FLAG) -Wno-error
1060-
GCC:*_*_*_CXX_FLAGS = -std=c++11 $(BUILD_OPTIONS) $(LTO_FLAG) -Wno-error
1056+
GCC:*_*_*_CC_FLAGS = -std=c11 $(BUILD_OPTIONS) $(LTO_FLAG)
1057+
GCC:*_*_*_CXX_FLAGS = -std=c++11 $(BUILD_OPTIONS) $(LTO_FLAG)
10611058
#-fanalyzer -Wmismatched-tags
10621059
#-Weffc++

Clover.fdf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
9191
INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
9292
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
9393
INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
94-
INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
94+
#INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
9595

9696
#INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
9797
INF CloverEFI/GraphicsConsoleDxe/GraphicsConsoleDxe.inf

CloverEFI/OsxBdsDxe/BdsDxe.inf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,10 @@
239239
[UserExtensions.TianoCore."ExtraFiles"]
240240
BdsDxeExtra.uni
241241

242+
[BuildOptions]
243+
244+
# -fno-rtti is only for C++
245+
246+
XCODE:*_*_*_CC_FLAGS = -fno-use-cxa-atexit -fno-omit-frame-pointer -fno-exceptions -DJCONST=CONST -Wno-incompatible-ms-struct #-Wunused-parameter
247+
248+
GCC:*_*_*_CC_FLAGS = -fno-omit-frame-pointer -DJCONST=CONST -fno-lto

rEFIt_UEFI/Platform/Settings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ CUSTOM_LOADER_ENTRY::CUSTOM_LOADER_ENTRY(const CUSTOM_LOADER_ENTRY_SETTINGS& _se
142142
SubEntries.AddReference(entry, true);
143143
}
144144

145-
KernelAndKextPatches = gSettings.KernelAndKextPatches; // Jief : why do we have a duplicated KernelAndKextPatches var inside CUSTOM_LOADER_ENTRY ?
146-
145+
// KernelAndKextPatches = gSettings.KernelAndKextPatches; // Jief : why do we have a duplicated KernelAndKextPatches var inside CUSTOM_LOADER_ENTRY ?
146+
KPDebug = gSettings.KernelAndKextPatches.KPDebug;
147147
}
148148

149149
XString8Array CUSTOM_LOADER_SUBENTRY::getLoadOptions() const

rEFIt_UEFI/Platform/Settings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ class CUSTOM_LOADER_ENTRY {
440440
XIcon DriveImage = XIcon();
441441
XImage CustomLogoImage = XImage(); // Todo : remove from settings.
442442
UINT8 CustomLogoType = 0;
443-
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches = KERNEL_AND_KEXT_PATCHES();
443+
// KERNEL_AND_KEXT_PATCHES KernelAndKextPatches = KERNEL_AND_KEXT_PATCHES();
444+
XBool KPDebug = false;
444445

445446
CUSTOM_LOADER_ENTRY(const CUSTOM_LOADER_ENTRY_SETTINGS &_settings);
446447

rEFIt_UEFI/Platform/ati.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ XBool get_model_val(value_t *val, INTN index, XBool Sier)
15371537
//static CONST UINT32 ctd[] = {0x04, 0x10, 0x800, 0x400}; //desktop
15381538
//static UINT32 cti = 0;
15391539

1540-
KERNEL_AND_KEXT_PATCHES *CurrentPatches;
1540+
//KERNEL_AND_KEXT_PATCHES *CurrentPatches;
15411541

15421542
//TODO - get connectors from ATIConnectorsPatch
15431543
XBool get_conntype_val(value_t *val, INTN index, XBool Sier)
@@ -1551,10 +1551,11 @@ XBool get_conntype_val(value_t *val, INTN index, XBool Sier)
15511551
//0x400: DisplayPort
15521552
//0x02: LVDS
15531553

1554-
if ((CurrentPatches == NULL) || (CurrentPatches->KPATIConnectorsData.isEmpty())) {
1555-
return false;
1556-
}
1557-
ct = CurrentPatches->KPATIConnectorsPatch.data();
1554+
// if ((CurrentPatches == NULL) || (CurrentPatches->KPATIConnectorsData.isEmpty())) {
1555+
// return false;
1556+
// }
1557+
// ct = CurrentPatches->KPATIConnectorsPatch.data();
1558+
ct = gSettings.KernelAndKextPatches.KPATIConnectorsPatch.data();
15581559
Len = Sier?24:16;
15591560

15601561
/* if (gMobile) {
@@ -2246,7 +2247,7 @@ XBool setup_ati_devprop(LOADER_ENTRY *Entry, pci_dt_t *ati_dev)
22462247
if (!init_card(ati_dev)) {
22472248
return false;
22482249
}
2249-
CurrentPatches = &Entry->KernelAndKextPatches;
2250+
// CurrentPatches = &Entry->KernelAndKextPatches;
22502251

22512252
// -------------------------------------------------
22522253
// Find a better way to do this (in device_inject.c)

rEFIt_UEFI/Platform/kernel_patcher.cpp

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,8 @@ XBool LOADER_ENTRY::PatchCPUID(const UINT8* Location, INT32 LenLoc,
825825
INT32 patchLocation=0, patchLocation1=0;
826826
INT32 Adr = 0, Num;
827827
XBool Patched = false;
828-
UINT8 FakeModel = (KernelAndKextPatches.FakeCPUID >> 4) & 0x0f;
829-
UINT8 FakeExt = (KernelAndKextPatches.FakeCPUID >> 0x10) & 0x0f;
828+
UINT8 FakeModel = (gSettings.KernelAndKextPatches.FakeCPUID >> 4) & 0x0f;
829+
UINT8 FakeExt = (gSettings.KernelAndKextPatches.FakeCPUID >> 0x10) & 0x0f;
830830
for (Num = 0; Num < 2; Num++) {
831831
Adr = FindBin(&KernelData[Adr], 0x800000 - Adr, Location, (UINT32)LenLoc);
832832
if (Adr < 0) {
@@ -1478,7 +1478,7 @@ XBool LOADER_ENTRY::BroadwellEPM()
14781478
return false;
14791479
}
14801480

1481-
KernelAndKextPatches.FakeCPUID = (UINT32)(macOSVersion.notEmpty() && macOSVersion < MacOsVersion("10.10.3"_XS8) ? 0x0306C0 : 0x040674);
1481+
gSettings.KernelAndKextPatches.FakeCPUID = (UINT32)(macOSVersion.notEmpty() && macOSVersion < MacOsVersion("10.10.3"_XS8) ? 0x0306C0 : 0x040674);
14821482
KernelCPUIDPatch();
14831483

14841484
DBG("Searching _xcpm_pkg_scope_msr ...\n");
@@ -1535,7 +1535,7 @@ XBool LOADER_ENTRY::HaswellLowEndXCPM()
15351535
return false;
15361536
}
15371537

1538-
KernelAndKextPatches.FakeCPUID = (UINT32)(0x0306A0); // correct FakeCPUID
1538+
gSettings.KernelAndKextPatches.FakeCPUID = (UINT32)(0x0306A0); // correct FakeCPUID
15391539
KernelCPUIDPatch();
15401540

15411541
// 10.8.5 - 10.11.x no need the following kernel patches on Haswell Celeron/Pentium
@@ -2361,19 +2361,19 @@ LOADER_ENTRY::KernelUserPatch()
23612361
// while config patches go to gSettings.KernelAndKextPatches
23622362
// how to resolve it?
23632363

2364-
for (size_t i = 0 ; i < KernelAndKextPatches.KernelPatches.size(); ++i) {
2365-
DBG( "Patch[%zu]: %s\n", i, KernelAndKextPatches.KernelPatches[i].Label.c_str());
2366-
if (!KernelAndKextPatches.KernelPatches[i].MenuItem.BValue) {
2364+
for (size_t i = 0 ; i < gSettings.KernelAndKextPatches.KernelPatches.size(); ++i) {
2365+
DBG( "Patch[%zu]: %s\n", i, gSettings.KernelAndKextPatches.KernelPatches[i].Label.c_str());
2366+
if (!gSettings.KernelAndKextPatches.KernelPatches[i].MenuItem.BValue) {
23672367
//DBG_RT( "Patch[%d]: %a :: is not allowed for booted OS %a\n", i, KernelAndKextPatches.KernelPatches[i].Label, macOSVersion);
23682368
DBG( "==> disabled\n");
23692369
continue;
23702370
}
23712371
// if we modify directly KernelAndKextPatches.KernelPatches[i].SearchLen, it will wrong for next driver
2372-
UINTN SearchLen = KernelAndKextPatches.KernelPatches[i].SearchLen;
2372+
UINTN SearchLen = gSettings.KernelAndKextPatches.KernelPatches[i].SearchLen;
23732373
XBool once = false;
23742374
UINTN procLen = 0;
2375-
UINTN procAddr = searchProc(KernelAndKextPatches.KernelPatches[i].ProcedureName);
2376-
DBG("procedure %s found at 0x%llx\n", KernelAndKextPatches.KernelPatches[i].ProcedureName.c_str(), procAddr);
2375+
UINTN procAddr = searchProc(gSettings.KernelAndKextPatches.KernelPatches[i].ProcedureName);
2376+
DBG("procedure %s found at 0x%llx\n", gSettings.KernelAndKextPatches.KernelPatches[i].ProcedureName.c_str(), procAddr);
23772377
if (SearchLen == 0) {
23782378
SearchLen = KERNEL_MAX_SIZE;
23792379
procLen = KERNEL_MAX_SIZE - procAddr;
@@ -2384,37 +2384,37 @@ LOADER_ENTRY::KernelUserPatch()
23842384
UINT8 * curs = &KernelData[procAddr];
23852385
UINTN j = 0;
23862386
while (j < KERNEL_MAX_SIZE) {
2387-
if (KernelAndKextPatches.KernelPatches[i].StartPattern.isEmpty() || //old behavior
2387+
if (gSettings.KernelAndKextPatches.KernelPatches[i].StartPattern.isEmpty() || //old behavior
23882388
CompareMemMask((const UINT8*)curs,
2389-
KernelAndKextPatches.KernelPatches[i].StartPattern.data(),
2390-
KernelAndKextPatches.KernelPatches[i].StartPattern.size(),
2391-
KernelAndKextPatches.KernelPatches[i].StartMask.data(),
2392-
KernelAndKextPatches.KernelPatches[i].StartPattern.size())) {
2389+
gSettings.KernelAndKextPatches.KernelPatches[i].StartPattern.data(),
2390+
gSettings.KernelAndKextPatches.KernelPatches[i].StartPattern.size(),
2391+
gSettings.KernelAndKextPatches.KernelPatches[i].StartMask.data(),
2392+
gSettings.KernelAndKextPatches.KernelPatches[i].StartPattern.size())) {
23932393
DBG( " StartPattern found\n");
23942394
Num = SearchAndReplaceMask(curs,
23952395
procLen,
2396-
(const UINT8*)KernelAndKextPatches.KernelPatches[i].Find.data(),
2397-
(const UINT8*)KernelAndKextPatches.KernelPatches[i].MaskFind.data(),
2398-
KernelAndKextPatches.KernelPatches[i].Find.size(),
2399-
(const UINT8*)KernelAndKextPatches.KernelPatches[i].Replace.data(),
2400-
(const UINT8*)KernelAndKextPatches.KernelPatches[i].MaskReplace.data(),
2401-
KernelAndKextPatches.KernelPatches[i].Count,
2402-
KernelAndKextPatches.KernelPatches[i].Skip);
2396+
(const UINT8*)gSettings.KernelAndKextPatches.KernelPatches[i].Find.data(),
2397+
(const UINT8*)gSettings.KernelAndKextPatches.KernelPatches[i].MaskFind.data(),
2398+
gSettings.KernelAndKextPatches.KernelPatches[i].Find.size(),
2399+
(const UINT8*)gSettings.KernelAndKextPatches.KernelPatches[i].Replace.data(),
2400+
(const UINT8*)gSettings.KernelAndKextPatches.KernelPatches[i].MaskReplace.data(),
2401+
gSettings.KernelAndKextPatches.KernelPatches[i].Count,
2402+
gSettings.KernelAndKextPatches.KernelPatches[i].Skip);
24032403

24042404
if (Num) {
24052405
y++;
24062406
curs += SearchLen - 1;
24072407
j += SearchLen - 1;
24082408
}
24092409
DBG( "==> %s : %lld replaces done\n", Num ? "Success" : "Error", Num);
2410-
if ( once || KernelAndKextPatches.KernelPatches[i].StartPattern.isEmpty() ) {
2410+
if ( once || gSettings.KernelAndKextPatches.KernelPatches[i].StartPattern.isEmpty() ) {
24112411
break;
24122412
}
24132413
}
24142414
j++; curs++;
24152415
}
24162416
}
2417-
if (KernelAndKextPatches.KPDebug) {
2417+
if (gSettings.KernelAndKextPatches.KPDebug) {
24182418
gBS->Stall(2000000);
24192419
}
24202420

@@ -2427,54 +2427,54 @@ LOADER_ENTRY::BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize)
24272427
INTN Num, y = 0;
24282428

24292429

2430-
for (size_t i = 0 ; i < KernelAndKextPatches.BootPatches.size(); ++i)
2430+
for (size_t i = 0 ; i < gSettings.KernelAndKextPatches.BootPatches.size(); ++i)
24312431
{
24322432
// if we modify directly KernelAndKextPatches.BootPatches[i].SearchLen, it will wrong for next driver
2433-
UINTN SearchLen = KernelAndKextPatches.BootPatches[i].SearchLen;
2433+
UINTN SearchLen = gSettings.KernelAndKextPatches.BootPatches[i].SearchLen;
24342434
if (!SearchLen) {
24352435
SearchLen = BooterSize;
24362436
}
24372437

2438-
DBG( "Patch[%zu]: %s\n", i, KernelAndKextPatches.BootPatches[i].Label.c_str());
2439-
if (!KernelAndKextPatches.BootPatches[i].MenuItem.BValue) {
2438+
DBG( "Patch[%zu]: %s\n", i, gSettings.KernelAndKextPatches.BootPatches[i].Label.c_str());
2439+
if (!gSettings.KernelAndKextPatches.BootPatches[i].MenuItem.BValue) {
24402440
DBG( "==> disabled\n");
24412441
continue;
24422442
}
24432443
UINT8 * curs = BooterData;
24442444
UINTN j = 0;
24452445
while (j < BooterSize) {
2446-
if (KernelAndKextPatches.BootPatches[i].StartPattern.isEmpty() || //old behavior
2446+
if (gSettings.KernelAndKextPatches.BootPatches[i].StartPattern.isEmpty() || //old behavior
24472447
CompareMemMask((const UINT8*)curs,
2448-
(const UINT8*)KernelAndKextPatches.BootPatches[i].StartPattern.data(),
2449-
KernelAndKextPatches.BootPatches[i].StartPattern.size(),
2450-
(const UINT8*)KernelAndKextPatches.BootPatches[i].StartMask.data(),
2451-
KernelAndKextPatches.BootPatches[i].StartPattern.size())) {
2448+
(const UINT8*)gSettings.KernelAndKextPatches.BootPatches[i].StartPattern.data(),
2449+
gSettings.KernelAndKextPatches.BootPatches[i].StartPattern.size(),
2450+
(const UINT8*)gSettings.KernelAndKextPatches.BootPatches[i].StartMask.data(),
2451+
gSettings.KernelAndKextPatches.BootPatches[i].StartPattern.size())) {
24522452
DBG( " StartPattern found\n");
24532453

24542454
Num = SearchAndReplaceMask(curs,
24552455
SearchLen,
2456-
(const UINT8*)KernelAndKextPatches.BootPatches[i].Find.data(),
2457-
(const UINT8*)KernelAndKextPatches.BootPatches[i].MaskFind.data(),
2458-
KernelAndKextPatches.BootPatches[i].Find.size(),
2459-
(const UINT8*)KernelAndKextPatches.BootPatches[i].Replace.data(),
2460-
(const UINT8*)KernelAndKextPatches.BootPatches[i].MaskReplace.data(),
2461-
KernelAndKextPatches.BootPatches[i].Count,
2462-
KernelAndKextPatches.BootPatches[i].Skip);
2456+
(const UINT8*)gSettings.KernelAndKextPatches.BootPatches[i].Find.data(),
2457+
(const UINT8*)gSettings.KernelAndKextPatches.BootPatches[i].MaskFind.data(),
2458+
gSettings.KernelAndKextPatches.BootPatches[i].Find.size(),
2459+
(const UINT8*)gSettings.KernelAndKextPatches.BootPatches[i].Replace.data(),
2460+
(const UINT8*)gSettings.KernelAndKextPatches.BootPatches[i].MaskReplace.data(),
2461+
gSettings.KernelAndKextPatches.BootPatches[i].Count,
2462+
gSettings.KernelAndKextPatches.BootPatches[i].Skip);
24632463
if (Num) {
24642464
y++;
24652465
curs += SearchLen - 1;
24662466
j += SearchLen - 1;
24672467
}
24682468

24692469
DBG( "==> %s : %lld replaces done\n", Num ? "Success" : "Error", Num);
2470-
if ( KernelAndKextPatches.BootPatches[i].StartPattern.isEmpty() ) {
2470+
if ( gSettings.KernelAndKextPatches.BootPatches[i].StartPattern.isEmpty() ) {
24712471
break;
24722472
}
24732473
}
24742474
j++; curs++;
24752475
}
24762476
}
2477-
if (KernelAndKextPatches.KPDebug) {
2477+
if (gSettings.KernelAndKextPatches.KPDebug) {
24782478
gBS->Stall(2000000);
24792479
}
24802480
return (y != 0);

rEFIt_UEFI/Platform/kernel_patcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "boot.h"
1010

1111
//#define DBG_RT( ...) if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPDebug) { printf(__VA_ARGS__); }
12-
#define DBG_RT(...) if ( KernelAndKextPatches.KPDebug ) { printf(__VA_ARGS__); }
12+
#define DBG_RT(...) if ( gSettings.KernelAndKextPatches.KPDebug ) { printf(__VA_ARGS__); }
1313

1414

1515
#define CPUFAMILY_INTEL_6_13 0xaa33392b

0 commit comments

Comments
 (0)