Created
January 4, 2023 04:19
-
-
Save Avangelista/c80371357677c74f00fd248f6c8e7fbb to your computer and use it in GitHub Desktop.
Check if iOS device is locked using Swift
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
| let sbs = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY) | |
| defer { | |
| dlclose(sbs) | |
| } | |
| let symbol1 = dlsym(sbs, "SBSSpringBoardServerPort") | |
| let SBSSpringBoardServerPort = unsafeBitCast(symbol1, to: (@convention(c) () -> mach_port_t).self) | |
| let symbol2 = dlsym(sbs, "SBGetScreenLockStatus") | |
| var lockStatus: ObjCBool = false | |
| var passcodeEnabled: ObjCBool = false | |
| let SBGetScreenLockStatus = unsafeBitCast(symbol2, to: (@convention(c) (mach_port_t, UnsafeMutablePointer<ObjCBool>, UnsafeMutablePointer<ObjCBool>) -> Void).self) | |
| SBGetScreenLockStatus(SBSSpringBoardServerPort(), &lockStatus, &passcodeEnabled) | |
| print(lockStatus) | |
| print(passcodeEnabled) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment