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

关于HookZz/Plugins/MachOStaticPatcher的使用 #62

Closed
calssion opened this issue Sep 17, 2019 · 5 comments
Closed

关于HookZz/Plugins/MachOStaticPatcher的使用 #62

calssion opened this issue Sep 17, 2019 · 5 comments

Comments

@calssion
Copy link

calssion commented Sep 17, 2019

还没搞懂怎么使用MachOStaticPatcher?里面的README.md是这样的:

So, Now you can hook target function as.
ZzReplaceStatic("binary_image_name", function_vmaddr, your_fake_function);

但实际上在文件里找到的函数是这样的:

void ZzReplaceStatic(char *image_name, void *function_virtual_address, void *replace_call, void **origin_call)

README.md是不是应该更新一下使用方式了,求助大佬,在arm64直接crash了,怀疑是我的使用方式有问题。

@jmpews
Copy link
Owner

jmpews commented Sep 17, 2019 via email

@calssion
Copy link
Author

好的感谢,用的是里面的example,我先摸索一下源码,如果能有这部分的实现原理就更好了

@calssion
Copy link
Author

calssion commented Sep 18, 2019

好的感谢,用的是里面的example,我先摸索一下源码,如果能有这部分的实现原理就更好了

错误出现在rebase_stub,*entry->trampoline_target_stub = entry->relocated_origin_function;出现Exec Bad Access

估计是访问到了空指针,这部分rebase出错

调用方式:ZzReplaceStatic("MachOStaitcPatcherExample", 0x100006ad8, runReplace, runMainFunction);

不知这样做是否是正确调用呢?0x100006ad8为nm获取到的函数地址,与hopper虚地址一致

@calssion
Copy link
Author

calssion commented Sep 19, 2019

好的感谢,用的是里面的example,我先摸索一下源码,如果能有这部分的实现原理就更好了

错误出现在rebase_stub,*entry->trampoline_target_stub = entry->relocated_origin_function;出现Exec Bad Access

估计是访问到了空指针,这部分rebase出错

调用方式:ZzReplaceStatic("MachOStaitcPatcherExample", 0x100006ad8, runReplace, runMainFunction);

不知这样做是否是正确调用呢?0x100006ad8为nm获取到的函数地址,与hopper虚地址一致

大家遇到相同的情况,可以暂时这样处理:注视掉下面这句代码,不懂这句的作用,估计是想用来回调原函数,但hook是成功的

*origin_call = (void *)entry->relocated_origin_function;

主要原因是指针越界了,待读懂大佬的代码后,再看看要如何使用吧

@calssion
Copy link
Author

以下提供正确的使用方式:

ZzReplaceStatic(char *image_name, void *function_virtual_address, void *replace_call, void **origin_call)

ZzReplaceStatic("image名称,可用dyld函数查看", 需要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

2 participants