Skip to content

Commit 890a6b7

Browse files
committed
fix #15 #16
1 parent a160972 commit 890a6b7

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

LiveContainerSwiftUI/LCSettingsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ struct LCSettingsView: View {
402402
return;
403403
}
404404
isJITLessTestInProgress = true
405-
LCUtils.validateJITLessSetup { success, error in
405+
LCUtils.validateJITLessSetup(with: defaultSigner) { success, error in
406406
if success {
407407
successInfo = "lc.jitlessSetup.success".loc
408408
successShow = true

LiveContainerSwiftUI/LCUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void LCPatchAltStore(const char *path, struct mach_header_64 *header);
2727

2828
@interface LCUtils : NSObject
2929

30-
+ (void)validateJITLessSetupWithCompletionHandler:(void (^)(BOOL success, NSError *error))completionHandler;
30+
+ (void)validateJITLessSetupWithSigner:(Signer)signer completionHandler:(void (^)(BOOL success, NSError *error))completionHandler;
3131
+ (NSURL *)archiveIPAWithBundleName:(NSString*)newBundleName error:(NSError **)error;
3232
+ (NSURL *)archiveTweakedAltStoreWithError:(NSError **)error;
3333
+ (NSData *)certificateData;

LiveContainerSwiftUI/LCUtils.m

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ + (void)loadStoreFrameworksWithError:(NSError **)error {
9898

9999
NSArray *signerFrameworks;
100100

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

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

343343
// Sign the test app bundle
344-
[LCUtils signAppBundle:[NSURL fileURLWithPath:path]
345-
completionHandler:^(BOOL success, NSDate* expirationDate, NSError *_Nullable error) {
346-
dispatch_async(dispatch_get_main_queue(), ^{
347-
completionHandler(success, error);
348-
});
349-
}];
344+
if(signer == AltSign) {
345+
[LCUtils signAppBundle:[NSURL fileURLWithPath:path]
346+
completionHandler:^(BOOL success, NSDate* expirationDate, NSError *_Nullable error) {
347+
dispatch_async(dispatch_get_main_queue(), ^{
348+
completionHandler(success, error);
349+
});
350+
}];
351+
} else {
352+
[LCUtils signAppBundleWithZSign:[NSURL fileURLWithPath:path]
353+
completionHandler:^(BOOL success, NSDate* expirationDate, NSError *_Nullable error) {
354+
dispatch_async(dispatch_get_main_queue(), ^{
355+
completionHandler(success, error);
356+
});
357+
}];
358+
}
359+
360+
350361
}
351362

352363
+ (NSURL *)archiveIPAWithBundleName:(NSString*)newBundleName error:(NSError **)error {

TweakLoader/UIKit+GuestHooks.m

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static void UIKitGuestHooksInit() {
2626
break;
2727
}
2828
if(orientationLock != UIInterfaceOrientationUnknown) {
29+
swizzle(UIApplication.class, @selector(_handleDelegateCallbacksWithOptions:isSuspended:restoreState:), @selector(hook__handleDelegateCallbacksWithOptions:isSuspended:restoreState:));
2930
swizzle(FBSSceneParameters.class, @selector(initWithXPCDictionary:), @selector(hook_initWithXPCDictionary:));
3031
swizzle(UIViewController.class, @selector(__supportedInterfaceOrientations), @selector(hook___supportedInterfaceOrientations));
3132
swizzle(UIViewController.class, @selector(shouldAutorotateToInterfaceOrientation:), @selector(hook_shouldAutorotateToInterfaceOrientation:));
@@ -305,15 +306,22 @@ - (void)hook__connectUISceneFromFBSScene:(id)scene transitionContext:(UIApplicat
305306
context.payload = nil;
306307
context.actions = nil;
307308
[self hook__connectUISceneFromFBSScene:scene transitionContext:context];
308-
if(orientationLock != UIInterfaceOrientationUnknown) {
309-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
309+
}
310+
311+
-(BOOL)hook__handleDelegateCallbacksWithOptions:(id)arg1 isSuspended:(BOOL)arg2 restoreState:(BOOL)arg3 {
312+
BOOL ans = [self hook__handleDelegateCallbacksWithOptions:arg1 isSuspended:arg2 restoreState:arg3];
313+
static dispatch_once_t onceToken;
314+
dispatch_once(&onceToken, ^{
315+
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
316+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
310317
[[LSApplicationWorkspace defaultWorkspace] openApplicationWithBundleID:@"com.apple.springboard"];
311-
});
312-
313-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
314318
[[LSApplicationWorkspace defaultWorkspace] openApplicationWithBundleID:NSUserDefaults.lcMainBundle.bundleIdentifier];
315319
});
316-
}
320+
321+
});
322+
323+
324+
return ans;
317325
}
318326
@end
319327

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

397405
- (UIInterfaceOrientationMask)hook___supportedInterfaceOrientations {
398-
return (UIInterfaceOrientationMask)(1 << orientationLock);
406+
if(orientationLock == UIInterfaceOrientationLandscapeRight) {
407+
return UIInterfaceOrientationMaskLandscape;
408+
} else {
409+
return UIInterfaceOrientationMaskPortrait;
410+
}
411+
399412
}
400413

401414
- (BOOL)hook_shouldAutorotateToInterfaceOrientation:(NSInteger)orientation {

0 commit comments

Comments
 (0)