diff options
author | Sam Bingner <sam@bingner.com> | 2024-05-13 11:48:00 -1000 |
---|---|---|
committer | Sam Bingner <sam@bingner.com> | 2024-05-13 11:49:41 -1000 |
commit | 284520390d792703c0873b22d20b29e34a31cdcb (patch) | |
tree | 4ef88637d5fe0b4a5f4cb1fa086e416e30d393a6 | |
parent | 0c426991076e724613c36431c59d8ef66838598b (diff) |
-rw-r--r-- | makefile | 2 | ||||
-rw-r--r-- | uiopen.mm | 31 | ||||
-rw-r--r-- | uiopen.xml | 2 |
3 files changed, 26 insertions, 9 deletions
@@ -21,7 +21,7 @@ iomfsetgamma := -I. $(private) -framework IOKit -framework IOMobileFramebuffer sbdidlaunch := $(private) -framework SpringBoardServices uicache := -framework UIKit -framework MobileCoreServices uiduid := -framework UIKit -uiopen := -framework UIKit +uiopen := -framework UIKit -fobjc-arc uishoot := -framework UIKit uicache: csstore.cpp @@ -56,21 +56,36 @@ #include <stdio.h> #include <dlfcn.h> +@interface UIApplication (uiopen) +-(BOOL)launchApplicationWithIdentifier:(NSString*)identifier suspended:(BOOL)suspended; +@end + int main(int argc, char *argv[]) { if (argc != 2) { - fprintf(stderr, "usage: %s <url>\n", argv[0]); + fprintf(stderr, "usage: %s <url|bundleid>\n", argv[0]); return 1; } - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *arg = [NSString stringWithUTF8String:argv[1]]; + NSURL *url = [NSURL URLWithString:arg]; + UIApplication *app = [UIApplication alloc]; + + bool success = false; + // Try opening as a bundle ID + if (int (*SBSLaunchApplicationWithIdentifier)(CFStringRef id, BOOL suspended) = (int (*)(CFStringRef, BOOL)) dlsym(RTLD_DEFAULT, "SBSLaunchApplicationWithIdentifier")) + success = !(*SBSLaunchApplicationWithIdentifier)((__bridge CFStringRef)arg, false); + else + success = [app launchApplicationWithIdentifier:arg suspended:NO]; - NSURL *url([NSURL URLWithString:[NSString stringWithUTF8String:argv[1]]]); + if (success == YES) { + return 0; + } - if (void (*SBSOpenSensitiveURLAndUnlock)(NSURL *, BOOL) = (void (*)(NSURL *, BOOL)) dlsym(RTLD_DEFAULT, "SBSOpenSensitiveURLAndUnlock")) - (*SBSOpenSensitiveURLAndUnlock)(url, YES); + // Try opening as a URL + if (BOOL (*SBSOpenSensitiveURLAndUnlock)(NSURL *, BOOL) = (BOOL (*)(NSURL *, BOOL)) dlsym(RTLD_DEFAULT, "SBSOpenSensitiveURLAndUnlock")) + success = (*SBSOpenSensitiveURLAndUnlock)(url, YES); else - [[UIApplication alloc] openURL:url]; + success = [app openURL:url]; - [pool release]; - return 0; + return !(success == YES); } @@ -3,6 +3,8 @@ <dict> <key>com.apple.springboard.opensensitiveurl</key> <true/> + <key>com.apple.springboard.launchapplications</key> + <true/> <key>platform-application</key> <true/> <key>com.apple.private.skip-library-validation</key> |