PixelJunk-Extractor/Program.cs

52 lines
1.8 KiB
C#
Raw Permalink 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)
{
using FileStream pkiwin = File.OpenRead(args[0] + "//shooter.pkiwin");
BinaryReader br = new(pkiwin);
Directory.CreateDirectory(args[0] + "//shooter");
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(args[0] + "//shooter.pkdwin");
foreach (SUBFILE sub in subfiles)
{
br = new(pkdwin);
br.BaseStream.Position = sub.offset;
using FileStream FS = File.Create(args[0] + "//shooter//" + n);
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();
}
}
struct SUBFILE
{
public int sizeUncompressed;
public int sizeCompressed;
public int offset;
}
}