Update NE entry table bundle

This commit is contained in:
Matt Nadareski
2022-11-08 09:59:15 -08:00
parent 9052cd3cdd
commit 751c248657
5 changed files with 78 additions and 68 deletions

View File

@@ -305,6 +305,29 @@ namespace BurnOutSharp.Builder
return (entry.ResourceID & 0x8000) != 0;
}
/// <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 Models.NewExecutable.SegmentEntryType GetEntryType(this Models.NewExecutable.EntryTableBundle entry)
{
// We can't do anything with an invalid entry
if (entry == null)
return Models.NewExecutable.SegmentEntryType.Unused;
// Determine the entry type based on segment indicator
if (entry.SegmentIndicator == 0x00)
return Models.NewExecutable.SegmentEntryType.Unused;
else if (entry.SegmentIndicator >= 0x01 && entry.SegmentIndicator <= 0xFE)
return Models.NewExecutable.SegmentEntryType.FixedSegment;
else if (entry.SegmentIndicator == 0xFF)
return Models.NewExecutable.SegmentEntryType.MoveableSegment;
// We should never get here
return Models.NewExecutable.SegmentEntryType.Unused;
}
#endregion
}
}

View File

@@ -43,16 +43,42 @@
/// </summary>
public byte SegmentIndicator;
/// <summary>
/// Fixed segment entry
/// </summary>
/// <remarks>Must be <c>NULL</c> if <see cref="MoveableSegmentEntry"/> is used.</remarks>
public FixedSegmentEntry FixedSegmentEntry;
#region Fixed Segment Entry
/// <summary>
/// Moveable segment entry
/// Flag word.
/// </summary>
/// <remarks>Must be <c>NULL</c> if <see cref="FixedSegmentEntry"/> is used.</remarks>
public MoveableSegmentEntry MoveableSegmentEntry;
public FixedSegmentEntryFlag FixedFlagWord;
/// <summary>
/// Offset within segment to entry point.
/// </summary>
public ushort FixedOffset;
#endregion
#region Moveable Segment Entry
/// <summary>
/// Flag word.
/// </summary>
public MoveableSegmentEntryFlag MoveableFlagWord;
/// <summary>
/// INT 3FH.
/// </summary>
public ushort MoveableReserved;
/// <summary>
/// Segment number.
/// </summary>
public byte MoveableSegmentNumber;
/// <summary>
/// Offset within segment to entry point.
/// </summary>
public ushort MoveableOffset;
#endregion
}
}

View File

@@ -262,6 +262,27 @@ namespace BurnOutSharp.Models.NewExecutable
PRELOAD = 0x0040,
}
public enum SegmentEntryType
{
/// <summary>
/// 000h - There is no entry data in an unused bundle. The next bundle
/// follows this field. This is used by the linker to skip ordinal numbers.
/// </summary>
Unused,
/// <summary>
/// 001h-0FEh - Segment number for fixed segment entries. A fixed segment
/// entry is 3 bytes long.
/// </summary>
FixedSegment,
/// <summary>
/// 0FFH - Moveable segment entries. The entry data contains the segment
/// number for the entry points. A moveable segment entry is 6 bytes long.
/// </summary>
MoveableSegment,
}
[Flags]
public enum SegmentTableEntryFlag : ushort
{

View File

@@ -1,25 +0,0 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.NewExecutable
{
/// <summary>
/// Segment number for fixed segment entries. A fixed
/// segment entry is 3 bytes long and has the following
/// format.
/// </summary>
/// <remarks>001h-0FEh</remarks>
/// <see href="http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm"/>
[StructLayout(LayoutKind.Sequential)]
public class FixedSegmentEntry
{
/// <summary>
/// Flag word.
/// </summary>
public FixedSegmentEntryFlag FlagWord;
/// <summary>
/// Offset within segment to entry point.
/// </summary>
public ushort Offset;
}
}

View File

@@ -1,35 +0,0 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.NewExecutable
{
/// <summary>
/// Moveable segment entries. The entry data contains the
/// segment number for the entry points. A moveable segment
/// entry is 6 bytes long and has the following format.
/// </summary>
/// <remarks>0FFH</remarks>
/// <see href="http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm"/>
[StructLayout(LayoutKind.Sequential)]
public class MoveableSegmentEntry
{
/// <summary>
/// Flag word.
/// </summary>
public MoveableSegmentEntryFlag FlagWord;
/// <summary>
/// INT 3FH.
/// </summary>
public ushort Reserved;
/// <summary>
/// Segment number.
/// </summary>
public byte SegmentNumber;
/// <summary>
/// Offset within segment to entry point.
/// </summary>
public ushort Offset;
}
}