I have answered this question in dfcg. Let's turn it over.+ --------- +
| Segment name virtual address virtual size physical address physical size mark |
+ --------- +
| Name voffset vsize roffset rsize flags |
+ --------- +
|. Text 00001000 00000092 00000400 00000200 |
|. RDATA 00002000 000000f6 00000600 00000200 40000040 |
|. Data 00003000 0000018e 00000800 00000200 c0000040 |
|. Rsrc 00004000 000003a0 00000a00 00000400 c0000040 |
+ --------- +
The formula for calculating the file virtual offset address and file physical offset address is as follows:
>>>>>>> Vatofileoffset (virtual address to file offset address)
For example, VA = 00401000 (virtual address)
Imagebase = 00400000 (base address)
Vrk = voffset-roffset = 00001000-00000400 = c00 (obtain the vrk value between the file virtual address and the file physical address)
Fileoffset = va-imagebase-vrk = 00401000-00400000-c00 = 400 (the offset of the physical address of the file)
For example, if Va = 00401325, then:
Fileoffset = va-imagebase-vrk = 00401325-00400000-c00 = 725
>>>>>> Fileoffsettova (convert the file offset address to the virtual address)
For example, fileoffset = 435 (File offset address)
Va = fileoffset + imagebase + vrk = 435 + 00400000 + c00 = 00401035 (virtual address)
There is also a figure from the boss: