Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Alkenso/43f516b1a7f34a92d38fdd71fbb3858e to your computer and use it in GitHub Desktop.
Save Alkenso/43f516b1a7f34a92d38fdd71fbb3858e to your computer and use it in GitHub Desktop.
Observe KEXT: NSDistributedNotificationCenter
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
private var _token: NSObjectProtocol?
func applicationDidFinishLaunching(_ notification: Notification) {
_token = DistributedNotificationCenter.default().addObserver(forName: NSNotification.Name(rawValue: "Loaded Kext Notification"),
object: nil,
queue: .main, using: Self.handleNotification)
}
private static func handleNotification(notification: Notification) {
guard let userInfo = notification.userInfo as? [String: Any],
let loadedKexts = userInfo["KextArrayKey"] as? [[String: Any]] else {
return
}
for kextInfo in loadedKexts {
guard let bundleIdentifier = kextInfo["com.apple.message.bundleID"] as? String,
let path = kextInfo["com.apple.message.kextpath"] as? String else {
continue
}
NSLog("KEXT \(bundleIdentifier) loaded from \(path).")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment