-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug: when callee_path_name is specified when hooking, the unhook …
…will fail.
- Loading branch information
Showing
1 changed file
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5c74c1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
太感谢了~~~ @caikelun
我的项目之前一直有个bug,就是unhook不稳定的情况。项目就是做文件加解密,Demo里Java层读写txt并用snackbar展示,用这个库启用hook时,libc.so的read/write方法会被hook,实现逐字符的解密(read()时)或加密(write()时),unhook时会则不会。核心函数是这个:
read_stub = bytehook_hook_all("libc.so", "read", (void *) read_proxy, NULL, NULL);
write_stub = bytehook_hook_all("libc.so", "write", (void *) write_proxy, NULL, NULL);
不稳定的情况在于,如果启用hook后读取txt并弹出了snackbar(此时hook了read(),文字被解密),然后——在snackbar没有消失时立刻unhook再读取txt,正常来说应该读取到乱码(因为unhook后read()不再经过解密),然而,还是会显示解密后的文字;如果想避免这个问题,一般需要hook并读取txt后,等snackbar消失2秒后再unhook,此时读取到的大概率才是未解密的文字。
我一直以为是我自己的问题,同事分析说可能是“整个调用链路的符号表,不知因为什么原因,还是使用的上次的”。
我这次更新版本之后,这个bug没再出现,请问不知道是不是解决了?
5c74c1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯,那应该就是这个问题了,要100%确认的话,可以对比下两个版本unhook时的bytehook logcat调试信息,看看是不是旧版本unhook是失败的。
5c74c1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这方面的话,我之前测试时,旧版本的unhook函数的返回值倒是正常的hhh,也没有任何报错,包括对比了##_stub的地址也都匹配,所以当时比较烦恼
如果之前触发这个bug的话,返回值会是有问题的么?
5c74c1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,这个bug unhook时并不会返回失败。另外,在旧版本中,把hook all的第一个参数从libc.so改成NULL也可以规避这个bug。
5c74c1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哇感谢~~好的!非常感谢哈哈哈~ 解决了一个心病
5c74c1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用客气哈