我正在尝试自动分析 .DLL 的导出函数中的指令,并且需要能够在不使用调试器的情况下从磁盘静态提升每个导出函数的入口点的前几条指令。
我为每个导出的函数检索正确的 RVA(由 objdump 的结果验证):
$objdump -p examples/MathLibrary.dll
...
Export Table:
DLL name: MathLibrary.dll
Ordinal base: 1
Ordinal RVA Name
1 0x11212 fibonacci_current
2 0x1118b fibonacci_index
3 0x1104b fibonacci_init
4 0x11307 fibonacci_next
然后使用以下方法计算似乎正确的文件偏移量:
fo = exports.address - section.VirtualAddress + section.PointerToRawData
节是指 .text。这给了我:
1 RVA 0x11212 'fibonacci_current' file offset: 1554
Seeking to offset: 1554 to read 48 bytes.
Read 14 bytes 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
2 0x1118b 'fibonacci_index' file offset: 1419
Seeking to offset: 1419 to read 48 bytes.
Read 5 bytes 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
3 0x1104b 'fibonacci_init' file offset: 1099
Seeking to offset: 1099 to read 48 bytes.
Read 37 bytes 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
4 0x11307 'fibonacci_next' file offset: 1799
Seeking to offset: 1799 to read 48 bytes.
Read 9 bytes 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
我得到的看起来像是位于 .text 部分中的有效偏移量,但是那里的字节都是 00。这是由 objdump 验证的。
0001420 0000 0000 0000 0000 0000 0000 0040 4000
0001440 722e 6c65 636f 0000 05bb 0000 f000 0001
0001460 0600 0000 9200 0000 0000 0000 0000 0000
0001500 0000 0000 0040 4200 0000 0000 0000 0000
0001520 0000 0000 0000 0000 0000 0000 0000 0000
*
0002000 cccc cccc e9cc 4173 0000 71e9 002e e900
我究竟做错了什么?这不是代码实际所在的位置吗?它们没有被转发,所以代码就在某处。谢谢你的帮助。