diff --git a/BurnOutSharp.sln b/BurnOutSharp.sln index aafd7199..f6ac0a99 100644 --- a/BurnOutSharp.sln +++ b/BurnOutSharp.sln @@ -26,13 +26,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BurnOutSharp.Models", "Burn EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BurnOutSharp.Builder", "BurnOutSharp.Builder\BurnOutSharp.Builder.csproj", "{7577733A-CC8D-4E7C-8B6D-FFC7EC1B3D07}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExecutableTest", "ExecutableTest\ExecutableTest.csproj", "{4B59824C-7E0A-4478-B408-FEAA1FD80F8F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BurnOutSharp.Wrappers", "BurnOutSharp.Wrappers\BurnOutSharp.Wrappers.csproj", "{35BD489F-E58D-45DD-9929-DC4B32414750}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BurnOutSharp.Matching", "BurnOutSharp.Matching\BurnOutSharp.Matching.csproj", "{563BC37B-8E02-4178-B6FE-F3F6F65E0096}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "psxt001z", "psxt001z\psxt001z.csproj", "{D9574B47-0D6B-445A-97BF-272B5EF9AD3F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "psxt001z", "psxt001z\psxt001z.csproj", "{D9574B47-0D6B-445A-97BF-272B5EF9AD3F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -72,10 +70,6 @@ Global {7577733A-CC8D-4E7C-8B6D-FFC7EC1B3D07}.Debug|Any CPU.Build.0 = Debug|Any CPU {7577733A-CC8D-4E7C-8B6D-FFC7EC1B3D07}.Release|Any CPU.ActiveCfg = Release|Any CPU {7577733A-CC8D-4E7C-8B6D-FFC7EC1B3D07}.Release|Any CPU.Build.0 = Release|Any CPU - {4B59824C-7E0A-4478-B408-FEAA1FD80F8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {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 diff --git a/ExecutableTest/ExecutableTest.csproj b/ExecutableTest/ExecutableTest.csproj deleted file mode 100644 index 4c8906e6..00000000 --- a/ExecutableTest/ExecutableTest.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - - diff --git a/ExecutableTest/Program.cs b/ExecutableTest/Program.cs deleted file mode 100644 index a49ce286..00000000 --- a/ExecutableTest/Program.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System.Text; -using BurnOutSharp.Wrappers; -using static BurnOutSharp.Builder.Extensions; - -namespace ExecutableTest -{ - public class ExecutableTest - { - public static void Main(string[] args) - { - // Invalid arguments means nothing to do - if (args == null || args.Length == 0) - { - Console.WriteLine("Please provide at least one file path"); - Console.ReadLine(); - return; - } - - // Register the codepages - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); - - // Loop through the args - foreach (string arg in args) - { - Console.WriteLine($"Checking possible path: {arg}"); - - // Check if the file or directory exists - if (File.Exists(arg)) - { - PrintFileInfo(arg); - } - else if (Directory.Exists(arg)) - { - foreach (string path in Directory.EnumerateFiles(arg, "*", SearchOption.AllDirectories)) - { - PrintFileInfo(path); - } - } - else - { - Console.WriteLine($"{arg} does not exist, skipping..."); - } - } - } - - /// - /// Print information for a single file, if possible - /// - private static void PrintFileInfo(string file) - { - using (Stream stream = File.OpenRead(file)) - { - // Read the first 4 bytes - byte[] magic = stream.ReadBytes(2); - - if (!IsMSDOS(magic)) - { - Console.WriteLine("Not a recognized executable format, skipping..."); - Console.WriteLine(); - return; - } - - // Build the executable information - Console.WriteLine("Creating MS-DOS executable builder"); - Console.WriteLine(); - - stream.Seek(0, SeekOrigin.Begin); - var msdos = MSDOS.Create(stream); - if (msdos == null) - { - Console.WriteLine("Something went wrong parsing MS-DOS executable"); - Console.WriteLine(); - return; - } - - // Print the executable info to screen - msdos.Print(); - - // Check for a valid new executable address - if (msdos.NewExeHeaderAddr >= stream.Length) - { - Console.WriteLine("New EXE header address invalid, skipping additional reading..."); - Console.WriteLine(); - return; - } - - // Try to read the executable info - stream.Seek(msdos.NewExeHeaderAddr, SeekOrigin.Begin); - magic = stream.ReadBytes(4); - - // New Executable - if (IsNE(magic)) - { - stream.Seek(0, SeekOrigin.Begin); - var newExecutable = NewExecutable.Create(stream); - if (newExecutable == null) - { - Console.WriteLine("Something went wrong parsing New Executable"); - Console.WriteLine(); - return; - } - - // Print the executable info to screen - newExecutable.Print(); - } - - // Linear Executable - else if (IsLE(magic)) - { - Console.WriteLine($"Linear executable found. No parsing currently available."); - Console.WriteLine(); - return; - } - - // Portable Executable - else if (IsPE(magic)) - { - stream.Seek(0, SeekOrigin.Begin); - var portableExecutable = PortableExecutable.Create(stream); - if (portableExecutable == null) - { - Console.WriteLine("Something went wrong parsing Portable Executable"); - Console.WriteLine(); - return; - } - - // Print the executable info to screen - portableExecutable.Print(); - } - - // Unknown - else - { - Console.WriteLine($"Unrecognized header signature: {BitConverter.ToString(magic).Replace("-", string.Empty)}"); - Console.WriteLine(); - return; - } - } - } - - /// - /// Determine if the magic bytes indicate an MS-DOS executable - /// - private static bool IsMSDOS(byte[] magic) - { - if (magic == null || magic.Length < 2) - return false; - - return magic[0] == 'M' && magic[1] == 'Z'; - } - - /// - /// Determine if the magic bytes indicate a New Executable - /// - private static bool IsNE(byte[] magic) - { - if (magic == null || magic.Length < 2) - return false; - - return magic[0] == 'N' && magic[1] == 'E'; - } - - /// - /// Determine if the magic bytes indicate a Linear Executable - /// - private static bool IsLE(byte[] magic) - { - if (magic == null || magic.Length < 2) - return false; - - return magic[0] == 'L' && (magic[1] == 'E' || magic[1] == 'X'); - } - - /// - /// Determine if the magic bytes indicate a Portable Executable - /// - private static bool IsPE(byte[] magic) - { - if (magic == null || magic.Length < 4) - return false; - - return magic[0] == 'P' && magic[1] == 'E' && magic[2] == '\0' && magic[3] == '\0'; - } - } -} \ No newline at end of file