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 final方法? #9

Open
yeziyi opened this issue Nov 25, 2017 · 3 comments
Open

不能hook final方法? #9

yeziyi opened this issue Nov 25, 2017 · 3 comments

Comments

@yeziyi
Copy link

yeziyi commented Nov 25, 2017

Process: com.panda.hook.andhook, PID: 26895
java.lang.LinkageError: Method void android_widget_TextView.setText(java.lang.CharSequence) overrides final method in class Landroid/widget/TextView; (declaration of 'android_widget_TextView' appears in /data/user/0/com.panda.hook.andhook/app_path/Generated_2112139824.jar)
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:338)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.panda.hook.javahook.HookManager.startArtHook(HookManager.java:148)
at com.panda.hook.javahook.HookManager.beginHook(HookManager.java:78)
at com.panda.hook.javahook.HookManager.addNeedsMethod(HookManager.java:224)
at com.panda.hook.javahook.HookManager.startHooks(HookManager.java:214)
at com.panda.hook.andhook.MainActivity$3.onClick(MainActivity.java:87)

@panhongwei
Copy link
Owner

从日志看是davilk系统跑了startArtHook,应该startDavilkHook才对,有点奇怪!

@xuxingcan
Copy link

@panhongwei 应该不是你所说的原因。
个人觉得应该是DexMaker导致的。
HookManager里面的startArtHook里,若当前类不是final且为ART,则DexMaker新建的类会继承原始类,由于新建类的方法名和hook的方法名相同,若hook的方法为final,则loadclass的时候会报错。
final的方法不能被重写。

@jarvis-ding
Copy link

@panhongwei 应该不是你所说的原因。
个人觉得应该是DexMaker导致的。
HookManager里面的startArtHook里,若当前类不是final且为ART,则DexMaker新建的类会继承原始类,由于新建类的方法名和hook的方法名相同,若hook的方法为final,则loadclass的时候会报错。
final的方法不能被重写。

final方法该如何重写覆盖呢?我在用frida覆盖方法的时候也出现了这个问题,一旦重写final方法就会导致APP异常退出,有没有什么办法呢?我想要打印出运行时传递的参数和调用栈

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

4 participants