From b4e1e41c9336476e508e3ded670f5860d3c18a30 Mon Sep 17 00:00:00 2001 From: morkt Date: Mon, 29 Jan 2018 03:36:30 +0400 Subject: [PATCH] (PACKDAT): decrypt scripts. --- ArcFormats/ArcPACKDAT.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ArcFormats/ArcPACKDAT.cs b/ArcFormats/ArcPACKDAT.cs index f9feddfe..d89b264e 100644 --- a/ArcFormats/ArcPACKDAT.cs +++ b/ArcFormats/ArcPACKDAT.cs @@ -80,11 +80,12 @@ namespace GameRes.Formats.SystemEpsylon public override Stream OpenEntry (ArcFile arc, Entry entry) { var pentry = entry as PackDatEntry; - if (null == pentry || entry.Size < 4 || 0 == (pentry.Flags & 0x10000)) + if (null == pentry || entry.Size < 4 + || !(0 != (pentry.Flags & 0x10000) || entry.Name.HasExtension (".s"))) return arc.File.CreateStream (entry.Offset, entry.Size); var input = arc.File.View.ReadBytes (entry.Offset, pentry.Size); - if (input.Length == pentry.Size) + if (0 != (pentry.Flags & 0x10000)) { unsafe { @@ -92,7 +93,7 @@ namespace GameRes.Formats.SystemEpsylon { uint* encoded = (uint*)buf_raw; uint key = pentry.Size >> 2; - key = (key << (((int)key & 7) + 8)) ^ key; + key ^= key << (((int)key & 7) + 8); for (uint i = entry.Size / 4; i != 0; --i ) { *encoded ^= key; @@ -102,6 +103,11 @@ namespace GameRes.Formats.SystemEpsylon } } } + if (entry.Name.HasExtension (".s")) + { + for (int i = 0; i < input.Length; ++i) + input[i] ^= 0xFF; + } return new BinMemoryStream (input, entry.Name); } }