mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-10 09:40:53 +01:00
Do not store the kext dir in the SIDELOAD_KEXT object.
This commit is contained in:
parent
19fd19200d
commit
956cfc1ad4
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef DEBUG_ALL
|
#ifndef DEBUG_ALL
|
||||||
#define DEBUG_KEXTLIST 1
|
#define DEBUG_SET 1
|
||||||
#else
|
#else
|
||||||
#define DEBUG_KEXTLIST DEBUG_ALL
|
#define DEBUG_KEXTLIST DEBUG_ALL
|
||||||
#endif
|
#endif
|
||||||
@ -20,7 +20,7 @@
|
|||||||
#if DEBUG_SET == 0
|
#if DEBUG_SET == 0
|
||||||
#define DBG(...)
|
#define DBG(...)
|
||||||
#else
|
#else
|
||||||
#define DBG(...) DebugLog (DEBUG_KEXTLIST, __VA_ARGS__)
|
#define DBG(...) DebugLog (DEBUG_SET, __VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ XObjArray<SIDELOAD_KEXT> InjectKextList;
|
|||||||
/*
|
/*
|
||||||
* Relative path to SelfDir (the efi dir)
|
* Relative path to SelfDir (the efi dir)
|
||||||
*/
|
*/
|
||||||
XStringW GetBundleVersion(const XStringW& pathUnderSelf)
|
XStringW GetBundleVersion(const XStringW& pathUnderKextdDir)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
XStringW CFBundleVersion;
|
XStringW CFBundleVersion;
|
||||||
@ -40,10 +40,10 @@ XStringW GetBundleVersion(const XStringW& pathUnderSelf)
|
|||||||
TagDict* InfoPlistDict = NULL;
|
TagDict* InfoPlistDict = NULL;
|
||||||
const TagStruct* Prop = NULL;
|
const TagStruct* Prop = NULL;
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
InfoPlistPath = SWPrintf("%ls\\%ls", pathUnderSelf.wc_str(), L"Contents\\Info.plist");
|
InfoPlistPath = SWPrintf("%ls\\%ls\\%ls", selfOem.getKextsDirPathRelToSelfDir().wc_str(), pathUnderKextdDir.wc_str(), L"Contents\\Info.plist");
|
||||||
Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), &InfoPlistPtr, &Size);
|
Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), &InfoPlistPtr, &Size);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
InfoPlistPath = SWPrintf("%ls\\%ls", pathUnderSelf.wc_str(), L"Info.plist");
|
InfoPlistPath = SWPrintf("%ls\\%ls\\%ls", selfOem.getKextsDirPathRelToSelfDir().wc_str(), pathUnderKextdDir.wc_str(), L"Info.plist");
|
||||||
Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), &InfoPlistPtr, &Size);
|
Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), &InfoPlistPtr, &Size);
|
||||||
}
|
}
|
||||||
if(!EFI_ERROR(Status)) {
|
if(!EFI_ERROR(Status)) {
|
||||||
@ -94,19 +94,19 @@ void GetListOfInjectKext(CHAR16 *KextDirNameUnderOEMPath)
|
|||||||
<string>8.8.8</string>
|
<string>8.8.8</string>
|
||||||
*/
|
*/
|
||||||
// FullName = SWPrintf("%ls\\%ls", FullPath.wc_str(), DirEntry->FileName);
|
// FullName = SWPrintf("%ls\\%ls", FullPath.wc_str(), DirEntry->FileName);
|
||||||
XStringW pathRelToSelfDir = SWPrintf("%ls\\%ls\\%ls", selfOem.getKextsDirPathRelToSelfDir().wc_str(), KextDirNameUnderOEMPath, DirEntry->FileName);
|
XStringW pathUnderKextsDir = SWPrintf("%ls\\%ls", KextDirNameUnderOEMPath, DirEntry->FileName);
|
||||||
mKext = new SIDELOAD_KEXT;
|
mKext = new SIDELOAD_KEXT;
|
||||||
mKext->FileName.SWPrintf("%ls", DirEntry->FileName);
|
mKext->FileName.SWPrintf("%ls", DirEntry->FileName);
|
||||||
mKext->MenuItem.BValue = Blocked;
|
mKext->MenuItem.BValue = Blocked;
|
||||||
mKext->KextDirNameUnderOEMPath.SWPrintf("%ls", KextDirNameUnderOEMPath);
|
mKext->KextDirNameUnderOEMPath.SWPrintf("%ls", KextDirNameUnderOEMPath);
|
||||||
mKext->Version = GetBundleVersion(pathRelToSelfDir);
|
mKext->Version = GetBundleVersion(pathUnderKextsDir);
|
||||||
InjectKextList.AddReference(mKext, true);
|
InjectKextList.AddReference(mKext, true);
|
||||||
|
|
||||||
DBG("Added Kext=%ls\\%ls\n", mKext->KextDirNameUnderOEMPath.wc_str(), mKext->FileName.wc_str());
|
DBG("Added Kext=%ls\\%ls\n", mKext->KextDirNameUnderOEMPath.wc_str(), mKext->FileName.wc_str());
|
||||||
|
|
||||||
// Obtain PlugInList
|
// Obtain PlugInList
|
||||||
// Iterate over PlugIns directory
|
// Iterate over PlugIns directory
|
||||||
PlugInsPath = SWPrintf("%ls\\Contents\\PlugIns", pathRelToSelfDir.wc_str());
|
PlugInsPath = SWPrintf("%ls\\%ls\\Contents\\PlugIns", selfOem.getKextsDirPathRelToSelfDir().wc_str(), pathUnderKextsDir.wc_str());
|
||||||
|
|
||||||
DirIterOpen(&self.getCloverDir(), PlugInsPath.wc_str(), &PlugInsIter);
|
DirIterOpen(&self.getCloverDir(), PlugInsPath.wc_str(), &PlugInsIter);
|
||||||
while (DirIterNext(&PlugInsIter, 1, L"*.kext", &PlugInEntry)) {
|
while (DirIterNext(&PlugInsIter, 1, L"*.kext", &PlugInEntry)) {
|
||||||
|
@ -147,9 +147,7 @@ XStringW LOADER_ENTRY::getKextPlist(const EFI_FILE* Root, const XStringW& dirPat
|
|||||||
}
|
}
|
||||||
|
|
||||||
TempName = SWPrintf("%ls\\%ls", FullName.wc_str(), L"Contents\\Info.plist");
|
TempName = SWPrintf("%ls\\%ls", FullName.wc_str(), L"Contents\\Info.plist");
|
||||||
//#ifndef LESS_DEBUG
|
|
||||||
MsgLog("info plist path: %ls\n", TempName.wc_str());
|
|
||||||
//#endif
|
|
||||||
if (!FileExists(Root, TempName)) {
|
if (!FileExists(Root, TempName)) {
|
||||||
//try to find a planar kext, without Contents
|
//try to find a planar kext, without Contents
|
||||||
TempName = SWPrintf("%ls\\%ls", FullName.wc_str(), L"Info.plist");
|
TempName = SWPrintf("%ls\\%ls", FullName.wc_str(), L"Info.plist");
|
||||||
@ -198,7 +196,7 @@ 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\\%s", dirPath.wc_str(), FileName.wc_str(), TempName.c_str());
|
const XStringW& fullPath = SWPrintf("%ls\\%ls\\%ls\\%s", selfOem.getKextsDirPathRelToSelfDir().wc_str(), dirPath.wc_str(), FileName.wc_str(), TempName.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
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
XBool isKextsDirFound() { return m_KextsDir != NULL; }
|
XBool isKextsDirFound() { return m_KextsDir != NULL; }
|
||||||
const EFI_FILE& getKextsDir() { assert(m_KextsDir != NULL); return *m_KextsDir; }
|
const EFI_FILE& getKextsDir() { assert(m_KextsDir != NULL); return *m_KextsDir; }
|
||||||
const XStringW& getKextsDirPathRelToSelfDir() { assert(m_KextsPathRelToSelfDir.notEmpty()); return m_KextsPathRelToSelfDir; }
|
const XStringW& getKextsDirPathRelToSelfDir() { assert(m_KextsPathRelToSelfDir.notEmpty()); return m_KextsPathRelToSelfDir; } // Usually "Kexts". Init from KEXTS_DIRNAME
|
||||||
const XStringW& getKextsFullPath() { assert(m_KextsFullPath.notEmpty()); return m_KextsFullPath; }
|
const XStringW& getKextsFullPath() { assert(m_KextsFullPath.notEmpty()); return m_KextsFullPath; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1220,7 +1220,7 @@ void LOADER_ENTRY::StartLoader()
|
|||||||
|
|
||||||
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\n", 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;
|
||||||
@ -1233,34 +1233,37 @@ void LOADER_ENTRY::StartLoader()
|
|||||||
assert( selfOem.isKextsDirFound() ); // be sure before calling getKextsPathRelToSelfDir()
|
assert( selfOem.isKextsDirFound() ); // be sure before calling getKextsPathRelToSelfDir()
|
||||||
XStringW dirPath = SWPrintf("%ls\\%ls", selfOem.getKextsDirPathRelToSelfDir().wc_str(), KextEntry.KextDirNameUnderOEMPath.wc_str());
|
XStringW dirPath = SWPrintf("%ls\\%ls", selfOem.getKextsDirPathRelToSelfDir().wc_str(), KextEntry.KextDirNameUnderOEMPath.wc_str());
|
||||||
|
|
||||||
XString8 bundlePath = S8Printf("%ls\\%ls", dirPath.wc_str(), KextEntry.FileName.wc_str());
|
XString8 bundleFullPath = S8Printf("%ls\\%ls", dirPath.wc_str(), KextEntry.FileName.wc_str());
|
||||||
if ( FileExists(&self.getCloverDir(), bundlePath) ) {
|
if ( FileExists(&self.getCloverDir(), bundleFullPath) ) {
|
||||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath, bundlePath.c_str());
|
XString8 bundlePathUnderKextsDir = S8Printf("%ls\\%ls", KextEntry.KextDirNameUnderOEMPath.wc_str(), KextEntry.FileName.wc_str());
|
||||||
|
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath, bundlePathUnderKextsDir.c_str());
|
||||||
|
DBG("OC BundlePath = '%s'\n", OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath));
|
||||||
} else {
|
} else {
|
||||||
DBG("Cannot find kext bundlePath at '%s'\n", bundlePath.c_str());
|
DBG("Cannot find kext bundlePath at '%s'\n", bundleFullPath.c_str());
|
||||||
}
|
}
|
||||||
#if 1
|
#if 1
|
||||||
//CFBundleExecutable
|
//CFBundleExecutable
|
||||||
XBool NoContents = false;
|
XBool NoContents = false;
|
||||||
XStringW infoPlistPath = getKextPlist(&self.getCloverDir(), dirPath, KextEntry.FileName, &NoContents); //it will be fullPath, including dir
|
XStringW infoPlistPathRelToSelf = getKextPlist(&self.getCloverDir(), dirPath, KextEntry.FileName, &NoContents); //it will be fullPath, including dir
|
||||||
DBG("InfoPlistPath=%ls\n", infoPlistPath.wc_str());
|
|
||||||
// XBool inject = checkOSBundleRequired(dict);
|
// XBool inject = checkOSBundleRequired(dict);
|
||||||
XBool inject = true;
|
XBool inject = true;
|
||||||
if (inject) {
|
if (inject) {
|
||||||
if ( infoPlistPath.notEmpty()) {
|
if ( infoPlistPathRelToSelf.notEmpty()) {
|
||||||
if (NoContents) {
|
if (NoContents) {
|
||||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, "Info.plist");
|
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, "Info.plist");
|
||||||
} else {
|
} else {
|
||||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, "Contents/Info.plist");
|
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, "Contents\\Info.plist");
|
||||||
}
|
}
|
||||||
|
DBG("OC PlistPath = '%s'\n", OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath));
|
||||||
} else {
|
} else {
|
||||||
DBG("Cannot find kext info.plist at '%ls'\n", KextEntry.FileName.wc_str());
|
DBG("Cannot find kext info.plist at '%ls'\n", KextEntry.FileName.wc_str());
|
||||||
}
|
}
|
||||||
TagDict* dict = getInfoPlist(&self.getCloverDir(), infoPlistPath);
|
TagDict* dict = getInfoPlist(&self.getCloverDir(), infoPlistPathRelToSelf);
|
||||||
XString8 execpath = getKextExecPath(&self.getCloverDir(), dirPath, KextEntry.FileName, dict, NoContents);
|
XString8 execpath = getKextExecPath(&self.getCloverDir(), KextEntry.KextDirNameUnderOEMPath, KextEntry.FileName, dict, NoContents);
|
||||||
if (execpath.notEmpty()) {
|
if (execpath.notEmpty()) {
|
||||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ExecutablePath, execpath.c_str());
|
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ExecutablePath, execpath.c_str());
|
||||||
DBG("assign executable as '%s'\n", execpath.c_str());
|
DBG("OC ExecutablePath = '%s'\n", execpath.c_str());
|
||||||
}
|
}
|
||||||
if ( dict ) dict->ReleaseTag();
|
if ( dict ) dict->ReleaseTag();
|
||||||
}
|
}
|
||||||
@ -1271,11 +1274,11 @@ void LOADER_ENTRY::StartLoader()
|
|||||||
if ( FileExists(&self.getCloverDir(), fullPath) ) {
|
if ( FileExists(&self.getCloverDir(), fullPath) ) {
|
||||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ExecutablePath, S8Printf("Contents\\MacOS\\%ls", KextEntry.FileName.subString(0, KextEntry.FileName.rindexOf(".")).wc_str()).c_str());
|
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ExecutablePath, S8Printf("Contents\\MacOS\\%ls", KextEntry.FileName.subString(0, KextEntry.FileName.rindexOf(".")).wc_str()).c_str());
|
||||||
}
|
}
|
||||||
XStringW infoPlistPath = SWPrintf("%s\\Contents\\Info.plist", OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath));
|
XStringW infoPlistPathRelToSelf = SWPrintf("%s\\Contents\\Info.plist", OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath));
|
||||||
if (FileExists(&self.getCloverDir(), infoPlistPath)) {
|
if (FileExists(&self.getCloverDir(), infoPlistPathRelToSelf)) {
|
||||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, "Contents/Info.plist"); // TODO : is always Contents/Info.plist ?
|
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, "Contents/Info.plist"); // TODO : is always Contents/Info.plist ?
|
||||||
} else {
|
} else {
|
||||||
DBG("Cannot find kext info.plist at '%ls'\n", infoPlistPath.wc_str());
|
DBG("Cannot find kext info.plist at '%ls'\n", infoPlistPathRelToSelf.wc_str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ImageData = NULL;
|
mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ImageData = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user