@@ -432,18 +432,27 @@ VOID LOADER_ENTRY::AppleIntelCPUPMPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8
432
432
UINTN Index1;
433
433
UINTN Index2;
434
434
UINTN Count = 0 ;
435
+ UINTN Start = 0 ;
436
+ UINTN Size = DriverSize;
435
437
436
438
DBG_RT (" \n AppleIntelCPUPMPatch: driverAddr = %llx, driverSize = %x\n " , (UINTN)Driver, DriverSize);
437
- if (KernelAndKextPatches->KPDebug ) {
438
- ExtractKextBundleIdentifier (InfoPlist);
439
- }
440
- DBG_RT (" Kext: %s\n " , gKextBundleIdentifier );
439
+ // if (KernelAndKextPatches->KPDebug) {
440
+ // ExtractKextBundleIdentifier(InfoPlist);
441
+ // }
442
+ // DBG_RT("Kext: %s\n", gKextBundleIdentifier);
441
443
442
444
// we should scan only __text __TEXT | Slice -> do this
443
- UINTN textName = FindMem (Driver, DriverSize, kPrelinkTextSection , sizeof (kPrelinkTextSection ));
444
- SEGMENT *textSeg = (SEGMENT *)&Driver[textName];
445
- UINTN Start = textSeg->fileoff ;
446
- UINTN Size = textSeg->filesize ;
445
+ INTN textName = FindMem (Driver, DriverSize, kPrelinkTextSection , sizeof (kPrelinkTextSection ));
446
+ if (textName > 0 ) {
447
+ SEGMENT *textSeg = (SEGMENT *)&Driver[textName];
448
+ Start = textSeg->fileoff ;
449
+ Size = textSeg->filesize ;
450
+ DBG (" found __text [%d,%d]\n " ,Start, Size );
451
+ if (Start > DriverSize) Start = 0 ;
452
+ if (Size > DriverSize) {
453
+ Size = DriverSize;
454
+ }
455
+ }
447
456
448
457
for (Index1 = Start; Index1 < Start + Size ; Index1++) {
449
458
// search for MovlE2ToEcx
0 commit comments