Skip to content
/ kextgizmos Public

A collection of helper functions, macros, and similar which are useful for developing macOS DriverKit and kernel extensions (dexts & kexts) and working with them from user space. Mirror of https://gitlab.com/pmdj/kextgizmos

Notifications You must be signed in to change notification settings

pmj/kextgizmos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kextgizmos

This is a collection (library?) of functions, data structures and macros which we have created, and which have repeatedly come in useful while developing macOS/OS X kernel extensions (kexts).

These gizmos are dual-licensed under the permissive zLib and MIT Free Software licenses. Please comply with the terms of one or the other when including the code in derived works.

To use, just copy the relevant files into your kext project and add them to the build system you're using. There are no dependencies beyond Kernel.framework. Make sure to run kextlibs to check whether your kext's OSBundleLibraries might need updating.

The Gizmos

ioreturn_strings

This defines a single function,

const char* djt_ioreturn_string(IOReturn r);

which returns the string representation of an IOKit return code, which you can log in place of the gobbledegook numeric value.

This gizmo is just as useful when used from user space code!

osobject_retaincount.h

Use the DJ_OSOBJECT_RETAINCOUNT() macro within an OSObject-derived class definition to get retain/release stack traces on that class. Helpful for tracking down leaks.

iopcidevice_helpers

This is a collection of helper functions for working with IOPCIDevice objects. It takes care of various boilerplate such as enumerating interrupts, including MSI/MSI-X, walking the capabilities in the device configuration range (the builtin IOPCIDevice methods fail silently on certain configuration layouts), working with BARs, and logging the whole config area.

profiling

Some very basic time measurement helpers for generating min/max/mean/stddev of measured code runtimes in nanoseconds with little overhead (no locks) and a drop-in IOUserClient external method for extracting the data from user space.

You must #define the DJ_PROFILE_ENABLE macro to switch this on (e.g. only for certain builds)

osdictionary_util

OSDictionary objects can be awkward to deal with due to all the retaining, releasing, casting, etc. The log_dictionary_contents() function helps you debug problems by pretty-printing the contents of a dictionary.

See also

About

A collection of helper functions, macros, and similar which are useful for developing macOS DriverKit and kernel extensions (dexts & kexts) and working with them from user space. Mirror of https://gitlab.com/pmdj/kextgizmos

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published