我正在使用其中的一些函数IOKit/kext/KextManager.h
以编程方式加载内核扩展,并且遇到了新的错误值。例如:
OSReturn osr = KextManagerLoadKextWithIdentifier(...);
// => -603947004
如何将此值转换为中找到的人类可读定义之一libkern/OSReturn.h
?
我正在使用其中的一些函数IOKit/kext/KextManager.h
以编程方式加载内核扩展,并且遇到了新的错误值。例如:
OSReturn osr = KextManagerLoadKextWithIdentifier(...);
// => -603947004
如何将此值转换为中找到的人类可读定义之一libkern/OSReturn.h
?
根据@pmjordan 的评论,我刚刚使用来自OSReturn.h
.
- (void)human_readable_libkern_metaclass_error_message:(int) n {
switch(n){
case 0:
printf("%s", "no error");
break;
case kOSMetaClassInternal:
// libkern_metaclass_err(1) -603979775
printf("%s", "Internal OSMetaClass run-time error.");
break;
case kOSMetaClassHasInstances:
// libkern_metaclass_err(2) -603979774
printf("%s", "A kext cannot be unloaded because there are instances derived from Libkern C++ classes that it defines.");
break;
case kOSMetaClassNoInit:
// libkern_metaclass_err(3) -603979773
printf("%s", "Internal error: The Libkern C++ class registration system was not properly initialized during kext loading.");
break;
case kOSMetaClassNoTempData:
// libkern_metaclass_err(4) -603979772
printf("%s", "Internal error: An allocation failure occurred registering Libkern C++ classes during kext loading.");
break;
case kOSMetaClassNoDicts:
// libkern_metaclass_err(5) -603979771
printf("%s", "Internal error: An allocation failure occurred registering Libkern C++ classes during kext loading.");
break;
case kOSMetaClassNoKModSet:
// libkern_metaclass_err(6) -603979770
printf("%s", "Internal error: An allocation failure occurred registering Libkern C++ classes during kext loading.");
break;
case kOSMetaClassNoInsKModSet:
// libkern_metaclass_err(7) -603979769
printf("%s", "Internal error: An error occurred registering a specific Libkern C++ class during kext loading.");
break;
case kOSMetaClassNoSuper:
// libkern_metaclass_err(8) -603979768
printf("%s", "Internal error: No superclass can be found for a specific Libkern C++ class during kext loading.");
break;
case kOSMetaClassInstNoSuper:
// libkern_metaclass_err(9) -603979767
printf("%s", "Internal error: No superclass can be found when constructing an instance of a Libkern C++ class.");
break;
case kOSMetaClassDuplicateClass:
// libkern_metaclass_err(10) -603979766
printf("%s", "A duplicate Libkern C++ classname was encountered during kext loading.");
break;
case kOSMetaClassNoKext:
// libkern_metaclass_err(11) -603979765
printf("%s", "Internal error: The kext for a Libkern C++ class can't be found during kext loading.");
break;
default:
printf("%s", "Unknown: error not defined in <libkern/OSReturn.h>)");
break;
}
}
XXX 加载失败 - (libkern/kext) 没有特权;检查系统/内核日志是否有错误或尝试 kextutil(8)。
当您在没有 root 权限的情况下尝试 kextload 时收到的错误消息。
-603947004 - 当您尝试通过没有 root 权限的代码加载 kext 时,此代码会出现在 OSReturn 中。上面的翻译代码适用于已定义的情况,但对于未定义的错误代码,通过终端调用命令会有所帮助。