This commit is contained in:
opa334
2022-10-30 00:45:30 +02:00
parent daacab0c8b
commit 029a80f4b9
44 changed files with 2019 additions and 484 deletions
+3 -1
View File
@@ -6,6 +6,7 @@
@interface LSApplicationProxy : LSBundleProxy
+ (instancetype)applicationProxyForIdentifier:(NSString*)identifier;
+ (instancetype)applicationProxyForBundleURL:(NSURL*)bundleURL;
@property NSURL* bundleURL;
@property NSString* bundleType;
@property NSString* canonicalExecutablePath;
@@ -14,7 +15,8 @@
@property (getter=isInstalled,nonatomic,readonly) BOOL installed;
@property (getter=isPlaceholder,nonatomic,readonly) BOOL placeholder;
@property (getter=isRestricted,nonatomic,readonly) BOOL restricted;
@property (nonatomic,readonly) NSSet * claimedURLSchemes;
@property (nonatomic,readonly) NSSet* claimedURLSchemes;
@property (nonatomic,readonly) NSString* applicationType;
@end
@interface LSApplicationWorkspace : NSObject
-4
View File
@@ -9,10 +9,6 @@
- (BOOL)isTrollStore;
- (NSString*)getTrollStoreVersion;
- (void)startActivity:(NSString*)activity;
- (void)stopActivityWithCompletion:(void (^)(void))completion;
- (void)downloadTrollStoreAndDo:(void (^)(NSString* localTrollStoreTarPath))doHandler;
- (void)installTrollStorePressed;
- (void)updateTrollStorePressed;
+14 -41
View File
@@ -1,5 +1,6 @@
#import "TSListControllerShared.h"
#import "TSUtil.h"
#import "TSPresentationDelegate.h"
@implementation TSListControllerShared
@@ -24,34 +25,6 @@
}
}
- (void)startActivity:(NSString*)activity
{
if(_activityController) return;
_activityController = [UIAlertController alertControllerWithTitle:activity message:@"" preferredStyle:UIAlertControllerStyleAlert];
UIActivityIndicatorView* activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(5,5,50,50)];
activityIndicator.hidesWhenStopped = YES;
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleMedium;
[activityIndicator startAnimating];
[_activityController.view addSubview:activityIndicator];
[self presentViewController:_activityController animated:YES completion:nil];
}
- (void)stopActivityWithCompletion:(void (^)(void))completion
{
if(!_activityController) return;
[_activityController dismissViewControllerAnimated:YES completion:^
{
_activityController = nil;
if(completion)
{
completion();
}
}];
}
- (void)downloadTrollStoreAndDo:(void (^)(NSString* localTrollStoreTarPath))doHandler
{
NSURL* trollStoreURL = [NSURL URLWithString:@"https://github.com/opa334/TrollStore/releases/latest/download/TrollStore.tar"];
@@ -67,9 +40,9 @@
dispatch_async(dispatch_get_main_queue(), ^
{
[self stopActivityWithCompletion:^
[TSPresentationDelegate stopActivityWithCompletion:^
{
[self presentViewController:errorAlert animated:YES completion:nil];
[TSPresentationDelegate presentViewController:errorAlert animated:YES completion:nil];
}];
});
}
@@ -89,11 +62,11 @@
{
if(update)
{
[self startActivity:@"Updating TrollStore"];
[TSPresentationDelegate startActivity:@"Updating TrollStore"];
}
else
{
[self startActivity:@"Installing TrollStore"];
[TSPresentationDelegate startActivity:@"Installing TrollStore"];
}
[self downloadTrollStoreAndDo:^(NSString* tmpTarPath)
@@ -113,7 +86,7 @@
{
dispatch_async(dispatch_get_main_queue(), ^
{
[self stopActivityWithCompletion:^
[TSPresentationDelegate stopActivityWithCompletion:^
{
[self reloadSpecifiers];
}];
@@ -124,12 +97,12 @@
{
dispatch_async(dispatch_get_main_queue(), ^
{
[self stopActivityWithCompletion:^
[TSPresentationDelegate stopActivityWithCompletion:^
{
UIAlertController* errorAlert = [UIAlertController alertControllerWithTitle:@"Error" message:[NSString stringWithFormat:@"Error installing TrollStore: trollstorehelper returned %d", ret] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:nil];
[errorAlert addAction:closeAction];
[self presentViewController:errorAlert animated:YES completion:nil];
[TSPresentationDelegate presentViewController:errorAlert animated:YES completion:nil];
}];
});
}
@@ -148,7 +121,7 @@
- (void)rebuildIconCachePressed
{
[self startActivity:@"Rebuilding Icon Cache"];
[TSPresentationDelegate startActivity:@"Rebuilding Icon Cache"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
@@ -156,14 +129,14 @@
dispatch_async(dispatch_get_main_queue(), ^
{
[self stopActivityWithCompletion:nil];
[TSPresentationDelegate stopActivityWithCompletion:nil];
});
});
}
- (void)refreshAppRegistrationsPressed
{
[self startActivity:@"Refreshing"];
[TSPresentationDelegate startActivity:@"Refreshing"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
@@ -172,7 +145,7 @@
dispatch_async(dispatch_get_main_queue(), ^
{
[self stopActivityWithCompletion:nil];
[TSPresentationDelegate stopActivityWithCompletion:nil];
});
});
}
@@ -198,7 +171,7 @@
}];
[uninstallWarningAlert addAction:continueAction];
[self presentViewController:uninstallWarningAlert animated:YES completion:nil];
[TSPresentationDelegate presentViewController:uninstallWarningAlert animated:YES completion:nil];
}
}
@@ -228,7 +201,7 @@
}];
[uninstallWarningAlert addAction:continueAction];
[self presentViewController:uninstallWarningAlert animated:YES completion:nil];
[TSPresentationDelegate presentViewController:uninstallWarningAlert animated:YES completion:nil];
}
@end
+10
View File
@@ -0,0 +1,10 @@
#import <UIKit/UIKit.h>
@interface TSPresentationDelegate : NSObject
@property (class) UIViewController* presentationViewController;
@property (class) UIAlertController* activityController;
+ (void)startActivity:(NSString*)activity withCancelHandler:(void (^)(void))cancelHandler;
+ (void)startActivity:(NSString*)activity;
+ (void)stopActivityWithCompletion:(void (^)(void))completion;
+ (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion;
@end
+81
View File
@@ -0,0 +1,81 @@
#import "TSPresentationDelegate.h"
@implementation TSPresentationDelegate
static UIViewController* g_presentationViewController;
static UIAlertController* g_activityController;
+ (UIViewController*)presentationViewController
{
return g_presentationViewController;
}
+ (void)setPresentationViewController:(UIViewController*)vc
{
g_presentationViewController = vc;
}
+ (UIAlertController*)activityController
{
return g_activityController;
}
+ (void)setActivityController:(UIAlertController*)ac
{
g_activityController = ac;
}
+ (void)startActivity:(NSString*)activity withCancelHandler:(void (^)(void))cancelHandler
{
if(self.activityController)
{
self.activityController.title = activity;
}
else
{
self.activityController = [UIAlertController alertControllerWithTitle:activity message:@"" preferredStyle:UIAlertControllerStyleAlert];
UIActivityIndicatorView* activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(5,5,50,50)];
activityIndicator.hidesWhenStopped = YES;
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleMedium;
[activityIndicator startAnimating];
[self.activityController.view addSubview:activityIndicator];
if(cancelHandler)
{
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction* action)
{
self.activityController = nil;
cancelHandler();
}];
[self.activityController addAction:cancelAction];
}
[self presentViewController:self.activityController animated:YES completion:nil];
}
}
+ (void)startActivity:(NSString*)activity
{
[self startActivity:activity withCancelHandler:nil];
}
+ (void)stopActivityWithCompletion:(void (^)(void))completion
{
if(!self.activityController) return;
[self.activityController dismissViewControllerAnimated:YES completion:^
{
self.activityController = nil;
if(completion)
{
completion();
}
}];
}
+ (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
{
[self.presentationViewController presentViewController:viewControllerToPresent animated:flag completion:completion];
}
@end
+36 -1
View File
@@ -1,6 +1,8 @@
@import Foundation;
#import "CoreServices.h"
#define TrollStoreErrorDomain @"TrollStoreErrorDomain"
extern void chineseWifiFixup(void);
extern void loadMCMFramework(void);
extern NSString* safe_getExecutablePath();
@@ -8,6 +10,7 @@ extern NSString* rootHelperPath(void);
extern NSString* getNSStringFromFile(int fd);
extern void printMultilineNSString(NSString* stringToPrint);
extern int spawnRoot(NSString* path, NSArray* args, NSString** stdOut, NSString** stdErr);
extern void killall(NSString* processName);
extern void respring(void);
extern void fetchLatestTrollStoreVersion(void (^completionHandler)(NSString* latestVersion));
@@ -16,6 +19,14 @@ extern NSArray* trollStoreInstalledAppContainerPaths();
extern NSString* trollStorePath();
extern NSString* trollStoreAppPath();
#import <UIKit/UIAlertController.h>
@interface UIAlertController (Private)
@property (setter=_setAttributedTitle:,getter=_attributedTitle,nonatomic,copy) NSAttributedString* attributedTitle;
@property (setter=_setAttributedMessage:,getter=_attributedMessage,nonatomic,copy) NSAttributedString* attributedMessage;
@property (nonatomic,retain) UIImage* image;
@end
typedef enum
{
PERSISTENCE_HELPER_TYPE_USER = 1 << 0,
@@ -23,4 +34,28 @@ typedef enum
PERSISTENCE_HELPER_TYPE_ALL = PERSISTENCE_HELPER_TYPE_USER | PERSISTENCE_HELPER_TYPE_SYSTEM
} PERSISTENCE_HELPER_TYPE;
extern LSApplicationProxy* findPersistenceHelperApp(PERSISTENCE_HELPER_TYPE allowedTypes);
extern LSApplicationProxy* findPersistenceHelperApp(PERSISTENCE_HELPER_TYPE allowedTypes);
typedef struct __SecCode const *SecStaticCodeRef;
typedef CF_OPTIONS(uint32_t, SecCSFlags) {
kSecCSDefaultFlags = 0
};
#define kSecCSRequirementInformation 1 << 2
#define kSecCSSigningInformation 1 << 1
OSStatus SecStaticCodeCreateWithPathAndAttributes(CFURLRef path, SecCSFlags flags, CFDictionaryRef attributes, SecStaticCodeRef *staticCode);
OSStatus SecCodeCopySigningInformation(SecStaticCodeRef code, SecCSFlags flags, CFDictionaryRef *information);
CFDataRef SecCertificateCopyExtensionValue(SecCertificateRef certificate, CFTypeRef extensionOID, bool *isCritical);
void SecPolicySetOptionsValue(SecPolicyRef policy, CFStringRef key, CFTypeRef value);
extern CFStringRef kSecCodeInfoEntitlementsDict;
extern CFStringRef kSecCodeInfoCertificates;
extern CFStringRef kSecPolicyAppleiPhoneApplicationSigning;
extern CFStringRef kSecPolicyAppleiPhoneProfileApplicationSigning;
extern CFStringRef kSecPolicyLeafMarkerOid;
extern SecStaticCodeRef getStaticCodeRef(NSString *binaryPath);
extern NSDictionary* dumpEntitlements(SecStaticCodeRef codeRef);
extern NSDictionary* dumpEntitlementsFromBinaryAtPath(NSString *binaryPath);
extern NSDictionary* dumpEntitlementsFromBinaryData(NSData* binaryData);
+104
View File
@@ -343,4 +343,108 @@ LSApplicationProxy* findPersistenceHelperApp(PERSISTENCE_HELPER_TYPE allowedType
}
return outProxy;
}
SecStaticCodeRef getStaticCodeRef(NSString *binaryPath)
{
if(binaryPath == nil)
{
return NULL;
}
CFURLRef binaryURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (__bridge CFStringRef)binaryPath, kCFURLPOSIXPathStyle, false);
if(binaryURL == NULL)
{
NSLog(@"[getStaticCodeRef] failed to get URL to binary %@", binaryPath);
return NULL;
}
SecStaticCodeRef codeRef = NULL;
OSStatus result;
result = SecStaticCodeCreateWithPathAndAttributes(binaryURL, kSecCSDefaultFlags, NULL, &codeRef);
CFRelease(binaryURL);
if(result != errSecSuccess)
{
NSLog(@"[getStaticCodeRef] failed to create static code for binary %@", binaryPath);
return NULL;
}
return codeRef;
}
NSDictionary* dumpEntitlements(SecStaticCodeRef codeRef)
{
if(codeRef == NULL)
{
NSLog(@"[dumpEntitlements] attempting to dump entitlements without a StaticCodeRef");
return nil;
}
CFDictionaryRef signingInfo = NULL;
OSStatus result;
result = SecCodeCopySigningInformation(codeRef, kSecCSRequirementInformation, &signingInfo);
if(result != errSecSuccess)
{
NSLog(@"[dumpEntitlements] failed to copy signing info from static code");
return nil;
}
NSDictionary *entitlementsNSDict = nil;
CFDictionaryRef entitlements = CFDictionaryGetValue(signingInfo, kSecCodeInfoEntitlementsDict);
if(entitlements == NULL)
{
NSLog(@"[dumpEntitlements] no entitlements specified");
}
else if(CFGetTypeID(entitlements) != CFDictionaryGetTypeID())
{
NSLog(@"[dumpEntitlements] invalid entitlements");
}
else
{
entitlementsNSDict = (__bridge NSDictionary *)(entitlements);
NSLog(@"[dumpEntitlements] dumped %@", entitlementsNSDict);
}
CFRelease(signingInfo);
return entitlementsNSDict;
}
NSDictionary* dumpEntitlementsFromBinaryAtPath(NSString *binaryPath)
{
// This function is intended for one-shot checks. Main-event functions should retain/release their own SecStaticCodeRefs
if(binaryPath == nil)
{
return nil;
}
SecStaticCodeRef codeRef = getStaticCodeRef(binaryPath);
if(codeRef == NULL)
{
return nil;
}
NSDictionary *entitlements = dumpEntitlements(codeRef);
CFRelease(codeRef);
return entitlements;
}
NSDictionary* dumpEntitlementsFromBinaryData(NSData* binaryData)
{
NSDictionary* entitlements;
NSString* tmpPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSUUID UUID].UUIDString];
NSURL* tmpURL = [NSURL fileURLWithPath:tmpPath];
if([binaryData writeToURL:tmpURL options:NSDataWritingAtomic error:nil])
{
entitlements = dumpEntitlementsFromBinaryAtPath(tmpPath);
[[NSFileManager defaultManager] removeItemAtURL:tmpURL error:nil];
}
return entitlements;
}