Skip to content

Commit 8086995

Browse files
committed
2.0 public beta4
1 parent 8c56104 commit 8086995

File tree

7 files changed

+168
-75
lines changed

7 files changed

+168
-75
lines changed

Bootstrap.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@
593593
"$(PROJECT_DIR)",
594594
"$(PROJECT_DIR)/basebin/common/lib",
595595
);
596-
MARKETING_VERSION = "2.0-beta3";
596+
MARKETING_VERSION = "2.0-beta4";
597597
OTHER_LDFLAGS = "";
598598
PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap;
599599
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -639,7 +639,7 @@
639639
"$(PROJECT_DIR)",
640640
"$(PROJECT_DIR)/basebin/common/lib",
641641
);
642-
MARKETING_VERSION = "2.0-beta3";
642+
MARKETING_VERSION = "2.0-beta4";
643643
OTHER_LDFLAGS = "";
644644
PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap;
645645
PRODUCT_NAME = "$(TARGET_NAME)";

Bootstrap/AppEnabler.m

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,44 @@ int enableForApp(NSString* bundlePath)
168168

169169
if([bundlePath hasPrefix:@"/Applications/"])
170170
{
171-
if([fm fileExistsAtPath:jbroot(bundlePath)])
172-
ASSERT([fm removeItemAtPath:jbroot(bundlePath) error:nil]);
171+
BOOL noregister = NO;
173172

174-
ASSERT([fm copyItemAtPath:bundlePath toPath:jbroot(bundlePath) error:nil]);
173+
NSString* newBundlePath = jbroot(bundlePath);
175174

176-
ASSERT([fm createSymbolicLinkAtPath:[jbroot(bundlePath) stringByAppendingString:@"/.jbroot"] withDestinationPath:jbroot(@"/") error:nil]);
175+
if(@available(iOS 16.0, *))
176+
{
177+
noregister = YES;
178+
179+
/*
180+
newBundlePath = [@"/.sysroot/" stringByAppendingString:bundlePath];
181+
182+
if(![fm fileExistsAtPath:jbroot(@"/.sysroot/Applications")]) {
183+
NSDictionary* attr = @{NSFilePosixPermissions:@(0755), NSFileOwnerAccountID:@(0), NSFileGroupOwnerAccountID:@(0)};
184+
ASSERT([fm createDirectoryAtPath:jbroot(@"/.sysroot/Applications") withIntermediateDirectories:YES attributes:attr error:nil]);
185+
}//*/
186+
}
187+
188+
if([fm fileExistsAtPath:newBundlePath])
189+
ASSERT([fm removeItemAtPath:newBundlePath error:nil]);
190+
191+
ASSERT([fm copyItemAtPath:bundlePath toPath:newBundlePath error:nil]);
192+
193+
ASSERT([fm createSymbolicLinkAtPath:[newBundlePath stringByAppendingString:@"/.jbroot"] withDestinationPath:jbroot(@"/") error:nil]);
177194

178195
NSString* log=nil;
179196
NSString* err=nil;
180-
if(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-p", bundlePath.UTF8String, NULL}, &log, &err) != 0) {
197+
if(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-p", newBundlePath.fileSystemRepresentation, NULL}, &log, &err) != 0)
198+
{
181199
STRAPLOG("%@\nERR:%@", log, err);
182-
AppInfo* app = [AppInfo appWithBundleIdentifier:appInfo[@"CFBundleIdentifier"]];
183-
if(app && [app.bundleURL.path hasPrefix:@"/Applications/"]) {
184-
ASSERT([fm removeItemAtPath:bundlePath error:nil]);
200+
201+
if(!noregister)
202+
{
203+
AppInfo* app = [AppInfo appWithBundleIdentifier:appInfo[@"CFBundleIdentifier"]];
204+
if(app && [app.bundleURL.path hasPrefix:@"/Applications/"]) {
205+
ASSERT([fm removeItemAtPath:newBundlePath error:nil]);
206+
}
185207
}
208+
186209
ABORT();
187210
}
188211
}
@@ -194,7 +217,7 @@ int enableForApp(NSString* bundlePath)
194217

195218
NSString* log=nil;
196219
NSString* err=nil;
197-
if(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).UTF8String, NULL}, &log, &err) != 0) {
220+
if(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).fileSystemRepresentation, NULL}, &log, &err) != 0) {
198221
STRAPLOG("%@\nERR:%@", log, err);
199222
ABORT();
200223
}
@@ -207,7 +230,7 @@ int enableForApp(NSString* bundlePath)
207230

208231
NSString* log=nil;
209232
NSString* err=nil;
210-
if(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).UTF8String, NULL}, &log, &err) != 0) {
233+
if(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).fileSystemRepresentation, NULL}, &log, &err) != 0) {
211234
STRAPLOG("%@\nERR:%@", log, err);
212235
ABORT();
213236
}
@@ -225,19 +248,28 @@ int disableForApp(NSString* bundlePath)
225248
NSDictionary* appInfo = [NSDictionary dictionaryWithContentsOfFile:[bundlePath stringByAppendingPathComponent:@"Info.plist"]];
226249
if(!appInfo) return -1;
227250

228-
if(![bundlePath hasPrefix:@"/Applications/"] && [bundlePath containsString:@"/Applications/"])
251+
if([bundlePath hasPrefix:@"/Applications/"]) {
252+
NSString* resignedBundlePath = jbroot(bundlePath);
253+
if([fm fileExistsAtPath:resignedBundlePath]) {
254+
ASSERT([fm removeItemAtPath:resignedBundlePath error:nil]);
255+
}
256+
NSString* resignedBundlePath2 = jbroot([@"/.sysroot/" stringByAppendingString:bundlePath]);
257+
if([fm fileExistsAtPath:resignedBundlePath2]) {
258+
ASSERT([fm removeItemAtPath:resignedBundlePath2 error:nil]);
259+
}
260+
}
261+
else if(![bundlePath hasPrefix:@"/Applications/"] && [bundlePath containsString:@"/Applications/"])
229262
{
230263
ASSERT([fm removeItemAtPath:bundlePath error:nil]);
231264

232265
NSString* sysPath = [@"/Applications/" stringByAppendingString:bundlePath.lastPathComponent];
233-
ASSERT(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-p", rootfsPrefix(sysPath).UTF8String, NULL}, nil, nil) == 0);
266+
ASSERT(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-p", rootfsPrefix(sysPath).fileSystemRepresentation, NULL}, nil, nil) == 0);
234267
}
235268
else if([appInfo[@"CFBundleIdentifier"] hasPrefix:@"com.apple."] || hasTrollstoreMarker(bundlePath.fileSystemRepresentation))
236269
{
237-
238270
ASSERT(restoreApp(bundlePath) == 0);
239271

240-
ASSERT(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).UTF8String, NULL}, nil, nil) == 0);
272+
ASSERT(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-s","-p", rootfsPrefix(bundlePath).fileSystemRepresentation, NULL}, nil, nil) == 0);
241273
}
242274
else
243275
{
@@ -251,9 +283,9 @@ int disableForApp(NSString* bundlePath)
251283
if(encryptedApp && backupVersion.intValue>=1) return 0;
252284

253285
//unregister or respring to keep app's icon on home screen
254-
ASSERT(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-u", rootfsPrefix(bundlePath).UTF8String, NULL}, nil, nil) == 0);
286+
ASSERT(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-u", rootfsPrefix(bundlePath).fileSystemRepresentation, NULL}, nil, nil) == 0);
255287
//come back
256-
ASSERT(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-p", rootfsPrefix(bundlePath).UTF8String, NULL}, nil, nil) == 0);
288+
ASSERT(spawn_bootstrap_binary((char*[]){"/usr/bin/uicache","-p", rootfsPrefix(bundlePath).fileSystemRepresentation, NULL}, nil, nil) == 0);
257289
}
258290

259291
return 0;

Bootstrap/AppViewController.m

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ -(BOOL)tweakEnabled:(AppInfo*)app {
121121
return YES;
122122
}
123123

124+
if(@available(iOS 16.0, *))
125+
{
126+
if([app.bundleURL.path hasPrefix:@"/Applications/"] && [NSFileManager.defaultManager fileExistsAtPath:jbroot(app.bundleURL.path)]) {
127+
return YES;
128+
}
129+
130+
if([NSFileManager.defaultManager fileExistsAtPath:jbroot([@"/.sysroot/" stringByAppendingString:app.bundleURL.path])]) {
131+
return YES;
132+
}
133+
}
134+
124135
if(!isRemovableBundlePath(app.bundleURL.path.fileSystemRepresentation)) {
125136
return NO;
126137
}
@@ -314,34 +325,46 @@ - (void)switchChanged:(id)sender {
314325
UISwitch *switchInCell = (UISwitch *)sender;
315326
CGPoint pos = [switchInCell convertPoint:switchInCell.bounds.origin toView:self.tableView];
316327
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:pos];
317-
BOOL enabled = switchInCell.on;
328+
318329
AppInfo* app = isFiltered? filteredApps[indexPath.row] : appsArray[indexPath.row];
319330

331+
BOOL enabled = switchInCell.on;
332+
320333
if(enabled && isBlacklistedApp(app.bundleIdentifier.UTF8String)) {
321334
[AppDelegate showMesage:Localized(@"This app is blacklisted by RootHide Manager, please unblacklist it first.") title:@""];
322335
[switchInCell setOn:NO];
323336
return;
324337
}
338+
339+
if([app.bundleURL.path hasPrefix:@"/Applications/"])
340+
{
341+
NSString* resignedBundlePath = [jbroot(@"/.sysroot") stringByAppendingPathComponent:app.bundleURL.path];
342+
if([NSFileManager.defaultManager fileExistsAtPath:resignedBundlePath])
343+
{
344+
NSString* InfoPlistPath = [resignedBundlePath stringByAppendingPathComponent:@"Info.plist"];
345+
346+
struct stat st={0};
347+
if(lstat(InfoPlistPath.fileSystemRepresentation, &st)!=0 || S_ISLNK(st.st_mode)) {
348+
[AppDelegate showMesage:Localized(@"This app's injection is hosted by Bootstrap now, you don't have to deal with it.") title:@""];
349+
[switchInCell setOn:!enabled];
350+
return;
351+
}
352+
}
353+
}
325354

326355
dispatch_async(dispatch_get_global_queue(0, 0), ^{
327356
[AppDelegate showHudMsg:Localized(@"Applying")];
328357

329-
killAllForBundle(app.bundleURL.path.UTF8String);
358+
killAllForBundle(app.bundleURL.path.fileSystemRepresentation);
330359

331-
int status;
332360
NSString* log=nil;
333361
NSString* err=nil;
334-
if(enabled) {
335-
status = spawn_root(NSBundle.mainBundle.executablePath, @[@"enableapp",app.bundleURL.path], &log, &err);
336-
} else {
337-
status = spawn_root(NSBundle.mainBundle.executablePath, @[@"disableapp",app.bundleURL.path], &log, &err);
338-
}
339-
362+
int status = spawn_root(NSBundle.mainBundle.executablePath, @[enabled ? @"enableapp" : @"disableapp",app.bundleURL.path], &log, &err);
340363
if(status != 0) {
341364
[AppDelegate showMesage:[NSString stringWithFormat:@"%@\nstderr:\n%@",log,err] title:[NSString stringWithFormat:@"error(%d)",status]];
342365
}
343366

344-
killAllForBundle(app.bundleURL.path.UTF8String);
367+
killAllForBundle(app.bundleURL.path.fileSystemRepresentation);
345368

346369
//refresh app cache list
347370
[self updateData:NO];

0 commit comments

Comments
 (0)