我最近开始学习
PE(可移植可执行文件)
文件格式,更具体地说是PE / COFF
。我正在阅读Randy Kath的教程。当我浏览MZ DOS头的结构时,我发现MZ DOS头使用e_magic
字段中的签名进行验证。该结构如下:typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header
USHORT e_magic; // Magic number
USHORT e_cblp; // Bytes on last page of file
USHORT e_cp; // Pages in file
USHORT e_crlc; // Relocations
USHORT e_cparhdr; // Size of header in paragraphs
USHORT e_minalloc; // Minimum extra paragraphs needed
USHORT e_maxalloc; // Maximum extra paragraphs needed
USHORT e_ss; // Initial (relative) SS value
USHORT e_sp; // Initial SP value
USHORT e_csum; // Checksum
USHORT e_ip; // Initial IP value
USHORT e_cs; // Initial (relative) CS value
USHORT e_lfarlc; // File address of relocation table
USHORT e_ovno; // Overlay number
USHORT e_res[4]; // Reserved words
USHORT e_oemid; // OEM identifier (for e_oeminfo)
USHORT e_oeminfo; // OEM information; e_oemid specific
USHORT e_res2[10]; // Reserved words
LONG e_lfanew; // File address of new exe header
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
教程中提到:
所有兼容MS-DOS的可执行文件都将此值设置为0x54AD,它代表ASCII字符MZ。
我的问题也一样。
M
和Z
的ascii值分别是77
和90
,在十六进制中分别转换为4D
和5A
。那么0x54AD
如何表示MZ
?
这可能是一个愚蠢的问题。但如果太傻,请帮助我理解。
谢谢。