using SabreTools.Models.NewExecutable; namespace SabreTools.Serialization { public static partial class Extensions { /// /// Determine if a resource type information entry is an integer or offset /// /// Resource type information entry to check /// True if the entry is an integer type, false if an offset, null on error public static bool? IsIntegerType(this ResourceTypeInformationEntry entry) { // We can't do anything with an invalid entry if (entry == null) return null; // If the highest order bit is set, it's an integer type return (entry.TypeID & 0x8000) != 0; } /// /// Determine if a resource type resource entry is an integer or offset /// /// Resource type resource entry to check /// True if the entry is an integer type, false if an offset, null on error public static bool? IsIntegerType(this ResourceTypeResourceEntry entry) { // We can't do anything with an invalid entry if (entry == null) return null; // If the highest order bit is set, it's an integer type return (entry.ResourceID & 0x8000) != 0; } /// /// Get the segment entry type for an entry table bundle /// /// Entry table bundle to check /// SegmentEntryType corresponding to the type public static SegmentEntryType GetEntryType(this EntryTableBundle entry) { // We can't do anything with an invalid entry if (entry == null) return SegmentEntryType.Unused; // 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; } } }