summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Bingner <sam@bingner.com>2021-02-18 23:52:24 -1000
committerSam Bingner <sam@bingner.com>2021-02-19 00:29:35 -1000
commitb5ff1c1916246fbfb4348e81d53aa932bddcea7d (patch)
tree6a44761ed910f79aa77735250f9d8ca7468bb47c
parenteac76deb1b8bdc59332a474ad468f3825113ac80 (diff)
Add app listing options to uicache
-rw-r--r--makefile2
-rw-r--r--uicache.mm67
2 files changed, 61 insertions, 8 deletions
diff --git a/makefile b/makefile
index 6764f73..f2fe703 100644
--- a/makefile
+++ b/makefile
@@ -19,7 +19,7 @@ ldrestart := -std=c++11
gssc := -lobjc
iomfsetgamma := -I. $(private) -framework IOKit -framework IOMobileFramebuffer
sbdidlaunch := $(private) -framework SpringBoardServices
-uicache := -framework UIKit # XXX: UIKit -> MobileCoreServices
+uicache := -framework UIKit -framework MobileCoreServices
uiduid := -framework UIKit
uiopen := -framework UIKit
uishoot := -framework UIKit
diff --git a/uicache.mm b/uicache.mm
index d765814..3419c76 100644
--- a/uicache.mm
+++ b/uicache.mm
@@ -122,14 +122,21 @@
@end
+@interface LSApplicationState : NSObject
+-(bool)isValid;
+@end
+
@interface LSApplicationProxy : NSObject
-- (NSString*) applicationIdentifier;
-- (NSURL*) bundleURL;
-- (NSDate*) registeredDate;
++(LSApplicationProxy*)applicationProxyForIdentifier:(NSString*)appid;
+-(NSString*)applicationIdentifier;
+-(LSApplicationState*)appState;
+-(NSURL*)bundleURL;
+-(NSURL*)containerURL;
+-(NSDate*)registeredDate;
@end
@interface LSApplicationWorkspace : NSObject
-+ (id) defaultWorkspace;
++ (LSApplicationWorkspace*) defaultWorkspace;
- (BOOL) registerApplication:(id)application;
- (BOOL) unregisterApplication:(id)application;
- (BOOL) invalidateIconCache:(id)bundle;
@@ -167,6 +174,32 @@ static Class $MCMAppDataContainer;
static Class $LSApplicationWorkspace;
LSApplicationWorkspace *workspace=nil;
+int list_all_apps(void)
+{
+ NSArray *allApps = [[LSApplicationWorkspace defaultWorkspace] allApplications];
+ for (LSApplicationProxy *app in allApps) {
+ printf("%s : %s\n", [[app applicationIdentifier] UTF8String], [[app bundleURL] fileSystemRepresentation]);
+ }
+ return 0;
+}
+
+int list_app(NSString *appid) {
+ if (appid == NULL) {
+ return 1;
+ }
+ LSApplicationProxy *app = [LSApplicationProxy applicationProxyForIdentifier:appid];
+ LSApplicationState *appState = [app appState];
+ if (![appState isValid]) {
+ fprintf(stderr, "Invalid appID provided: %s\n", appid.UTF8String);
+ return 1;
+ }
+ printf("Information for %s\n", appid.UTF8String);
+ printf("State: %s\n", [[appState description] UTF8String]);
+ printf("Path: %s\n", [[app bundleURL] fileSystemRepresentation]);
+ printf("Container Path: %s\n", [[app containerURL] fileSystemRepresentation]);
+ return 0;
+}
+
NSString *getAppPath(NSString *path)
{
path = [path stringByResolvingSymlinksInPath];
@@ -283,7 +316,7 @@ bool registerPath(NSString *path)
void usage(void)
{
- fprintf(stderr, "Usage: %s [-hrv] [[-p | -u] /Applications/App.app]]\n", getprogname());
+ fprintf(stderr, "Usage: %s [-hrv] [[-p | -u] /Applications/App.app]] | -l [application.id]\n", getprogname());
exit(EXIT_FAILURE);
}
@@ -606,7 +639,7 @@ int main(int argc, const char *argv[])
static int rv=0;
@autoreleasepool {
- bool respring=false, do_all=false;
+ bool respring=false, do_all=false, list_apps=false;
void (*jb_oneshot_entitle_now)(pid_t a, uint64_t b);
void *libjb = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY);
@@ -622,6 +655,7 @@ int main(int argc, const char *argv[])
{
{"all", no_argument, 0, 'a'},
{"help", no_argument, 0, 'h'},
+ {"list", optional_argument, 0, 'l'},
{"path", required_argument, 0, 'p'},
{"unregister", required_argument, 0, 'u'},
{"respring", no_argument, 0, 'r'},
@@ -629,9 +663,10 @@ int main(int argc, const char *argv[])
{0, 0, 0, 0}
};
int option_index = 0;
+ NSString *app_id = NULL;
char ch;
bool have_path = false;
- while ((ch = getopt_long(argc, (char *const *)argv, "ap:ru:vh?", long_options, &option_index)) != -1) {
+ while ((ch = getopt_long(argc, (char *const *)argv, "al::p:ru:vh?", long_options, &option_index)) != -1) {
switch (ch)
{
case 'a':
@@ -640,6 +675,14 @@ int main(int argc, const char *argv[])
case 'h':
usage();
break;
+ case 'l':
+ if (optarg) {
+ app_id = @(optarg);
+ } else if (argv[optind] != NULL && argv[optind][0] != '-') {
+ app_id = @(argv[optind++]);
+ }
+ list_apps = true;
+ break;
case 'p':
paths[@(optarg)] = @YES;
have_path = true;
@@ -658,6 +701,16 @@ int main(int argc, const char *argv[])
break;
}
}
+ if (list_apps) {
+ if (do_all || have_path || respring) {
+ usage();
+ return 1;
+ }
+ if (app_id != NULL) {
+ return list_app(app_id);
+ }
+ return list_all_apps();
+ }
if (do_all || !$MCMPluginKitPluginDataContainer || !$MCMAppDataContainer || !$LSApplicationWorkspace) {
rv = standard_uicache();
} else if (have_path) {