mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 05:35:34 +08:00
(PD): workaround for obfuscated OGG files.
This commit is contained in:
parent
6fca707142
commit
1dbe45cf1e
@ -240,7 +240,7 @@ namespace GameRes.Formats.Fs
|
|||||||
if (len <= 0 || len >= 0x24)
|
if (len <= 0 || len >= 0x24)
|
||||||
return null;
|
return null;
|
||||||
string name = enc.GetString (buf, 0, len);
|
string name = enc.GetString (buf, 0, len);
|
||||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
var entry = Create<Entry> (name);
|
||||||
uint shift = LittleEndian.ToUInt32 (buf, 0x24);
|
uint shift = LittleEndian.ToUInt32 (buf, 0x24);
|
||||||
entry.Offset = LittleEndian.ToUInt32 (buf, 0x28) - shift;
|
entry.Offset = LittleEndian.ToUInt32 (buf, 0x28) - shift;
|
||||||
entry.Size = LittleEndian.ToUInt32 (buf, 0x2c) - shift;
|
entry.Size = LittleEndian.ToUInt32 (buf, 0x2c) - shift;
|
||||||
@ -254,6 +254,8 @@ namespace GameRes.Formats.Fs
|
|||||||
|
|
||||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||||
{
|
{
|
||||||
|
if (entry.Name.HasExtension (".ogg") && entry.Size > 0x22)
|
||||||
|
return OpenOgg (arc, entry);
|
||||||
if (!entry.Name.HasAnyOfExtensions (".def", ".dsf") || entry.Size < 2)
|
if (!entry.Name.HasAnyOfExtensions (".def", ".dsf") || entry.Size < 2)
|
||||||
return base.OpenEntry (arc, entry);
|
return base.OpenEntry (arc, entry);
|
||||||
var data = arc.File.View.ReadBytes (entry.Offset, entry.Size);
|
var data = arc.File.View.ReadBytes (entry.Offset, entry.Size);
|
||||||
@ -265,6 +267,19 @@ namespace GameRes.Formats.Fs
|
|||||||
return new BinMemoryStream (data);
|
return new BinMemoryStream (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stream OpenOgg (ArcFile arc, Entry entry)
|
||||||
|
{
|
||||||
|
const uint header_length = 0x23;
|
||||||
|
var header = arc.File.View.ReadBytes (entry.Offset, header_length);
|
||||||
|
if (!(header.AsciiEqual (0, "OggS") &&
|
||||||
|
header[0x1A] != 1 && header[0x1B] == 0x1E && header[0x1C] == 1 &&
|
||||||
|
header.AsciiEqual (0x1D, "vorbis")))
|
||||||
|
return base.OpenEntry (arc, entry);
|
||||||
|
header[0x1A] = 1;
|
||||||
|
var rest = arc.File.CreateStream (entry.Offset+header_length, entry.Size-header_length);
|
||||||
|
return new PrefixStream (header, rest);
|
||||||
|
}
|
||||||
|
|
||||||
void DecodeEntry (byte[] buf, byte key)
|
void DecodeEntry (byte[] buf, byte key)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < buf.Length; ++i)
|
for (int i = 0; i < buf.Length; ++i)
|
||||||
|
Loading…
Reference in New Issue
Block a user