: How does the RVA and raw in the PE file convert each other ?" (See snow)

Source: Internet
Author: User
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.