- OSObject * parsedXML = NULL; // must release
- OSArray * builtinExtensions = NULL; // do not release
- OSArray * allPersonalities = NULL; // must release
- OSString * errorString = NULL; // must release
- kernel_section_t * infosect = NULL; // do not free
- OSCollectionIterator * personalitiesIterator = NULL; // must release
- unsigned int count, i;
-
- OSKextLog(/* kext */ NULL,
- kOSKextLogStepLevel |
- kOSKextLogLoadFlag,
- "Reading built-in kernel personalities for I/O Kit drivers.");
-
- /* Look in the __BUILTIN __info segment for an array of Info.plist
- * entries. For each one, extract the personalities dictionary, add
- * it to our array, then push them all (without matching) to
- * the IOCatalogue. This can be used to augment the personalities
- * in gIOKernelConfigTables, especially when linking entire kexts into
- * the mach_kernel image.
- */
- infosect = getsectbyname("__BUILTIN", "__info");
- if (!infosect) {
- // this isn't fatal
- goto finish;
- }
-
- parsedXML = OSUnserializeXML((const char *) (uintptr_t)infosect->addr,
- &errorString);
- if (parsedXML) {
- builtinExtensions = OSDynamicCast(OSArray, parsedXML);
- }
- if (!builtinExtensions) {
- const char * errorCString = "(unknown error)";
-
- if (errorString && errorString->getCStringNoCopy()) {
- errorCString = errorString->getCStringNoCopy();
- } else if (parsedXML) {
- errorCString = "not an array";
- }
- OSKextLog(/* kext */ NULL,
- kOSKextLogErrorLevel |
- kOSKextLogLoadFlag,
- "Error unserializing built-in personalities: %s.", errorCString);
- goto finish;
- }
-
- // estimate 3 personalities per Info.plist/kext
- count = builtinExtensions->getCount();
- allPersonalities = OSArray::withCapacity(count * 3);
-
- for (i = 0; i < count; i++) {
- OSDictionary * infoDict = NULL; // do not release
- OSString * moduleName = NULL; // do not release
- OSDictionary * personalities; // do not release
- OSString * personalityName; // do not release
-
- OSSafeReleaseNULL(personalitiesIterator);
-
- infoDict = OSDynamicCast(OSDictionary,
- builtinExtensions->getObject(i));
- if (!infoDict) {
- continue;
- }
-
- moduleName = OSDynamicCast(OSString,
- infoDict->getObject(kCFBundleIdentifierKey));
- if (!moduleName) {
- continue;
- }
-
- OSKextLog(/* kext */ NULL,
- kOSKextLogStepLevel |
- kOSKextLogLoadFlag,
- "Adding personalities for built-in driver %s:",
- moduleName->getCStringNoCopy());
-
- personalities = OSDynamicCast(OSDictionary,
- infoDict->getObject("IOKitPersonalities"));
- if (!personalities) {
- continue;
- }
-
- personalitiesIterator = OSCollectionIterator::withCollection(personalities);
- if (!personalitiesIterator) {
- continue; // xxx - well really, what can we do? should we panic?
- }
-
- while ((personalityName = OSDynamicCast(OSString,
- personalitiesIterator->getNextObject()))) {
-
- OSDictionary * personality = OSDynamicCast(OSDictionary,
- personalities->getObject(personalityName));
-
- OSKextLog(/* kext */ NULL,
- kOSKextLogDetailLevel |
- kOSKextLogLoadFlag,
- "Adding built-in driver personality %s.",
- personalityName->getCStringNoCopy());
-
+ OSObject * parsedXML = NULL;// must release
+ OSArray * builtinExtensions = NULL;// do not release
+ OSArray * allPersonalities = NULL;// must release
+ OSString * errorString = NULL;// must release
+ kernel_section_t * infosect = NULL;// do not free
+ OSCollectionIterator * personalitiesIterator = NULL;// must release
+ unsigned int count, i;
+
+ OSKextLog(/* kext */ NULL,
+ kOSKextLogStepLevel |
+ kOSKextLogLoadFlag,
+ "Reading built-in kernel personalities for I/O Kit drivers.");
+
+ /* Look in the __BUILTIN __info segment for an array of Info.plist
+ * entries. For each one, extract the personalities dictionary, add
+ * it to our array, then push them all (without matching) to
+ * the IOCatalogue. This can be used to augment the personalities
+ * in gIOKernelConfigTables, especially when linking entire kexts into
+ * the mach_kernel image.
+ */
+ infosect = getsectbyname("__BUILTIN", "__info");
+ if (!infosect) {
+ // this isn't fatal
+ goto finish;
+ }
+
+ parsedXML = OSUnserializeXML((const char *) (uintptr_t)infosect->addr,
+ &errorString);
+ if (parsedXML) {
+ builtinExtensions = OSDynamicCast(OSArray, parsedXML);
+ }
+ if (!builtinExtensions) {
+ const char * errorCString = "(unknown error)";
+
+ if (errorString && errorString->getCStringNoCopy()) {
+ errorCString = errorString->getCStringNoCopy();
+ } else if (parsedXML) {
+ errorCString = "not an array";
+ }
+ OSKextLog(/* kext */ NULL,
+ kOSKextLogErrorLevel |
+ kOSKextLogLoadFlag,
+ "Error unserializing built-in personalities: %s.", errorCString);
+ goto finish;
+ }
+
+ // estimate 3 personalities per Info.plist/kext
+ count = builtinExtensions->getCount();
+ allPersonalities = OSArray::withCapacity(count * 3);
+
+ for (i = 0; i < count; i++) {
+ OSDictionary * infoDict = NULL;// do not release
+ OSString * moduleName = NULL;// do not release
+ OSDictionary * personalities;// do not release
+ OSString * personalityName;// do not release
+
+ OSSafeReleaseNULL(personalitiesIterator);
+
+ infoDict = OSDynamicCast(OSDictionary,
+ builtinExtensions->getObject(i));
+ if (!infoDict) {
+ continue;
+ }
+
+ moduleName = OSDynamicCast(OSString,
+ infoDict->getObject(kCFBundleIdentifierKey));
+ if (!moduleName) {
+ continue;
+ }
+
+ OSKextLog(/* kext */ NULL,
+ kOSKextLogStepLevel |
+ kOSKextLogLoadFlag,
+ "Adding personalities for built-in driver %s:",
+ moduleName->getCStringNoCopy());
+
+ personalities = OSDynamicCast(OSDictionary,
+ infoDict->getObject("IOKitPersonalities"));
+ if (!personalities) {
+ continue;
+ }
+
+ personalitiesIterator = OSCollectionIterator::withCollection(personalities);
+ if (!personalitiesIterator) {
+ continue; // xxx - well really, what can we do? should we panic?
+ }
+
+ while ((personalityName = OSDynamicCast(OSString,
+ personalitiesIterator->getNextObject()))) {
+ OSDictionary * personality = OSDynamicCast(OSDictionary,
+ personalities->getObject(personalityName));
+
+ OSKextLog(/* kext */ NULL,
+ kOSKextLogDetailLevel |
+ kOSKextLogLoadFlag,
+ "Adding built-in driver personality %s.",
+ personalityName->getCStringNoCopy());
+