mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-09 02:16:55 +00:00
Placeholder for section table trailer data
This commit is contained in:
@@ -103,11 +103,6 @@ namespace SabreTools.Serialization.Deserializers
|
||||
pex.SectionTable[i] = ParseSectionHeader(data);
|
||||
}
|
||||
|
||||
// TODO: Figure out a way to determine the end of the data here
|
||||
// to find hidden things between the end of the section table and
|
||||
// the beginning of the next data block. Some packers and protections
|
||||
// can hide things here, e.g. ActiveMark
|
||||
|
||||
#endregion
|
||||
|
||||
#region COFF Symbol Table and COFF String Table
|
||||
|
||||
@@ -390,6 +390,45 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <inheritdoc cref="Models.PortableExecutable.Executable.SectionTable"/>
|
||||
public Models.PortableExecutable.SectionHeader[]? SectionTable => Model.SectionTable;
|
||||
|
||||
/// <summary>
|
||||
/// Data after the section table, if it exists
|
||||
/// </summary>
|
||||
public byte[] SectionTrailerData
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_sectionTrailerDataLock)
|
||||
{
|
||||
// If we already have cached data, just use that immediately
|
||||
if (_sectionTrailerData != null)
|
||||
return _sectionTrailerData;
|
||||
|
||||
if (Stub?.Header?.NewExeHeaderAddr == null)
|
||||
{
|
||||
_sectionTrailerData = [];
|
||||
return _sectionTrailerData;
|
||||
}
|
||||
if (COFFFileHeader == null)
|
||||
{
|
||||
_sectionTrailerData = [];
|
||||
return _sectionTrailerData;
|
||||
}
|
||||
|
||||
// Get the offset from the end of the section table
|
||||
long endOfSectionTable = Stub.Header.NewExeHeaderAddr
|
||||
+ 24 // Signature size + COFF file header size
|
||||
+ COFFFileHeader.SizeOfOptionalHeader
|
||||
+ (COFFFileHeader.NumberOfSections * 40); // Size of a section header
|
||||
|
||||
// TODO: Figure out how to determine the end of the extra data
|
||||
_sectionTrailerData = [];
|
||||
|
||||
// Cache and return the stub executable data, even if null
|
||||
return _sectionTrailerData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Models.PortableExecutable.Executable.Stub"/>
|
||||
public Models.MSDOS.Executable? Stub => Model.Stub;
|
||||
|
||||
@@ -745,6 +784,16 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// </summary>
|
||||
private readonly object _sectionStringDataLock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Data after the section table, if it exists
|
||||
/// </summary>
|
||||
private byte[]? _sectionTrailerData = null;
|
||||
|
||||
/// <summary>
|
||||
/// Lock object for <see cref="_sectionTrailerData"/>
|
||||
/// </summary>
|
||||
private readonly object _sectionTrailerDataLock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Stub executable data, if it exists
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user