Skip to content

Commit 6d3f918

Browse files
committed
fix: roothide
Signed-off-by: 82Flex <[email protected]>
1 parent 3c18cc3 commit 6d3f918

File tree

11 files changed

+146
-34
lines changed

11 files changed

+146
-34
lines changed

Headers/LSApplicationProxy.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
//
2-
// LSApplicationProxy.h
3-
// XXTPickerCollection
4-
//
5-
// Created by Zheng on 03/05/2017.
6-
// Copyright © 2017 Zheng. All rights reserved.
7-
//
8-
91
#ifndef LSApplicationProxy_h
102
#define LSApplicationProxy_h
113

124
#import <UIKit/UIKit.h>
135

6+
@class LSApplicationRecord;
7+
148
@interface LSApplicationProxy : NSObject
159

1610
+ (LSApplicationProxy *)applicationProxyForIdentifier:(NSString *)bid;
@@ -20,11 +14,11 @@
2014
- (NSString *)shortVersionString;
2115
- (NSString *)applicationType;
2216
- (NSURL *)bundleURL;
23-
//- (NSURL *)bundleContainerURL;
2417
- (NSURL *)dataContainerURL;
2518
- (NSDictionary <NSString *, NSURL *> *)groupContainerURLs;
2619

2720
@property (nonatomic, readonly, copy) NSString *applicationIdentifier;
21+
@property (nonatomic, readonly, strong) LSApplicationRecord *correspondingApplicationRecord;
2822

2923
@end
3024

Headers/LSApplicationWorkspace.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

Headers/LSRecordPromise.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef LSRecordPromise_h
2+
#define LSRecordPromise_h
3+
4+
#import <Foundation/Foundation.h>
5+
6+
@class LSApplicationRecord;
7+
8+
@interface LSRecordPromise : NSObject
9+
10+
- (instancetype)initWithRecord:(LSApplicationRecord *)arg1 error:(NSError **)arg2;
11+
12+
@end
13+
14+
#endif /* LSRecordPromise_h */

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2+
Version 2, December 2004
3+
4+
Copyright (C) 2004 Sam Hocevar <[email protected]>
5+
6+
Everyone is permitted to copy and distribute verbatim or modified
7+
copies of this license document, and changing it is allowed as long
8+
as the name is changed.
9+
10+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12+
13+
0. You just DO WHAT THE FUCK YOU WANT TO.

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ TARGET := iphone:clang:14.5:14.0
44
else
55
TARGET := iphone:clang:16.5:15.0
66
endif
7-
INSTALL_TARGET_PROCESSES := installd
87

98
ifeq ($(THEOS_PACKAGE_SCHEME),rootless)
109
JBROOT_PREFIX := /var/jb

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@
22

33
This jailbreak tweak allows you to “run” app directly from Xcode without code signing or with any entitlements.
44

5+
Which makes it super easy to develop TrollStore based system apps, or to test your own apps without the need to sign them with a developer certificate.
6+
7+
Tested on iOS 15.0/15.4/16.2/16.4/16.5.1 with Dopamine and Dopamine (RootHide) jailbreaks.
8+
59
## How to use?
610

7-
1. Install this tweak from <https://apt.82flex.com>
8-
2. Open Xcode and modify the target settings of your app: `CODE_SIGNING_ALLOWED=NO`
9-
3. Add a “Run Script” phase to your target with the following content:
11+
1. (RootHide) Install “Xcode Any Debug” from <https://roothide.github.io>
12+
2. (Other) Install and configure “XcodeRootDebug” from <https://apt.82flex.com>
13+
3. Install this tweak from <https://apt.82flex.com>
14+
4. Open Xcode and modify the target settings of your app: `CODE_SIGNING_ALLOWED=NO`
15+
5. Add a “Run Script” phase to your target with the following content:
1016

1117
```bash
12-
ldid -S${CODE_SIGN_ENTITLEMENTS} ${CODESIGNING_FOLDER_PATH}
18+
if [ "$CODE_SIGNING_ALLOWED" = "NO" ]; then
19+
ldid -S${CODE_SIGN_ENTITLEMENTS} ${CODESIGNING_FOLDER_PATH}
20+
fi
1321
```
22+
23+
## LICENSE
24+
25+
WTFPL License

XcodeAnyTroll.xm

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#import <libSandy.h>
77
#import <libSandyXpc.h>
88

9+
#import "LSApplicationProxy.h"
10+
#import "LSRecordPromise.h"
911
#import "MCMContainer.h"
1012

1113
#define TAG "[XcodeAnyTroll] "
@@ -22,10 +24,51 @@ static SandyXpcMessagingCenter *GetXpcMessagingCenter(void) {
2224
return messagingCenter;
2325
}
2426

27+
#import <Foundation/Foundation.h>
28+
29+
struct BlockDescriptor {
30+
unsigned long reserved;
31+
unsigned long size;
32+
void *rest[1];
33+
};
34+
35+
struct Block {
36+
void *isa;
37+
int flags;
38+
int reserved;
39+
void *invoke;
40+
struct BlockDescriptor *descriptor;
41+
};
42+
43+
__used
44+
static const char *BlockSig(id blockObj)
45+
{
46+
struct Block *block = (__bridge struct Block *)blockObj;
47+
struct BlockDescriptor *descriptor = block->descriptor;
48+
49+
int copyDisposeFlag = 1 << 25;
50+
int signatureFlag = 1 << 30;
51+
52+
assert(block->flags & signatureFlag);
53+
54+
int index = 0;
55+
if (block->flags & copyDisposeFlag)
56+
index += 2;
57+
58+
return (const char *)descriptor->rest[index];
59+
}
60+
61+
@interface MIInstallOptions : NSObject
62+
63+
@property (getter=isDeveloperInstall, nonatomic) bool developerInstall;
64+
65+
@end
66+
2567
%hook MICodeSigningVerifier
2668

2769
+ (id)_validateSignatureAndCopyInfoForURL:(NSURL *)url withOptions:(id)options error:(NSError **)errorPtr {
2870
id result = %orig(url, options, errorPtr);
71+
2972
if (errorPtr && *errorPtr) {
3073
NSError *error = *errorPtr;
3174
if (![[error description] containsString:@"0xe800801c"] && ![[error description] containsString:@"0xe8008001"]) {
@@ -120,15 +163,55 @@ static SandyXpcMessagingCenter *GetXpcMessagingCenter(void) {
120163

121164
%hook MIClientConnection
122165

166+
/* iOS 16.4+ */
167+
- (void)_installURL:(NSURL *)url identity:(id)identity targetingDomain:(NSUInteger)domain options:(MIInstallOptions *)options completion:(void (^)(BOOL, NSArray *, id, NSError *))completion {
168+
HBLogDebug(@TAG "installURL:%@ withOptions:%@", url, options);
169+
170+
void (^replCompletion)(BOOL, NSArray *, id, NSError *) = ^(BOOL succeed, NSArray *appList, id recordPromise, NSError *error) {
171+
HBLogDebug(@TAG "completion called with appList:%@ recordPromise:%@ error:%@", appList, recordPromise, error);
172+
if (!completion) {
173+
return;
174+
}
175+
176+
if (gPackagePath && gPackageIdentifier && ([[error description] containsString:@"0xe800801c"] || [[error description] containsString:@"0xe8008001"])) {
177+
NSError *error = nil;
178+
NSDictionary *retVal = nil;
179+
180+
retVal = [GetXpcMessagingCenter() sendMessageAndReceiveReplyName:@"InstallPackage" userInfo:@{
181+
@"PackagePath": gPackagePath,
182+
@"PackageIdentifier": gPackageIdentifier,
183+
} error:&error];
184+
if (error) {
185+
HBLogDebug(@TAG "XPC error occurred: %@", error);
186+
completion(succeed, appList, recordPromise, error);
187+
return;
188+
}
189+
190+
HBLogDebug(@TAG "XPC reply received: %@", retVal);
191+
192+
LSApplicationProxy *appProxy = [LSApplicationProxy applicationProxyForIdentifier:gPackageIdentifier];
193+
LSRecordPromise *recordPromise = [[LSRecordPromise alloc] initWithRecord:appProxy.correspondingApplicationRecord error:nil];
194+
195+
completion(YES, retVal[@"InstalledAppInfoArray"], recordPromise, nil);
196+
return;
197+
}
198+
199+
completion(succeed, appList, recordPromise, error);
200+
};
201+
202+
%orig(url, identity, domain, options, replCompletion);
203+
}
204+
205+
/* iOS 15 */
123206
- (void)installURL:(NSURL *)url withOptions:(NSDictionary *)options completion:(void (^)(id, NSError *))completion {
124207
HBLogDebug(@TAG "installURL:%@ withOptions:%@", url, options);
125208

126209
if (![options[@"PackageType"] isEqualToString:@"Developer"]) {
127-
%orig(url, options, completion);
210+
%orig;
128211
return;
129212
}
130213

131-
void (^replCompletion)(id, NSError *) = ^(NSDictionary *userInfo, NSError *error) {
214+
void (^replCompletion)(NSDictionary *, NSError *) = ^(NSDictionary *userInfo, NSError *error) {
132215
HBLogDebug(@TAG "completion called with userInfo:%@ error:%@", [userInfo[@"InstalledAppInfoArray"] firstObject], error);
133216
if (!completion) {
134217
return;
@@ -193,6 +276,12 @@ static void TestConnection(void) {
193276
%ctor {
194277
@autoreleasepool {
195278
void *sandyHandle = dlopen("@rpath/libsandy.dylib", RTLD_LAZY);
279+
if (!sandyHandle) {
280+
sandyHandle = dlopen("/usr/lib/libsandy.dylib", RTLD_LAZY);
281+
}
282+
if (!sandyHandle) {
283+
sandyHandle = dlopen("@loader_path/.jbroot/usr/lib/libsandy.dylib", RTLD_LAZY);
284+
}
196285
if (sandyHandle) {
197286
int (*__dyn_libSandy_applyProfile)(const char *profileName) =
198287
(int (*)(const char *))dlsym(sandyHandle, "libSandy_applyProfile");

layout/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Description: An awesome MobileSubstrate tweak!
66
Maintainer: Lessica
77
Author: Lessica
88
Section: Tweaks
9-
Depends: mobilesubstrate (>= 0.9.5000), com.82flex.libsandyxpc (>= 1.1), com.opa334.libsandy (>= 1.1.4)
9+
Depends: mobilesubstrate (>= 0.9.5000), com.82flex.libsandyxpc (>= 1.1), com.opa334.libsandy (>= 1.1.3)

layout/DEBIAN/postinst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ else
1111
fi
1212
fi
1313

14+
killall -9 installd || true
15+
1416
exit 0

layout/DEBIAN/prerm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ else
1111
fi
1212
fi
1313

14+
killall -9 installd || true
15+
1416
exit 0

0 commit comments

Comments
 (0)