Mac Developer Library

Developer

KextManager.h Reference

Options
Deployment Target:

On This Page

KextManager.h Reference

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Not Applicable

Objective-C

@import IOKit;

The KextManager API provides a simple interface for applications to load kernel extensions (kexts) via RPC to kextd, and to look up the URLs for kexts by bundle identifier.

Included Headers

  • <CoreFoundation/CoreFoundation.h>

  • <libkern/OSReturn.h>

  • <sys/cdefs.h>

Functions

  • Returns information about loaded kexts in a dictionary.

    Declaration

    Objective-C

    CFDictionaryRef KextManagerCopyLoadedKextInfo ( CFArrayRef kextIdentifiers, CFArrayRef infoKeys );

    Parameters

    kextIdentifiers

    An array of kext identifiers to read from the kernel. Pass NULL to read info for all loaded kexts.

    infoKeys

    An array of info keys to read from the kernel. Pass NULL to read all information.

    Return Value

    A dictionary, keyed by bundle identifier, of dictionaries containing information about loaded kexts.

    Discussion

    The information keys returned by this function are listed below. Some are taken directly from the kext's information property list, and some are generated at run time. Never assume a given key will be present for a kext.

    • CFBundleIdentifier - CFString

    • CFBundleVersion - CFString (note: version strings may be canonicalized but their numeric values will be the same; "1.2.0" may become "1.2", for example)

    • OSBundleCompatibleVersion - CFString

    • OSBundleIsInterface - CFBoolean

    • OSKernelResource - CFBoolean

    • OSBundleCPUType - CFNumber

    • OSBundleCPUSubtype - CFNumber

    • OSBundlePath - CFString (this is merely a hint stored in the kernel; the kext is not guaranteed to be at this path)

    • OSBundleExecutablePath - CFString (the absolute path to the executable within the kext bundle; a hint as above)

    • OSBundleUUID - CFData (the UUID of the kext executable, if it has one)

    • OSBundleStarted - CFBoolean (true if the kext is running)

    • OSBundlePrelinked - CFBoolean (true if the kext is loaded from a prelinked kernel)

    • OSBundleLoadTag - CFNumber (the "Index" given by kextstat)

    • OSBundleLoadAddress - CFNumber

    • OSBundleLoadSize - CFNumber

    • OSBundleWiredSize - CFNumber

    • OSBundleDependencies - CFArray of load tags identifying immediate link dependencies

    • OSBundleRetainCount - CFNumber (the OSObject retain count of the kext itself)

    • OSBundleClasses - CFArray of CFDictionary containing info on C++ classes defined by the kext:

    • OSMetaClassName - CFString

    • OSMetaClassSuperclassName - CFString, absent for root classes

    • OSMetaClassTrackingCount - CFNumber giving the instance count of the class itself, plus 1 for each direct subclass with any instances

    Import Statement

    Objective-C

    @import IOKit;

    Availability

    Available in OS X v10.7 and later.

  • Create a URL locating a kext with a given bundle identifier.

    Declaration

    Objective-C

    CFURLRef KextManagerCreateURLForBundleIdentifier ( CFAllocatorRef allocator, CFStringRef kextIdentifier );

    Parameters

    allocator

    The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    kextIdentifier

    The bundle identifier to look up.

    Return Value

    A CFURLRef locating a kext with the requested bundle identifier. Returns NULL if the kext cannot be found, or on error.

    Discussion

    Kexts are looked up first by whether they are loaded, second by version. Specifically, if kextIdentifier identifies a kext that is currently loaded, the returned URL will locate that kext if it's still present on disk. If the requested kext is not loaded, or if its bundle is not at the location it was originally loaded from, the returned URL will locate the latest version of the desired kext, if one can be found within the system extensions folder. If no version of the kext can be found, NULL is returned.

    Import Statement

    Objective-C

    @import IOKit;

    Availability

    Available in OS X v10.2 and later.

  • Request the kext loading system to load a kext with a given bundle identifier.

    Declaration

    Objective-C

    OSReturn KextManagerLoadKextWithIdentifier ( CFStringRef kextIdentifier, CFArrayRef dependencyKextAndFolderURLs );

    Parameters

    kextIdentifier

    The bundle identifier of the kext to look up and load.

    dependencyKextAndFolderURLs

    An array of additional URLs, of individual kexts and of folders that may contain kexts.

    Return Value

    kOSReturnSuccess if the kext is successfully loaded (or is already loaded), otherwise returns on error.

    Discussion

    kextIdentifier is looked up in the system extensions folder and among any kexts from dependencyKextAndFolderURLs. Any non-kext URLs in dependencyKextAndFolderURLs are scanned at the top level for kexts and plugins of kexts.

    Either the calling process must have an effective user id of 0 (superuser), or the kext being loaded and all its dependencies must reside in /System and have an OSBundleAllowUserLoad property of true.

    Import Statement

    Objective-C

    @import IOKit;

    Availability

    Available in OS X v10.6 and later.

  • Request the kext loading system to load a kext with a given URL.

    Declaration

    Objective-C

    OSReturn KextManagerLoadKextWithURL ( CFURLRef kextURL, CFArrayRef dependencyKextAndFolderURLs );

    Parameters

    kextURL

    The URL of the kext to load.

    dependencyKextAndFolderURLs

    An array of additional URLs, of individual kexts and of folders that may contain kexts.

    Return Value

    kOSReturnSuccess if the kext is successfully loaded (or is already loaded), otherwise returns on error.

    Discussion

    Any non-kext URLs in dependencyKextAndFolderURLs are scanned at the top level for kexts and plugins of kexts.

    Either the calling process must have an effective user id of 0 (superuser), or the kext being loaded and all its dependencies must reside in /System and have an OSBundleAllowUserLoad property of true.

    Import Statement

    Objective-C

    @import IOKit;

    Availability

    Available in OS X v10.6 and later.

  • Request the kernel to unload a kext with a given bundle identifier.

    Declaration

    Objective-C

    OSReturn KextManagerUnloadKextWithIdentifier ( CFStringRef kextIdentifier );

    Parameters

    kextIdentifier

    The bundle identifier of the kext to unload.

    Return Value

    kOSReturnSuccess if the kext is found and successfully unloaded, otherwise returns on error. See /usr/include/libkern/OSKextLib.h for error codes.

    Discussion

    The calling process must have an effective user id of 0 (superuser).

    Import Statement

    Objective-C

    @import IOKit;

    Availability

    Available in OS X v10.7 and later.