1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdbool.h>
#include <assert.h>
#include <err.h>
#include <dlfcn.h>
#include "jvm/jni.h"
#include "linker/dlfcn.h"
#include "wrapper/verbose.h"
void
java_lang_System_load(JNIEnv *env, jobject object, va_list args)
{
assert(env && object);
const char *lib = (*env)->GetStringUTFChars(env, va_arg(args, jstring), NULL);
verbose("%s", lib);
void *handle;
if (!(handle = bionic_dlopen(lib, RTLD_NOW | RTLD_GLOBAL)))
return;
union {
void *ptr;
void* (*fun)(void*, void*);
} JNI_OnLoad;
if ((JNI_OnLoad.ptr = bionic_dlsym(handle, "JNI_OnLoad"))) {
JavaVM *vm;
(*env)->GetJavaVM(env, &vm);
JNI_OnLoad.fun(vm, NULL);
}
}
jclass
java_lang_Object_getClass(JNIEnv *env, jobject object, va_list args)
{
assert(env && object);
return (*env)->GetObjectClass(env, object);
}
jobject
java_lang_Class_getClassLoader(JNIEnv *env, jobject object, va_list args)
{
assert(env && object);
static jobject sv;
return (sv ? sv : (sv = (*env)->AllocObject(env, (*env)->FindClass(env, "java/lang/ClassLoader"))));
}
jobject
java_lang_ClassLoader_findLibrary(JNIEnv *env, jobject object, va_list args)
{
assert(env && object);
XXX
char lib[255];
snprintf(lib, sizeof(lib), "lib%s.so", (*env)->GetStringUTFChars(env, va_arg(args, jstring), NULL));
return (*env)->NewStringUTF(env, lib);
}
jstring
java_io_File_getPath(JNIEnv *env, jobject object, va_list args)
{
assert(env && object);
FIXME
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.miHoYo.bh3oversea/files");
}
|