Only deserialze a file once per round of checks

This commit is contained in:
Matt Nadareski
2021-09-10 16:10:15 -07:00
parent 5344de96b2
commit b779f2f546
121 changed files with 162 additions and 225 deletions

View File

@@ -10,7 +10,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// Otherwise, the field is a forwarder RVA, which names a symbol in another DLL.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-address-table</remarks>
internal class ExportAddressTableEntry
public class ExportAddressTableEntry
{
/// <summary>
/// The address of the exported symbol when loaded into memory, relative to the image base.

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// Otherwise, the field is a forwarder RVA, which names a symbol in another DLL.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-pdata-section</remarks>
internal class FunctionTableEntry
public class FunctionTableEntry
{
#region 32-bit MIPS

View File

@@ -8,7 +8,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// Each entry in the hint/name table has the following format
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#hintname-table</remarks>
internal class HintNameTableEntry
public class HintNameTableEntry
{
/// <summary>
/// An index into the export name pointer table.

View File

@@ -8,7 +8,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// Each import address entry has the following format
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-address-table</remarks>
internal class ImportAddressTableEntry
public class ImportAddressTableEntry
{
/// <summary>
/// The RVA of the import lookup table.

View File

@@ -8,7 +8,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// Each import directory entry has the following format
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-directory-table</remarks>
internal class ImportDirectoryTableEntry
public class ImportDirectoryTableEntry
{
/// <summary>
/// The RVA of the import lookup table.

View File

@@ -7,7 +7,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// <summary>
/// Resource type and name strings
/// </summary>
internal class NEResourceNameString
public class NEResourceNameString
{
/// <summary>
/// Length of the type or name string that follows. A zero value

View File

@@ -7,7 +7,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// <summary>
/// A table of resources for this type
/// </summary>
internal class NEResourceTableEntry
public class NEResourceTableEntry
{
/// <summary>
/// File offset to the contents of the resource data,

View File

@@ -10,7 +10,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// EXE header. The first entry in the segment table is segment number 1.
/// The following is the structure of a segment table entry.
/// </summary>
internal class NESegmentTableEntry
public class NESegmentTableEntry
{
/// <summary>
/// Logical-sector offset (n byte) to the contents of the segment

View File

@@ -10,7 +10,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// <summary>
/// Each Resource Data entry describes an actual unit of raw data in the Resource Data area.
/// </summary>
internal class ResourceDataEntry
public class ResourceDataEntry
{
/// <summary>
/// The address of a unit of resource data in the Resource Data area.

View File

@@ -10,7 +10,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// These strings are stored together after the last Resource Directory entry and before the first Resource Data entry.
/// This minimizes the impact of these variable-length strings on the alignment of the fixed-size directory entries.
/// </summary>
internal class ResourceDirectoryString
public class ResourceDirectoryString
{
/// <summary>
/// The size of the string, not including length field itself.

View File

@@ -18,7 +18,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// Offsets are relative to the address in the IMAGE_DIRECTORY_ENTRY_RESOURCE DataDirectory.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#resource-directory-entries</remarks>
internal class ResourceDirectoryTableEntry
public class ResourceDirectoryTableEntry
{
/// <summary>
/// The offset of a string that gives the Type, Name, or Language ID entry, depending on level of table.

View File

@@ -7,7 +7,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Entries
/// <summary>
/// Resource type information block
/// </summary>
internal class ResourceTypeInformationBlock
public class ResourceTypeInformationBlock
{
/// <summary>
/// Type ID. This is an integer type if the high-order bit is

View File

@@ -2,7 +2,7 @@ using System;
namespace BurnOutSharp.ExecutableType.Microsoft
{
internal enum ExecutableType
public enum ExecutableType
{
Unknown,
NE,
@@ -11,7 +11,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#dll-characteristics
[Flags]
internal enum DllCharacteristics : ushort
public enum DllCharacteristics : ushort
{
/// <summary>
/// Reserved, must be zero.
@@ -91,7 +91,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
}
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#optional-header-data-directories-image-only
internal enum ImageDirectory : byte
public enum ImageDirectory : byte
{
/// <summary>
/// The export table address and size. (.edata)
@@ -177,7 +177,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#characteristics
[Flags]
internal enum ImageObjectCharacteristics : ushort
public enum ImageObjectCharacteristics : ushort
{
/// <summary>
/// Image only, Windows CE, and Microsoft Windows NT and later.
@@ -276,7 +276,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
}
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#machine-types
internal enum MachineType : ushort
public enum MachineType : ushort
{
/// <summary>
/// The content of this field is assumed to be applicable to any machine type
@@ -423,7 +423,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
/// s Solo data
/// </summary>
[Flags]
internal enum NeFlags : ushort
public enum NeFlags : ushort
{
/// <summary>
/// Not a process
@@ -509,7 +509,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
/// rr Reference type
/// </summary>
[Flags]
internal enum NrFlags : byte
public enum NrFlags : byte
{
/// <summary>
/// Additive fixup
@@ -550,7 +550,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
////
/// </summary>
[Flags]
internal enum NrStype : byte
public enum NrStype : byte
{
/// <summary>
/// Source type mask
@@ -589,7 +589,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
}
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#optional-header-image-only
internal enum OptionalHeaderType : ushort
public enum OptionalHeaderType : ushort
{
/// <summary>
/// ROM image
@@ -609,7 +609,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
/// http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm
[Flags]
internal enum ResourceTableEntryFlags : ushort
public enum ResourceTableEntryFlags : ushort
{
/// <summary>
/// Resource is not fixed.
@@ -630,7 +630,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
/// <summary>
/// Predefined Resource Types
/// </summary>
internal enum ResourceTypes : ushort
public enum ResourceTypes : ushort
{
RT_CURSOR = 1,
RT_BITMAP = 2,
@@ -662,7 +662,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#section-flags
[Flags]
internal enum SectionCharacteristics : uint
public enum SectionCharacteristics : uint
{
/// <summary>
/// Reserved for future use.
@@ -878,7 +878,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
/// http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm
[Flags]
internal enum SegmentTableEntryFlags : ushort
public enum SegmentTableEntryFlags : ushort
{
/// <summary>
/// Segment-type field.
@@ -962,7 +962,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
}
[Flags]
internal enum TargetOperatingSystems : byte
public enum TargetOperatingSystems : byte
{
/// <summary>
/// Unknown (any "new-format" OS)
@@ -991,7 +991,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
}
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#windows-subsystem
internal enum WindowsSubsystem : ushort
public enum WindowsSubsystem : ushort
{
/// <summary>
/// An unknown subsystem

View File

@@ -4,7 +4,7 @@ using BurnOutSharp.Tools;
namespace BurnOutSharp.ExecutableType.Microsoft.Headers
{
internal class CommonObjectFileFormatHeader
public class CommonObjectFileFormatHeader
{
/// <summary>
/// After the MS-DOS stub, at the file offset specified at offset 0x3c, is a 4-byte signature that identifies the file as a PE format image file.

View File

@@ -4,7 +4,7 @@ using BurnOutSharp.Tools;
namespace BurnOutSharp.ExecutableType.Microsoft.Headers
{
internal class DataDirectoryHeader
public class DataDirectoryHeader
{
/// <summary>
/// The first field, VirtualAddress, is actually the RVA of the table.

View File

@@ -13,7 +13,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Headers
/// and PE executables, usually as stubs so that when they are ran under DOS, they display a warning.
/// </summary>
/// <remarks>https://wiki.osdev.org/MZ</remarks>
internal class MSDOSExecutableHeader
public class MSDOSExecutableHeader
{
#region Standard Fields

View File

@@ -9,7 +9,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Headers
/// Because of the age of the format some items are unclear in meaning.
/// </summary>
/// <remarks>http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm</remarks>
internal class NewExecutableHeader
public class NewExecutableHeader
{
/// <summary>
/// Signature word. [00]

View File

@@ -18,7 +18,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Headers
/// a particular data directory entry goes beyond the optional header.
/// In addition, it is important to validate the optional header magic number for format compatibility.
/// </summary>
internal class OptionalHeader
public class OptionalHeader
{
#region Standard Fields

View File

@@ -11,7 +11,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Headers
/// Instead, the location of the section table is determined by calculating the location of the first byte after the headers.
/// Make sure to use the size of the optional header as specified in the file header.
/// </summary>
internal class SectionHeader
public class SectionHeader
{
/// <summary>
/// An 8-byte, null-padded UTF-8 encoded string.

View File

@@ -8,7 +8,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
/// The WIN-NE executable format, designed for Windows 3.x, was the "NE", or "New Executable" format.
/// Again, a 16bit format, it alleviated the maximum size restrictions that the MZ format had.
/// </summary>
internal class NewExecutable
public class NewExecutable
{
#region Headers

View File

@@ -12,7 +12,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
/// A COFF object file header consists of a COFF file header and an optional header.
/// In both cases, the file headers are followed immediately by section headers.
/// </summary>
internal class PortableExecutable
public class PortableExecutable
{
#region Headers

View File

@@ -4,7 +4,7 @@ using BurnOutSharp.Tools;
namespace BurnOutSharp.ExecutableType.Microsoft.Resources
{
internal class FixedFileInfo
public class FixedFileInfo
{
/// <summary>
/// Contains the value 0xFEEF04BD.

View File

@@ -11,7 +11,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Resources
/// Either high-order or low-order word can be zero, indicating that the file is language or code page independent.
/// If the Var structure is omitted, the file will be interpreted as both language and code page independent.
/// </summary>
internal class LanguageCodePage
public class LanguageCodePage
{
/// <summary>
/// The low-order word of each DWORD must contain a Microsoft language identifier

View File

@@ -6,7 +6,7 @@ using BurnOutSharp.Tools;
namespace BurnOutSharp.ExecutableType.Microsoft.Resources
{
internal class Resource
public class Resource
{
/// <summary>
/// The length, in bytes, of the resource structure.

View File

@@ -2,7 +2,7 @@ using System.IO;
namespace BurnOutSharp.ExecutableType.Microsoft.Resources
{
internal class StringFileInfo : Resource
public class StringFileInfo : Resource
{
/// <summary>
/// An array of one or more StringTable structures.

View File

@@ -4,7 +4,7 @@ using BurnOutSharp.Tools;
namespace BurnOutSharp.ExecutableType.Microsoft.Resources
{
internal class StringStruct : Resource
public class StringStruct : Resource
{
/// <summary>
/// Typically contains a list of languages that the application or DLL supports.

View File

@@ -3,7 +3,7 @@ using System.IO;
namespace BurnOutSharp.ExecutableType.Microsoft.Resources
{
internal class StringTable : Resource
public class StringTable : Resource
{
/// <summary>
/// An array of one or more String structures.

View File

@@ -2,7 +2,7 @@ using System.IO;
namespace BurnOutSharp.ExecutableType.Microsoft.Resources
{
internal class Var : Resource
public class Var : Resource
{
/// <summary>
/// An array of one or more values that are language and code page identifier pairs.

View File

@@ -2,7 +2,7 @@ using System.IO;
namespace BurnOutSharp.ExecutableType.Microsoft.Resources
{
internal class VarFileInfo : Resource
public class VarFileInfo : Resource
{
/// <summary>
/// Typically contains a list of languages that the application or DLL supports.

View File

@@ -2,7 +2,7 @@ using System.IO;
namespace BurnOutSharp.ExecutableType.Microsoft.Resources
{
internal class VersionInfo : Resource
public class VersionInfo : Resource
{
/// <summary>
/// Arbitrary data associated with this VS_VERSIONINFO structure.

View File

@@ -9,7 +9,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Sections
/// The target platform determines which of the three function table entry format variations described below is used.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-edata-section-image-only</remarks>
internal class ExceptionHandlingSection
public class ExceptionHandlingSection
{
/// <summary>
/// Array of function table entries that are used for exception handling

View File

@@ -8,7 +8,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Sections
/// Exported symbols are generally found in DLLs, but DLLs can also import symbols.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-edata-section-image-only</remarks>
internal class ExportDataSection
public class ExportDataSection
{
/// <summary>
/// A table with just one row (unlike the debug directory).

View File

@@ -18,7 +18,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Sections
/// Hint-Name Table
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-idata-section</remarks>
internal class ImportDataSection
public class ImportDataSection
{
/// <summary>
/// Import directory table

View File

@@ -13,7 +13,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Sections
// then that table lists directory entries at the next level down
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-rsrc-section</remarks>
internal class ResourceSection
public class ResourceSection
{
/// <summary>
/// A table with just one row (unlike the debug directory).

View File

@@ -8,7 +8,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// An ordinal number is used as an index into the export address table.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-address-table</remarks>
internal class ExportAddressTable
public class ExportAddressTable
{
/// <remarks>Number of entries is defined externally</remarks>
public ExportAddressTableEntry[] Entries;

View File

@@ -9,7 +9,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// The export directory table contains address information that is used to resolve imports to the entry points within this image.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-directory-table</remarks>
internal class ExportDirectoryTable
public class ExportDirectoryTable
{
/// <summary>
/// Reserved, must be 0.

View File

@@ -10,7 +10,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// The pointers are ordered lexically to allow binary searches.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-name-pointer-table</remarks>
internal class ExportNamePointerTable
public class ExportNamePointerTable
{
/// <remarks>Number of entries is defined externally</remarks>
public uint[] Entries;

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// These public export names are not necessarily the same as the private symbol names that the symbols have in their own image file and source code, although they can be.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-ordinal-table</remarks>
internal class ExportNameTable
public class ExportNameTable
{
/// <remarks>Number of entries is defined externally</remarks>
public string[] Entries;

View File

@@ -10,7 +10,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// In other words, the ordinal base must be subtracted from the ordinals to obtain true indexes into the export address table.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-ordinal-table</remarks>
internal class ExportOrdinalTable
public class ExportOrdinalTable
{
/// <remarks>Number of entries is defined externally</remarks>
public ushort[] Entries;

View File

@@ -9,7 +9,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// The target platform determines which of the three function table entry format variations described below is used.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-pdata-section</remarks>
internal class FunctionTable
public class FunctionTable
{
/// <remarks>Number of entries is defined externally</remarks>
public FunctionTableEntry[] Entries;

View File

@@ -7,7 +7,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// One hint/name table suffices for the entire import section.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#hintname-table</remarks>
internal class HintNameTable
public class HintNameTable
{
/// <remarks>Number of entries is defined externally</remarks>
public HintNameTableEntry[] Entries;

View File

@@ -11,7 +11,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// The loader typically processes the binding.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-address-table</remarks>
internal class ImportAddressTable
public class ImportAddressTable
{
/// <remarks>Number of entries is known after parsing</remarks>
public ImportAddressTableEntry[] Entries;

View File

@@ -11,7 +11,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// The last directory entry is empty (filled with null values), which indicates the end of the directory table.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-directory-table</remarks>
internal class ImportDirectoryTable
public class ImportDirectoryTable
{
/// <remarks>Number of entries is known after parsing</remarks>
public ImportDirectoryTableEntry[] Entries;

View File

@@ -13,7 +13,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// The last entry is set to zero (NULL) to indicate the end of the table.
/// </summary>
/// <remarks>https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-lookup-table</remarks>
internal class ImportLookupTable
public class ImportLookupTable
{
/// <remarks>Number of entries is known after parsing</remarks>
public uint[] EntriesPE32;

View File

@@ -16,7 +16,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// resource. It also defines the location and size of the resource.
/// </summary>
/// <remarks>http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm</remarks>
internal class NEResourceTable
public class NEResourceTable
{
/// <summary>
/// Alignment shift count for resource data.

View File

@@ -11,7 +11,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft.Tables
/// This data structure should be considered the heading of a table
/// because the table actually consists of directory entries and this structure
/// </summary>
internal class ResourceDirectoryTable
public class ResourceDirectoryTable
{
/// <summary>
/// Resource flags.