mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-29 06:14:13 +08:00
implemented GXP archives.
This commit is contained in:
parent
d3fa6c005d
commit
f6304da105
@ -73,6 +73,7 @@
|
||||
<Compile Include="Ankh\ArcGRP.cs" />
|
||||
<Compile Include="Aoi\ImageAGF.cs" />
|
||||
<Compile Include="ArcCG.cs" />
|
||||
<Compile Include="Astronauts\ArcGXP.cs" />
|
||||
<Compile Include="Banana\ImageGEC.cs" />
|
||||
<Compile Include="BlackRainbow\ArcPAK.cs" />
|
||||
<Compile Include="Cmvs\ArcPBZ.cs" />
|
||||
|
100
ArcFormats/Astronauts/ArcGXP.cs
Normal file
100
ArcFormats/Astronauts/ArcGXP.cs
Normal file
@ -0,0 +1,100 @@
|
||||
//! \file ArcGXP.cs
|
||||
//! \date Thu Jun 30 08:17:12 2016
|
||||
//! \brief Astronauts resource archive.
|
||||
//
|
||||
// Copyright (C) 2016 by morkt
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.Astronauts
|
||||
{
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class PakOpener : ArchiveFormat
|
||||
{
|
||||
public override string Tag { get { return "GXP"; } }
|
||||
public override string Description { get { return "Astronauts resource archive"; } }
|
||||
public override uint Signature { get { return 0x505847; } } // 'GXP'
|
||||
public override bool IsHierarchic { get { return true; } }
|
||||
public override bool CanCreate { get { return false; } }
|
||||
|
||||
static readonly byte[] KnownKey = {
|
||||
0x40, 0x21, 0x28, 0x38, 0xA6, 0x6E, 0x43, 0xA5, 0x40, 0x21, 0x28, 0x38, 0xA6, 0x43, 0xA5, 0x64,
|
||||
0x3E, 0x65, 0x24, 0x20, 0x46, 0x6E, 0x74,
|
||||
};
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
int count = file.View.ReadInt32 (0x18);
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
|
||||
long base_offset = file.View.ReadInt64 (0x28);
|
||||
uint entry_key = KnownKey[0] | (1u^KnownKey[1]) << 8 | (2u^KnownKey[2]) << 16 | (3u^KnownKey[3]) << 24;
|
||||
uint index_offset = 0x30;
|
||||
var entry_buffer = new byte[0x100];
|
||||
var dir = new List<Entry> (count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var entry_length = file.View.ReadUInt32 (index_offset) ^ entry_key;
|
||||
if (entry_length < 0x20 || entry_length > 0x1000)
|
||||
return null;
|
||||
if (entry_length > entry_buffer.Length)
|
||||
entry_buffer = new byte[entry_length];
|
||||
if (entry_length != file.View.Read (index_offset, entry_buffer, 0, entry_length))
|
||||
return null;
|
||||
Decrypt (entry_buffer, entry_length);
|
||||
int name_length = LittleEndian.ToInt32 (entry_buffer, 0xC) * 2; // length in characters
|
||||
if (name_length >= entry_length)
|
||||
return null;
|
||||
var name = Encoding.Unicode.GetString (entry_buffer, 0x20, name_length);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = base_offset + LittleEndian.ToInt64 (entry_buffer, 0x18);
|
||||
entry.Size = LittleEndian.ToUInt32 (entry_buffer, 4); // length is 64-bit actually
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
return null;
|
||||
dir.Add (entry);
|
||||
index_offset += entry_length;
|
||||
}
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
|
||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||
{
|
||||
var data = arc.File.View.ReadBytes (entry.Offset, entry.Size);
|
||||
Decrypt (data, entry.Size);
|
||||
return new MemoryStream (data);
|
||||
}
|
||||
|
||||
static void Decrypt (byte[] data, uint length)
|
||||
{
|
||||
for (uint i = 0; i < length; ++i)
|
||||
{
|
||||
data[i] ^= (byte)(i ^ KnownKey[i % KnownKey.Length]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -222,6 +222,7 @@ Crime Rhyme series<br/>
|
||||
Damegane<br/>
|
||||
Distance<br/>
|
||||
ExE<br/>
|
||||
Fair Child<br/>
|
||||
Fate/stay night<br/>
|
||||
Fate/hollow ataraxia<br/>
|
||||
G-senjou no Maou<br/>
|
||||
@ -256,6 +257,7 @@ Zecchou Spiral!!<br/>
|
||||
<tr class="odd"><td>*.ypf</td><td><tt>YPF</tt></td><td>Yes</td><td rowspan="2">YU-RIS</td><td rowspan="2">
|
||||
Eroge! ~H mo Game mo Kaihatsu Zanmai~<br/>
|
||||
Mamono Musume-tachi to no Rakuen ~Slime & Scylla~<br/>
|
||||
Mashou no Nie 3 ~Hakudaku no Umi ni Shizumu Injoku no Reiki~<br/>
|
||||
Sei Monmusu Festival!!<br/>
|
||||
Shin Chikan Ou<br/>
|
||||
Unionism Quartet<br/>
|
||||
@ -584,6 +586,7 @@ Zettai★Maou ~Boku no Mune-kyun Gakuen Saga~<br/>
|
||||
</td></tr>
|
||||
<tr><td>*.sud</td><td>-</td><td>No</td><td rowspan="3">Triangle</td><td rowspan="3">
|
||||
Kourin Tenshi En Ciel Rena<br/>
|
||||
Mahou Senshi Sweet Knights ~Heroine Ryoujoku Shirei~<br/>
|
||||
Mamagoto<br/>
|
||||
Vampire Crusaders<br/>
|
||||
</td></tr>
|
||||
@ -915,6 +918,9 @@ Karen<br/>
|
||||
Ingoku Chikan Ressha<br/>
|
||||
Peropero Saimin 3 Raouden ~Yousei no Sakuryaku~<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.gxp</td><td><tt>GXP</tt></td><td>No</td><td>Astronauts</td><td>
|
||||
Demonion 2 ~Maou to Sannin no Joou~<br/>
|
||||
</td></tr>
|
||||
</table>
|
||||
<p><a name="note-1" class="footnote">1</a> Non-encrypted only</p>
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user