Last active
April 29, 2020 18:38
-
-
Save Alkenso/43f516b1a7f34a92d38fdd71fbb3858e to your computer and use it in GitHub Desktop.
Observe KEXT: NSDistributedNotificationCenter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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