Skip to content

Commit

Permalink
some improvements and bug fixes
Browse files Browse the repository at this point in the history
1: fix safari causing kernel panic after enabling tweak on some devices
2: fix the issue that Safari cannot read preferences after enabling tweak
3: fix the issue of not being able to enable tweaks for apps that contain apple-watch plugins
4: add a check to prevent bootstrapping in the wrong environment
5: add a check to check for unexpected multiple jbroot directories
6: auto enable tweaks for the System Settings app on first bootstrap
7: update the built-in strap files
  • Loading branch information
roothider committed Sep 29, 2024
1 parent ef2922a commit 64d8985
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 7 deletions.
30 changes: 29 additions & 1 deletion Bootstrap/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void bootstrapAction()
}

NSString* launchdpath = getLaunchdPath();
if(![launchdpath isEqualToString:@"/sbin/launchd"] && ![launchdpath hasPrefix:@"/var/containers/Bundle/Application/.jbroot-"])
if(![launchdpath isEqualToString:@"/sbin/launchd"] && ![launchdpath hasPrefix:@"/private/var/containers/Bundle/Application/.jbroot-"])
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Error") message:Localized(@"Please reboot device first.") preferredStyle:UIAlertControllerStyleAlert];

Expand All @@ -438,6 +438,18 @@ void bootstrapAction()
UIImpactFeedbackGenerator* generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleSoft];
[generator impactOccurred];

int count=0;
NSArray *subItems = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/var/containers/Bundle/Application/" error:nil];
for (NSString *subItem in subItems) {
if (is_jbroot_name(subItem.UTF8String))
count++;
}

if(count > 1) {
[AppDelegate showMesage:Localized(@"There are multi jbroot in /var/containers/Bundle/Applicaton/") title:Localized(@"Error")];
return;
}

if(find_jbroot(YES)) //make sure jbroot() function available
{
if([NSFileManager.defaultManager fileExistsAtPath:jbroot(@"/.installed_dopamine")]) {
Expand Down Expand Up @@ -495,6 +507,22 @@ void bootstrapAction()
if(gTweakEnabled && ![NSFileManager.defaultManager fileExistsAtPath:jbroot(@"/var/mobile/.tweakenabled")]) {
ASSERT([[NSString new] writeToFile:jbroot(@"/var/mobile/.tweakenabled") atomically:YES encoding:NSUTF8StringEncoding error:nil]);
}

if(![NSFileManager.defaultManager fileExistsAtPath:jbroot(@"/var/mobile/.preferences_tweak_inited")])
{
[AppDelegate addLogText:Localized(@"Enable Tweak Injection for com.apple.Preferences")];

NSString* log=nil;
NSString* err=nil;
status = spawnRoot(NSBundle.mainBundle.executablePath, @[@"enableapp",@"/Applications/Preferences.app"], &log, &err);

if(status == 0) {
ASSERT([[NSString new] writeToFile:jbroot(@"/var/mobile/.preferences_tweak_inited") atomically:YES encoding:NSUTF8StringEncoding error:nil]);
} else {
[AppDelegate showMesage:[NSString stringWithFormat:@"%@\nstderr:\n%@",log,err] title:[NSString stringWithFormat:@"error(%d)",status]];
return;
}
}

[generator impactOccurred];
[AppDelegate addLogText:Localized(@"respring now...")]; sleep(1);
Expand Down
Binary file modified Bootstrap/basebin/bootstrap.dylib
Binary file not shown.
Binary file modified Bootstrap/basebin/bootstrapd
Binary file not shown.
Binary file modified Bootstrap/basebin/devtest
Binary file not shown.
Binary file modified Bootstrap/basebin/preload
Binary file not shown.
Binary file modified Bootstrap/basebin/preload.dylib
Binary file not shown.
Binary file modified Bootstrap/basebin/rebuildapp
Binary file not shown.
Binary file modified Bootstrap/basebin/uicache
Binary file not shown.
6 changes: 6 additions & 0 deletions Bootstrap/sources.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

#define DEFAULT_SOURCES "\
Types: deb\n\
URIs: https://yourepo.com/\n\
Suites: ./\n\
Components:\n\
\n\
Types: deb\n\
URIs: https://repo.chariz.com/\n\
Suites: ./\n\
Components:\n\
Expand Down Expand Up @@ -44,6 +49,7 @@ Components: main\n\
# Zebra Sources List\n\
deb https://getzbra.com/repo/ ./\n\
deb https://repo.chariz.com/ ./\n\
deb https://yourepo.com/ ./\n\
deb https://havoc.app/ ./\n\
deb https://roothide.github.io/ ./\n\
deb https://roothide.github.io/procursus iphoneos-arm64e/%d main\n\
Expand Down
5 changes: 0 additions & 5 deletions Bootstrap/utils.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ uint64_t resolve_jbrand_value(const char* name)
return value;
}


NSString* find_jbroot(BOOL force)
{
static NSString* cached_jbroot = nil;
Expand All @@ -75,10 +74,6 @@ uint64_t resolve_jbrand_value(const char* name)
if (is_jbroot_name(subItem.UTF8String))
{
NSString* path = [@"/var/containers/Bundle/Application/" stringByAppendingPathComponent:subItem];

// if([NSFileManager.defaultManager fileExistsAtPath:
// [path stringByAppendingPathComponent:@".installed_dopamine"]])
// continue;

jbroot = path;
break;
Expand Down
2 changes: 1 addition & 1 deletion basebin
Binary file modified strapfiles/bootstrap-1800.tar.zst
Binary file not shown.
Binary file modified strapfiles/bootstrap-1900.tar.zst
Binary file not shown.

0 comments on commit 64d8985

Please sign in to comment.