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

java.lang.NoSuchMethodError: No static method backup #89

Closed
quthla opened this issue Dec 30, 2018 · 2 comments
Closed

java.lang.NoSuchMethodError: No static method backup #89

quthla opened this issue Dec 30, 2018 · 2 comments

Comments

@quthla
Copy link

quthla commented Dec 30, 2018

In demoApp it works just fine but when copying Hook.smali to another app, backup method is destroyed by the hook. Calling backup2 gives no error but backup, which is hooked, gives error below.

Without calling backup I can hook just fine but I need the return value of backup method.

java.lang.NoSuchMethodError: No static method backup(Ljava/lang/Object;)D in class Llab/galaxy/yahfa/demoApp/Hook; or its super classes (declaration of 'lab.galaxy.yahfa.demoApp.Hook' appears in base.apk!classes5.dex)

2018-12-30 17:40:56.334 21454-21454/? I/YAHFA-Native: target method is at 0x6fe6c4a0, hook method is at 0x79dea85920, backup method is at 0x79dea85858
2018-12-30 17:40:56.334 21454-21454/? I/YAHFA-Native: setNonCompilable: access flags is 0x80001
2018-12-30 17:40:56.334 21454-21454/? I/YAHFA-Native: setNonCompilable: access flags is 0x80009
2018-12-30 17:40:56.334 21454-21454/? I/YAHFA-Native: origin ep is 0x720018e0, new ep is 0x7a74b25000
2018-12-30 17:40:56.334 21454-21454/? I/YAHFA-Native: access flags is 0x2080101
2018-12-30 17:40:56.334 21454-21454/? I/YAHFA-Native: hook and backup done
package lab.galaxy.yahfa.demoApp;

public class Hook {
    private static String TAG = "HOOK";
    private static Context context = null;

    public static void doHook(Context context) {
        try {
            Hook.context = context;
            ClassLoader classLoader = context.getClassLoader();
            Class clazz = Class.forName("android.xyz", true, classLoader);
            HookMain.findAndBackupAndHook(clazz, "xyz", "()D", findMethodByName("hook"), findMethodByName("backup"));
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }

    }

    public static Method findMethodByName(String name) {
        for (Method method : Hook.class.getDeclaredMethods()) {
            if (method.getName().equals(name)) {
                return method;
            }
        }
        return null;
    }

    public static double hook(Object thiz) {
        backup2(thiz);

        return backup(thiz);
    }

    public static double backup(Object thiz) {
        Log.e(TAG, "Shouldn't be here");
        return 0;
    }

    public static double backup2(Object thiz) {
        Log.e(TAG, "Backup2 Shouldn't be here");
        return 0;
    }
}
@rk700
Copy link
Member

rk700 commented Jan 2, 2019

I'm not quite sure but how about rebuild the project instead of copying .smali file?

@quthla
Copy link
Author

quthla commented Jan 2, 2019

I built the Hook.class in the demoApp module and it worked fine there but I don't have the source code of the other app (anymore) so the only option was to copy the built Hook.smali. I switched to AndHook now which is working fine but still thought I'd report this issue.

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