百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

SandHook

> 编程语言
开源

Android ART 钩子 / 原生内联钩子 / 单指令钩子 - 支持 4.4 - 11.0 32/64 位 - Xposed API 兼容

2.2K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Android ART 钩子 / 原生内联钩子 / 单指令钩子 - 支持 4.4 - 11.0 32/64 位 - Xposed API 兼容

SandHook

  • Android ART Hook
  • Native Inline Hook

Version

Chinese

中文文档以及实现

中文 Blog

与 VirtualApp 相关的商业合作请联系微信:10890

arch support

  • ARM64
  • ARM32(no tested)
  • Thumb-2

OS

4.4(ART Runtime) - 11.0 dev-preview-1

Project Struct

  • annotation
    annotation api
  • hooklib
    core lib of art hook
  • nativehook
    lib of native hook
  • xposedcompat
    stable implement of xposed api compat for sandhook
  • xposedcompat_new
    annother implement of xposed api compat for sandhook(hook more fast first time)
  • hookers
    hook plugin demo for annotation api

how to use

gradle
implementation 'com.swift.sandhook:hooklib:4.2.0'
// need for android 11
implementation 'com.swift.sandhook:nativehook:4.2.0'

Annotation API


  • hook method must be a static method
  • first par must be this if method is not static
  • method description must "same"(can be isAssignableFrom) with origin method
  • backup method same with above
…

if hookers is in plugin(like xposed):

groovy
provided 'com.swift.sandhook:hookannotation:4.2.0'

in your plugin

if OS <= 5.1 backup method can call itself to avoid be inlining

Xposed API


Now you can use Xposed api:

We have two different implements:

groovy
//stable
implementation 'com.swift.sandhook:xposedcompat:4.2.0'

//or

//hook fast first time
implementation 'com.swift.sandhook:xposedcompat_new:4.2.0'
…

Notice

Disable Inline

JIT inline

We can do nothing to prevent some methods been inlined before app start, but we can try to disable VM Jit Inline after launch.

if you will hook some method that could be inlined, please call SandHook.disableVMInline()(OS >= 7.0) in Application.OnCreate()

Inline by dex2oat

Background dex2oat

SandHook.tryDisableProfile(getPackageName());

dex2oat by DexClassLoader

SandHook.disableDex2oatInline(fullyDisableDex2oat);

or

ArtDexOptimizer.dexoatAndDisableInline to dex2oat manuly

Deoptimize(Boot Image)

You can also deoptimize a caller that inlined your hook method by SandHook.deCompile(caller), just implement >= 7.0

Hidden API

SandHook.passApiCheck();

To bypass hidden api on P & Q

Debuggable

You must set debuggble of the target hook process before init when OS >= 8.0.

SandHookConfig.DEBUG =

Native Hook

simple hook(no backup)

#include "includes/sandhook.h"

bool nativeHookNoBackup(void* origin, void* hook);

need backup origin method

#include "sandhook_native.h"

void* SandInlineHook(void* origin, void* replace);

void* SandInlineHookSym(const char* so, const char* symb, void* replace);

return is backup method

break point

you can insert a break point in body of method(not only start of method), so you can read/write registers in break point.

bool SandBreakPoint(void* origin, void (*callback)(REG[]));

bool SandSingleInstBreakPoint(void *origin, BreakCallback(callback));

short method

#include "sandhook_native.h"

void* SandSingleInstHook(void* origin, void* replace);

void* SandSingleInstHookSym(const char* so, const char* symb, void* replace);

use it when your method is <= 16bytes(64bit)/8bytes(32bit)

SandSingleInstHook only need 4bytes length

more

  • disassembler (only implement important instructions)
  • assembler (only implement important instructions)

Demo

SandVXPosed

non-Root Xposed Environment Demo (VirtualApp with SandHook):

https://github.com/ganyao114/SandVXposed

EdXposed(SandHook Brunch)

Unofficial xposed framework >= 8.0

See release above

https://github.com/ElderDrivers/EdXposed

Android Q(10.0)

in MyApp.java

//if you want test Android Q, please set true, because SDK_INT of Android Q is still 28 public final static boolean testAndroidQ = false;

References

  • Epic:https://github.com/tiann/epic
  • Yahfa:https://github.com/rk700/YAHFA

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaandroidaoparthook

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言