Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

they work

  • Loading branch information...
commit d5f5d018b211332bf16b2eb33ed75a621b5a1f49 0 parents
@comex authored
Showing with 109 additions and 0 deletions.
  1. +7 −0 Makefile
  2. +2 −0  ent.plist
  3. +59 −0 sblaunch.c
  4. +27 −0 sbopenurl.c
  5. +14 −0 sburlschemes.c
7 Makefile
@@ -0,0 +1,7 @@
+BINS := sblaunch sburlschemes sbopenurl
+all: $(BINS)
+%: %.c ent.plist
+ igcc -o $@ $< -std=gnu99 -framework CoreFoundation -framework SpringBoardServices
+ ldid -Sent.plist $@
+clean:
+ rm -f $(BINS)
2  ent.plist
@@ -0,0 +1,2 @@
+<dict><key>com.apple.springboard.debugapplications</key><true/><key>com.apple.springboard.opensensitiveurl</key><true/></dict>
+
59 sblaunch.c
@@ -0,0 +1,59 @@
+#include <CoreFoundation/CoreFoundation.h>
+#include <stdbool.h>
+#define SBSApplicationLaunchUnlockDevice 4
+#define SBSApplicationDebugOnNextLaunch_plus_SBSApplicationLaunchWaitForDebugger 0x402
+
+bool SBSProcessIDForDisplayIdentifier(CFStringRef id, pid_t *pid);
+int SBSLaunchApplicationWithIdentifier(CFStringRef id, char flags);
+int SBSLaunchApplicationForDebugging(CFStringRef bundleID, CFURLRef openURL, CFArrayRef arguments, CFDictionaryRef environment, CFStringRef stdout, CFStringRef stderr, char flags);
+
+int main(int argc, char **argv) {
+ bool p = false;
+ const char *url = NULL;
+ const char *bundle;
+ int flags = SBSApplicationLaunchUnlockDevice;
+
+ int c;
+ while((c = getopt(argc, argv, "pdbu:")) != -1)
+ switch(c) {
+ case 'p': p = true; break;
+ case 'd': flags |= SBSApplicationDebugOnNextLaunch_plus_SBSApplicationLaunchWaitForDebugger; break;
+ case 'b': flags |= 1; break;
+ case 'u': url = optarg; break;
+ default: goto usage;
+ }
+ if(optind == argc) goto usage;
+ bundle = argv[optind];
+
+ CFMutableArrayRef arguments = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+ while(++optind != argc) CFArrayAppendValue(arguments, CFStringCreateWithCString(NULL, argv[optind], kCFStringEncodingUTF8));
+
+
+ CFStringRef cs = CFStringCreateWithCString(NULL, bundle, kCFStringEncodingUTF8);
+ CFURLRef cu = url ? CFURLCreateWithBytes(NULL, url, strlen(url), kCFStringEncodingUTF8, NULL) : NULL;
+ if(url && !cu) {
+ fprintf(stderr, "invalid URL\n");
+ return 1;
+ }
+ int err;
+ if(err = SBSLaunchApplicationForDebugging(cs, cu, arguments, NULL, NULL, NULL, flags)) {
+ fprintf(stderr, "SBSLaunchApplicationWithIdentifier failed: %d\n", err);
+ return 1;
+ }
+ if(p) {
+ pid_t pid;
+ while(!SBSProcessIDForDisplayIdentifier(cs, &pid)) {
+ usleep(50000);
+ }
+ printf("%d\n", (int) pid);
+ }
+ return 0;
+
+ usage:
+ fprintf(stderr, "Usage: sblaunch [-p] [-d] [-b] [-u url] <bundle> [arguments...]\n"
+ " -p: print pid\n"
+ " -d: launch for debugging\n"
+ " -b: launch in background\n"
+ );
+ return 1;
+}
27 sbopenurl.c
@@ -0,0 +1,27 @@
+#include <CoreFoundation/CoreFoundation.h>
+#include <stdbool.h>
+#include <unistd.h>
+#define SBSApplicationLaunchUnlockDevice 4
+#define SBSApplicationDebugOnNextLaunch_plus_SBSApplicationLaunchWaitForDebugger 0x402
+
+bool SBSOpenSensitiveURLAndUnlock(CFURLRef url, char flags);
+
+int main(int argc, char **argv) {
+ if(argc != 2) {
+ fprintf(stderr, "Usage: sbopenurl url\n");
+ }
+ CFURLRef cu = CFURLCreateWithBytes(NULL, argv[1], strlen(argv[1]), kCFStringEncodingUTF8, NULL);
+ if(!cu) {
+ fprintf(stderr, "invalid URL\n");
+ return 1;
+ }
+ int fd = dup(2);
+ close(2);
+ bool ret = SBSOpenSensitiveURLAndUnlock(cu, 1);
+ if(!ret) {
+ dup2(fd, 2);
+ fprintf(stderr, "SBSOpenSensitiveURLAndUnlock failed\n");
+ return 1;
+ }
+ return 0;
+}
14 sburlschemes.c
@@ -0,0 +1,14 @@
+#include <CoreFoundation/CoreFoundation.h>
+#include <stdio.h>
+
+CFArrayRef SBSCopyPublicURLSchemes();
+
+int main() {
+ char buf[1024];
+ CFArrayRef ary = SBSCopyPublicURLSchemes();
+ for(CFIndex i = 0; i < CFArrayGetCount(ary); i++) {
+ CFStringGetCString(CFArrayGetValueAtIndex(ary, i),buf, sizeof(buf), kCFStringEncodingUTF8);
+ printf("%s\n", buf);
+ }
+ return 0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.