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

调用原函数时出现NoSuchMethodError #48

Open
Mivik opened this issue Mar 30, 2020 · 1 comment
Open

调用原函数时出现NoSuchMethodError #48

Mivik opened this issue Mar 30, 2020 · 1 comment

Comments

@Mivik
Copy link

Mivik commented Mar 30, 2020

2020-03-30 11:58:21.487 16795-16795/com.mivik.cymoe W/SandHook-Native: JNI Loaded
2020-03-30 11:58:21.506 16795-16795/com.mivik.cymoe E/SandHook-Native: ErrorCodeException: switch to arm32! not impl!
2020-03-30 11:58:21.506 16795-16795/com.mivik.cymoe D/SandHook: method <protected void android.app.Activity.attachBaseContext(android.content.Context)> hook <replacement> success!
2020-03-30 11:56:49.990 16213-16213/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mivik.cymoe, PID: 16213
    java.lang.NoSuchMethodError: No static method attachBaseContext_old(Landroid/content/ContextWrapper;Landroid/content/Context;)V in class Lcom/mivik/cymoe/hook/TestHook; or its super classes (declaration of 'com.mivik.cymoe.hook.TestHook' appears in base.apk)
        at com.mivik.cymoe.hook.TestHook.attachBaseContext_new(Hooks.kt:98)
        at com.mivik.cymoe.CymoeApplication.attachBaseContext(CymoeApplication.kt:13)
        at android.app.Application.attach(Application.java:376)
        at android.app.Instrumentation.newApplication(Instrumentation.java:1157)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1222)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6558)
        at com.elderdrivers.riru.edxp._hooker.yahfa.HandleBindAppHooker.hook(HandleBindAppHooker.java:21)
        at android.app.ActivityThread.access$1400(ActivityThread.java:228)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1893)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:224)
        at android.app.ActivityThread.main(ActivityThread.java:7567)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

由于是需要加载目标应用到自己进程中,而目标应用只提供了arm32的native lib,因此不得不使用arm32

值得一提的是,找不到原函数的NoSuchMethodError只在release架构下出现,debug架构时无问题

@ganyao114
Copy link
Collaborator

如果是用注解 api 的话,建议使用以下方式 call 原方法
@HookMethodBackup("onPause")
static HookWrapper.HookEntity onPauseBackup;

@HookMethod("onPause")
public static void onPause(@ThisObject Activity thiz) throws Throwable {
    Log.e("ActivityHooker", "hooked onPause success " + thiz);
    onPauseBackup.callOrigin(thiz);
}

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

2 participants