@zsa233/frida-analykit-agent 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/android.d.ts +41 -0
- package/dist/api/android.js +1 -0
- package/dist/bridges.d.ts +4 -0
- package/dist/bridges.js +8 -0
- package/dist/cmodule/scan_adrp.d.ts +9 -0
- package/{src/cmodule/scan_adrp.ts → dist/cmodule/scan_adrp.js} +19 -30
- package/dist/config.d.ts +26 -0
- package/dist/config.js +27 -0
- package/dist/consts.d.ts +18 -0
- package/dist/consts.js +23 -0
- package/dist/elf/insn.d.ts +10 -0
- package/dist/elf/insn.js +43 -0
- package/dist/elf/module.d.ts +95 -0
- package/dist/elf/module.js +632 -0
- package/dist/elf/struct.d.ts +235 -0
- package/{src/elf/struct.ts → dist/elf/struct.js} +63 -149
- package/dist/elf/tools.d.ts +6 -0
- package/dist/elf/tools.js +25 -0
- package/dist/elf/verifier.d.ts +11 -0
- package/dist/elf/verifier.js +57 -0
- package/dist/elf/xref.d.ts +32 -0
- package/dist/elf/xref.js +271 -0
- package/dist/func.d.ts +7 -0
- package/dist/func.js +23 -0
- package/dist/helper.d.ts +130 -0
- package/dist/helper.js +527 -0
- package/{src/index.ts → dist/index.d.ts} +0 -1
- package/dist/index.js +9 -0
- package/dist/jni/env.d.ts +821 -0
- package/dist/jni/env.js +1054 -0
- package/{src/jni/struct.ts → dist/jni/struct.d.ts} +8 -54
- package/dist/jni/struct.js +173 -0
- package/dist/lib/libc.d.ts +68 -0
- package/dist/lib/libc.js +125 -0
- package/dist/lib/libssl.d.ts +23 -0
- package/dist/lib/libssl.js +60 -0
- package/dist/message.d.ts +18 -0
- package/dist/message.js +21 -0
- package/dist/net/ssl.d.ts +29 -0
- package/dist/net/ssl.js +249 -0
- package/dist/net/struct.d.ts +34 -0
- package/{src/net/struct.ts → dist/net/struct.js} +4 -18
- package/dist/net/tools.js +1 -0
- package/dist/process.d.ts +43 -0
- package/dist/process.js +77 -0
- package/dist/rpc.d.ts +1 -0
- package/dist/rpc.js +248 -0
- package/dist/utils/array_pointer.d.ts +21 -0
- package/dist/utils/array_pointer.js +81 -0
- package/dist/utils/queue.d.ts +19 -0
- package/dist/utils/queue.js +89 -0
- package/dist/utils/scan.d.ts +35 -0
- package/dist/utils/scan.js +72 -0
- package/dist/utils/std.d.ts +40 -0
- package/dist/utils/std.js +128 -0
- package/dist/utils/text_endec.d.ts +8 -0
- package/dist/utils/text_endec.js +29 -0
- package/dist/utils/utils.d.ts +28 -0
- package/dist/utils/utils.js +66 -0
- package/package.json +18 -5
- package/src/api/android.ts +0 -80
- package/src/bridges.ts +0 -18
- package/src/cmodule/scan_adrp.c +0 -81
- package/src/config.ts +0 -56
- package/src/consts.ts +0 -31
- package/src/elf/insn.ts +0 -61
- package/src/elf/module.ts +0 -751
- package/src/elf/tools.ts +0 -33
- package/src/elf/verifier.ts +0 -74
- package/src/elf/xref.ts +0 -360
- package/src/func.ts +0 -32
- package/src/helper.ts +0 -685
- package/src/jni/env.ts +0 -1439
- package/src/lib/libc.ts +0 -161
- package/src/lib/libssl.ts +0 -95
- package/src/message.ts +0 -26
- package/src/net/ssl.ts +0 -360
- package/src/process.ts +0 -137
- package/src/rpc.ts +0 -268
- package/src/runtime-globals.d.ts +0 -11
- package/src/utils/array_pointer.ts +0 -102
- package/src/utils/queue.ts +0 -102
- package/src/utils/scan.ts +0 -103
- package/src/utils/std.ts +0 -165
- package/src/utils/text_endec.ts +0 -35
- package/src/utils/utils.ts +0 -111
- /package/{src/net/tools.ts → dist/net/tools.d.ts} +0 -0
package/dist/jni/env.js
ADDED
|
@@ -0,0 +1,1054 @@
|
|
|
1
|
+
import { Java } from "../bridges.js";
|
|
2
|
+
import { IndirectRefKind, JNI_VT } from "./struct.js";
|
|
3
|
+
import { nativeFunctionOptions } from '../consts.js';
|
|
4
|
+
import { help, NativePointerObject } from "../helper.js";
|
|
5
|
+
import { setGlobalProperties } from '../config.js';
|
|
6
|
+
function getThreadFromEnv(env) {
|
|
7
|
+
return env.handle.add(Process.pointerSize).readPointer();
|
|
8
|
+
}
|
|
9
|
+
class MirrorObject extends NativePointerObject {
|
|
10
|
+
constructor(handle) {
|
|
11
|
+
super(handle);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class jobject extends NativePointerObject {
|
|
15
|
+
constructor(handle, { parent = null, isStatic = parent?._isStatic || false, } = {}) {
|
|
16
|
+
super(handle);
|
|
17
|
+
this._isStatic = false;
|
|
18
|
+
this._deleted = false;
|
|
19
|
+
this._parent = parent;
|
|
20
|
+
this._isStatic = isStatic;
|
|
21
|
+
}
|
|
22
|
+
$unwrap() {
|
|
23
|
+
return {
|
|
24
|
+
isStatic: this._isStatic,
|
|
25
|
+
parent: this._parent,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
$toString() {
|
|
29
|
+
const result = JNIEnv.CallObjectMethod(this, JNIEnv.javaLangObject().toString);
|
|
30
|
+
const utf16 = result.$jstring.toUTF16String();
|
|
31
|
+
const str = utf16.toString();
|
|
32
|
+
utf16.release();
|
|
33
|
+
result.$unref();
|
|
34
|
+
return str;
|
|
35
|
+
}
|
|
36
|
+
get $IndirectRefKind() {
|
|
37
|
+
return Number(this._handle.and(JniEnv.kKindMask));
|
|
38
|
+
}
|
|
39
|
+
$bind(kws) {
|
|
40
|
+
const opt = { ...this.$unwrap(), ...kws };
|
|
41
|
+
return new this.constructor(this._handle, opt);
|
|
42
|
+
}
|
|
43
|
+
get $class() {
|
|
44
|
+
if (this._class !== undefined) {
|
|
45
|
+
return this._class;
|
|
46
|
+
}
|
|
47
|
+
const cls = JNIEnv.GetObjectClass(this._handle).$globalRef().$jclass.$bind({ parent: this, isStatic: this._isStatic });
|
|
48
|
+
this._class = cls;
|
|
49
|
+
return cls;
|
|
50
|
+
}
|
|
51
|
+
$method(name, sig) {
|
|
52
|
+
return JNIEnv.GetMethodID(this.$class, name, sig);
|
|
53
|
+
}
|
|
54
|
+
$methodID(methodId) {
|
|
55
|
+
return JNIEnv.ToReflectedMethod(this.$class, methodId, this._isStatic).$bind({ parent: this });
|
|
56
|
+
}
|
|
57
|
+
$getName() {
|
|
58
|
+
const handle = this;
|
|
59
|
+
const javaLang = this._parent === null ? JNIEnv.javaLangClass() : JNIEnv.javaLangReflectMethod();
|
|
60
|
+
const result = JNIEnv.CallObjectMethod(handle, javaLang.getName);
|
|
61
|
+
const utf16 = result.$jstring.toUTF16String();
|
|
62
|
+
const str = utf16.toString();
|
|
63
|
+
utf16.release();
|
|
64
|
+
result.$unref();
|
|
65
|
+
return str;
|
|
66
|
+
}
|
|
67
|
+
get $jstring() { return new jstring(this.$handle, this.$unwrap()); }
|
|
68
|
+
get $jobject() { return new jobject(this.$handle, this.$unwrap()); }
|
|
69
|
+
get $jclass() { return new jclass(this.$handle, this.$unwrap()); }
|
|
70
|
+
get $jint() { return new jint(this.$handle); }
|
|
71
|
+
get $jfloat() { return new jfloat(this.$handle); }
|
|
72
|
+
get $jdouble() { return new jdouble(this.$handle); }
|
|
73
|
+
get $jbyte() { return new jbyte(this.$handle); }
|
|
74
|
+
get $jchar() { return new jchar(this.$handle); }
|
|
75
|
+
get $jlong() { return new jlong(this.$handle); }
|
|
76
|
+
get $jshort() { return new jshort(this.$handle); }
|
|
77
|
+
get $jboolean() { return new jboolean(this.$handle); }
|
|
78
|
+
get $jobjectArray() { return new jobjectArray(this.$handle); }
|
|
79
|
+
$decode(thread = null) {
|
|
80
|
+
return JNIEnv.DecodeJObject(thread, this);
|
|
81
|
+
}
|
|
82
|
+
$unref() {
|
|
83
|
+
if (this._deleted) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
this._deleted = true;
|
|
87
|
+
switch (this.$IndirectRefKind) {
|
|
88
|
+
case IndirectRefKind.kHandleScopeOrInvalid:
|
|
89
|
+
case IndirectRefKind.kLocal:
|
|
90
|
+
JNIEnv.DeleteLocalRef(this);
|
|
91
|
+
break;
|
|
92
|
+
case IndirectRefKind.kGlobal:
|
|
93
|
+
JNIEnv.DeleteGlobalRef(this);
|
|
94
|
+
break;
|
|
95
|
+
case IndirectRefKind.kWeakGlobal:
|
|
96
|
+
JNIEnv.DeleteWeakGlobalRef(this);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
$globalRef() {
|
|
101
|
+
if (this.$IndirectRefKind === IndirectRefKind.kGlobal) {
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
const glo = JNIEnv.NewGlobalRef(this);
|
|
105
|
+
const handle = ptr(glo.$handle.toString());
|
|
106
|
+
Script.bindWeak(glo.$handle, () => {
|
|
107
|
+
JNIEnv.DeleteGlobalRef(handle);
|
|
108
|
+
});
|
|
109
|
+
this.$unref();
|
|
110
|
+
return glo;
|
|
111
|
+
}
|
|
112
|
+
toString() {
|
|
113
|
+
return `<jobject: ${this.$handle}>[${this.$IndirectRefKind}]`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export class jmethod extends jobject {
|
|
117
|
+
constructor(handle, opt = {}) {
|
|
118
|
+
if (!('parent' in opt)) {
|
|
119
|
+
opt.parent = new jobject(NULL);
|
|
120
|
+
}
|
|
121
|
+
super(handle, opt);
|
|
122
|
+
}
|
|
123
|
+
toString() {
|
|
124
|
+
return `<jmethod: ${this.$handle}>[${this.$IndirectRefKind}]`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export class jclass extends jobject {
|
|
128
|
+
constructor(handle, { isStatic = false } = {}) {
|
|
129
|
+
super(handle, { isStatic });
|
|
130
|
+
}
|
|
131
|
+
toString() {
|
|
132
|
+
return `<jclass: ${this.$handle}>[${this.$IndirectRefKind}]`;
|
|
133
|
+
}
|
|
134
|
+
$methodID(methodId) {
|
|
135
|
+
return JNIEnv.ToReflectedMethod(this, methodId, this._isStatic).$bind({ parent: this });
|
|
136
|
+
}
|
|
137
|
+
$method(name, sig) {
|
|
138
|
+
return JNIEnv.GetMethodID(this, name, sig);
|
|
139
|
+
}
|
|
140
|
+
$toString() {
|
|
141
|
+
const isExcept = JNIEnv.ExceptionCheck();
|
|
142
|
+
if (isExcept) {
|
|
143
|
+
return '';
|
|
144
|
+
}
|
|
145
|
+
if (this.$handle.isNull() || JNIEnv.IsSameObject(this, NULL)) {
|
|
146
|
+
return '';
|
|
147
|
+
}
|
|
148
|
+
const result = JNIEnv.CallObjectMethod(this, JNIEnv.javaLangObject().toString);
|
|
149
|
+
const utf16 = result.$jstring.toUTF16String();
|
|
150
|
+
const str = utf16.toString();
|
|
151
|
+
utf16.release();
|
|
152
|
+
result.$unref();
|
|
153
|
+
return str;
|
|
154
|
+
}
|
|
155
|
+
$getName() {
|
|
156
|
+
const handle = this._parent ? this._parent : this;
|
|
157
|
+
const javaLang = JNIEnv.javaLangClass();
|
|
158
|
+
const result = JNIEnv.CallObjectMethod(handle, javaLang.getName);
|
|
159
|
+
const utf16 = result.$jstring.toUTF16String();
|
|
160
|
+
const str = utf16.toString();
|
|
161
|
+
utf16.release();
|
|
162
|
+
result.$unref();
|
|
163
|
+
return str;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export class jstring extends jobject {
|
|
167
|
+
toString() {
|
|
168
|
+
if (this.$handle.isNull() || this._str !== undefined) {
|
|
169
|
+
return this._str || '';
|
|
170
|
+
}
|
|
171
|
+
const utf16 = this.toUTF16String();
|
|
172
|
+
const str = utf16.toString();
|
|
173
|
+
this._str = str;
|
|
174
|
+
return str;
|
|
175
|
+
}
|
|
176
|
+
[Symbol.toPrimitive](hint) {
|
|
177
|
+
if (hint === "string") {
|
|
178
|
+
return `<jstring: ${this.$handle}>[${this.$IndirectRefKind}]`;
|
|
179
|
+
}
|
|
180
|
+
return "default";
|
|
181
|
+
}
|
|
182
|
+
toUTF16String() {
|
|
183
|
+
return new UTF16JString(this);
|
|
184
|
+
}
|
|
185
|
+
toUTF8String() {
|
|
186
|
+
return new UTF8JString(this);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
export class jmethodID extends jobject {
|
|
190
|
+
$getName() {
|
|
191
|
+
const handle = this._parent;
|
|
192
|
+
const javaLang = JNIEnv.javaLangReflectMethod();
|
|
193
|
+
const result = JNIEnv.CallObjectMethod(handle, javaLang.getName);
|
|
194
|
+
const utf16 = result.$jstring.toUTF16String();
|
|
195
|
+
const str = utf16.toString();
|
|
196
|
+
utf16.release();
|
|
197
|
+
result.$unref();
|
|
198
|
+
return str;
|
|
199
|
+
}
|
|
200
|
+
toString() { return `<jmethodID: ${this.$handle}>[${this.$IndirectRefKind}]`; }
|
|
201
|
+
}
|
|
202
|
+
export class jboolean extends NativePointerObject {
|
|
203
|
+
toBool() {
|
|
204
|
+
return this._handle.toInt32() !== 0;
|
|
205
|
+
}
|
|
206
|
+
toString() { return `<jboolean: ${this.$handle}>`; }
|
|
207
|
+
}
|
|
208
|
+
export class jbyte extends NativePointerObject {
|
|
209
|
+
toByte() {
|
|
210
|
+
return this._handle.toInt32();
|
|
211
|
+
}
|
|
212
|
+
toString() { return `<jbyte: ${this.$handle}>`; }
|
|
213
|
+
}
|
|
214
|
+
export class jchar extends NativePointerObject {
|
|
215
|
+
toChar() {
|
|
216
|
+
return this._handle.toInt32();
|
|
217
|
+
}
|
|
218
|
+
toString() { return `<jchar: ${this.$handle}>`; }
|
|
219
|
+
}
|
|
220
|
+
export class jdouble extends NativePointerObject {
|
|
221
|
+
toDouble() {
|
|
222
|
+
return Number(this._handle);
|
|
223
|
+
}
|
|
224
|
+
toString() { return `<jdouble: ${this.$handle}>`; }
|
|
225
|
+
}
|
|
226
|
+
export class jfloat extends NativePointerObject {
|
|
227
|
+
toFloat() {
|
|
228
|
+
return Number(this._handle);
|
|
229
|
+
}
|
|
230
|
+
toString() { return `<jfloat: ${this.$handle}>`; }
|
|
231
|
+
}
|
|
232
|
+
export class jint extends NativePointerObject {
|
|
233
|
+
toInt() {
|
|
234
|
+
return Number(this._handle);
|
|
235
|
+
}
|
|
236
|
+
toString() { return `<jint: ${this.$handle}>`; }
|
|
237
|
+
}
|
|
238
|
+
export class jlong extends NativePointerObject {
|
|
239
|
+
toLong() {
|
|
240
|
+
return Number(this._handle);
|
|
241
|
+
}
|
|
242
|
+
toString() { return `<jlong: ${this.$handle}>`; }
|
|
243
|
+
}
|
|
244
|
+
export class jshort extends NativePointerObject {
|
|
245
|
+
toShort() {
|
|
246
|
+
return Number(this._handle);
|
|
247
|
+
}
|
|
248
|
+
toString() { return `<jshort: ${this.$handle}>`; }
|
|
249
|
+
}
|
|
250
|
+
export class jvoid extends NativePointerObject {
|
|
251
|
+
toString() { return `<jvoid: ${this.$handle}>`; }
|
|
252
|
+
}
|
|
253
|
+
export class jthrowable extends jobject {
|
|
254
|
+
toString() { return `<jthrowable: ${this.$handle}>`; }
|
|
255
|
+
}
|
|
256
|
+
export class jvalue {
|
|
257
|
+
constructor(handle) {
|
|
258
|
+
this._handle = handle;
|
|
259
|
+
}
|
|
260
|
+
$index(offset) {
|
|
261
|
+
return this._handle.add(offset * Process.pointerSize).readPointer();
|
|
262
|
+
}
|
|
263
|
+
jobject(offset) {
|
|
264
|
+
return new jobject(this.$index(offset));
|
|
265
|
+
}
|
|
266
|
+
jstring(offset) {
|
|
267
|
+
return new jstring(this.$index(offset));
|
|
268
|
+
}
|
|
269
|
+
toString() { return `<jvalue: ${this._handle}>`; }
|
|
270
|
+
}
|
|
271
|
+
export class jarray extends NativePointerObject {
|
|
272
|
+
constructor(handle) {
|
|
273
|
+
super(handle);
|
|
274
|
+
this._pointerSize = Process.pointerSize;
|
|
275
|
+
}
|
|
276
|
+
$index(index) {
|
|
277
|
+
return new this._wrapper(this._handle.add(index * this._pointerSize).readPointer());
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
export class jobjectArray extends jarray {
|
|
281
|
+
constructor() {
|
|
282
|
+
super(...arguments);
|
|
283
|
+
this._wrapper = jobject;
|
|
284
|
+
}
|
|
285
|
+
$index(index) {
|
|
286
|
+
return JNIEnv.GetObjectArrayElement(this.$handle, index);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
export class jbooleanArray extends jarray {
|
|
290
|
+
constructor() {
|
|
291
|
+
super(...arguments);
|
|
292
|
+
this._pointerSize = 1;
|
|
293
|
+
this._wrapper = jboolean;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
export class jbyteArray extends jarray {
|
|
297
|
+
constructor() {
|
|
298
|
+
super(...arguments);
|
|
299
|
+
this._pointerSize = 1;
|
|
300
|
+
this._wrapper = jbyte;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
export class jcharArray extends jarray {
|
|
304
|
+
constructor() {
|
|
305
|
+
super(...arguments);
|
|
306
|
+
this._pointerSize = 2;
|
|
307
|
+
this._wrapper = jchar;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
export class jdoubleArray extends jarray {
|
|
311
|
+
constructor() {
|
|
312
|
+
super(...arguments);
|
|
313
|
+
this._pointerSize = 8;
|
|
314
|
+
this._wrapper = jdouble;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
export class jfloatArray extends jarray {
|
|
318
|
+
constructor() {
|
|
319
|
+
super(...arguments);
|
|
320
|
+
this._pointerSize = 4;
|
|
321
|
+
this._wrapper = jfloat;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
export class jintArray extends jarray {
|
|
325
|
+
constructor() {
|
|
326
|
+
super(...arguments);
|
|
327
|
+
this._pointerSize = 4;
|
|
328
|
+
this._wrapper = jint;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
export class jlongArray extends jarray {
|
|
332
|
+
constructor() {
|
|
333
|
+
super(...arguments);
|
|
334
|
+
this._pointerSize = 8;
|
|
335
|
+
this._wrapper = jlong;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
export class jshortArray extends jarray {
|
|
339
|
+
constructor() {
|
|
340
|
+
super(...arguments);
|
|
341
|
+
this._pointerSize = 2;
|
|
342
|
+
this._wrapper = jshort;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
export function unwrapJvalueArgs(args, n) {
|
|
346
|
+
const list = [];
|
|
347
|
+
for (let i = 0; i < n; i++) {
|
|
348
|
+
list.push(args.$index(i));
|
|
349
|
+
}
|
|
350
|
+
return list;
|
|
351
|
+
}
|
|
352
|
+
// utf16
|
|
353
|
+
class UTF16JString {
|
|
354
|
+
constructor(jstr) {
|
|
355
|
+
this._length = null;
|
|
356
|
+
this._str = null;
|
|
357
|
+
this._cstrPtr = NULL;
|
|
358
|
+
this._released = false;
|
|
359
|
+
this.$getString = JNIEnv.GetStringChars;
|
|
360
|
+
this.$readString = (p, len) => p.readUtf16String(len);
|
|
361
|
+
this.$releaser = JNIEnv.ReleaseStringChars;
|
|
362
|
+
this._jstr = jstr;
|
|
363
|
+
}
|
|
364
|
+
get $length() {
|
|
365
|
+
return this._length !== null ? this._length : (this._length = JNIEnv.GetStringLength(this._jstr).toInt());
|
|
366
|
+
}
|
|
367
|
+
toString() {
|
|
368
|
+
if (this._str !== null) {
|
|
369
|
+
return this._str;
|
|
370
|
+
}
|
|
371
|
+
const cstr = this.$getString(this._jstr);
|
|
372
|
+
this._cstrPtr = cstr;
|
|
373
|
+
this._str = this.$readString(cstr, this.$length);
|
|
374
|
+
return this._str || '';
|
|
375
|
+
}
|
|
376
|
+
isNull() {
|
|
377
|
+
return this._jstr?.$handle.isNull();
|
|
378
|
+
}
|
|
379
|
+
release() {
|
|
380
|
+
if (this._cstrPtr.isNull()) {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
return this._released ? true : (this._released = true,
|
|
384
|
+
this.$releaser(this._jstr, this._cstrPtr),
|
|
385
|
+
true);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
// utf8
|
|
389
|
+
class UTF8JString extends UTF16JString {
|
|
390
|
+
constructor() {
|
|
391
|
+
super(...arguments);
|
|
392
|
+
this.$getString = JNIEnv.GetStringUTFChars;
|
|
393
|
+
this.$readString = (p, len) => p.readUtf8String(len);
|
|
394
|
+
this.$releaser = JNIEnv.ReleaseStringUTFChars;
|
|
395
|
+
}
|
|
396
|
+
get $length() {
|
|
397
|
+
return this._length !== null ? this._length : (this._length = JNIEnv.GetStringUTFLength(this._jstr).toInt());
|
|
398
|
+
}
|
|
399
|
+
toString() {
|
|
400
|
+
return (this._str !== null ? this._str : (this._str = this._jstr.$handle.readUtf16String(this.$length))) || '';
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function CLZ(val) {
|
|
404
|
+
val = val >>> 0;
|
|
405
|
+
return val === 0 ? 32 : 32 - val.toString(2).length;
|
|
406
|
+
}
|
|
407
|
+
function MinimumBitsToStore(value) {
|
|
408
|
+
return (value === 0 ? -1 : (32 - 1 - CLZ(value))) + 1;
|
|
409
|
+
}
|
|
410
|
+
function proxyCallMethod(env, offMethod, constructor = null, { retType = 'pointer', argTypes = ['pointer', 'pointer', 'pointer', 'pointer'] } = {}) {
|
|
411
|
+
const method = function (impl, ...args) {
|
|
412
|
+
return impl(this.handle, ...args);
|
|
413
|
+
};
|
|
414
|
+
return env.$proxy(method, retType, argTypes, offMethod, constructor);
|
|
415
|
+
}
|
|
416
|
+
function proxyCallNonvirtualMethod(env, offMethod, constructor = null, { retType = 'pointer', argTypes = ['pointer', 'pointer', 'pointer', 'pointer', 'pointer'] } = {}) {
|
|
417
|
+
return proxyCallMethod(env, offMethod, constructor, { retType, argTypes });
|
|
418
|
+
}
|
|
419
|
+
const callMethodVariadicArgTypes = ['pointer', 'pointer', 'pointer', '...', 'pointer'];
|
|
420
|
+
const callNonvirtualMethodVariadictArgTypes = ['pointer', 'pointer', 'pointer', 'pointer', '...', 'pointer'];
|
|
421
|
+
class JniEnvBase {
|
|
422
|
+
constructor(vm) {
|
|
423
|
+
this._vm = vm;
|
|
424
|
+
}
|
|
425
|
+
get $env() {
|
|
426
|
+
return this.$vm.getEnv();
|
|
427
|
+
}
|
|
428
|
+
get $vm() {
|
|
429
|
+
return this._vm ? this._vm : Java.vm;
|
|
430
|
+
}
|
|
431
|
+
// JNIEnvExt::
|
|
432
|
+
// [0] *JNINativeInterface
|
|
433
|
+
// [1] Thread * self_
|
|
434
|
+
get $thread() {
|
|
435
|
+
return this.$env.handle.add(JniEnvBase.ptrSize).readPointer();
|
|
436
|
+
}
|
|
437
|
+
$proxy(wrapFunc, retType, argTypes, index, constructor = null, optBuilder) {
|
|
438
|
+
let cache = null;
|
|
439
|
+
const getCache = () => {
|
|
440
|
+
const env = this.$env;
|
|
441
|
+
if (cache === null) {
|
|
442
|
+
const p = env.handle.readPointer();
|
|
443
|
+
const handle = p.add(index * JniEnvBase.ptrSize).readPointer();
|
|
444
|
+
const impl = new NativeFunction(handle, retType, argTypes, nativeFunctionOptions);
|
|
445
|
+
cache = {
|
|
446
|
+
handle: handle,
|
|
447
|
+
impl: impl,
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
return cache;
|
|
451
|
+
};
|
|
452
|
+
const func = (...args) => {
|
|
453
|
+
const env = this.$env;
|
|
454
|
+
const cache = getCache();
|
|
455
|
+
const result = wrapFunc.apply(env, [cache.impl, ...args.map(v => v instanceof NativePointerObject ? v.$handle : v)]);
|
|
456
|
+
if (constructor === null) {
|
|
457
|
+
return result;
|
|
458
|
+
}
|
|
459
|
+
let opt = {};
|
|
460
|
+
if (optBuilder) {
|
|
461
|
+
opt = optBuilder(...args);
|
|
462
|
+
}
|
|
463
|
+
return new constructor(result, opt);
|
|
464
|
+
};
|
|
465
|
+
Object.defineProperty(func, '$handle', {
|
|
466
|
+
get: function () {
|
|
467
|
+
return getCache()?.handle;
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
return func;
|
|
471
|
+
}
|
|
472
|
+
$symbol(wrapFunc, retType, argTypes, symbol, constructor = null) {
|
|
473
|
+
let cache = null;
|
|
474
|
+
const getCache = () => {
|
|
475
|
+
if (cache === null) {
|
|
476
|
+
const find = Java.api.find || ((name) => {
|
|
477
|
+
const module = Java.api.module;
|
|
478
|
+
let address = module.findExportByName(name);
|
|
479
|
+
if (address === null) {
|
|
480
|
+
address = module.findSymbolByName(name);
|
|
481
|
+
}
|
|
482
|
+
return address;
|
|
483
|
+
});
|
|
484
|
+
const handle = find(symbol);
|
|
485
|
+
if (!handle) {
|
|
486
|
+
throw `symbol[${symbol}] 不存在于 art/dalvik so中`;
|
|
487
|
+
}
|
|
488
|
+
const impl = new NativeFunction(handle, retType, argTypes, nativeFunctionOptions);
|
|
489
|
+
cache = {
|
|
490
|
+
handle: handle,
|
|
491
|
+
impl: impl,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
return cache;
|
|
495
|
+
};
|
|
496
|
+
const func = (...args) => {
|
|
497
|
+
const env = this.$env;
|
|
498
|
+
const cache = getCache();
|
|
499
|
+
const result = wrapFunc.apply(env, [cache.impl, ...args.map(v => v instanceof NativePointerObject ? v.$handle : v)]);
|
|
500
|
+
if (constructor === null) {
|
|
501
|
+
return result;
|
|
502
|
+
}
|
|
503
|
+
return new constructor(result);
|
|
504
|
+
};
|
|
505
|
+
Object.defineProperty(func, '$handle', {
|
|
506
|
+
get: function () {
|
|
507
|
+
return getCache()?.handle;
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
return func;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
JniEnvBase.cacheClass = {};
|
|
514
|
+
JniEnvBase.ptrSize = Process.pointerSize;
|
|
515
|
+
JniEnvBase.kKindBits = MinimumBitsToStore(IndirectRefKind.kLastKind);
|
|
516
|
+
JniEnvBase.kKindMask = (1 << JniEnvBase.kKindBits) - 1;
|
|
517
|
+
class JniEnvCaller extends JniEnvBase {
|
|
518
|
+
constructor(vm) {
|
|
519
|
+
super(vm);
|
|
520
|
+
// jobject CallObjectMethod(JNIEnv* env, jobject obj, jmethodID mid, ...)
|
|
521
|
+
this.CallObjectMethod = proxyCallMethod(this, JNI_VT.CallObjectMethod, jobject, { argTypes: callMethodVariadicArgTypes });
|
|
522
|
+
// jobject CallObjectMethodV(JNIEnv* env, jobject obj, jmethodID mid, va_list args)
|
|
523
|
+
this.CallObjectMethodV = proxyCallMethod(this, JNI_VT.CallObjectMethodV, jobject);
|
|
524
|
+
// jobject CallObjectMethodA(JNIEnv* env, jobject obj, jmethodID mid, const jvalue* args)
|
|
525
|
+
this.CallObjectMethodA = proxyCallMethod(this, JNI_VT.CallObjectMethodA, jobject);
|
|
526
|
+
// jboolean CallBooleanMethod(JNIEnv* env, jobject obj, jmethodID mid, ...)
|
|
527
|
+
this.CallBooleanMethod = proxyCallMethod(this, JNI_VT.CallBooleanMethod, jboolean, { argTypes: callMethodVariadicArgTypes });
|
|
528
|
+
// jboolean CallBooleanMethodV(JNIEnv* env, jobject obj, jmethodID mid, va_list args)
|
|
529
|
+
this.CallBooleanMethodV = proxyCallMethod(this, JNI_VT.CallBooleanMethodV, jboolean);
|
|
530
|
+
// jboolean CallBooleanMethodA(JNIEnv* env, jobject obj, jmethodID mid, const jvalue* args)
|
|
531
|
+
this.CallBooleanMethodA = proxyCallMethod(this, JNI_VT.CallBooleanMethodA, jboolean);
|
|
532
|
+
// jbyte CallByteMethod(JNIEnv* env, jobject obj, jmethodID mid, ...)
|
|
533
|
+
this.CallByteMethod = proxyCallMethod(this, JNI_VT.CallBooleanMethod, jbyte, { argTypes: callMethodVariadicArgTypes });
|
|
534
|
+
// jbyte CallByteMethodV(JNIEnv* env, jobject obj, jmethodID mid, va_list args)
|
|
535
|
+
this.CallByteMethodV = proxyCallMethod(this, JNI_VT.CallByteMethodV, jbyte);
|
|
536
|
+
// jbyte CallByteMethodA(JNIEnv* env, jobject obj, jmethodID mid, const jvalue* args)
|
|
537
|
+
this.CallByteMethodA = proxyCallMethod(this, JNI_VT.CallByteMethodA, jbyte);
|
|
538
|
+
// jchar CallCharMethod(JNIEnv* env, jobject obj, jmethodID mid, ...)
|
|
539
|
+
this.CallCharMethod = proxyCallMethod(this, JNI_VT.CallCharMethod, jchar, { argTypes: callMethodVariadicArgTypes });
|
|
540
|
+
// jchar CallCharMethodV(JNIEnv* env, jobject obj, jmethodID mid, va_list args)
|
|
541
|
+
this.CallCharMethodV = proxyCallMethod(this, JNI_VT.CallCharMethodV, jchar);
|
|
542
|
+
// jchar CallCharMethodA(JNIEnv* env, jobject obj, jmethodID mid, const jvalue* args)
|
|
543
|
+
this.CallCharMethodA = proxyCallMethod(this, JNI_VT.CallCharMethodA, jchar);
|
|
544
|
+
// jshort CallShortMethod(JNIEnv* env, jobject obj, jmethodID mid, ...)
|
|
545
|
+
this.CallShortMethod = proxyCallMethod(this, JNI_VT.CallShortMethod, jshort, { argTypes: callMethodVariadicArgTypes });
|
|
546
|
+
// jshort CallShortMethodV(JNIEnv* env, jobject obj, jmethodID mid, va_list args)
|
|
547
|
+
this.CallShortMethodV = proxyCallMethod(this, JNI_VT.CallShortMethodV, jshort);
|
|
548
|
+
// jshort CallShortMethodA(JNIEnv* env, jobject obj, jmethodID mid, const jvalue* args)
|
|
549
|
+
this.CallShortMethodA = proxyCallMethod(this, JNI_VT.CallShortMethodA, jshort);
|
|
550
|
+
// jint CallIntMethod(JNIEnv* env, jobject obj, jmethodID mid, ...)
|
|
551
|
+
this.CallIntMethod = proxyCallMethod(this, JNI_VT.CallIntMethod, jint, { argTypes: callMethodVariadicArgTypes });
|
|
552
|
+
// jint CallIntMethodV(JNIEnv* env, jobject obj, jmethodID mid, va_list args)
|
|
553
|
+
this.CallIntMethodV = proxyCallMethod(this, JNI_VT.CallIntMethodV, jint);
|
|
554
|
+
// jint CallIntMethodA(JNIEnv* env, jobject obj, jmethodID mid, const jvalue* args)
|
|
555
|
+
this.CallIntMethodA = proxyCallMethod(this, JNI_VT.CallIntMethodA, jint);
|
|
556
|
+
// jlong CallLongMethod(JNIEnv* env, jobject obj, jmethodID mid, ...)
|
|
557
|
+
this.CallLongMethod = proxyCallMethod(this, JNI_VT.CallLongMethod, jint, { argTypes: callMethodVariadicArgTypes });
|
|
558
|
+
// jlong CallLongMethodV(JNIEnv* env, jobject obj, jmethodID mid, va_list args)
|
|
559
|
+
this.CallLongMethodV = proxyCallMethod(this, JNI_VT.CallLongMethodV, jint);
|
|
560
|
+
// jlong CallLongMethodA(JNIEnv* env, jobject obj, jmethodID mid, const jvalue* args)
|
|
561
|
+
this.CallLongMethodA = proxyCallMethod(this, JNI_VT.CallLongMethodA, jint);
|
|
562
|
+
// jfloat CallFloatMethod(JNIEnv* env, jobject obj, jmethodID mid, ...)
|
|
563
|
+
this.CallFloatMethod = proxyCallMethod(this, JNI_VT.CallFloatMethod, jfloat, { argTypes: callMethodVariadicArgTypes });
|
|
564
|
+
// jfloat CallFloatMethodV(JNIEnv* env, jobject obj, jmethodID mid, va_list args)
|
|
565
|
+
this.CallFloatMethodV = proxyCallMethod(this, JNI_VT.CallFloatMethodV, jfloat);
|
|
566
|
+
// jfloat CallFloatMethodA(JNIEnv* env, jobject obj, jmethodID mid, const jvalue* args)
|
|
567
|
+
this.CallFloatMethodA = proxyCallMethod(this, JNI_VT.CallFloatMethodA, jfloat);
|
|
568
|
+
// jdouble CallDoubleMethod(JNIEnv* env, jobject obj, jmethodID mid, ...)
|
|
569
|
+
this.CallDoubleMethod = proxyCallMethod(this, JNI_VT.CallDoubleMethod, jdouble, { argTypes: callMethodVariadicArgTypes });
|
|
570
|
+
// jdouble CallDoubleMethodV(JNIEnv* env, jobject obj, jmethodID mid, va_list args)
|
|
571
|
+
this.CallDoubleMethodV = proxyCallMethod(this, JNI_VT.CallDoubleMethodV, jdouble);
|
|
572
|
+
// jdouble CallDoubleMethodA(JNIEnv* env, jobject obj, jmethodID mid, const jvalue* args)
|
|
573
|
+
this.CallDoubleMethodA = proxyCallMethod(this, JNI_VT.CallDoubleMethodA, jdouble);
|
|
574
|
+
// void CallVoidMethod(JNIEnv* env, jobject obj, jmethodID mid, ...)
|
|
575
|
+
this.CallVoidMethod = proxyCallMethod(this, JNI_VT.CallVoidMethod, jvoid, { argTypes: callMethodVariadicArgTypes });
|
|
576
|
+
// void CallVoidMethodV(JNIEnv* env, jobject obj, jmethodID mid, va_list args)
|
|
577
|
+
this.CallVoidMethodV = proxyCallMethod(this, JNI_VT.CallVoidMethodV, jvoid);
|
|
578
|
+
// void CallVoidMethodA(JNIEnv* env, jobject obj, jmethodID mid, const jvalue* args)
|
|
579
|
+
this.CallVoidMethodA = proxyCallMethod(this, JNI_VT.CallVoidMethodA, jvoid);
|
|
580
|
+
// jobject CallNonvirtualObjectMethod(JNIEnv* env, jobject obj, jclass, jmethodID mid, ...)
|
|
581
|
+
this.CallNonvirtualObjectMethod = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualObjectMethod, jobject, { argTypes: callNonvirtualMethodVariadictArgTypes });
|
|
582
|
+
// jobject CallNonvirtualObjectMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, va_list args)
|
|
583
|
+
this.CallNonvirtualObjectMethodV = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualObjectMethodV, jobject);
|
|
584
|
+
// jobject CallNonvirtualObjectMethodA(JNIEnv* env, jobject obj, jclass, jmethodID mid, const jvalue* args)
|
|
585
|
+
this.CallNonvirtualObjectMethodA = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualObjectMethodA, jobject);
|
|
586
|
+
// jboolean CallNonvirtualBooleanMethod(JNIEnv* env, jobject obj, jclass, jmethodID mid, ...)
|
|
587
|
+
this.CallNonvirtualBooleanMethod = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualBooleanMethod, jboolean, { argTypes: callNonvirtualMethodVariadictArgTypes });
|
|
588
|
+
// jboolean CallNonvirtualBooleanMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, va_list args)
|
|
589
|
+
this.CallNonvirtualBooleanMethodV = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualBooleanMethodV, jboolean);
|
|
590
|
+
// jboolean CallNonvirtualBooleanMethodA(JNIEnv* env, jobject obj, jclass, jmethodID mid, const jvalue* args)
|
|
591
|
+
this.CallNonvirtualBooleanMethodA = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualBooleanMethodA, jboolean);
|
|
592
|
+
// jbyte CallNonvirtualByteMethod(JNIEnv* env, jobject obj, jclass, jmethodID mid, ...)
|
|
593
|
+
this.CallNonvirtualByteMethod = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualByteMethod, jbyte, { argTypes: callNonvirtualMethodVariadictArgTypes });
|
|
594
|
+
// jbyte CallNonvirtualByteMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, va_list args)
|
|
595
|
+
this.CallNonvirtualByteMethodV = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualByteMethodV, jbyte);
|
|
596
|
+
// jbyte CallNonvirtualByteMethodA(JNIEnv* env, jobject obj, jclass, jmethodID mid, const jvalue* args)
|
|
597
|
+
this.CallNonvirtualByteMethodA = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualByteMethodA, jbyte);
|
|
598
|
+
// jchar CallNonvirtualCharMethod(JNIEnv* env, jobject obj, jclass, jmethodID mid, ...)
|
|
599
|
+
this.CallNonvirtualCharMethod = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualCharMethod, jchar, { argTypes: callNonvirtualMethodVariadictArgTypes });
|
|
600
|
+
// jchar CallNonvirtualCharMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, va_list args)
|
|
601
|
+
this.CallNonvirtualCharMethodV = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualCharMethodV, jchar);
|
|
602
|
+
// jchar CallNonvirtualCharMethodA(JNIEnv* env, jobject obj, jclass, jmethodID mid, const jvalue* args)
|
|
603
|
+
this.CallNonvirtualCharMethodA = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualCharMethodA, jchar);
|
|
604
|
+
// jshort CallNonvirtualShortMethod(JNIEnv* env, jobject obj, jclass, jmethodID mid, ...)
|
|
605
|
+
this.CallNonvirtualShortMethod = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualShortMethod, jshort, { argTypes: callNonvirtualMethodVariadictArgTypes });
|
|
606
|
+
// jshort CallNonvirtualShortMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, va_list args)
|
|
607
|
+
this.CallNonvirtualShortMethodV = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualShortMethodV, jshort);
|
|
608
|
+
// jshort CallNonvirtualShortMethodA(JNIEnv* env, jobject obj, jclass, jmethodID mid, const jvalue* args)
|
|
609
|
+
this.CallNonvirtualShortMethodA = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualShortMethodA, jshort);
|
|
610
|
+
// jint CallNonvirtualIntMethod(JNIEnv* env, jobject obj, jclass, jmethodID mid, ...)
|
|
611
|
+
this.CallNonvirtualIntMethod = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualIntMethod, jint, { argTypes: callNonvirtualMethodVariadictArgTypes });
|
|
612
|
+
// jint CallNonvirtualIntMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, va_list args)
|
|
613
|
+
this.CallNonvirtualIntMethodV = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualIntMethodV, jint);
|
|
614
|
+
// jint CallNonvirtualIntMethodA(JNIEnv* env, jobject obj, jclass, jmethodID mid, const jvalue* args)
|
|
615
|
+
this.CallNonvirtualIntMethodA = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualIntMethodA, jint);
|
|
616
|
+
// jlong CallNonvirtualLongMethod(JNIEnv* env, jobject obj, jclass, jmethodID mid, ...)
|
|
617
|
+
this.CallNonvirtualLongMethod = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualLongMethod, jlong, { argTypes: callNonvirtualMethodVariadictArgTypes });
|
|
618
|
+
// jlong CallNonvirtualLongMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, va_list args)
|
|
619
|
+
this.CallNonvirtualLongMethodV = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualLongMethodV, jlong);
|
|
620
|
+
// jlong CallNonvirtualLongMethodA(JNIEnv* env, jobject obj, jclass, jmethodID mid, const jvalue* args)
|
|
621
|
+
this.CallNonvirtualLongMethodA = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualLongMethodA, jlong);
|
|
622
|
+
// jfloat CallNonvirtualFloatMethod(JNIEnv* env, jobject obj, jclass, jmethodID mid, ...)
|
|
623
|
+
this.CallNonvirtualFloatMethod = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualFloatMethod, jfloat, { argTypes: callNonvirtualMethodVariadictArgTypes });
|
|
624
|
+
// jfloat CallNonvirtualFloatMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, va_list args)
|
|
625
|
+
this.CallNonvirtualFloatMethodV = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualFloatMethodV, jfloat);
|
|
626
|
+
// jfloat CallNonvirtualFloatMethodA(JNIEnv* env, jobject obj, jclass, jmethodID mid, const jvalue* args)
|
|
627
|
+
this.CallNonvirtualFloatMethodA = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualFloatMethodA, jfloat);
|
|
628
|
+
// jdouble CallNonvirtualDoubleMethod(JNIEnv* env, jobject obj, jclass, jmethodID mid, ...)
|
|
629
|
+
this.CallNonvirtualDoubleMethod = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualDoubleMethod, jdouble, { argTypes: callNonvirtualMethodVariadictArgTypes });
|
|
630
|
+
// jdouble CallNonvirtualDoubleMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, va_list args)
|
|
631
|
+
this.CallNonvirtualDoubleMethodV = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualDoubleMethodV, jdouble);
|
|
632
|
+
// jdouble CallNonvirtualDoubleMethodA(JNIEnv* env, jobject obj, jclass, jmethodID mid, const jvalue* args)
|
|
633
|
+
this.CallNonvirtualDoubleMethodA = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualDoubleMethodA, jdouble);
|
|
634
|
+
// jvoid CallNonvirtualVoidMethod(JNIEnv* env, jobject obj, jclass, jmethodID mid, ...)
|
|
635
|
+
this.CallNonvirtualVoidMethod = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualVoidMethod, jvoid, { argTypes: callNonvirtualMethodVariadictArgTypes });
|
|
636
|
+
// jvoid CallNonvirtualVoidMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, va_list args)
|
|
637
|
+
this.CallNonvirtualVoidMethodV = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualVoidMethodV, jvoid);
|
|
638
|
+
// jvoid CallNonvirtualVoidMethodA(JNIEnv* env, jobject obj, jclass, jmethodID mid, const jvalue* args)
|
|
639
|
+
this.CallNonvirtualVoidMethodA = proxyCallNonvirtualMethod(this, JNI_VT.CallNonvirtualVoidMethodA, jvoid);
|
|
640
|
+
// jobject CallStaticObjectMethod(JNIEnv* env, jclass, jmethodID mid, ...)
|
|
641
|
+
this.CallStaticObjectMethod = proxyCallMethod(this, JNI_VT.CallStaticObjectMethod, jobject, { argTypes: callMethodVariadicArgTypes });
|
|
642
|
+
// jobject CallStaticObjectMethodV(JNIEnv* env, jclass, jmethodID mid, va_list args)
|
|
643
|
+
this.CallStaticObjectMethodV = proxyCallMethod(this, JNI_VT.CallStaticObjectMethodV, jobject);
|
|
644
|
+
// jobject CallStaticObjectMethodA(JNIEnv* env, jclass, jmethodID mid, const jvalue* args)
|
|
645
|
+
this.CallStaticObjectMethodA = proxyCallMethod(this, JNI_VT.CallStaticObjectMethodA, jobject);
|
|
646
|
+
// jboolean CallStaticBooleanMethod(JNIEnv* env, jclass, jmethodID mid, ...)
|
|
647
|
+
this.CallStaticBooleanMethod = proxyCallMethod(this, JNI_VT.CallStaticBooleanMethod, jboolean, { argTypes: callMethodVariadicArgTypes });
|
|
648
|
+
// jboolean CallStaticBooleanMethodV(JNIEnv* env, jclass, jmethodID mid, va_list args)
|
|
649
|
+
this.CallStaticBooleanMethodV = proxyCallMethod(this, JNI_VT.CallStaticBooleanMethodV, jboolean);
|
|
650
|
+
// jboolean CallStaticBooleanMethodA(JNIEnv* env, jclass, jmethodID mid, const jvalue* args)
|
|
651
|
+
this.CallStaticBooleanMethodA = proxyCallMethod(this, JNI_VT.CallStaticBooleanMethodA, jboolean);
|
|
652
|
+
// jbyte CallStaticByteMethod(JNIEnv* env, jclass, jmethodID mid, ...)
|
|
653
|
+
this.CallStaticByteMethod = proxyCallMethod(this, JNI_VT.CallStaticByteMethod, jbyte, { argTypes: callMethodVariadicArgTypes });
|
|
654
|
+
// jbyte CallStaticByteMethodV(JNIEnv* env, jclass, jmethodID mid, va_list args)
|
|
655
|
+
this.CallStaticByteMethodV = proxyCallMethod(this, JNI_VT.CallStaticByteMethodV, jbyte);
|
|
656
|
+
// jbyte CallStaticByteMethodA(JNIEnv* env, jclass, jmethodID mid, const jvalue* args)
|
|
657
|
+
this.CallStaticByteMethodA = proxyCallMethod(this, JNI_VT.CallStaticByteMethodA, jbyte);
|
|
658
|
+
// jchar CallStaticCharMethod(JNIEnv* env, jclass, jmethodID mid, ...)
|
|
659
|
+
this.CallStaticCharMethod = proxyCallMethod(this, JNI_VT.CallStaticCharMethod, jchar, { argTypes: callMethodVariadicArgTypes });
|
|
660
|
+
// jchar CallStaticCharMethodV(JNIEnv* env, jclass, jmethodID mid, va_list args)
|
|
661
|
+
this.CallStaticCharMethodV = proxyCallMethod(this, JNI_VT.CallStaticCharMethodV, jchar);
|
|
662
|
+
// jchar CallStaticCharMethodA(JNIEnv* env, jclass, jmethodID mid, const jvalue* args)
|
|
663
|
+
this.CallStaticCharMethodA = proxyCallMethod(this, JNI_VT.CallStaticCharMethodA, jchar);
|
|
664
|
+
// jshort CallStaticShortMethod(JNIEnv* env, jclass, jmethodID mid, ...)
|
|
665
|
+
this.CallStaticShortMethod = proxyCallMethod(this, JNI_VT.CallStaticShortMethod, jshort, { argTypes: callMethodVariadicArgTypes });
|
|
666
|
+
// jshort CallStaticShortMethodV(JNIEnv* env, jclass, jmethodID mid, va_list args)
|
|
667
|
+
this.CallStaticShortMethodV = proxyCallMethod(this, JNI_VT.CallStaticShortMethodV, jshort);
|
|
668
|
+
// jshort CallStaticShortMethodA(JNIEnv* env, jclass, jmethodID mid, const jvalue* args)
|
|
669
|
+
this.CallStaticShortMethodA = proxyCallMethod(this, JNI_VT.CallStaticShortMethodA, jshort);
|
|
670
|
+
// jint CallStaticIntMethod(JNIEnv* env, jclass, jmethodID mid, ...)
|
|
671
|
+
this.CallStaticIntMethod = proxyCallMethod(this, JNI_VT.CallStaticIntMethod, jint, { argTypes: callMethodVariadicArgTypes });
|
|
672
|
+
// jint CallStaticIntMethodV(JNIEnv* env, jclass, jmethodID mid, va_list args)
|
|
673
|
+
this.CallStaticIntMethodV = proxyCallMethod(this, JNI_VT.CallStaticIntMethodV, jint);
|
|
674
|
+
// jint CallStaticIntMethodA(JNIEnv* env, jclass, jmethodID mid, const jvalue* args)
|
|
675
|
+
this.CallStaticIntMethodA = proxyCallMethod(this, JNI_VT.CallStaticIntMethodA, jint);
|
|
676
|
+
// jlong CallStaticLongMethod(JNIEnv* env, jclass, jmethodID mid, ...)
|
|
677
|
+
this.CallStaticLongMethod = proxyCallMethod(this, JNI_VT.CallStaticLongMethod, jint, { argTypes: callMethodVariadicArgTypes });
|
|
678
|
+
// jlong CallStaticLongMethodV(JNIEnv* env, jclass, jmethodID mid, va_list args)
|
|
679
|
+
this.CallStaticLongMethodV = proxyCallMethod(this, JNI_VT.CallStaticLongMethodV, jint);
|
|
680
|
+
// jlong CallStaticLongMethodA(JNIEnv* env, jclass, jmethodID mid, const jvalue* args)
|
|
681
|
+
this.CallStaticLongMethodA = proxyCallMethod(this, JNI_VT.CallStaticLongMethodA, jint);
|
|
682
|
+
// jfloat CallStaticFloatMethod(JNIEnv* env, jclass, jmethodID mid, ...)
|
|
683
|
+
this.CallStaticFloatMethod = proxyCallMethod(this, JNI_VT.CallStaticFloatMethod, jfloat, { argTypes: callMethodVariadicArgTypes });
|
|
684
|
+
// jfloat CallStaticFloatMethodV(JNIEnv* env, jclass, jmethodID mid, va_list args)
|
|
685
|
+
this.CallStaticFloatMethodV = proxyCallMethod(this, JNI_VT.CallStaticFloatMethodV, jfloat);
|
|
686
|
+
// jfloat CallStaticFloatMethodA(JNIEnv* env, jclass, jmethodID mid, const jvalue* args)
|
|
687
|
+
this.CallStaticFloatMethodA = proxyCallMethod(this, JNI_VT.CallStaticFloatMethodA, jfloat);
|
|
688
|
+
// jdouble CallStaticDoubleMethod(JNIEnv* env, jclass, jmethodID mid, ...)
|
|
689
|
+
this.CallStaticDoubleMethod = proxyCallMethod(this, JNI_VT.CallStaticDoubleMethod, jdouble, { argTypes: callMethodVariadicArgTypes });
|
|
690
|
+
// jdouble CallStaticDoubleMethodV(JNIEnv* env, jclass, jmethodID mid, va_list args)
|
|
691
|
+
this.CallStaticDoubleMethodV = proxyCallMethod(this, JNI_VT.CallStaticDoubleMethodV, jdouble);
|
|
692
|
+
// jdouble CallStaticDoubleMethodA(JNIEnv* env, jclass, jmethodID mid, const jvalue* args)
|
|
693
|
+
this.CallStaticDoubleMethodA = proxyCallMethod(this, JNI_VT.CallStaticDoubleMethodA, jdouble);
|
|
694
|
+
// void CallStaticVoidMethod(JNIEnv* env, jclass, jmethodID mid, ...)
|
|
695
|
+
this.CallStaticVoidMethod = proxyCallMethod(this, JNI_VT.CallStaticVoidMethod, jvoid, { argTypes: callMethodVariadicArgTypes });
|
|
696
|
+
// void CallStaticVoidMethodV(JNIEnv* env, jclass, jmethodID mid, va_list args)
|
|
697
|
+
this.CallStaticVoidMethodV = proxyCallMethod(this, JNI_VT.CallStaticVoidMethodV, jvoid);
|
|
698
|
+
// void CallStaticVoidMethodA(JNIEnv* env, jclass, jmethodID mid, const jvalue* args)
|
|
699
|
+
this.CallStaticVoidMethodA = proxyCallMethod(this, JNI_VT.CallStaticVoidMethodA, jvoid);
|
|
700
|
+
// jfieldID GetFieldID(JNIEnv* env, jclass java_class, const char* name, const char* sig)
|
|
701
|
+
this.GetFieldID = this.$proxy(function (impl, java_class, name, sig) {
|
|
702
|
+
return impl(this.handle, java_class, Memory.allocUtf8String(name), Memory.allocUtf8String(sig));
|
|
703
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer', 'pointer'], JNI_VT.GetFieldID, jobject);
|
|
704
|
+
// jfieldID GetStaticFieldID(JNIEnv* env, jclass java_class, const char* name, const char* sig)
|
|
705
|
+
this.GetStaticFieldID = this.$proxy(function (impl, java_class, name, sig) {
|
|
706
|
+
return impl(this.handle, java_class, Memory.allocUtf8String(name), Memory.allocUtf8String(sig));
|
|
707
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer', 'pointer'], JNI_VT.GetStaticFieldID, jobject);
|
|
708
|
+
// jobject GetObjectField(JNIEnv* env, jobject obj, jfieldID fid)
|
|
709
|
+
this.GetObjectField = this.$proxy(function (impl, obj, fid) {
|
|
710
|
+
return impl(this.handle, obj, fid);
|
|
711
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetObjectField, jobject);
|
|
712
|
+
// jboolean GetBooleanField(JNIEnv* env, jobject obj, jfieldID fid)
|
|
713
|
+
this.GetBooleanField = this.$proxy(function (impl, obj, fid) {
|
|
714
|
+
return impl(this.handle, obj, fid);
|
|
715
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetBooleanField, jboolean);
|
|
716
|
+
// jbyte GetByteField(JNIEnv* env, jobject obj, jfieldID fid)
|
|
717
|
+
this.GetByteField = this.$proxy(function (impl, obj, fid) {
|
|
718
|
+
return impl(this.handle, obj, fid);
|
|
719
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetByteField, jbyte);
|
|
720
|
+
// jchar GetCharField(JNIEnv* env, jobject obj, jfieldID fid)
|
|
721
|
+
this.GetCharField = this.$proxy(function (impl, obj, fid) {
|
|
722
|
+
return impl(this.handle, obj, fid);
|
|
723
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetCharField, jchar);
|
|
724
|
+
// jshort GetShortField(JNIEnv* env, jobject obj, jfieldID fid)
|
|
725
|
+
this.GetShortField = this.$proxy(function (impl, obj, fid) {
|
|
726
|
+
return impl(this.handle, obj, fid);
|
|
727
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetShortField, jshort);
|
|
728
|
+
// jint GetIntField(JNIEnv* env, jobject obj, jfieldID fid)
|
|
729
|
+
this.GetIntField = this.$proxy(function (impl, obj, fid) {
|
|
730
|
+
return impl(this.handle, obj, fid);
|
|
731
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetIntField, jint);
|
|
732
|
+
// jlong GetLongField(JNIEnv* env, jobject obj, jfieldID fid)
|
|
733
|
+
this.GetLongField = this.$proxy(function (impl, obj, fid) {
|
|
734
|
+
return impl(this.handle, obj, fid);
|
|
735
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetLongField, jlong);
|
|
736
|
+
// jfloat GetFloatField(JNIEnv* env, jobject obj, jfieldID fid)
|
|
737
|
+
this.GetFloatField = this.$proxy(function (impl, obj, fid) {
|
|
738
|
+
return impl(this.handle, obj, fid);
|
|
739
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetFloatField, jfloat);
|
|
740
|
+
// jdouble GetDoubleField(JNIEnv* env, jobject obj, jfieldID fid)
|
|
741
|
+
this.GetDoubleField = this.$proxy(function (impl, obj, fid) {
|
|
742
|
+
return impl(this.handle, obj, fid);
|
|
743
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetDoubleField, jdouble);
|
|
744
|
+
// jobject GetStaticObjectField(JNIEnv* env, jclass, jfieldID fid)
|
|
745
|
+
this.GetStaticObjectField = this.$proxy(function (impl, cls, fid) {
|
|
746
|
+
return impl(this.handle, cls, fid);
|
|
747
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStaticObjectField, jobject);
|
|
748
|
+
// jboolean GetStaticBooleanField(JNIEnv* env, jclass, jfieldID fid)
|
|
749
|
+
this.GetStaticBooleanField = this.$proxy(function (impl, obj, fid) {
|
|
750
|
+
return impl(this.handle, obj, fid);
|
|
751
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStaticBooleanField, jboolean);
|
|
752
|
+
// jbyte GetStaticByteField(JNIEnv* env, jclass, jfieldID fid)
|
|
753
|
+
this.GetStaticByteField = this.$proxy(function (impl, obj, fid) {
|
|
754
|
+
return impl(this.handle, obj, fid);
|
|
755
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStaticByteField, jbyte);
|
|
756
|
+
// jchar GetStaticCharField(JNIEnv* env, jclass, jfieldID fid)
|
|
757
|
+
this.GetStaticCharField = this.$proxy(function (impl, obj, fid) {
|
|
758
|
+
return impl(this.handle, obj, fid);
|
|
759
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStaticCharField, jchar);
|
|
760
|
+
// jshort GetStaticShortField(JNIEnv* env, jclass, jfieldID fid)
|
|
761
|
+
this.GetStaticShortField = this.$proxy(function (impl, obj, fid) {
|
|
762
|
+
return impl(this.handle, obj, fid);
|
|
763
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStaticShortField, jshort);
|
|
764
|
+
// jint GetStaticIntField(JNIEnv* env, jclass, jfieldID fid)
|
|
765
|
+
this.GetStaticIntField = this.$proxy(function (impl, obj, fid) {
|
|
766
|
+
return impl(this.handle, obj, fid);
|
|
767
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStaticIntField, jint);
|
|
768
|
+
// jlong GetStaticLongField(JNIEnv* env, jclass, jfieldID fid)
|
|
769
|
+
this.GetStaticLongField = this.$proxy(function (impl, obj, fid) {
|
|
770
|
+
return impl(this.handle, obj, fid);
|
|
771
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStaticLongField, jlong);
|
|
772
|
+
// jfloat GetStaticFloatField(JNIEnv* env, jclass, jfieldID fid)
|
|
773
|
+
this.GetStaticFloatField = this.$proxy(function (impl, obj, fid) {
|
|
774
|
+
return impl(this.handle, obj, fid);
|
|
775
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStaticFloatField, jfloat);
|
|
776
|
+
// jdouble GetStaticDoubleField(JNIEnv* env, jclass, jfieldID fid)
|
|
777
|
+
this.GetStaticDoubleField = this.$proxy(function (impl, obj, fid) {
|
|
778
|
+
return impl(this.handle, obj, fid);
|
|
779
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStaticDoubleField, jdouble);
|
|
780
|
+
// static jclass FindClass(JNIEnv* env, const char* name)
|
|
781
|
+
this.FindClass = this.$proxy(function (impl, name) {
|
|
782
|
+
const result = impl(this.handle, Memory.allocUtf8String(name));
|
|
783
|
+
this.throwIfExceptionPending();
|
|
784
|
+
return result;
|
|
785
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.FindClass, jclass);
|
|
786
|
+
// jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic)
|
|
787
|
+
this.ToReflectedMethod = this.$proxy(function (impl, klass, methodId, isStatic) {
|
|
788
|
+
return impl(this.handle, klass, methodId, isStatic ? 1 : 0);
|
|
789
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer', 'uint8'], JNI_VT.ToReflectedMethod, jobject, ($0, $1, isStatic) => ({ isStatic }));
|
|
790
|
+
// jclass GetSuperclass(JNIEnv* env, jclass java_class)
|
|
791
|
+
this.GetSuperclass = this.$proxy(function (impl, java_class) {
|
|
792
|
+
return impl(this.handle, java_class);
|
|
793
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.GetSuperclass, jclass);
|
|
794
|
+
// jobject NewObject(JNIEnv* env, jclass java_class, jmethodID mid, ...)
|
|
795
|
+
this.NewObject = this.$proxy(function (impl, java_class, mid, ...args) {
|
|
796
|
+
return impl(this.handle, java_class, mid, ...args);
|
|
797
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer', '...', 'pointer'], JNI_VT.NewObject, jobject);
|
|
798
|
+
// jobject NewObjectV(JNIEnv* env, jclass java_class, jmethodID mid, va_list args)
|
|
799
|
+
this.NewObjectV = this.$proxy(function (impl, java_class, mid, args) {
|
|
800
|
+
return impl(this.handle, java_class, mid, args);
|
|
801
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer', 'pointer'], JNI_VT.NewObjectV, jobject);
|
|
802
|
+
// jobject NewObjectA(JNIEnv* env, jclass java_class, jmethodID mid, const jvalue* args)
|
|
803
|
+
this.NewObjectA = this.$proxy(function (impl, java_class, mid, args) {
|
|
804
|
+
return impl(this.handle, java_class, mid, args);
|
|
805
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer', 'pointer'], JNI_VT.NewObjectA, jobject);
|
|
806
|
+
// jclass GetObjectClass(jobject obj)
|
|
807
|
+
this.GetObjectClass = this.$proxy(function (impl, obj) {
|
|
808
|
+
return impl(this.handle, obj);
|
|
809
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.GetObjectClass, jclass);
|
|
810
|
+
// jmethodID GetMethodID(jclass clazz, const char *name, const char *sig)
|
|
811
|
+
this.GetMethodID = this.$proxy(function (impl, klass, name, sig) {
|
|
812
|
+
return impl(this.handle, klass, Memory.allocUtf8String(name), Memory.allocUtf8String(sig));
|
|
813
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer', 'pointer'], JNI_VT.GetMethodID, jmethodID);
|
|
814
|
+
// static jmethodID GetStaticMethodID(JNIEnv* env, jclass java_class, const char* name, const char* sig)
|
|
815
|
+
this.GetStaticMethodID = this.$proxy(function (impl, java_class, name, sig) {
|
|
816
|
+
return impl(this.handle, java_class, Memory.allocUtf8String(name), Memory.allocUtf8String(sig));
|
|
817
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer', 'pointer'], JNI_VT.GetStaticMethodID, jmethodID);
|
|
818
|
+
// static const jchar* GetStringChars(JNIEnv* env, jstring java_string, jboolean* is_copy)
|
|
819
|
+
this.GetStringChars = this.$proxy(function (impl, str) {
|
|
820
|
+
return impl(this.handle, str, NULL);
|
|
821
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStringChars, NativePointer);
|
|
822
|
+
// jsize GetStringLength(JNIEnv* env, jstring java_string)
|
|
823
|
+
this.GetStringLength = this.$proxy(function (impl, java_string) {
|
|
824
|
+
return impl(this.handle, java_string);
|
|
825
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.GetStringLength, jint);
|
|
826
|
+
// void ReleaseStringChars(JNIEnv* env, jstring java_string, const jchar* chars)
|
|
827
|
+
this.ReleaseStringChars = this.$proxy(function (impl, java_string, chars) {
|
|
828
|
+
return impl(this.handle, java_string, chars);
|
|
829
|
+
}, 'void', ['pointer', 'pointer', 'pointer'], JNI_VT.ReleaseStringChars);
|
|
830
|
+
// const char* GetStringUTFChars(jstring str, jboolean *isCopy)
|
|
831
|
+
this.GetStringUTFChars = this.$proxy(function (impl, str) {
|
|
832
|
+
return impl(this.handle, str, NULL);
|
|
833
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStringUTFChars, NativePointer);
|
|
834
|
+
// jsize GetStringUTFLength(JNIEnv* env, jstring java_string)
|
|
835
|
+
this.GetStringUTFLength = this.$proxy(function (impl, java_string) {
|
|
836
|
+
return impl(this.handle, java_string);
|
|
837
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.GetStringUTFLength, jint);
|
|
838
|
+
// void ReleaseStringUTFChars(JNIEnv*, jstring, const char* chars)
|
|
839
|
+
this.ReleaseStringUTFChars = this.$proxy(function (impl, chars) {
|
|
840
|
+
return impl(this.handle, chars);
|
|
841
|
+
}, 'void', ['pointer', 'pointer'], JNI_VT.ReleaseStringUTFChars);
|
|
842
|
+
// jsize GetArrayLength(JNIEnv* env, jarray java_array)
|
|
843
|
+
this.GetArrayLength = this.$proxy(function (impl, java_array) {
|
|
844
|
+
return impl(this.handle, java_array);
|
|
845
|
+
}, 'int', ['pointer', 'pointer'], JNI_VT.GetArrayLength, jint);
|
|
846
|
+
// jobject GetObjectArrayElement(JNIEnv* env, jobjectArray java_array, jsize index)
|
|
847
|
+
this.GetObjectArrayElement = this.$proxy(function (impl, java_array, index) {
|
|
848
|
+
return impl(this.handle, java_array, index);
|
|
849
|
+
}, 'pointer', ['pointer', 'pointer', 'int'], JNI_VT.GetObjectArrayElement, jobject);
|
|
850
|
+
// jboolean* GetBooleanArrayElements(JNIEnv* env, jbooleanArray array, jboolean* is_copy)
|
|
851
|
+
this.GetBooleanArrayElements = this.$proxy(function (impl, java_array) {
|
|
852
|
+
return impl(this.handle, java_array, NULL);
|
|
853
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetBooleanArrayElements, jbooleanArray);
|
|
854
|
+
// jbyte* GetByteArrayElements(JNIEnv* env, jbyteArray array, jboolean* is_copy)
|
|
855
|
+
this.GetByteArrayElements = this.$proxy(function (impl, java_array) {
|
|
856
|
+
return impl(this.handle, java_array, NULL);
|
|
857
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetByteArrayElements, jbyteArray);
|
|
858
|
+
// jchar* GetCharArrayElements(JNIEnv* env, jcharArray array, jboolean* is_copy)
|
|
859
|
+
this.GetCharArrayElements = this.$proxy(function (impl, java_array) {
|
|
860
|
+
return impl(this.handle, java_array, NULL);
|
|
861
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetCharArrayElements, jcharArray);
|
|
862
|
+
// jdouble* GetDoubleArrayElements(JNIEnv* env, jdoubleArray array, jboolean* is_copy)
|
|
863
|
+
this.GetDoubleArrayElements = this.$proxy(function (impl, java_array) {
|
|
864
|
+
return impl(this.handle, java_array, NULL);
|
|
865
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetDoubleArrayElements, jdoubleArray);
|
|
866
|
+
// jfloat* GetFloatArrayElements(JNIEnv* env, jfloatArray array, jboolean* is_copy)
|
|
867
|
+
this.GetFloatArrayElements = this.$proxy(function (impl, java_array) {
|
|
868
|
+
return impl(this.handle, java_array, NULL);
|
|
869
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetFloatArrayElements, jfloatArray);
|
|
870
|
+
// jint* GetIntArrayElements(JNIEnv* env, jintArray array, jboolean* is_copy)
|
|
871
|
+
this.GetIntArrayElements = this.$proxy(function (impl, java_array) {
|
|
872
|
+
return impl(this.handle, java_array, NULL);
|
|
873
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetIntArrayElements, jintArray);
|
|
874
|
+
// jlong* GetLongArrayElements(JNIEnv* env, jlongArray array, jboolean* is_copy)
|
|
875
|
+
this.GetLongArrayElements = this.$proxy(function (impl, java_array) {
|
|
876
|
+
return impl(this.handle, java_array, NULL);
|
|
877
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetLongArrayElements, jlongArray);
|
|
878
|
+
// jshort* GetShortArrayElements(JNIEnv* env, jshortArray array, jboolean* is_copy)
|
|
879
|
+
this.GetShortArrayElements = this.$proxy(function (impl, java_array) {
|
|
880
|
+
return impl(this.handle, java_array, NULL);
|
|
881
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetShortArrayElements, jshortArray);
|
|
882
|
+
// void ReleaseBooleanArrayElements(JNIEnv* env, jbooleanArray array, jboolean* elements, jint mode)
|
|
883
|
+
this.ReleaseBooleanArrayElements = this.$proxy(function (impl, array, elements, mode) {
|
|
884
|
+
return impl(this.handle, array, elements, mode);
|
|
885
|
+
}, 'void', ['pointer', 'pointer', 'pointer', 'int'], JNI_VT.ReleaseBooleanArrayElements);
|
|
886
|
+
// void ReleaseByteArrayElements(JNIEnv* env, jbyteArray array, jbyte* elements, jint mode)
|
|
887
|
+
this.ReleaseByteArrayElements = this.$proxy(function (impl, array, elements, mode) {
|
|
888
|
+
return impl(this.handle, array, elements, mode);
|
|
889
|
+
}, 'void', ['pointer', 'pointer', 'pointer', 'int'], JNI_VT.ReleaseByteArrayElements);
|
|
890
|
+
// void ReleaseCharArrayElements(JNIEnv* env, jcharArray array, jchar* elements, jint mode)
|
|
891
|
+
this.ReleaseCharArrayElements = this.$proxy(function (impl, array, elements, mode) {
|
|
892
|
+
return impl(this.handle, array, elements, mode);
|
|
893
|
+
}, 'void', ['pointer', 'pointer', 'pointer', 'int'], JNI_VT.ReleaseCharArrayElements);
|
|
894
|
+
// void ReleaseFloatArrayElements(JNIEnv* env, jfloatArray array, jfloat* elements, jint mode)
|
|
895
|
+
this.ReleaseFloatArrayElements = this.$proxy(function (impl, array, elements, mode) {
|
|
896
|
+
return impl(this.handle, array, elements, mode);
|
|
897
|
+
}, 'void', ['pointer', 'pointer', 'pointer', 'int'], JNI_VT.ReleaseFloatArrayElements);
|
|
898
|
+
// void ReleaseDoubleArrayElements(JNIEnv* env, jdoubleArray array, jdouble* elements, jint mode)
|
|
899
|
+
this.ReleaseDoubleArrayElements = this.$proxy(function (impl, array, elements, mode) {
|
|
900
|
+
return impl(this.handle, array, elements, mode);
|
|
901
|
+
}, 'void', ['pointer', 'pointer', 'pointer', 'int'], JNI_VT.ReleaseDoubleArrayElements);
|
|
902
|
+
// void ReleaseIntArrayElements(JNIEnv* env, jintArray array, jint* elements, jint mode)
|
|
903
|
+
this.ReleaseIntArrayElements = this.$proxy(function (impl, array, elements, mode) {
|
|
904
|
+
return impl(this.handle, array, elements, mode);
|
|
905
|
+
}, 'void', ['pointer', 'pointer', 'pointer', 'int'], JNI_VT.ReleaseIntArrayElements);
|
|
906
|
+
// void ReleaseLongArrayElements(JNIEnv* env, jlongArray array, jlong* elements, jint mode)
|
|
907
|
+
this.ReleaseLongArrayElements = this.$proxy(function (impl, array, elements, mode) {
|
|
908
|
+
return impl(this.handle, array, elements, mode);
|
|
909
|
+
}, 'void', ['pointer', 'pointer', 'pointer', 'int'], JNI_VT.ReleaseLongArrayElements);
|
|
910
|
+
// void ReleaseShortArrayElements(JNIEnv* env, jshortArray array, jshort* elements, jint mode)
|
|
911
|
+
this.ReleaseShortArrayElements = this.$proxy(function (impl, array, elements, mode) {
|
|
912
|
+
return impl(this.handle, array, elements, mode);
|
|
913
|
+
}, 'void', ['pointer', 'pointer', 'pointer', 'int'], JNI_VT.ReleaseShortArrayElements);
|
|
914
|
+
// static const jchar* GetStringCritical(JNIEnv* env, jstring java_string, jboolean* is_copy)
|
|
915
|
+
this.GetStringCritical = this.$proxy(function (impl, str) {
|
|
916
|
+
return impl(this.handle, str, NULL).readCString();
|
|
917
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.GetStringCritical);
|
|
918
|
+
// jint Throw(JNIEnv* env, jthrowable java_exception)
|
|
919
|
+
this.Throw = this.$proxy(function (impl, java_exception) {
|
|
920
|
+
return impl(this.handle, java_exception);
|
|
921
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.Throw, jint);
|
|
922
|
+
// jint ThrowNew(JNIEnv* env, jclass c, const char* msg)
|
|
923
|
+
this.ThrowNew = this.$proxy(function (impl, c, msg) {
|
|
924
|
+
const cMsg = Memory.allocUtf8String(msg);
|
|
925
|
+
help.$error(`[ThrowNew]c[${c}], msg[${msg}]`);
|
|
926
|
+
return impl(this.handle, c, cMsg);
|
|
927
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.ThrowNew, jint);
|
|
928
|
+
// jthrowable ExceptionOccurred(JNIEnv* env)
|
|
929
|
+
this.ExceptionOccurred = this.$proxy(function (impl) {
|
|
930
|
+
return impl(this.handle);
|
|
931
|
+
}, 'pointer', ['pointer'], JNI_VT.ExceptionOccurred, jthrowable);
|
|
932
|
+
// void ExceptionDescribe(JNIEnv* env)
|
|
933
|
+
this.ExceptionDescribe = this.$proxy(function (impl) {
|
|
934
|
+
return impl(this.handle);
|
|
935
|
+
}, 'void', ['pointer'], JNI_VT.ExceptionDescribe);
|
|
936
|
+
// void ExceptionClear(JNIEnv* env)
|
|
937
|
+
this.ExceptionClear = this.$proxy(function (impl) {
|
|
938
|
+
return impl(this.handle);
|
|
939
|
+
}, 'void', ['pointer'], JNI_VT.ExceptionClear);
|
|
940
|
+
// jboolean ExceptionCheck(JNIEnv* env)
|
|
941
|
+
this.ExceptionCheck = this.$proxy(function (impl) {
|
|
942
|
+
return impl(this.handle).toUInt32() != 0;
|
|
943
|
+
}, 'pointer', ['pointer'], JNI_VT.ExceptionCheck);
|
|
944
|
+
// void FatalError(JNIEnv*, const char* msg)
|
|
945
|
+
this.FatalError = this.$proxy(function (impl, msg) {
|
|
946
|
+
return impl(this.handle, Memory.allocUtf8String(msg));
|
|
947
|
+
}, 'pointer', ['pointer'], JNI_VT.FatalError);
|
|
948
|
+
// jint PushLocalFrame(JNIEnv* env, jint capacity)
|
|
949
|
+
this.PushLocalFrame = this.$proxy(function (impl, capacity) {
|
|
950
|
+
return impl(this.handle, capacity);
|
|
951
|
+
}, 'int', ['pointer', 'int'], JNI_VT.PushLocalFrame, jint);
|
|
952
|
+
// jobject PopLocalFrame(JNIEnv* env, jobject java_survivor)
|
|
953
|
+
this.PopLocalFrame = this.$proxy(function (impl, java_survivor) {
|
|
954
|
+
return impl(this.handle, java_survivor);
|
|
955
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.PopLocalFrame, jobject);
|
|
956
|
+
// static jobject NewGlobalRef(JNIEnv* env, jobject obj)
|
|
957
|
+
this.NewGlobalRef = this.$proxy(function (impl, obj) {
|
|
958
|
+
return impl(this.handle, obj);
|
|
959
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.NewGlobalRef, jobject);
|
|
960
|
+
// static jboolean IsSameObject(JNIEnv* env, jobject obj1, jobject obj2)
|
|
961
|
+
this.IsSameObject = this.$proxy(function (impl, obj1, obj2) {
|
|
962
|
+
return impl(this.handle, obj1, obj2) != 0;
|
|
963
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], JNI_VT.IsSameObject);
|
|
964
|
+
// jobject JNIEnvExt::NewLocalRef(mirror::Object* obj)
|
|
965
|
+
this.NewLocalRef = this.$proxy(function (impl, obj) {
|
|
966
|
+
return impl(this.handle, obj);
|
|
967
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.NewLocalRef, jobject);
|
|
968
|
+
// static void DeleteGlobalRef(JNIEnv* env, jobject obj)
|
|
969
|
+
this.DeleteGlobalRef = this.$proxy(function (impl, obj) {
|
|
970
|
+
impl(this.handle, obj);
|
|
971
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.DeleteGlobalRef);
|
|
972
|
+
// void DeleteLocalRef(JNIEnv* env, jobject obj)
|
|
973
|
+
this.DeleteLocalRef = this.$proxy(function (impl, obj) {
|
|
974
|
+
impl(this.handle, obj);
|
|
975
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.DeleteLocalRef);
|
|
976
|
+
// static void DeleteWeakGlobalRef(JNIEnv* env, jweak obj)
|
|
977
|
+
this.DeleteWeakGlobalRef = this.$proxy(function (impl, obj) {
|
|
978
|
+
impl(this.handle, obj);
|
|
979
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.DeleteWeakGlobalRef);
|
|
980
|
+
// jint RegisterNatives(JNIEnv* env, jclass java_class, const JNINativeMethod* methods, jint method_count)
|
|
981
|
+
this.RegisterNatives = this.$proxy(function (impl, java_class, methods, method_count) {
|
|
982
|
+
return impl(this.handle, java_class, methods, method_count);
|
|
983
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer', 'pointer'], JNI_VT.RegisterNatives, jint);
|
|
984
|
+
// jint UnregisterNatives(JNIEnv* env, jclass java_class)
|
|
985
|
+
this.UnregisterNatives = this.$proxy(function (impl, java_class) {
|
|
986
|
+
return impl(this.handle, java_class);
|
|
987
|
+
}, 'pointer', ['pointer', 'pointer'], JNI_VT.UnregisterNatives, jint);
|
|
988
|
+
// ObjPtr<mirror::Object> JavaVMExt::DecodeGlobal(IndirectRef ref)
|
|
989
|
+
this.DecodeGlobal = this.$symbol(function (impl, obj) {
|
|
990
|
+
return impl(this.vm.handle, obj);
|
|
991
|
+
}, 'pointer', ['pointer', 'pointer'], '_ZN3art9JavaVMExt12DecodeGlobalEPv', MirrorObject);
|
|
992
|
+
// ObjPtr<mirror::Object> Thread::DecodeJObject(jobject obj)
|
|
993
|
+
this.DecodeJObject = this.$symbol(function (impl, thread = null, obj) {
|
|
994
|
+
const th = thread ? thread : getThreadFromEnv(this);
|
|
995
|
+
return impl(th, obj);
|
|
996
|
+
}, 'pointer', ['pointer', 'pointer'], '_ZNK3art6Thread13DecodeJObjectEP8_jobject', MirrorObject);
|
|
997
|
+
// jobject JavaVMExt::AddGlobalRef(Thread* self, ObjPtr<mirror::Object> obj)
|
|
998
|
+
this.AddGlobalRef = this.$symbol(function (impl, thread = null, obj) {
|
|
999
|
+
const th = thread ? thread : getThreadFromEnv(this);
|
|
1000
|
+
return impl(this.vm.handle, th, obj);
|
|
1001
|
+
}, 'pointer', ['pointer', 'pointer', 'pointer'], '_ZN3art9JavaVMExt12AddGlobalRefEPNS_6ThreadENS_6ObjPtrINS_6mirror6ObjectEEE', jobject);
|
|
1002
|
+
// IndirectReferenceTable::IndirectReferenceTable(size_t max_count, IndirectRefKind desired_kind, ResizableCapacity resizable, std::string * error_msg)
|
|
1003
|
+
this.IndirectReferenceTable_$new = this.$symbol(function (impl, self, max_count, desired_kind, resizable, error_msg) {
|
|
1004
|
+
return impl(self, max_count, desired_kind, resizable, error_msg);
|
|
1005
|
+
}, 'pointer', ['pointer', 'size_t', 'pointer', 'pointer', 'pointer'], '_ZN3art22IndirectReferenceTableC2EmNS_15IndirectRefKindENS0_17ResizableCapacityEPNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE', NativePointer);
|
|
1006
|
+
// IndirectReferenceTable::~IndirectReferenceTable
|
|
1007
|
+
this.IndirectReferenceTable_$del = this.$symbol(function (impl, self) {
|
|
1008
|
+
return impl(self);
|
|
1009
|
+
}, 'void', ['pointer'], '_ZN3art22IndirectReferenceTableD2Ev');
|
|
1010
|
+
// bool IndirectReferenceTable::Resize(size_t new_size, std::string* error_msg)
|
|
1011
|
+
this.IndirectReferenceTable_Resize = this.$symbol(function (impl, new_size, error_msg) {
|
|
1012
|
+
return impl(new_size, error_msg);
|
|
1013
|
+
}, 'bool', ['size_t', 'pointer'], '_ZN3art22IndirectReferenceTable6ResizeEmPNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE');
|
|
1014
|
+
}
|
|
1015
|
+
makeObjectArrayElements(java_array) {
|
|
1016
|
+
return new jobjectArray(java_array);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
class JniEnv extends JniEnvCaller {
|
|
1020
|
+
constructor(vm) {
|
|
1021
|
+
super(vm);
|
|
1022
|
+
const that = this;
|
|
1023
|
+
return new Proxy(this, {
|
|
1024
|
+
get(target, prop) {
|
|
1025
|
+
if (prop in target) {
|
|
1026
|
+
return target[prop];
|
|
1027
|
+
}
|
|
1028
|
+
const env = that.$vm.getEnv();
|
|
1029
|
+
return env[prop];
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
$clone() {
|
|
1034
|
+
return new JniEnv(this.$vm);
|
|
1035
|
+
}
|
|
1036
|
+
javaLangReflectMethod() {
|
|
1037
|
+
if (!JniEnv._javaLangReflectMethod) {
|
|
1038
|
+
const cache = this.$env.javaLangReflectMethod();
|
|
1039
|
+
// patch
|
|
1040
|
+
const jcls = this.FindClass('java/lang/reflect/Method');
|
|
1041
|
+
const methodID = this.GetMethodID(jcls, 'getReturnType', '()Ljava/lang/Class;');
|
|
1042
|
+
cache.getReturnType = methodID;
|
|
1043
|
+
JniEnv._javaLangReflectMethod = cache;
|
|
1044
|
+
jcls.$unref();
|
|
1045
|
+
}
|
|
1046
|
+
return JniEnv._javaLangReflectMethod;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
export const JNIEnv = new JniEnv();
|
|
1050
|
+
setGlobalProperties({
|
|
1051
|
+
'JNIEnv': JNIEnv,
|
|
1052
|
+
'jobject': jobject,
|
|
1053
|
+
'jclass': jclass,
|
|
1054
|
+
});
|