From c4bf3931e2a3737cfb1205a0c33f402653652546 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 2 Dec 2022 15:20:44 -0800 Subject: [PATCH] Add skeletons for all wrappers --- BurnOutSharp.Wrappers/LinearExecutable.cs | 64 +++++++++++++++++++++ BurnOutSharp.Wrappers/MSDOS.cs | 64 +++++++++++++++++++++ BurnOutSharp.Wrappers/NewExecutable.cs | 64 +++++++++++++++++++++ BurnOutSharp.Wrappers/PortableExecutable.cs | 64 +++++++++++++++++++++ BurnOutSharp.sln | 6 ++ ExecutableTest/ExecutableTest.csproj | 1 + 6 files changed, 263 insertions(+) create mode 100644 BurnOutSharp.Wrappers/LinearExecutable.cs create mode 100644 BurnOutSharp.Wrappers/MSDOS.cs create mode 100644 BurnOutSharp.Wrappers/NewExecutable.cs create mode 100644 BurnOutSharp.Wrappers/PortableExecutable.cs diff --git a/BurnOutSharp.Wrappers/LinearExecutable.cs b/BurnOutSharp.Wrappers/LinearExecutable.cs new file mode 100644 index 00000000..1f1dfde8 --- /dev/null +++ b/BurnOutSharp.Wrappers/LinearExecutable.cs @@ -0,0 +1,64 @@ +using System.IO; + +namespace BurnOutSharp.Wrappers +{ + public class LinearExecutable + { + #region Pass-Through Properties + + // TODO: Determine what properties can be passed through + + #endregion + + #region Extension Properties + + // TODO: Determine what extension properties are needed + + #endregion + + #region Instance Variables + + /// + /// Internal representation of the executable + /// + private BurnOutSharp.Models.LinearExecutable.Executable _executable; + + #endregion + + /// + /// Private constructor + /// + private LinearExecutable() { } + + /// + /// Create an LE/LX executable from a byte array and offset + /// + /// Byte array representing the executable + /// Offset within the array to parse + /// An LE/LX executable wrapper on success, null on failure + public static LinearExecutable Create(byte[] data, int offset) + { + var executable = BurnOutSharp.Builder.LinearExecutable.ParseExecutable(data, offset); + if (executable == null) + return null; + + var wrapper = new LinearExecutable { _executable = executable }; + return wrapper; + } + + /// + /// Create an LE/LX executable from a Stream + /// + /// Stream representing the executable + /// An LE/LX executable wrapper on success, null on failure + public static LinearExecutable Create(Stream data) + { + var executable = BurnOutSharp.Builder.LinearExecutable.ParseExecutable(data); + if (executable == null) + return null; + + var wrapper = new LinearExecutable { _executable = executable }; + return wrapper; + } + } +} \ No newline at end of file diff --git a/BurnOutSharp.Wrappers/MSDOS.cs b/BurnOutSharp.Wrappers/MSDOS.cs new file mode 100644 index 00000000..df6b635b --- /dev/null +++ b/BurnOutSharp.Wrappers/MSDOS.cs @@ -0,0 +1,64 @@ +using System.IO; + +namespace BurnOutSharp.Wrappers +{ + public class MSDOS + { + #region Pass-Through Properties + + // TODO: Determine what properties can be passed through + + #endregion + + #region Extension Properties + + // TODO: Determine what extension properties are needed + + #endregion + + #region Instance Variables + + /// + /// Internal representation of the executable + /// + private BurnOutSharp.Models.MSDOS.Executable _executable; + + #endregion + + /// + /// Private constructor + /// + private MSDOS() { } + + /// + /// Create an MS-DOS executable from a byte array and offset + /// + /// Byte array representing the executable + /// Offset within the array to parse + /// An MS-DOS executable wrapper on success, null on failure + public static MSDOS Create(byte[] data, int offset) + { + var executable = BurnOutSharp.Builder.MSDOS.ParseExecutable(data, offset); + if (executable == null) + return null; + + var wrapper = new MSDOS { _executable = executable }; + return wrapper; + } + + /// + /// Create an MS-DOS executable from a Stream + /// + /// Stream representing the executable + /// An MS-DOS executable wrapper on success, null on failure + public static MSDOS Create(Stream data) + { + var executable = BurnOutSharp.Builder.MSDOS.ParseExecutable(data); + if (executable == null) + return null; + + var wrapper = new MSDOS { _executable = executable }; + return wrapper; + } + } +} \ No newline at end of file diff --git a/BurnOutSharp.Wrappers/NewExecutable.cs b/BurnOutSharp.Wrappers/NewExecutable.cs new file mode 100644 index 00000000..5674cfdb --- /dev/null +++ b/BurnOutSharp.Wrappers/NewExecutable.cs @@ -0,0 +1,64 @@ +using System.IO; + +namespace BurnOutSharp.Wrappers +{ + public class NewExecutable + { + #region Pass-Through Properties + + // TODO: Determine what properties can be passed through + + #endregion + + #region Extension Properties + + // TODO: Determine what extension properties are needed + + #endregion + + #region Instance Variables + + /// + /// Internal representation of the executable + /// + private BurnOutSharp.Models.NewExecutable.Executable _executable; + + #endregion + + /// + /// Private constructor + /// + private NewExecutable() { } + + /// + /// Create an NE executable from a byte array and offset + /// + /// Byte array representing the executable + /// Offset within the array to parse + /// An NE executable wrapper on success, null on failure + public static NewExecutable Create(byte[] data, int offset) + { + var executable = BurnOutSharp.Builder.NewExecutable.ParseExecutable(data, offset); + if (executable == null) + return null; + + var wrapper = new NewExecutable { _executable = executable }; + return wrapper; + } + + /// + /// Create an NE executable from a Stream + /// + /// Stream representing the executable + /// An NE executable wrapper on success, null on failure + public static NewExecutable Create(Stream data) + { + var executable = BurnOutSharp.Builder.NewExecutable.ParseExecutable(data); + if (executable == null) + return null; + + var wrapper = new NewExecutable { _executable = executable }; + return wrapper; + } + } +} \ No newline at end of file diff --git a/BurnOutSharp.Wrappers/PortableExecutable.cs b/BurnOutSharp.Wrappers/PortableExecutable.cs new file mode 100644 index 00000000..97b89df5 --- /dev/null +++ b/BurnOutSharp.Wrappers/PortableExecutable.cs @@ -0,0 +1,64 @@ +using System.IO; + +namespace BurnOutSharp.Wrappers +{ + public class PortableExecutable + { + #region Pass-Through Properties + + // TODO: Determine what properties can be passed through + + #endregion + + #region Extension Properties + + // TODO: Determine what extension properties are needed + + #endregion + + #region Instance Variables + + /// + /// Internal representation of the executable + /// + private BurnOutSharp.Models.PortableExecutable.Executable _executable; + + #endregion + + /// + /// Private constructor + /// + private PortableExecutable() { } + + /// + /// Create a PE executable from a byte array and offset + /// + /// Byte array representing the executable + /// Offset within the array to parse + /// A PE executable wrapper on success, null on failure + public static PortableExecutable Create(byte[] data, int offset) + { + var executable = BurnOutSharp.Builder.PortableExecutable.ParseExecutable(data, offset); + if (executable == null) + return null; + + var wrapper = new PortableExecutable { _executable = executable }; + return wrapper; + } + + /// + /// Create a PE executable from a Stream + /// + /// Stream representing the executable + /// A PE executable wrapper on success, null on failure + public static PortableExecutable Create(Stream data) + { + var executable = BurnOutSharp.Builder.PortableExecutable.ParseExecutable(data); + if (executable == null) + return null; + + var wrapper = new PortableExecutable { _executable = executable }; + return wrapper; + } + } +} \ No newline at end of file diff --git a/BurnOutSharp.sln b/BurnOutSharp.sln index 4f21b965..533b81c9 100644 --- a/BurnOutSharp.sln +++ b/BurnOutSharp.sln @@ -28,6 +28,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BurnOutSharp.Builder", "Bur EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExecutableTest", "ExecutableTest\ExecutableTest.csproj", "{4B59824C-7E0A-4478-B408-FEAA1FD80F8F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BurnOutSharp.Wrappers", "BurnOutSharp.Wrappers\BurnOutSharp.Wrappers.csproj", "{35BD489F-E58D-45DD-9929-DC4B32414750}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -70,6 +72,10 @@ Global {4B59824C-7E0A-4478-B408-FEAA1FD80F8F}.Debug|Any CPU.Build.0 = Debug|Any CPU {4B59824C-7E0A-4478-B408-FEAA1FD80F8F}.Release|Any CPU.ActiveCfg = Release|Any CPU {4B59824C-7E0A-4478-B408-FEAA1FD80F8F}.Release|Any CPU.Build.0 = Release|Any CPU + {35BD489F-E58D-45DD-9929-DC4B32414750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35BD489F-E58D-45DD-9929-DC4B32414750}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35BD489F-E58D-45DD-9929-DC4B32414750}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35BD489F-E58D-45DD-9929-DC4B32414750}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ExecutableTest/ExecutableTest.csproj b/ExecutableTest/ExecutableTest.csproj index ee83a18d..4c8906e6 100644 --- a/ExecutableTest/ExecutableTest.csproj +++ b/ExecutableTest/ExecutableTest.csproj @@ -10,6 +10,7 @@ +