Add files via upload

This commit is contained in:
NintenHero 2024-03-09 11:14:12 -06:00 committed by GitHub
parent ecf089db31
commit 163b0c5407
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>ACotGK_seng_Extractor</RootNamespace>
</PropertyGroup>
</Project>

25
ACotGK-seng-Extractor.sln Normal file
View File

@ -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}") = "ACotGK-seng-Extractor", "ACotGK-seng-Extractor.csproj", "{879F783D-F43F-41E2-B47F-5A7D35CFC70B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{879F783D-F43F-41E2-B47F-5A7D35CFC70B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{879F783D-F43F-41E2-B47F-5A7D35CFC70B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{879F783D-F43F-41E2-B47F-5A7D35CFC70B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{879F783D-F43F-41E2-B47F-5A7D35CFC70B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E148DFAD-0BFD-44C3-A171-4AC9AD3B50A5}
EndGlobalSection
EndGlobal

65
Program.cs Normal file
View File

@ -0,0 +1,65 @@
//Written for The Accursed Crown of the Giant King. https://store.steampowered.com/app/1970780/
using System;
using System.IO;
namespace ACotGK_seng_Extractor
{
static class Program
{
public static BinaryReader br;
static void Main(string[] args)
{
using FileStream source = File.OpenRead(args[0]);
br = new(source);
int fileCount = br.ReadInt32();
System.Collections.Generic.List<SUBFILE> fileTable = new();
for (int i = 0; i < fileCount - 1; i++)
{
br.ReadInt32();
string name = NullTerminatedString();
if (br.BaseStream.Position < (i + 1) * 0x4C + 0x48)
br.BaseStream.Position = (i + 1) * 0x4C + 0x48;
fileTable.Add(new SUBFILE
{
name = name,
offset = br.ReadInt32(),
size = br.ReadInt32()
});
}
foreach (SUBFILE sub in fileTable)
{
br.BaseStream.Position = sub.offset;
Directory.CreateDirectory(Path.GetDirectoryName(args[0]) + "//" + Path.GetFileNameWithoutExtension(args[0]) + "//" + Path.GetDirectoryName(sub.name));
using FileStream FS = File.Create(Path.GetDirectoryName(args[0]) + "//" + Path.GetFileNameWithoutExtension(args[0]) + "//" + sub.name);
BinaryWriter bw = new(FS);
bw.Write(br.ReadBytes(sub.size));
bw.Close();
}
}
public struct SUBFILE
{
public string name;
public int offset;
public int size;
}
public static string NullTerminatedString()
{
char[] fileName = Array.Empty<char>();
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;
}
}
}