Skip to content

Commit 4e9d1a2

Browse files
RootHideRootHide
RootHide
authored and
RootHide
committed
beta 4.3
1: Fix the issue that error 255 may occur during bootstrapping 2: Fix the issue that error 255 may occur when enabling tweak for the app 3: Fix the bootstrapping issue for ipad mini6 ios17.0 3: add a global tweak enable switch so that you can temporarily disable all tweaks when you install a broken tweak and cause the apps to crash. 4: Fixed Safari crashing issue in some devices after tweak enabled 5: Optimize app list sorting and improve user experience If this version does not introduce new issue, it will be the last beta version.
1 parent 7e66445 commit 4e9d1a2

19 files changed

+177
-62
lines changed

Bootstrap.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@
436436
"$(inherited)",
437437
"@executable_path/Frameworks",
438438
);
439-
MARKETING_VERSION = 0.4.2;
439+
MARKETING_VERSION = 0.4.3;
440440
OTHER_LDFLAGS = "";
441441
PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap;
442442
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -470,7 +470,7 @@
470470
"$(inherited)",
471471
"@executable_path/Frameworks",
472472
);
473-
MARKETING_VERSION = 0.4.2;
473+
MARKETING_VERSION = 0.4.3;
474474
OTHER_LDFLAGS = "";
475475
PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap;
476476
PRODUCT_NAME = "$(TARGET_NAME)";

Bootstrap/AppEnabler.m

+43-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import <Foundation/Foundation.h>
2+
#include <sys/stat.h>
23
#include "AppList.h"
34
#include "common.h"
45

@@ -135,6 +136,7 @@ int backupApp(NSString* bundlePath)
135136
return 0;
136137
}
137138

139+
//if the app package is changed/upgraded, the directory structure may change and some paths may become invalid.
138140
int restoreApp(NSString* bundlePath)
139141
{
140142
SYSLOG("restoreApp=%@", bundlePath);
@@ -200,24 +202,39 @@ int enableForApp(NSString* bundlePath)
200202

201203
ASSERT([fm createSymbolicLinkAtPath:[jbroot(bundlePath) stringByAppendingString:@"/.jbroot"] withDestinationPath:jbroot(@"/") error:nil]);
202204

203-
ASSERT(spawnBootstrap((char*[]){"/usr/bin/uicache","-p", bundlePath.UTF8String, NULL}, nil, nil) == 0);
205+
NSString* log=nil;
206+
NSString* err=nil;
207+
if(spawnBootstrap((char*[]){"/usr/bin/uicache","-p", bundlePath.UTF8String, NULL}, &log, &err) != 0) {
208+
STRAPLOG("%@\nERR:%@", log, err);
209+
ABORT();
210+
}
204211
}
205212
else if([appInfo[@"CFBundleIdentifier"] hasPrefix:@"com.apple."]
206213
|| [NSFileManager.defaultManager fileExistsAtPath:[bundlePath stringByAppendingString:@"/../_TrollStore"]])
207214
{
208215
ASSERT(backupApp(bundlePath) == 0);
209216

210217
ASSERT([fm createSymbolicLinkAtPath:[bundlePath stringByAppendingString:@"/.jbroot"] withDestinationPath:jbroot(@"/") error:nil]);
211-
212-
ASSERT(spawnBootstrap((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).UTF8String, NULL}, nil, nil) == 0);
218+
219+
NSString* log=nil;
220+
NSString* err=nil;
221+
if(spawnBootstrap((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).UTF8String, NULL}, &log, &err) != 0) {
222+
STRAPLOG("%@\nERR:%@", log, err);
223+
ABORT();
224+
}
213225
}
214226
else
215227
{
216228
ASSERT(backupApp(bundlePath) == 0);
217229

218230
ASSERT([fm createSymbolicLinkAtPath:[bundlePath stringByAppendingString:@"/.jbroot"] withDestinationPath:jbroot(@"/") error:nil]);
219231

220-
ASSERT(spawnBootstrap((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).UTF8String, NULL}, nil, nil) == 0);
232+
NSString* log=nil;
233+
NSString* err=nil;
234+
if(spawnBootstrap((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).UTF8String, NULL}, &log, &err) != 0) {
235+
STRAPLOG("%@\nERR:%@", log, err);
236+
ABORT();
237+
}
221238
}
222239

223240
return 0;
@@ -242,17 +259,36 @@ int disableForApp(NSString* bundlePath)
242259
else if([appInfo[@"CFBundleIdentifier"] hasPrefix:@"com.apple."]
243260
|| [NSFileManager.defaultManager fileExistsAtPath:[bundlePath stringByAppendingString:@"/../_TrollStore"]])
244261
{
262+
263+
struct stat st;
264+
if(lstat([bundlePath stringByAppendingString:@"/.jbroot"].fileSystemRepresentation, &st)==0)
265+
ASSERT([fm removeItemAtPath:[bundlePath stringByAppendingString:@"/.jbroot"] error:nil]);
266+
if(lstat([bundlePath stringByAppendingString:@"/.prelib"].fileSystemRepresentation, &st)==0)
267+
ASSERT([fm removeItemAtPath:[bundlePath stringByAppendingString:@"/.prelib"] error:nil]);
268+
if(lstat([bundlePath stringByAppendingString:@"/.preload"].fileSystemRepresentation, &st)==0)
269+
ASSERT([fm removeItemAtPath:[bundlePath stringByAppendingString:@"/.preload"] error:nil]);
270+
if(lstat([bundlePath stringByAppendingString:@"/.rebuild"].fileSystemRepresentation, &st)==0)
271+
ASSERT([fm removeItemAtPath:[bundlePath stringByAppendingString:@"/.rebuild"] error:nil]);
272+
245273
ASSERT(restoreApp(bundlePath) == 0);
246-
ASSERT([fm removeItemAtPath:[bundlePath stringByAppendingString:@"/.jbroot"] error:nil]);
274+
247275
ASSERT(spawnBootstrap((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).UTF8String, NULL}, nil, nil) == 0);
248276
}
249277
else
250278
{
251279
//should be an appstored app
252280

253-
ASSERT(restoreApp(bundlePath) == 0);
281+
struct stat st;
282+
if(lstat([bundlePath stringByAppendingString:@"/.jbroot"].fileSystemRepresentation, &st)==0)
283+
ASSERT([fm removeItemAtPath:[bundlePath stringByAppendingString:@"/.jbroot"] error:nil]);
284+
if(lstat([bundlePath stringByAppendingString:@"/.prelib"].fileSystemRepresentation, &st)==0)
285+
ASSERT([fm removeItemAtPath:[bundlePath stringByAppendingString:@"/.prelib"] error:nil]);
286+
if(lstat([bundlePath stringByAppendingString:@"/.preload"].fileSystemRepresentation, &st)==0)
287+
ASSERT([fm removeItemAtPath:[bundlePath stringByAppendingString:@"/.preload"] error:nil]);
288+
if(lstat([bundlePath stringByAppendingString:@"/.rebuild"].fileSystemRepresentation, &st)==0)
289+
ASSERT([fm removeItemAtPath:[bundlePath stringByAppendingString:@"/.rebuild"] error:nil]);
254290

255-
ASSERT([fm removeItemAtPath:[bundlePath stringByAppendingString:@"/.jbroot"] error:nil]);
291+
ASSERT(restoreApp(bundlePath) == 0);
256292

257293
//unregister or respring to keep app's icon on home screen
258294
ASSERT(spawnBootstrap((char*[]){"/usr/bin/uicache","-u", rootfsPrefix(bundlePath).UTF8String, NULL}, nil, nil) == 0);

Bootstrap/AppViewController.m

+34-9
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,28 @@ - (void)viewWillAppear:(BOOL)animated {
127127
[self.tableView.refreshControl endRefreshing];
128128
}
129129

130+
-(BOOL)tweakEnabled:(AppList*)app {
131+
struct stat st;
132+
if(lstat([app.bundleURL.path stringByAppendingPathComponent:@".jbroot"].fileSystemRepresentation, &st)==0) {
133+
return YES;
134+
}
135+
136+
if(!isDefaultInstallationPath(app.bundleURL.path)) {
137+
return NO;
138+
}
139+
140+
NSString* uuidPath = [app.bundleURL.path stringByDeletingLastPathComponent];
141+
NSString* backupFlag = [uuidPath stringByAppendingPathComponent:@".appbackup"];
142+
NSString* backupPath = [[uuidPath stringByAppendingPathComponent:app.bundleURL.path.lastPathComponent] stringByAppendingPathExtension:@"appbackup"];
143+
SYSLOG("uuidPath=%@, backupFlag=%@, backupPath=%@", uuidPath, backupFlag, backupPath);
144+
if([NSFileManager.defaultManager fileExistsAtPath:backupFlag] && [NSFileManager.defaultManager fileExistsAtPath:backupPath]) {
145+
//if the app has been successfully backed up but failed to enable tweak injection for some reason, or the app bundle is overwritten, we will still show that tweak injection has been enabled so that the user will have the chance to restore the app in appenabler
146+
return YES;
147+
}
148+
149+
return NO;
150+
}
151+
130152
- (void)updateData:(BOOL)sort {
131153
NSMutableArray* applications = [NSMutableArray new];
132154
PrivateApi_LSApplicationWorkspace* _workspace = [NSClassFromString(@"LSApplicationWorkspace") new];
@@ -155,6 +177,10 @@ - (void)updateData:(BOOL)sort {
155177
[app.bundleURL.path stringByAppendingString:@"/.TrollStorePresistenceHelper"]])
156178
continue;
157179

180+
if([NSFileManager.defaultManager fileExistsAtPath:
181+
[app.bundleURL.path stringByAppendingString:@"/.Bootstrap"]])
182+
continue;
183+
158184
if([app.bundleURL.path.lastPathComponent isEqualToString:@"TrollStore.app"])
159185
continue;
160186

@@ -171,15 +197,16 @@ - (void)updateData:(BOOL)sort {
171197
if(sort)
172198
{
173199
NSArray *appsSortedByName = [applications sortedArrayUsingComparator:^NSComparisonResult(AppList *app1, AppList *app2) {
174-
struct stat st;
175-
BOOL enabled1 = lstat([app1.bundleURL.path stringByAppendingPathComponent:@".jbroot"].fileSystemRepresentation, &st)==0;
176-
BOOL enabled2 = lstat([app2.bundleURL.path stringByAppendingPathComponent:@".jbroot"].fileSystemRepresentation, &st)==0;
177-
if(enabled1 || enabled2) {
200+
201+
BOOL enabled1 = [self tweakEnabled:app1];
202+
BOOL enabled2 = [self tweakEnabled:app2];
203+
204+
if((enabled1&&!enabled2) || (!enabled1&&enabled2)) {
178205
return [@(enabled2) compare:@(enabled1)];
179206
}
180207

181208
if(app1.isHiddenApp || app2.isHiddenApp) {
182-
return [@(app1.isHiddenApp) compare:@(app2.isHiddenApp)];
209+
return (enabled1&&enabled2) ? [@(app2.isHiddenApp) compare:@(app1.isHiddenApp)] : [@(app1.isHiddenApp) compare:@(app2.isHiddenApp)];
183210
}
184211

185212
return [app1.name localizedStandardCompare:app2.name];
@@ -281,9 +308,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
281308
if([unsupportedBundleIDs containsObject:app.bundleIdentifier])
282309
theSwitch.enabled = NO;
283310

284-
struct stat st;
285-
BOOL enabled = lstat([app.bundleURL.path stringByAppendingPathComponent:@".jbroot"].fileSystemRepresentation, &st)==0;
286-
[theSwitch setOn:enabled];
311+
[theSwitch setOn:[self tweakEnabled:app]];
287312
[theSwitch addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
288313

289314
cell.accessoryView = theSwitch;
@@ -320,7 +345,7 @@ - (void)switchChanged:(id)sender {
320345
}
321346

322347
if(status != 0) {
323-
[AppDelegate showMesage:[NSString stringWithFormat:@"%@\n\nstderr:\n%@",log,err] title:[NSString stringWithFormat:@"code(%d)",status]];
348+
[AppDelegate showMesage:[NSString stringWithFormat:@"%@\nstderr:\n%@",log,err] title:[NSString stringWithFormat:@"error(%d)",status]];
324349
}
325350

326351
killAllForApp(app.bundleURL.path.UTF8String);

0 commit comments

Comments
 (0)