Converting RVA to File Offset
Use the section table. Each section header gives:
VirtualAddress: the section's RVA in memory.VirtualSize: its size in memory.PointerToRawData: the section's file offset on disk.SizeOfRawData: its size on disk.
Algorithm to convert an RVA:
- Find the section where
VirtualAddress≤ RVA <VirtualAddress + VirtualSize. - Compute: fileOffset = RVA - VirtualAddress + PointerToRawData
Key Takeaway
RVA to offset = subtract the section's VirtualAddress, add its PointerToRawData.