Note: ByteHook uses the prefab package schema v2, which is configured by default since Android Gradle Plugin 7.1.0. If you are using Android Gradle Plugin earlier than 7.1.0, please add the following configuration to gradle.properties:
If you are using ByteHook in an SDK project, you may need to avoid packaging libbytehook.so into your AAR, so as not to encounter duplicate libbytehook.so file when packaging the app project.
On the other hand, if you are using ByteHook in an APP project, you may need to add some options to deal with conflicts caused by duplicate libbytehook.so file.
These three hook functions are used to hook single, partial, and all caller dynamic libraries in the process.
Notice:
If you need to call the original function in the proxy function, please always use the BYTEHOOK_CALL_PREV() macro.
Make sure to call BYTEHOOK_POP_STACK() macro before proxy function returning. In the CPP source file, you can also call BYTEHOOK_STACK_SCOPE() macro at the beginning of the proxy function instead.
ByteHook
简体中文
ByteHook is an Android PLT hook library which supports armeabi-v7a, arm64-v8a, x86 and x86_64.
ByteHook is now used in TikTok, Douyin, Toutiao, Xigua Video, Lark.
If you need an Android inline hook library, please move to ShadowHook.
Features
Documentation
ByteHook Documentation
Quick Start
There is a sample app in the bytehook-sample you can refer to.
1. Add dependency in build.gradle
ByteHook is published on Maven Central, and uses Prefab package format for native dependencies, which is supported by Android Gradle Plugin 4.0+.
Note: ByteHook uses the prefab package schema v2, which is configured by default since Android Gradle Plugin 7.1.0. If you are using Android Gradle Plugin earlier than 7.1.0, please add the following configuration to
gradle.properties:2. Add dependency in CMakeLists.txt or Android.mk
3. Specify one or more ABI(s) you need
4. Add packaging options
If you are using ByteHook in an SDK project, you may need to avoid packaging libbytehook.so into your AAR, so as not to encounter duplicate libbytehook.so file when packaging the app project.
On the other hand, if you are using ByteHook in an APP project, you may need to add some options to deal with conflicts caused by duplicate libbytehook.so file.
Note: If you use prefab dependency bytehook under x86 and x86_64 architectures, you need to add prefab_bypass.gradle to the module’s build.gradle.
5. Initialize
6. Hook and Unhook
These three hook functions are used to hook single, partial, and all caller dynamic libraries in the process.
Notice:
BYTEHOOK_CALL_PREV()macro.BYTEHOOK_POP_STACK()macro before proxy function returning. In the CPP source file, you can also callBYTEHOOK_STACK_SCOPE()macro at the beginning of the proxy function instead.Contributing
License
ByteHook is licensed by MIT License.
ByteHook uses the following third-party source code or libraries:
BSD 3-Clause License
Copyright (c) 1991, 1993 The Regents of the University of California.
BSD 3-Clause License
Copyright (c) 2005-2011 Google Inc.