A Lightweight Native Instrumentation Library for Android Security Research
Android-Mem-Kit is a minimal-overhead, pure C library for Android native instrumentation. It provides memory patching, function hooking, and symbol resolution capabilities for security research, debugging, and educational purposes.
| Feature | Implementation | Description |
|---|---|---|
| Function Hooking | ShadowHook | Inline hook with intercept, proxy chaining, and records |
| Symbol Resolution | XDL | Bypasses Android 7+ linker restrictions |
| JIT Code Generation | SLJIT | Platform-independent runtime code generation |
- Small Binary Size: <100KB overhead
- Simple NDK Integration: No FFI bridge or complex build setup
- Direct JNI/NDK Access: Native C integration with Android frameworks
- Modern Tooling: Leverages battle-tested libraries (ShadowHook, XDL, SLJIT)
| Document | Content |
|---|---|
| docs/GENERAL.md | Quick start: prerequisites, setup, build, and basic usage |
| docs/USAGE.md | Complete API reference: memory, hooking, intercept, records, JIT, IL2CPP, XDL, DL callbacks |
| docs/RECIPES.md | Common patterns: integrity checks, SSL pinning bypass, JIT code generation |
When using ShadowHook on building shared library, you may encounter error code 12 (MK_ERRNO_INIT_LINKER) during memkit_hook_init(). This is caused by missing libshadowhook_nothing.so.
Root Cause: ShadowHook requires libshadowhook_nothing.so to be present alongside libshadowhook.so for proper shared library compatibility. When building from local sources (USE_LOCAL_DEPS=ON), this library is now automatically built as part of the CMake build process.
When building memkit as a subproject via add_subdirectory() in your parent project's CMakeLists.txt:
enable_language(ASM) # Required for shadowhook assembly (sh_glue.S). Needs CMake 3.9+.
add_subdirectory(path/to/Android-Mem-Kit)
target_link_libraries(your_lib)Set -DMEMKIT_BUILD_SHARED=OFF to build a static library. The default is OFF for subprojects and ON for standalone builds.
The build process produces two files in build/<ABI>/lib/:
- libmemkit.so - Main memkit library (~190KB for arm64-v8a with JIT)
- libshadowhook_nothing.so - Required companion library for shared library compatibility (~1.5KB)
Both files must be packaged together in your lib/<ABI>/ directory.
This project utilizes excellent open-source libraries:
- ShadowHook by ByteDance - Inline hooking for Android
- XDL by HexHacking - Dynamic linker bypass
- SLJIT - Platform-independent JIT code generation
MIT License - See LICENSE file for details.
Contributions are welcome! Please read CONTRIBUTING.md first.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built for the security research community. Use responsibly.