PAGalaxyLab / YAHFA

Yet Another Hook Framework for ART
GNU General Public License v3.0
1.57k stars 351 forks source link

Hook 方法中如果有参数类型不是Android Sdk已有的,能Hook吗? #27

Closed c1024 closed 7 years ago

c1024 commented 7 years ago

比如下面Hook方法里面参数类型都是SDK已有的。 public static String hook(Object thiz, String a, String b, String c, String d) { Log.w("YAHFA", "in ClassWithVirtualMethod.tac(): "+a+", "+b+", "+c+", "+d); return origin(thiz, a, b, c, d); }

如果要Hook的方法里面参数或者返回值类型不是Android Sdk里面的,能Hook吗?

rk700 commented 7 years ago

和xposed类似的是,hook()方法的参数可以全部写成Object类型,调用时再cast成实际类型,之后通过反射调用其方法

与xposed不同的是,设置hook目标时,不需要提供目标方法参数的class,只需要提供方法签名字符串

rk700 commented 7 years ago

https://github.com/rk700/VirtualHook/issues/8

c1024 commented 7 years ago

@rk700 照你说的,测试可以,谢谢