我试图通过静态分析可执行文件来找到类“Greeter”的“vftable”符号的地址(或从基地址的偏移量)。在 Visual Studio 中通过添加断点和反汇编“Greeter”类的构造函数对其进行动态分析时,我能够找到符号的地址。
00007FF76A891951 lea rcx,[Greeter::`vftable' (07FF76A89ACE0h)]
00007FF76A891958 mov qword ptr [rax],rcx
但这是它的运行时地址。我需要找到一种方法来计算偏移量,方法是使用“dumpbin”之类的工具或类似的工具。我知道我可以通过使用上面的地址来计算偏移量,但我需要一种方法来自动化它,所以它必须通过一个工具。
我尝试在 exe 上使用“dumpbin”来反汇编它并找到与 Greeter 类相同的指令:
0000000140011951: 48 8D 0D 88 93 00 lea rcx,[??_7Greeter@@6B@]
0000000140011958: 48 89 08 mov qword ptr [rax],rcx
所以,我开始尝试找到对这个符号的引用??_7Greeter@@6B@
我尝试通过以下命令使用“dumpbin”:
dumpbin /all ConsoleApplication.obj > cout
我得到以下相关输出:
Section length 18, #relocs 3, #linenums 0, checksum 0, selection 6 (pick largest)
Relocation CRC BDB82F45
134 00000008 SECT43 notype External | ??_7Greeter@@6B@ (const Greeter::`vftable')
135 00000000 SECT44 notype Static | .rdata
我也得到了这个输出:
SECTION HEADER #43
.rdata name
0 physical address
0 virtual address
18 size of raw data
DA3B file pointer to raw data (0000DA3B to 0000DA52)
DA53 file pointer to relocation table
0 file pointer to line numbers
3 number of relocations
0 number of line numbers
40401040 flags
Initialized Data
COMDAT; sym= "const Greeter::`vftable'" (??_7Greeter@@6B@)
8 byte align
Read Only
RAW DATA #43
00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000010: 00 00 00 00 00 00 00 00 ........
RELOCATIONS #43
Symbol Symbol
Offset Type Applied To Index Name
-------- ---------------- ----------------- -------- ------
00000000 ADDR64 00000000 00000000 14C ??_R4Greeter@@6B@ (const Greeter::`RTTI Complete Object Locator')
00000008 ADDR64 00000000 00000000 8C ?sayHello@Greeter@@UEAAX_J00@Z (public: virtual void __cdecl Greeter::sayHello(__int64,__int64,__int64))
00000010 ADDR64 00000000 00000000 8D ?initUser@Greeter@@UEAAXXZ (public: virtual void __cdecl Greeter::initUser(void))
有人知道我将如何找到这个符号的偏移量吗?我需要使用特定的“dumpbin”选项来打印反汇编中提到的符号的偏移量吗?