-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathInit.kt
More file actions
60 lines (50 loc) · 1.8 KB
/
Init.kt
File metadata and controls
60 lines (50 loc) · 1.8 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package io.github.xpler.example.module
import android.os.Bundle
import android.util.Log
import io.github.xpler2.XplerHint
import io.github.xpler2.XplerModuleInterface
import io.github.xpler2.hooker
import io.xpler2.github.xposed.XposedHint
@XplerHint(
description = "Xpler Example Module",
scope = ["io.abc.a116"],
)
@XposedHint(version = 82)
// @LsposedHint(version = 100) // ~! perhaps it will be supported in the future
fun init(module: XplerModuleInterface) {
try {
if (!module.isFirstPackage) return // skip if not the first package
if (module.packageName != "io.abc.a116") return // skip if not the target package
if (module.processName.indexOf(":") != -1) return // skip sub-processes
Log.i("Xpler2", "[Xpler2]init called in packageName: `${module.packageName}`, process: ${module.processName}")
val applicationClazz = module.classLoader.loadClass("io.abc.a116.MainActivity")
val onCreateMethod = applicationClazz.getDeclaredMethod("onCreate", Bundle::class.java)
onCreateMethod.hooker {
onBefore {
module.log("[Xpler2]before[50]: $this")
returnAndSkip(null)
}
onAfter {
module.log("[Xpler2]after[50]: $this")
}
}
onCreateMethod.hooker(51) {
onBefore {
module.log("[Xpler2]before[51]: $this")
}
onAfter {
module.log("[Xpler2]after[51]: $this")
}
}
onCreateMethod.hooker(49) {
onBefore {
module.log("[Xpler2]before[49]: $this")
}
onAfter {
module.log("[Xpler2]after[49]: $this")
}
}
} catch (e: Throwable) {
module.log("[Xpler2]not init.", e)
}
}