Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 0 additions & 19 deletions app_pojavlauncher/src/main/jni/ctxbridges/egl_loader.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
//
// Created by maks on 21.09.2022.
//
#include <stddef.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <string.h>
#include "egl_loader.h"
#include "global_state.h"
#include "loader_dlopen.h"
#include <androidnsbypass/nsbypass_t.h>
#include <androidnsbypass/nsbypass.h>

EGLBoolean (*eglMakeCurrent_p) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
EGLBoolean (*eglDestroyContext_p) (EGLDisplay dpy, EGLContext ctx);
Expand Down Expand Up @@ -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) {
Expand Down
36 changes: 34 additions & 2 deletions app_pojavlauncher/src/main/jni/ctxbridges/loader_dlopen.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,53 @@
//
// Created by maks on 26.10.2024.
//
#include <string.h>
#include <stdio.h>
#include <dlfcn.h>
#include <linux/limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#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:
Expand Down
1 change: 0 additions & 1 deletion app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Created by maks on 21.09.2022.
//
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include "loader_dlopen.h"
#include "osmesa_loader.h"
Expand Down
Loading