mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 15:44:00 +08:00
implemented DPMX archives.
This commit is contained in:
parent
efbac265ff
commit
68f602640e
@ -112,6 +112,7 @@
|
|||||||
<Compile Include="GameSystem\ImageCGD.cs" />
|
<Compile Include="GameSystem\ImageCGD.cs" />
|
||||||
<Compile Include="GameSystem\ImageCHR.cs" />
|
<Compile Include="GameSystem\ImageCHR.cs" />
|
||||||
<Compile Include="GameSystem\ImageTEXB.cs" />
|
<Compile Include="GameSystem\ImageTEXB.cs" />
|
||||||
|
<Compile Include="HSP\ArcDPM.cs" />
|
||||||
<Compile Include="Lz4Stream.cs" />
|
<Compile Include="Lz4Stream.cs" />
|
||||||
<Compile Include="Majiro\ImageRC8.cs" />
|
<Compile Include="Majiro\ImageRC8.cs" />
|
||||||
<Compile Include="Mixwill\ArcARC0.cs" />
|
<Compile Include="Mixwill\ArcARC0.cs" />
|
||||||
|
157
ArcFormats/HSP/ArcDPM.cs
Normal file
157
ArcFormats/HSP/ArcDPM.cs
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
//! \file ArcDPM.cs
|
||||||
|
//! \date Sun Jan 22 22:17:21 2017
|
||||||
|
//! \brief Hot Soup Processor engine resource archive.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 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;
|
||||||
|
|
||||||
|
namespace GameRes.Formats.HSP
|
||||||
|
{
|
||||||
|
[Export(typeof(ArchiveFormat))]
|
||||||
|
public class DpmOpener : ArchiveFormat
|
||||||
|
{
|
||||||
|
public override string Tag { get { return "DPM"; } }
|
||||||
|
public override string Description { get { return "Hot Soup Processor resource archive"; } }
|
||||||
|
public override uint Signature { get { return 0x584D5044; } } // 'DPMX'
|
||||||
|
public override bool IsHierarchic { get { return false; } }
|
||||||
|
public override bool CanWrite { get { return false; } }
|
||||||
|
|
||||||
|
public DpmOpener ()
|
||||||
|
{
|
||||||
|
Extensions = new string[] { "dpm", "bin" };
|
||||||
|
Signatures = new uint[] { 0x584D5044, 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
static readonly uint DefaultKey = 0xAC52AE58;
|
||||||
|
|
||||||
|
public override ArcFile TryOpen (ArcView file)
|
||||||
|
{
|
||||||
|
uint signature = file.View.ReadUInt32 (0);
|
||||||
|
bool is_inside_exe = false;
|
||||||
|
long base_offset = 0;
|
||||||
|
uint arc_key = 0;
|
||||||
|
if (0x5A4D == (signature & 0xFFFF)) // 'MZ'
|
||||||
|
{
|
||||||
|
var exe = new ExeFile (file);
|
||||||
|
if (exe.Overlay.Size <= 4 || !file.View.AsciiEqual (exe.Overlay.Offset, "DPMX"))
|
||||||
|
return null;
|
||||||
|
base_offset = exe.Overlay.Offset;
|
||||||
|
arc_key = FindExeKey (exe, base_offset);
|
||||||
|
is_inside_exe = true;
|
||||||
|
}
|
||||||
|
else if (0x584D5044 != signature)
|
||||||
|
return null;
|
||||||
|
int count = file.View.ReadInt32 (base_offset+8);
|
||||||
|
if (!IsSaneCount (count))
|
||||||
|
return null;
|
||||||
|
long index_offset = base_offset + 0x10 + file.View.ReadUInt32 (base_offset+0xC);
|
||||||
|
uint data_size = (uint)(file.MaxOffset - (index_offset + 32 * count));
|
||||||
|
base_offset += file.View.ReadUInt32 (base_offset+4);
|
||||||
|
var dir = new List<Entry> (count);
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
var name = file.View.ReadString (index_offset, 0x10);
|
||||||
|
index_offset += 0x14;
|
||||||
|
var entry = FormatCatalog.Instance.Create<DpmEntry> (name);
|
||||||
|
entry.Key = file.View.ReadUInt32 (index_offset);
|
||||||
|
entry.Offset = file.View.ReadUInt32 (index_offset+4) + base_offset;
|
||||||
|
entry.Size = file.View.ReadUInt32 (index_offset+8);
|
||||||
|
if (!entry.CheckPlacement (file.MaxOffset))
|
||||||
|
return null;
|
||||||
|
dir.Add (entry);
|
||||||
|
index_offset += 0xC;
|
||||||
|
}
|
||||||
|
if (is_inside_exe)
|
||||||
|
return new DpmArchive (file, this, dir, arc_key, data_size);
|
||||||
|
else
|
||||||
|
return new DpmArchive (file, this, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||||
|
{
|
||||||
|
var dent = entry as DpmEntry;
|
||||||
|
var darc = arc as DpmArchive;
|
||||||
|
if (null == dent || null == darc || 0 == dent.Key)
|
||||||
|
return base.OpenEntry (arc, entry);
|
||||||
|
var data = arc.File.View.ReadBytes (entry.Offset, entry.Size);
|
||||||
|
darc.DecryptEntry (data, dent.Key);
|
||||||
|
return new BinMemoryStream (data, entry.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint FindExeKey (ExeFile exe, long dpm_offset)
|
||||||
|
{
|
||||||
|
if (!exe.ContainsSection (".rdata"))
|
||||||
|
return DefaultKey;
|
||||||
|
uint base_offset = (uint)(dpm_offset - 0x10000);
|
||||||
|
var offset_str = base_offset.ToString() + '\0';
|
||||||
|
var offset_bytes = Encoding.ASCII.GetBytes (offset_str);
|
||||||
|
var key_pos = exe.FindString (exe.Sections[".rdata"], offset_bytes);
|
||||||
|
if (-1 == key_pos)
|
||||||
|
return DefaultKey;
|
||||||
|
return exe.View.ReadUInt32 (key_pos+0x17);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class DpmEntry : Entry
|
||||||
|
{
|
||||||
|
public uint Key;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class DpmArchive : ArcFile
|
||||||
|
{
|
||||||
|
readonly byte Seed1;
|
||||||
|
readonly byte Seed2;
|
||||||
|
|
||||||
|
public DpmArchive (ArcView arc, ArchiveFormat impl, ICollection<Entry> dir)
|
||||||
|
: base (arc, impl, dir)
|
||||||
|
{
|
||||||
|
Seed1 = 0xAA;
|
||||||
|
Seed2 = 0x55;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DpmArchive (ArcView arc, ArchiveFormat impl, ICollection<Entry> dir, uint arc_key, uint dpm_size)
|
||||||
|
: base (arc, impl, dir)
|
||||||
|
{
|
||||||
|
Seed1 = (byte)((((arc_key >> 16) & 0xFF) * (arc_key & 0xFF) / 3) ^ dpm_size);
|
||||||
|
Seed2 = (byte)((((arc_key >> 8) & 0xFF) * ((arc_key >> 24) & 0xFF) / 5) ^ dpm_size ^ 0xAA);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void DecryptEntry (byte[] data, uint entry_key)
|
||||||
|
{
|
||||||
|
byte s1 = 0xA5; // FIXME these constants seem to vary across games
|
||||||
|
byte s2 = 0x5A; // but this engine is rare, can't confirm for sure.
|
||||||
|
s1 = (byte)(Seed1 + ((entry_key >> 16) ^ (entry_key + s1)));
|
||||||
|
s2 = (byte)(Seed2 + ((entry_key >> 24) ^ ((entry_key >> 8) + s2)));
|
||||||
|
byte val = 0;
|
||||||
|
for (int i = 0; i < data.Length; ++i)
|
||||||
|
{
|
||||||
|
val += (byte)(s1 ^ (data[i] - s2));
|
||||||
|
data[i] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -149,6 +149,7 @@ Tiny Dungeon ~BLESS of DRAGON~<br/>
|
|||||||
Tiny Dungeon ~Brave or Slave~<br/>
|
Tiny Dungeon ~Brave or Slave~<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>
|
||||||
|
Ayase Ke no Onna ~Inka no Ketsumyaku~<br/>
|
||||||
Chokotto☆Vampire!<br/>
|
Chokotto☆Vampire!<br/>
|
||||||
Clover Point<br/>
|
Clover Point<br/>
|
||||||
Setsuei<br/>
|
Setsuei<br/>
|
||||||
@ -305,6 +306,7 @@ Specialite!<br/>
|
|||||||
Suiheisen made Nan Mile?<br/>
|
Suiheisen made Nan Mile?<br/>
|
||||||
Swan Song<br/>
|
Swan Song<br/>
|
||||||
Teakamamire no Tenshi<br/>
|
Teakamamire no Tenshi<br/>
|
||||||
|
Towazugatari ~Shoujo Ryoujoku Hishou~<br/>
|
||||||
Zecchou Spiral!!<br/>
|
Zecchou Spiral!!<br/>
|
||||||
Zettai Karen! Ojou-sama<br/>
|
Zettai Karen! Ojou-sama<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
@ -401,6 +403,7 @@ Futari no Erika ~Osanajimi to Ima Kanojo to~<br/>
|
|||||||
Inen no Yakata<br/>
|
Inen no Yakata<br/>
|
||||||
Inran OL Sawatari Tokiko<br/>
|
Inran OL Sawatari Tokiko<br/>
|
||||||
Itsuwari no Kyoushitsu<br/>
|
Itsuwari no Kyoushitsu<br/>
|
||||||
|
Kangoku ~Injoku no Jikkentou~<br/>
|
||||||
Kunoichi Kikyou ~Gensou Kannou Emaki~<br/>
|
Kunoichi Kikyou ~Gensou Kannou Emaki~<br/>
|
||||||
Mechiku ~Injoku no Shuuyoujo~<br/>
|
Mechiku ~Injoku no Shuuyoujo~<br/>
|
||||||
Momo x Momi<br/>
|
Momo x Momi<br/>
|
||||||
@ -445,6 +448,7 @@ Hitozuma Onna Kyoushi Reika <span class="footnote">ShiinaRio v2.39</span><br/>
|
|||||||
Idol Koukai Chijoku Sex <span class="footnote">ShiinaRio v2.46</span><br/>
|
Idol Koukai Chijoku Sex <span class="footnote">ShiinaRio v2.46</span><br/>
|
||||||
Intruder <span class="footnote">ShiinaRio v2.49</span><br/>
|
Intruder <span class="footnote">ShiinaRio v2.49</span><br/>
|
||||||
Itsuka, Dokoka de ~Ano Ameoto no Kioku~<span class="footnote">2.36 or 2.37</span><br/>
|
Itsuka, Dokoka de ~Ano Ameoto no Kioku~<span class="footnote">2.36 or 2.37</span><br/>
|
||||||
|
Kateinai Choukyou <span class="footnote">ShiinaRio v2.31</span><br/>
|
||||||
Kichiku Nakadashi Suieibu<span class="footnote">ShiinaRio v2.41</span><br/>
|
Kichiku Nakadashi Suieibu<span class="footnote">ShiinaRio v2.41</span><br/>
|
||||||
Mahou Shoujo no Taisetsu na Koto <span class="footnote">ShiinaRio v2.47</span><br/>
|
Mahou Shoujo no Taisetsu na Koto <span class="footnote">ShiinaRio v2.47</span><br/>
|
||||||
Maki Fes! <span class="footnote">ShiinaRio v2.50</span><br/>
|
Maki Fes! <span class="footnote">ShiinaRio v2.50</span><br/>
|
||||||
@ -453,6 +457,7 @@ Mimi o Sumaseba <span class="footnote">ShiinaRio v2.47</span><br/>
|
|||||||
Nagagutsu wo Haita Deco <span class="footnote">ShiinaRio v2.39</span><br/>
|
Nagagutsu wo Haita Deco <span class="footnote">ShiinaRio v2.39</span><br/>
|
||||||
Najimi no Oba-chan <span class="footnote">ShiinaRio v2.47</span><br/>
|
Najimi no Oba-chan <span class="footnote">ShiinaRio v2.47</span><br/>
|
||||||
Niizuma to Yuukaihan <span class="footnote">ShiinaRio v2.45</span><br/>
|
Niizuma to Yuukaihan <span class="footnote">ShiinaRio v2.45</span><br/>
|
||||||
|
Onegan! <span class="footnote">ShiinaRio v2.48</span><br/>
|
||||||
Otome Chibaku Yuugi <span class="footnote">ShiinaRio v2.40</span><br/>
|
Otome Chibaku Yuugi <span class="footnote">ShiinaRio v2.40</span><br/>
|
||||||
Otome Juurin Yuugi <span class="footnote">ShiinaRio v2.37</span><br/>
|
Otome Juurin Yuugi <span class="footnote">ShiinaRio v2.37</span><br/>
|
||||||
Puchipuchi Idol Kouhosei <span class="footnote">ShiinaRio v2.49</span><br/>
|
Puchipuchi Idol Kouhosei <span class="footnote">ShiinaRio v2.49</span><br/>
|
||||||
@ -483,7 +488,9 @@ Gakuen Tengoku ~Kyonyuu de Ikimakuri~<br/>
|
|||||||
Gokujou Chikan Densha<br/>
|
Gokujou Chikan Densha<br/>
|
||||||
Hokenshitsu no Sensei ~Onedari Bakunyuu Lesson~<br/>
|
Hokenshitsu no Sensei ~Onedari Bakunyuu Lesson~<br/>
|
||||||
Jokyoushi wo Kurau<br/>
|
Jokyoushi wo Kurau<br/>
|
||||||
|
Kangoku Suieibu<br/>
|
||||||
Lovers Collection<br/>
|
Lovers Collection<br/>
|
||||||
|
Maho☆Gaku ~Mahoroba Kokusai Bouei Daigaku Fuzoku Gakuen~<br/>
|
||||||
Nachtmusik<br/>
|
Nachtmusik<br/>
|
||||||
Nachtmusik Another<br/>
|
Nachtmusik Another<br/>
|
||||||
Oto☆Puri<br/>
|
Oto☆Puri<br/>
|
||||||
@ -1126,6 +1133,7 @@ Karen<br/>
|
|||||||
<tr class="odd last"><td>*.mk</td><td><tt>MKVS</tt></td><td>No</td></tr>
|
<tr class="odd last"><td>*.mk</td><td><tt>MKVS</tt></td><td>No</td></tr>
|
||||||
<tr><td>*.pak</td><td>-</td><td>No</td><td>Black Rainbow<br/>Melty</td><td>
|
<tr><td>*.pak</td><td>-</td><td>No</td><td>Black Rainbow<br/>Melty</td><td>
|
||||||
Ingoku Chikan Ressha<br/>
|
Ingoku Chikan Ressha<br/>
|
||||||
|
love, VAMPIRE FLOWERS<br/>
|
||||||
Peropero Saimin 3 Raouden ~Yousei no Sakuryaku~<br/>
|
Peropero Saimin 3 Raouden ~Yousei no Sakuryaku~<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="odd"><td>*.gxp</td><td><tt>GXP</tt></td><td>No</td><td>Astronauts</td><td>
|
<tr class="odd"><td>*.gxp</td><td><tt>GXP</tt></td><td>No</td><td>Astronauts</td><td>
|
||||||
@ -1347,8 +1355,12 @@ Seika no Mori<br/>
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>*.gd</td><td><tt>GD2</tt><br/><tt>GD3</tt></td><td>No</td><td rowspan="2">C4</td><td rowspan="2">
|
<tr><td>*.gd</td><td><tt>GD2</tt><br/><tt>GD3</tt></td><td>No</td><td rowspan="2">C4</td><td rowspan="2">
|
||||||
Koi Suru Science<br/>
|
Koi Suru Science<br/>
|
||||||
|
Mite Kudasaimasu?<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="last"><td>*.vmd</td><td>-</td><td>No</td></tr>
|
<tr class="last"><td>*.vmd</td><td>-</td><td>No</td></tr>
|
||||||
|
<tr class ="odd"><td>*.dpm<br/>*.bin</td><td><tt>DPMX</tt></td><td>No</td><td>Hot Soup Processor</td><td>
|
||||||
|
femme fatale<br/>
|
||||||
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p><a name="note-1" class="footnote">1</a> Non-encrypted only</p>
|
<p><a name="note-1" class="footnote">1</a> Non-encrypted only</p>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user