From cee58e2c237e512fb97bf30e673cf2fbc4473191 Mon Sep 17 00:00:00 2001 From: tomikun <60690056+alexytomi@users.noreply.github.com> Date: Tue, 28 Jul 2026 14:49:45 +0800 Subject: [PATCH 1/3] regression: Accidentally broke SDL integration detection, oops --- app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c b/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c index 73fa746fb..af0878f53 100644 --- a/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c +++ b/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c @@ -58,6 +58,7 @@ static bool custom_SDL_InitSubSystem_Func(SDL_InitFlags flags) { void create_sdl_hooks(bytehook_hook_all_t bytehook_hook_all_p) { - bytehook_stub_t stub_SDL_InitSubSystem = bytehook_hook_all_p("libSDL3.so", "SDL_InitSubSystem", &custom_SDL_InitSubSystem_Func, NULL, NULL); + // Don't set callee_path_name to anything besides NULL or else it won't be able to find the symbol + bytehook_stub_t stub_SDL_InitSubSystem = bytehook_hook_all_p(NULL, "SDL_InitSubSystem", &custom_SDL_InitSubSystem_Func, NULL, NULL); LOGI("Successfully initialized SDL hooks, stubs: %p, %p\n", stub_SDL_InitSubSystem); } \ No newline at end of file From 67005035c7df8de5c86bed8238ea2a9e48f6a6b5 Mon Sep 17 00:00:00 2001 From: tomikun <60690056+alexytomi@users.noreply.github.com> Date: Tue, 28 Jul 2026 14:50:08 +0800 Subject: [PATCH 2/3] fix: Properly dlsym SDL functions Seems like android doesn't like global anything --- .../src/main/jni/native_hooks/sdl_hook.c | 4 ++-- app_pojavlauncher/src/main/jni/utils.h | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c b/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c index af0878f53..f371585bb 100644 --- a/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c +++ b/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c @@ -19,7 +19,7 @@ DECL_DLSYM(SDL_SetError); static bool custom_SDL_InitSubSystem_Func(SDL_InitFlags flags) { // Call notifyLauncher on SDL_InitSubSystem, this sets up all the JNI stuff needed by SDL. TRY_ATTACH_ENV(dvm_env, pojav_environ->dalvikJavaVMPtr, "SDL_InitSubSystem failed!", - SET_DLSYM_PTR(SDL_SetError); + SET_DLSYM_PTR(dlopen("libSDL3.so", RTLD_NOLOAD), SDL_SetError); if (SDL_SetError_p) SDL_SetError_p("Failed to load SDL launcher integration android-side. This is not an SDL bug, please contact the launcher developer."); return false; ); @@ -33,7 +33,7 @@ static bool custom_SDL_InitSubSystem_Func(SDL_InitFlags flags) { notifyLauncher(dvm_env, NOTIF_TYPE_SDL, (int[]){ACTION_INIT_LAUNCHER_INTEGRATION, safeFlags}, 2); // This is the normal for the launcher, the default in SDL is false. - SET_DLSYM_PTR(SDL_SetHint); + SET_DLSYM_PTR(dlopen("libSDL3.so", RTLD_NOLOAD), SDL_SetHint); if (SDL_SetHint_p) SDL_SetHint_p("SDL_RETURN_KEY_HIDES_IME", "true"); // FIXME: idk why it wont srgb, sorry SDL_SetHint_p("SDL_OPENGL_FORCE_SRGB_FRAMEBUFFER", "0"); diff --git a/app_pojavlauncher/src/main/jni/utils.h b/app_pojavlauncher/src/main/jni/utils.h index ae4873ea2..f40d06e08 100644 --- a/app_pojavlauncher/src/main/jni/utils.h +++ b/app_pojavlauncher/src/main/jni/utils.h @@ -13,16 +13,17 @@ #define DECL_DLSYM(fn) typedef typeof(&fn) fn##_t; -#define SET_DLSYM_PTR(fn) \ - fn##_t fn##_p; \ - do { \ - dlerror(); \ - void *_p = dlsym(RTLD_NEXT, #fn); \ - const char *_e = dlerror(); \ - if (_e || !_p) { \ - LOGE("dlsym(%s) failed: %s\n", #fn, _e ? _e : "unknown error"); \ - } \ - fn##_p = (typeof(fn##_t))_p; \ +#define SET_DLSYM_PTR(handle, fn) \ + fn##_t fn##_p; \ + do { \ + dlerror(); \ + void *_p = dlsym((handle), #fn); \ + const char *_e = dlerror(); \ + if (_e || !_p) { \ + LOGE("dlsym(%s) failed: %s\n", \ + #fn, _e ? _e : "unknown error"); \ + } \ + fn##_p = (fn##_t)_p; \ } while (0) #define TRY_ATTACH_ENV(env_name, vm, error_message, then) JNIEnv* env_name;\ From 417500e184a9ebe78305187b71ac10f5b40e8543 Mon Sep 17 00:00:00 2001 From: tomikun <60690056+alexytomi@users.noreply.github.com> Date: Tue, 28 Jul 2026 14:58:17 +0800 Subject: [PATCH 3/3] mitigation: MobileGlues incorrectly parses EGL color space --- app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c b/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c index f371585bb..42a09ced3 100644 --- a/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c +++ b/app_pojavlauncher/src/main/jni/native_hooks/sdl_hook.c @@ -35,8 +35,11 @@ static bool custom_SDL_InitSubSystem_Func(SDL_InitFlags flags) { // This is the normal for the launcher, the default in SDL is false. SET_DLSYM_PTR(dlopen("libSDL3.so", RTLD_NOLOAD), SDL_SetHint); if (SDL_SetHint_p) SDL_SetHint_p("SDL_RETURN_KEY_HIDES_IME", "true"); - // FIXME: idk why it wont srgb, sorry - SDL_SetHint_p("SDL_OPENGL_FORCE_SRGB_FRAMEBUFFER", "0"); + // FIXME: MobileGlues has issues with passing in the proper EGL params to make this work + const char *egl = getenv("POJAVEXEC_EGL"); + if (egl && strcmp(egl, "libmobileglues.so") == 0) { + SDL_SetHint_p("SDL_OPENGL_FORCE_SRGB_FRAMEBUFFER", "0"); + } // Call original func after doing all the needed setup bool r = BYTEHOOK_CALL_PREV(custom_SDL_InitSubSystem_Func, SDL_InitSubSystem_t, flags);