Addresses in reverse engineering

2023年7月17日


Relative Virtual Address (RVA)

RVA通常用module name + 地址表示。如图,CheatEngine的Memory Viewer显示的是RVA。

:Our interested code is at v2game.exe+563d47 in CheatEngine notation

x64dbg可以转换各种地址。在CPU tab,右击选择Go to -> Expression (ctrl+G),输入module name + 地址[1],下方会显示section offset。x64dbg不显示.exe。点击OK,CPU tab就会显示那一行代码。注意下方的status bar,第一个地址是section offset,第二个是RVA,第三个是file offset。

:用x64dbg的expression可以转换地址。在status bar,.text:010b3d47是section offset,v2game.exe:$563147是RVA,#563147是file offset。

Virtual Address (VA)

RVA + ImageBase = VA

VA不经常用到。

注意,《The IDA Pro Book, 2nd Edition: The Unofficial Guide to the World’s Most Popular Disassembler》(Chapter 5.1)把virtual address当作section offset。

Section offset

PE文件格式定义了多个sections,包括.text, .data, .rdata, .idata, .reloc, .rsrc, .debug等。[2] .text指的是程序代码。

所以Section offset .text:010b3d47指的是在.text section里的第010b3d47行。

File offset

File offset指的是一行代码在整个exe文件中的位置。

在IDA Interactive Disassembler,用file offset跳转比较方便。在菜单选择 Jump -> Jump to file offset,然后输入地址,这里不需要输入module name。点击OK,当前view就会跳转到那一行。

在Disassembly view,左边是section offset,下面状态栏的第一个地址是file offset。

:在IDA,状态栏的第一个地址00563147是file offset,第二个地址是section offset(省略section name)

Hex Editor一般显示的是file offset。我用HxD Hex Editor搜索字符串teleport,发现其中一个位置是9ee880。这是file offset。把该地址输入IDA, Jump to file offset,发现该地址是在.rdata section。

参考资料

  1. . Values. x64dbg documentation. [2023-07-18].
  2. SATYAJIT DAULAGUPHU. A Comprehensive Guide To PE Structure, The Layman’s Way. . 2022-08-15 [2023-07-18].