diff --git a/BurnOutSharp.Builder/Extensions.cs b/BurnOutSharp.Builder/Extensions.cs
index b0c5e80a..feae44c9 100644
--- a/BurnOutSharp.Builder/Extensions.cs
+++ b/BurnOutSharp.Builder/Extensions.cs
@@ -394,28 +394,34 @@ namespace BurnOutSharp.Builder
///
/// Read resource data as an accelerator table resource
///
- /// Data to parse into an accelerator table resource
- /// Offset into the byte array
+ /// Resource data entry to parse into an accelerator table resource
/// A filled accelerator table resource on success, null on error
- public static Models.PortableExecutable.AcceleratorTableEntry[] AsAcceleratorTableResource(this byte[] data, ref int offset)
+ public static Models.PortableExecutable.AcceleratorTableEntry[] AsAcceleratorTableResource(this Models.PortableExecutable.ResourceDataEntry entry)
{
// If we have data that's invalid for this resource type, we can't do anything
- if (data == null || data.Length % 8 != 0)
+ if (entry?.Data == null || entry.Data.Length % 8 != 0)
return null;
// Get the number of entries
- int count = data.Length / 8;
+ int count = entry.Data.Length / 8;
+
+ // Initialize the iterator
+ int offset = 0;
+
+ // Create the output object
+ var table = new Models.PortableExecutable.AcceleratorTableEntry[count];
// Read in the table
- var table = new Models.PortableExecutable.AcceleratorTableEntry[count];
for (int i = 0; i < count; i++)
{
- var entry = new Models.PortableExecutable.AcceleratorTableEntry();
- entry.Flags = (Models.PortableExecutable.AcceleratorTableFlags)data.ReadUInt16(ref offset);
- entry.Ansi = data.ReadUInt16(ref offset);
- entry.Id = data.ReadUInt16(ref offset);
- entry.Padding = data.ReadUInt16(ref offset);
- table[i] = entry;
+ var acceleratorTableEntry = new Models.PortableExecutable.AcceleratorTableEntry();
+
+ acceleratorTableEntry.Flags = (Models.PortableExecutable.AcceleratorTableFlags)entry.Data.ReadUInt16(ref offset);
+ acceleratorTableEntry.Ansi = entry.Data.ReadUInt16(ref offset);
+ acceleratorTableEntry.Id = entry.Data.ReadUInt16(ref offset);
+ acceleratorTableEntry.Padding = entry.Data.ReadUInt16(ref offset);
+
+ table[i] = acceleratorTableEntry;
}
return table;
diff --git a/ExecutableTest/Program.cs b/ExecutableTest/Program.cs
index 6633a6c7..9e3ff2dc 100644
--- a/ExecutableTest/Program.cs
+++ b/ExecutableTest/Program.cs
@@ -1147,7 +1147,6 @@ namespace ExecutableTest
// TODO: Print out per-type data
if (types != null && types.Count > 0 && types[0] is uint resourceType)
{
- int offset = 0;
switch ((BurnOutSharp.Models.PortableExecutable.ResourceType)resourceType)
{
case BurnOutSharp.Models.PortableExecutable.ResourceType.RT_CURSOR:
@@ -1186,7 +1185,7 @@ namespace ExecutableTest
Console.WriteLine($"{padding}Font resource found, not parsed yet");
break;
case BurnOutSharp.Models.PortableExecutable.ResourceType.RT_ACCELERATOR:
- var acceleratorTable = entry.Data.AsAcceleratorTableResource(ref offset);
+ var acceleratorTable = entry.AsAcceleratorTableResource();
if (acceleratorTable == null)
{
Console.WriteLine($"{padding}Accelerator table resource found, but malformed");