### ApplicationHook Example with Method Hooking (Kotlin) Source: https://context7.com/kyuubiran/ezxhepler-template/llms.txt This example demonstrates hooking into the Android Application.onCreate method using EzXHelper's MethodFinder and a DSL for hook creation. It shows how to execute code before and after the original method, accessing hook parameters and context. ```kotlin package com.example.xposedapp.hook import android.app.Application import io.github.kyuubiran.ezxhelper.core.finder.MethodFinder import io.github.kyuubiran.ezxhelper.xposed.dsl.HookFactory.`-Static`.createHook object ApplicationHook : BaseHook() { override val name: String = "ApplicationHook" override fun init() { MethodFinder.fromClass(Application::class) .filterByName("onCreate") .first() .createHook { before { // Execute code before the original method println("Application onCreate about to be called") } after { // Execute code after the original method val app = it.thisObject as Application println("Application onCreate completed: ${app.packageName}") } } } } ``` -------------------------------- ### Implement Method Hook with Parameter Modification using EzXHelper Source: https://context7.com/kyuubiran/ezxhepler-template/llms.txt This Kotlin code snippet demonstrates how to create a method hook using EzXHelper's `MethodFinder` and `createHook` API. It targets the `startActivity` method of the `Activity` class, logs the intent component, modifies the intent by adding an extra, and logs after the method execution. This example showcases before and after hook callbacks for argument manipulation and post-execution actions. ```kotlin object ActivityHook : BaseHook() { override val name: String = "ActivityHook" override fun init() { // Hook Activity.startActivity with Intent parameter MethodFinder.fromClass("android.app.Activity".toClass()) .filterByName("startActivity") .filterByParamTypes(Intent::class.java) .first() .createHook { before { param -> val intent = param.args[0] as Intent Logger.i("Starting activity: ${intent.component}") // Modify the intent before method executes intent.putExtra("hooked", true) } after { param -> Logger.i("Activity started successfully") } } } } ``` -------------------------------- ### Specify Xposed Init Entry Point Source: https://context7.com/kyuubiran/ezxhepler-template/llms.txt The `xposed_init` file is a simple text file that contains the fully qualified class name of the main hook entry point for your Xposed module. Xposed frameworks use this file to locate and load the primary class responsible for initiating hooks. ```text com.example.xposedapp.MainHook ``` -------------------------------- ### MainHook Entry Point for Xposed Modules (Kotlin) Source: https://context7.com/kyuubiran/ezxhepler-template/llms.txt The MainHook class is the primary entry point for Xposed modules. It implements IXposedHookLoadPackage and IXposedHookZygoteInit to manage package loading and zygote initialization. It utilizes EzXposed for initialization and a custom initHooks function to manage modular hook implementations. ```kotlin package com.example.xposedapp import com.example.xposedapp.hook.ApplicationHook import com.example.xposedapp.hook.BaseHook import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.IXposedHookZygoteInit import de.robv.android.xposed.callbacks.XC_LoadPackage import io.github.kyuubiran.ezxhelper.android.logging.Logger import io.github.kyuubiran.ezxhelper.xposed.EzXposed const val TARGET_APP = "com.example.target" const val TAG = "EzXposedApp" class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit { override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) { if (lpparam.packageName == TARGET_APP) return EzXposed.initHandleLoadPackage(lpparam) Logger.tag = TAG initHooks( // Add your hooks here ApplicationHook, // CustomHook1, // CustomHook2 ) } override fun initZygote(startupParam: IXposedHookZygoteInit.StartupParam) { EzXposed.initZygote(startupParam) } private fun initHooks(vararg hooks: BaseHook) { for (hook in hooks) { try { hook.init() } catch (e: Exception) { Logger.e("Init hook failed!", e) } } } } ``` -------------------------------- ### Configure App-Level Build with Kotlin DSL Source: https://context7.com/kyuubiran/ezxhepler-template/llms.txt The `build.gradle.kts` file at the app level configures the Android application settings, including SDK versions, build types, and dependencies. It integrates Xposed API and EzXHelper libraries using the version catalog defined in `libs.versions.toml`. ```kotlin plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) } android { namespace = "com.example.xposedapp" compileSdk = 36 defaultConfig { applicationId = "com.example.xposedapp" minSdk = 24 targetSdk = 36 versionCode = 1 versionName = "1.0" } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } } dependencies { implementation(libs.xposed.api) implementation(libs.ezxhelper.core) implementation(libs.ezxhelper.xposed.api) implementation(libs.ezxhelper.android.utils) } ``` -------------------------------- ### Manage Gradle Dependencies with libs.versions.toml Source: https://context7.com/kyuubiran/ezxhepler-template/llms.txt The `libs.versions.toml` file utilizes Gradle's version catalog feature to centralize dependency management. It defines versions for plugins and libraries, including Xposed API and EzXHelper components, promoting consistency and simplifying updates across the project. ```toml [versions] agp = "8.11.1" ezxhelper = "3.0.1" kotlin = "2.2.0" xposed-api = "82" [libraries] xposed-api = { module = "de.robv.android.xposed:api", version.ref = "xposed-api" } ezxhelper-android-utils = { module = "io.github.kyuubiran.ezxhelper:android-utils", version.ref = "ezxhelper" } ezxhelper-core = { module = "io.github.kyuubiran.ezxhelper:core", version.ref = "ezxhelper" } ezxhelper-xposed-api = { module = "io.github.kyuubiran.ezxhelper:xposed-api-82", version.ref = "ezxhelper" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } ``` -------------------------------- ### Hook AlertDialog.Builder Constructor with Kotlin Source: https://context7.com/kyuubiran/ezxhepler-template/llms.txt This snippet demonstrates how to hook the constructor of `android.app.AlertDialog.Builder` using EzXHelper. It intercepts object creation and logs the class name of the provided `Context`. This requires the EzXHelper library and an Xposed environment. ```kotlin object DialogHook : BaseHook() { override val name: String = "DialogHook" override fun init() { // Hook AlertDialog.Builder constructor MethodFinder.fromClass("android.app.AlertDialog$Builder".toClass()) .filterByName("") .filterByParamTypes(Context::class.java) .first() .createHook { after { val context = param.args[0] as Context Logger.i("AlertDialog.Builder created in: ${context.javaClass.name}") } } } } ``` -------------------------------- ### Define Target Application Scope in arrays.xml Source: https://context7.com/kyuubiran/ezxhepler-template/llms.txt The arrays.xml file allows you to define an array of strings, where each string is a package name of an application. This array, referenced by `xposedscope` in the AndroidManifest.xml, specifies which applications your Xposed module will hook into, enabling fine-grained control over the module's scope. ```xml com.target.app1 com.target.app2 ``` -------------------------------- ### BaseHook Abstract Class for Hook Implementations (Kotlin) Source: https://context7.com/kyuubiran/ezxhepler-template/llms.txt The BaseHook abstract class defines a standard interface for all hook implementations. Each hook must provide a unique name and implement an initialization method. This promotes modularity and consistent hook management within the Xposed module. ```kotlin package com.example.xposedapp.hook abstract class BaseHook { abstract val name: String abstract fun init() } // Example: Creating a custom hook implementation object MyCustomHook : BaseHook() { override val name: String = "MyCustomHook" override fun init() { // Hook implementation goes here } } ``` -------------------------------- ### Configure Xposed Module Metadata in AndroidManifest.xml Source: https://context7.com/kyuubiran/ezxhepler-template/llms.txt The AndroidManifest.xml file is used to declare Xposed module metadata such as its description, minimum required Xposed API version, and the scope of applications it targets. This configuration is essential for Xposed frameworks like LSPosed or EdXposed to properly load and manage the module. ```xml ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.