macOS kernel SDK targeting various XNU versions
This project lets your kernel extensions (kexts) target a broad range of XNU kernels when using the latest Xcode version right from the interface. In addition, it also includes several headers only available in other projects or older Xcode releases.
To start using MacKernelSDK do the following steps:
Clone MacKernelSDK to your project directory:
git clone https://github.com/acidanthera/MacKernelSDKAdd custom KERNEL_EXTENSION_HEADER_SEARCH_PATHS and KERNEL_FRAMEWORK_HEADERS values in project configuration in Xcode. To do this choose Add User-defined Setting.
KERNEL_EXTENSION_HEADER_SEARCH_PATHS = $(PROJECT_DIR)/MacKernelSDK/Headers
KERNEL_FRAMEWORK_HEADERS = $(PROJECT_DIR)/MacKernelSDK/HeadersLink to custom libkmod.a library by adding it to your kernel extension Link Binary with Libraries.
Ensure that Library Search Paths contains the libkmod.a location, e.g.:
$(PROJECT_DIR)/MacKernelSDK/Library/x86_64Otherwise Xcode will link to the original libkmod.
Optionally add /MacKernelSDK to .gitignore.
To make sure that you use the right SDK check for __ACIDANTHERA_MAC_SDK macro in Availability.h.
i386To compile for 32-bit you will need to add a set of flags in your project:
Other C Flags (OTHER_CFLAGS):
-static-nostdlib-Wno-stdlibcxx-not-found-target i386-apple-macos10.6-fallow-unsupported-fno-stack-protector if targeting 10.5 and older-fno-jump-tables if targeting 10.5 and olderOther Linker Flags (OTHER_LDFLAGS):
-static-target i386-apple-macos10.6C++ Standard Library (CLANG_CXX_LIBRARY) to Compiler Default or empty.
Library Search Paths set to contain a kmod with an i386 slice, e.g. $(PROJECT_DIR)/MacKernelSDK/Library/universal.
The symbol table may be misaligned due to i386 kexts being of type MH_OBJECT.fix-macho32 is provided in the scripts directory of ocbuild to correct alignments. Python 3 and macholib are required.
Usage:
./fix-macho32 [bin_path]xnu-8019.80.24:libkern/OSBase.h)corecrypto, libkern/crypto)i386/cpu_topology.h and i386/pmCPU.h)security/_label.h, security/mac_framework.h, security/mac_policy.h)skywalk, IOKit/skywalk/IOSkywalkSupport.h)IOHIDPrivateKeys.hIOHIDEventServiceKeys_Private.hIOHIDEvent.hIOHIDEventFieldDefs.hIOHIDEventService.hIOHIDEventTypes.hIOHIDUtility.hAppleHIDUsageTables.h (removed in newer releases)IOBluetoothInternal.h (removed in newer releases)IOPCIHostBridge class from IOPCIFamily 484.40.6IOKit/IOSMBusController.h)IOKit/battery/AppleSmartBatteryCommands.h)kdp/kdp_support.h)IOKit/network)IOKit/skywalk)IOKit/bluetooth) for macOS 11 and belowLibrary/x86_64/libkmod.a)Library/universal/libkmod.a)string.h to avoid using new checked interfaces before 10.13IOService.h to avoid report virtual methods before 10.9RootDomain.h to avoid report virtual methods before 10.9OSMetaClass.h to avoid DriverKit usage before 10.15cdefs.h to avoid Darwin14 aliases before 10.10assert.h to avoid kext assertion checking before 10.12IOHIDDevice.h to avoid new virtual methods before 10.14IOFramebuffer.h to avoid new virtual methods before 10.13IONDRVFramebuffer.h to avoid new virtual methods before 10.13IOSCSIParallelInterfaceController.h to avoid new virtual methods before 10.7IOPCIBridge.h to avoid new virtual methods before 12.0IOService.h to avoid init methods before 10.10IOUserClient.h to avoid new virtual methods before 10.6IOBlockStorageDevice.h to avoid new virtual methods before 10.12ipc_mig.h to avoid new methods before 10.6IOPCIDevice.h due to missing overridesOSMetaClass.h due to using unsupported memory checking with older clangkauth.h due to KPI deprecationnet, netinit, network, sys due to NKE KPI deprecationhid, serial, usb due to missing overrides and KPI deprecation in favor of DriverKitOSUnserialize.h due to OSStringPtr misuseKUNCUserNotifications.h due to KPI deprecationIOSCSIParallelInterfaceController.h due to missing overridesIOPCIBridge.h due to missing overridesIOUserClient.h to avoid issues with IOExternalMethod on 32-bit platformsIOMethodACID32 in place of IOMethod, referencing a static method taking the class as the first parameterpadding in IOExternalMethod to kIOExternalMethodACID32PaddingIOExternalMethod definition for more detailsNo open issues yet, or sync has not completed.