diff --git a/app_pojavlauncher/src/main/jni/ctxbridges/egl_loader.c b/app_pojavlauncher/src/main/jni/ctxbridges/egl_loader.c index b237776c24..575005e224 100644 --- a/app_pojavlauncher/src/main/jni/ctxbridges/egl_loader.c +++ b/app_pojavlauncher/src/main/jni/ctxbridges/egl_loader.c @@ -1,15 +1,11 @@ // // Created by maks on 21.09.2022. // -#include #include #include #include #include "egl_loader.h" -#include "global_state.h" #include "loader_dlopen.h" -#include -#include EGLBoolean (*eglMakeCurrent_p) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); EGLBoolean (*eglDestroyContext_p) (EGLDisplay dpy, EGLContext ctx); @@ -41,21 +37,6 @@ bool dlsym_EGL() { char* gles = getenv("LIBGL_GLES"); char* eglName = (strncmp(gles ? gles : "", "libGLESv2_angle.so", 18) == 0) ? "libEGL_angle.so" : getenv("POJAVEXEC_EGL"); void* dl_handle = loader_dlopen(eglName,"libEGL.so", RTLD_LOCAL|RTLD_LAZY); - // Mesa renderers that are also GPU drivers need this - if (eglName != NULL && dl_handle == NULL && strncmp(eglName, "libEGL_mesa.so", 14) == 0) { - // Not sure where to put this because pojavexec is shit - if (!app_escapeNs) { - app_escapeNs = private_create_namespace( - "app-escapeNs", - NULL, - getenv("POJAV_NATIVEDIR"), // append to search path! - ANDROID_NAMESPACE_TYPE_SHARED, // Inherit from escapeNs paths - getenv("POJAV_NATIVEDIR"), // not needed, useless for non-isolate - get_escape_namespace(), // Inherit from escapeNs so we get the system lib paths too - __builtin_return_address(0)); - } - dl_handle = linker_ns_dlopen(eglName, RTLD_LOCAL | RTLD_LAZY, app_escapeNs); - } if(dl_handle == NULL) return false; eglGetProcAddress_p = dlsym(dl_handle, "eglGetProcAddress"); if(eglGetProcAddress_p == NULL) { diff --git a/app_pojavlauncher/src/main/jni/ctxbridges/loader_dlopen.c b/app_pojavlauncher/src/main/jni/ctxbridges/loader_dlopen.c index cc8ff70dad..adba4a1e76 100644 --- a/app_pojavlauncher/src/main/jni/ctxbridges/loader_dlopen.c +++ b/app_pojavlauncher/src/main/jni/ctxbridges/loader_dlopen.c @@ -1,21 +1,53 @@ // // Created by maks on 26.10.2024. // -#include -#include #include #include +#include +#include +#include + +#include "androidnsbypass/nsbypass.h" +#include "androidnsbypass/nsbypass_t.h" +#include "global_state.h" + void* loader_dlopen(char* primaryName, char* secondaryName, int flags) { void* dl_handle; if(primaryName == NULL) goto secondary; dl_handle = dlopen(primaryName, flags); if(dl_handle != NULL) return dl_handle; + // Fallback to nsbypass if it didn't work + if (!app_escapeNs) { + app_escapeNs = private_create_namespace( + "app-escapeNs", + NULL, + getenv("POJAV_NATIVEDIR"), // append to search path! + ANDROID_NAMESPACE_TYPE_SHARED, // Inherit from escapeNs paths + getenv("POJAV_NATIVEDIR"), // not needed, useless for non-isolate + get_escape_namespace(), // Inherit from escapeNs so we get the system lib paths too + __builtin_return_address(0)); + } + dl_handle = linker_ns_dlopen(primaryName, RTLD_LOCAL | RTLD_LAZY, app_escapeNs); + if(dl_handle != NULL) return dl_handle; + if(secondaryName == NULL) goto dl_error; secondary: dl_handle = dlopen(secondaryName, flags); if(dl_handle == NULL) goto dl_error; + // Fallback to nsbypass if it didn't work + if (!app_escapeNs) { + app_escapeNs = private_create_namespace( + "app-escapeNs", + NULL, + getenv("POJAV_NATIVEDIR"), // append to search path! + ANDROID_NAMESPACE_TYPE_SHARED, // Inherit from escapeNs paths + getenv("POJAV_NATIVEDIR"), // not needed, useless for non-isolate + get_escape_namespace(), // Inherit from escapeNs so we get the system lib paths too + __builtin_return_address(0)); + } + dl_handle = linker_ns_dlopen(secondaryName, RTLD_LOCAL | RTLD_LAZY, app_escapeNs); return dl_handle; dl_error: diff --git a/app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c b/app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c index 43cc3a5790..d722b7a6c3 100644 --- a/app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c +++ b/app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c @@ -2,7 +2,6 @@ // Created by maks on 21.09.2022. // #include -#include #include #include "loader_dlopen.h" #include "osmesa_loader.h"