Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 committed Jul 26, 2024
1 parent 07a34c9 commit 67820ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions BaseBin/systemhook/src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static kSpawnConfig spawn_config_for_executable(const char* path, char *const ar
if (string_has_prefix(argv[1], "com.apple.WebKit.WebContent")) {
// The most sandboxed process on the system, we can't support it on iOS 16+ for now
if (__builtin_available(iOS 16.0, *)) {
return (kSpawnConfigDontInject | kSpawnConfigDontTrust);
return 0;
}
}
}
Expand All @@ -94,10 +94,10 @@ static kSpawnConfig spawn_config_for_executable(const char* path, char *const ar
size_t blacklistCount = sizeof(processBlacklist) / sizeof(processBlacklist[0]);
for (size_t i = 0; i < blacklistCount; i++)
{
if (!strcmp(processBlacklist[i], path)) return (kSpawnConfigDontInject | kSpawnConfigDontTrust);
if (!strcmp(processBlacklist[i], path)) return 0;
}

return 0;
return (kSpawnConfigInject | kSpawnConfigTrust);
}

int __posix_spawn_orig(pid_t *restrict pid, const char *restrict path, struct _posix_spawn_args_desc *desc, char *const argv[restrict], char * const envp[restrict])
Expand Down Expand Up @@ -127,7 +127,7 @@ int spawn_hook_common(pid_t *restrict pid, const char *restrict path,

kSpawnConfig spawnConfig = spawn_config_for_executable(path, argv);

if (!(spawnConfig & kSpawnConfigDontTrust)) {
if (spawnConfig & kSpawnConfigTrust) {
bool preferredArchsSet = false;
cpu_type_t preferredTypes[4];
cpu_subtype_t preferredSubtypes[4];
Expand Down Expand Up @@ -168,7 +168,7 @@ int spawn_hook_common(pid_t *restrict pid, const char *restrict path,
if (!strcmp(existingLibraryInsert, HOOK_DYLIB_PATH)) {
systemHookAlreadyInserted = true;
}
else if (!(spawnConfig & kSpawnConfigDontTrust)) {
else if (spawnConfig & kSpawnConfigTrust) {
// Upload everything already in DYLD_INSERT_LIBRARIES to trustcache aswell
trust_binary(existingLibraryInsert, NULL);
}
Expand All @@ -182,7 +182,7 @@ int spawn_hook_common(pid_t *restrict pid, const char *restrict path,
bool shouldInsertJBEnv = true;
bool hasSafeModeVariable = false;
do {
if (spawnConfig & kSpawnConfigDontInject) {
if (!(spawnConfig & kSpawnConfigInject)) {
shouldInsertJBEnv = false;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions BaseBin/systemhook/src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

typedef enum
{
kSpawnConfigDontInject = 1 << 0,
kSpawnConfigDontTrust = 1 << 1
kSpawnConfigInject = 1 << 0,
kSpawnConfigTrust = 1 << 1,
} kSpawnConfig;

struct _posix_spawn_args_desc {
Expand Down
4 changes: 2 additions & 2 deletions BaseBin/systemhook/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ int csops_audittoken_hook(pid_t pid, unsigned int ops, void *useraddr, size_t us

#endif

bool shouldEnableTweaks(void)
bool should_enable_tweaks(void)
{
if (access(JBROOT_PATH("/basebin/.safe_mode"), F_OK) == 0) {
return false;
Expand Down Expand Up @@ -367,7 +367,7 @@ __attribute__((constructor)) static void initializer(void)
#endif
// Load tweaks if desired
// We can hardcode /var/jb here since if it doesn't exist, loading TweakLoader.dylib is not going to work anyways
if (shouldEnableTweaks()) {
if (should_enable_tweaks()) {
const char *tweakLoaderPath = "/var/jb/usr/lib/TweakLoader.dylib";
if(access(tweakLoaderPath, F_OK) == 0) {
void *tweakLoaderHandle = dlopen(tweakLoaderPath, RTLD_NOW);
Expand Down

0 comments on commit 67820ae

Please sign in to comment.