Move unused parser

This commit is contained in:
Matt Nadareski
2026-02-12 16:04:16 -05:00
parent c5f732584b
commit d56c8a3d83
2 changed files with 25 additions and 30 deletions

View File

@@ -1,6 +1,5 @@
using System;
using SabreTools.Data.Models.COFF;
using SabreTools.Data.Models.PortableExecutable;
using SabreTools.IO.Extensions;
#pragma warning disable IDE0017 // Simplify object initialization
@@ -143,34 +142,5 @@ namespace SabreTools.Data.Extensions
}
#endregion
// TODO: Implement other resource types from https://learn.microsoft.com/en-us/windows/win32/menurc/resource-file-formats
#region Resources
/// <summary>
/// Parse a byte array into a ResourceHeader
/// </summary>
/// <param name="data">Data to parse</param>
/// <param name="offset">Offset into the byte array</param>
/// <returns>A filled ResourceHeader on success, null on error</returns>
public static Models.PortableExecutable.Resource.ResourceHeader ParseResourceHeader(this byte[] data, ref int offset)
{
// Read in the table
var obj = new Models.PortableExecutable.Resource.ResourceHeader();
obj.DataSize = data.ReadUInt32LittleEndian(ref offset);
obj.HeaderSize = data.ReadUInt32LittleEndian(ref offset);
obj.ResourceType = (ResourceType)data.ReadUInt32LittleEndian(ref offset); // TODO: Could be a string too
obj.Name = data.ReadUInt32LittleEndian(ref offset); // TODO: Could be a string too
obj.DataVersion = data.ReadUInt32LittleEndian(ref offset);
obj.MemoryFlags = (MemoryFlags)data.ReadUInt16LittleEndian(ref offset);
obj.LanguageId = data.ReadUInt16LittleEndian(ref offset);
obj.Version = data.ReadUInt32LittleEndian(ref offset);
obj.Characteristics = data.ReadUInt32LittleEndian(ref offset);
return obj;
}
#endregion
}
}

View File

@@ -14,6 +14,7 @@ using static SabreTools.Data.Models.PortableExecutable.Constants;
#pragma warning disable IDE0017 // Simplify object initialization
namespace SabreTools.Serialization.Readers
{
// TODO: Implement other resource types from https://learn.microsoft.com/en-us/windows/win32/menurc/resource-file-formats
public class PortableExecutable : BaseBinaryReader<Executable>
{
/// <inheritdoc/>
@@ -2582,6 +2583,30 @@ namespace SabreTools.Serialization.Readers
return obj;
}
/// <summary>
/// Parse a byte array into a ResourceHeader
/// </summary>
/// <param name="data">Data to parse</param>
/// <param name="offset">Offset into the byte array</param>
/// <returns>A filled ResourceHeader on success, null on error</returns>
public static Data.Models.PortableExecutable.Resource.ResourceHeader ParseResourceHeader(byte[] data, ref int offset)
{
// Read in the table
var obj = new Data.Models.PortableExecutable.Resource.ResourceHeader();
obj.DataSize = data.ReadUInt32LittleEndian(ref offset);
obj.HeaderSize = data.ReadUInt32LittleEndian(ref offset);
obj.ResourceType = (ResourceType)data.ReadUInt32LittleEndian(ref offset); // TODO: Could be a string too
obj.Name = data.ReadUInt32LittleEndian(ref offset); // TODO: Could be a string too
obj.DataVersion = data.ReadUInt32LittleEndian(ref offset);
obj.MemoryFlags = (MemoryFlags)data.ReadUInt16LittleEndian(ref offset);
obj.LanguageId = data.ReadUInt16LittleEndian(ref offset);
obj.Version = data.ReadUInt32LittleEndian(ref offset);
obj.Characteristics = data.ReadUInt32LittleEndian(ref offset);
return obj;
}
/// <summary>
/// Parse a Stream into a SectionDefinition
/// </summary>