• Stars
    star
    167
  • Rank 226,635 (Top 5 %)
  • Language
    C
  • License
    Other
  • Created about 4 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

macOS kernel SDK targeting various XNU versions

MacKernelSDK

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.

Quick start

To start using MacKernelSDK do the following steps:

  1. Clone MacKernelSDK to your project directory:

    git clone https://github.com/acidanthera/MacKernelSDK
  2. Add 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/Headers
    

    xcode-config

  3. Link to custom libkmod.a library by adding it to your kernel extension Link Binary with Libraries.

    xcode-link

  4. Ensure that Library Search Paths contains the libkmod.a location, e.g.:

    $(PROJECT_DIR)/MacKernelSDK/Library/x86_64
    

    Otherwise Xcode will link to the original libkmod.

  5. Optionally add /MacKernelSDK to .gitignore.

  6. To make sure that you use the right SDK check for __ACIDANTHERA_MAC_SDK macro in Availability.h.

Targeting i386

To compile for 32-bit you will need to add a set of flags in your project:

  1. 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 older
  2. Other Linker Flags (OTHER_LDFLAGS):

    • -static
    • -target i386-apple-macos10.6
  3. C++ Standard Library (CLANG_CXX_LIBRARY) to Compiler Default or empty.

  4. Library Search Paths set to contain a kmod with an i386 slice, e.g. $(PROJECT_DIR)/MacKernelSDK/Library/universal.

  5. 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]
    

Extensions and modifications

  • Based on macOS 11 SDK from Xcode 12.0 (12A7209)
  • Added extra headers from xnu-8019.80.24:
    • Absolute time macros (libkern/OSBase.h)
    • Cryptography (corecrypto, libkern/crypto)
    • CPU PM (i386/cpu_topology.h and i386/pmCPU.h)
    • MAC Framework (security/_label.h, security/mac_framework.h, security/mac_policy.h)
    • Skywalk Subsystem (skywalk, IOKit/skywalk/IOSkywalkSupport.h)
  • Added private headers from IOHIDFamily 1446.140.2:
    • IOHIDPrivateKeys.h
    • IOHIDEventServiceKeys_Private.h
    • IOHIDEvent.h
    • IOHIDEventFieldDefs.h
    • IOHIDEventService.h
    • IOHIDEventTypes.h
    • IOHIDUtility.h
  • Added private headers from IOHIDFamily 1035.70.7:
    • AppleHIDUsageTables.h (removed in newer releases)
  • Added private headers for IOBluetoothFamily from 10.6 SDK
    • IOBluetoothInternal.h (removed in newer releases)
  • Added private IOPCIHostBridge class from IOPCIFamily 484.40.6
  • Added extra compiled and reverse-engineered headers:
    • SMBus (IOKit/IOSMBusController.h)
    • Apple Smart Battery (IOKit/battery/AppleSmartBatteryCommands.h)
    • KDP (kdp/kdp_support.h)
    • NKE private APIs (IOKit/network)
    • IOUSBFamily from macOS 10.10 SDK
    • IO80211Family from Black80211 originally created by Roman Peshkov
    • IOSkywalkFamily by cjiang (IOKit/skywalk)
    • IOBluetoothFamily by cjiang (IOKit/bluetooth) for macOS 11 and below
  • Added kmod targeting earlier macOS kernels:
    • 10.6 64-bit or newer (Library/x86_64/libkmod.a)
    • 10.4 or newer (Library/universal/libkmod.a)
  • Added availability checking when targeting older macOS versions:
    • In string.h to avoid using new checked interfaces before 10.13
    • In IOService.h to avoid report virtual methods before 10.9
    • In RootDomain.h to avoid report virtual methods before 10.9
    • In OSMetaClass.h to avoid DriverKit usage before 10.15
    • In cdefs.h to avoid Darwin14 aliases before 10.10
    • In assert.h to avoid kext assertion checking before 10.12
    • In IOHIDDevice.h to avoid new virtual methods before 10.14
    • In IOFramebuffer.h to avoid new virtual methods before 10.13
    • In IONDRVFramebuffer.h to avoid new virtual methods before 10.13
    • In IOSCSIParallelInterfaceController.h to avoid new virtual methods before 10.7
    • In IOPCIBridge.h to avoid new virtual methods before 12.0
    • In IOService.h to avoid init methods before 10.10
    • In IOUserClient.h to avoid new virtual methods before 10.6
    • In IOBlockStorageDevice.h to avoid new virtual methods before 10.12
    • In ipc_mig.h to avoid new methods before 10.6
  • Fixed compiler warnings:
    • In IOPCIDevice.h due to missing overrides
    • In OSMetaClass.h due to using unsupported memory checking with older clang
    • In kauth.h due to KPI deprecation
    • In net, netinit, network, sys due to NKE KPI deprecation
    • In hid, serial, usb due to missing overrides and KPI deprecation in favor of DriverKit
    • In OSUnserialize.h due to OSStringPtr misuse
    • In KUNCUserNotifications.h due to KPI deprecation
    • In IOSCSIParallelInterfaceController.h due to missing overrides
    • In IOPCIBridge.h due to missing overrides

More Repositories

1

OpenCorePkg

OpenCore bootloader
C
13,029
star
2

Lilu

Arbitrary kext and process patching on macOS
C
3,585
star
3

AppleALC

Native macOS HD audio for not officially supported codecs
C++
3,439
star
4

WhateverGreen

Various patches necessary for certain ATI/AMD/Intel/Nvidia GPUs
C++
3,236
star
5

VirtualSMC

SMC emulator layer
C++
1,664
star
6

BrcmPatchRAM

C++
1,037
star
7

MaciASL

ACPI editing IDE for macOS
Objective-C
749
star
8

OcBinaryData

733
star
9

NVMeFix

C++
685
star
10

AirportBrcmFixup

An open source kernel extension providing a set of patches required for non-native Airport Broadcom Wi-Fi cards.
C++
643
star
11

MacHyperVSupport

Hyper-V integration support for macOS
C++
620
star
12

AppleSupportPkg

AppleSupportPkg - contains UEFI drivers for Apple environment support
559
star
13

CPUFriend

Dynamic macOS CPU power management data injection
C++
535
star
14

VoodooPS2

C++
513
star
15

IntelMausi

Intel Ethernet LAN driver for macOS
C
390
star
16

bugtracker

Acidanthera Bugtracker
375
star
17

HibernationFixup

A Lilu plugin intended to fix hibernation compatibility issues
C++
371
star
18

FeatureUnlock

Add Sidecar support to unsupported models
C++
362
star
19

gfxutil

Device Properties conversion tool
C
274
star
20

MacInfoPkg

Mac Platform Information
249
star
21

RestrictEvents

C++
249
star
22

CpuTscSync

It is a Lilu plugin, combining functionality of VoodooTSCSync and disabling xcpm_urgency if TSC is not in sync. It should solve kernel panics after wake.
C++
171
star
23

AptioFixPkg

AptioFixPkg drivers to workaround macOS compatibility with APTIO UEFI FW
161
star
24

Shiki

Protected video playback support and hardware video acceleration on various hardware.
152
star
25

VoodooInput

Generic Multitouch Handler kernel extension for macOS
C++
151
star
26

BrightnessKeys

Handler for brightness keys without DSDT patches
C++
132
star
27

RTCMemoryFixup

open source kernel extension providing a way to emulate some offsets in your CMOS (RTC) memory
C++
97
star
28

macserial

Decode mac serial number
96
star
29

CryptexFixup

Various patches to install Rosetta Cryptex
C++
88
star
30

BT4LEContinuityFixup

72
star
31

OcSupportPkg

OpenCore common libraries
71
star
32

IOJones

Realtime I/O Registry viewer
60
star
33

DebugEnhancer

A Lilu plugin intended to enable debug output in the macOS kernel
C++
58
star
34

audk

Acidanthera UEFI Development Kit based on EDK II edk2-stable202405
C
57
star
35

dmidecode

dmidecode version with macOS specific improvements
C
40
star
36

ocbuild

Shell
39
star
37

EmeraldSDHC

SD host controller support for macOS
C++
39
star
38

OpenCoreShell

Patched UDK Shell adopted for wide firmware range
38
star
39

EfiPkg

38
star
40

UEFIGraphicsFB

UEFI framebuffer driver for macOS
C++
28
star
41

mac-efi-firmware

C
24
star
42

CpuTopologySync

Rebuild asymmetric CPU topology on macOS.
23
star
43

DuetPkg

Duet UEFI firmware emulator
15
star
44

ocmtoc

C
7
star
45

OcLegacyPkg

Legacy OpenCorePkg repository left for historical purposes
7
star