commit b2410d8b08c989949f354dd65b48f64cfdfb2d48
parent 905149f8bf2dc588224f9b25b9c76b9bab8c9594
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Wed, 7 Jun 2023 18:39:16 +0200
add: hook extensions
Diffstat:
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/hook/Hooker.kt b/app/src/main/kotlin/me/rhunk/snapenhance/hook/Hooker.kt
@@ -89,4 +89,39 @@ object Hooker {
unhooks.forEach{ it.unhook() }
}.also { unhooks.addAll(it) }
}
-}-
\ No newline at end of file
+}
+
+fun Class<*>.hookConstructor(
+ stage: HookStage,
+ consumer: (HookAdapter) -> Unit
+) = Hooker.hookConstructor(this, stage, consumer)
+
+fun Class<*>.hookConstructor(
+ stage: HookStage,
+ filter: ((HookAdapter) -> Boolean),
+ consumer: (HookAdapter) -> Unit
+) = Hooker.hookConstructor(this, stage, filter, consumer)
+
+fun Class<*>.hook(
+ methodName: String,
+ stage: HookStage,
+ consumer: (HookAdapter) -> Unit
+): Set<XC_MethodHook.Unhook> = Hooker.hook(this, methodName, stage, consumer)
+
+fun Class<*>.hook(
+ methodName: String,
+ stage: HookStage,
+ filter: (HookAdapter) -> Boolean,
+ consumer: (HookAdapter) -> Unit
+): Set<XC_MethodHook.Unhook> = Hooker.hook(this, methodName, stage, filter, consumer)
+
+fun Member.hook(
+ stage: HookStage,
+ consumer: (HookAdapter) -> Unit
+): XC_MethodHook.Unhook = Hooker.hook(this, stage, consumer)
+
+fun Member.hook(
+ stage: HookStage,
+ filter: ((HookAdapter) -> Boolean),
+ consumer: (HookAdapter) -> Unit
+): XC_MethodHook.Unhook = Hooker.hook(this, stage, filter, consumer)+
\ No newline at end of file