type
status
date
slug
summary
tags
category
icon
password
- MethodSwizzle
- fishhook
- Cydia Substrate
- category ovveride
fishhook
使用
验证

查看Demo所在的地址空间:

将编译后的 Product下FishhookDemo.app,查看其内容,将
FishhookDemo
拖入 MachOView 工具,查看 Lazy Symbol Pointers 下的 NSLog的偏移。
查看
有几个需要说明的点:
x
是查看地址的命令,即 memory read
dis -s
是查看汇编指令
- iOS 是小端序,所以地址要从右往左读取,如下:

原理
fishhook 是如何通过字符串找到函数的呢?

懒加载符号表(Lazy Symbol Pointers)开始入手。懒加载符号表里面第一个符号是 NSLog 的指针。这个懒加载符号表有一个与之一一对应的符号表(Indirect Symbols)。

InDirect Symbols 找到对应符号的偏移量,如下图选中,其 Data 中的值:000000ED,十进制是 237,就是在 Symbol Table 中的序号。

在 Symbol Table 中找到 第237个,如下图,其中第一行显示了NSLog 在 String Table 中的偏移,即 000000DB。

根据上一步找到的偏移量000000DB,以及 String Table 自身的偏移量00008820(第一行),得到 NSLog 函数最后的偏移量:88
00008820+000000DB=000088F8,在下图中,改地址,就在选中行。
_ 是函数的开始,. 是分隔符 。5F是从 _开始,往后依次 _NSLog

代码研读
框架
参考
链接
代码