mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-25 04:14:13 +08:00
(VffOpener): recognize archives embedded into EXE files.
This commit is contained in:
parent
da15b1f31f
commit
6ca6dd7e19
@ -49,6 +49,7 @@ namespace GameRes.Formats.LiveMaker
|
|||||||
|
|
||||||
public override ArcFile TryOpen (ArcView file)
|
public override ArcFile TryOpen (ArcView file)
|
||||||
{
|
{
|
||||||
|
uint base_offset = 0;
|
||||||
ArcView index_file = file;
|
ArcView index_file = file;
|
||||||
ArcView extra_file = null;
|
ArcView extra_file = null;
|
||||||
try
|
try
|
||||||
@ -58,24 +59,32 @@ namespace GameRes.Formats.LiveMaker
|
|||||||
// game.001 -- [optional] extra part
|
// game.001 -- [optional] extra part
|
||||||
// game.ext -- [optional] separate index (could be included into the main body)
|
// game.ext -- [optional] separate index (could be included into the main body)
|
||||||
|
|
||||||
if (!file.Name.EndsWith (".dat", StringComparison.InvariantCultureIgnoreCase))
|
|
||||||
return null;
|
|
||||||
uint signature = index_file.View.ReadUInt32 (0);
|
uint signature = index_file.View.ReadUInt32 (0);
|
||||||
if (0x666676 != signature)
|
if (file.Name.EndsWith (".exe", StringComparison.InvariantCultureIgnoreCase)
|
||||||
|
&& (0x5A4D == (signature & 0xFFFF))) // 'MZ'
|
||||||
|
{
|
||||||
|
base_offset = SkipExeData (index_file);
|
||||||
|
signature = index_file.View.ReadUInt32 (base_offset);
|
||||||
|
}
|
||||||
|
else if (!file.Name.EndsWith (".dat", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else if (0x666676 != signature)
|
||||||
{
|
{
|
||||||
var ext_filename = Path.ChangeExtension (file.Name, ".ext");
|
var ext_filename = Path.ChangeExtension (file.Name, ".ext");
|
||||||
if (!VFS.FileExists (ext_filename))
|
if (!VFS.FileExists (ext_filename))
|
||||||
return null;
|
return null;
|
||||||
index_file = VFS.OpenView (ext_filename);
|
index_file = VFS.OpenView (ext_filename);
|
||||||
signature = index_file.View.ReadUInt32 (0);
|
signature = index_file.View.ReadUInt32 (0);
|
||||||
|
}
|
||||||
if (0x666676 != signature)
|
if (0x666676 != signature)
|
||||||
return null;
|
return null;
|
||||||
}
|
int count = index_file.View.ReadInt32 (base_offset+6);
|
||||||
int count = index_file.View.ReadInt32 (6);
|
|
||||||
if (!IsSaneCount (count))
|
if (!IsSaneCount (count))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var dir = ReadIndex (index_file, count);
|
var dir = ReadIndex (index_file, base_offset, count);
|
||||||
if (null == dir)
|
if (null == dir)
|
||||||
return null;
|
return null;
|
||||||
long max_offset = file.MaxOffset;
|
long max_offset = file.MaxOffset;
|
||||||
@ -133,9 +142,9 @@ namespace GameRes.Formats.LiveMaker
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Entry> ReadIndex (ArcView file, int count)
|
List<Entry> ReadIndex (ArcView file, uint base_offset, int count)
|
||||||
{
|
{
|
||||||
uint index_offset = 0xA;
|
uint index_offset = base_offset+0xA;
|
||||||
var name_buffer = new byte[0x100];
|
var name_buffer = new byte[0x100];
|
||||||
var rnd = new TpRandom (0x75D6EE39u);
|
var rnd = new TpRandom (0x75D6EE39u);
|
||||||
var dir = new List<Entry> (count);
|
var dir = new List<Entry> (count);
|
||||||
@ -153,11 +162,11 @@ namespace GameRes.Formats.LiveMaker
|
|||||||
dir.Add (FormatCatalog.Instance.Create<PackedEntry> (name));
|
dir.Add (FormatCatalog.Instance.Create<PackedEntry> (name));
|
||||||
}
|
}
|
||||||
rnd.Reset();
|
rnd.Reset();
|
||||||
long offset = file.View.ReadInt64 (index_offset) ^ (int)rnd.GetRand32();
|
long offset = base_offset + (file.View.ReadInt64 (index_offset) ^ (int)rnd.GetRand32());
|
||||||
foreach (var entry in dir)
|
foreach (var entry in dir)
|
||||||
{
|
{
|
||||||
index_offset += 8;
|
index_offset += 8;
|
||||||
long next_offset = file.View.ReadInt64 (index_offset) ^ (int)rnd.GetRand32();
|
long next_offset = base_offset + (file.View.ReadInt64 (index_offset) ^ (int)rnd.GetRand32());
|
||||||
entry.Offset = offset;
|
entry.Offset = offset;
|
||||||
entry.Size = (uint)(next_offset - offset);
|
entry.Size = (uint)(next_offset - offset);
|
||||||
offset = next_offset;
|
offset = next_offset;
|
||||||
@ -178,6 +187,31 @@ namespace GameRes.Formats.LiveMaker
|
|||||||
}
|
}
|
||||||
return Encodings.cp932.GetString (name_buf, 0, name_length);
|
return Encodings.cp932.GetString (name_buf, 0, name_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint SkipExeData (ArcView file)
|
||||||
|
{
|
||||||
|
uint offset = 0;
|
||||||
|
uint pe_offset = file.View.ReadUInt32 (0x3c);
|
||||||
|
if (pe_offset < file.MaxOffset && 0x4550 == file.View.ReadUInt32 (pe_offset)) // 'PE'
|
||||||
|
{
|
||||||
|
int opt_header = file.View.ReadUInt16 (pe_offset+0x14); // SizeOfOptionalHeader
|
||||||
|
offset = file.View.ReadUInt32 (pe_offset+0x54); // SizeOfHeaders
|
||||||
|
long section_table = pe_offset+opt_header+0x18;
|
||||||
|
int count = file.View.ReadUInt16 (pe_offset+6); // NumberOfSections
|
||||||
|
if (section_table + 0x28*count < file.MaxOffset)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
uint size = file.View.ReadUInt32 (section_table+0x10);
|
||||||
|
uint addr = file.View.ReadUInt32 (section_table+0x14);
|
||||||
|
section_table += 0x28;
|
||||||
|
if (0 != size)
|
||||||
|
offset = Math.Max (addr + size, offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class TpRandom
|
internal class TpRandom
|
||||||
@ -239,6 +273,7 @@ namespace GameRes.Formats.LiveMaker
|
|||||||
ExtraFile.Dispose();
|
ExtraFile.Dispose();
|
||||||
_vff_disposed = true;
|
_vff_disposed = true;
|
||||||
}
|
}
|
||||||
|
base.Dispose (disposing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ Okaa-san ga Ippai!<br/>
|
|||||||
<tr><td>*+*.lst</td><td>-</td><td>No</td><td rowspan="2">Nexton LikeC</td><td rowspan="2">
|
<tr><td>*+*.lst</td><td>-</td><td>No</td><td rowspan="2">Nexton LikeC</td><td rowspan="2">
|
||||||
Chikan Ou ~Inkoku no Souzousha~<br/>
|
Chikan Ou ~Inkoku no Souzousha~<br/>
|
||||||
Daisaimin Rankou Gakuen<br/>
|
Daisaimin Rankou Gakuen<br/>
|
||||||
|
Haitoku no Gakuen ~Yami ni Sasagerareta Otome-tachi~<br/>
|
||||||
Injoku Shinryuu Club<br/>
|
Injoku Shinryuu Club<br/>
|
||||||
Moon.<br/>
|
Moon.<br/>
|
||||||
Ryoujoku Famiresu Choukyou Menu<br/>
|
Ryoujoku Famiresu Choukyou Menu<br/>
|
||||||
@ -255,6 +256,7 @@ Oku-sama wa Moto Yariman<br/>
|
|||||||
Omana 2: Omaenchi Moeteruzo<br/>
|
Omana 2: Omaenchi Moeteruzo<br/>
|
||||||
Ore no Saimin Fantasia<br/>
|
Ore no Saimin Fantasia<br/>
|
||||||
Ouka Ryouran<br/>
|
Ouka Ryouran<br/>
|
||||||
|
Oyako Ninjutsu Kunoichi PonPon!!<br/>
|
||||||
RGH ~Koi to Hero to Gakuen to~<br/>
|
RGH ~Koi to Hero to Gakuen to~<br/>
|
||||||
Riding Incubus<br/>
|
Riding Incubus<br/>
|
||||||
Seirei Tenshou<br/>
|
Seirei Tenshou<br/>
|
||||||
@ -294,6 +296,7 @@ Natsu Kagura<br/>
|
|||||||
Assault Angel Canon<br/>
|
Assault Angel Canon<br/>
|
||||||
Chikatetsu Fuusa Jiken<br/>
|
Chikatetsu Fuusa Jiken<br/>
|
||||||
Eien no Owari ni<br/>
|
Eien no Owari ni<br/>
|
||||||
|
Elf no Futago Hime Willan to Arsura<br/>
|
||||||
Fuurinkanzan<br/>
|
Fuurinkanzan<br/>
|
||||||
Gedou Yuusha<br/>
|
Gedou Yuusha<br/>
|
||||||
Himemiko<br/>
|
Himemiko<br/>
|
||||||
@ -951,6 +954,7 @@ Big Magnum Harimoto-sensei<br/>
|
|||||||
<tr><td>*.mfc</td><td><tt>MFC</tt></td><td>No</td></tr>
|
<tr><td>*.mfc</td><td><tt>MFC</tt></td><td>No</td></tr>
|
||||||
<tr class="odd"><td>game.dat</td><td><tt>vff</tt></td><td>No</td><td rowspan="2">LiveMaker</td><td rowspan="2">
|
<tr class="odd"><td>game.dat</td><td><tt>vff</tt></td><td>No</td><td rowspan="2">LiveMaker</td><td rowspan="2">
|
||||||
Grope ~Yami no Naka no Kotori-tachi~<br/>
|
Grope ~Yami no Naka no Kotori-tachi~<br/>
|
||||||
|
Incest Lover ~Mama to Haha no Himitsu~<br/>
|
||||||
Ryoujoku Seifuku Jogakuen ~Chimitsu ni Nureta Seifuku~<br/>
|
Ryoujoku Seifuku Jogakuen ~Chimitsu ni Nureta Seifuku~<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="odd"><td>*.gal</td><td><tt>Gale105</tt><br/><tt>Gale106</tt></td><td>No</td></tr>
|
<tr class="odd"><td>*.gal</td><td><tt>Gale105</tt><br/><tt>Gale106</tt></td><td>No</td></tr>
|
||||||
@ -987,8 +991,11 @@ Hanamaru! 2<br/>
|
|||||||
Hime Kami 1/2<br/>
|
Hime Kami 1/2<br/>
|
||||||
In'youchuu Goku ~Ryoujoku Jigoku Taimaroku~<br/>
|
In'youchuu Goku ~Ryoujoku Jigoku Taimaroku~<br/>
|
||||||
In'youchuu Rei ~Ryoujoku Shiro Taima Emaki~<br/>
|
In'youchuu Rei ~Ryoujoku Shiro Taima Emaki~<br/>
|
||||||
|
Kuraibito<br/>
|
||||||
|
Onna Kyoushi Suzune<br/>
|
||||||
Oshioki ~Gakuen Reijou Kousei Keikaku~<br/>
|
Oshioki ~Gakuen Reijou Kousei Keikaku~<br/>
|
||||||
Ore Maou! ~Kudake Chitta Tamashii<br/>
|
Ore Maou! ~Kudake Chitta Tamashii<br/>
|
||||||
|
Volley Coaching!<br/>
|
||||||
Zoku Etsuraku no Tane<br/>
|
Zoku Etsuraku no Tane<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="odd"><td>*.bin</td><td><tt>OZ</tt></td><td>No</td><td>Patisserie</td><td>
|
<tr class="odd"><td>*.bin</td><td><tt>OZ</tt></td><td>No</td><td>Patisserie</td><td>
|
||||||
@ -1017,6 +1024,7 @@ Rakuin Hime Runed Princess<br/>
|
|||||||
Elevator Panic ~Misshitsu no Inkou~<br/>
|
Elevator Panic ~Misshitsu no Inkou~<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>*.dat</td><td><tt>MK2.0</tt></td><td>No</td><td>MAIKA</td><td>
|
<tr><td>*.dat</td><td><tt>MK2.0</tt></td><td>No</td><td>MAIKA</td><td>
|
||||||
|
Inka Gakuen Taisen<br/>
|
||||||
Uchuu Keiji Soldivan<br/>
|
Uchuu Keiji Soldivan<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="odd"><td>*.ttd</td><td><tt>.FRC</tt></td><td>No</td><td>Morning</td><td>
|
<tr class="odd"><td>*.ttd</td><td><tt>.FRC</tt></td><td>No</td><td>Morning</td><td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user