PatcherAPI

Runtime patching helper that wraps Xposed hooks and tracks created unpatch actions.

Use instances to apply hooks via the patch methods. Each patch returns an Unpatch callback that will remove the applied hook when invoked. Call unpatchAll to run all registered unpatch actions and clear the internal registry.

Parameters

logger

logger used for error reporting

Functions

Link copied to clipboard
inline fun <T> PatcherAPI.after(vararg paramTypes: Class<*>, crossinline callback: HookCallback<T>): Unpatch

Adds a Hook to a constructor of a class.

inline fun <T> PatcherAPI.after(methodName: String, vararg paramTypes: Class<*>, crossinline callback: HookCallback<T>): Unpatch

Adds a Hook to a method of a class.

Link copied to clipboard
inline fun <T> PatcherAPI.before(vararg paramTypes: Class<*>, crossinline callback: HookCallback<T>): Unpatch

Adds a PreHook to a constructor of a class.

inline fun <T> PatcherAPI.before(methodName: String, vararg paramTypes: Class<*>, crossinline callback: HookCallback<T>): Unpatch

Adds a PreHook to a method of a class.

Link copied to clipboard
inline fun <T> PatcherAPI.instead(vararg paramTypes: Class<*>, crossinline callback: InsteadHookCallback<T>): Unpatch

Replaces a constructor of a class.

inline fun <T> PatcherAPI.instead(methodName: String, vararg paramTypes: Class<*>, crossinline callback: InsteadHookCallback<T>): Unpatch

Replaces a method of a class.

Link copied to clipboard
fun patch(m: Member, hook: XC_MethodHook): Unpatch

Patch a specific method or constructor.

Patch a specific method or constructor using a MethodHookCallback.

fun patch(clazz: Class<*>, fn: String, paramTypes: Array<Class<*>> = emptyArray(), hook: XC_MethodHook): Unpatch

Patch a method by Class.

fun patch(forClass: String, fn: String, paramTypes: Array<Class<*>> = emptyArray(), hook: XC_MethodHook): Unpatch

Patch a method by class name.

Link copied to clipboard

Invoke all registered unpatch actions and clear the registry.