Java method hooking for Android apps, with an Xposed-compatible API. It powers the plugins of exteraGram.
- Hooks Java methods and constructors inside the app's own process, on Android 7.0 (API 24) and later, through LSPlant.
- Has its own API,
com.exteragram.hook, built around a chain of interceptors. An interceptor can call the original any number of times, with other arguments or another receiver. - Keeps the classic
de.robv.android.xposedAPI (XposedBridge,XC_MethodHook) as a thin layer over that chain, so existing Xposed-style code and Python plugins through Chaquopy keep working. - Experimental partial hooks: a single call site, field read or write, or instruction inside a method, done by rewriting that method's dex.
- Runtime helpers: calling the original method, deoptimizing callers that inlined a hooked method, allocating objects without a constructor, and turning off hidden API restrictions and the profile saver.
import com.exteragram.hook.ExteraHook
val target = SomeClass::class.java.getDeclaredMethod("targetMethod", String::class.java)
val handle = ExteraHook.hook(target).intercept { chain ->
"hooked(${chain.proceed()})"
}
handle.unhook()How to add it to an app, use it from Java, Kotlin or Python, and what the runtime does under the hood is in docs/host-integration.md.
exterahook(hook-core/): the library.shadowhook(third_party/shadowhook/): ShadowHook 2.0.1 for inline hooks, built from source.third_party/LSPlant-master/: LSPlant with exteraHook's changes, a separate Gradle build that the root build includes.test-host: an app with a scenario for every runtime path. It runs them through instrumentation, on Gradle Managed Devices, or from its own screen.
You need:
- JDK 17 to 24. Gradle 8.14 does not run on JDK 25, which recent Android Studio versions bundle;
- Android SDK 36, NDK
29.0.14206865and CMake 3.28 or newer; - a
local.propertieswithsdk.dirboth in the root and inthird_party/LSPlant-master.
./gradlew :exterahook:testDebugUnitTest
./gradlew :exterahook:assembleRelease
./gradlew :test-host:connectedUniversalDebugAndroidTest
./gradlew :test-host:matrixCheckThe artifacts are not on a public Maven repository. Publish them into a local one that your app reads:
./gradlew :exterahook:publish -PlocalPublishRepo=/path/to/maven-repo
./gradlew :shadowhook:publish -PlocalPublishRepo=/path/to/maven-repo
cd third_party/LSPlant-master
./gradlew :lsplant:publishLsplantPublicationToLocalExteraRepoRepository \
-PlocalPublishRepo=/path/to/maven-repoThis publishes:
com.exteragram.hook:hook-core:1.0.1com.exteragram.hook.thirdparty:lsplant:6.4-extera.9com.bytedance.android:shadowhook:2.0.1
An app that uses hook-core also needs these three and
org.lsposed.hiddenapibypass:hiddenapibypass. The native parts are static libraries consumed
through prefab.
- Only
armeabi-v7aandarm64-v8aare supported. - The
exterahookAAR does not packagelibshadowhook.soorlibshadowhook_nothing.so. - The arm64 build of ShadowHook uses
-mbranch-protection=standard. - Turning off hidden API restrictions can be a problem for Google Play. Decide that per app.
exteraHook is licensed under the GNU Lesser General Public License v3.0 or later, with additional terms: an app that ships exteraHook and has a user interface must name it, with a link to this repository, among the legal notices it displays.
Third-party code in this repository keeps its own license, see NOTICE.md. LSPlant is modified, see its list of changes.