Skip to content

Commit

Permalink
Style[exec_hooks]: change function name, log lines, add clipboard con…
Browse files Browse the repository at this point in the history
…stants
  • Loading branch information
artdeell committed Jan 7, 2025
1 parent 1b3d5c6 commit 967bb9d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app_pojavlauncher/src/main/jni/input_bridge_v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jint JNI_OnLoad(JavaVM* vm, __attribute__((unused)) void* reserved) {
jobject mouseDownBufferJ = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticObjectField(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, field_mouseDownBuffer);
pojav_environ->mouseDownBuffer = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetDirectBufferAddress(pojav_environ->runtimeJNIEnvPtr_JRE, mouseDownBufferJ);
hookExec();
installLinkerBugMitigation();
installLwjglDlopenHook();
installEMUIIteratorMititgation();
}

Expand Down
2 changes: 1 addition & 1 deletion app_pojavlauncher/src/main/jni/java_exec_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static jint hooked_ProcessImpl_forkAndExec(JNIEnv *env, jobject process, jint mo

if(strcmp(prog_basename, "xdg-open") == 0) {
// When invoking xdg-open, send the open URL into Android
Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(env, NULL, /* CLIPBOARD_OPEN */ 2002, argBlock);
Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(env, NULL, CLIPBOARD_OPEN, argBlock);
return 0;
}else if(strcmp(prog_basename, "ffmpeg") == 0) {
// When invoking ffmpeg, always replace the program path with the path to ffmpeg from the plugin.
Expand Down
4 changes: 2 additions & 2 deletions app_pojavlauncher/src/main/jni/lwjgl_dlopen_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ static jlong ndlopen_bugfix(__attribute__((unused)) JNIEnv *env,
/**
* Install the LWJGL dlopen hook. This allows us to mitigate linker bugs and add custom library overrides.
*/
void installLinkerBugMitigation() {
__android_log_print(ANDROID_LOG_INFO, "LwjglLinkerHook", "API < 30 detected, installing linker bug mitigation");
void installLwjglDlopenHook() {
__android_log_print(ANDROID_LOG_INFO, "LwjglLinkerHook", "Installing LWJGL dlopen() hook");
JNIEnv* env = pojav_environ->runtimeJNIEnvPtr_JRE;
jclass dynamicLinkLoader = (*env)->FindClass(env, "org/lwjgl/system/linux/DynamicLinkLoader");
if(dynamicLinkLoader == NULL) {
Expand Down
6 changes: 4 additions & 2 deletions app_pojavlauncher/src/main/jni/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

#include <stdbool.h>


#define CLIPBOARD_COPY 2000
#define CLIPBOARD_PASTE 2001
#define CLIPBOARD_OPEN 2002

char** convert_to_char_array(JNIEnv *env, jobjectArray jstringArray);
jobjectArray convert_from_char_array(JNIEnv *env, char **charArray, int num_rows);
void free_char_array(JNIEnv *env, jobjectArray jstringArray, const char **charArray);
jstring convertStringJVM(JNIEnv* srcEnv, JNIEnv* dstEnv, jstring srcStr);

void hookExec();
void installLinkerBugMitigation();
void installLwjglDlopenHook();
void installEMUIIteratorMititgation();
JNIEXPORT jstring JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(JNIEnv* env, jclass clazz, jint action, jbyteArray copySrc);

0 comments on commit 967bb9d

Please sign in to comment.