Last active
April 29, 2020 18:39
-
-
Save Alkenso/65a7badef5b22d6c986a3ef68e4bf9a8 to your computer and use it in GitHub Desktop.
Observe KEXT: polling
This file contains hidden or 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 IOKit.kext // #import <IOKit/kext/KextManager.h> | |
| func LocateKEXT(_ identifier: String) -> URL? { | |
| KextManagerCreateURLForBundleIdentifier(kCFAllocatorDefault, identifier as CFString)?.takeRetainedValue() as URL? | |
| } | |
| func IsKEXTLoaded(_ identifier: String) -> Bool { | |
| LocateKEXT(identifier) != nil | |
| } | |
| let kextIdentifier = "com.alkenso.TestKext" | |
| var kextLoadedState = IsKEXTLoaded(kextIdentifier) | |
| Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { (_) in | |
| let currentKextLoadedState = IsKEXTLoaded(kextIdentifier) | |
| if kextLoadedState != currentKextLoadedState { | |
| kextLoadedState = currentKextLoadedState | |
| NSLog("KEXT \(kextIdentifier) is loaded: \(currentKextLoadedState)") | |
| } | |
| } | |
| RunLoop.main.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment