WCU / Cybersecurity
~/CSC 471/Class 04/KP 08
Class 04 · KP 08 / 20

Worked Example: RVA to File Offset

on disk (file offset)PointerToRawDataraw bytesin memory (RVA)VirtualAddressmapped bytesfileOffset = RVA − VirtualAddress + PointerToRawData
RVA-to-offset: the section table maps a memory address back to the file.

Suppose .text has:

  • VirtualAddress = 0x1000
  • VirtualSize = 0x5000
  • PointerToRawData = 0x400
  • SizeOfRawData = 0x5000

We want to read the byte at RVA 0x1234.

  • Is 0x1000 ≤ 0x1234 < 0x6000 ? Yes — it lives in .text.
  • fileOffset = 0x1234 - 0x1000 + 0x400 = 0x234 + 0x400 = 0x634.

So the AddressOfEntryPoint RVA maps this way too: an entry point RVA of

0x1234 is found at disk offset 0x634.

Sanity check

If an RVA falls in no section (a gap), the conversion is undefined — a

classic sign of a malformed or deliberately weird PE.