那既然这是一个EXE,我们现在先来分析一下这个表(我写在下面的,都已经按照小端调整过来了)
![](http://tiebapic.baidu.com/forum/w%3D580/sign=a2d4e01f5f4c510faec4e21250582528/1405b21c8701a18ba2462c98db2f07082a38fe8d.jpg?tbpicau=2025-02-24-05_3f8a6ae873acd5cf34ecc8ed4ae9bcbc)
typedef struct _IMAGE_SECTION_HEADER {
BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
union {
DWORD PhysicalAddress;
DWORD VirtualSize;
} Misc; -------------->00 03 BC 64 第二部分
DWORD VirtualAddress; 00 00 10 00 第三部分
DWORD SizeOfRawData; 00 03 BE 00 第四部分
DWORD PointerToRawData; 00 00 04 00 第五部分
DWORD PointerToRelocations;
DWORD PointerToLinenumbers;
WORD NumberOfRelocations;
WORD NumberOfLinenumbers;
DWORD Characteristics;
} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
【显然在软件里作者显示的顺序与在文件里的排列是不是同一个顺序】
第一个数组8字节,都是ACSII
然后第二部分,是一个4字节的UNION。按照楼上的文章,这是一个EXE文件,它应该被解读为第二个结构体( VirtualSize),意思是在这段数据的【实际大小】
In an EXE, it holds the actual size of the code or data。
第三部分,重点,虽然英文是VR,实际上是【RVA】,意思是这一段代码,被映射到内存里以后,从楼上提到的Image Base点的偏移!这里RVA是1000
With Microsoft tools, the first section defaults to an RVA of 0x1000.
第四部分,重点,SizeOfRawData,意思是
【实际大小】向上取整到【file alignment】的倍数。
In EXEs, this field contains the size of the section after it's been rounded up to the file alignment size. For example, assume a file alignment size of 0x200. If the VirtualSize field from above says that the section is 0x35A bytes in length, this field will say that the section is 0x400 bytes long.
豚酱评点:
不知所谓!!!!!!!!!!!!!!!!!!!!!!!!
按照人类的逻辑,raw data就是未经处理的数据,virtual size是虚拟的大小。
本来按照英语,未经处理的数据是原大小,而virtual size才是真正被读进内存的大小,但是微软却偏要反过来!?
我有空一定要去外网吐槽一下!
以下数字按照十六进制运算:
3BC64 / 200 = 1DE并且有余数
(1DE+1)=1DF
1DF*200=3BE00
第五部分:
这一段在【真正硬盘中文件中的起始地址大小】
A file pointer to the first page within the COFF file. This value must be a multiple of the FileAlignment member of the IMAGE_OPTIONAL_HEADER structure. If a section contains only uninitialized data, set this member is zero.
This is the file-based offset of where the raw data emitted by the compiler or assembler can be found. If your program memory maps a PE or COFF file itself (rather than letting the operating system load it), this field is more important than the VirtualAddress field. You'll have a completely linear file mapping in this situation, so you'll find the data for the sections at this offset, rather than at the RVA specified in the VirtualAddress field.