FishHook通過符號找字符串

The process of looking up the name of a given entry in the lazy or non-lazy pointer tables looks like this: [https://github.com/facebook/fishhook]

fishHook.png

例如:查找符號 _close

1、Find entry with same index in indirect symbol table

通過Lazy Symbol Pointers找到符號在Dynamic Symbol Table->Indirect Symbols的位置
_close在Lazy Symbol Pointers與動態(tài)表Dynamic Symbol Table的位置是一樣的。

Lazy Symbol Pointers.png
Indirect Symbols.png

2、Treat value as index into symbol table array

Dynamic Symbol Table的Data為 ox43 為符號在Symbol Table數(shù)組的下標(biāo)

_close的data值.png
Symbols.png

_close 的偏移位置是:Symbols[_close下標(biāo)] = 0x3218 + 0x43 * 10 = 0x3648

0x3218: Symbols的初始地址
0x43:close在symbols的下標(biāo)
10:為symtab的sizeof (16 —> 16進(jìn)制 = 10)

找到具體的位置:


_close在Symbols的位置.png

3、Look up string table entry by adding offset from symbol table entry to string table base

通過Symbols的String Table Index偏移量CE找到對應(yīng)在String Table的位置

image.png

String Table的起始值是:0x379C


String Table.png

字符串的位置:0x379C + 0xCE = 0x386A

_close在String Table的位置.png
385C : 66
385D : 6F
      .
      .
      .
386A : 5F       // _     
38BF : 63       // c
38C0 : 6C      // l
38C1 : 6F      // o
38C2 : 73      // s
38C3 : 65      // e

lPush._open._pri  //  `_open`

16進(jìn)制:      5F  63  6C  6F  73 65
字    形:     _  c   l   o   s   e

_是函數(shù)的開始 .是分隔符

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容