便携式可执行文件 DOS header 长度
Portable executable DOS header length
我一直在研究这个图像来构建一个可移植的可执行文件:https://i.imgur.com/LIImg.jpg
image/walkthrough 表示 PE header 从 0x40(十进制为 64)开始。然而,十六进制转储显示 DOS header 是 32 字节长。每个字段是否以 4 个字节打包?
看WinNT.h中的IMAGE_DOS_HEADER,好像也不合适。它有 16 个 2 字节的字段,一个 4 长度的 2 字节数组,一个 10 长度的 2 字节数组,以及指向 PE 位置的 4 字节指针。不管你怎么看,它加起来都不等于 64...
However, the hexadecimal dump says the DOS header is 32 bytes long.
Offset:0x30
00 00 00 00-00 00 00 00-00 00 00 00-40 00 00 00
0x30 + 16 = 0x40 (64).
typedef struct _IMAGE_DOS_HEADER
{
// Cumulative size:
WORD e_magic; // 2
WORD e_cblp; // 4
WORD e_cp; // 6
WORD e_crlc; // 8
WORD e_cparhdr; // 10
WORD e_minalloc; // 12
WORD e_maxalloc; // 14
WORD e_ss; // 16
WORD e_sp; // 18
WORD e_csum; // 20
WORD e_ip; // 22
WORD e_cs; // 24
WORD e_lfarlc; // 26
WORD e_ovno; // 28
WORD e_res[4]; // 36
WORD e_oemid; // 38
WORD e_oeminfo; // 40
WORD e_res2[10]; // 60
LONG e_lfanew; // 64
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
It has 16 2-byte fields, one 4-length 2-byte array, one 10-length 2-byte array, and the 4-byte pointer to the PE location. Any way you look at that it doesn't add up to 64...
(16 * 2) = 32
(4 * 2) = 8
(10 * 2) = 20
+ 4
------------------
64
我一直在研究这个图像来构建一个可移植的可执行文件:https://i.imgur.com/LIImg.jpg
image/walkthrough 表示 PE header 从 0x40(十进制为 64)开始。然而,十六进制转储显示 DOS header 是 32 字节长。每个字段是否以 4 个字节打包?
看WinNT.h中的IMAGE_DOS_HEADER,好像也不合适。它有 16 个 2 字节的字段,一个 4 长度的 2 字节数组,一个 10 长度的 2 字节数组,以及指向 PE 位置的 4 字节指针。不管你怎么看,它加起来都不等于 64...
However, the hexadecimal dump says the DOS header is 32 bytes long.
Offset:0x30
00 00 00 00-00 00 00 00-00 00 00 00-40 00 00 00
0x30 + 16 = 0x40 (64).
typedef struct _IMAGE_DOS_HEADER
{
// Cumulative size:
WORD e_magic; // 2
WORD e_cblp; // 4
WORD e_cp; // 6
WORD e_crlc; // 8
WORD e_cparhdr; // 10
WORD e_minalloc; // 12
WORD e_maxalloc; // 14
WORD e_ss; // 16
WORD e_sp; // 18
WORD e_csum; // 20
WORD e_ip; // 22
WORD e_cs; // 24
WORD e_lfarlc; // 26
WORD e_ovno; // 28
WORD e_res[4]; // 36
WORD e_oemid; // 38
WORD e_oeminfo; // 40
WORD e_res2[10]; // 60
LONG e_lfanew; // 64
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
It has 16 2-byte fields, one 4-length 2-byte array, one 10-length 2-byte array, and the 4-byte pointer to the PE location. Any way you look at that it doesn't add up to 64...
(16 * 2) = 32
(4 * 2) = 8
(10 * 2) = 20
+ 4
------------------
64