-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessedPEFile.cs
More file actions
54 lines (44 loc) · 1.92 KB
/
ProcessedPEFile.cs
File metadata and controls
54 lines (44 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.IO;
using CsharpFunctionDumper.AssemblyProcessing;
using CsharpFunctionDumper.CLRProcessing;
using CsharpFunctionDumper.COFF;
using CsharpFunctionDumper.Optional;
namespace CsharpFunctionDumper
{
/// <summary>
/// A state for the current PE file being processed.
/// </summary>
public class ProcessedPEFile
{
public DOSHeader DosHeader { get; private set; }
public COFFHeader CoffHeader { get; private set; }
public OptionalHeader OptionalHeader { get; private set; }
public SectionsHeaders SectionsHeaders { get; private set; }
public CLRHeader ClrHeader { get; private set; }
public MetaDataHeader MetaDataHeader { get; private set; }
public ProcessedPEFile(AssemblyBuffer assemblyBuffer)
{
this.DosHeader = new DOSHeader(assemblyBuffer);
this.CoffHeader = new COFFHeader(assemblyBuffer, this.DosHeader);
this.OptionalHeader = new OptionalHeader(assemblyBuffer);
this.SectionsHeaders = new SectionsHeaders(assemblyBuffer);
this.ClrHeader = new CLRHeader(assemblyBuffer, this.OptionalHeader, this.SectionsHeaders);
this.MetaDataHeader = new MetaDataHeader(assemblyBuffer, this.ClrHeader, this.SectionsHeaders);
}
/// <summary>
/// Processes a PE file at a specific directory.
/// </summary>
/// <param name="filePath"> an ABSOLUTE path to the target file. </param>
/// <returns> The processedPEFile from it .</returns>
public static ProcessedPEFile ProcessFile(string filePath)
{
byte[] buffer = File.ReadAllBytes(filePath);
AssemblyBuffer assemblyBuffer = new AssemblyBuffer("", buffer);
return new ProcessedPEFile(assemblyBuffer);
}
public string GetOutput()
{
return this.MetaDataHeader.OutputData();
}
}
}