openlink 1.13+(not finish)
This commit is contained in:
parent
d7d86dbe4e
commit
d3ad3cab2f
|
@ -331,8 +331,10 @@ LOCAL_MODULE := lwjgl
|
|||
LOCAL_STATIC_LIBRARIES := dyncall \
|
||||
dyncallback \
|
||||
dynload
|
||||
LOCAL_SHARED_LIBRARIES := byopen
|
||||
LOCAL_SRC_FILES := lwjgl3/common_tools.c \
|
||||
LOCAL_SHARED_LIBRARIES := byopen \
|
||||
fcl
|
||||
LOCAL_SRC_FILES := lwjgl3/fcl_hook.c \
|
||||
lwjgl3/common_tools.c \
|
||||
lwjgl3/org_lwjgl_opengl_AMDDebugOutput.c \
|
||||
lwjgl3/org_lwjgl_opengl_AMDDrawBuffersBlend.c \
|
||||
lwjgl3/org_lwjgl_opengl_AMDFramebufferMultisampleAdvanced.c \
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
static JavaVM* dalvikJavaVMPtr;
|
||||
|
||||
static JavaVM* runtimeJavaVMPtr;
|
||||
|
||||
jclass class_FCLBridge;
|
||||
jmethodID method_OpenLink;
|
||||
jmethodID method_OpenPath;
|
||||
|
@ -19,10 +17,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
|||
class_FCLBridge = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "com/tungsten/fclauncher/bridge/FCLBridge"));
|
||||
method_OpenLink = (*env)->GetStaticMethodID(env, class_FCLBridge, "openLink", "(Ljava/lang/String;)V");
|
||||
method_OpenPath = (*env)->GetStaticMethodID(env, class_FCLBridge, "openLink", "(Ljava/lang/String;)V");
|
||||
} else if (dalvikJavaVMPtr != vm) {
|
||||
runtimeJavaVMPtr = vm;
|
||||
}
|
||||
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#define FOLD_CRAFT_LAUNCHER_FCL_BRIDGE_H
|
||||
|
||||
#include <android/native_window.h>
|
||||
#include <fcl_event.h>
|
||||
#include "fcl_event.h"
|
||||
|
||||
ANativeWindow* fclGetNativeWindow(void);
|
||||
int fclWaitForEvent(int timeout);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "common_tools.h"
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include "fcl_hook.h"
|
||||
|
||||
JavaVM *jvm;
|
||||
|
||||
|
@ -184,7 +185,9 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
|||
UNUSED_PARAM(reserved)
|
||||
|
||||
jvm = vm;
|
||||
|
||||
JNIEnv *env = NULL;
|
||||
(*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_4);
|
||||
hookExec(env);
|
||||
envTLSInit();
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Created by mio on 2023/7/9.
|
||||
//
|
||||
|
||||
#include "fcl_hook.h"
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
#include "fcl/include/fcl_internal.h"
|
||||
|
||||
jint (*orig_ProcessImpl_forkAndExec)(JNIEnv *env, jobject process, jint mode, jbyteArray helperpath, jbyteArray prog, jbyteArray argBlock, jint argc, jbyteArray envBlock, jint envc, jbyteArray dir, jintArray std_fds, jboolean redirectErrorStream);
|
||||
|
||||
jint
|
||||
hooked_ProcessImpl_forkAndExec(JNIEnv *env, jobject process, jint mode, jbyteArray helperpath, jbyteArray prog, jbyteArray argBlock, jint argc, jbyteArray envBlock, jint envc, jbyteArray dir, jintArray std_fds, jboolean redirectErrorStream) {
|
||||
char *pProg = (char *)((*env)->GetByteArrayElements(env, prog, NULL));
|
||||
|
||||
if (strcmp(basename(pProg), "xdg-open") != 0) {
|
||||
(*env)->ReleaseByteArrayElements(env, prog, (jbyte *)pProg, 0);
|
||||
return orig_ProcessImpl_forkAndExec(env, process, mode, helperpath, prog, argBlock, argc, envBlock, envc, dir, std_fds, redirectErrorStream);
|
||||
}
|
||||
(*env)->ReleaseByteArrayElements(env, prog, (jbyte *)pProg, 0);
|
||||
|
||||
long len = (*env)->GetArrayLength(env,argBlock);
|
||||
unsigned char* cs[len];
|
||||
(*env)->GetByteArrayRegion(env,argBlock, 0, len, (jbyte *)cs);
|
||||
(*env)->DeleteLocalRef(env,argBlock);
|
||||
|
||||
FCL_INTERNAL_LOG("forkAndExec:%s",cs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hookExec(JNIEnv *env) {
|
||||
jclass cls;
|
||||
orig_ProcessImpl_forkAndExec = dlsym(RTLD_DEFAULT, "Java_java_lang_UNIXProcess_forkAndExec");
|
||||
if (!orig_ProcessImpl_forkAndExec) {
|
||||
orig_ProcessImpl_forkAndExec = dlsym(RTLD_DEFAULT, "Java_java_lang_ProcessImpl_forkAndExec");
|
||||
cls = (*env)->FindClass(env, "java/lang/ProcessImpl");
|
||||
} else {
|
||||
cls = (*env)->FindClass(env, "java/lang/UNIXProcess");
|
||||
}
|
||||
JNINativeMethod methods[] = {
|
||||
{"forkAndExec", "(I[B[B[BI[BI[B[IZ)I", (void *)&hooked_ProcessImpl_forkAndExec}
|
||||
};
|
||||
(*env)->RegisterNatives(env, cls, methods, 1);
|
||||
printf("Registered forkAndExec\n");
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// Created by mio on 2023/7/9.
|
||||
//
|
||||
|
||||
#ifndef FOLD_CRAFT_LAUNCHER_FCL_HOOK_H
|
||||
#define FOLD_CRAFT_LAUNCHER_FCL_HOOK_H
|
||||
|
||||
#include <jni.h>
|
||||
void hookExec(JNIEnv *env);
|
||||
|
||||
|
||||
#endif //FOLD_CRAFT_LAUNCHER_FCL_HOOK_H
|
Loading…
Reference in New Issue