mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 20:04:13 +08:00
(FPK): support archives with encrypted index.
This commit is contained in:
parent
ad8504179e
commit
f6b729e5d9
@ -2,7 +2,7 @@
|
|||||||
//! \date Mon May 25 10:01:24 2015
|
//! \date Mon May 25 10:01:24 2015
|
||||||
//! \brief FPK resource archives implementation.
|
//! \brief FPK resource archives implementation.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2015 by morkt
|
// Copyright (C) 2015-2016 by morkt
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to
|
// of this software and associated documentation files (the "Software"), to
|
||||||
@ -42,17 +42,29 @@ namespace GameRes.Formats.CandySoft
|
|||||||
|
|
||||||
public override ArcFile TryOpen (ArcView file)
|
public override ArcFile TryOpen (ArcView file)
|
||||||
{
|
{
|
||||||
int count = file.View.ReadInt32 (0);
|
if (file.MaxOffset < 0x10)
|
||||||
if (!IsSaneCount (count))
|
|
||||||
return null;
|
return null;
|
||||||
|
int count = file.View.ReadInt32 (0);
|
||||||
List<Entry> dir = null;
|
List<Entry> dir = null;
|
||||||
try
|
if (count < 0)
|
||||||
{
|
{
|
||||||
dir = ReadIndex (file, count, 0x10);
|
count &= 0x7FFFFFFF;
|
||||||
|
if (!IsSaneCount (count))
|
||||||
|
return null;
|
||||||
|
dir = ReadEncryptedIndex (file, count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!IsSaneCount (count))
|
||||||
|
return null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dir = ReadIndex (file, count, 0x10);
|
||||||
|
}
|
||||||
|
catch { /* read failed, try another filename length */ }
|
||||||
|
if (null == dir)
|
||||||
|
dir = ReadIndex (file, count, 0x18);
|
||||||
}
|
}
|
||||||
catch { /* read failed, try another filename length */ }
|
|
||||||
if (null == dir)
|
|
||||||
dir = ReadIndex (file, count, 0x18);
|
|
||||||
if (null == dir)
|
if (null == dir)
|
||||||
return null;
|
return null;
|
||||||
return new ArcFile (file, this, dir);
|
return new ArcFile (file, this, dir);
|
||||||
@ -81,6 +93,39 @@ namespace GameRes.Formats.CandySoft
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Entry> ReadEncryptedIndex (ArcView file, int count)
|
||||||
|
{
|
||||||
|
file.View.Reserve (file.MaxOffset-8, 8);
|
||||||
|
uint index_offset = file.View.ReadUInt32 (file.MaxOffset-4);
|
||||||
|
if (index_offset < 4 || index_offset >= file.MaxOffset-8)
|
||||||
|
return null;
|
||||||
|
var key = file.View.ReadBytes (file.MaxOffset-8, 4);
|
||||||
|
int name_size = 0x18;
|
||||||
|
int index_size = count * (12 + name_size);
|
||||||
|
var index = file.View.ReadBytes (index_offset, (uint)index_size);
|
||||||
|
if (index.Length != index_size)
|
||||||
|
return null;
|
||||||
|
for (int i = 0; i < index.Length; ++i)
|
||||||
|
index[i] ^= key[i & 3];
|
||||||
|
|
||||||
|
int index_pos = 0;
|
||||||
|
var dir = new List<Entry> (count);
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
string name = Binary.GetCString (index, index_pos+8, name_size);
|
||||||
|
if (string.IsNullOrWhiteSpace (name))
|
||||||
|
return null;
|
||||||
|
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||||
|
entry.Offset = LittleEndian.ToUInt32 (index, index_pos);
|
||||||
|
entry.Size = LittleEndian.ToUInt32 (index, index_pos+4);
|
||||||
|
if (!entry.CheckPlacement (file.MaxOffset))
|
||||||
|
return null;
|
||||||
|
dir.Add (entry);
|
||||||
|
index_pos += 12 + name_size;
|
||||||
|
}
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||||
{
|
{
|
||||||
var input = arc.File.CreateStream (entry.Offset, entry.Size);
|
var input = arc.File.CreateStream (entry.Offset, entry.Size);
|
||||||
|
@ -134,6 +134,7 @@ White ~blanche comme la lune~<br/>
|
|||||||
<tr><td>*.dat</td><td><tt>NEKOPACK</tt></td><td>No</td><td>Rosebleu<br/>Lime</td><td>
|
<tr><td>*.dat</td><td><tt>NEKOPACK</tt></td><td>No</td><td>Rosebleu<br/>Lime</td><td>
|
||||||
Inpyuri -Hito to Anata to Ayakashi to-<br/>
|
Inpyuri -Hito to Anata to Ayakashi to-<br/>
|
||||||
Nostradamus ni Kiitemiro♪<br/>
|
Nostradamus ni Kiitemiro♪<br/>
|
||||||
|
Tiny Dungeon ~BLACK and WHITE~<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="odd"><td>*.dat</td><td>-</td><td>No</td><td>Meteor<br/>Silver Bullet</td><td>
|
<tr class="odd"><td>*.dat</td><td>-</td><td>No</td><td>Meteor<br/>Silver Bullet</td><td>
|
||||||
Chokotto☆Vampire!<br/>
|
Chokotto☆Vampire!<br/>
|
||||||
@ -486,6 +487,7 @@ Tsuribaka ~Gakuen Taikou! Joshikousei Tsuriage Adventure~<br/>
|
|||||||
<tr><td>*.gr</td><td>-</td><td>No</td></tr>
|
<tr><td>*.gr</td><td>-</td><td>No</td></tr>
|
||||||
<tr class="odd"><td>*.dat</td><td><tt>SPack</tt></td><td>No</td><td>Goku-Fero</td><td>Inchuu Reiki Elenova</tr>
|
<tr class="odd"><td>*.dat</td><td><tt>SPack</tt></td><td>No</td><td>Goku-Fero</td><td>Inchuu Reiki Elenova</tr>
|
||||||
<tr><td>*.fpk</td><td>-</td><td>No</td><td rowspan="2">Candy Soft<br/>Interheart</td><td rowspan="2">
|
<tr><td>*.fpk</td><td>-</td><td>No</td><td rowspan="2">Candy Soft<br/>Interheart</td><td rowspan="2">
|
||||||
|
Aimai Ren'ai<br/>
|
||||||
Chijoku no Kankei ~Inkou Kyoushi~<br/>
|
Chijoku no Kankei ~Inkou Kyoushi~<br/>
|
||||||
Chijoku no Kankei 2<br/>
|
Chijoku no Kankei 2<br/>
|
||||||
Jii -Nozoki no Houshuu-<br/>
|
Jii -Nozoki no Houshuu-<br/>
|
||||||
@ -1071,13 +1073,17 @@ Caramel Box Yarukibako<br/>
|
|||||||
Kagiroi ~Shaku Kei~<br/>
|
Kagiroi ~Shaku Kei~<br/>
|
||||||
L.i.n.k.<br/>
|
L.i.n.k.<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>*.lac</td><td><tt>LAC</tt></td><td>No</td><td rowspan="5">Leaf</td><td rowspan="5">
|
<tr><td>*.lac</td><td><tt>LAC</tt></td><td>No</td><td rowspan="8">Leaf</td><td rowspan="8">
|
||||||
|
Kimi ga Yobu, Megiddo no Oka de<br/>
|
||||||
ToHeart2 AnotherDays<br/>
|
ToHeart2 AnotherDays<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>*.a</td><td><tt>\x1E\xAF</tt></td><td>No</td></tr>
|
<tr><td>*.a</td><td><tt>\x1E\xAF</tt></td><td>No</td></tr>
|
||||||
<tr><td>*.am</td><td><tt>am00</tt></td><td>No</td></tr>
|
<tr><td>*.am</td><td><tt>am00</tt></td><td>No</td></tr>
|
||||||
<tr><td>*.g</td><td>-</td><td>No</td></tr>
|
<tr><td>*.g</td><td>-</td><td>No</td></tr>
|
||||||
<tr><td>*.w</td><td>-</td><td>No</td></tr>
|
<tr><td>*.w</td><td>-</td><td>No</td></tr>
|
||||||
|
<tr><td>*.pak</td><td><tt>LAC</tt></td><td>No</td></tr>
|
||||||
|
<tr><td>*.tex</td><td><tt>TEX PACK0.02</tt></td><td>No</td></tr>
|
||||||
|
<tr><td>*.lgf</td><td><tt>lgf</tt></td><td>No</td></tr>
|
||||||
<tr class="odd"><td>*.ark</td><td>-</td><td>No</td><td>Irrlicht</td><td>
|
<tr class="odd"><td>*.ark</td><td>-</td><td>No</td><td>Irrlicht</td><td>
|
||||||
Alter Ego<br/>
|
Alter Ego<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user