mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34:00 +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)
|
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||||
{
|
{
|
||||||
var pentry = entry as PackDatEntry;
|
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);
|
return arc.File.CreateStream (entry.Offset, entry.Size);
|
||||||
|
|
||||||
var input = arc.File.View.ReadBytes (entry.Offset, pentry.Size);
|
var input = arc.File.View.ReadBytes (entry.Offset, pentry.Size);
|
||||||
if (input.Length == pentry.Size)
|
if (0 != (pentry.Flags & 0x10000))
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
@ -92,7 +93,7 @@ namespace GameRes.Formats.SystemEpsylon
|
|||||||
{
|
{
|
||||||
uint* encoded = (uint*)buf_raw;
|
uint* encoded = (uint*)buf_raw;
|
||||||
uint key = pentry.Size >> 2;
|
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 )
|
for (uint i = entry.Size / 4; i != 0; --i )
|
||||||
{
|
{
|
||||||
*encoded ^= key;
|
*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);
|
return new BinMemoryStream (input, entry.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user