Reputation: 556
Is it possible to load a kernel extension (kext
) through a C API instead of using the system()
call?
Upvotes: 2
Views: 852
Reputation: 3906
CFStringRef km_path = CFStringCreateWithCString(kCFAllocatorDefault, "/Library/Extensions/KauthORama.kext",
kCFStringEncodingUTF8);
CFURLRef km_url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, km_path,
kCFURLPOSIXPathStyle, true);
OSReturn status = KextManagerLoadKextWithURL(km_url, NULL);
if (status == kOSReturnSuccess){
syslog(LOG_NOTICE, "Loaded!");
}else{
syslog(LOG_NOTICE, "Lodaed error: %d", errno);
}
Upvotes: 0
Reputation: 23438
Yes, you want the KextManager API. In particular, KextManagerLoadKextWithIdentifier()
is probably the function you'll want to use to load an installed kext, versus KextManagerLoadKextWithURL()
if you want to load a kext that is not in /System/Library/Extensions or /Library/Extensions but e.g. in an .app bundle.
Upvotes: 3