PixelJunk-Extractor/Program.cs

53 lines
2.0 KiB
C#
Raw Normal View History

2024-03-04 19:11:11 +00:00
//Written for PixelJunk Shooter. https://store.steampowered.com/app/255870/
using System.IO;
2024-03-03 15:32:36 +00:00
using System.IO.Compression;
namespace PixelJunk_Extractor
{
class Program
{
static void Main(string[] args)
{
BinaryReader br = new(File.OpenRead(Path.GetDirectoryName(args[0]) + "//" + Path.GetFileNameWithoutExtension(args[0]) + ".pkiwin"));
string path = Path.GetDirectoryName(args[0]);
Directory.CreateDirectory(path + "//" + Path.GetFileNameWithoutExtension(args[0]));
2024-03-03 15:32:36 +00:00
br.BaseStream.Position = 8;
SUBFILE[] subfiles = new SUBFILE[br.ReadInt32()];
for (int i = 0; i < subfiles.Length; i++)
{
2024-07-31 13:39:58 +00:00
subfiles[i].sizeUncompressed = br.ReadInt32();
2024-03-03 15:32:36 +00:00
subfiles[i].sizeCompressed = br.ReadInt32();
subfiles[i].offset = br.ReadInt32();
br.ReadInt32();//unknown
}
int n = 0;
using FileStream pkdwin = File.OpenRead(path + "//" + Path.GetFileNameWithoutExtension(args[0]) + ".pkdwin");
2024-03-03 15:32:36 +00:00
foreach (SUBFILE sub in subfiles)
{
br = new(pkdwin);
br.BaseStream.Position = sub.offset;
using FileStream FS = File.Create(path + "//" + Path.GetFileNameWithoutExtension(args[0]) + "//" + n);
2024-03-03 15:32:36 +00:00
BinaryWriter bw = new(FS);
MemoryStream ms = new();
br.ReadInt16();
using (var ds = new DeflateStream(new MemoryStream(br.ReadBytes(sub.sizeCompressed)), CompressionMode.Decompress))
ds.CopyTo(ms);
br = new(ms);
br.BaseStream.Position = 0;
bw.Write(br.ReadBytes(sub.sizeUncompressed));
bw.Close();
n++;
}
br.Close();
}
}
2024-03-03 15:32:36 +00:00
struct SUBFILE
{
public int sizeUncompressed;
public int sizeCompressed;
public int offset;
}
}