mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34:00 +08:00
(GyuFormat): query encryption scheme.
This commit is contained in:
parent
5ea59a1a3e
commit
85ec4b3a37
@ -99,6 +99,9 @@
|
||||
<DependentUpon>WidgetBELL.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DDSystem\ArcDDP.cs" />
|
||||
<Compile Include="ExHibit\WidgetGYU.xaml.cs">
|
||||
<DependentUpon>WidgetGYU.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Ipac\ArcIPAC.cs" />
|
||||
<Compile Include="Ipac\AudioWST.cs" />
|
||||
<Compile Include="Ipac\ImageIES.cs" />
|
||||
@ -606,6 +609,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ExHibit\WidgetGYU.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="FC01\WidgetMCG.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -2,7 +2,7 @@
|
||||
//! \date Mon Nov 02 00:38:41 2015
|
||||
//! \brief ExHIBIT engine image format.
|
||||
//
|
||||
// Copyright (C) 2015 by morkt
|
||||
// Copyright (C) 2015-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
|
||||
@ -25,12 +25,16 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Media;
|
||||
using GameRes.Utility;
|
||||
using GameRes.Compression;
|
||||
using GameRes.Cryptography;
|
||||
using GameRes.Formats.Strings;
|
||||
using GameRes.Formats.Properties;
|
||||
|
||||
namespace GameRes.Formats.ExHibit
|
||||
{
|
||||
@ -44,6 +48,12 @@ namespace GameRes.Formats.ExHibit
|
||||
public int PaletteSize;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class GyuMap : ResourceScheme
|
||||
{
|
||||
public Dictionary<string, Dictionary<int, uint>> KnownKeys;
|
||||
}
|
||||
|
||||
[Export(typeof(ImageFormat))]
|
||||
public class GyuFormat : ImageFormat
|
||||
{
|
||||
@ -51,6 +61,14 @@ namespace GameRes.Formats.ExHibit
|
||||
public override string Description { get { return "ExHIBIT engine image format"; } }
|
||||
public override uint Signature { get { return 0x1A555947; } } // 'GYU'
|
||||
|
||||
public static Dictionary<string, Dictionary<int, uint>> KnownKeys = new Dictionary<string, Dictionary<int, uint>>();
|
||||
|
||||
public override ResourceScheme Scheme
|
||||
{
|
||||
get { return new GyuMap { KnownKeys = KnownKeys }; }
|
||||
set { KnownKeys = ((GyuMap)value).KnownKeys; }
|
||||
}
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
{
|
||||
using (var reader = new ArcView.Reader (stream))
|
||||
@ -71,12 +89,28 @@ namespace GameRes.Formats.ExHibit
|
||||
}
|
||||
}
|
||||
|
||||
IDictionary<int, uint> CurrentMap = null;
|
||||
|
||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||
{
|
||||
var meta = (GyuMetaData)info;
|
||||
if (0 == meta.Key)
|
||||
throw new UnknownEncryptionScheme ("Unknown image encryption key");
|
||||
|
||||
{
|
||||
bool got_key = false;
|
||||
var name = Path.GetFileNameWithoutExtension (meta.FileName);
|
||||
int num;
|
||||
if (int.TryParse (name, out num))
|
||||
{
|
||||
if (null == CurrentMap)
|
||||
CurrentMap = QueryScheme();
|
||||
got_key = CurrentMap != null && CurrentMap.TryGetValue (num, out meta.Key);
|
||||
}
|
||||
if (!got_key)
|
||||
{
|
||||
CurrentMap = null;
|
||||
throw new UnknownEncryptionScheme ("Unknown image encryption key");
|
||||
}
|
||||
}
|
||||
var reader = new GyuReader (stream, meta);
|
||||
reader.Unpack();
|
||||
return ImageData.CreateFlipped (meta, reader.Format, reader.Palette, reader.Data, reader.Stride);
|
||||
@ -86,6 +120,33 @@ namespace GameRes.Formats.ExHibit
|
||||
{
|
||||
throw new System.NotImplementedException ("GyuFormat.Write not implemented");
|
||||
}
|
||||
|
||||
private IDictionary<int, uint> QueryScheme ()
|
||||
{
|
||||
if (0 == KnownKeys.Count)
|
||||
return null;
|
||||
if (1 == KnownKeys.Count)
|
||||
return KnownKeys.First().Value;
|
||||
var options = Query<GyuOptions> (arcStrings.GYUImageEncrypted);
|
||||
return options.Scheme;
|
||||
}
|
||||
|
||||
public override ResourceOptions GetDefaultOptions ()
|
||||
{
|
||||
return new GyuOptions { Scheme = GetScheme (Settings.Default.GYUTitle) };
|
||||
}
|
||||
|
||||
public override object GetAccessWidget ()
|
||||
{
|
||||
return new GUI.WidgetGYU();
|
||||
}
|
||||
|
||||
Dictionary<int, uint> GetScheme (string title)
|
||||
{
|
||||
Dictionary<int, uint> scheme = null;
|
||||
KnownKeys.TryGetValue (title, out scheme);
|
||||
return scheme;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class GyuReader
|
||||
@ -284,4 +345,9 @@ namespace GameRes.Formats.ExHibit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GyuOptions : ResourceOptions
|
||||
{
|
||||
public IDictionary<int, uint> Scheme;
|
||||
}
|
||||
}
|
||||
|
10
ArcFormats/ExHibit/WidgetGYU.xaml
Normal file
10
ArcFormats/ExHibit/WidgetGYU.xaml
Normal file
@ -0,0 +1,10 @@
|
||||
<StackPanel x:Class="GameRes.Formats.GUI.WidgetGYU"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:p="clr-namespace:GameRes.Formats.Properties"
|
||||
xmlns:ex="clr-namespace:GameRes.Formats.ExHibit">
|
||||
<ComboBox Name="Title" ItemsSource="{Binding Source={x:Static ex:GyuFormat.KnownKeys}, Mode=OneWay}"
|
||||
SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=GYUTitle, Mode=TwoWay}"
|
||||
SelectedValuePath="Key" DisplayMemberPath="Key"
|
||||
Width="200" Grid.Row="1" HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
15
ArcFormats/ExHibit/WidgetGYU.xaml.cs
Normal file
15
ArcFormats/ExHibit/WidgetGYU.xaml.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace GameRes.Formats.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WidgetGYU.xaml
|
||||
/// </summary>
|
||||
public partial class WidgetGYU : StackPanel
|
||||
{
|
||||
public WidgetGYU()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
12
ArcFormats/Properties/Settings.Designer.cs
generated
12
ArcFormats/Properties/Settings.Designer.cs
generated
@ -621,5 +621,17 @@ namespace GameRes.Formats.Properties {
|
||||
this["TacticsArcTitle"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string GYUTitle {
|
||||
get {
|
||||
return ((string)(this["GYUTitle"]));
|
||||
}
|
||||
set {
|
||||
this["GYUTitle"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,5 +152,8 @@
|
||||
<Setting Name="TacticsArcTitle" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="GYUTitle" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
12
ArcFormats/Strings/arcStrings.Designer.cs
generated
12
ArcFormats/Strings/arcStrings.Designer.cs
generated
@ -215,6 +215,16 @@ namespace GameRes.Formats.Strings {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Image is encrypted.
|
||||
///Choose appropriate encryption scheme..
|
||||
/// </summary>
|
||||
public static string GYUImageEncrypted {
|
||||
get {
|
||||
return ResourceManager.GetString("GYUImageEncrypted", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Choose game executable file.
|
||||
/// </summary>
|
||||
@ -415,7 +425,7 @@ namespace GameRes.Formats.Strings {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Calcualting checksum....
|
||||
/// Looks up a localized string similar to Calculating checksum....
|
||||
/// </summary>
|
||||
public static string MsgCalculatingChecksum {
|
||||
get {
|
||||
|
@ -375,4 +375,8 @@
|
||||
<data name="GALChoose" xml:space="preserve">
|
||||
<value>제목을 선택하거나 암호값 입력하기</value>
|
||||
</data>
|
||||
<data name="GYUImageEncrypted" xml:space="preserve">
|
||||
<value>이미지가 암호화됨.
|
||||
적절한 암호체계를 선택하세요.</value>
|
||||
</data>
|
||||
</root>
|
@ -179,7 +179,7 @@ Choose appropriate encryption scheme.</value>
|
||||
<value>Adding file</value>
|
||||
</data>
|
||||
<data name="MsgCalculatingChecksum" xml:space="preserve">
|
||||
<value>Calcualting checksum...</value>
|
||||
<value>Calculating checksum...</value>
|
||||
</data>
|
||||
<data name="MsgCompressingIndex" xml:space="preserve">
|
||||
<value>Compressing index...</value>
|
||||
@ -378,4 +378,8 @@ Choose appropriate encryption scheme.</value>
|
||||
<data name="GALChoose" xml:space="preserve">
|
||||
<value>Choose title or enter a key</value>
|
||||
</data>
|
||||
<data name="GYUImageEncrypted" xml:space="preserve">
|
||||
<value>Image is encrypted.
|
||||
Choose appropriate encryption scheme.</value>
|
||||
</data>
|
||||
</root>
|
@ -161,6 +161,10 @@
|
||||
<data name="GALChoose" xml:space="preserve">
|
||||
<value>Выберите наименование или введите ключ</value>
|
||||
</data>
|
||||
<data name="GYUImageEncrypted" xml:space="preserve">
|
||||
<value>Изображение зашифровано.
|
||||
Выберите способ шифрования.</value>
|
||||
</data>
|
||||
<data name="INTChooseExe" xml:space="preserve">
|
||||
<value>Выберите исполняемый файл</value>
|
||||
</data>
|
||||
|
@ -380,4 +380,8 @@ Choose appropriate encryption scheme.</value>
|
||||
<data name="GALChoose" xml:space="preserve">
|
||||
<value>请选择游戏名称或输入密钥</value>
|
||||
</data>
|
||||
<data name="GYUImageEncrypted" xml:space="preserve">
|
||||
<value>图像已加密。
|
||||
请选择正确的加密方式。</value>
|
||||
</data>
|
||||
</root>
|
@ -154,6 +154,9 @@
|
||||
<setting name="TacticsArcTitle" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="GYUTitle" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</GameRes.Formats.Properties.Settings>
|
||||
</userSettings>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
||||
|
@ -122,6 +122,7 @@ Happy Princess<br/>
|
||||
Idol ☆ Revolution<br/>
|
||||
Narimono<br/>
|
||||
Reconquista<br/>
|
||||
Switch!! ~Boku ga Natsu ni Omou Koto~<br/>
|
||||
White ~blanche comme la lune~<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.rct</td><td><tt>\x98\x5A\x92\x9AT</tt></td><td>Yes</td></tr>
|
||||
@ -295,6 +296,7 @@ Eien no Owari ni<br/>
|
||||
Fuurinkanzan<br/>
|
||||
Himemiko<br/>
|
||||
Ikusa Otome Valkyrie<br/>
|
||||
Mahou Tenshi Misaki<br/>
|
||||
Mahou Tenshi Misaki 2<br/>
|
||||
Ohime-sama wa Tokkun Chuu R! ~Seinaru Mahou Shugyou~<br/>
|
||||
Onsoku Hishou Sonic Mercedes<br/>
|
||||
@ -737,6 +739,7 @@ Moshimo Ashita ga Harenaraba<br/>
|
||||
<tr class="odd"><td>*.pga</td><td><tt>PGAPGAH</tt></td><td>Yes</td></tr>
|
||||
<tr class="odd"><td>*.chr</td><td><tt>char</tt></td><td>No</td></tr>
|
||||
<tr><td>*.gyu</td><td><tt>GYU\x1a</tt></td><td>No</td><td>ExHIBIT</td><td>
|
||||
Eve ~New Generation X~<br/>
|
||||
Fuyu no Rondo<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.dat</td><td>-</td><td>No</td><td>ACTGS</td><td>
|
||||
@ -775,6 +778,7 @@ Izumo 2<br/>
|
||||
Izumo 2 ~Gakuen Kyousoukyoku~<br/>
|
||||
Izumo 3<br/>
|
||||
Oni Kagura<br/>
|
||||
Tokino Senka<br/>
|
||||
Tsuki Kagura<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.pbx</td><td><tt>Pandora.box</tt></td><td>No</td><td>Terios</td><td>
|
||||
@ -1000,6 +1004,7 @@ Nukiani!! Sweet Home<br/>
|
||||
<tr class="odd"><td>*.arc</td><td><tt>ARCX</tt></td><td>No</td><td>Studio Jaren</td><td>
|
||||
Denpa no Dorei<br/>
|
||||
Soushinjutsu Plus<br/>
|
||||
Soushinjutsu 2<br/>
|
||||
</td></tr>
|
||||
<tr><td>*.ns2</td><td>-</td><td>No</td><td>NScripter</td><td>
|
||||
Rakuin Hime Runed Princess<br/>
|
||||
|
Loading…
Reference in New Issue
Block a user