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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.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)
{
assert(env && object);
return (*env)->GetObjectClass(env, object);
}
jobject
java_lang_Class_getClassLoader(JNIEnv *env, jobject object)
{
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
#if WOLF
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.swiftappskom.thewolfrpg/files");
#elif STARLIGHT
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/jp.co.bandainamcoent.BNEI0242/files");
#elif SHADOWVERSE
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.cygames.Shadowverse/files");
#elif HEARTHSTONE
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.blizzard.wtcg.hearthstone/files");
#else
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.miHoYo.bh3oversea/files");
#endif
}
jstring
java_io_File_getParent(JNIEnv *env, jobject object, va_list args)
{
#if WOLF
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.swiftappskom.thewolfrpg");
#elif STARLIGHT
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/jp.co.bandainamcoent.BNEI0242");
#elif SHADOWVERSE
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.cygames.Shadowverse");
#elif HEARTHSTONE
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.blizzard.wtcg.hearthstone");
#else
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.miHoYo.bh3oversea");
#endif
}
jboolean
java_lang_String_equals(JNIEnv *env, jobject object, va_list args)
{
assert(env && object);
jstring str = va_arg(args, jstring);
const char *utf1 = (*env)->GetStringUTFChars(env, object, NULL);
const char *utf2 = (*env)->GetStringUTFChars(env, str, NULL);
const jboolean equal = (utf1 == utf2 || (utf1 && utf2 && !strcmp(utf1, utf2)));
(*env)->ReleaseStringUTFChars(env, object, utf1);
(*env)->ReleaseStringUTFChars(env, str, utf2);
return equal;
}
jclass
java_lang_Class_forName(JNIEnv *env, jobject object, va_list args)
{
assert(env && object);
jstring str = va_arg(args, jstring);
const char *utf = (*env)->GetStringUTFChars(env, str, NULL);
return (*env)->FindClass(env, utf);
}
jstring
java_util_Locale_getLanguage(JNIEnv *env, jobject object)
{
assert(env && object);
return (*env)->NewStringUTF(env, "en");
}
jstring
java_util_Locale_getCountry(JNIEnv *env, jobject object)
{
assert(env && object);
return (*env)->NewStringUTF(env, "US");
}
#include "jvm/jvm.h"
#include <stdint.h>
jstring
java_lang_Class_getName(JNIEnv *env, jobject object)
{
assert(env && object);
const struct jvm *jvm = jnienv_get_jvm(env);
return (*env)->NewStringUTF(env, jvm->objects[(uintptr_t)object - 1].klass.name.data);
}
|