From 65c94e0dbb4587c5f17fb9eb4de6ba0a856492c6 Mon Sep 17 00:00:00 2001 From: tomikun <60690056+alexytomi@users.noreply.github.com> Date: Sat, 15 Aug 2026 16:10:50 +0800 Subject: [PATCH] mitigation: Workaround new SDL autodetection crash on Turnip Hooking dlopen crashes linker_ns_load for some reason. No clue why. --- app_pojavlauncher/src/main/jni/native_hooks/dlopen_hook.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app_pojavlauncher/src/main/jni/native_hooks/dlopen_hook.c b/app_pojavlauncher/src/main/jni/native_hooks/dlopen_hook.c index 346576636..dfdc5caa8 100644 --- a/app_pojavlauncher/src/main/jni/native_hooks/dlopen_hook.c +++ b/app_pojavlauncher/src/main/jni/native_hooks/dlopen_hook.c @@ -45,6 +45,7 @@ static const char *redirect_dlopen_path(const char *filename) { } static void *sdl3_handle = NULL; + static JNI_OnLoad_t orig_sdl3_JNI_OnLoad; static bool ifSdl(const char *filename) { @@ -89,6 +90,7 @@ void *custom_dlsym(void *handle, const char *symbol) { handle, symbol); BYTEHOOK_POP_STACK(); + if (sdl3_handle == NULL) sdl3_handle = dlopen("libSDL3.so", RTLD_LOCAL | RTLD_NOW); if (sdl3_handle && handle == sdl3_handle && strcmp(symbol, "JNI_OnLoad") == 0) { orig_sdl3_JNI_OnLoad = (JNI_OnLoad_t) result; @@ -100,8 +102,9 @@ void *custom_dlsym(void *handle, const char *symbol) { } void create_dlopen_hooks(bytehook_hook_all_t bytehook_hook_all_p) { - bytehook_stub_t stub_dlopen = - bytehook_hook_all_p(NULL, "dlopen", &custom_dlopen, NULL, NULL); + // FIXME: Hooking dlopen causes a crash with Turnip loader, so let's stop doing that entirely + bytehook_stub_t stub_dlopen = (void *)(uintptr_t)0xD15AB1ED; +// bytehook_hook_all_p(NULL, "dlopen", &custom_dlopen, NULL, NULL); bytehook_stub_t stub_dlsym = bytehook_hook_all_p(NULL, "dlsym", &custom_dlsym, NULL, NULL); LOGI("Successfully initialized dlopen hooks, stub: %p %p", stub_dlopen, stub_dlsym);