mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 19:34:15 +08:00
(PACKDAT): decrypt scripts.
This commit is contained in:
parent
a4ba1ecdd5
commit
b4e1e41c93
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user