通用的Android PLT hook库,支持armeabi-v7a,arm64-v8a,x86,x86_64
2,581
stars
104
commits
C
primary language
Jun 16, 2026
updated
ByteHook is an Android PLT hook library. Its goals are:
If you need an Android inline hook library, try shadowhook.
Android 4.1 - 17 QPR1 Beta 4
We will test and support the latest Android OS Beta versions as promptly as possible, and list the supported Android OS versions here.
There is a sample app in the bytehook-sample you can refer to.
ByteHook is published on Maven Central, and uses Prefab package format for native dependencies, which is supported by Android Gradle Plugin 4.0+.
android {
buildFeatures {
prefab true
}
}
dependencies {
implementation 'com.bytedance:bytehook:x.y.z'
}
Replace x.y.z with the version number. It's recommended to use the latest release version.
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:
android.prefabVersion=2.0.0
CMakeLists.txt
find_package(bytehook REQUIRED CONFIG)
add_library(mylib SHARED mylib.c)
target_link_libraries(mylib bytehook::bytehook)
Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := mylib
LOCAL_SRC_FILES := mylib.c
LOCAL_SHARED_LIBRARIES += bytehook
include $(BUILD_SHARED_LIBRARY)
$(call import-module,prefab/bytehook)
android {
defaultConfig {
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
}
}
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.
android {
packagingOptions {
exclude '**/libbytehook.so'
}
}
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.
android {
packagingOptions {
pickFirst '**/libbytehook.so'
}
}
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.
apply from: rootProject.file('gradle/prefab_bypass.gradle')
import com.bytedance.android.bytehook.ByteHook;
public class MySdk {
public static synchronized void init() {
ByteHook.init();
}
}
#include "bytehook.h"
bytehook_stub_t bytehook_hook_single(
const char *caller_path_name,
const char *callee_path_name,
const char *sym_name,
void *new_func,
bytehook_hooked_t hooked,
void *hooked_arg);
bytehook_stub_t bytehook_hook_partial(
bytehook_caller_allow_filter_t caller_allow_filter,
void *caller_allow_filter_arg,
const char *callee_path_name,
const char *sym_name,
void *new_func,
bytehook_hooked_t hooked,
void *hooked_arg);
bytehook_stub_t bytehook_hook_all(
const char *callee_path_name,
const char *sym_name,
void *new_func,
bytehook_hooked_t hooked,
void *hooked_arg);
int bytehook_unhook(bytehook_stub_t stub);
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 call BYTEHOOK_STACK_SCOPE() macro at the beginning of the proxy function instead.ByteHook is licensed under the MIT License.
ByteHook uses the following third-party source code or libraries:
C
87.3%
Java
6.5%
C++
4.4%
CMake
1.4%
通用的Android PLT hook库,支持armeabi-v7a,arm64-v8a,x86,x86_64
2,581
stars
104
commits
C
primary language
Jun 16, 2026
updated
ByteHook is an Android PLT hook library. Its goals are:
If you need an Android inline hook library, try shadowhook.
Android 4.1 - 17 QPR1 Beta 4
We will test and support the latest Android OS Beta versions as promptly as possible, and list the supported Android OS versions here.
There is a sample app in the bytehook-sample you can refer to.
ByteHook is published on Maven Central, and uses Prefab package format for native dependencies, which is supported by Android Gradle Plugin 4.0+.
android {
buildFeatures {
prefab true
}
}
dependencies {
implementation 'com.bytedance:bytehook:x.y.z'
}
Replace x.y.z with the version number. It's recommended to use the latest release version.
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:
android.prefabVersion=2.0.0
CMakeLists.txt
find_package(bytehook REQUIRED CONFIG)
add_library(mylib SHARED mylib.c)
target_link_libraries(mylib bytehook::bytehook)
Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := mylib
LOCAL_SRC_FILES := mylib.c
LOCAL_SHARED_LIBRARIES += bytehook
include $(BUILD_SHARED_LIBRARY)
$(call import-module,prefab/bytehook)
android {
defaultConfig {
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
}
}
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.
android {
packagingOptions {
exclude '**/libbytehook.so'
}
}
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.
android {
packagingOptions {
pickFirst '**/libbytehook.so'
}
}
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.
apply from: rootProject.file('gradle/prefab_bypass.gradle')
import com.bytedance.android.bytehook.ByteHook;
public class MySdk {
public static synchronized void init() {
ByteHook.init();
}
}
#include "bytehook.h"
bytehook_stub_t bytehook_hook_single(
const char *caller_path_name,
const char *callee_path_name,
const char *sym_name,
void *new_func,
bytehook_hooked_t hooked,
void *hooked_arg);
bytehook_stub_t bytehook_hook_partial(
bytehook_caller_allow_filter_t caller_allow_filter,
void *caller_allow_filter_arg,
const char *callee_path_name,
const char *sym_name,
void *new_func,
bytehook_hooked_t hooked,
void *hooked_arg);
bytehook_stub_t bytehook_hook_all(
const char *callee_path_name,
const char *sym_name,
void *new_func,
bytehook_hooked_t hooked,
void *hooked_arg);
int bytehook_unhook(bytehook_stub_t stub);
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 call BYTEHOOK_STACK_SCOPE() macro at the beginning of the proxy function instead.ByteHook is licensed under the MIT License.
ByteHook uses the following third-party source code or libraries:
C
87.3%
Java
6.5%
C++
4.4%
CMake
1.4%