Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 committed Apr 7, 2024
1 parent cc6b2bf commit abf3d87
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion BaseBin/libjailbreak/src/jbclient_xpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ char *realafpath(const char *restrict path, char *restrict resolved_path)
// Running realpath on stuff in /var/jb or on rootfs causes some processes, on some devices, to crash
// If it starts with /, it's not a relative path and we can skip calling realpath on it
// We only care about resolving relative paths, so we can skip anything that doesn't look like one
// As a side effect, we also ignore loader relative paths that start with (@rpath/@executable_path/@loader_path)
// Additionally, we also ignore loader relative paths that start with (@rpath/@executable_path/@loader_path)
if (!resolved_path) {
resolved_path = malloc(PATH_MAX);
}
Expand Down
4 changes: 2 additions & 2 deletions BaseBin/libjailbreak/src/trustcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ int trustcache_file_build_from_path(const char *filePath, trustcache_file_v1 **t
return 0;
}

bool is_cdhash_in_trustcache(uint64_t tcKaddr, cdhash_t CDHash)
bool trustcache_contains_cdhash(uint64_t tcKaddr, cdhash_t CDHash)
{
uint64_t tcFileKaddr = kread64(tcKaddr + koffsetof(trustcache, fileptr));
uint32_t length = kread32(tcFileKaddr + offsetof(trustcache_file_v1, length));
Expand Down Expand Up @@ -393,7 +393,7 @@ bool is_cdhash_trustcached(cdhash_t CDHash)
{
__block bool inTrustCache = false;
_trustcache_list_enumerate(^(uint64_t tcKaddr, bool *stop) {
bool inThisTrustCache = is_cdhash_in_trustcache(tcKaddr, CDHash);
bool inThisTrustCache = trustcache_contains_cdhash(tcKaddr, CDHash);
if (inThisTrustCache) {
inTrustCache = true;
*stop = true;
Expand Down
1 change: 0 additions & 1 deletion BaseBin/libjailbreak/src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ uint64_t proc_self(void)
static uint64_t gSelfProc = 0;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
bool needsRelease = false;
gSelfProc = proc_find(getpid());
// decrement ref count again, we assume proc_self will exist for the whole lifetime of this process
proc_rele(gSelfProc);
Expand Down
5 changes: 3 additions & 2 deletions BaseBin/systemhook/src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ kBinaryConfig configForBinary(const char* path, char *const argv[restrict])
return 0;
}

// 1. Make sure the about to be spawned binary and all of it's dependencies are trust cached
// 1. Ensure the binary about to be spawned and all of it's dependencies are trust cached
// 2. Insert "DYLD_INSERT_LIBRARIES=/usr/lib/systemhook.dylib" into all binaries spawned
// 3. Increase Jetsam limit to more sane value (Multipler defined as JETSAM_MULTIPLIER)

int spawn_hook_common(pid_t *restrict pid, const char *restrict path,
const posix_spawn_file_actions_t *restrict file_actions,
Expand All @@ -243,7 +244,7 @@ int spawn_hook_common(pid_t *restrict pid, const char *restrict path,
kBinaryConfig binaryConfig = configForBinary(path, argv);

if (!(binaryConfig & kBinaryConfigDontProcess)) {
// jailbreakd: Upload binary to trustcache if needed
// Upload binary to trustcache if needed
trust_binary(path);
}

Expand Down
5 changes: 1 addition & 4 deletions BaseBin/systemhook/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ __attribute__((constructor)) static void initializer(void)
#ifndef __arm64e__
// On arm64, writing to executable pages removes CS_VALID from the csflags of the process
// These hooks are neccessary to get the system to behave with this
// They're ugly but they're needed
// They are ugly but needed
litehook_hook_function(csops, csops_hook);
litehook_hook_function(csops_audittoken, csops_audittoken_hook);
if (__builtin_available(iOS 16.0, *)) {
Expand All @@ -502,9 +502,6 @@ __attribute__((constructor)) static void initializer(void)

#ifndef __arm64e__
// Feeable attempt at adding back CS_VALID
// If any hooks are applied after this, it is lost again
// Temporary workaround until a better solution for this problem is found
// This + the csops hook should resolve all cases unless a tweak does something really stupid
jbclient_cs_revalidate();
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion BaseBin/systemhook/src/objc.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ bool NSConcreteTask_launchWithDictionary_error__hook(id self, id sender, NSDicti
void dopamine_fix_NSTask(void)
{
// This only works if libobjc and Foundation are already loaded, that is by design
// So as of right now it only automatically works if some any tweak is loaded (as libellekit depends on Foundation)
// So as of right now it only automatically works if some tweak is loaded (as libellekit depends on Foundation)
// If you want to use NSTask in your app or whatever, call this function yourself after Foundation is loaded
// This could be automated but it's difficult due to image loading callbacks being shit
void *libobjcHandle = dlopen("/usr/lib/libobjc.A.dylib", RTLD_NOLOAD);
Expand Down

0 comments on commit abf3d87

Please sign in to comment.