YAHFA icon indicating copy to clipboard operation
YAHFA copied to clipboard

新版本hook问题!原方法运行多次后才能hook能成功!

Open pony5551 opened this issue 5 years ago • 5 comments

新版不是不能hook,遥是一开始不能hook!

在运行hook后再运行 Log.e(TAG, "call Log.e()");

刚开始几百次是hook不了的,要多点几次能才hook,我看了一下大概运行550次

Log.e(TAG, "call Log.e()");才会被hook!

android10 pxile3

pony5551 avatar Dec 18 '20 13:12 pony5551

android9也一样有问题

android8正常

pony5551 avatar Dec 18 '20 14:12 pony5551

初步分析了一下,

问题代码在这里

if (newEntrypoint) {
    writeAddr((char *) fromMethod + OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod,
            newEntrypoint);
} else {
    LOGE("failed to allocate space for trampoline of target method");
    return 1;
}

if (OFFSET_entry_point_from_interpreter_in_ArtMethod != 0) {
    void *interpEntrypoint = readAddr((char *) toMethod + OFFSET_entry_point_from_interpreter_in_ArtMethod);
    writeAddr((char *) fromMethod + OFFSET_entry_point_from_interpreter_in_ArtMethod,
            interpEntrypoint);
}

pony5551 avatar Dec 18 '20 17:12 pony5551

entry更新没有生效?

x86模拟器是否会出现同样的问题?

rk700 avatar Dec 21 '20 07:12 rk700

x86没测试,不过我好几个机器都有问题,就应该是有问题吧!

pony5551 avatar Dec 24 '20 00:12 pony5551