From 3b69c32f967a7aeb1d7353ae5142cde0ee66ca26 Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Tue, 24 Nov 2020 11:45:50 -1000 Subject: Fix safe mode for iOS14 --- Tweak.xm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Tweak.xm b/Tweak.xm index a8fa66c..dd3af5b 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -440,7 +440,7 @@ const char *dylibs_[] = { NULL, }; -MSHook(void *, dlopen, const char *path, int mode) { +MSHook(void *, dlopen, const char *path, int mode, void *lr) { // we probably don't need this whitelist, but it has the nifty benefit of letting Cycript inject // that said, older versions of iOS (before 3.1) will need a special case due to now shared cache @@ -462,14 +462,17 @@ MSHook(void *, dlopen, const char *path, int mode) { mode |= RTLD_NOLOAD; load: - return _dlopen(path, mode); + return _dlopen(path, mode, lr); } - %ctor { NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); - MSHookFunction(&dlopen, MSHake(dlopen)); + decltype(_dlopen) dlopen$(nullptr); + if (MSImageRef libdyld = MSGetImageByName("/usr/lib/system/libdyld.dylib")) { + MSHookSymbol(dlopen$, "__ZL15dlopen_internalPKciPv", libdyld); + } + MSHookFunction(dlopen$ ?: reinterpret_cast(&dlopen), MSHake(dlopen)); // on iOS 6, backboardd is in charge of brightness, and freaks out when SpringBoard restarts :( // the result is that the device is super dark until we attempt to update the brightness here. -- cgit v1.2.3