Search kext executable by name if CFBundleExecutable leads to a non

existant file.
Add corecaptureElCap.kext, IO80211ElCap and
IO80211ElCap/Plugins/AirPortAtheros40.kext in oredered list.
This commit is contained in:
jief666 2024-01-07 18:14:33 +01:00
parent 5faf2f688b
commit 17c8480280
2 changed files with 27 additions and 4 deletions

View File

@ -196,10 +196,29 @@ XString8 LOADER_ENTRY::getKextExecPath(const EFI_FILE* Root, const XStringW& di
} else { } else {
TempName = S8Printf("Contents\\MacOS\\%s", Executable.c_str()); TempName = S8Printf("Contents\\MacOS\\%s", Executable.c_str());
} }
const XStringW& fullPath = SWPrintf("%ls\\%ls\\%ls\\%s", selfOem.getKextsDirPathRelToSelfDir().wc_str(), dirPath.wc_str(), FileName.wc_str(), TempName.c_str()); XStringW fullPath = SWPrintf("%ls\\%ls\\%ls\\%s", selfOem.getKextsDirPathRelToSelfDir().wc_str(), dirPath.wc_str(), FileName.wc_str(), TempName.c_str());
if (!FileExists(Root, fullPath)) {
// kext from OpenCoreLegacyPatcher renamed the executable without updating CFBundleExecutable
// let's see if there is an executable that has the same name as the kext.
XString8 TempName2;
XStringW FileNameWithoutExt;
if ( FileName.indexOf('.') != MAX_XSIZE ) FileNameWithoutExt = FileName.subString(0, FileName.indexOf('.'));
else FileNameWithoutExt = FileName;
if (NoContents) {
TempName2 = S8Printf("%ls", FileNameWithoutExt.wc_str());
} else {
TempName2 = S8Printf("Contents\\MacOS\\%ls", FileNameWithoutExt.wc_str());
}
fullPath = SWPrintf("%ls\\%ls\\%ls\\%s", selfOem.getKextsDirPathRelToSelfDir().wc_str(), dirPath.wc_str(), FileName.wc_str(), TempName2.c_str());
if (!FileExists(Root, fullPath)) { if (!FileExists(Root, fullPath)) {
MsgLog("Failed to load kext executable: %ls\n", FileName.wc_str()); MsgLog("Failed to load kext executable: %ls\n", FileName.wc_str());
return ""_XS8; //no executable return ""_XS8; //no executable
}else{
MsgLog("Warning : wrong value for CFBundleExecutable for kext %ls. It's %s and should be %ls\n", FileName.wc_str(), Executable.c_str(), FileName.wc_str());
return TempName2;
}
} }
} }
return TempName; return TempName;

View File

@ -1217,11 +1217,14 @@ void LOADER_ENTRY::StartLoader()
pos = setKextAtPos(&kextArray, "BrcmPatchRAM3.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "BrcmPatchRAM3.kext"_XS8, pos);
pos = setKextAtPos(&kextArray, "IO80211FamilyLegacy.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "IO80211FamilyLegacy.kext"_XS8, pos);
pos = setKextAtPos(&kextArray, "HS80211Family.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "HS80211Family.kext"_XS8, pos);
pos = setKextAtPos(&kextArray, "corecaptureElCap.kext"_XS8, pos);
pos = setKextAtPos(&kextArray, "IO80211ElCap.kext"_XS8, pos);
pos = setKextAtPos(&kextArray, "IO80211ElCap\\Contents\\Plugins\\AirPortAtheros40.kext"_XS8, pos);
pos = setKextAtPos(&kextArray, "AirPortAtheros40.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "AirPortAtheros40.kext"_XS8, pos);
for (size_t kextIdx = 0 ; kextIdx < kextArray.size() ; kextIdx++ ) { for (size_t kextIdx = 0 ; kextIdx < kextArray.size() ; kextIdx++ ) {
const SIDELOAD_KEXT& KextEntry = kextArray[kextIdx]; const SIDELOAD_KEXT& KextEntry = kextArray[kextIdx];
DBG("Bridge kext to OC : Path=%ls\%ls\n", KextEntry.KextDirNameUnderOEMPath.wc_str(), KextEntry.FileName.wc_str()); DBG("Bridge kext to OC : Path=%ls\\%ls\n", KextEntry.KextDirNameUnderOEMPath.wc_str(), KextEntry.FileName.wc_str());
mOpenCoreConfiguration.Kernel.Add.Values[kextIdx] = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Add.Values))malloc(mOpenCoreConfiguration.Kernel.Add.ValueSize); mOpenCoreConfiguration.Kernel.Add.Values[kextIdx] = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Add.Values))malloc(mOpenCoreConfiguration.Kernel.Add.ValueSize);
memset(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx], 0, mOpenCoreConfiguration.Kernel.Add.ValueSize); memset(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx], 0, mOpenCoreConfiguration.Kernel.Add.ValueSize);
mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->Enabled = 1; mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->Enabled = 1;
@ -3696,6 +3699,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable) IN EFI_SYSTEM_TABLE *SystemTable)
{ {
MemoryTrackerInit(); MemoryTrackerInit();
//MemoryTrackerInstallHook(); can't install hook before construct_globals_objects()... yet
EFI_STATUS Status = RefitMainMain(ImageHandle, SystemTable); EFI_STATUS Status = RefitMainMain(ImageHandle, SystemTable);