mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-09-22 06:45:03 +00:00
Add PE accelerator table resource
This commit is contained in:
@@ -361,6 +361,35 @@ namespace BurnOutSharp.Builder
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read resource data as an accelerator table resource
|
||||
/// </summary>
|
||||
/// <param name="data">Data to parse into an accelerator table resource</param>
|
||||
/// <returns>A filled accelerator table resource on success, null on error</returns>
|
||||
public static Models.PortableExecutable.AcceleratorTableEntryResource[] AsAcceleratorTableResource(this byte[] data)
|
||||
{
|
||||
// If we have data that's invalid for this resource type, we can't do anything
|
||||
if (data == null || data.Length % 8 != 0)
|
||||
return null;
|
||||
|
||||
// Get the number of entries
|
||||
int count = data.Length / 8;
|
||||
int offset = 0;
|
||||
|
||||
// Read in the table
|
||||
var table = new Models.PortableExecutable.AcceleratorTableEntryResource[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var entry = new Models.PortableExecutable.AcceleratorTableEntryResource();
|
||||
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);
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BurnOutSharp.Models.PortableExecutable
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the data in an individual accelerator table resource. 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/acceltableentry"/>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class AcceleratorTableEntryResource
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes keyboard accelerator characteristics.
|
||||
/// </summary>
|
||||
public AcceleratorTableFlags Flags;
|
||||
|
||||
/// <summary>
|
||||
/// An ANSI character value or a virtual-key code that identifies the accelerator key.
|
||||
/// </summary>
|
||||
public ushort Ansi;
|
||||
|
||||
/// <summary>
|
||||
/// An identifier for the keyboard accelerator. This is the value passed to the window
|
||||
/// procedure when the user presses the specified key.
|
||||
/// </summary>
|
||||
public ushort Id;
|
||||
|
||||
/// <summary>
|
||||
/// The number of bytes inserted to ensure that the structure is aligned on a DWORD boundary.
|
||||
/// </summary>
|
||||
public ushort Padding;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,46 @@
|
||||
|
||||
namespace BurnOutSharp.Models.PortableExecutable
|
||||
{
|
||||
[Flags]
|
||||
public enum AcceleratorTableFlags : ushort
|
||||
{
|
||||
/// <summary>
|
||||
/// The accelerator key is a virtual-key code. If this flag is not specified,
|
||||
/// the accelerator key is assumed to specify an ASCII character code.
|
||||
/// </summary>
|
||||
FVIRTKEY = 0x01,
|
||||
|
||||
/// <summary>
|
||||
/// A menu item on the menu bar is not highlighted when an accelerator is used.
|
||||
/// This attribute is obsolete and retained only for backward compatibility with
|
||||
/// resource files designed for 16-bit Windows.
|
||||
/// </summary>
|
||||
FNOINVERT = 0x02,
|
||||
|
||||
/// <summary>
|
||||
/// The accelerator is activated only if the user presses the SHIFT key. This flag
|
||||
/// applies only to virtual keys.
|
||||
/// </summary>
|
||||
FSHIFT = 0x04,
|
||||
|
||||
/// <summary>
|
||||
/// The accelerator is activated only if the user presses the CTRL key. This flag
|
||||
/// applies only to virtual keys.
|
||||
/// </summary>
|
||||
FCONTROL = 0x08,
|
||||
|
||||
/// <summary>
|
||||
/// The accelerator is activated only if the user presses the ALT key. This flag
|
||||
/// applies only to virtual keys.
|
||||
/// </summary>
|
||||
FALT = 0x10,
|
||||
|
||||
/// <summary>
|
||||
/// The entry is last in an accelerator table.
|
||||
/// </summary>
|
||||
LastEntry = 0x80,
|
||||
}
|
||||
|
||||
public enum BaseRelocationTypes : uint
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user