@@ -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 );
0 commit comments