From 4d360cc484946101b412c0a7c48e379ea8ee8ef8 Mon Sep 17 00:00:00 2001 From: NintenHero <37460517+MichaelHinrichs@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:15:55 -0500 Subject: [PATCH] Add files via upload --- Avem33-Unpacker.csproj | 9 +++++++++ Avem33-Unpacker.sln | 25 +++++++++++++++++++++++ Program.cs | 45 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 Avem33-Unpacker.csproj create mode 100644 Avem33-Unpacker.sln create mode 100644 Program.cs diff --git a/Avem33-Unpacker.csproj b/Avem33-Unpacker.csproj new file mode 100644 index 0000000..9408892 --- /dev/null +++ b/Avem33-Unpacker.csproj @@ -0,0 +1,9 @@ + + + + Exe + net5.0 + Avem33_Unpacker + + + diff --git a/Avem33-Unpacker.sln b/Avem33-Unpacker.sln new file mode 100644 index 0000000..abbdaa6 --- /dev/null +++ b/Avem33-Unpacker.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.34407.143 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avem33-Unpacker", "Avem33-Unpacker.csproj", "{5BE8CE3A-BFBF-4A8A-A12B-0E677DFF3BD5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5BE8CE3A-BFBF-4A8A-A12B-0E677DFF3BD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5BE8CE3A-BFBF-4A8A-A12B-0E677DFF3BD5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5BE8CE3A-BFBF-4A8A-A12B-0E677DFF3BD5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5BE8CE3A-BFBF-4A8A-A12B-0E677DFF3BD5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {664B2A89-AB00-431B-81A2-8032D2AFE1F7} + EndGlobalSection +EndGlobal diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..0a34e07 --- /dev/null +++ b/Program.cs @@ -0,0 +1,45 @@ +//Written for Avem33. https://store.steampowered.com/app/673900/ +using System; +using System.IO; + +namespace Avem33_Unpacker +{ + class Program + { + public static BinaryReader br; + + private static void Main(string[] args) + { + br = new BinaryReader(File.OpenRead(args[0])); + Directory.CreateDirectory(Path.GetDirectoryName(args[0]) + "//" + Path.GetFileNameWithoutExtension(args[0])); + while (br.BaseStream.Position < br.BaseStream.Length) + { + string name = NullTerminatedString(); + + byte readbyte = 0xFE; + while (readbyte == 0xFE) + readbyte = br.ReadByte();//padding + br.BaseStream.Position--; + using FileStream FS = File.Create(Path.GetDirectoryName(args[0]) + "//" + Path.GetFileNameWithoutExtension(args[0]) + "//" + name); + BinaryWriter bw = new(FS); + bw.Write(br.ReadBytes(br.ReadInt32())); + bw.Close(); + } + } + + public static string NullTerminatedString() + { + char[] fileName = Array.Empty(); + char readchar = (char)1; + while (readchar > 0) + { + readchar = br.ReadChar(); + Array.Resize(ref fileName, fileName.Length + 1); + fileName[^1] = readchar; + } + Array.Resize(ref fileName, fileName.Length - 1); + string name = new(fileName); + return name; + } + } +}