Skip to main content

A library for working with a directory with KDK's

Project description

kdk_storage

A small Python library for working with a directory of Apple Kernel Debug Kits (KDKs).

It scans a folder full of installed KDKs, sorts them by version (handling beta ordering), and gives you a simple API to locate the kernel and driver (kext) binaries inside any given KDK.

What is a KDK?

A Kernel Debug Kit is a package Apple ships for each macOS build that contains the (usually unstripped) kernel and kext binaries used for kernel debugging and research. When installed, each KDK lives in its own directory named like:

KDK_15.5_24F74.kdk

kdk_storage treats a parent folder holding many such directories as a single addressable storage.

Installation

Requires Python >= 3.9. The project is built with Hatchling.

pip install .

or, for development:

pip install -e .

Usage

from pathlib import Path
from kdk_storage import KDKStorage

# Point at the directory that contains your KDK_* folders.
storage = KDKStorage(Path("/Library/Developer/KDKs"))

# List available versions (optionally skipping betas).
print(storage.get_versions_list(skip_betas=False))
# ['15.4_24E248', '15.5_24F74', ...]

# Human-readable listing that marks betas.
for line in storage.get_versions_list_to_print(skip_betas=False):
    print(line)
# 15.5_24F74
# 15.6_24G5054d (beta)

# Resolve a kernel binary for a version.
kernel = storage.kernel("15.5_24F74", "kernel")
print(kernel.binary)        # full path to the kernel Mach-O
print(kernel.is_macho_fat())  # True if it's a fat/universal binary

Partial version matching

KDKStorage.kernel() accepts a partial version string. If the argument isn't an exact match but is a substring of exactly one available version, that version is used:

storage.kernel("24F74", "kernel")   # matches 15.5_24F74

If the substring is ambiguous (matches more than one version) or matches none, kernel() returns None.

Working with drivers

Given a specific KDK, you can also resolve a driver (kext) binary:

kdk = storage.hashmap_versions["15.5_24F74"]
driver = kdk.driver("AppleACPIPlatform")
print(driver.binary)  # path to the kext's Mach-O under Contents/MacOS

API overview

Class Purpose
KDKStorage Scans a directory of KDKs, sorts them by version, and resolves kernels/drivers.
KDK A single Kernel Debug Kit directory; knows its version and whether it's a beta.
KDKElement Base class for a binary inside a KDK. Provides is_macho_fat().
Kernel A kernel binary under System/Library/Kernels.
Driver A kext binary under System/Library/Extensions/<name>.kext/Contents/MacOS.

Version ordering

KDKs are sorted by their numeric version components, with two tie-breaking rules:

  • A beta build (detected when the last character of the version string is a lowercase letter, e.g. 24G5054d) sorts before the corresponding release build.
  • Otherwise the build identifier (the part after _) is compared lexicographically.

License

MIT © Valentin Shilnenkov

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kdk_storage-0.0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kdk_storage-0.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file kdk_storage-0.0.1.tar.gz.

File metadata

  • Download URL: kdk_storage-0.0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for kdk_storage-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2c74de3de2debf71455dac87953dabacf27e13de5efff14e9f8af2c40a7018e7
MD5 a1afb01071eebeeb22b22b92ac635cfb
BLAKE2b-256 b80c2c1022b90290df83562c2365e166e5c214b85eec6e89e628c111a33f2fc1

See more details on using hashes here.

File details

Details for the file kdk_storage-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: kdk_storage-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for kdk_storage-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 89ea89d4c85010e126855815bf1d09dfc06bbea14ca577bfc15d6d0c05750df1
MD5 9a04874685fc560c4bbe12fa538babc4
BLAKE2b-256 4d96de693909ecb28fbbb34552dcab78f4328ba6aa975413461ff26a784a7cf7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page