Skip to content

Commit 5c4fcc3

Browse files
committed
Refactor: Add hookMethod extension for Member
This commit introduces a new extension function `hookMethod` for the `java.lang.reflect.Member` type. This allows for a more concise way to hook methods using XposedBridge, similar to the existing `hookMethod` extension for `DexMethod`.
1 parent 5aceb14 commit 5c4fcc3

File tree

1 file changed

+8
-1
lines changed
  • app/src/main/java/io/github/chsbuffer/revancedxposed

1 file changed

+8
-1
lines changed

app/src/main/java/io/github/chsbuffer/revancedxposed/BaseHook.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.luckypray.dexkit.result.MethodData
1717
import org.luckypray.dexkit.wrap.DexClass
1818
import org.luckypray.dexkit.wrap.DexField
1919
import org.luckypray.dexkit.wrap.DexMethod
20+
import java.lang.reflect.Member
2021
import kotlin.reflect.KFunction0
2122
import kotlin.system.measureTimeMillis
2223

@@ -27,7 +28,12 @@ interface IHook {
2728
fun Hook()
2829

2930
fun DexMethod.hookMethod(callback: XC_MethodHook) {
30-
XposedBridge.hookMethod(toMember(), callback) }
31+
XposedBridge.hookMethod(toMember(), callback)
32+
}
33+
34+
fun Member.hookMethod(callback: XC_MethodHook) {
35+
XposedBridge.hookMethod(this, callback)
36+
}
3137

3238
fun DexClass.toClass() = getInstance(classLoader)
3339
fun DexMethod.toMethod() = getMethodInstance(classLoader)
@@ -36,6 +42,7 @@ interface IHook {
3642
isConstructor -> getConstructorInstance(classLoader)
3743
else -> throw NotImplementedError()
3844
}
45+
3946
fun DexField.toField() = getFieldInstance(classLoader)
4047
}
4148

0 commit comments

Comments
 (0)