mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 08:18:36 +03:00
Refactor PEFormat into smaller classes following Single Responsibility Principle
This commit is contained in:
30
X86Disassembler/PE/Parsers/FileHeaderParser.cs
Normal file
30
X86Disassembler/PE/Parsers/FileHeaderParser.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.IO;
|
||||
|
||||
namespace X86Disassembler.PE.Parsers
|
||||
{
|
||||
/// <summary>
|
||||
/// Parser for the File header of a PE file
|
||||
/// </summary>
|
||||
public class FileHeaderParser : IParser<FileHeader>
|
||||
{
|
||||
/// <summary>
|
||||
/// Parse the File header from the binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">The binary reader positioned at the start of the File header</param>
|
||||
/// <returns>The parsed File header</returns>
|
||||
public FileHeader Parse(BinaryReader reader)
|
||||
{
|
||||
FileHeader header = new FileHeader();
|
||||
|
||||
header.Machine = reader.ReadUInt16();
|
||||
header.NumberOfSections = reader.ReadUInt16();
|
||||
header.TimeDateStamp = reader.ReadUInt32();
|
||||
header.PointerToSymbolTable = reader.ReadUInt32();
|
||||
header.NumberOfSymbols = reader.ReadUInt32();
|
||||
header.SizeOfOptionalHeader = reader.ReadUInt16();
|
||||
header.Characteristics = reader.ReadUInt16();
|
||||
|
||||
return header;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user