我正在尝试解析 Windows 中的 PE 文件并从此结构中获取数据

我写了这段代码,它从 exe 文件中读取字节。
#include <Windows.h>
int main()
{
// open the file for binary reading
std::ifstream file;
file.open("D:/SomeProgram.exe", ios_base::binary);
if (!file.is_open())
return 1;
// get the length of the file
file.seekg(0, ios::end);
size_t fileSize = file.tellg();
file.seekg(0, ios::beg);
// create a vector to hold all the bytes in the file
std::vector<byte> data(fileSize, 0);
// read the file
file.read(reinterpret_cast<char*>(&data[0]), fileSize);
Run Code Online (Sandbox Code Playgroud)
我不知道如何获取数据,其中包含e_magic, e_cbip, e_cp.... 和最重要的e_ifanew. 我知道,这个结构 IMAGE_DOS_HEADER 存储在 Windows.h 中,但我不知道如何使用它从任何 exe …