implemented SZS archives and TIG images.

This commit is contained in:
morkt 2016-06-04 20:01:19 +04:00
parent 3bf28986b8
commit 4b945bc46a
4 changed files with 183 additions and 1 deletions

View File

@ -120,8 +120,10 @@
<Compile Include="RealLive\ImagePDT.cs" />
<Compile Include="Silky\ImageZIT.cs" />
<Compile Include="SimpleEncryption.cs" />
<Compile Include="Slg\ArcSZS.cs" />
<Compile Include="Slg\AudioVOI.cs" />
<Compile Include="Slg\ImageALB.cs" />
<Compile Include="Slg\ImageTIG.cs" />
<Compile Include="Softpal\ArcPAC.cs" />
<Compile Include="Softpal\AudioBGM.cs" />
<Compile Include="Softpal\ImagePGD.cs" />

76
ArcFormats/Slg/ArcSZS.cs Normal file
View File

@ -0,0 +1,76 @@
//! \file ArcSZS.cs
//! \date Sat Jun 04 17:31:59 2016
//! \brief SLG system 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.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Security.Cryptography;
namespace GameRes.Formats.Slg
{
[Export(typeof(ArchiveFormat))]
public class SzsOpener : ArchiveFormat
{
public override string Tag { get { return "SZS"; } }
public override string Description { get { return "SLG system resource archive"; } }
public override uint Signature { get { return 0x31535A53; } } // 'SZS1'
public override bool IsHierarchic { get { return false; } }
public override bool CanCreate { get { return false; } }
public override ArcFile TryOpen (ArcView file)
{
int version = file.View.ReadByte (4) - '0';
if (version < 0 || !file.View.AsciiEqual (5, "0__"))
return null;
int count = file.View.ReadInt16 (0xC);
if (!IsSaneCount (count))
return null;
uint index_offset = 0x10;
var dir = new List<Entry> (count);
for (int i = 0; i < count; ++i)
{
var name = file.View.ReadString (index_offset, 0x100);
if (string.IsNullOrWhiteSpace (name))
return null;
index_offset += 0x100;
var entry = FormatCatalog.Instance.Create<Entry> (name);
entry.Offset = file.View.ReadInt64 (index_offset);
entry.Size = file.View.ReadUInt32 (index_offset+8);
if (!entry.CheckPlacement (file.MaxOffset))
return null;
dir.Add (entry);
index_offset += 0x10;
}
return new ArcFile (file, this, dir);
}
public override Stream OpenEntry (ArcFile arc, Entry entry)
{
var input = arc.File.CreateStream (entry.Offset, entry.Size);
return new CryptoStream (input, new XorTransform (0x90), CryptoStreamMode.Read);
}
}
}

View File

@ -0,0 +1,98 @@
//! \file ImageTIG.cs
//! \date Sat Jun 04 18:00:15 2016
//! \brief SLG system encrypted PNG images.
//
// 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.ComponentModel.Composition;
using System.IO;
using System.Security.Cryptography;
namespace GameRes.Formats.Slg
{
[Export(typeof(ImageFormat))]
public class TigFormat : PngFormat
{
public override string Tag { get { return "TIG"; } }
public override string Description { get { return "SLG system encrypted PNG image"; } }
public override uint Signature { get { return 0x7CF3C28B; } }
public override ImageMetaData ReadMetaData (Stream stream)
{
using (var proxy = new ProxyStream (stream, true))
using (var input = new CryptoStream (proxy, new TigTransform(), CryptoStreamMode.Read))
return base.ReadMetaData (input);
}
public override ImageData Read (Stream stream, ImageMetaData info)
{
using (var proxy = new ProxyStream (stream, true))
using (var input = new CryptoStream (proxy, new TigTransform(), CryptoStreamMode.Read))
return base.Read (input, info);
}
public override void Write (Stream file, ImageData image)
{
throw new System.NotImplementedException ("TigFormat.Write not implemented");
}
}
internal sealed class TigTransform : ICryptoTransform
{
const int BlockSize = 256;
uint m_key;
public bool CanReuseTransform { get { return true; } }
public bool CanTransformMultipleBlocks { get { return true; } }
public int InputBlockSize { get { return BlockSize; } }
public int OutputBlockSize { get { return BlockSize; } }
public TigTransform ()
{
m_key = 0x7F7F7F7F;
}
public int TransformBlock (byte[] inputBuffer, int inputOffset, int inputCount,
byte[] outputBuffer, int outputOffset)
{
for (int i = 0; i < inputCount; ++i)
{
m_key *= 0x343FD;
m_key += 0x269EC3;
outputBuffer[outputOffset+i] = (byte)(inputBuffer[inputOffset+i] - (m_key >> 16));
}
return inputCount;
}
public byte[] TransformFinalBlock (byte[] inputBuffer, int inputOffset, int inputCount)
{
byte[] outputBuffer = new byte[inputCount];
TransformBlock (inputBuffer, inputOffset, inputCount, outputBuffer, 0);
return outputBuffer;
}
public void Dispose ()
{
System.GC.SuppressFinalize (this);
}
}
}

View File

@ -364,6 +364,7 @@ Lovers Collection<br/>
Nachtmusik<br/>
Nachtmusik Another<br/>
Oto☆Puri<br/>
Rakuen no Rukia ~Blood Moon Rising~<br/>
Samayou Mitama ni Yasuragi no Toki wo<br/>
Time Trouble ~Marie ni Kubikkake~<br/>
</td></tr>
@ -579,6 +580,7 @@ Before Dawn Daybreak ~Shinen no Utahime~<br/>
Gun-Katana<br/>
Jishou Seirei Majutsushi vs Shinsei Daiikkyuu Akuma<br/>
Kurogane no Tsubasa ~The Alchemist's Story~<br/>
Mushitsukai<br/>
Yami no Koe series<br/>
</td></tr>
<tr><td>*.dwq</td><td><tt>BMP</tt><br/><tt>JPEG</tt><br/><tt>PNG</tt><br/><tt>JPEG+MASK</tt><br/><tt>PACKBMP+MASK</tt><br/></td><td>No</td></tr>
@ -638,6 +640,7 @@ Cross Quartz<br/>
Hyakki Yakou<br/>
Saikyou Goshujin-sama! -Mighty My Master-<br/>
Saiminjutsu Re<br/>
Wizard Links<br/>
</td></tr>
<tr><td>*.med</td><td><tt>MD</tt></td><td>No</td></tr>
<tr class="odd"><td>*.tcd</td><td><tt>TCD3</tt></td><td>No</td><td rowspan="2">TopCat</td><td rowspan="2">
@ -809,9 +812,12 @@ Tokyo Necro<br/>
Thanatos no Koi ~In Ane Otouto Soukan~<br/>
</td></tr>
<tr class="odd"><td>*.gps</td><td><tt>GPS</tt></td><td>No</td></tr>
<tr><td>*.alb</td><td><tt>ALB1.21</tt></td><td>No</td><td rowspan="2">SLG system</td><td rowspan="2">
<tr><td>*.szs</td><td><tt>SZS100__</tt></td><td>No</td><td rowspan="4">SLG system</td><td rowspan="4">
Sengoku Hime<br/>
Shihen 69 ~Shinen no Messiah~<br/>
</td></tr>
<tr><td>*.tig</td><td><tt>\x7C\xF3\xC2\x8B</tt></td><td>No</td></tr>
<tr><td>*.alb</td><td><tt>ALB1.21</tt></td><td>No</td></tr>
<tr><td>*.voi</td><td>-</td><td>No</td></tr>
<tr class="odd"><td>*.wag</td><td><tt>IAF_</tt></td><td>No</td><td rowspan="3">Hexenhaus</td><td rowspan="3">
Angenehm Platz -Kleiner Garten Sie Erstellen-<br/>