Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability for exceptions such as libmryipc #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Tweak.x
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
#import <os/log.h>

static const char *exceptions[] = {
"/Library/MobileSubstrate/DynamicLibraries/mrybootstrap.dylib",
"/usr/lib/TweakInject/mrybootstrap.dylib",
NULL
};

static BOOL isAllowed(const char *path) {
for (const char **exception = exceptions; *exception; exception++) {
if (strcmp(*exception, path) == 0)
return YES;
}
return NO;
}

static BOOL hasPrefix(const char *string, const char *prefix) {
return strncmp(prefix, string, strlen(prefix)) == 0;
}

%hookf(void *, dlopen, const char *path, int mode) {
if (hasPrefix(path, "/Library/MobileSubstrate/DynamicLibraries") || hasPrefix(path, "/usr/lib/TweakInject")) {
if ((hasPrefix(path, "/Library/MobileSubstrate/DynamicLibraries/") || hasPrefix(path, "/usr/lib/TweakInject/")) && !isAllowed(path)) {
os_log(OS_LOG_DEFAULT, "stopcrashingpls: Loading of %{public}s was blocked.", path);
return NULL;
}
Expand Down