Skip to content

Commit 8f5a461

Browse files
committed
dont hang on AICPUPM patch
Signed-off-by: SergeySlice <sergey.slice@gmail.com>
1 parent 562e571 commit 8f5a461

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

rEFIt_UEFI/Platform/kext_patcher.cpp

+17-8
Original file line numberDiff line numberDiff line change
@@ -432,18 +432,27 @@ VOID LOADER_ENTRY::AppleIntelCPUPMPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8
432432
UINTN Index1;
433433
UINTN Index2;
434434
UINTN Count = 0;
435+
UINTN Start = 0;
436+
UINTN Size = DriverSize;
435437

436438
DBG_RT("\nAppleIntelCPUPMPatch: 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);
441443

442444
// 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+
}
447456

448457
for (Index1 = Start; Index1 < Start + Size; Index1++) {
449458
// search for MovlE2ToEcx

0 commit comments

Comments
 (0)