Add PE accelerator table

This commit is contained in:
Matt Nadareski
2022-11-09 12:05:30 -08:00
parent ac514fce30
commit 5c3e8c35c4
3 changed files with 24 additions and 4 deletions

View File

@@ -394,7 +394,7 @@ namespace BurnOutSharp.Builder
/// <param name="data">Data to parse into an accelerator table resource</param>
/// <param name="offset">Offset into the byte array</param>
/// <returns>A filled accelerator table resource on success, null on error</returns>
public static Models.PortableExecutable.AcceleratorTableEntryResource[] AsAcceleratorTableResource(this byte[] data, ref int offset)
public static Models.PortableExecutable.AcceleratorTableEntry[] AsAcceleratorTableResource(this byte[] data, ref int offset)
{
// If we have data that's invalid for this resource type, we can't do anything
if (data == null || data.Length % 8 != 0)
@@ -404,10 +404,10 @@ namespace BurnOutSharp.Builder
int count = data.Length / 8;
// Read in the table
var table = new Models.PortableExecutable.AcceleratorTableEntryResource[count];
var table = new Models.PortableExecutable.AcceleratorTableEntry[count];
for (int i = 0; i < count; i++)
{
var entry = new Models.PortableExecutable.AcceleratorTableEntryResource();
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);

View File

@@ -8,7 +8,7 @@ namespace BurnOutSharp.Models.PortableExecutable
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/acceltableentry"/>
[StructLayout(LayoutKind.Sequential)]
public class AcceleratorTableEntryResource
public class AcceleratorTableEntry
{
/// <summary>
/// Describes keyboard accelerator characteristics.

View File

@@ -0,0 +1,20 @@
namespace BurnOutSharp.Models.PortableExecutable
{
/// <summary>
/// An accelerator table is one resource entry in a resource file. The structure definition
/// provided here is for explanation only; it is not present in any standard header file.
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/resource-file-formats"/>
public class AcceleratorTableResource
{
/// <summary>
/// Each entry consists of a resource header and the data for that resource.
/// </summary>
public ResourceHeader ResourceHeader;
/// <summary>
/// Accelerator table data
/// </summary>
public AcceleratorTableEntry[] AcceleratorTable;
}
}