Worked Example: RVA to File Offset
Suppose .text has:
VirtualAddress= 0x1000VirtualSize= 0x5000PointerToRawData= 0x400SizeOfRawData= 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.