From c46854eaf787cc01d10f0eee6f70f8aeb66e63cc Mon Sep 17 00:00:00 2001
From: NintenHero <37460517+MichaelHinrichs@users.noreply.github.com>
Date: Sat, 16 Mar 2024 21:56:01 -0500
Subject: [PATCH] Add files via upload
---
ASURA-Dat-Extractor.csproj | 11 ++++++++
ASURA-Dat-Extractor.sln | 25 ++++++++++++++++++
Program.cs | 53 ++++++++++++++++++++++++++++++++++++++
3 files changed, 89 insertions(+)
create mode 100644 ASURA-Dat-Extractor.csproj
create mode 100644 ASURA-Dat-Extractor.sln
create mode 100644 Program.cs
diff --git a/ASURA-Dat-Extractor.csproj b/ASURA-Dat-Extractor.csproj
new file mode 100644
index 0000000..40ad6c5
--- /dev/null
+++ b/ASURA-Dat-Extractor.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ ASURA_Dat_Extractor
+ enable
+ enable
+
+
+
diff --git a/ASURA-Dat-Extractor.sln b/ASURA-Dat-Extractor.sln
new file mode 100644
index 0000000..63c0fd6
--- /dev/null
+++ b/ASURA-Dat-Extractor.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34309.116
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASURA-Dat-Extractor", "ASURA-Dat-Extractor.csproj", "{0F02F8AF-66B4-4BCD-8CE8-99EC0FA91388}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0F02F8AF-66B4-4BCD-8CE8-99EC0FA91388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0F02F8AF-66B4-4BCD-8CE8-99EC0FA91388}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0F02F8AF-66B4-4BCD-8CE8-99EC0FA91388}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0F02F8AF-66B4-4BCD-8CE8-99EC0FA91388}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {B9437036-BE0E-4F28-A7F8-4A87692DCBB9}
+ EndGlobalSection
+EndGlobal
diff --git a/Program.cs b/Program.cs
new file mode 100644
index 0000000..56b856f
--- /dev/null
+++ b/Program.cs
@@ -0,0 +1,53 @@
+//Written for ASURA. https://store.steampowered.com/app/2293900/
+using System.IO.Compression;
+
+FileStream input = File.OpenRead(args[0]);
+BinaryReader br = new(input);
+Directory.CreateDirectory(Path.GetDirectoryName(args[0]) + "\\" + Path.GetFileNameWithoutExtension(args[0]));
+if (new string(br.ReadChars(7)) != "D-PACK2")
+ throw new Exception("Not a ASURA dat file.");
+
+br.ReadByte();
+int fileCount = br.ReadInt32();
+int size = br.ReadInt32();
+
+List subfiles = [];
+for (int i = 0; i < fileCount; i++)
+{
+ subfiles.Add(new()
+ {
+ unknown = br.ReadSingle(),
+ start = br.ReadInt32(),
+ sizeUncompressed = br.ReadInt32(),
+ sizeCompressed = br.ReadInt32(),
+ name = i
+ });
+}
+
+foreach (SUBFILE subfile in subfiles)
+{
+ br.BaseStream.Position = subfile.start;
+
+ using FileStream FS = File.Create(Path.GetDirectoryName(args[0]) + "\\" + Path.GetFileNameWithoutExtension(args[0]) + "\\" + subfile.name);
+ BinaryWriter bw = new(FS);
+
+ MemoryStream ms = new();
+ br.ReadInt16();
+ using (var ds = new DeflateStream(new MemoryStream(br.ReadBytes(subfile.sizeCompressed - 2)), CompressionMode.Decompress))
+ ds.CopyTo(ms);
+ br = new(ms);
+ br.BaseStream.Position = 0;
+
+ bw.Write(br.ReadBytes(subfile.sizeUncompressed));
+ bw.Close();
+ br = new(input);
+}
+
+class SUBFILE
+{
+ public float unknown;
+ public int start;
+ public int sizeUncompressed;
+ public int sizeCompressed;
+ public int name;
+}
\ No newline at end of file