内存部分定义

问题描述

我正在参加一个汇编课程,并且在试图弄清楚一个问题时很费劲。我们有以下几点:

enter image description here

在我的一生中,我一直试图通过谷歌来解决这个问题,但没有找到太多,不幸的是,我们的文本中没有任何内容可以指导我。我希望有人能够指导我解决这个问题。

1)。 .text 部分加载到内存后的大小是多少? 2)。 .data 部分加载到内存后的 RVA 是多少? 3)。磁盘上 .data 部分的物理大小是多少?

解决方法

如果您在 Google 上搜索 COFF 规范,它会带您到 Section Table (Section Headers)
转储显然包含三个 COFF 部分标题。如果您更喜欢 assembly 中的描述,请点击此处:

COFF_SECTION_HEADER   STRUC
.Name                 DB 8*BYTE ; Section name,NULL padded.
.VirtualSize          DD  ; Total aligned section size when loaded in memory. 
.VirtualAddress       DD  ; RVA of section relative to ImageBase when loaded.
.SizeOfRawData        DD  ; Section size in the file (before loaded).
.PointerToRawData     DD  ; File pointer to section data. 
.PointerToRelocations DD  ; File pointer to relocations. NULL if no relocations.
.PointerToLinenumbers DD  ; File pointer to line-number entries or NULL. 
.NumberOfRelocations  DW  ; Number of relocation entries for this section.
.NumberOfLinenumbers  DW  ; Number of line-number entries for this section.
.Characteristics      DD  ; Section properties.
ENDSTRUC 

请记住,在 LittleEndian 中,DWORD 以不太重要的字节(反转)开头,例如 .VirtualSize 部分的 .text,它转储为 00100000 实际上是 {{ 1}},即加载到内存中时为 1 KB。 PE 文件中 0x00001000.data 部分的大小保存在成员 .text 中。