Skip to content

Commit

Permalink
fix #15 #16
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeBlack committed Dec 14, 2024
1 parent a160972 commit 890a6b7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion LiveContainerSwiftUI/LCSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ struct LCSettingsView: View {
return;
}
isJITLessTestInProgress = true
LCUtils.validateJITLessSetup { success, error in
LCUtils.validateJITLessSetup(with: defaultSigner) { success, error in
if success {
successInfo = "lc.jitlessSetup.success".loc
successShow = true
Expand Down
2 changes: 1 addition & 1 deletion LiveContainerSwiftUI/LCUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void LCPatchAltStore(const char *path, struct mach_header_64 *header);

@interface LCUtils : NSObject

+ (void)validateJITLessSetupWithCompletionHandler:(void (^)(BOOL success, NSError *error))completionHandler;
+ (void)validateJITLessSetupWithSigner:(Signer)signer completionHandler:(void (^)(BOOL success, NSError *error))completionHandler;
+ (NSURL *)archiveIPAWithBundleName:(NSString*)newBundleName error:(NSError **)error;
+ (NSURL *)archiveTweakedAltStoreWithError:(NSError **)error;
+ (NSData *)certificateData;
Expand Down
29 changes: 20 additions & 9 deletions LiveContainerSwiftUI/LCUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ + (void)loadStoreFrameworksWithError:(NSError **)error {

NSArray *signerFrameworks;

if([self store] == AltStore) {
if([NSFileManager.defaultManager fileExistsAtPath:[self.storeBundlePath URLByAppendingPathComponent:@"Frameworks/KeychainAccess.framework"].path]) {
// AltStore requires 1 more framework than sidestore
signerFrameworks = @[@"OpenSSL.framework", @"Roxas.framework", @"KeychainAccess.framework", @"AltStoreCore.framework"];
} else {
Expand Down Expand Up @@ -326,10 +326,10 @@ + (void)writeStoreIDToSetupExecutableWithError:(NSError **)error {
[data writeToURL:execPath options:0 error:error];
}

+ (void)validateJITLessSetupWithCompletionHandler:(void (^)(BOOL success, NSError *error))completionHandler {
+ (void)validateJITLessSetupWithSigner:(Signer)signer completionHandler:(void (^)(BOOL success, NSError *error))completionHandler {
// Verify that the certificate is usable
// Create a test app bundle
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"CertificateValidation"];
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"CertificateValidation.app"];
[NSFileManager.defaultManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
NSString *tmpExecPath = [path stringByAppendingPathComponent:@"LiveContainer.tmp"];
NSString *tmpLibPath = [path stringByAppendingPathComponent:@"TestJITLess.dylib"];
Expand All @@ -341,12 +341,23 @@ + (void)validateJITLessSetupWithCompletionHandler:(void (^)(BOOL success, NSErro
[info writeToFile:tmpInfoPath atomically:YES];

// Sign the test app bundle
[LCUtils signAppBundle:[NSURL fileURLWithPath:path]
completionHandler:^(BOOL success, NSDate* expirationDate, NSError *_Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(success, error);
});
}];
if(signer == AltSign) {
[LCUtils signAppBundle:[NSURL fileURLWithPath:path]
completionHandler:^(BOOL success, NSDate* expirationDate, NSError *_Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(success, error);
});
}];
} else {
[LCUtils signAppBundleWithZSign:[NSURL fileURLWithPath:path]
completionHandler:^(BOOL success, NSDate* expirationDate, NSError *_Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(success, error);
});
}];
}


}

+ (NSURL *)archiveIPAWithBundleName:(NSString*)newBundleName error:(NSError **)error {
Expand Down
27 changes: 20 additions & 7 deletions TweakLoader/UIKit+GuestHooks.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static void UIKitGuestHooksInit() {
break;
}
if(orientationLock != UIInterfaceOrientationUnknown) {
swizzle(UIApplication.class, @selector(_handleDelegateCallbacksWithOptions:isSuspended:restoreState:), @selector(hook__handleDelegateCallbacksWithOptions:isSuspended:restoreState:));
swizzle(FBSSceneParameters.class, @selector(initWithXPCDictionary:), @selector(hook_initWithXPCDictionary:));
swizzle(UIViewController.class, @selector(__supportedInterfaceOrientations), @selector(hook___supportedInterfaceOrientations));
swizzle(UIViewController.class, @selector(shouldAutorotateToInterfaceOrientation:), @selector(hook_shouldAutorotateToInterfaceOrientation:));
Expand Down Expand Up @@ -305,15 +306,22 @@ - (void)hook__connectUISceneFromFBSScene:(id)scene transitionContext:(UIApplicat
context.payload = nil;
context.actions = nil;
[self hook__connectUISceneFromFBSScene:scene transitionContext:context];
if(orientationLock != UIInterfaceOrientationUnknown) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
}

-(BOOL)hook__handleDelegateCallbacksWithOptions:(id)arg1 isSuspended:(BOOL)arg2 restoreState:(BOOL)arg3 {
BOOL ans = [self hook__handleDelegateCallbacksWithOptions:arg1 isSuspended:arg2 restoreState:arg3];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[LSApplicationWorkspace defaultWorkspace] openApplicationWithBundleID:@"com.apple.springboard"];
});

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[LSApplicationWorkspace defaultWorkspace] openApplicationWithBundleID:NSUserDefaults.lcMainBundle.bundleIdentifier];
});
}

});


return ans;
}
@end

Expand Down Expand Up @@ -395,7 +403,12 @@ - (instancetype)hook_initWithXPCDictionary:(NSDictionary*)dict {
@implementation UIViewController(LiveContainerHook)

- (UIInterfaceOrientationMask)hook___supportedInterfaceOrientations {
return (UIInterfaceOrientationMask)(1 << orientationLock);
if(orientationLock == UIInterfaceOrientationLandscapeRight) {
return UIInterfaceOrientationMaskLandscape;
} else {
return UIInterfaceOrientationMaskPortrait;
}

}

- (BOOL)hook_shouldAutorotateToInterfaceOrientation:(NSInteger)orientation {
Expand Down

0 comments on commit 890a6b7

Please sign in to comment.