Skip to content

Commit

Permalink
Small code cleanup, support jailbreaking without developer mode being…
Browse files Browse the repository at this point in the history
… enabled
  • Loading branch information
opa334 committed Mar 3, 2024
1 parent bee77a7 commit e6a166b
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 147 deletions.
32 changes: 25 additions & 7 deletions Application/Dopamine/Jailbreak/DOJailbreaker.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,25 @@ - (NSError *)gatherSystemInformation

int r = xpf_start_with_kernel_path(kernelPath.fileSystemRepresentation);
if (r == 0) {
const char *sets[] = {
char *sets[] = {
"translation",
"sandbox",
"trustcache",
"sandbox",
"physmap",
"struct",
"physrw",
"perfkrw",
"badRecovery",
NULL
NULL,
NULL,
NULL,
};

if (!xpf_set_is_supported("badRecovery")) {
sets[(sizeof(sets)/sizeof(sets[0]))-2] = NULL;

uint32_t idx = 7;
if (xpf_set_is_supported("devmode")) {
sets[idx++] = "devmode";
}
if (xpf_set_is_supported("badRecovery")) {
sets[idx++] = "badRecovery";
}

_systemInfoXdict = xpf_construct_offset_dictionary(sets);
Expand Down Expand Up @@ -261,6 +266,17 @@ - (NSError *)showNonDefaultSystemApps
return nil;
}

- (NSError *)ensureDevModeEnabled
{
if (@available(iOS 16.0, *)) {
uint64_t developer_mode_state = kread64(ksymbol(developer_mode_enabled));
if (kread8(developer_mode_state) == 0) {
kwrite8(developer_mode_state, 1);
}
}
return nil;
}

- (NSError *)loadBasebinTrustcache
{
trustcache_file_v1 *basebinTcFile = NULL;
Expand Down Expand Up @@ -457,6 +473,8 @@ - (void)runWithError:(NSError **)errOut didRemoveJailbreak:(BOOL*)didRemove show
if (*errOut) return;
*errOut = [self showNonDefaultSystemApps];
if (*errOut) return;
*errOut = [self ensureDevModeEnabled];
if (*errOut) return;

// Now that we are unsandboxed, populate the jailbreak root path
[[DOEnvironmentManager sharedManager] ensureJailbreakRootExists];
Expand Down
2 changes: 1 addition & 1 deletion BaseBin/ChOma
18 changes: 12 additions & 6 deletions BaseBin/launchdhook/src/update.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,27 @@ void jbupdate_update_system_info(void)
int r = xpf_start_with_kernel_path(kernelPath);
const char *error = NULL;
if (r == 0) {
const char *sets[] = {
char *sets[] = {
"translation",
"trustcache",
"sandbox",
"physmap",
"struct",
"physrw",
"perfkrw",
"badRecovery",
NULL
NULL,
NULL,
NULL,
};

if (!xpf_set_is_supported("badRecovery")) {
sets[(sizeof(sets)/sizeof(sets[0]))-2] = NULL;

uint32_t idx = 7;
if (xpf_set_is_supported("devmode")) {
sets[idx++] = "devmode";
}
if (xpf_set_is_supported("badRecovery")) {
sets[idx++] = "badRecovery";
}

systemInfoXdict = xpf_construct_offset_dictionary(sets);
if (!systemInfoXdict) {
error = xpf_get_error();
Expand Down
6 changes: 3 additions & 3 deletions BaseBin/libjailbreak/src/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void jbinfo_initialize_hardcoded_offsets(void)
}
}
#endif

// proc
gSystemInfo.kernelStruct.proc.list_next = 0x0;
gSystemInfo.kernelStruct.proc.list_prev = 0x8;
Expand Down Expand Up @@ -88,7 +88,7 @@ void jbinfo_initialize_hardcoded_offsets(void)
gSystemInfo.kernelStruct.pmap.wx_allowed = 0;
gSystemInfo.kernelStruct.pmap.type = 0x9c + pmapA11Adjust;
#endif

// pt_desc
gSystemInfo.kernelStruct.pt_desc.pmap = 0x10;
gSystemInfo.kernelStruct.pt_desc.va = 0x18;
Expand Down Expand Up @@ -133,7 +133,7 @@ void jbinfo_initialize_hardcoded_offsets(void)
#else
gSystemInfo.kernelStruct.task.task_can_transfer_memory_ownership = 0x590;
#endif

// ipc_port
gSystemInfo.kernelStruct.ipc_port.kobject = 0x58;

Expand Down
Loading

0 comments on commit e6a166b

Please sign in to comment.