Files

43 lines
1.8 KiB
C#
Raw Permalink Normal View History

2025-09-26 13:06:18 -04:00
using SabreTools.Data.Models.NewExecutable;
2023-09-15 22:38:47 -04:00
2025-09-26 13:15:55 -04:00
namespace SabreTools.Data.Extensions
2023-09-15 22:38:47 -04:00
{
public static class NewExecutableExtensions
2023-09-15 22:38:47 -04:00
{
/// <summary>
/// Determine if a resource type information entry is an integer or offset
/// </summary>
/// <param name="entry">Resource type information entry to check</param>
/// <returns>True if the entry is an integer type, false if an offset, null on error</returns>
2024-05-12 11:46:05 -04:00
public static bool IsIntegerType(this ResourceTypeInformationEntry entry)
2024-11-27 22:07:48 -05:00
=> (entry.TypeID & 0x8000) != 0;
2023-09-15 22:38:47 -04:00
/// <summary>
/// Determine if a resource type resource entry is an integer or offset
/// </summary>
/// <param name="entry">Resource type resource entry to check</param>
/// <returns>True if the entry is an integer type, false if an offset, null on error</returns>
2024-05-12 11:46:05 -04:00
public static bool IsIntegerType(this ResourceTypeResourceEntry entry)
2024-11-27 22:07:48 -05:00
=> (entry.ResourceID & 0x8000) != 0;
2023-09-15 22:38:47 -04:00
/// <summary>
/// Get the segment entry type for an entry table bundle
/// </summary>
/// <param name="entry">Entry table bundle to check</param>
/// <returns>SegmentEntryType corresponding to the type</returns>
public static SegmentEntryType GetEntryType(this EntryTableBundle entry)
{
// Determine the entry type based on segment indicator
if (entry.SegmentIndicator == 0x00)
return SegmentEntryType.Unused;
else if (entry.SegmentIndicator >= 0x01 && entry.SegmentIndicator <= 0xFE)
return SegmentEntryType.FixedSegment;
else if (entry.SegmentIndicator == 0xFF)
return SegmentEntryType.MoveableSegment;
// We should never get here
return SegmentEntryType.Unused;
}
}
}