Add regions for easier code navigation

This commit is contained in:
Matt Nadareski
2022-11-06 21:48:19 -08:00
parent fbab512975
commit 9f04022afc
2 changed files with 40 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ namespace BurnOutSharp.Builder
// Create a new executable to fill
var executable = new Executable();
#region Executable Header
// Try to parse the executable header
var executableHeader = ParseExecutableHeader(data, offset);
if (executableHeader == null)
@@ -38,6 +40,10 @@ namespace BurnOutSharp.Builder
// Set the executable header
executable.Header = executableHeader;
#endregion
#region Relocation Table
// If the offset for the relocation table doesn't exist
int tableAddress = initialOffset + executableHeader.RelocationTableAddr;
if (tableAddress >= data.Length)
@@ -51,6 +57,8 @@ namespace BurnOutSharp.Builder
// Set the relocation table
executable.RelocationTable = relocationTable;
#endregion
// Return the executable
return executable;
}
@@ -165,6 +173,8 @@ namespace BurnOutSharp.Builder
// Create a new executable to fill
var executable = new Executable();
#region Executable Header
// Try to parse the executable header
var executableHeader = ParseExecutableHeader(data);
if (executableHeader == null)
@@ -173,6 +183,10 @@ namespace BurnOutSharp.Builder
// Set the executable header
executable.Header = executableHeader;
#endregion
#region Relocation Table
// If the offset for the relocation table doesn't exist
int tableAddress = initialOffset + executableHeader.RelocationTableAddr;
if (tableAddress >= data.Length)
@@ -187,6 +201,8 @@ namespace BurnOutSharp.Builder
// Set the relocation table
executable.RelocationTable = relocationTable;
#endregion
// Return the executable
return executable;
}

View File

@@ -30,6 +30,8 @@ namespace BurnOutSharp.Builder
// Create a new executable to fill
var executable = new Executable();
#region MS-DOS Stub
// Parse the MS-DOS stub
var stub = MSDOS.ParseExecutable(data, offset);
if (stub?.Header == null || stub.Header.NewExeHeaderAddr == 0)
@@ -38,6 +40,10 @@ namespace BurnOutSharp.Builder
// Set the MS-DOS stub
executable.Stub = stub;
#endregion
#region Executable Header
// Try to parse the executable header
var executableHeader = ParseExecutableHeader(data, offset);
if (executableHeader == null)
@@ -46,6 +52,10 @@ namespace BurnOutSharp.Builder
// Set the executable header
executable.Header = executableHeader;
#endregion
#region Segment Table
// If the offset for the segment table doesn't exist
int tableAddress = initialOffset + executableHeader.SegmentTableOffset;
if (tableAddress >= data.Length)
@@ -59,6 +69,8 @@ namespace BurnOutSharp.Builder
// Set the segment table
executable.SegmentTable = relocationTable;
#endregion
// TODO: Implement NE parsing
return null;
}
@@ -166,6 +178,8 @@ namespace BurnOutSharp.Builder
// Create a new executable to fill
var executable = new Executable();
#region MS-DOS Stub
// Parse the MS-DOS stub
var stub = MSDOS.ParseExecutable(data);
if (stub?.Header == null || stub.Header.NewExeHeaderAddr == 0)
@@ -174,6 +188,10 @@ namespace BurnOutSharp.Builder
// Set the MS-DOS stub
executable.Stub = stub;
#endregion
#region Executable Header
// Try to parse the executable header
var executableHeader = ParseExecutableHeader(data);
if (executableHeader == null)
@@ -182,6 +200,10 @@ namespace BurnOutSharp.Builder
// Set the executable header
executable.Header = executableHeader;
#endregion
#region Segment Table
// If the offset for the segment table doesn't exist
int tableAddress = initialOffset + executableHeader.SegmentTableOffset;
if (tableAddress >= data.Length)
@@ -196,6 +218,8 @@ namespace BurnOutSharp.Builder
// Set the segment table
executable.SegmentTable = relocationTable;
#endregion
// TODO: Implement NE parsing
return null;
}