mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-28 17:08:18 +01:00
Add a 10.x folder
This commit is contained in:
parent
0946f0d1e8
commit
ffb691c078
@ -288,12 +288,12 @@ VOID AddKexts(IN LOADER_ENTRY *Entry, CHAR16 *SrcDir, CHAR16 *Path/*, CHAR16 *Un
|
||||
MsgLog("Preparing kexts injection for arch=%s from %s\n", (archCpuType==CPU_TYPE_X86_64)?L"x86_64":(archCpuType==CPU_TYPE_I386)?L"i386":L"", SrcDir);
|
||||
CurrentKext = InjectKextList;
|
||||
while (CurrentKext) {
|
||||
DBG("current kext name=%s path=%s, match against=%s\n", CurrentKext->FileName, CurrentKext->KextDirNameUnderOEMPath, Path);
|
||||
DBG(" current kext name=%s path=%s, match against=%s\n", CurrentKext->FileName, CurrentKext->KextDirNameUnderOEMPath, Path);
|
||||
if (StrCmp(CurrentKext->KextDirNameUnderOEMPath, Path) == 0) {
|
||||
UnicodeSPrint(FileName, 512, L"%s\\%s", SrcDir, CurrentKext->FileName);
|
||||
if (!(CurrentKext->MenuItem.BValue)) {
|
||||
// inject require
|
||||
MsgLog("Extra kext: %s (v.%s)\n", FileName, CurrentKext->Version);
|
||||
MsgLog("->Extra kext: %s (v.%s)\n", FileName, CurrentKext->Version);
|
||||
Status = AddKext(Entry, SelfVolume->RootDir, FileName, archCpuType);
|
||||
if(!EFI_ERROR(Status)) {
|
||||
// decide which plugins to inject
|
||||
@ -302,10 +302,10 @@ VOID AddKexts(IN LOADER_ENTRY *Entry, CHAR16 *SrcDir, CHAR16 *Path/*, CHAR16 *Un
|
||||
UnicodeSPrint(PlugInName, 512, L"%s\\%s\\%s", FileName, L"Contents\\PlugIns", CurrentPlugInKext->FileName);
|
||||
if (!(CurrentPlugInKext->MenuItem.BValue)) {
|
||||
// inject PlugIn require
|
||||
MsgLog(" |-- PlugIn kext: %s (v.%s)\n", PlugInName, CurrentPlugInKext->Version);
|
||||
MsgLog(" |-- PlugIn kext: %s (v.%s)\n", PlugInName, CurrentPlugInKext->Version);
|
||||
AddKext(Entry, SelfVolume->RootDir, PlugInName, archCpuType);
|
||||
} else {
|
||||
MsgLog(" |-- Disabled plug-in kext: %s (v.%s)\n", PlugInName, CurrentPlugInKext->Version);
|
||||
MsgLog(" |-- Disabled plug-in kext: %s (v.%s)\n", PlugInName, CurrentPlugInKext->Version);
|
||||
}
|
||||
CurrentPlugInKext = CurrentPlugInKext->Next;
|
||||
} // end of plug-in kext injection
|
||||
@ -445,61 +445,75 @@ EFI_STATUS LoadKexts(IN LOADER_ENTRY *Entry)
|
||||
DBG("GetOtherKextsDir(FALSE) return NULL\n");
|
||||
}
|
||||
|
||||
CHAR16* OSShortVersionKextsDir;
|
||||
if ((OSShortVersionKextsDir = GetOSVersionKextsDir(ShortOSVersion)) != NULL)
|
||||
// Add kext from 10.x
|
||||
{
|
||||
AddKexts(Entry, OSShortVersionKextsDir, UniShortOSVersion, archCpuType);
|
||||
CHAR16 OSAllVersionKextsDir[1024];
|
||||
UnicodeSPrint(OSAllVersionKextsDir, sizeof(OSAllVersionKextsDir), L"%s\\kexts\\10.x", OEMPath);
|
||||
AddKexts(Entry, OSAllVersionKextsDir, L"10.x", archCpuType);
|
||||
|
||||
{
|
||||
CHAR16 DirName[256];
|
||||
if (OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%a_install", ShortOSVersion);
|
||||
} else {
|
||||
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%a_recovery", ShortOSVersion);
|
||||
}else{
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%a_normal", ShortOSVersion);
|
||||
}
|
||||
}
|
||||
CHAR16 SrcDir2[1024];
|
||||
UnicodeSPrint(SrcDir2, sizeof(SrcDir2), L"%s\\..\\%s", OSShortVersionKextsDir, DirName);
|
||||
AddKexts(Entry, SrcDir2, DirName, archCpuType);
|
||||
|
||||
// jief: Load kext also from long version folder.
|
||||
{
|
||||
CHAR16 OSVersionKextsDirName[256];
|
||||
if ( StrCmp(UniOSVersion, UniShortOSVersion) != 0 ) {
|
||||
UnicodeSPrint(OSVersionKextsDirName, sizeof(OSVersionKextsDirName), L"%a", Entry->OSVersion);
|
||||
}else{
|
||||
DBG("UniOSVersion == UniShortOSVersion, '%s'\n", UniShortOSVersion);
|
||||
UnicodeSPrint(OSVersionKextsDirName, sizeof(OSVersionKextsDirName), L"%a.0", Entry->OSVersion);
|
||||
}
|
||||
{
|
||||
CHAR16 OSVersionKextsDir[1024];
|
||||
UnicodeSPrint(OSVersionKextsDir, sizeof(OSVersionKextsDir), L"%s\\..\\%s", OSShortVersionKextsDir, OSVersionKextsDirName);
|
||||
AddKexts(Entry, OSVersionKextsDir, OSVersionKextsDirName, archCpuType);
|
||||
}
|
||||
|
||||
CHAR16 DirName[256];
|
||||
if ( OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%s_install", OSVersionKextsDirName);
|
||||
}else{
|
||||
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%s_recovery", OSVersionKextsDirName);
|
||||
}else{
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%s_normal", OSVersionKextsDirName);
|
||||
}
|
||||
}
|
||||
CHAR16 SrcDir2[1024];
|
||||
UnicodeSPrint(SrcDir2, sizeof(SrcDir2), L"%s\\..\\%s", OSShortVersionKextsDir, DirName);
|
||||
AddKexts(Entry, SrcDir2, DirName, archCpuType);
|
||||
CHAR16 DirName[256];
|
||||
if (OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"10.x_install");
|
||||
} else {
|
||||
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"10.x_recovery");
|
||||
}else{
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"10.x_normal");
|
||||
}
|
||||
}
|
||||
CHAR16 DirPath[1024];
|
||||
UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, DirName);
|
||||
AddKexts(Entry, DirPath, DirName, archCpuType);
|
||||
}
|
||||
|
||||
FreePool(OSShortVersionKextsDir);
|
||||
}else{
|
||||
DBG("GetOSVersionKextsDir(%a) return NULL", ShortOSVersion);
|
||||
|
||||
// Add kext from 10.{version}.x
|
||||
{
|
||||
CHAR16 UniOSVersionDotX[16];
|
||||
UnicodeSPrint(UniOSVersionDotX, sizeof(UniOSVersionDotX), L"%a.x", ShortOSVersion);
|
||||
|
||||
CHAR16 OSShortVersionDotXKextsDir[1024];
|
||||
UnicodeSPrint(OSShortVersionDotXKextsDir, sizeof(OSShortVersionDotXKextsDir), L"%s\\kexts\\%s", OEMPath, UniOSVersionDotX);
|
||||
AddKexts(Entry, OSShortVersionDotXKextsDir, UniOSVersionDotX, archCpuType);
|
||||
|
||||
CHAR16 DirName[256];
|
||||
if (OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%s_install", UniOSVersionDotX);
|
||||
} else {
|
||||
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%s_recovery", UniOSVersionDotX);
|
||||
}else{
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%s_normal", UniOSVersionDotX);
|
||||
}
|
||||
}
|
||||
CHAR16 DirPath[1024];
|
||||
UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, DirName);
|
||||
AddKexts(Entry, DirPath, DirName, archCpuType);
|
||||
}
|
||||
|
||||
// Add kext from :
|
||||
// 10.{version} if NO minor version
|
||||
// 10.{version}.{minor version} if minor version is > 0
|
||||
{
|
||||
CHAR16 OSVersionKextsDirName[256];
|
||||
UnicodeSPrint(OSVersionKextsDirName, sizeof(OSVersionKextsDirName), L"%a", Entry->OSVersion);
|
||||
|
||||
CHAR16 DirPath[1024];
|
||||
UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, OSVersionKextsDirName);
|
||||
AddKexts(Entry, DirPath, OSVersionKextsDirName, archCpuType);
|
||||
|
||||
CHAR16 DirName[256];
|
||||
if ( OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%s_install", OSVersionKextsDirName);
|
||||
}else{
|
||||
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%s_recovery", OSVersionKextsDirName);
|
||||
}else{
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%s_normal", OSVersionKextsDirName);
|
||||
}
|
||||
}
|
||||
UnicodeSPrint(DirPath, sizeof(DirPath), L"%s\\kexts\\%s", OEMPath, DirName);
|
||||
AddKexts(Entry, DirPath, DirName, archCpuType);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2155,6 +2155,8 @@ VOID AddMenuInfoLine(IN REFIT_MENU_SCREEN *Screen, IN CHAR16 *InfoLine)
|
||||
|
||||
VOID AddMenuEntry(IN REFIT_MENU_SCREEN *Screen, IN REFIT_MENU_ENTRY *Entry)
|
||||
{
|
||||
if ( !Screen ) return;
|
||||
if ( !Entry ) return;
|
||||
AddListElement((VOID ***) &(Screen->Entries), (UINTN*)&(Screen->EntryCount), Entry);
|
||||
}
|
||||
|
||||
@ -4611,27 +4613,30 @@ REFIT_MENU_ENTRY *SubMenuKextPatches()
|
||||
|
||||
REFIT_MENU_ENTRY *SubMenuKextBlockInjection(CHAR16* UniSysVer)
|
||||
{
|
||||
REFIT_MENU_ENTRY *Entry;
|
||||
REFIT_MENU_SCREEN *SubScreen;
|
||||
REFIT_MENU_ENTRY *Entry = NULL;
|
||||
REFIT_MENU_SCREEN *SubScreen = NULL;
|
||||
REFIT_INPUT_DIALOG *InputBootArgs;
|
||||
UINTN i = 0;
|
||||
SIDELOAD_KEXT *Kext = NULL;
|
||||
CHAR8 sysVer[17]; //RehabMan: logic below uses max index of 16, so buffer must be 17
|
||||
CHAR8 sysVer[256];
|
||||
|
||||
UnicodeStrToAsciiStrS(UniSysVer, sysVer, 16);
|
||||
for (i = 0; i < 16; i++) {
|
||||
UnicodeStrToAsciiStrS(UniSysVer, sysVer, sizeof(sysVer));
|
||||
for (i = 0; i < sizeof(sysVer)-2; i++) {
|
||||
if (sysVer[i] == '\0') {
|
||||
sysVer[i+0] = '-';
|
||||
sysVer[i+1] = '>';
|
||||
sysVer[i+2] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Kext = InjectKextList;
|
||||
NewEntry(&Entry, &SubScreen, ActionEnter, SCREEN_KEXT_INJECT, sysVer);
|
||||
AddMenuInfoLine(SubScreen, PoolPrint(L"Choose/check kext to disable:"));
|
||||
while (Kext) {
|
||||
if (StrStr(Kext->KextDirNameUnderOEMPath, UniSysVer) != NULL) {
|
||||
if (StrCmp(Kext->KextDirNameUnderOEMPath, UniSysVer) == 0) {
|
||||
if ( SubScreen == NULL ) {
|
||||
NewEntry(&Entry, &SubScreen, ActionEnter, SCREEN_KEXT_INJECT, sysVer);
|
||||
AddMenuInfoLine(SubScreen, PoolPrint(L"Choose/check kext to disable:"));
|
||||
}
|
||||
InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG));
|
||||
InputBootArgs->Entry.Title = PoolPrint(L"%s, v.%s", Kext->FileName, Kext->Version);
|
||||
InputBootArgs->Entry.Tag = TAG_INPUT;
|
||||
@ -4657,57 +4662,130 @@ REFIT_MENU_ENTRY *SubMenuKextBlockInjection(CHAR16* UniSysVer)
|
||||
Kext = Kext->Next;
|
||||
}
|
||||
|
||||
AddMenuEntry(SubScreen, &MenuEntryReturn);
|
||||
if ( SubScreen != NULL ) AddMenuEntry(SubScreen, &MenuEntryReturn);
|
||||
return Entry;
|
||||
}
|
||||
|
||||
LOADER_ENTRY *SubMenuKextInjectMgmt(LOADER_ENTRY *Entry)
|
||||
{
|
||||
LOADER_ENTRY *SubEntry;
|
||||
REFIT_MENU_SCREEN *SubScreen;
|
||||
CHAR16 *kextDir = NULL;
|
||||
UINTN i;
|
||||
CHAR8 ShortOSVersion[8];
|
||||
CHAR16 *UniSysVer = NULL;
|
||||
CHAR8 *ChosenOS =Entry->OSVersion;
|
||||
LOADER_ENTRY *SubEntry;
|
||||
REFIT_MENU_SCREEN *SubScreen;
|
||||
CHAR16 *kextDir = NULL;
|
||||
UINTN i;
|
||||
CHAR8 ShortOSVersion[8];
|
||||
CHAR16 *UniSysVer = NULL;
|
||||
CHAR8 *ChosenOS = Entry->OSVersion;
|
||||
|
||||
NewEntry((REFIT_MENU_ENTRY**)&SubEntry, &SubScreen, ActionEnter, SCREEN_SYSTEM, "Block injected kexts->");
|
||||
SubEntry->Flags = Entry->Flags;
|
||||
if (ChosenOS) {
|
||||
NewEntry((REFIT_MENU_ENTRY**) &SubEntry, &SubScreen, ActionEnter, SCREEN_SYSTEM, "Block injected kexts->");
|
||||
SubEntry->Flags = Entry->Flags;
|
||||
if (ChosenOS) {
|
||||
// DBG("chosen os %a\n", ChosenOS);
|
||||
//shorten os version 10.11.6 -> 10.11
|
||||
for (i = 0; i < 8; i++) {
|
||||
ShortOSVersion[i] = ChosenOS[i];
|
||||
if (ShortOSVersion[i] == '\0') {
|
||||
break;
|
||||
}
|
||||
if (((i > 2) && (ShortOSVersion[i] == '.')) || (i == 5)) {
|
||||
ShortOSVersion[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
UniSysVer = PoolPrint(L"%a", ShortOSVersion);
|
||||
//shorten os version 10.11.6 -> 10.11
|
||||
for (i = 0; i < 8; i++) {
|
||||
ShortOSVersion[i] = ChosenOS[i];
|
||||
if (ShortOSVersion[i] == '\0') {
|
||||
break;
|
||||
}
|
||||
if (((i > 2) && (ShortOSVersion[i] == '.')) || (i == 5)) {
|
||||
ShortOSVersion[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AddMenuInfoLine(SubScreen, PoolPrint(L"Block injected kexts for target version of macOS: %a", ShortOSVersion));
|
||||
if ((kextDir = GetOSVersionKextsDir(ShortOSVersion)) != NULL) {
|
||||
AddMenuEntry(SubScreen, SubMenuKextBlockInjection(UniSysVer));
|
||||
FreePool(kextDir);
|
||||
}
|
||||
FreePool(UniSysVer);
|
||||
} else {
|
||||
AddMenuInfoLine(SubScreen, PoolPrint(L"Block injected kexts for target version of macOS: %a", ChosenOS));
|
||||
}
|
||||
if ((kextDir = GetOtherKextsDir(TRUE)) != NULL) {
|
||||
AddMenuEntry(SubScreen, SubMenuKextBlockInjection(L"Other"));
|
||||
FreePool(kextDir);
|
||||
}
|
||||
if ((kextDir = GetOtherKextsDir(FALSE)) != NULL) {
|
||||
AddMenuEntry(SubScreen, SubMenuKextBlockInjection(L"Off"));
|
||||
FreePool(kextDir);
|
||||
}
|
||||
AddMenuInfoLine(SubScreen,
|
||||
PoolPrint(
|
||||
L"Block injected kexts for target version of macOS: %a",
|
||||
ShortOSVersion));
|
||||
|
||||
AddMenuEntry(SubScreen, &MenuEntryReturn);
|
||||
return SubEntry;
|
||||
// Add kext from 10.x
|
||||
{
|
||||
AddMenuEntry(SubScreen, SubMenuKextBlockInjection(L"10.x"));
|
||||
|
||||
CHAR16 DirName[256];
|
||||
if (OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"10.x_install");
|
||||
}
|
||||
else {
|
||||
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"10.x_recovery");
|
||||
}
|
||||
else {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"10.x_normal");
|
||||
}
|
||||
}
|
||||
AddMenuEntry(SubScreen, SubMenuKextBlockInjection(DirName));
|
||||
}
|
||||
|
||||
// Add kext from 10.{version}.x
|
||||
{
|
||||
CHAR16 DirName[256];
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%a.x", ShortOSVersion);
|
||||
AddMenuEntry(SubScreen, SubMenuKextBlockInjection(DirName));
|
||||
|
||||
if (OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%a.x_install",
|
||||
ShortOSVersion);
|
||||
}
|
||||
else {
|
||||
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%a.x_recovery",
|
||||
ShortOSVersion);
|
||||
}
|
||||
else {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%a.x_normal",
|
||||
ShortOSVersion);
|
||||
}
|
||||
}
|
||||
AddMenuEntry(SubScreen, SubMenuKextBlockInjection(DirName));
|
||||
}
|
||||
|
||||
// Add kext from :
|
||||
// 10.{version} if NO minor version
|
||||
// 10.{version}.{minor version} if minor version is > 0
|
||||
{
|
||||
{
|
||||
CHAR16 OSVersionKextsDirName[256];
|
||||
UnicodeSPrint(OSVersionKextsDirName,
|
||||
sizeof(OSVersionKextsDirName), L"%a", Entry->OSVersion);
|
||||
AddMenuEntry(SubScreen,
|
||||
SubMenuKextBlockInjection(OSVersionKextsDirName));
|
||||
}
|
||||
|
||||
CHAR16 DirName[256];
|
||||
if (OSTYPE_IS_OSX_INSTALLER(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%a_install",
|
||||
Entry->OSVersion);
|
||||
}
|
||||
else {
|
||||
if (OSTYPE_IS_OSX_RECOVERY(Entry->LoaderType)) {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%a_recovery",
|
||||
Entry->OSVersion);
|
||||
}
|
||||
else {
|
||||
UnicodeSPrint(DirName, sizeof(DirName), L"%a_normal",
|
||||
Entry->OSVersion);
|
||||
}
|
||||
}
|
||||
AddMenuEntry(SubScreen, SubMenuKextBlockInjection(DirName));
|
||||
}
|
||||
}
|
||||
else {
|
||||
AddMenuInfoLine(SubScreen,
|
||||
PoolPrint(
|
||||
L"Block injected kexts for target version of macOS: %a",
|
||||
ChosenOS));
|
||||
}
|
||||
if ((kextDir = GetOtherKextsDir(TRUE)) != NULL) {
|
||||
AddMenuEntry(SubScreen, SubMenuKextBlockInjection(L"Other"));
|
||||
FreePool(kextDir);
|
||||
}
|
||||
if ((kextDir = GetOtherKextsDir(FALSE)) != NULL) {
|
||||
AddMenuEntry(SubScreen, SubMenuKextBlockInjection(L"Off"));
|
||||
FreePool(kextDir);
|
||||
}
|
||||
|
||||
AddMenuEntry(SubScreen, &MenuEntryReturn);
|
||||
return SubEntry;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user