Results 61 comments of Ruikai Liu

I'm not sure but the best way to modify static fields is using Java reflection instead of this tool. Reflection could be done with pure Java code or with JNI.

用反射 https://github.com/rk700/YAHFA/issues/12

开了个新分支 https://github.com/rk700/YAHFA/tree/internalHook 其中就是在demo Application创建时直接进行hook,不使用DexClassLoader。 7.0以上需要改hookMethod的hotness还没有试,但是在x86 avd 5.0-6.0上试验都ok

有具体测试环境和包吗

我这边系统9是台华为EMUI 9,有空我试下`android.view.WindowManagerImpl.addView()`。 不过你也提到8.1上没问题,9上少部分包可以,所以估计问题原因可能比较复杂,不一定能确定。毕竟这个Hook项目也只是之前出于概念验证所写的,这些年Android系统不断更新,修修补补适配高版本系统也变得越来越难。

有可能是和method cache数组被覆盖了有关。 创建了一个新的分支 https://github.com/PAGalaxyLab/YAHFA/tree/test_backup 通过`malloc`的方式来保存目标方法供`backupMethod`来调用,可以试验下。

如果这种方式可以,那看来可能确实和method cache数组有关。 后面会在master分支里合并更新

那后面可以这样改下,对不同系统版本采用不同的方式

Android 5.0的话,可以存在代码内联优化的情况,特别是一些系统库函数。具体需要去看调用log时对应的机器指令,参考 https://github.com/rk700/YAHFA/issues/2