Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pony5551 opened this issue Dec 18, 2020 · 5 comments
Open

Comments

@pony5551
Copy link

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

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

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

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

android10
pxile3

@pony5551
Copy link
Author

android9也一样有问题

android8正常

@pony5551
Copy link
Author

初步分析了一下,

问题代码在这里

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);
}

@rk700
Copy link
Member

rk700 commented Dec 21, 2020

entry更新没有生效?

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

@pony5551
Copy link
Author

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

@thouger
Copy link

thouger commented Nov 21, 2024

对我也发现这个问题,调用doWork200次,但是里面的输出却没有200次,然后hook会回调的函数,也没输出的多

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants