为什么我没有得到“PE ”
本文关键字:PE 为什么 | 更新日期: 2023-09-27 18:05:47
来自PE规格:
在位置
0x3c
处,存根具有PE签名的文件偏移量。此信息使Windows能够正确执行映像文件,即使它有一个MS DOS存根。这个文件偏移量位于链接时定位0x3c
2.2。签名(仅限图像)
MS DOS存根后,在偏移量0x3c
指定的文件偏移量处,是一个4字节的签名,用于标识文件为PE格式的映像文件。此签名为"PE'0'0"(即字母" P "answers" E "后面跟着两个空字节)。
I try read these bytes:
using System;
using System.IO;
class Program {
const String fileName = @".'some_application.exe";
const Int64 peMarkerPosition = 0x3c;
static void Main(string[] args) {
using (FileStream fs = new FileStream(fileName, FileMode.Open,
FileAccess.Read)) {
Byte[] marker = new Byte[4];
fs.Position = peMarkerPosition;
fs.Read(marker, 0, marker.Length);
// Now I expect 'marker'has such bytes: "PE'0'0".
fs.Close();
foreach (Byte b in marker) {
Console.Write(Convert.ToChar(b)); // But I see other values...
}
Console.WriteLine("'nPress any key for exit...");
Console.ReadKey();
}
}
}
但marker
变量有0x08
, 0x01
, 0x00
和x0x00
字节(第一个和第二个不是P
和E
字符)…为什么我得到这样的结果?