-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathSystem.loadLibrary.js
More file actions
44 lines (36 loc) · 1.12 KB
/
System.loadLibrary.js
File metadata and controls
44 lines (36 loc) · 1.12 KB
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
/**
适用对象:通用
作用:监控 System.loadLibrary 加载的库文件
*/
const TargetLibName = 'cocos2djs'
const MyLibName = 'test'
function hook() {
const System = Java.use('java.lang.System');
const Runtime = Java.use('java.lang.Runtime');
const VMStack = Java.use('dalvik.system.VMStack');
System.loadLibrary.implementation = function (libName) {
try {
console.log('\nSystem.loadLibrary("' + libName + '")');
//printStack(); // 想知道是哪个类加载的可以打开日志
const loaded = Runtime.getRuntime().loadLibrary0(VMStack.getCallingClassLoader(), libName);
if (libName == TargetLibName) {
console.log(TargetLibName + " is loaded!");
try {
Runtime.getRuntime().loadLibrary0(VMStack.getCallingClassLoader(), MyLibName);
} catch (e) {
console.log(e);
}
}
return loaded;
} catch (ex) {
//console.log(ex);
}
}
}
// 打印堆栈
function printStack() {
Java.perform(function () {
console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Exception").$new()));
});
}
hook();