private void dump(string filename) { if (Directory.Exists(filename + "_d")) Directory.Delete(filename + "_d", true); Directory.CreateDirectory(filename + "_d"); ShuffleARC_M Archive = new ShuffleARC_M(filename); using (var fs = File.OpenRead(filename)) { for (int i = 0; i < Archive.Files.Count(); i++) { byte[] ZipBuffer = new byte[Archive.Files[i].Length]; fs.Seek(Archive.Files[i].Offset, SeekOrigin.Begin); fs.Read(ZipBuffer, 0, ZipBuffer.Length); string ZipName = Archive.Files[i].NameHash.ToString("X8") + ".zip"; string outlet = Path.Combine(filename + "_d", ZipName); File.WriteAllBytes(outlet, ZipBuffer); string file = ""; try { using (ZipFile Zip = new ZipFile(outlet)) { if (Zip.Count() == 1) { file = Zip[0].FileName.Trim('\0'); if (file == "") Zip[0].FileName = file = i.ToString("0000"); Zip.Save(); } Zip.ExtractAll(filename + "_d"); } // Decrypt File File.Delete(outlet); file = Path.Combine(filename + "_d", file); if ((Archive.Files[i].F2 & 0x200) > 0) { byte[] data = File.ReadAllBytes(file); XOR(data); File.WriteAllBytes(file, data); } } catch { file = i.ToString("0000"); } // Check for PVR try { byte[] z = File.ReadAllBytes(file); int off = BitConverter.ToInt32(z, 0x4); int val = (BitConverter.ToInt32(z, 0x2C + off) & 0xFFFFFF); if (val == 0x525650) { File.WriteAllBytes(Path.Combine("pvr", Archive.Files[i].NameHash + "_" + i.ToString("0000") + ".pvr"), z.Skip(off).ToArray()); File.Delete(file); continue; } } catch {} // Check for GHVK pack try { byte[] z = File.ReadAllBytes(file); if ((BitConverter.ToUInt32(z, 0)) == 0x4B564847) { int count = BitConverter.ToInt16(z, 8); // int o1 = BitConverter.ToInt32(z, 0x40); int o2 = BitConverter.ToInt32(z, 0x44); // int o3 = BitConverter.ToInt32(z, 0x48); int o4 = BitConverter.ToInt32(z, 0x4C); int o5 = BitConverter.ToInt32(z, 0x50); string[] filenames = new string[count]; byte[][] files = new byte[count][]; for (int f = 0; f < count; f++) { int startstr = BitConverter.ToInt32(z, o4 + f*4); int offset = BitConverter.ToInt32(z, o5 + f*4); int length = BitConverter.ToInt32(z, o2 + f*4); filenames[f] = Encoding.ASCII.GetString(z.Skip(startstr).TakeWhile(b => !b.Equals(0)).ToArray()); files[f] = z.Skip(offset).Take(length).ToArray(); string outFile = Path.Combine("pkm2", Archive.Files[i].NameHash.ToString("X8"), filenames[f]); new FileInfo(outFile).Directory.Create(); File.WriteAllBytes(outFile, files[f]); } File.Delete(file); continue; } } catch {} } } }