bool AlcEnabler::init() { progressState = ProcessingState::NotReady; patcher.init(); if (patcher.getError() != KernelPatcher::Error::NoError) { DBGLOG("alc @ failed to initialise kernel patcher"); patcher.clearError(); return false; } return loadKexts(); }
static int loadKexts(char * targetFolder, bool isPluginRun) { bool isBundleType2 = false; long result = -1; long dirEntryFlags, dirEntryTime, dirEntryIndex = 0; const char * dirEntryName; while (1) { _DRIVERS_DEBUG_DUMP("O"); result = GetDirEntry(targetFolder, &dirEntryIndex, &dirEntryName, &dirEntryFlags, &dirEntryTime); if (result == -1) { _DRIVERS_DEBUG_DUMP("b"); // Back to loadKexts() when isPluginRun is true or loadDrivers() when false. break; } // Kexts are just folders so we need to have one. if ((dirEntryFlags & kFileTypeMask) == kFileTypeDirectory) { // Checking the file extension. if (strcmp(dirEntryName + (strlen(dirEntryName) - 5), ".kext") == 0) { sprintf(gPlatform.KextFileName, "%s/%s", targetFolder, dirEntryName); #if DEBUG_DRIVERS if (strlen(gPlatform.KextFileName) >= MAX_KEXT_PATH_LENGTH) { stop("Error: gPlatform.KextFileName >= %d chars. Change MAX_KEXT_PATH_LENGTH!", MAX_KEXT_PATH_LENGTH); } #endif // Determine bundle type. isBundleType2 = (GetFileInfo(gPlatform.KextFileName, "Contents", &dirEntryFlags, &dirEntryTime) == 0); result = loadPlist(gPlatform.KextFileName, isBundleType2); // False the first time we're here but true for the recursive call. if (!isPluginRun) { // Setup plug-ins path. sprintf(gPlatform.KextFileSpec, "%s/%sPlugIns", gPlatform.KextFileName, (isBundleType2) ? "Contents/" : ""); #if DEBUG_DRIVERS if (strlen(gPlatform.KextFileSpec) >= MAX_KEXT_PATH_LENGTH) { stop("Error: gPlatform.KextFileSpec >= %d chars. Change MAX_KEXT_PATH_LENGTH!", MAX_KEXT_PATH_LENGTH); } #endif _DRIVERS_DEBUG_DUMP("R"); // Recursive call for kexts in the PlugIns folder. result = loadKexts(gPlatform.KextFileSpec, true); } } } } return result; }
long loadDrivers(char * dirSpec) { if (initDriverSupport() != STATE_SUCCESS) { return -1; } bool shouldLoadMKext = ((gBootMode & kBootModeSafe) == 0); _DRIVERS_DEBUG_DUMP("shouldLoadMKext: %s\n", shouldLoadMKext ? "true" : "false"); if (shouldLoadMKext) // Skipped in "Safe Boot" mode. { if (loadMultiKext(gPlatform.KernelCachePath) == STATE_SUCCESS) { gKextLoadStatus |= 1; _DRIVERS_DEBUG_DUMP("loadMultiKext(1) OK.\n"); } if (loadMultiKext("/Extra") == STATE_SUCCESS) { gKextLoadStatus |= 2; _DRIVERS_DEBUG_DUMP("loadMultiKext(2) OK.\n"); } } _DRIVERS_DEBUG_DUMP("gKextLoadStatus: %d\n", gKextLoadStatus); _DRIVERS_DEBUG_SLEEP(5); // Do we need to load individual kexts, in a one by one fashion? if (gKextLoadStatus != 3) { _DRIVERS_DEBUG_DUMP("gKextLoadStatus != 3\n"); // Yes we do. Start by looking for kexts in: /Extra/Extensions/ if ((gKextLoadStatus & 2) == 0) { _DRIVERS_DEBUG_DUMP("Calling loadKexts(\"/Extra/Extensions\");\n"); if (loadKexts("/Extra/Extensions", 0) == STATE_SUCCESS) { _DRIVERS_DEBUG_DUMP("loadKexts(2) OK.\n"); } _DRIVERS_DEBUG_DUMP("\n"); } // Now progress to the system kexts. if ((gKextLoadStatus & 1) == 0) { _DRIVERS_DEBUG_DUMP("\nCalling loadKexts(\"/System/Library/Extensions\");\n"); if (loadKexts("/System/Library/Extensions", 0) == STATE_SUCCESS) { _DRIVERS_DEBUG_DUMP("loadKexts(1) OK.\n"); } _DRIVERS_DEBUG_DUMP("\n"); } matchLibraries(); loadMatchedModules(); } _DRIVERS_DEBUG_SLEEP(15); return STATE_SUCCESS; }