Merge pull request #62 from Florin9doi/p11_kexts_path

Fix kext injection for minor versions
This commit is contained in:
Sergey 2019-12-23 15:48:50 +03:00 committed by GitHub
commit d058be8f04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 68 deletions

View File

@ -1013,8 +1013,8 @@ typedef struct {
// BOOLEAN DropMCFG; // BOOLEAN DropMCFG;
BOOLEAN FixMCFG; BOOLEAN FixMCFG;
UINT32 DeviceRenameCount; UINT32 DeviceRenameCount;
ACPI_NAME_LIST *DeviceRename; ACPI_NAME_LIST *DeviceRename;
//Injections //Injections
BOOLEAN StringInjector; BOOLEAN StringInjector;
BOOLEAN InjectSystemID; BOOLEAN InjectSystemID;

View File

@ -417,7 +417,7 @@ EFI_STATUS LoadKexts(IN LOADER_ENTRY *Entry)
CHAR16 UniOSVersion[16]; CHAR16 UniOSVersion[16];
AsciiStrToUnicodeStrS(Entry->OSVersion, UniOSVersion, 16); AsciiStrToUnicodeStrS(Entry->OSVersion, UniOSVersion, 16);
DBG("UniOSVersion == %s\n", UniOSVersion); DBG("UniOSVersion == %s\n", UniOSVersion);
CHAR16 UniShortOSVersion[6]; CHAR16 UniShortOSVersion[6];
CHAR8 ShortOSVersion[6]; CHAR8 ShortOSVersion[6];
@ -429,120 +429,112 @@ EFI_STATUS LoadKexts(IN LOADER_ENTRY *Entry)
AsciiStrnCpyS(ShortOSVersion, 6, Entry->OSVersion, 5); AsciiStrnCpyS(ShortOSVersion, 6, Entry->OSVersion, 5);
AsciiStrToUnicodeStrS(Entry->OSVersion, UniShortOSVersion, 6); AsciiStrToUnicodeStrS(Entry->OSVersion, UniShortOSVersion, 6);
} }
DBG("ShortOSVersion == %a\n", ShortOSVersion); DBG("ShortOSVersion == %a\n", ShortOSVersion);
DBG("UniShortOSVersion == %s\n", UniShortOSVersion); DBG("UniShortOSVersion == %s\n", UniShortOSVersion);
// syscl - allow specific load inject kext // syscl - allow specific load inject kext
// Clover/Kexts/Other is for general injection thus we need to scan both Other and OSVersion folder // Clover/Kexts/Other is for general injection thus we need to scan both Other and OSVersion folder
if ((SrcDir = GetOtherKextsDir(TRUE)) != NULL) { if ((SrcDir = GetOtherKextsDir(TRUE)) != NULL) {
AddKexts(Entry, SrcDir, L"Other", archCpuType); AddKexts(Entry, SrcDir, L"Other", archCpuType);
FreePool(SrcDir); FreePool(SrcDir);
}else{ } else {
DBG("GetOtherKextsDir(TRUE) return NULL\n"); DBG("GetOtherKextsDir(TRUE) return NULL\n");
} }
// slice: CLOVER/kexts/Off keep disabled kext which can be allowed // slice: CLOVER/kexts/Off keep disabled kext which can be allowed
if ((SrcDir = GetOtherKextsDir(FALSE)) != NULL) { if ((SrcDir = GetOtherKextsDir(FALSE)) != NULL) {
AddKexts(Entry, SrcDir, L"Off", archCpuType); AddKexts(Entry, SrcDir, L"Off", archCpuType);
FreePool(SrcDir); FreePool(SrcDir);
}else{ } else {
DBG("GetOtherKextsDir(FALSE) return NULL\n"); DBG("GetOtherKextsDir(FALSE) return NULL\n");
} }
// Add kext from 10 // Add kext from 10
{ {
CHAR16 *OSAllVersionKextsDir; CHAR16 *OSAllVersionKextsDir;
CHAR16 *OSShortVersionKextsDir; CHAR16 *OSShortVersionKextsDir;
CHAR16 *OSVersionKextsDirName; CHAR16 *OSVersionKextsDirName;
CHAR16 *DirName; CHAR16 *DirName;
CHAR16 *DirPath; CHAR16 *DirPath;
OSAllVersionKextsDir = PoolPrint(L"%s\\kexts\\10", OEMPath); OSAllVersionKextsDir = PoolPrint(L"%s\\kexts\\10", OEMPath);
// UnicodeSPrint(OSAllVersionKextsDir, sizeof(OSAllVersionKextsDir), L"%s\\kexts\\10", OEMPath); // UnicodeSPrint(OSAllVersionKextsDir, sizeof(OSAllVersionKextsDir), L"%s\\kexts\\10", OEMPath);
AddKexts(Entry, OSAllVersionKextsDir, L"10", archCpuType); AddKexts(Entry, OSAllVersionKextsDir, L"10", archCpuType);
FreePool(OSAllVersionKextsDir); FreePool(OSAllVersionKextsDir);
if (OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) { if (OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
DirName = PoolPrint(L"10_install"); DirName = PoolPrint(L"10_install");
// UnicodeSPrint(DirName, sizeof(DirName), L"10_install"); // UnicodeSPrint(DirName, sizeof(DirName), L"10_install");
} else { } else if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) { DirName = PoolPrint(L"10_recovery");
DirName = PoolPrint(L"10_recovery"); // UnicodeSPrint(DirName, sizeof(DirName), L"10_recovery");
// UnicodeSPrint(DirName, sizeof(DirName), L"10_recovery"); } else {
}else{ DirName = PoolPrint(L"10_normal");
DirName = PoolPrint(L"10_normal"); // UnicodeSPrint(DirName, sizeof(DirName), L"10_normal");
// UnicodeSPrint(DirName, sizeof(DirName), L"10_normal"); }
}
}
DirPath = PoolPrint(L"%s\\kexts\\%s", OEMPath, DirName); DirPath = PoolPrint(L"%s\\kexts\\%s", OEMPath, DirName);
// UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, DirName); // UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, DirName);
AddKexts(Entry, DirPath, DirName, archCpuType); AddKexts(Entry, DirPath, DirName, archCpuType);
FreePool(DirPath); FreePool(DirPath);
FreePool(DirName); FreePool(DirName);
// Add kext from 10.{version} // Add kext from 10.{version}
OSShortVersionKextsDir = PoolPrint(L"%s\\kexts\\%s", OEMPath, UniShortOSVersion); OSShortVersionKextsDir = PoolPrint(L"%s\\kexts\\%s", OEMPath, UniShortOSVersion);
// UnicodeSPrint(OSShortVersionKextsDir, sizeof(OSShortVersionKextsDir), L"%s\\kexts\\%s", OEMPath, UniShortOSVersion); // UnicodeSPrint(OSShortVersionKextsDir, sizeof(OSShortVersionKextsDir), L"%s\\kexts\\%s", OEMPath, UniShortOSVersion);
AddKexts(Entry, OSShortVersionKextsDir, UniShortOSVersion, archCpuType); AddKexts(Entry, OSShortVersionKextsDir, UniShortOSVersion, archCpuType);
FreePool(OSShortVersionKextsDir); FreePool(OSShortVersionKextsDir);
if (OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) { if (OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
DirName = PoolPrint(L"%s_install", UniShortOSVersion); DirName = PoolPrint(L"%s_install", UniShortOSVersion);
// UnicodeSPrint(DirName, sizeof(DirName), L"%s_install", UniShortOSVersion); // UnicodeSPrint(DirName, sizeof(DirName), L"%s_install", UniShortOSVersion);
} else { } else if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) { DirName = PoolPrint(L"%s_recovery", UniShortOSVersion);
DirName = PoolPrint(L"%s_recovery", UniShortOSVersion); // UnicodeSPrint(DirName, sizeof(DirName), L"%s_recovery", UniShortOSVersion);
// UnicodeSPrint(DirName, sizeof(DirName), L"%s_recovery", UniShortOSVersion); } else {
}else{ DirName = PoolPrint(L"%s_normal", UniShortOSVersion);
DirName = PoolPrint(L"%s_normal", UniShortOSVersion); // UnicodeSPrint(DirName, sizeof(DirName), L"%s_normal", UniShortOSVersion);
// UnicodeSPrint(DirName, sizeof(DirName), L"%s_normal", UniShortOSVersion); }
}
}
DirPath = PoolPrint(L"%s\\kexts\\%s", OEMPath, DirName); DirPath = PoolPrint(L"%s\\kexts\\%s", OEMPath, DirName);
// UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, DirName); // UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, DirName);
AddKexts(Entry, DirPath, DirName, archCpuType); AddKexts(Entry, DirPath, DirName, archCpuType);
FreePool(DirPath); FreePool(DirPath);
FreePool(DirName); FreePool(DirName);
// Add kext from :
// 10.{version}.0 if NO minor version
// 10.{version}.{minor version} if minor version is > 0
// Add kext from :
// 10.{version}.0 if NO minor version
// 10.{version}.{minor version} if minor version is > 0
if ( AsciiStrCmp(ShortOSVersion, Entry->OSVersion) == 0 ) { if ( AsciiStrCmp(ShortOSVersion, Entry->OSVersion) == 0 ) {
OSVersionKextsDirName = PoolPrint(L"%a.0", Entry->OSVersion); OSVersionKextsDirName = PoolPrint(L"%a.0", Entry->OSVersion);
// UnicodeSPrint(OSVersionKextsDirName, sizeof(OSVersionKextsDirName), L"%a.0", Entry->OSVersion); // UnicodeSPrint(OSVersionKextsDirName, sizeof(OSVersionKextsDirName), L"%a.0", Entry->OSVersion);
}else{ } else {
OSVersionKextsDirName = PoolPrint(L"%a.0", Entry->OSVersion); OSVersionKextsDirName = PoolPrint(L"%a", Entry->OSVersion);
// UnicodeSPrint(OSVersionKextsDirName, sizeof(OSVersionKextsDirName), L"%a", Entry->OSVersion); // UnicodeSPrint(OSVersionKextsDirName, sizeof(OSVersionKextsDirName), L"%a", Entry->OSVersion);
} }
DirPath = PoolPrint(L"%s\\kexts\\%s", OEMPath, OSVersionKextsDirName); DirPath = PoolPrint(L"%s\\kexts\\%s", OEMPath, OSVersionKextsDirName);
// UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, OSVersionKextsDirName); // UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, OSVersionKextsDirName);
AddKexts(Entry, DirPath, OSVersionKextsDirName, archCpuType); AddKexts(Entry, DirPath, OSVersionKextsDirName, archCpuType);
FreePool(DirPath); FreePool(DirPath);
FreePool(OSVersionKextsDirName);
if ( OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) { if ( OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
DirName = PoolPrint(L"%s_install", OSVersionKextsDirName); DirName = PoolPrint(L"%s_install", OSVersionKextsDirName);
// UnicodeSPrint(DirName, sizeof(DirName), L"%s_install", OSVersionKextsDirName); // UnicodeSPrint(DirName, sizeof(DirName), L"%s_install", OSVersionKextsDirName);
}else{ } else if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) { DirName = PoolPrint(L"%s_recovery", OSVersionKextsDirName);
DirName = PoolPrint(L"%s_recovery", OSVersionKextsDirName); // UnicodeSPrint(DirName, sizeof(DirName), L"%s_recovery", OSVersionKextsDirName);
// UnicodeSPrint(DirName, sizeof(DirName), L"%s_recovery", OSVersionKextsDirName); } else {
}else{ DirName = PoolPrint(L"%s_normal", OSVersionKextsDirName);
DirName = PoolPrint(L"%s_normal", OSVersionKextsDirName); // UnicodeSPrint(DirName, sizeof(DirName), L"%s_normal", OSVersionKextsDirName);
// UnicodeSPrint(DirName, sizeof(DirName), L"%s_normal", OSVersionKextsDirName); }
}
}
DirPath = PoolPrint(L"%s\\kexts\\%s", OEMPath, DirName); DirPath = PoolPrint(L"%s\\kexts\\%s", OEMPath, DirName);
// UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, DirName); // UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, DirName);
AddKexts(Entry, DirPath, DirName, archCpuType); AddKexts(Entry, DirPath, DirName, archCpuType);
FreePool(DirPath); FreePool(DirPath);
FreePool(DirName); FreePool(DirName);
} FreePool(OSVersionKextsDirName);
}
// reserve space in the device tree // reserve space in the device tree