我正在使用 IOKit/kext/KextManager.h
中的一些函数以编程方式加载内核扩展,但我遇到了新的错误值。例如:
OSReturn osr = KextManagerLoadKextWithIdentifier(...);
// => -603947004
如何将此值转换为
libkern/OSReturn.h
中人类可读的定义之一? 最佳答案
根据@pmjordan 的 comment ,我刚刚使用 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;
}
}
关于objective-c - 将 OSReturn 值转换为人类可读的定义,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13548957/