Skip to content

Commit 16d70cd

Browse files
committed
Fix incorrect slide for 32-bit kexts
1 parent 17bf69d commit 16d70cd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Lilu/Sources/kern_mach.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,16 @@ kern_return_t MachInfo::getRunningAddresses(mach_vm_address_t slide, size_t size
971971
if (!strncmp(sect->sectname, "__text", sizeof(sect->sectname))) {
972972
running_text_addr = sect->addr;
973973
running_mh = mh;
974+
975+
// MH_OBJECT may have a file offset, align to the next page and add to the slide.
976+
slide += alignValue(sect->offset);
974977
break;
975978
}
976979
}
977980
}
981+
982+
if (running_text_addr)
983+
break;
978984
#endif
979985
}
980986
addr += loadCmd->cmdsize;

Lilu/Sources/kern_patcher.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,8 @@ void KernelPatcher::onOSKextSaveLoadedKextPanicList() {
761761
} else {
762762
kmod_info_t *kmod = *that->kextKmods;
763763
if (kmod) {
764-
DBGLOG("patcher", "newly loaded kext is " PRIKADDR " and its name is %.*s", CASTKADDR((uint64_t)kmod->address), KMOD_MAX_NAME, kmod->name);
764+
DBGLOG("patcher", "newly loaded kext is " PRIKADDR " and its name is %.*s (start func is " PRIKADDR ")",
765+
CASTKADDR((uint64_t)kmod->address), KMOD_MAX_NAME, kmod->name, CASTKADDR((uint64_t)kmod->start));
765766
that->processKext(kmod, false);
766767
} else {
767768
SYSLOG("patcher", "no kext is currently loaded, this should not happen");
@@ -783,7 +784,8 @@ kern_return_t KernelPatcher::onKmodCreateInternal(kmod_info_t *kmod, kmod_t *id)
783784
that->processAlreadyLoadedKexts();
784785
that->waitingForAlreadyLoadedKexts = false;
785786
} else {
786-
DBGLOG("patcher", "newly loaded kext is " PRIKADDR " and its name is %.*s", CASTKADDR((uint64_t)kmod->address), KMOD_MAX_NAME, kmod->name);
787+
DBGLOG("patcher", "newly loaded kext is " PRIKADDR " and its name is %.*s (start func is " PRIKADDR ")",
788+
CASTKADDR((uint64_t)kmod->address), KMOD_MAX_NAME, kmod->name, CASTKADDR((uint64_t)kmod->start));
787789
that->processKext(kmod, false);
788790
}
789791
}

0 commit comments

Comments
 (0)