@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
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
kWeakGlobal = 3, // <<weak global reference>>
|
|
8
|
-
kLastKind = kWeakGlobal
|
|
1
|
+
export declare enum IndirectRefKind {
|
|
2
|
+
kHandleScopeOrInvalid = 0,// <<stack indirect reference table or invalid reference>>
|
|
3
|
+
kLocal = 1,// <<local reference>>
|
|
4
|
+
kGlobal = 2,// <<global reference>>
|
|
5
|
+
kWeakGlobal = 3,// <<weak global reference>>
|
|
6
|
+
kLastKind = 3
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export enum JNI_VT {
|
|
8
|
+
export declare enum JNI_VT {
|
|
13
9
|
FindClass = 6,
|
|
14
10
|
FromReflectedMethod = 7,
|
|
15
11
|
ToReflectedMethod = 9,
|
|
@@ -20,10 +16,8 @@ export enum JNI_VT {
|
|
|
20
16
|
ExceptionDescribe = 16,
|
|
21
17
|
ExceptionClear = 17,
|
|
22
18
|
FatalError = 18,
|
|
23
|
-
|
|
24
19
|
PushLocalFrame = 19,
|
|
25
20
|
PopLocalFrame = 20,
|
|
26
|
-
|
|
27
21
|
NewGlobalRef = 21,
|
|
28
22
|
DeleteGlobalRef = 22,
|
|
29
23
|
DeleteLocalRef = 23,
|
|
@@ -34,87 +28,66 @@ export enum JNI_VT {
|
|
|
34
28
|
NewObjectA = 30,
|
|
35
29
|
GetObjectClass = 31,
|
|
36
30
|
GetMethodID = 33,
|
|
37
|
-
|
|
38
31
|
CallObjectMethod = 34,
|
|
39
32
|
CallObjectMethodV = 35,
|
|
40
33
|
CallObjectMethodA = 36,
|
|
41
|
-
|
|
42
34
|
CallBooleanMethod = 37,
|
|
43
35
|
CallBooleanMethodV = 38,
|
|
44
36
|
CallBooleanMethodA = 39,
|
|
45
|
-
|
|
46
37
|
CallByteMethod = 40,
|
|
47
38
|
CallByteMethodV = 41,
|
|
48
39
|
CallByteMethodA = 42,
|
|
49
|
-
|
|
50
40
|
CallCharMethod = 43,
|
|
51
41
|
CallCharMethodV = 44,
|
|
52
42
|
CallCharMethodA = 45,
|
|
53
|
-
|
|
54
43
|
CallShortMethod = 46,
|
|
55
44
|
CallShortMethodV = 47,
|
|
56
45
|
CallShortMethodA = 48,
|
|
57
|
-
|
|
58
46
|
CallIntMethod = 49,
|
|
59
47
|
CallIntMethodV = 50,
|
|
60
48
|
CallIntMethodA = 51,
|
|
61
|
-
|
|
62
49
|
CallLongMethod = 52,
|
|
63
50
|
CallLongMethodV = 53,
|
|
64
51
|
CallLongMethodA = 54,
|
|
65
|
-
|
|
66
52
|
CallFloatMethod = 55,
|
|
67
53
|
CallFloatMethodV = 56,
|
|
68
54
|
CallFloatMethodA = 57,
|
|
69
|
-
|
|
70
55
|
CallDoubleMethod = 58,
|
|
71
56
|
CallDoubleMethodV = 59,
|
|
72
57
|
CallDoubleMethodA = 60,
|
|
73
|
-
|
|
74
58
|
CallVoidMethod = 61,
|
|
75
59
|
CallVoidMethodV = 62,
|
|
76
60
|
CallVoidMethodA = 63,
|
|
77
|
-
|
|
78
61
|
CallNonvirtualObjectMethod = 64,
|
|
79
62
|
CallNonvirtualObjectMethodV = 65,
|
|
80
63
|
CallNonvirtualObjectMethodA = 66,
|
|
81
|
-
|
|
82
64
|
CallNonvirtualBooleanMethod = 67,
|
|
83
65
|
CallNonvirtualBooleanMethodV = 68,
|
|
84
66
|
CallNonvirtualBooleanMethodA = 69,
|
|
85
|
-
|
|
86
67
|
CallNonvirtualByteMethod = 70,
|
|
87
68
|
CallNonvirtualByteMethodV = 71,
|
|
88
69
|
CallNonvirtualByteMethodA = 72,
|
|
89
|
-
|
|
90
70
|
CallNonvirtualCharMethod = 73,
|
|
91
71
|
CallNonvirtualCharMethodV = 74,
|
|
92
72
|
CallNonvirtualCharMethodA = 75,
|
|
93
|
-
|
|
94
73
|
CallNonvirtualShortMethod = 76,
|
|
95
74
|
CallNonvirtualShortMethodV = 77,
|
|
96
75
|
CallNonvirtualShortMethodA = 78,
|
|
97
|
-
|
|
98
76
|
CallNonvirtualIntMethod = 79,
|
|
99
77
|
CallNonvirtualIntMethodV = 80,
|
|
100
78
|
CallNonvirtualIntMethodA = 81,
|
|
101
|
-
|
|
102
79
|
CallNonvirtualLongMethod = 82,
|
|
103
80
|
CallNonvirtualLongMethodV = 83,
|
|
104
81
|
CallNonvirtualLongMethodA = 84,
|
|
105
|
-
|
|
106
82
|
CallNonvirtualFloatMethod = 85,
|
|
107
83
|
CallNonvirtualFloatMethodV = 86,
|
|
108
84
|
CallNonvirtualFloatMethodA = 87,
|
|
109
|
-
|
|
110
85
|
CallNonvirtualDoubleMethod = 88,
|
|
111
86
|
CallNonvirtualDoubleMethodV = 89,
|
|
112
87
|
CallNonvirtualDoubleMethodA = 90,
|
|
113
|
-
|
|
114
88
|
CallNonvirtualVoidMethod = 91,
|
|
115
89
|
CallNonvirtualVoidMethodV = 92,
|
|
116
90
|
CallNonvirtualVoidMethodA = 93,
|
|
117
|
-
|
|
118
91
|
GetFieldID = 94,
|
|
119
92
|
GetObjectField = 95,
|
|
120
93
|
GetBooleanField = 96,
|
|
@@ -125,49 +98,37 @@ export enum JNI_VT {
|
|
|
125
98
|
GetLongField = 101,
|
|
126
99
|
GetFloatField = 102,
|
|
127
100
|
GetDoubleField = 103,
|
|
128
|
-
|
|
129
101
|
GetStaticMethodID = 113,
|
|
130
|
-
|
|
131
102
|
CallStaticObjectMethod = 114,
|
|
132
103
|
CallStaticObjectMethodV = 115,
|
|
133
104
|
CallStaticObjectMethodA = 116,
|
|
134
|
-
|
|
135
105
|
CallStaticBooleanMethod = 117,
|
|
136
106
|
CallStaticBooleanMethodV = 118,
|
|
137
107
|
CallStaticBooleanMethodA = 119,
|
|
138
|
-
|
|
139
108
|
CallStaticByteMethod = 120,
|
|
140
109
|
CallStaticByteMethodV = 121,
|
|
141
110
|
CallStaticByteMethodA = 122,
|
|
142
|
-
|
|
143
111
|
CallStaticCharMethod = 123,
|
|
144
112
|
CallStaticCharMethodV = 124,
|
|
145
113
|
CallStaticCharMethodA = 125,
|
|
146
|
-
|
|
147
114
|
CallStaticShortMethod = 126,
|
|
148
115
|
CallStaticShortMethodV = 127,
|
|
149
116
|
CallStaticShortMethodA = 128,
|
|
150
|
-
|
|
151
117
|
CallStaticIntMethod = 129,
|
|
152
118
|
CallStaticIntMethodV = 130,
|
|
153
119
|
CallStaticIntMethodA = 131,
|
|
154
|
-
|
|
155
120
|
CallStaticLongMethod = 132,
|
|
156
121
|
CallStaticLongMethodV = 133,
|
|
157
122
|
CallStaticLongMethodA = 134,
|
|
158
|
-
|
|
159
123
|
CallStaticFloatMethod = 135,
|
|
160
124
|
CallStaticFloatMethodV = 136,
|
|
161
125
|
CallStaticFloatMethodA = 137,
|
|
162
|
-
|
|
163
126
|
CallStaticDoubleMethod = 138,
|
|
164
127
|
CallStaticDoubleMethodV = 139,
|
|
165
128
|
CallStaticDoubleMethodA = 140,
|
|
166
|
-
|
|
167
129
|
CallStaticVoidMethod = 141,
|
|
168
130
|
CallStaticVoidMethodV = 142,
|
|
169
131
|
CallStaticVoidMethodA = 143,
|
|
170
|
-
|
|
171
132
|
GetStaticFieldID = 144,
|
|
172
133
|
GetStaticObjectField = 145,
|
|
173
134
|
GetStaticBooleanField = 146,
|
|
@@ -178,18 +139,14 @@ export enum JNI_VT {
|
|
|
178
139
|
GetStaticLongField = 151,
|
|
179
140
|
GetStaticFloatField = 152,
|
|
180
141
|
GetStaticDoubleField = 153,
|
|
181
|
-
|
|
182
142
|
GetStringLength = 164,
|
|
183
143
|
GetStringChars = 165,
|
|
184
144
|
ReleaseStringChars = 166,
|
|
185
|
-
|
|
186
145
|
GetStringUTFLength = 168,
|
|
187
146
|
GetStringUTFChars = 169,
|
|
188
147
|
ReleaseStringUTFChars = 170,
|
|
189
|
-
|
|
190
148
|
GetArrayLength = 171,
|
|
191
149
|
GetObjectArrayElement = 173,
|
|
192
|
-
|
|
193
150
|
GetBooleanArrayElements = 183,
|
|
194
151
|
GetByteArrayElements = 184,
|
|
195
152
|
GetCharArrayElements = 185,
|
|
@@ -198,7 +155,6 @@ export enum JNI_VT {
|
|
|
198
155
|
GetLongArrayElements = 188,
|
|
199
156
|
GetFloatArrayElements = 189,
|
|
200
157
|
GetDoubleArrayElements = 190,
|
|
201
|
-
|
|
202
158
|
ReleaseBooleanArrayElements = 191,
|
|
203
159
|
ReleaseByteArrayElements = 192,
|
|
204
160
|
ReleaseCharArrayElements = 193,
|
|
@@ -207,11 +163,9 @@ export enum JNI_VT {
|
|
|
207
163
|
ReleaseLongArrayElements = 196,
|
|
208
164
|
ReleaseFloatArrayElements = 197,
|
|
209
165
|
ReleaseDoubleArrayElements = 198,
|
|
210
|
-
|
|
211
166
|
RegisterNatives = 215,
|
|
212
167
|
UnregisterNatives = 216,
|
|
213
|
-
|
|
214
168
|
GetStringCritical = 224,
|
|
215
169
|
DeleteWeakGlobalRef = 227,
|
|
216
|
-
ExceptionCheck = 228
|
|
170
|
+
ExceptionCheck = 228
|
|
217
171
|
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
export var IndirectRefKind;
|
|
2
|
+
(function (IndirectRefKind) {
|
|
3
|
+
IndirectRefKind[IndirectRefKind["kHandleScopeOrInvalid"] = 0] = "kHandleScopeOrInvalid";
|
|
4
|
+
IndirectRefKind[IndirectRefKind["kLocal"] = 1] = "kLocal";
|
|
5
|
+
IndirectRefKind[IndirectRefKind["kGlobal"] = 2] = "kGlobal";
|
|
6
|
+
IndirectRefKind[IndirectRefKind["kWeakGlobal"] = 3] = "kWeakGlobal";
|
|
7
|
+
IndirectRefKind[IndirectRefKind["kLastKind"] = 3] = "kLastKind";
|
|
8
|
+
})(IndirectRefKind || (IndirectRefKind = {}));
|
|
9
|
+
export var JNI_VT;
|
|
10
|
+
(function (JNI_VT) {
|
|
11
|
+
JNI_VT[JNI_VT["FindClass"] = 6] = "FindClass";
|
|
12
|
+
JNI_VT[JNI_VT["FromReflectedMethod"] = 7] = "FromReflectedMethod";
|
|
13
|
+
JNI_VT[JNI_VT["ToReflectedMethod"] = 9] = "ToReflectedMethod";
|
|
14
|
+
JNI_VT[JNI_VT["GetSuperclass"] = 10] = "GetSuperclass";
|
|
15
|
+
JNI_VT[JNI_VT["Throw"] = 13] = "Throw";
|
|
16
|
+
JNI_VT[JNI_VT["ThrowNew"] = 14] = "ThrowNew";
|
|
17
|
+
JNI_VT[JNI_VT["ExceptionOccurred"] = 15] = "ExceptionOccurred";
|
|
18
|
+
JNI_VT[JNI_VT["ExceptionDescribe"] = 16] = "ExceptionDescribe";
|
|
19
|
+
JNI_VT[JNI_VT["ExceptionClear"] = 17] = "ExceptionClear";
|
|
20
|
+
JNI_VT[JNI_VT["FatalError"] = 18] = "FatalError";
|
|
21
|
+
JNI_VT[JNI_VT["PushLocalFrame"] = 19] = "PushLocalFrame";
|
|
22
|
+
JNI_VT[JNI_VT["PopLocalFrame"] = 20] = "PopLocalFrame";
|
|
23
|
+
JNI_VT[JNI_VT["NewGlobalRef"] = 21] = "NewGlobalRef";
|
|
24
|
+
JNI_VT[JNI_VT["DeleteGlobalRef"] = 22] = "DeleteGlobalRef";
|
|
25
|
+
JNI_VT[JNI_VT["DeleteLocalRef"] = 23] = "DeleteLocalRef";
|
|
26
|
+
JNI_VT[JNI_VT["NewLocalRef"] = 23] = "NewLocalRef";
|
|
27
|
+
JNI_VT[JNI_VT["IsSameObject"] = 24] = "IsSameObject";
|
|
28
|
+
JNI_VT[JNI_VT["NewObject"] = 28] = "NewObject";
|
|
29
|
+
JNI_VT[JNI_VT["NewObjectV"] = 29] = "NewObjectV";
|
|
30
|
+
JNI_VT[JNI_VT["NewObjectA"] = 30] = "NewObjectA";
|
|
31
|
+
JNI_VT[JNI_VT["GetObjectClass"] = 31] = "GetObjectClass";
|
|
32
|
+
JNI_VT[JNI_VT["GetMethodID"] = 33] = "GetMethodID";
|
|
33
|
+
JNI_VT[JNI_VT["CallObjectMethod"] = 34] = "CallObjectMethod";
|
|
34
|
+
JNI_VT[JNI_VT["CallObjectMethodV"] = 35] = "CallObjectMethodV";
|
|
35
|
+
JNI_VT[JNI_VT["CallObjectMethodA"] = 36] = "CallObjectMethodA";
|
|
36
|
+
JNI_VT[JNI_VT["CallBooleanMethod"] = 37] = "CallBooleanMethod";
|
|
37
|
+
JNI_VT[JNI_VT["CallBooleanMethodV"] = 38] = "CallBooleanMethodV";
|
|
38
|
+
JNI_VT[JNI_VT["CallBooleanMethodA"] = 39] = "CallBooleanMethodA";
|
|
39
|
+
JNI_VT[JNI_VT["CallByteMethod"] = 40] = "CallByteMethod";
|
|
40
|
+
JNI_VT[JNI_VT["CallByteMethodV"] = 41] = "CallByteMethodV";
|
|
41
|
+
JNI_VT[JNI_VT["CallByteMethodA"] = 42] = "CallByteMethodA";
|
|
42
|
+
JNI_VT[JNI_VT["CallCharMethod"] = 43] = "CallCharMethod";
|
|
43
|
+
JNI_VT[JNI_VT["CallCharMethodV"] = 44] = "CallCharMethodV";
|
|
44
|
+
JNI_VT[JNI_VT["CallCharMethodA"] = 45] = "CallCharMethodA";
|
|
45
|
+
JNI_VT[JNI_VT["CallShortMethod"] = 46] = "CallShortMethod";
|
|
46
|
+
JNI_VT[JNI_VT["CallShortMethodV"] = 47] = "CallShortMethodV";
|
|
47
|
+
JNI_VT[JNI_VT["CallShortMethodA"] = 48] = "CallShortMethodA";
|
|
48
|
+
JNI_VT[JNI_VT["CallIntMethod"] = 49] = "CallIntMethod";
|
|
49
|
+
JNI_VT[JNI_VT["CallIntMethodV"] = 50] = "CallIntMethodV";
|
|
50
|
+
JNI_VT[JNI_VT["CallIntMethodA"] = 51] = "CallIntMethodA";
|
|
51
|
+
JNI_VT[JNI_VT["CallLongMethod"] = 52] = "CallLongMethod";
|
|
52
|
+
JNI_VT[JNI_VT["CallLongMethodV"] = 53] = "CallLongMethodV";
|
|
53
|
+
JNI_VT[JNI_VT["CallLongMethodA"] = 54] = "CallLongMethodA";
|
|
54
|
+
JNI_VT[JNI_VT["CallFloatMethod"] = 55] = "CallFloatMethod";
|
|
55
|
+
JNI_VT[JNI_VT["CallFloatMethodV"] = 56] = "CallFloatMethodV";
|
|
56
|
+
JNI_VT[JNI_VT["CallFloatMethodA"] = 57] = "CallFloatMethodA";
|
|
57
|
+
JNI_VT[JNI_VT["CallDoubleMethod"] = 58] = "CallDoubleMethod";
|
|
58
|
+
JNI_VT[JNI_VT["CallDoubleMethodV"] = 59] = "CallDoubleMethodV";
|
|
59
|
+
JNI_VT[JNI_VT["CallDoubleMethodA"] = 60] = "CallDoubleMethodA";
|
|
60
|
+
JNI_VT[JNI_VT["CallVoidMethod"] = 61] = "CallVoidMethod";
|
|
61
|
+
JNI_VT[JNI_VT["CallVoidMethodV"] = 62] = "CallVoidMethodV";
|
|
62
|
+
JNI_VT[JNI_VT["CallVoidMethodA"] = 63] = "CallVoidMethodA";
|
|
63
|
+
JNI_VT[JNI_VT["CallNonvirtualObjectMethod"] = 64] = "CallNonvirtualObjectMethod";
|
|
64
|
+
JNI_VT[JNI_VT["CallNonvirtualObjectMethodV"] = 65] = "CallNonvirtualObjectMethodV";
|
|
65
|
+
JNI_VT[JNI_VT["CallNonvirtualObjectMethodA"] = 66] = "CallNonvirtualObjectMethodA";
|
|
66
|
+
JNI_VT[JNI_VT["CallNonvirtualBooleanMethod"] = 67] = "CallNonvirtualBooleanMethod";
|
|
67
|
+
JNI_VT[JNI_VT["CallNonvirtualBooleanMethodV"] = 68] = "CallNonvirtualBooleanMethodV";
|
|
68
|
+
JNI_VT[JNI_VT["CallNonvirtualBooleanMethodA"] = 69] = "CallNonvirtualBooleanMethodA";
|
|
69
|
+
JNI_VT[JNI_VT["CallNonvirtualByteMethod"] = 70] = "CallNonvirtualByteMethod";
|
|
70
|
+
JNI_VT[JNI_VT["CallNonvirtualByteMethodV"] = 71] = "CallNonvirtualByteMethodV";
|
|
71
|
+
JNI_VT[JNI_VT["CallNonvirtualByteMethodA"] = 72] = "CallNonvirtualByteMethodA";
|
|
72
|
+
JNI_VT[JNI_VT["CallNonvirtualCharMethod"] = 73] = "CallNonvirtualCharMethod";
|
|
73
|
+
JNI_VT[JNI_VT["CallNonvirtualCharMethodV"] = 74] = "CallNonvirtualCharMethodV";
|
|
74
|
+
JNI_VT[JNI_VT["CallNonvirtualCharMethodA"] = 75] = "CallNonvirtualCharMethodA";
|
|
75
|
+
JNI_VT[JNI_VT["CallNonvirtualShortMethod"] = 76] = "CallNonvirtualShortMethod";
|
|
76
|
+
JNI_VT[JNI_VT["CallNonvirtualShortMethodV"] = 77] = "CallNonvirtualShortMethodV";
|
|
77
|
+
JNI_VT[JNI_VT["CallNonvirtualShortMethodA"] = 78] = "CallNonvirtualShortMethodA";
|
|
78
|
+
JNI_VT[JNI_VT["CallNonvirtualIntMethod"] = 79] = "CallNonvirtualIntMethod";
|
|
79
|
+
JNI_VT[JNI_VT["CallNonvirtualIntMethodV"] = 80] = "CallNonvirtualIntMethodV";
|
|
80
|
+
JNI_VT[JNI_VT["CallNonvirtualIntMethodA"] = 81] = "CallNonvirtualIntMethodA";
|
|
81
|
+
JNI_VT[JNI_VT["CallNonvirtualLongMethod"] = 82] = "CallNonvirtualLongMethod";
|
|
82
|
+
JNI_VT[JNI_VT["CallNonvirtualLongMethodV"] = 83] = "CallNonvirtualLongMethodV";
|
|
83
|
+
JNI_VT[JNI_VT["CallNonvirtualLongMethodA"] = 84] = "CallNonvirtualLongMethodA";
|
|
84
|
+
JNI_VT[JNI_VT["CallNonvirtualFloatMethod"] = 85] = "CallNonvirtualFloatMethod";
|
|
85
|
+
JNI_VT[JNI_VT["CallNonvirtualFloatMethodV"] = 86] = "CallNonvirtualFloatMethodV";
|
|
86
|
+
JNI_VT[JNI_VT["CallNonvirtualFloatMethodA"] = 87] = "CallNonvirtualFloatMethodA";
|
|
87
|
+
JNI_VT[JNI_VT["CallNonvirtualDoubleMethod"] = 88] = "CallNonvirtualDoubleMethod";
|
|
88
|
+
JNI_VT[JNI_VT["CallNonvirtualDoubleMethodV"] = 89] = "CallNonvirtualDoubleMethodV";
|
|
89
|
+
JNI_VT[JNI_VT["CallNonvirtualDoubleMethodA"] = 90] = "CallNonvirtualDoubleMethodA";
|
|
90
|
+
JNI_VT[JNI_VT["CallNonvirtualVoidMethod"] = 91] = "CallNonvirtualVoidMethod";
|
|
91
|
+
JNI_VT[JNI_VT["CallNonvirtualVoidMethodV"] = 92] = "CallNonvirtualVoidMethodV";
|
|
92
|
+
JNI_VT[JNI_VT["CallNonvirtualVoidMethodA"] = 93] = "CallNonvirtualVoidMethodA";
|
|
93
|
+
JNI_VT[JNI_VT["GetFieldID"] = 94] = "GetFieldID";
|
|
94
|
+
JNI_VT[JNI_VT["GetObjectField"] = 95] = "GetObjectField";
|
|
95
|
+
JNI_VT[JNI_VT["GetBooleanField"] = 96] = "GetBooleanField";
|
|
96
|
+
JNI_VT[JNI_VT["GetByteField"] = 97] = "GetByteField";
|
|
97
|
+
JNI_VT[JNI_VT["GetCharField"] = 98] = "GetCharField";
|
|
98
|
+
JNI_VT[JNI_VT["GetShortField"] = 99] = "GetShortField";
|
|
99
|
+
JNI_VT[JNI_VT["GetIntField"] = 100] = "GetIntField";
|
|
100
|
+
JNI_VT[JNI_VT["GetLongField"] = 101] = "GetLongField";
|
|
101
|
+
JNI_VT[JNI_VT["GetFloatField"] = 102] = "GetFloatField";
|
|
102
|
+
JNI_VT[JNI_VT["GetDoubleField"] = 103] = "GetDoubleField";
|
|
103
|
+
JNI_VT[JNI_VT["GetStaticMethodID"] = 113] = "GetStaticMethodID";
|
|
104
|
+
JNI_VT[JNI_VT["CallStaticObjectMethod"] = 114] = "CallStaticObjectMethod";
|
|
105
|
+
JNI_VT[JNI_VT["CallStaticObjectMethodV"] = 115] = "CallStaticObjectMethodV";
|
|
106
|
+
JNI_VT[JNI_VT["CallStaticObjectMethodA"] = 116] = "CallStaticObjectMethodA";
|
|
107
|
+
JNI_VT[JNI_VT["CallStaticBooleanMethod"] = 117] = "CallStaticBooleanMethod";
|
|
108
|
+
JNI_VT[JNI_VT["CallStaticBooleanMethodV"] = 118] = "CallStaticBooleanMethodV";
|
|
109
|
+
JNI_VT[JNI_VT["CallStaticBooleanMethodA"] = 119] = "CallStaticBooleanMethodA";
|
|
110
|
+
JNI_VT[JNI_VT["CallStaticByteMethod"] = 120] = "CallStaticByteMethod";
|
|
111
|
+
JNI_VT[JNI_VT["CallStaticByteMethodV"] = 121] = "CallStaticByteMethodV";
|
|
112
|
+
JNI_VT[JNI_VT["CallStaticByteMethodA"] = 122] = "CallStaticByteMethodA";
|
|
113
|
+
JNI_VT[JNI_VT["CallStaticCharMethod"] = 123] = "CallStaticCharMethod";
|
|
114
|
+
JNI_VT[JNI_VT["CallStaticCharMethodV"] = 124] = "CallStaticCharMethodV";
|
|
115
|
+
JNI_VT[JNI_VT["CallStaticCharMethodA"] = 125] = "CallStaticCharMethodA";
|
|
116
|
+
JNI_VT[JNI_VT["CallStaticShortMethod"] = 126] = "CallStaticShortMethod";
|
|
117
|
+
JNI_VT[JNI_VT["CallStaticShortMethodV"] = 127] = "CallStaticShortMethodV";
|
|
118
|
+
JNI_VT[JNI_VT["CallStaticShortMethodA"] = 128] = "CallStaticShortMethodA";
|
|
119
|
+
JNI_VT[JNI_VT["CallStaticIntMethod"] = 129] = "CallStaticIntMethod";
|
|
120
|
+
JNI_VT[JNI_VT["CallStaticIntMethodV"] = 130] = "CallStaticIntMethodV";
|
|
121
|
+
JNI_VT[JNI_VT["CallStaticIntMethodA"] = 131] = "CallStaticIntMethodA";
|
|
122
|
+
JNI_VT[JNI_VT["CallStaticLongMethod"] = 132] = "CallStaticLongMethod";
|
|
123
|
+
JNI_VT[JNI_VT["CallStaticLongMethodV"] = 133] = "CallStaticLongMethodV";
|
|
124
|
+
JNI_VT[JNI_VT["CallStaticLongMethodA"] = 134] = "CallStaticLongMethodA";
|
|
125
|
+
JNI_VT[JNI_VT["CallStaticFloatMethod"] = 135] = "CallStaticFloatMethod";
|
|
126
|
+
JNI_VT[JNI_VT["CallStaticFloatMethodV"] = 136] = "CallStaticFloatMethodV";
|
|
127
|
+
JNI_VT[JNI_VT["CallStaticFloatMethodA"] = 137] = "CallStaticFloatMethodA";
|
|
128
|
+
JNI_VT[JNI_VT["CallStaticDoubleMethod"] = 138] = "CallStaticDoubleMethod";
|
|
129
|
+
JNI_VT[JNI_VT["CallStaticDoubleMethodV"] = 139] = "CallStaticDoubleMethodV";
|
|
130
|
+
JNI_VT[JNI_VT["CallStaticDoubleMethodA"] = 140] = "CallStaticDoubleMethodA";
|
|
131
|
+
JNI_VT[JNI_VT["CallStaticVoidMethod"] = 141] = "CallStaticVoidMethod";
|
|
132
|
+
JNI_VT[JNI_VT["CallStaticVoidMethodV"] = 142] = "CallStaticVoidMethodV";
|
|
133
|
+
JNI_VT[JNI_VT["CallStaticVoidMethodA"] = 143] = "CallStaticVoidMethodA";
|
|
134
|
+
JNI_VT[JNI_VT["GetStaticFieldID"] = 144] = "GetStaticFieldID";
|
|
135
|
+
JNI_VT[JNI_VT["GetStaticObjectField"] = 145] = "GetStaticObjectField";
|
|
136
|
+
JNI_VT[JNI_VT["GetStaticBooleanField"] = 146] = "GetStaticBooleanField";
|
|
137
|
+
JNI_VT[JNI_VT["GetStaticByteField"] = 147] = "GetStaticByteField";
|
|
138
|
+
JNI_VT[JNI_VT["GetStaticCharField"] = 148] = "GetStaticCharField";
|
|
139
|
+
JNI_VT[JNI_VT["GetStaticShortField"] = 149] = "GetStaticShortField";
|
|
140
|
+
JNI_VT[JNI_VT["GetStaticIntField"] = 150] = "GetStaticIntField";
|
|
141
|
+
JNI_VT[JNI_VT["GetStaticLongField"] = 151] = "GetStaticLongField";
|
|
142
|
+
JNI_VT[JNI_VT["GetStaticFloatField"] = 152] = "GetStaticFloatField";
|
|
143
|
+
JNI_VT[JNI_VT["GetStaticDoubleField"] = 153] = "GetStaticDoubleField";
|
|
144
|
+
JNI_VT[JNI_VT["GetStringLength"] = 164] = "GetStringLength";
|
|
145
|
+
JNI_VT[JNI_VT["GetStringChars"] = 165] = "GetStringChars";
|
|
146
|
+
JNI_VT[JNI_VT["ReleaseStringChars"] = 166] = "ReleaseStringChars";
|
|
147
|
+
JNI_VT[JNI_VT["GetStringUTFLength"] = 168] = "GetStringUTFLength";
|
|
148
|
+
JNI_VT[JNI_VT["GetStringUTFChars"] = 169] = "GetStringUTFChars";
|
|
149
|
+
JNI_VT[JNI_VT["ReleaseStringUTFChars"] = 170] = "ReleaseStringUTFChars";
|
|
150
|
+
JNI_VT[JNI_VT["GetArrayLength"] = 171] = "GetArrayLength";
|
|
151
|
+
JNI_VT[JNI_VT["GetObjectArrayElement"] = 173] = "GetObjectArrayElement";
|
|
152
|
+
JNI_VT[JNI_VT["GetBooleanArrayElements"] = 183] = "GetBooleanArrayElements";
|
|
153
|
+
JNI_VT[JNI_VT["GetByteArrayElements"] = 184] = "GetByteArrayElements";
|
|
154
|
+
JNI_VT[JNI_VT["GetCharArrayElements"] = 185] = "GetCharArrayElements";
|
|
155
|
+
JNI_VT[JNI_VT["GetShortArrayElements"] = 186] = "GetShortArrayElements";
|
|
156
|
+
JNI_VT[JNI_VT["GetIntArrayElements"] = 187] = "GetIntArrayElements";
|
|
157
|
+
JNI_VT[JNI_VT["GetLongArrayElements"] = 188] = "GetLongArrayElements";
|
|
158
|
+
JNI_VT[JNI_VT["GetFloatArrayElements"] = 189] = "GetFloatArrayElements";
|
|
159
|
+
JNI_VT[JNI_VT["GetDoubleArrayElements"] = 190] = "GetDoubleArrayElements";
|
|
160
|
+
JNI_VT[JNI_VT["ReleaseBooleanArrayElements"] = 191] = "ReleaseBooleanArrayElements";
|
|
161
|
+
JNI_VT[JNI_VT["ReleaseByteArrayElements"] = 192] = "ReleaseByteArrayElements";
|
|
162
|
+
JNI_VT[JNI_VT["ReleaseCharArrayElements"] = 193] = "ReleaseCharArrayElements";
|
|
163
|
+
JNI_VT[JNI_VT["ReleaseShortArrayElements"] = 194] = "ReleaseShortArrayElements";
|
|
164
|
+
JNI_VT[JNI_VT["ReleaseIntArrayElements"] = 195] = "ReleaseIntArrayElements";
|
|
165
|
+
JNI_VT[JNI_VT["ReleaseLongArrayElements"] = 196] = "ReleaseLongArrayElements";
|
|
166
|
+
JNI_VT[JNI_VT["ReleaseFloatArrayElements"] = 197] = "ReleaseFloatArrayElements";
|
|
167
|
+
JNI_VT[JNI_VT["ReleaseDoubleArrayElements"] = 198] = "ReleaseDoubleArrayElements";
|
|
168
|
+
JNI_VT[JNI_VT["RegisterNatives"] = 215] = "RegisterNatives";
|
|
169
|
+
JNI_VT[JNI_VT["UnregisterNatives"] = 216] = "UnregisterNatives";
|
|
170
|
+
JNI_VT[JNI_VT["GetStringCritical"] = 224] = "GetStringCritical";
|
|
171
|
+
JNI_VT[JNI_VT["DeleteWeakGlobalRef"] = 227] = "DeleteWeakGlobalRef";
|
|
172
|
+
JNI_VT[JNI_VT["ExceptionCheck"] = 228] = "ExceptionCheck";
|
|
173
|
+
})(JNI_VT || (JNI_VT = {}));
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare class Libc {
|
|
2
|
+
constructor();
|
|
3
|
+
static readonly $libc: Module;
|
|
4
|
+
$lazyLoadFunc<RetType extends NativeFunctionReturnType, ArgTypes extends NativeFunctionArgumentType[] | []>(symName: string, retType: RetType, argTypes: ArgTypes): NativeFunction<GetNativeFunctionReturnValue<RetType>, ResolveVariadic<Extract<GetNativeFunctionArgumentValue<ArgTypes>, unknown[]>>> & {
|
|
5
|
+
$handle: NativePointer | undefined;
|
|
6
|
+
};
|
|
7
|
+
$nativeFunc<RetType extends NativeFunctionReturnType, ArgTypes extends NativeFunctionArgumentType[] | []>(symName: string, retType: RetType, argTypes: ArgTypes): NativeFunction<GetNativeFunctionReturnValue<RetType>, ResolveVariadic<Extract<GetNativeFunctionArgumentValue<ArgTypes>, unknown[]>>> & {
|
|
8
|
+
$handle: NativePointer | undefined;
|
|
9
|
+
};
|
|
10
|
+
readonly $readlink: NativeFunction<number, [NativePointerValue, NativePointerValue, number | UInt64]> & {
|
|
11
|
+
$handle: NativePointer | undefined;
|
|
12
|
+
};
|
|
13
|
+
readlink(pathname: string, bufsize?: number): string | null;
|
|
14
|
+
readonly $opendir: NativeFunction<NativePointer, [NativePointerValue]> & {
|
|
15
|
+
$handle: NativePointer | undefined;
|
|
16
|
+
};
|
|
17
|
+
opendir(path: string): NativePointer;
|
|
18
|
+
readonly $fopen: NativeFunction<NativePointer, [NativePointerValue, NativePointerValue]> & {
|
|
19
|
+
$handle: NativePointer | undefined;
|
|
20
|
+
};
|
|
21
|
+
fopen(pathname: string, mode: string): NativePointer;
|
|
22
|
+
readonly fclose: NativeFunction<number, [NativePointerValue]> & {
|
|
23
|
+
$handle: NativePointer | undefined;
|
|
24
|
+
};
|
|
25
|
+
readonly $fputs: NativeFunction<number, [NativePointerValue, NativePointerValue]> & {
|
|
26
|
+
$handle: NativePointer | undefined;
|
|
27
|
+
};
|
|
28
|
+
fputs(str: string, file: NativePointer): number;
|
|
29
|
+
readonly fflush: NativeFunction<number, [NativePointerValue]> & {
|
|
30
|
+
$handle: NativePointer | undefined;
|
|
31
|
+
};
|
|
32
|
+
readonly readdir: NativeFunction<NativePointer, [NativePointerValue]> & {
|
|
33
|
+
$handle: NativePointer | undefined;
|
|
34
|
+
};
|
|
35
|
+
readonly closedir: NativeFunction<number, [NativePointerValue]> & {
|
|
36
|
+
$handle: NativePointer | undefined;
|
|
37
|
+
};
|
|
38
|
+
readonly fileno: NativeFunction<number, [NativePointerValue]> & {
|
|
39
|
+
$handle: NativePointer | undefined;
|
|
40
|
+
};
|
|
41
|
+
readonly pthread_self: NativeFunction<Int64, []> & {
|
|
42
|
+
$handle: NativePointer | undefined;
|
|
43
|
+
};
|
|
44
|
+
readonly getpid: NativeFunction<number, []> & {
|
|
45
|
+
$handle: NativePointer | undefined;
|
|
46
|
+
};
|
|
47
|
+
readonly getuid: NativeFunction<number, []> & {
|
|
48
|
+
$handle: NativePointer | undefined;
|
|
49
|
+
};
|
|
50
|
+
readonly gettid: NativeFunction<number, []> & {
|
|
51
|
+
$handle: NativePointer | undefined;
|
|
52
|
+
};
|
|
53
|
+
readonly $clock_gettime: NativeFunction<number, [number, NativePointerValue]> & {
|
|
54
|
+
$handle: NativePointer | undefined;
|
|
55
|
+
};
|
|
56
|
+
clock_gettime(clk_id: number): {
|
|
57
|
+
tv_sec: number;
|
|
58
|
+
tv_nsec: number;
|
|
59
|
+
} | null;
|
|
60
|
+
readonly $__system_property_get: NativeFunction<number, [NativePointerValue, NativePointerValue]> & {
|
|
61
|
+
$handle: NativePointer | undefined;
|
|
62
|
+
};
|
|
63
|
+
__system_property_get(name: string): string;
|
|
64
|
+
readonly $getcwd: NativeFunction<NativePointer, [NativePointerValue, number | UInt64]> & {
|
|
65
|
+
$handle: NativePointer | undefined;
|
|
66
|
+
};
|
|
67
|
+
getcwd(): string | null;
|
|
68
|
+
}
|
package/dist/lib/libc.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { mustType } from "../utils/utils.js";
|
|
2
|
+
import { nativeFunctionOptions } from "../consts.js";
|
|
3
|
+
const PROP_VALUE_MAX = 92;
|
|
4
|
+
export class Libc {
|
|
5
|
+
constructor() {
|
|
6
|
+
// ssize_t readlink(const char *pathname, char *buf, size_t bufsiz);
|
|
7
|
+
this.$readlink = this.$lazyLoadFunc('readlink', 'int', ['pointer', 'pointer', 'size_t']);
|
|
8
|
+
// DIR *opendir(const char *name);
|
|
9
|
+
this.$opendir = this.$lazyLoadFunc('opendir', 'pointer', ['pointer']);
|
|
10
|
+
// FILE *fopen(const char *pathname, const char *mode);
|
|
11
|
+
this.$fopen = this.$lazyLoadFunc('fopen', 'pointer', ['pointer', 'pointer']);
|
|
12
|
+
// int fclose(FILE *stream);
|
|
13
|
+
this.fclose = this.$lazyLoadFunc('fclose', 'int', ['pointer']);
|
|
14
|
+
// int fputs(const char *str, FILE *stream);
|
|
15
|
+
this.$fputs = this.$lazyLoadFunc('fputs', 'int', ['pointer', 'pointer']);
|
|
16
|
+
// int fflush(FILE *stream);
|
|
17
|
+
this.fflush = this.$lazyLoadFunc('fflush', 'int', ['pointer']);
|
|
18
|
+
// struct dirent *readdir(DIR *dirp);
|
|
19
|
+
this.readdir = this.$lazyLoadFunc('readdir', 'pointer', ['pointer']);
|
|
20
|
+
// int closedir(DIR *dirp);
|
|
21
|
+
this.closedir = this.$lazyLoadFunc('closedir', 'int', ['pointer']);
|
|
22
|
+
// int fileno(FILE *stream);
|
|
23
|
+
this.fileno = this.$lazyLoadFunc('fileno', 'int', ['pointer']);
|
|
24
|
+
// pthread_t pthread_self(void);
|
|
25
|
+
this.pthread_self = this.$lazyLoadFunc('pthread_self', 'int64', []);
|
|
26
|
+
// pid_t getpid(void);
|
|
27
|
+
this.getpid = this.$lazyLoadFunc('getpid', 'uint', []);
|
|
28
|
+
// uid_t getuid(void);
|
|
29
|
+
this.getuid = this.$lazyLoadFunc('getuid', 'uint', []);
|
|
30
|
+
// pid_t gettid(void);
|
|
31
|
+
this.gettid = this.$lazyLoadFunc('gettid', 'uint', []);
|
|
32
|
+
// int clock_gettime(clockid_t clk_id, struct timespec *tp);
|
|
33
|
+
this.$clock_gettime = this.$lazyLoadFunc('clock_gettime', 'int', ['int', 'pointer']);
|
|
34
|
+
// int __system_property_get(const char *name, char *value);
|
|
35
|
+
this.$__system_property_get = this.$lazyLoadFunc('__system_property_get', 'int', ['pointer', 'pointer']);
|
|
36
|
+
// char *getcwd(char *buf, size_t size);
|
|
37
|
+
this.$getcwd = this.$lazyLoadFunc('getcwd', 'pointer', ['pointer', 'size_t']);
|
|
38
|
+
return new Proxy(this, {
|
|
39
|
+
get(target, prop) {
|
|
40
|
+
if (prop in target) {
|
|
41
|
+
return target[prop];
|
|
42
|
+
}
|
|
43
|
+
if (prop[0] !== '$') {
|
|
44
|
+
return target['$' + prop];
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return target[prop.substring(1)];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
$lazyLoadFunc(symName, retType, argTypes) {
|
|
53
|
+
let func = null;
|
|
54
|
+
const wrapper = ((...args) => {
|
|
55
|
+
if (func === null) {
|
|
56
|
+
func = this.$nativeFunc(symName, retType, argTypes);
|
|
57
|
+
}
|
|
58
|
+
const ret = func(...args);
|
|
59
|
+
return ret;
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(wrapper, '$handle', {
|
|
62
|
+
get() {
|
|
63
|
+
if (func === null) {
|
|
64
|
+
func = this.$nativeFunc(symName, retType, argTypes);
|
|
65
|
+
}
|
|
66
|
+
return func.$handle;
|
|
67
|
+
},
|
|
68
|
+
enumerable: true,
|
|
69
|
+
});
|
|
70
|
+
return wrapper;
|
|
71
|
+
}
|
|
72
|
+
$nativeFunc(symName, retType, argTypes) {
|
|
73
|
+
const handle = mustType(Libc.$libc.findExportByName(symName));
|
|
74
|
+
const fn = new NativeFunction(handle, retType, argTypes, nativeFunctionOptions);
|
|
75
|
+
fn.$handle = handle;
|
|
76
|
+
return fn;
|
|
77
|
+
}
|
|
78
|
+
readlink(pathname, bufsize = 256) {
|
|
79
|
+
const cfdPath = Memory.allocUtf8String(pathname);
|
|
80
|
+
const resolvedPath = Memory.alloc(bufsize);
|
|
81
|
+
const result = this.$readlink(cfdPath, resolvedPath, bufsize);
|
|
82
|
+
let link = null;
|
|
83
|
+
if (result !== -1) {
|
|
84
|
+
link = resolvedPath.readCString();
|
|
85
|
+
}
|
|
86
|
+
return link;
|
|
87
|
+
}
|
|
88
|
+
opendir(path) {
|
|
89
|
+
const cpath = Memory.allocUtf8String(path);
|
|
90
|
+
const dir = this.$opendir(cpath);
|
|
91
|
+
return dir;
|
|
92
|
+
}
|
|
93
|
+
fopen(pathname, mode) {
|
|
94
|
+
return this.$fopen(Memory.allocUtf8String(pathname), Memory.allocUtf8String(mode));
|
|
95
|
+
}
|
|
96
|
+
fputs(str, file) {
|
|
97
|
+
return this.$fputs(Memory.allocUtf8String(str), file);
|
|
98
|
+
}
|
|
99
|
+
clock_gettime(clk_id) {
|
|
100
|
+
const ps = Process.pointerSize;
|
|
101
|
+
const tv = Memory.alloc(ps * 2);
|
|
102
|
+
const ret = this.$clock_gettime(clk_id, tv);
|
|
103
|
+
if (ret != 0) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
tv_sec: Number(tv[ps === 8 ? 'readU64' : 'readU32']()),
|
|
108
|
+
tv_nsec: Number(tv.add(ps)[ps === 8 ? 'readU64' : 'readU32']()),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
__system_property_get(name) {
|
|
112
|
+
const sdk_version_value = Memory.alloc(PROP_VALUE_MAX);
|
|
113
|
+
const ret = this.$__system_property_get(Memory.allocUtf8String(name), sdk_version_value);
|
|
114
|
+
if (ret < 0) {
|
|
115
|
+
console.error(`[__system_property_get] name[${name}] error[${ret}]`);
|
|
116
|
+
}
|
|
117
|
+
return sdk_version_value.readCString(ret) || '';
|
|
118
|
+
}
|
|
119
|
+
getcwd() {
|
|
120
|
+
const buff_size = 256;
|
|
121
|
+
const buff = Memory.alloc(buff_size);
|
|
122
|
+
return this.$getcwd(buff, buff_size).readCString();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
Libc.$libc = Process.findModuleByName('libc.so') || Module.load('libc.so');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ElfModuleX } from "../elf/module.js";
|
|
2
|
+
export declare class Libssl {
|
|
3
|
+
static $modx?: ElfModuleX;
|
|
4
|
+
static $getModule(): ElfModuleX;
|
|
5
|
+
static $nativeFunc<RetType extends NativeFunctionReturnType, ArgTypes extends NativeFunctionArgumentType[] | []>(symName: string, retType: RetType, argTypes: ArgTypes): NativeFunction<GetNativeFunctionReturnValue<RetType>, ResolveVariadic<Extract<GetNativeFunctionArgumentValue<ArgTypes>, unknown[]>>> & {
|
|
6
|
+
$handle: NativePointer | undefined;
|
|
7
|
+
};
|
|
8
|
+
static $lazyLoadFunc<RetType extends NativeFunctionReturnType, ArgTypes extends NativeFunctionArgumentType[] | []>(symName: string, retType: RetType, argTypes: ArgTypes): NativeFunction<GetNativeFunctionReturnValue<RetType>, ResolveVariadic<Extract<GetNativeFunctionArgumentValue<ArgTypes>, unknown[]>>> & {
|
|
9
|
+
$handle: NativePointer | undefined;
|
|
10
|
+
};
|
|
11
|
+
static readonly SSL_CTX_set_keylog_callback: NativeFunction<void, [NativePointerValue, NativePointerValue]> & {
|
|
12
|
+
$handle: NativePointer | undefined;
|
|
13
|
+
};
|
|
14
|
+
static readonly SSL_CTX_get_keylog_callback: NativeFunction<NativePointer, [NativePointerValue]> & {
|
|
15
|
+
$handle: NativePointer | undefined;
|
|
16
|
+
};
|
|
17
|
+
static readonly SSL_connect: NativeFunction<number, [NativePointerValue]> & {
|
|
18
|
+
$handle: NativePointer | undefined;
|
|
19
|
+
};
|
|
20
|
+
static readonly SSL_new: NativeFunction<NativePointer, [NativePointerValue]> & {
|
|
21
|
+
$handle: NativePointer | undefined;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { ElfModuleX, ElfFileFixer } from "../elf/module.js";
|
|
3
|
+
import { nativeFunctionOptions } from "../consts.js";
|
|
4
|
+
export class Libssl {
|
|
5
|
+
static $getModule() {
|
|
6
|
+
if (!this.$modx) {
|
|
7
|
+
let isNewLoad = false;
|
|
8
|
+
const libsslModule = Process.findModuleByName('libssl.so') || (isNewLoad = true, Module.load('libssl.so'));
|
|
9
|
+
if (isNewLoad) {
|
|
10
|
+
console.error(`[libssl.so]为新加载module.`);
|
|
11
|
+
}
|
|
12
|
+
this.$modx = new ElfModuleX(libsslModule, [new ElfFileFixer(libsslModule.path)], { symbolScanLimit: 50000 });
|
|
13
|
+
}
|
|
14
|
+
return this.$modx;
|
|
15
|
+
}
|
|
16
|
+
static $nativeFunc(symName, retType, argTypes) {
|
|
17
|
+
const sym = this.$getModule().findSymbol(symName);
|
|
18
|
+
if (!sym || !sym.implPtr) {
|
|
19
|
+
// throw error if call
|
|
20
|
+
const throwFunc = function () {
|
|
21
|
+
throw new Error(`[Libssl] symbol[${symName}] Not Found!`);
|
|
22
|
+
};
|
|
23
|
+
throwFunc.$handle = null;
|
|
24
|
+
return throwFunc;
|
|
25
|
+
}
|
|
26
|
+
const handle = sym.implPtr;
|
|
27
|
+
const fn = new NativeFunction(handle, retType, argTypes, nativeFunctionOptions);
|
|
28
|
+
fn.$handle = handle;
|
|
29
|
+
return fn;
|
|
30
|
+
}
|
|
31
|
+
static $lazyLoadFunc(symName, retType, argTypes) {
|
|
32
|
+
let func = null;
|
|
33
|
+
const getFunc = () => {
|
|
34
|
+
if (func === null) {
|
|
35
|
+
func = this.$nativeFunc(symName, retType, argTypes);
|
|
36
|
+
}
|
|
37
|
+
return func;
|
|
38
|
+
};
|
|
39
|
+
const wrapper = ((...args) => {
|
|
40
|
+
return getFunc()(...args);
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(wrapper, '$handle', {
|
|
43
|
+
get() { return getFunc().$handle; },
|
|
44
|
+
});
|
|
45
|
+
return wrapper;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
_a = Libssl;
|
|
49
|
+
// // int bssl::ssl_log_secret(const SSL *ssl, const char *label, const uint8_t *secret, size_t secret_len)
|
|
50
|
+
// static readonly ssl_log_secret = this.$lazyLoadFunc(
|
|
51
|
+
// '_ZN4bssl14ssl_log_secretEPK6ssl_stPKcPKhm', 'bool', ['pointer', 'pointer', 'pointer', 'size_t']
|
|
52
|
+
// )
|
|
53
|
+
// void SSL_CTX_set_keylog_callback(SSL_CTX *ctx, void(*cb)(const SSL *ssl, const char *line))
|
|
54
|
+
Libssl.SSL_CTX_set_keylog_callback = _a.$lazyLoadFunc('SSL_CTX_set_keylog_callback', 'void', ['pointer', 'pointer']);
|
|
55
|
+
// void (*SSL_CTX_get_keylog_callback(const SSL_CTX *ctx))(const SSL *ssl, const char *line)
|
|
56
|
+
Libssl.SSL_CTX_get_keylog_callback = _a.$lazyLoadFunc('SSL_CTX_get_keylog_callback', 'pointer', ['pointer']);
|
|
57
|
+
// int SSL_connect(SSL *ssl)
|
|
58
|
+
Libssl.SSL_connect = _a.$lazyLoadFunc('SSL_connect', 'int', ['pointer']);
|
|
59
|
+
// SSL *SSL_new(SSL_CTX *ctx)
|
|
60
|
+
Libssl.SSL_new = _a.$lazyLoadFunc('SSL_new', 'pointer', ['pointer']);
|