initial commit
This commit is contained in:
commit
1b60743303
274 changed files with 25866 additions and 0 deletions
18
SEGATools/AssemblyGitBuildBranch.cs
Normal file
18
SEGATools/AssemblyGitBuildBranch.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.AssemblyGitBuildBranch
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly)]
|
||||
public class AssemblyGitBuildBranch : Attribute
|
||||
{
|
||||
public string GitBuildBranch { get; private set; }
|
||||
|
||||
public AssemblyGitBuildBranch(string txt) => this.GitBuildBranch = txt;
|
||||
}
|
||||
}
|
18
SEGATools/AssemblyGitBuildSHA1.cs
Normal file
18
SEGATools/AssemblyGitBuildSHA1.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.AssemblyGitBuildSHA1
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly)]
|
||||
public class AssemblyGitBuildSHA1 : Attribute
|
||||
{
|
||||
public string GitBuildSHA1 { get; private set; }
|
||||
|
||||
public AssemblyGitBuildSHA1(string txt) => this.GitBuildSHA1 = txt;
|
||||
}
|
||||
}
|
22
SEGATools/AssemblyInfo.cs
Normal file
22
SEGATools/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using SEGATools;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("CDI")]
|
||||
[assembly: InternalsVisibleTo("GDI")]
|
||||
[assembly: AssemblyCompany("Japanese Cake")]
|
||||
[assembly: AssemblyGitBuildBranch("release_1.6.3")]
|
||||
[assembly: InternalsVisibleTo("ISO9660")]
|
||||
[assembly: AssemblyProduct("SEGA Tools")]
|
||||
[assembly: AssemblyTitle("SEGA Tools")]
|
||||
[assembly: AssemblyDescription("SEGATools.dll")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: InternalsVisibleTo("BIN")]
|
||||
[assembly: ComVisible(true)]
|
||||
[assembly: AssemblyGitBuildSHA1("fd2eb45")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCopyright("2012-2016")]
|
||||
[assembly: Guid("c48aeffd-e41a-403e-9c32-f376d63a4ae2")]
|
||||
[assembly: AssemblyFileVersion("1.0.3")]
|
||||
[assembly: AssemblyVersion("1.0.3.0")]
|
12
SEGATools/AssemblyTest.cs
Normal file
12
SEGATools/AssemblyTest.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.AssemblyTest
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools
|
||||
{
|
||||
public class AssemblyTest
|
||||
{
|
||||
}
|
||||
}
|
44
SEGATools/Audio/AudioConversionSettings.cs
Normal file
44
SEGATools/Audio/AudioConversionSettings.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Audio.AudioConversionSettings
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.Audio
|
||||
{
|
||||
public class AudioConversionSettings
|
||||
{
|
||||
public bool RemovePause { get; private set; }
|
||||
|
||||
public short PauseDurationInSeconds => this.RemovePause ? (short) 2 : (short) 0;
|
||||
|
||||
public int SamplingRate { get; private set; }
|
||||
|
||||
public short BitsPerSample => 16;
|
||||
|
||||
public short NumberOfChannels { get; private set; }
|
||||
|
||||
private AudioConversionSettings(int SamplingRate, short NumberOfChannels, bool RemovePause)
|
||||
{
|
||||
this.SamplingRate = SamplingRate;
|
||||
this.NumberOfChannels = NumberOfChannels;
|
||||
this.RemovePause = RemovePause;
|
||||
}
|
||||
|
||||
public static AudioConversionSettings defaultAudioConvOptions() => new AudioConversionSettings(44100, (short) 2, false);
|
||||
|
||||
public static AudioConversionSettings newStereoPCMSettings(
|
||||
int SamplingRate,
|
||||
bool RemovePause)
|
||||
{
|
||||
return new AudioConversionSettings(SamplingRate, (short) 2, RemovePause);
|
||||
}
|
||||
|
||||
public static AudioConversionSettings newMonoPCMSettings(
|
||||
int SamplingRate,
|
||||
bool RemovePause)
|
||||
{
|
||||
return new AudioConversionSettings(SamplingRate, (short) 1, RemovePause);
|
||||
}
|
||||
}
|
||||
}
|
151
SEGATools/Audio/AudioConversionSettingsViewer.cs
Normal file
151
SEGATools/Audio/AudioConversionSettingsViewer.cs
Normal file
|
@ -0,0 +1,151 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Audio.AudioConversionSettingsViewer
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SEGATools.Audio
|
||||
{
|
||||
public class AudioConversionSettingsViewer : UserControl
|
||||
{
|
||||
private List<AudioConversionSettingsViewer.SamplingRateItem> samplingRates = new List<AudioConversionSettingsViewer.SamplingRateItem>();
|
||||
private IContainer components;
|
||||
private FlowLayoutPanel flowLayoutPanel;
|
||||
private Label lbSamplingRate;
|
||||
private ComboBox cbSamplingRate;
|
||||
private CheckBox cbRemovePause;
|
||||
|
||||
[RefreshProperties(RefreshProperties.Repaint)]
|
||||
[NotifyParentProperty(true)]
|
||||
[Category("Appearance")]
|
||||
[Description("Specifies whether the remove pause checkbox is visible.")]
|
||||
[DefaultValue(typeof (bool), "true")]
|
||||
public bool ShowRemovePause
|
||||
{
|
||||
get => this.cbRemovePause.Visible;
|
||||
set => this.cbRemovePause.Visible = value;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool RemovePause => this.cbRemovePause.Checked;
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
[Browsable(false)]
|
||||
public int SamplingRate => int.Parse(this.cbSamplingRate.SelectedItem.ToString());
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public AudioConversionSettings AudioConversionSettings
|
||||
{
|
||||
get => AudioConversionSettings.newStereoPCMSettings((int) this.cbSamplingRate.SelectedValue, this.cbRemovePause.Checked);
|
||||
set
|
||||
{
|
||||
this.cbSamplingRate.SelectedItem = (object) this.samplingRates.Find((Predicate<AudioConversionSettingsViewer.SamplingRateItem>) (samplingRate => samplingRate.Value == value.SamplingRate));
|
||||
this.cbRemovePause.Checked = value.RemovePause;
|
||||
}
|
||||
}
|
||||
|
||||
public AudioConversionSettingsViewer()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.samplingRates.Add(new AudioConversionSettingsViewer.SamplingRateItem(16000));
|
||||
this.samplingRates.Add(new AudioConversionSettingsViewer.SamplingRateItem(44100));
|
||||
this.samplingRates.Add(new AudioConversionSettingsViewer.SamplingRateItem(48000));
|
||||
this.cbSamplingRate.DataSource = (object) this.samplingRates;
|
||||
this.cbSamplingRate.DisplayMember = AudioConversionSettingsViewer.SamplingRateItem.DisplayMember;
|
||||
this.cbSamplingRate.ValueMember = AudioConversionSettingsViewer.SamplingRateItem.ValueMember;
|
||||
this.cbSamplingRate.SelectedItem = (object) this.samplingRates.Find((Predicate<AudioConversionSettingsViewer.SamplingRateItem>) (samplingRate => samplingRate.Value == 44100));
|
||||
this.cbSamplingRate.Enabled = false;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && this.components != null)
|
||||
this.components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.flowLayoutPanel = new FlowLayoutPanel();
|
||||
this.lbSamplingRate = new Label();
|
||||
this.cbSamplingRate = new ComboBox();
|
||||
this.cbRemovePause = new CheckBox();
|
||||
this.flowLayoutPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
this.flowLayoutPanel.AutoScroll = true;
|
||||
this.flowLayoutPanel.AutoSize = true;
|
||||
this.flowLayoutPanel.BackColor = Color.Transparent;
|
||||
this.flowLayoutPanel.Controls.Add((Control) this.lbSamplingRate);
|
||||
this.flowLayoutPanel.Controls.Add((Control) this.cbSamplingRate);
|
||||
this.flowLayoutPanel.Controls.Add((Control) this.cbRemovePause);
|
||||
this.flowLayoutPanel.Dock = DockStyle.Fill;
|
||||
this.flowLayoutPanel.Location = new Point(0, 0);
|
||||
this.flowLayoutPanel.Name = "flowLayoutPanel";
|
||||
this.flowLayoutPanel.Size = new Size(325, 28);
|
||||
this.flowLayoutPanel.TabIndex = 0;
|
||||
this.lbSamplingRate.AutoSize = true;
|
||||
this.lbSamplingRate.Location = new Point(3, 3);
|
||||
this.lbSamplingRate.Margin = new Padding(3);
|
||||
this.lbSamplingRate.Name = "lbSamplingRate";
|
||||
this.lbSamplingRate.Size = new Size(79, 13);
|
||||
this.lbSamplingRate.TabIndex = 9;
|
||||
this.lbSamplingRate.Text = "Sampling Rate:";
|
||||
this.lbSamplingRate.TextAlign = ContentAlignment.BottomLeft;
|
||||
this.cbSamplingRate.FormattingEnabled = true;
|
||||
this.cbSamplingRate.Items.AddRange(new object[2]
|
||||
{
|
||||
(object) "44100",
|
||||
(object) "48000"
|
||||
});
|
||||
this.cbSamplingRate.Location = new Point(85, 0);
|
||||
this.cbSamplingRate.Margin = new Padding(0);
|
||||
this.cbSamplingRate.Name = "cbSamplingRate";
|
||||
this.cbSamplingRate.Size = new Size(75, 21);
|
||||
this.cbSamplingRate.TabIndex = 10;
|
||||
this.cbRemovePause.AutoSize = true;
|
||||
this.cbRemovePause.CheckAlign = ContentAlignment.MiddleRight;
|
||||
this.cbRemovePause.Enabled = false;
|
||||
this.cbRemovePause.Location = new Point(163, 3);
|
||||
this.cbRemovePause.Name = "cbRemovePause";
|
||||
this.cbRemovePause.Size = new Size(150, 17);
|
||||
this.cbRemovePause.TabIndex = 11;
|
||||
this.cbRemovePause.Text = "Remove 2-seconds pause";
|
||||
this.cbRemovePause.UseVisualStyleBackColor = true;
|
||||
this.AutoScaleDimensions = new SizeF(6f, 13f);
|
||||
this.AutoScaleMode = AutoScaleMode.Font;
|
||||
this.BackColor = Color.Transparent;
|
||||
this.Controls.Add((Control) this.flowLayoutPanel);
|
||||
this.Name = nameof (AudioConversionSettingsViewer);
|
||||
this.Size = new Size(325, 28);
|
||||
this.flowLayoutPanel.ResumeLayout(false);
|
||||
this.flowLayoutPanel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
|
||||
internal sealed class SamplingRateItem
|
||||
{
|
||||
public static string DisplayMember => "Name";
|
||||
|
||||
public static string ValueMember => "Value";
|
||||
|
||||
public int Value { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public SamplingRateItem(int SamplingRate)
|
||||
{
|
||||
this.Name = SamplingRate.ToString() + "Hz";
|
||||
this.Value = SamplingRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SEGATools/Audio/AudioConversionSettingsViewer.resx
Normal file
120
SEGATools/Audio/AudioConversionSettingsViewer.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
98
SEGATools/Audio/CanonicalWaveHeader.cs
Normal file
98
SEGATools/Audio/CanonicalWaveHeader.cs
Normal file
|
@ -0,0 +1,98 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Audio.CanonicalWaveHeader
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Audio
|
||||
{
|
||||
internal class CanonicalWaveHeader
|
||||
{
|
||||
private const short HEADERSIZE = 44;
|
||||
private const int _chunkID = 1179011410;
|
||||
private const int _remainingSize = 20;
|
||||
private const int _format = 1163280727;
|
||||
private const int _subChunk1ID = 544501094;
|
||||
private const int _subChunk1Size = 16;
|
||||
private const short _audioFormat = 1;
|
||||
private const int _subChunk2ID = 1635017060;
|
||||
private int _subChunk2Size;
|
||||
private bool sampleDataInitialized;
|
||||
|
||||
public short Size => 44;
|
||||
|
||||
public int ChunkID => 1179011410;
|
||||
|
||||
public int ChunkSize => 36 + this.SubChunk2Size;
|
||||
|
||||
public int Format => 1163280727;
|
||||
|
||||
public int SubChunk1ID => 544501094;
|
||||
|
||||
public int SubChunk1Size => 16;
|
||||
|
||||
public short AudioFormat => 1;
|
||||
|
||||
public short NumberOfChannels { get; private set; }
|
||||
|
||||
public int SampleRate { get; private set; }
|
||||
|
||||
public int ByteRate => this.SampleRate * (int) this.NumberOfChannels * ((int) this.BitsPerSample / 8);
|
||||
|
||||
public short BlockAlign => (short) ((int) this.NumberOfChannels * ((int) this.BitsPerSample / 8));
|
||||
|
||||
public short BitsPerSample { get; private set; }
|
||||
|
||||
public int SubChunk2ID => 1635017060;
|
||||
|
||||
public int SubChunk2Size
|
||||
{
|
||||
get => this._subChunk2Size;
|
||||
set
|
||||
{
|
||||
this._subChunk2Size = value;
|
||||
this.sampleDataInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public CanonicalWaveHeader(
|
||||
short numberOfChannels,
|
||||
int sampleRate,
|
||||
short bitsPerSample,
|
||||
int? sampleDataSize)
|
||||
{
|
||||
this.NumberOfChannels = numberOfChannels;
|
||||
this.SampleRate = sampleRate;
|
||||
this.BitsPerSample = bitsPerSample;
|
||||
if (!sampleDataSize.HasValue)
|
||||
return;
|
||||
this.sampleDataInitialized = true;
|
||||
this.SubChunk2Size = sampleDataSize.Value;
|
||||
}
|
||||
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
if (!this.sampleDataInitialized)
|
||||
throw new UninitialiedSampleDataSizeException("Sample data size (SubChunk2Size property) has not been initialied.");
|
||||
byte[] numArray = new byte[44];
|
||||
BitConverter.GetBytes(this.ChunkID).CopyTo((Array) numArray, 0);
|
||||
BitConverter.GetBytes(this.ChunkSize).CopyTo((Array) numArray, 4);
|
||||
BitConverter.GetBytes(this.Format).CopyTo((Array) numArray, 8);
|
||||
BitConverter.GetBytes(this.SubChunk1ID).CopyTo((Array) numArray, 12);
|
||||
BitConverter.GetBytes(this.SubChunk1Size).CopyTo((Array) numArray, 16);
|
||||
BitConverter.GetBytes(this.AudioFormat).CopyTo((Array) numArray, 20);
|
||||
BitConverter.GetBytes(this.NumberOfChannels).CopyTo((Array) numArray, 22);
|
||||
BitConverter.GetBytes(this.SampleRate).CopyTo((Array) numArray, 24);
|
||||
BitConverter.GetBytes(this.ByteRate).CopyTo((Array) numArray, 28);
|
||||
BitConverter.GetBytes(this.BlockAlign).CopyTo((Array) numArray, 32);
|
||||
BitConverter.GetBytes(this.BitsPerSample).CopyTo((Array) numArray, 34);
|
||||
BitConverter.GetBytes(this.SubChunk2ID).CopyTo((Array) numArray, 36);
|
||||
BitConverter.GetBytes(this.SubChunk2Size).CopyTo((Array) numArray, 40);
|
||||
return numArray;
|
||||
}
|
||||
|
||||
public static CanonicalWaveHeader FromByteArray(byte[] headerArray) => new CanonicalWaveHeader(BitConverter.ToInt16(headerArray, 22), BitConverter.ToInt32(headerArray, 24), BitConverter.ToInt16(headerArray, 34), new int?(BitConverter.ToInt32(headerArray, 40)));
|
||||
}
|
||||
}
|
142
SEGATools/Audio/Raw2WavConverter.cs
Normal file
142
SEGATools/Audio/Raw2WavConverter.cs
Normal file
|
@ -0,0 +1,142 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Audio.Raw2WavConverter
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.UserProcess;
|
||||
using SEGATools.VirtualFile;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
|
||||
namespace SEGATools.Audio
|
||||
{
|
||||
public class Raw2WavConverter : UserProcessBase
|
||||
{
|
||||
private static readonly int BUFFER_SIZE = 524288;
|
||||
|
||||
public AudioConversionSettings AudioConversionSettings { get; set; }
|
||||
|
||||
public event AsyncOperationProgressChangedEventHandler ConversionProgressChanged
|
||||
{
|
||||
add => this.AsyncOperationProgressChanged += value;
|
||||
remove => this.AsyncOperationProgressChanged -= value;
|
||||
}
|
||||
|
||||
public event AsyncOperationCompletedEventHandler ConversionCompleted
|
||||
{
|
||||
add => this.AsyncOperationCompleted += value;
|
||||
remove => this.AsyncOperationCompleted -= value;
|
||||
}
|
||||
|
||||
public Raw2WavConverter() => this.AudioConversionSettings = AudioConversionSettings.defaultAudioConvOptions();
|
||||
|
||||
public Raw2WavConverter(IContainer container)
|
||||
: base(container)
|
||||
=> this.AudioConversionSettings = AudioConversionSettings.defaultAudioConvOptions();
|
||||
|
||||
public void ConvertAsync(IList<IVirtualFile> InputFiles, string outputPath, object taskId)
|
||||
{
|
||||
AsyncOperation asyncOperation = this.CreateAsyncOperation(taskId);
|
||||
new Raw2WavConverter.WorkerEventHandler(this.ConvertRaw2WavWorker).BeginInvoke(InputFiles, outputPath, asyncOperation, (AsyncCallback) null, (object) null);
|
||||
}
|
||||
|
||||
private void ConvertRaw2WavWorker(
|
||||
IList<IVirtualFile> inputFiles,
|
||||
string outputPath,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
long TotalNumberOfBytesToWrite = 0;
|
||||
Exception exception = (Exception) null;
|
||||
foreach (IVirtualFile inputFile in (IEnumerable<IVirtualFile>) inputFiles)
|
||||
TotalNumberOfBytesToWrite += this.ComputeAudioStreamLength(inputFile.FileInputStream, this.AudioConversionSettings.PauseDurationInSeconds);
|
||||
long TotalNumberOfBytesRemainingToWrite = TotalNumberOfBytesToWrite;
|
||||
try
|
||||
{
|
||||
foreach (IVirtualFile inputFile in (IEnumerable<IVirtualFile>) inputFiles)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
{
|
||||
IVirtualFile OutputFile = inputFiles.Count != 1 ? (IVirtualFile) VirtualFileFactory.createVirtualFile(Path.Combine(outputPath, Path.GetFileName(Path.ChangeExtension(inputFile.VirtualName, ".wav")))) : (IVirtualFile) VirtualFileFactory.createVirtualFile(outputPath);
|
||||
TotalNumberOfBytesRemainingToWrite = this.ConvertStream(inputFile, OutputFile, TotalNumberOfBytesRemainingToWrite, TotalNumberOfBytesToWrite, asyncOp);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
}
|
||||
this.ReportCompletion(outputPath, exception, asyncOp);
|
||||
}
|
||||
|
||||
private long ComputeAudioStreamLength(System.IO.Stream AudioStream, short NumberOfSecondToSubtrack) => AudioStream.Length - (long) ((int) this.AudioConversionSettings.NumberOfChannels * this.AudioConversionSettings.SamplingRate * ((int) this.AudioConversionSettings.BitsPerSample / 8) * (int) NumberOfSecondToSubtrack);
|
||||
|
||||
private void GenerateWaveHeader(
|
||||
BinaryReader InputFileReader,
|
||||
BinaryWriter OutputFileWriter,
|
||||
out long BytesToWrite)
|
||||
{
|
||||
BytesToWrite = this.ComputeAudioStreamLength(InputFileReader.BaseStream, this.AudioConversionSettings.PauseDurationInSeconds);
|
||||
CanonicalWaveHeader canonicalWaveHeader = new CanonicalWaveHeader(this.AudioConversionSettings.NumberOfChannels, this.AudioConversionSettings.SamplingRate, this.AudioConversionSettings.BitsPerSample, new int?((int) BytesToWrite));
|
||||
OutputFileWriter.Write(canonicalWaveHeader.ToByteArray());
|
||||
}
|
||||
|
||||
private long ConvertStream(
|
||||
IVirtualFile InputFile,
|
||||
IVirtualFile OutputFile,
|
||||
long TotalNumberOfBytesRemainingToWrite,
|
||||
long TotalNumberOfBytesToWrite,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
long num = 0;
|
||||
long BytesToWrite = 0;
|
||||
using (BinaryReader InputFileReader = new BinaryReader(InputFile.FileInputStream))
|
||||
{
|
||||
using (BinaryWriter OutputFileWriter = new BinaryWriter(OutputFile.FileOutputStream))
|
||||
{
|
||||
this.GenerateWaveHeader(InputFileReader, OutputFileWriter, out BytesToWrite);
|
||||
num = BytesToWrite;
|
||||
while (num > 0L)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
{
|
||||
byte[] buffer = num <= (long) Raw2WavConverter.BUFFER_SIZE ? InputFileReader.ReadBytes((int) num) : InputFileReader.ReadBytes(Raw2WavConverter.BUFFER_SIZE);
|
||||
OutputFileWriter.Write(buffer);
|
||||
num -= (long) buffer.Length;
|
||||
TotalNumberOfBytesRemainingToWrite -= (long) buffer.Length;
|
||||
int progressPercentage = (int) ((double) (BytesToWrite - num) / (double) BytesToWrite * 100.0);
|
||||
int totalProgressPercentage = (int) ((double) (TotalNumberOfBytesToWrite - TotalNumberOfBytesRemainingToWrite) / (double) TotalNumberOfBytesToWrite * 100.0);
|
||||
this.ReportProgress(new UserProcessProgressChangedEventArgs(InputFile.VirtualName, OutputFile.OriginalFileName, progressPercentage, totalProgressPercentage, asyncOp.UserSuppliedState), asyncOp);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num == 0L)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
goto label_16;
|
||||
}
|
||||
try
|
||||
{
|
||||
File.Delete(OutputFile.OriginalFileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UserProcessBase.logger.ErrorFormat("Unable to delete the file {0}: {1}", (object) OutputFile, (object) ex.Message);
|
||||
}
|
||||
label_16:
|
||||
return TotalNumberOfBytesRemainingToWrite;
|
||||
}
|
||||
|
||||
private delegate void WorkerEventHandler(
|
||||
IList<IVirtualFile> InputFiles,
|
||||
string OutputPath,
|
||||
AsyncOperation asyncOp);
|
||||
}
|
||||
}
|
18
SEGATools/Audio/UninitialiedSampleDataSizeException.cs
Normal file
18
SEGATools/Audio/UninitialiedSampleDataSizeException.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Audio.UninitialiedSampleDataSizeException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Audio
|
||||
{
|
||||
internal class UninitialiedSampleDataSizeException : Exception
|
||||
{
|
||||
public UninitialiedSampleDataSizeException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
43
SEGATools/Binary/BinaryPatch.cs
Normal file
43
SEGATools/Binary/BinaryPatch.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Binary.BinaryPatch
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace SEGATools.Binary
|
||||
{
|
||||
public class BinaryPatch
|
||||
{
|
||||
private static readonly System.Security.Cryptography.HashAlgorithm HashAlgorithm = (System.Security.Cryptography.HashAlgorithm) SHA1.Create();
|
||||
|
||||
public long Offset { get; private set; }
|
||||
|
||||
public byte[] Data { get; private set; }
|
||||
|
||||
public string Hash { get; private set; }
|
||||
|
||||
internal BinaryPatch(long offset, byte[] data)
|
||||
{
|
||||
this.Offset = offset;
|
||||
this.Data = data;
|
||||
this.Hash = BitConverter.ToString(BinaryPatch.HashAlgorithm.ComputeHash(data));
|
||||
}
|
||||
|
||||
public BinaryPatch Translate(long OffsetDelta) => new BinaryPatch(this.Offset + OffsetDelta, this.Data);
|
||||
|
||||
public override string ToString() => string.Format("BinaryPatch [Offset=0x{0:X}, Hash=0x{1}]", (object) this.Offset, (object) this.Hash);
|
||||
|
||||
public override int GetHashCode() => 1 + 17 * this.Offset.GetHashCode() + 31 * this.Hash.GetHashCode();
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || this.GetType() != obj.GetType())
|
||||
return false;
|
||||
BinaryPatch binaryPatch = (BinaryPatch) obj;
|
||||
return this.Offset == binaryPatch.Offset && this.Hash.Equals(binaryPatch.Hash);
|
||||
}
|
||||
}
|
||||
}
|
37
SEGATools/Binary/BinaryPatcher.cs
Normal file
37
SEGATools/Binary/BinaryPatcher.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Binary.BinaryPatcher
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.UserProcess;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
|
||||
namespace SEGATools.Binary
|
||||
{
|
||||
public class BinaryPatcher : UserProcessBase
|
||||
{
|
||||
public BinaryPatcher()
|
||||
{
|
||||
}
|
||||
|
||||
public BinaryPatcher(IContainer container)
|
||||
: base(container)
|
||||
{
|
||||
}
|
||||
|
||||
public void ApplyPatch(System.IO.Stream stream, BinaryPatch Patch)
|
||||
{
|
||||
UserProcessBase.logger.DebugFormat("Applying {0}", (object) Patch);
|
||||
stream.Seek(Patch.Offset, SeekOrigin.Begin);
|
||||
stream.Write(Patch.Data, 0, Patch.Data.Length);
|
||||
}
|
||||
|
||||
public void ApplyPatches(System.IO.Stream stream, BinaryPatch[] Patches)
|
||||
{
|
||||
foreach (BinaryPatch patch in Patches)
|
||||
this.ApplyPatch(stream, patch);
|
||||
}
|
||||
}
|
||||
}
|
170
SEGATools/Binary/InitialProgramPatches.cs
Normal file
170
SEGATools/Binary/InitialProgramPatches.cs
Normal file
|
@ -0,0 +1,170 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Binary.InitialProgramPatches
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
|
||||
namespace SEGATools.Binary
|
||||
{
|
||||
public class InitialProgramPatches
|
||||
{
|
||||
private static int IP0000_REPEATED_TIME = 16;
|
||||
|
||||
public static BinaryPatch[] RegionFreePatchesForTrack1
|
||||
{
|
||||
get
|
||||
{
|
||||
BinaryPatch[] binaryPatchArray = new BinaryPatch[InitialProgramPatches.IP0000_REPEATED_TIME];
|
||||
for (int index = 0; index < binaryPatchArray.Length; ++index)
|
||||
binaryPatchArray[index] = InitialProgramPatches.RegionFreeFlagsPatch.Translate((long) (index * DiscSectorCommon.LogicalSectorSize));
|
||||
return binaryPatchArray;
|
||||
}
|
||||
}
|
||||
|
||||
public static BinaryPatch[] RegionFreePatchesForTrack3 => new BinaryPatch[4]
|
||||
{
|
||||
InitialProgramPatches.RegionFreeFlagsPatch,
|
||||
InitialProgramPatches.RegionJapanAreaProtectionSymbolsPatch,
|
||||
InitialProgramPatches.RegionUsaAreaProtectionSymbolsPatch,
|
||||
InitialProgramPatches.RegionEuropeAreaProtectionSymbolsPatch
|
||||
};
|
||||
|
||||
public static BinaryPatch[] VGAFlagPatchesForTrack1
|
||||
{
|
||||
get
|
||||
{
|
||||
BinaryPatch[] binaryPatchArray = new BinaryPatch[InitialProgramPatches.IP0000_REPEATED_TIME];
|
||||
for (int index = 0; index < binaryPatchArray.Length; ++index)
|
||||
binaryPatchArray[index] = InitialProgramPatches.VGAFlagPatch.Translate((long) (index * DiscSectorCommon.LogicalSectorSize));
|
||||
return binaryPatchArray;
|
||||
}
|
||||
}
|
||||
|
||||
public static BinaryPatch[] VGAFlagPatchesForTrack3 => new BinaryPatch[1]
|
||||
{
|
||||
InitialProgramPatches.VGAFlagPatch
|
||||
};
|
||||
|
||||
public static BinaryPatch VGAFlagPatch => new BinaryPatch(61L, new byte[1]
|
||||
{
|
||||
(byte) 49
|
||||
});
|
||||
|
||||
public static BinaryPatch RegionFreeFlagsPatch => new BinaryPatch(48L, new byte[3]
|
||||
{
|
||||
(byte) 74,
|
||||
(byte) 85,
|
||||
(byte) 69
|
||||
});
|
||||
|
||||
public static BinaryPatch RegionJapanAreaProtectionSymbolsPatch => new BinaryPatch(14080L, new byte[32]
|
||||
{
|
||||
(byte) 14,
|
||||
(byte) 160,
|
||||
(byte) 9,
|
||||
(byte) 0,
|
||||
(byte) 70,
|
||||
(byte) 111,
|
||||
(byte) 114,
|
||||
(byte) 32,
|
||||
(byte) 74,
|
||||
(byte) 65,
|
||||
(byte) 80,
|
||||
(byte) 65,
|
||||
(byte) 78,
|
||||
(byte) 44,
|
||||
(byte) 84,
|
||||
(byte) 65,
|
||||
(byte) 73,
|
||||
(byte) 87,
|
||||
(byte) 65,
|
||||
(byte) 78,
|
||||
(byte) 44,
|
||||
(byte) 80,
|
||||
(byte) 72,
|
||||
(byte) 73,
|
||||
(byte) 76,
|
||||
(byte) 73,
|
||||
(byte) 80,
|
||||
(byte) 73,
|
||||
(byte) 78,
|
||||
(byte) 69,
|
||||
(byte) 83,
|
||||
(byte) 46
|
||||
});
|
||||
|
||||
public static BinaryPatch RegionUsaAreaProtectionSymbolsPatch => new BinaryPatch(14112L, new byte[32]
|
||||
{
|
||||
(byte) 14,
|
||||
(byte) 160,
|
||||
(byte) 9,
|
||||
(byte) 0,
|
||||
(byte) 70,
|
||||
(byte) 111,
|
||||
(byte) 114,
|
||||
(byte) 32,
|
||||
(byte) 85,
|
||||
(byte) 83,
|
||||
(byte) 65,
|
||||
(byte) 32,
|
||||
(byte) 97,
|
||||
(byte) 110,
|
||||
(byte) 100,
|
||||
(byte) 32,
|
||||
(byte) 67,
|
||||
(byte) 65,
|
||||
(byte) 78,
|
||||
(byte) 65,
|
||||
(byte) 68,
|
||||
(byte) 65,
|
||||
(byte) 46,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32
|
||||
});
|
||||
|
||||
public static BinaryPatch RegionEuropeAreaProtectionSymbolsPatch => new BinaryPatch(14144L, new byte[32]
|
||||
{
|
||||
(byte) 14,
|
||||
(byte) 160,
|
||||
(byte) 9,
|
||||
(byte) 0,
|
||||
(byte) 70,
|
||||
(byte) 111,
|
||||
(byte) 114,
|
||||
(byte) 32,
|
||||
(byte) 69,
|
||||
(byte) 85,
|
||||
(byte) 82,
|
||||
(byte) 79,
|
||||
(byte) 80,
|
||||
(byte) 69,
|
||||
(byte) 46,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32,
|
||||
(byte) 32
|
||||
});
|
||||
}
|
||||
}
|
59
SEGATools/Binary/SEGALibrary.cs
Normal file
59
SEGATools/Binary/SEGALibrary.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Binary.SEGALibrary
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Binary
|
||||
{
|
||||
public class SEGALibrary
|
||||
{
|
||||
public static readonly SEGALibrary AIP_103 = new SEGALibrary("AIP", new SEGALibraryVersion("1", "03"));
|
||||
public static readonly SEGALibrary AIPf_105 = new SEGALibrary("AIPf", new SEGALibraryVersion("1", "05"));
|
||||
public static readonly SEGALibrary SYTMR_053 = new SEGALibrary("syTmr", new SEGALibraryVersion("0", "53"));
|
||||
public static readonly SEGALibrary FMMNG_103 = new SEGALibrary("fmMng", new SEGALibraryVersion("1", "03"));
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public SEGALibraryVersion Version { get; private set; }
|
||||
|
||||
public DateTime BuildDate { get; private set; }
|
||||
|
||||
public SEGALibraryType GetLibraryType() => SEGALibrary.GetTypeFromName(this.Name);
|
||||
|
||||
public SEGALibrary(string Name, SEGALibraryVersion Version)
|
||||
: this(Name, Version, new DateTime())
|
||||
{
|
||||
}
|
||||
|
||||
public SEGALibrary(string Name, SEGALibraryVersion Version, DateTime BuildOn)
|
||||
{
|
||||
this.Name = Name;
|
||||
this.Version = Version;
|
||||
this.BuildDate = BuildOn;
|
||||
}
|
||||
|
||||
public override string ToString() => string.Format("[{0} v{1} build: {2}]", (object) this.Name, (object) this.Version, (object) this.BuildDate);
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || this.GetType() != obj.GetType())
|
||||
return false;
|
||||
SEGALibrary segaLibrary = (SEGALibrary) obj;
|
||||
return this.GetLibraryType() == segaLibrary.GetLibraryType() && this.Version.Equals((object) segaLibrary.Version);
|
||||
}
|
||||
|
||||
public override int GetHashCode() => 1 + 17 * this.Name.GetHashCode() + 31 * this.Version.GetHashCode();
|
||||
|
||||
private static SEGALibraryType GetTypeFromName(string Name)
|
||||
{
|
||||
if (SEGALibrary.AIP_103.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase) || SEGALibrary.AIPf_105.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return SEGALibraryType.AIP;
|
||||
if (SEGALibrary.SYTMR_053.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return SEGALibraryType.SYS_TIMER;
|
||||
return SEGALibrary.FMMNG_103.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase) ? SEGALibraryType.FLASH_MEMORY_MANAGER : SEGALibraryType.UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
16
SEGATools/Binary/SEGALibraryType.cs
Normal file
16
SEGATools/Binary/SEGALibraryType.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Binary.SEGALibraryType
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.Binary
|
||||
{
|
||||
public enum SEGALibraryType
|
||||
{
|
||||
UNKNOWN,
|
||||
AIP,
|
||||
SYS_TIMER,
|
||||
FLASH_MEMORY_MANAGER,
|
||||
}
|
||||
}
|
35
SEGATools/Binary/SEGALibraryVersion.cs
Normal file
35
SEGATools/Binary/SEGALibraryVersion.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Binary.SEGALibraryVersion
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Binary
|
||||
{
|
||||
public class SEGALibraryVersion : IComparable<SEGALibraryVersion>
|
||||
{
|
||||
public string Major { get; private set; }
|
||||
|
||||
public string Minor { get; private set; }
|
||||
|
||||
public SEGALibraryVersion(string major, string minor)
|
||||
{
|
||||
this.Major = major;
|
||||
this.Minor = minor;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) => obj != null && this.GetType() == obj.GetType() && this.CompareTo((SEGALibraryVersion) obj) == 0;
|
||||
|
||||
public override string ToString() => string.Format("{0}.{1}", (object) this.Major, (object) this.Minor);
|
||||
|
||||
public override int GetHashCode() => 1 + 17 * this.Major.GetHashCode() + 31 * this.Minor.GetHashCode();
|
||||
|
||||
public int CompareTo(SEGALibraryVersion other)
|
||||
{
|
||||
int num = this.Major.CompareTo(other.Major);
|
||||
return num != 0 ? num : this.Minor.CompareTo(other.Minor);
|
||||
}
|
||||
}
|
||||
}
|
63
SEGATools/CueSheet/CueSheetCreator.cs
Normal file
63
SEGATools/CueSheet/CueSheetCreator.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.CueSheet.CueSheetCreator
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
using SEGATools.DiscFileSystem;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace SEGATools.CueSheet
|
||||
{
|
||||
public class CueSheetCreator
|
||||
{
|
||||
public static void CreateFromDiscSession(IDiscSession session, string FileName, string Title)
|
||||
{
|
||||
using (StreamWriter streamWriter = new StreamWriter(FileName))
|
||||
{
|
||||
streamWriter.WriteLine(string.Format("TITLE \"{0}\"\n", (object) Title.ToUpper()));
|
||||
if (session.Tracks.Count == 0)
|
||||
return;
|
||||
foreach (IDiscTrack track1 in session.Tracks)
|
||||
{
|
||||
IDiscTrack Track = track1;
|
||||
streamWriter.WriteLine(string.Format("FILE \"{0}\" BINARY", (object) Path.GetFileName(Track.FileName)));
|
||||
streamWriter.WriteLine(string.Format("TRACK {0:00} {1}", (object) Track.Index, (object) CueSheetCreator.GetCueSheetTrackModeFromTrack(Track)));
|
||||
if (Track == session.Tracks[0])
|
||||
streamWriter.WriteLine("PREGAP " + CueSheetCreator.LogicalBlockAddressToMmSsFf(Track.LogicalBlockAddress));
|
||||
streamWriter.WriteLine("INDEX 01 00:00:00");
|
||||
if (!CueSheetCreator.IsTheLastTrack(Track, session) && CueSheetCreator.IsPostGapRequired(Track, session.Tracks.First<IDiscTrack>((Func<IDiscTrack, bool>) (track => track.Index == Track.Index + 1))))
|
||||
streamWriter.WriteLine("POSTGAP 00:02:00");
|
||||
streamWriter.WriteLine("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string LogicalBlockAddressToMmSsFf(uint lba)
|
||||
{
|
||||
uint num1 = lba / 75U;
|
||||
uint num2 = num1 / 60U;
|
||||
uint num3 = num1 % 60U;
|
||||
uint num4 = lba - (uint) (((int) num2 * 60 + (int) num3) * 75);
|
||||
return string.Format("{0:00}:{1:00}:{2:00}", (object) num2, (object) num3, (object) num4);
|
||||
}
|
||||
|
||||
private static string GetCueSheetTrackModeFromTrack(IDiscTrack Track)
|
||||
{
|
||||
if (Track.TrackData == TrackModeType.Audio)
|
||||
return "AUDIO";
|
||||
if (Track.TrackSector is ISO9660Sector)
|
||||
return "MODE1/2048";
|
||||
if (Track.TrackSector is CDROMMode1RawSector)
|
||||
return "MODE1/2352";
|
||||
throw new FormatException(string.Format("Not supported track mode for {0}", (object) Track));
|
||||
}
|
||||
|
||||
private static bool IsTheLastTrack(IDiscTrack Track, IDiscSession Session) => Track.Index == Session.Tracks[Session.Tracks.Count - 1].Index;
|
||||
|
||||
private static bool IsPostGapRequired(IDiscTrack FirstTrack, IDiscTrack SecondTrack) => FirstTrack.Index + 1 == SecondTrack.Index && FirstTrack.TrackData != SecondTrack.TrackData;
|
||||
}
|
||||
}
|
347
SEGATools/Disc/DiscExtractor.cs
Normal file
347
SEGATools/Disc/DiscExtractor.cs
Normal file
|
@ -0,0 +1,347 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Disc.DiscExtractor
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.ISO9660.DirectoryRecords;
|
||||
using ImageReader.Stream;
|
||||
using SEGATools.DiscFileSystem;
|
||||
using SEGATools.Security;
|
||||
using SEGATools.UserProcess;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace SEGATools.Disc
|
||||
{
|
||||
public class DiscExtractor : UserProcessBase
|
||||
{
|
||||
private static readonly int OutputFileStreamBuffer = 524288;
|
||||
|
||||
public event AsyncOperationProgressChangedEventHandler ExtractionProgressChanged
|
||||
{
|
||||
add => this.AsyncOperationProgressChanged += value;
|
||||
remove => this.AsyncOperationProgressChanged -= value;
|
||||
}
|
||||
|
||||
public event AsyncOperationCompletedEventHandler ExtractionCompleted
|
||||
{
|
||||
add => this.AsyncOperationCompleted += value;
|
||||
remove => this.AsyncOperationCompleted -= value;
|
||||
}
|
||||
|
||||
public IDiscFileSystem DiscFileSystem { get; set; }
|
||||
|
||||
public DiscExtractor()
|
||||
{
|
||||
}
|
||||
|
||||
public DiscExtractor(IContainer container)
|
||||
: base(container)
|
||||
{
|
||||
}
|
||||
|
||||
public void ExtractPathsAsync(
|
||||
List<DirectoryRecord> directoryRecords,
|
||||
string outputPath,
|
||||
object taskId)
|
||||
{
|
||||
this.ExtractPathsAsync(directoryRecords, outputPath, (SendOrPostCallback) null, taskId);
|
||||
}
|
||||
|
||||
public void ExtractDirectoryRecordsAsync(
|
||||
DirectoryRecord directoryRecord,
|
||||
string outputPath,
|
||||
object taskId)
|
||||
{
|
||||
this.ExtractPathsAsync(directoryRecord, outputPath, (SendOrPostCallback) null, taskId);
|
||||
}
|
||||
|
||||
public void ExtractDiscTracksAsync(IDiscTrack track, string outputFileName, object taskId) => this.ExtractDiscTracksAsync(new List<IDiscTrack>()
|
||||
{
|
||||
track
|
||||
}, outputFileName, taskId);
|
||||
|
||||
public void ExtractBootStrap(InitialProgram ip, string outputFilename)
|
||||
{
|
||||
if (ip == null)
|
||||
throw new ArgumentNullException(nameof (ip));
|
||||
if (string.IsNullOrEmpty(outputFilename))
|
||||
throw new ArgumentNullException(nameof (outputFilename));
|
||||
using (System.IO.Stream stream = ip.Stream)
|
||||
{
|
||||
byte[] buffer = new byte[stream.Length];
|
||||
using (FileStream fileStream = new FileStream(outputFilename, FileMode.OpenOrCreate))
|
||||
{
|
||||
stream.Read(buffer, 0, buffer.Length);
|
||||
fileStream.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtractPathsAsync(
|
||||
DirectoryRecord directoryRecord,
|
||||
string outputPath,
|
||||
SendOrPostCallback callBack,
|
||||
object taskId)
|
||||
{
|
||||
this.ExtractPathsAsync(new List<DirectoryRecord>()
|
||||
{
|
||||
directoryRecord
|
||||
}, outputPath, callBack, taskId);
|
||||
}
|
||||
|
||||
private void ExtractPathsAsync(
|
||||
List<DirectoryRecord> directoryRecords,
|
||||
string outputPath,
|
||||
SendOrPostCallback callBack,
|
||||
object taskId)
|
||||
{
|
||||
AsyncOperation asyncOperation = this.CreateAsyncOperation(taskId);
|
||||
new DiscExtractor.FileExtractorWorkerEventHandler(this.FileExtractorWorker).BeginInvoke(directoryRecords, outputPath, asyncOperation, (AsyncCallback) null, (object) null);
|
||||
}
|
||||
|
||||
private void ExtractDiscTracksAsync(List<IDiscTrack> tracks, string outputPath, object taskId)
|
||||
{
|
||||
AsyncOperation asyncOperation = this.CreateAsyncOperation(taskId);
|
||||
new DiscExtractor.TrackExtractorWorkerEventHandler(this.TrackExtractorWorker).BeginInvoke(tracks, outputPath, asyncOperation, (AsyncCallback) null, (object) null);
|
||||
}
|
||||
|
||||
private void FileExtractorWorker(
|
||||
List<DirectoryRecord> directoryRecords,
|
||||
string outputPath,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
string lastFileName = string.Empty;
|
||||
string Filename = string.Empty;
|
||||
Exception exception = (Exception) null;
|
||||
long num1 = 0;
|
||||
List<DirectoryRecord> source = new List<DirectoryRecord>();
|
||||
foreach (DirectoryRecord directoryRecord in directoryRecords)
|
||||
{
|
||||
num1 += (long) directoryRecord.UsedSpace;
|
||||
source.Add(directoryRecord);
|
||||
source.AddRange((IEnumerable<DirectoryRecord>) directoryRecord.GetAllSubDirectories());
|
||||
}
|
||||
List<DirectoryRecord> list = source.Distinct<DirectoryRecord>().ToList<DirectoryRecord>();
|
||||
long num2 = num1;
|
||||
string commonPathPrefix = DirectoryRecord.FindCommonPathPrefix(directoryRecords);
|
||||
UserProcessBase.logger.DebugFormat("The longest path prefix for all {0} files is {1}", (object) list.Count, (object) commonPathPrefix);
|
||||
try
|
||||
{
|
||||
this.CheckForEnoughFreeDiscSpace(num1, outputPath);
|
||||
foreach (DirectoryRecord directoryRecord in list)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
{
|
||||
Filename = directoryRecord.FullPath;
|
||||
string str1;
|
||||
if (list.Count == 1 && !directoryRecord.IsDirectory)
|
||||
{
|
||||
str1 = outputPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!directoryRecord.FullPath.StartsWith(commonPathPrefix))
|
||||
throw new DiscExtractorException(string.Format("The path \"{0}\" was expected to have the prefix \"{1}\"", (object) directoryRecord.FullPath, (object) commonPathPrefix));
|
||||
string str2 = directoryRecord.FullPath.Remove(0, commonPathPrefix.Length);
|
||||
if (Path.IsPathRooted(str2))
|
||||
str2 = str2.Substring(1);
|
||||
str1 = Path.Combine(outputPath, str2);
|
||||
}
|
||||
UserProcessBase.logger.DebugFormat("Extract {0} to {1}", (object) Filename, (object) str1);
|
||||
if (directoryRecord.IsDirectory)
|
||||
{
|
||||
UserProcessBase.logger.DebugFormat("Create output directory {0}", (object) str1);
|
||||
DirectoryInfo directoryInfo = new DirectoryInfo(str1);
|
||||
if (!directoryInfo.Exists)
|
||||
{
|
||||
Directory.CreateDirectory(directoryInfo.FullName);
|
||||
DateTime dateTime = directoryRecord.RecordingDateTime.HasValue ? directoryRecord.RecordingDateTime.Value : DateTime.Now;
|
||||
directoryInfo.CreationTime = dateTime;
|
||||
directoryInfo.LastWriteTime = dateTime;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastFileName = str1;
|
||||
num2 = this.ExtractDirectoryRecord(directoryRecord, str1, num1, num2, asyncOp);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
UserProcessBase.logger.ErrorFormat("Unable to extract the data: {0}", (object) exception);
|
||||
}
|
||||
this.DoExtractionCleanupIfNeeded(lastFileName, num2, exception, asyncOp);
|
||||
this.ReportCompletion(Filename, exception, asyncOp);
|
||||
}
|
||||
|
||||
private long ExtractDirectoryRecord(
|
||||
DirectoryRecord directoryRecord,
|
||||
string FileOutputPath,
|
||||
long totalNumberOfBytesToExtract,
|
||||
long totalNumberOfBytesRemaining,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
using (DiscSectorStream forDirectoryRecord = this.DiscFileSystem.GetDiscStreamForDirectoryRecord(directoryRecord))
|
||||
{
|
||||
using (FileStream fileStream = new FileStream(FileOutputPath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, DiscExtractor.OutputFileStreamBuffer))
|
||||
{
|
||||
long length = forDirectoryRecord.Length;
|
||||
byte[] buffer = new byte[DiscExtractor.OutputFileStreamBuffer];
|
||||
while (length > 0L)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
{
|
||||
int count = forDirectoryRecord.Read(buffer, 0, buffer.Length);
|
||||
length -= (long) count;
|
||||
totalNumberOfBytesRemaining -= (long) count;
|
||||
fileStream.Write(buffer, 0, count);
|
||||
this.ReportProgress(this.CreateProgressChangedEventArgs(directoryRecord.FullPath, FileOutputPath, forDirectoryRecord.Length, length, totalNumberOfBytesToExtract, totalNumberOfBytesRemaining, asyncOp), asyncOp);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
DateTime dateTime = directoryRecord.RecordingDateTime.HasValue ? directoryRecord.RecordingDateTime.Value : DateTime.Now;
|
||||
File.SetCreationTime(FileOutputPath, dateTime);
|
||||
File.SetLastWriteTime(FileOutputPath, dateTime);
|
||||
return totalNumberOfBytesRemaining;
|
||||
}
|
||||
|
||||
private void TrackExtractorWorker(
|
||||
List<IDiscTrack> tracks,
|
||||
string outputPath,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
Exception exception = (Exception) null;
|
||||
string lastFileName = string.Empty;
|
||||
long ofBytesToExtract = this.ComputeNumberOfBytesToExtract(tracks);
|
||||
this.CheckForEnoughFreeDiscSpace(ofBytesToExtract, outputPath);
|
||||
long num = ofBytesToExtract;
|
||||
try
|
||||
{
|
||||
foreach (IDiscTrack track in tracks)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
{
|
||||
string outputFileName = tracks.Count > 1 ? Path.Combine(outputPath, Path.GetFileName(track.VirtualName)) : outputPath;
|
||||
lastFileName = outputFileName;
|
||||
num = this.ExtractDiscTrack(track, outputFileName, ofBytesToExtract, num, asyncOp);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
UserProcessBase.logger.ErrorFormat("Unable to extract the track: {0}", (object) exception);
|
||||
}
|
||||
this.DoExtractionCleanupIfNeeded(lastFileName, num, exception, asyncOp);
|
||||
this.ReportCompletion(outputPath, exception, asyncOp);
|
||||
}
|
||||
|
||||
private long ExtractDiscTrack(
|
||||
IDiscTrack track,
|
||||
string outputFileName,
|
||||
long totalNumberOfBytesToExtract,
|
||||
long totalNumberOfBytesRemaining,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
using (System.IO.Stream fileInputStream = track.FileInputStream)
|
||||
{
|
||||
using (FileStream fileStream = new FileStream(outputFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, DiscExtractor.OutputFileStreamBuffer))
|
||||
{
|
||||
long length = fileInputStream.Length;
|
||||
byte[] buffer = new byte[DiscExtractor.OutputFileStreamBuffer];
|
||||
while (length > 0L)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
{
|
||||
int count = fileInputStream.Read(buffer, 0, buffer.Length);
|
||||
length -= (long) count;
|
||||
totalNumberOfBytesRemaining -= (long) count;
|
||||
fileStream.Write(buffer, 0, count);
|
||||
this.ReportProgress(this.CreateProgressChangedEventArgs(track.FileName, outputFileName, fileInputStream.Length, length, totalNumberOfBytesToExtract, totalNumberOfBytesRemaining, asyncOp), asyncOp);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return totalNumberOfBytesRemaining;
|
||||
}
|
||||
|
||||
private long ComputeNumberOfBytesToExtract(List<IDiscTrack> tracks)
|
||||
{
|
||||
long num = 0;
|
||||
foreach (IDiscTrack track in tracks)
|
||||
num += track.FileInputStream.Length;
|
||||
return num;
|
||||
}
|
||||
|
||||
private void CheckForEnoughFreeDiscSpace(long requiredSpaceInBytes, string outputPath)
|
||||
{
|
||||
if (requiredSpaceInBytes > new DriveInfo(outputPath.Substring(0, 3)).AvailableFreeSpace)
|
||||
{
|
||||
UserProcessBase.logger.ErrorFormat("Extraction requires {0} bytes of free disc space in drive {1}", (object) requiredSpaceInBytes, (object) outputPath.Substring(0, 3));
|
||||
throw new IOException("Not enough free disc space!");
|
||||
}
|
||||
}
|
||||
|
||||
private UserProcessProgressChangedEventArgs CreateProgressChangedEventArgs(
|
||||
string input,
|
||||
string output,
|
||||
long numberOfBytesToExtract,
|
||||
long remainingBytesToExtract,
|
||||
long totalNumberOfBytesToExtract,
|
||||
long totalNumberOfBytesRemaining,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
int progressPercentage = (int) ((double) (numberOfBytesToExtract - remainingBytesToExtract) / (double) numberOfBytesToExtract * 100.0);
|
||||
int totalProgressPercentage = (int) ((double) (totalNumberOfBytesToExtract - totalNumberOfBytesRemaining) / (double) totalNumberOfBytesToExtract * 100.0);
|
||||
return new UserProcessProgressChangedEventArgs(input, output, progressPercentage, totalProgressPercentage, asyncOp.UserSuppliedState);
|
||||
}
|
||||
|
||||
private void DoExtractionCleanupIfNeeded(
|
||||
string lastFileName,
|
||||
long remainingBytes,
|
||||
Exception exception,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp) && exception == null || remainingBytes <= 0L)
|
||||
return;
|
||||
if (!File.Exists(lastFileName))
|
||||
return;
|
||||
try
|
||||
{
|
||||
File.Delete(lastFileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UserProcessBase.logger.ErrorFormat("Unable to delete the file {0}: {1}", (object) lastFileName, (object) ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private delegate void FileExtractorWorkerEventHandler(
|
||||
List<DirectoryRecord> directoryRecords,
|
||||
string outputPath,
|
||||
AsyncOperation asyncOp);
|
||||
|
||||
private delegate void TrackExtractorWorkerEventHandler(
|
||||
List<IDiscTrack> tracks,
|
||||
string outputPath,
|
||||
AsyncOperation asyncOp);
|
||||
}
|
||||
}
|
23
SEGATools/Disc/DiscExtractorException.cs
Normal file
23
SEGATools/Disc/DiscExtractorException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Disc.DiscExtractorException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Disc
|
||||
{
|
||||
public class DiscExtractorException : Exception
|
||||
{
|
||||
public DiscExtractorException(string message)
|
||||
: base(string.Format("Disc Extractor Error: {0}", (object) message))
|
||||
{
|
||||
}
|
||||
|
||||
public DiscExtractorException(string message, Exception innerException)
|
||||
: base(string.Format("Disc Extractor Error: {0}", (object) message), innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
155
SEGATools/Disc/DiscFormatProvider.cs
Normal file
155
SEGATools/Disc/DiscFormatProvider.cs
Normal file
|
@ -0,0 +1,155 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Disc.DiscFormatProvider
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.FileFormat;
|
||||
using SEGATools.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SEGATools.Disc
|
||||
{
|
||||
public class DiscFormatProvider : Component
|
||||
{
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
private static readonly string FILEFORMAT_NAMESPACE = "GDRomExplorer.ImageFileFormat";
|
||||
private static readonly string FILEFORMAT_PLUGIN_FOLDER = "Formats";
|
||||
private static List<IImageFileFormat> fileFormats;
|
||||
private IContainer components;
|
||||
|
||||
public List<IImageFileFormat> SupportedFileFormat => DiscFormatProvider.fileFormats.ToList<IImageFileFormat>();
|
||||
|
||||
public DiscFormatProvider()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
if (DiscFormatProvider.fileFormats != null)
|
||||
return;
|
||||
DiscFormatProvider.LoadImageFileFormatAssemblies();
|
||||
}
|
||||
|
||||
public DiscFormatProvider(IContainer container)
|
||||
{
|
||||
container.Add((IComponent) this);
|
||||
this.InitializeComponent();
|
||||
if (DiscFormatProvider.fileFormats != null)
|
||||
return;
|
||||
DiscFormatProvider.LoadImageFileFormatAssemblies();
|
||||
}
|
||||
|
||||
public string GetFileDialogFilters(params string[] fileExtensionFilters)
|
||||
{
|
||||
int num = 0;
|
||||
List<string> stringList1 = new List<string>();
|
||||
List<string> stringList2 = new List<string>();
|
||||
foreach (IImageFileFormat fileFormat in DiscFormatProvider.fileFormats)
|
||||
{
|
||||
string[] strArray = fileFormat.FileExtentions;
|
||||
if (fileExtensionFilters != null && fileExtensionFilters.Length > 0)
|
||||
strArray = ((IEnumerable<string>) fileFormat.FileExtentions).Where<string>((Func<string, bool>) (extension => ((IEnumerable<string>) fileExtensionFilters).Contains<string>(extension))).ToArray<string>();
|
||||
for (int index = 0; index < strArray.Length; ++index)
|
||||
{
|
||||
stringList1.Add(fileFormat.FileExtentionDescriptions[index]);
|
||||
string str = string.Format("*{0}", (object) fileFormat.FileExtentions[index]);
|
||||
stringList1.Add(str);
|
||||
stringList2.Add(str);
|
||||
++num;
|
||||
}
|
||||
}
|
||||
if (num > 1)
|
||||
{
|
||||
stringList1.Insert(0, string.Join(";", stringList2.ToArray()));
|
||||
stringList1.Insert(0, Resources.DiscFormatProviderAllExtensions);
|
||||
}
|
||||
return string.Join("|", stringList1.ToArray());
|
||||
}
|
||||
|
||||
public int GetFileFormatIndex(IImageFileFormat imageFileFormat) => DiscFormatProvider.fileFormats.IndexOf(imageFileFormat) + 2;
|
||||
|
||||
public bool IsFileExtensionSupported(string fileExtension) => this.FindImageFileFormatForFileExtension(fileExtension) != null;
|
||||
|
||||
public IImageFileFormat FindImageFileFormatForFileExtension(string fileExtension) => string.IsNullOrEmpty(fileExtension) ? (IImageFileFormat) null : DiscFormatProvider.fileFormats.Find((Predicate<IImageFileFormat>) (imageFileFormat => new List<string>((IEnumerable<string>) imageFileFormat.FileExtentions).Contains<string>(fileExtension, (IEqualityComparer<string>) StringComparer.InvariantCultureIgnoreCase)));
|
||||
|
||||
public string GetDescriptionForFileExtension(string extension, IImageFileFormat imageFileFormat)
|
||||
{
|
||||
for (int index = 0; index < imageFileFormat.FileExtentions.Length; ++index)
|
||||
{
|
||||
if (imageFileFormat.FileExtentions[index].Equals(extension, StringComparison.InvariantCultureIgnoreCase))
|
||||
return imageFileFormat.FileExtentionDescriptions[index];
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static void LoadImageFileFormatAssemblies()
|
||||
{
|
||||
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), DiscFormatProvider.FILEFORMAT_PLUGIN_FOLDER);
|
||||
try
|
||||
{
|
||||
DiscFormatProvider.LoadImageFileFormatAssembliesFromPluginPath(path);
|
||||
}
|
||||
catch (DirectoryNotFoundException ex)
|
||||
{
|
||||
DiscFormatProvider.logger.ErrorFormat("Unable to find the plugin folder: {0}", (object) path);
|
||||
logger.Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadImageFileFormatAssembliesFromPluginPath(string path)
|
||||
{
|
||||
DiscFormatProvider.fileFormats = new List<IImageFileFormat>();
|
||||
List<Type> typeList = new List<Type>();
|
||||
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
foreach (string file in Directory.GetFiles(path, "*.dll"))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<Type> list = ((IEnumerable<Type>) Assembly.LoadFile(file).GetTypes()).Where<Type>((Func<Type, bool>) (t => t.IsClass && t.Namespace != null && t.Namespace.StartsWith("GDRomExplorer.ImageFileFormat") && typeof (IImageFileFormat).IsAssignableFrom(t))).ToList<Type>();
|
||||
typeList.AddRange((IEnumerable<Type>) list);
|
||||
}
|
||||
catch (ReflectionTypeLoadException ex)
|
||||
{
|
||||
DiscFormatProvider.logger.ErrorFormat("Unable to load types in namespace \"{0}\"", (object) DiscFormatProvider.FILEFORMAT_NAMESPACE);
|
||||
logger.Error(ex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
DiscFormatProvider.logger.InfoFormat("Found {0} file formats to load", (object) typeList.Count);
|
||||
foreach (Type type in typeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
IImageFileFormat instance = (IImageFileFormat) Activator.CreateInstance(type);
|
||||
if (DiscFormatProvider.fileFormats.Contains(instance))
|
||||
{
|
||||
DiscFormatProvider.logger.WarnFormat("File format {0} already loaded", (object) type.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
instance.PluginAssemblyFileName = type.Assembly.CodeBase;
|
||||
DiscFormatProvider.fileFormats.Add(instance);
|
||||
DiscFormatProvider.logger.InfoFormat("File format {0} loaded", (object) type.Name);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DiscFormatProvider.logger.ErrorFormat("Unable to load file format {0}: {1}", (object) type.Name, (object) ex);
|
||||
}
|
||||
}
|
||||
DiscFormatProvider.fileFormats = DiscFormatProvider.fileFormats.Distinct<IImageFileFormat>().ToList<IImageFileFormat>();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && this.components != null)
|
||||
this.components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent() => this.components = (IContainer) new Container();
|
||||
}
|
||||
}
|
119
SEGATools/Disc/DiscOpener.cs
Normal file
119
SEGATools/Disc/DiscOpener.cs
Normal file
|
@ -0,0 +1,119 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Disc.DiscOpener
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.Binary;
|
||||
using SEGATools.DiscFileSystem;
|
||||
using SEGATools.Scanner;
|
||||
using SEGATools.UserProcess;
|
||||
using SEGATools.VirtualFile;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
|
||||
namespace SEGATools.Disc
|
||||
{
|
||||
public class DiscOpener : UserProcessBase
|
||||
{
|
||||
private IDiscFileSystem disc;
|
||||
private bool computePathTable;
|
||||
|
||||
public event AsyncOperationProgressChangedEventHandler FileOpenerProgressChanged
|
||||
{
|
||||
add => this.AsyncOperationProgressChanged += value;
|
||||
remove => this.AsyncOperationProgressChanged -= value;
|
||||
}
|
||||
|
||||
public event AsyncOperationCompletedEventHandler FileOpenerCompleted
|
||||
{
|
||||
add => this.AsyncOperationCompleted += value;
|
||||
remove => this.AsyncOperationCompleted -= value;
|
||||
}
|
||||
|
||||
public IDiscFileSystem DiscFileSystem => this.disc;
|
||||
|
||||
public DiscOpener()
|
||||
{
|
||||
}
|
||||
|
||||
public DiscOpener(IContainer container)
|
||||
: base(container)
|
||||
{
|
||||
}
|
||||
|
||||
public void OpenImageAsync(
|
||||
string Filename,
|
||||
IDiscFileSystemConverter ImageFileConverter,
|
||||
bool ComputePathTable)
|
||||
{
|
||||
AsyncOperation asyncOperation = this.CreateAsyncOperation((object) Guid.NewGuid());
|
||||
this.computePathTable = ComputePathTable;
|
||||
new DiscOpener.FileOpenerWorkerEventHandler(this.FileOpenerWorker).BeginInvoke(Filename, ImageFileConverter, asyncOperation, (AsyncCallback) null, (object) null);
|
||||
}
|
||||
|
||||
public void OpenImage(
|
||||
string Filename,
|
||||
IDiscFileSystemConverter ImageFileConverter,
|
||||
bool ComputePathTable)
|
||||
{
|
||||
this.computePathTable = ComputePathTable;
|
||||
this.FileOpenerWorker(Filename, ImageFileConverter, (AsyncOperation) null);
|
||||
}
|
||||
|
||||
public void CloseImage()
|
||||
{
|
||||
if (this.disc == null)
|
||||
return;
|
||||
this.disc.Close();
|
||||
this.disc = (IDiscFileSystem) null;
|
||||
}
|
||||
|
||||
private void FileOpenerWorker(
|
||||
string Filename,
|
||||
IDiscFileSystemConverter ImageFileConverter,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
Exception exception = (Exception) null;
|
||||
if (asyncOp != null)
|
||||
this.ReportProgress(new UserProcessProgressChangedEventArgs(Filename, 0, asyncOp.UserSuppliedState), asyncOp);
|
||||
if (this.disc != null)
|
||||
{
|
||||
this.disc.Close();
|
||||
this.disc = (IDiscFileSystem) null;
|
||||
}
|
||||
try
|
||||
{
|
||||
this.disc = DiscFileSystemBuilder.ToDisc(Filename, ImageFileConverter, this.computePathTable);
|
||||
foreach (IDiscSession discSession in this.disc.Sessions.FindAll((Predicate<IDiscSession>) (session => session.BootStrap != null)))
|
||||
{
|
||||
using (FileScanner fileScanner = new FileScanner())
|
||||
{
|
||||
IVirtualFile<System.IO.Stream> virtualFile = VirtualFileFactory.createVirtualFile(discSession.BootStrap.Stream, this.disc.FileName);
|
||||
List<SEGALibrary> Libraries = fileScanner.ScanFile<SEGALibrary>((IVirtualFile) virtualFile, FileScannerPattern.aPatternForSEGALibraries(), (IFileScannerResultConverter<SEGALibrary>) new FileScannerResultConverterForSEGALibrary());
|
||||
this.disc.RegisterLibraries((object) discSession.BootStrap, Libraries);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
this.disc = (IDiscFileSystem) null;
|
||||
UserProcessBase.logger.DebugFormat("Error while reading the image file: {0}", (object) ex);
|
||||
}
|
||||
if ((this.TaskCanceled(asyncOp) || exception != null) && this.disc != null)
|
||||
{
|
||||
this.disc.Close();
|
||||
this.disc = (IDiscFileSystem) null;
|
||||
}
|
||||
this.ReportCompletion(Filename, exception, asyncOp);
|
||||
}
|
||||
|
||||
private delegate void FileOpenerWorkerEventHandler(
|
||||
string filename,
|
||||
IDiscFileSystemConverter imageFileConverter,
|
||||
AsyncOperation asyncOp);
|
||||
}
|
||||
}
|
60
SEGATools/Disc/DiscSectorEncoder.cs
Normal file
60
SEGATools/Disc/DiscSectorEncoder.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Disc.DiscSectorEncoder
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
using SEGATools.HashAlgorithm;
|
||||
using SEGATools.UserProcess;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
|
||||
namespace SEGATools.Disc
|
||||
{
|
||||
public class DiscSectorEncoder : UserProcessBase
|
||||
{
|
||||
private EDC edcEncoder = new EDC();
|
||||
private ECC.ECCParityVectorAlgorithm eccPParityEncoder = (ECC.ECCParityVectorAlgorithm) new ECC.PParity();
|
||||
private ECC.ECCParityVectorAlgorithm eccQParityEncoder = (ECC.ECCParityVectorAlgorithm) new ECC.QParity();
|
||||
|
||||
public DiscSectorEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
public DiscSectorEncoder(IContainer container)
|
||||
: base(container)
|
||||
{
|
||||
}
|
||||
|
||||
public void EncodeMode1Sectors(System.IO.Stream stream, int[] sectors)
|
||||
{
|
||||
byte[] numArray = new byte[DiscSectorCommon.RawSectorSize];
|
||||
for (int index = 0; index < sectors.Length; ++index)
|
||||
{
|
||||
UserProcessBase.logger.DebugFormat("Patching EDC and ECC data of sector {0}", (object) sectors[index]);
|
||||
stream.Seek((long) (sectors[index] * DiscSectorCommon.RawSectorSize), SeekOrigin.Begin);
|
||||
stream.Read(numArray, 0, DiscSectorCommon.RawSectorSize);
|
||||
this.ClearErrorDetectionAndCorrectionData(numArray);
|
||||
this.GenerateEDC(numArray);
|
||||
this.eccPParityEncoder.ComputeVectors(numArray);
|
||||
this.eccQParityEncoder.ComputeVectors(numArray);
|
||||
stream.Seek((long) -DiscSectorCommon.RawSectorSize, SeekOrigin.Current);
|
||||
stream.Write(numArray, 0, numArray.Length);
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateEDC(byte[] sector)
|
||||
{
|
||||
byte[] hash = this.edcEncoder.ComputeHash(sector, 0, EDC.SECTOR_DATA_LENGTH_FOR_EDC_COMPUTATION);
|
||||
Buffer.BlockCopy((Array) hash, 0, (Array) sector, EDC.EDC_DATA_OFFSET, hash.Length);
|
||||
}
|
||||
|
||||
public void ClearErrorDetectionAndCorrectionData(byte[] sector)
|
||||
{
|
||||
for (int edcDataOffset = EDC.EDC_DATA_OFFSET; edcDataOffset < sector.Length; ++edcDataOffset)
|
||||
sector[edcDataOffset] = (byte) 0;
|
||||
}
|
||||
}
|
||||
}
|
113
SEGATools/DiscFileSystem/DiscFileSystem.cs
Normal file
113
SEGATools/DiscFileSystem/DiscFileSystem.cs
Normal file
|
@ -0,0 +1,113 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.DiscFileSystem
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.ISO9660.DirectoryRecords;
|
||||
using ImageReader.Stream;
|
||||
using SEGATools.Binary;
|
||||
using SEGATools.Encrypt;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
internal sealed class DiscFileSystem : IDiscFileSystem
|
||||
{
|
||||
private readonly Dictionary<object, List<SEGALibrary>> FileLibraries;
|
||||
|
||||
public List<IDiscSession> Sessions { get; private set; }
|
||||
|
||||
public string FileName { get; private set; }
|
||||
|
||||
public bool CanExtractData { get; private set; }
|
||||
|
||||
public bool CanBeExportedToCueSheet { get; private set; }
|
||||
|
||||
public bool CanBeExportedToGdi { get; private set; }
|
||||
|
||||
public string DiscName { get; set; }
|
||||
|
||||
public DirectoryRecord MainBinary { get; set; }
|
||||
|
||||
public DiscImageType DiscType { get; set; }
|
||||
|
||||
public List<IDiscTrack> AllTracks
|
||||
{
|
||||
get
|
||||
{
|
||||
List<IDiscTrack> allTracks = new List<IDiscTrack>();
|
||||
this.Sessions.ForEach((Action<IDiscSession>) (session => allTracks.AddRange((IEnumerable<IDiscTrack>) session.Tracks)));
|
||||
return allTracks.OrderBy<IDiscTrack, uint>((Func<IDiscTrack, uint>) (track => track.LogicalBlockAddress)).ToList<IDiscTrack>();
|
||||
}
|
||||
}
|
||||
|
||||
public DESKey NaomiDESKey { get; set; }
|
||||
|
||||
internal DiscFileSystem(string filename, List<IDiscSession> sessions)
|
||||
: this(filename, sessions, false, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
internal DiscFileSystem(
|
||||
string filename,
|
||||
List<IDiscSession> sessions,
|
||||
bool supportDataExtraction)
|
||||
: this(filename, sessions, supportDataExtraction, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
internal DiscFileSystem(
|
||||
string filename,
|
||||
List<IDiscSession> sessions,
|
||||
bool supportDataExtraction,
|
||||
bool supportCueSheet)
|
||||
: this(filename, sessions, supportDataExtraction, supportCueSheet, false)
|
||||
{
|
||||
}
|
||||
|
||||
internal DiscFileSystem(
|
||||
string filename,
|
||||
List<IDiscSession> sessions,
|
||||
bool supportDataExtraction,
|
||||
bool supportCueSheet,
|
||||
bool supportGdiExport)
|
||||
{
|
||||
this.FileName = filename;
|
||||
this.DiscName = "N/A";
|
||||
sessions.ForEach((Action<IDiscSession>) (discSession => discSession.Disc = (IDiscFileSystem) this));
|
||||
this.Sessions = sessions.OrderBy<IDiscSession, int>((Func<IDiscSession, int>) (session => session.Index)).ToList<IDiscSession>();
|
||||
this.DiscType = DiscImageType.Unknown;
|
||||
this.CanExtractData = supportDataExtraction;
|
||||
this.CanBeExportedToCueSheet = supportCueSheet;
|
||||
this.CanBeExportedToGdi = supportGdiExport;
|
||||
this.FileLibraries = new Dictionary<object, List<SEGALibrary>>();
|
||||
}
|
||||
|
||||
public IDiscTrack GetTrackForLogicalBlockAddress(long lba) => this.AllTracks.LastOrDefault<IDiscTrack>((Func<IDiscTrack, bool>) (track => (long) track.LogicalBlockAddress <= lba));
|
||||
|
||||
public DiscSectorStream GetDiscStreamForDirectoryRecord(
|
||||
DirectoryRecord directoryRecord)
|
||||
{
|
||||
IDiscTrack logicalBlockAddress = this.GetTrackForLogicalBlockAddress((long) directoryRecord.Extent);
|
||||
return logicalBlockAddress == null || directoryRecord.IsDirectory ? (DiscSectorStream) null : new DiscSectorStream(logicalBlockAddress.FileInputStream, logicalBlockAddress.TrackSector, directoryRecord.Extent - logicalBlockAddress.LogicalBlockAddress, directoryRecord.ExtentSize, true);
|
||||
}
|
||||
|
||||
public void RegisterLibraries(object file, List<SEGALibrary> Libraries) => this.FileLibraries[file] = Libraries;
|
||||
|
||||
public List<SEGALibrary> GetSEGALibraries(object file) => !this.FileLibraries.Keys.Contains<object>(file) ? (List<SEGALibrary>) null : this.FileLibraries[file];
|
||||
|
||||
public void Close()
|
||||
{
|
||||
this.MainBinary = (DirectoryRecord) null;
|
||||
if (this.Sessions == null)
|
||||
return;
|
||||
foreach (IDiscSession session in this.Sessions)
|
||||
session.Close();
|
||||
this.Sessions.Clear();
|
||||
this.Sessions = (List<IDiscSession>) null;
|
||||
}
|
||||
}
|
||||
}
|
161
SEGATools/DiscFileSystem/DiscFileSystemBuilder.cs
Normal file
161
SEGATools/DiscFileSystem/DiscFileSystemBuilder.cs
Normal file
|
@ -0,0 +1,161 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.DiscFileSystemBuilder
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscFileSystem;
|
||||
using ImageReader.ImageReader;
|
||||
using ImageReader.ISO9660.DirectoryRecords;
|
||||
using ImageReader.Stream;
|
||||
using SEGATools.Encrypt;
|
||||
using SEGATools.Security;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
public sealed class DiscFileSystemBuilder
|
||||
{
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
private static readonly string NAOMI_GD_BINARY_NAME = "NAOMIGD.BIN";
|
||||
private static readonly Regex NAOMI_PRODUCT_ID_PREFIX = new Regex("GD.+-.*", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
private static readonly string NAOMI_KEY_FILE_EXT = "key";
|
||||
private static readonly string NAOMI_KEY_FILE_NAME = "key.txt";
|
||||
|
||||
private static InitialProgram GetBootStrapFrom(IDiscTrack track)
|
||||
{
|
||||
byte[] buffer;
|
||||
using (DiscSectorStream discSectorStream = new DiscSectorStream(track.FileInputStream, track.TrackSector, 0U, InitialProgram.IP_FILESIZE, true))
|
||||
{
|
||||
buffer = new byte[discSectorStream.Length];
|
||||
discSectorStream.Read(buffer, 0, buffer.Length);
|
||||
}
|
||||
try
|
||||
{
|
||||
return InitialProgramConverter.ToInitialProgram(buffer, 0);
|
||||
}
|
||||
catch (InitialProgramInvalidHardwareIdException ex)
|
||||
{
|
||||
logger.Warn(ex);
|
||||
return (InitialProgram) null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static InitialProgram GetBootStrapFrom(IDiscSession session)
|
||||
{
|
||||
foreach (IDiscTrack dataTrack in session.DataTracks)
|
||||
{
|
||||
InitialProgram bootStrapFrom = DiscFileSystemBuilder.GetBootStrapFrom(dataTrack);
|
||||
if (bootStrapFrom != null)
|
||||
return bootStrapFrom;
|
||||
}
|
||||
return (InitialProgram) null;
|
||||
}
|
||||
|
||||
private static DirectoryRecord GetMainBinary(
|
||||
IDiscFileSystem discFileSystem,
|
||||
DirectoryRecord rootDirectoryRecord,
|
||||
InitialProgram ip)
|
||||
{
|
||||
if (rootDirectoryRecord.Contains(DiscFileSystemBuilder.NAOMI_GD_BINARY_NAME))
|
||||
{
|
||||
DirectoryRecord directoryRecord1 = rootDirectoryRecord.SubDirectories.Find((Predicate<DirectoryRecord>) (directoryRecord => directoryRecord.ExtentSize.Equals(256U)));
|
||||
DiscSectorStream forDirectoryRecord = discFileSystem.GetDiscStreamForDirectoryRecord(directoryRecord1);
|
||||
forDirectoryRecord.Seek(192L, SeekOrigin.Begin);
|
||||
byte[] numArray = new byte[64];
|
||||
forDirectoryRecord.Read(numArray, 0, numArray.Length);
|
||||
int count = 0;
|
||||
while (count < numArray.Length && numArray[count] != (byte) 0)
|
||||
++count;
|
||||
string NaomiMainBinaryFileName = Encoding.Default.GetString(numArray, 0, count);
|
||||
return rootDirectoryRecord.SubDirectories.Find((Predicate<DirectoryRecord>) (directoryRecord => directoryRecord.Name.Equals(NaomiMainBinaryFileName)));
|
||||
}
|
||||
string MainBinaryFileName = ip.MainBinary.Trim();
|
||||
return rootDirectoryRecord.Contains(MainBinaryFileName) ? rootDirectoryRecord.SubDirectories.Find((Predicate<DirectoryRecord>) (directoryRecord => directoryRecord.Name.Equals(MainBinaryFileName))) : (DirectoryRecord) null;
|
||||
}
|
||||
|
||||
private static DESKey TryGetDESKey(string FileName)
|
||||
{
|
||||
string[] strArray = new string[2]
|
||||
{
|
||||
Path.ChangeExtension(FileName, DiscFileSystemBuilder.NAOMI_KEY_FILE_EXT),
|
||||
Path.Combine(Path.GetDirectoryName(FileName), DiscFileSystemBuilder.NAOMI_KEY_FILE_NAME)
|
||||
};
|
||||
foreach (string path in strArray)
|
||||
{
|
||||
DiscFileSystemBuilder.logger.DebugFormat("Searching for DES key in {0}", (object) path);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
using (StreamReader streamReader = new StreamReader(path))
|
||||
{
|
||||
string key = streamReader.ReadLine();
|
||||
if (DESKey.TryParse(key))
|
||||
{
|
||||
DESKey desKey = DESKey.Parse(key);
|
||||
DiscFileSystemBuilder.logger.DebugFormat("DESKey found in {0}: {1}", (object) path, (object) desKey);
|
||||
return desKey;
|
||||
}
|
||||
DiscFileSystemBuilder.logger.WarnFormat("Could not parse the DES key in {0}", (object) path);
|
||||
}
|
||||
}
|
||||
}
|
||||
DiscFileSystemBuilder.logger.Debug((object) "No DES key found");
|
||||
return (DESKey) null;
|
||||
}
|
||||
|
||||
public static IDiscFileSystem ToDisc(
|
||||
string FileName,
|
||||
IDiscFileSystemConverter DiscFileSystemConverter,
|
||||
bool computePathTable)
|
||||
{
|
||||
IDiscFileSystem discFileSystem = DiscFileSystemConverter.ToDiscFileSystem(FileName);
|
||||
foreach (IDiscSession session in discFileSystem.Sessions.FindAll((Predicate<IDiscSession>) (s => s.DataTracks.Count > 0)))
|
||||
{
|
||||
if (session.DataTracks.Count >= 1)
|
||||
{
|
||||
IDiscTrack dataTrack = session.DataTracks[0];
|
||||
try
|
||||
{
|
||||
using (DiscImageReader discImageReader = new DiscImageReader())
|
||||
{
|
||||
discImageReader.ParsePathTable = !computePathTable;
|
||||
discImageReader.Open(dataTrack.FileInputStream, dataTrack.LogicalBlockAddress, dataTrack.TrackSector);
|
||||
session.PrimaryVolumeDescriptor = discImageReader.PrimaryVolumeDescriptor;
|
||||
session.RootDirectoryRecord = discImageReader.PrimaryVolumeDescriptor.RootDirectoryRecord;
|
||||
}
|
||||
}
|
||||
catch (DiscImageReaderException ex)
|
||||
{
|
||||
logger.Error(ex);
|
||||
}
|
||||
}
|
||||
session.BootStrap = DiscFileSystemBuilder.GetBootStrapFrom(session);
|
||||
}
|
||||
IDiscSession discSession1 = discFileSystem.Sessions.LastOrDefault<IDiscSession>((Func<IDiscSession, bool>) (session => session.RootDirectoryRecord != null));
|
||||
if (discSession1 == null)
|
||||
throw DiscFileSystemException.noFileSystemFoundException();
|
||||
IDiscSession discSession2 = discFileSystem.Sessions.LastOrDefault<IDiscSession>((Func<IDiscSession, bool>) (s => s.BootStrap != null));
|
||||
if (discSession2 != null && discSession2.BootStrap != null)
|
||||
{
|
||||
discFileSystem.DiscType = DiscImageType.Dreamcast;
|
||||
InitialProgram bootStrap = discSession2.BootStrap;
|
||||
discSession1.MainBinary = DiscFileSystemBuilder.GetMainBinary(discFileSystem, discSession1.RootDirectoryRecord, bootStrap);
|
||||
if (DiscFileSystemBuilder.NAOMI_PRODUCT_ID_PREFIX.Match(bootStrap.ProductID).Success)
|
||||
{
|
||||
discFileSystem.DiscType = DiscImageType.Naomi;
|
||||
discFileSystem.NaomiDESKey = DiscFileSystemBuilder.TryGetDESKey(FileName);
|
||||
}
|
||||
discFileSystem.DiscName = bootStrap.SoftwareName.Trim();
|
||||
discFileSystem.MainBinary = discSession1.MainBinary;
|
||||
}
|
||||
return discFileSystem;
|
||||
}
|
||||
}
|
||||
}
|
20
SEGATools/DiscFileSystem/DiscFileUtils.cs
Normal file
20
SEGATools/DiscFileSystem/DiscFileUtils.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.DiscFileUtils
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
public class DiscFileUtils
|
||||
{
|
||||
public static string GetExtensionForDiscTrack(IDiscTrack DiscTrack)
|
||||
{
|
||||
if (DiscTrack.TrackData == TrackModeType.Audio)
|
||||
return ".raw";
|
||||
return DiscTrack.TrackSector is ISO9660Sector ? ".iso" : ".bin";
|
||||
}
|
||||
}
|
||||
}
|
23
SEGATools/DiscFileSystem/DiscFormatException.cs
Normal file
23
SEGATools/DiscFileSystem/DiscFormatException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.DiscFormatException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
public class DiscFormatException : Exception
|
||||
{
|
||||
public DiscFormatException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public DiscFormatException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
15
SEGATools/DiscFileSystem/DiscImageType.cs
Normal file
15
SEGATools/DiscFileSystem/DiscImageType.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.DiscImageType
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
public enum DiscImageType : short
|
||||
{
|
||||
Unknown,
|
||||
Dreamcast,
|
||||
Naomi,
|
||||
}
|
||||
}
|
110
SEGATools/DiscFileSystem/DiscSession.cs
Normal file
110
SEGATools/DiscFileSystem/DiscSession.cs
Normal file
|
@ -0,0 +1,110 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.DiscSession
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.ISO9660.DirectoryRecords;
|
||||
using ImageReader.ISO9660.VolumeDescriptors;
|
||||
using SEGATools.Security;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
internal sealed class DiscSession : IDiscSession
|
||||
{
|
||||
public static readonly string DEFAULT_SESSION_NAME_WITH_FORMAT = "Session {0}";
|
||||
private readonly string name;
|
||||
private int index;
|
||||
private InitialProgram ip;
|
||||
private IDiscFileSystem disc;
|
||||
private DirectoryRecord mainBinary;
|
||||
private PrimaryVolumeDescriptor primaryVolumeDescriptor;
|
||||
private DirectoryRecord rootDirectoryRecord;
|
||||
private List<IDiscTrack> tracks;
|
||||
|
||||
public List<IDiscTrack> Tracks => this.tracks.ToList<IDiscTrack>();
|
||||
|
||||
public List<IDiscTrack> DataTracks => this.tracks.FindAll((Predicate<IDiscTrack>) (track => track.TrackData == TrackModeType.Data));
|
||||
|
||||
public IDiscTrack FirstDataTrack
|
||||
{
|
||||
get
|
||||
{
|
||||
List<IDiscTrack> all = this.tracks.FindAll((Predicate<IDiscTrack>) (track => track.TrackData == TrackModeType.Data));
|
||||
return all.Count <= 0 ? (IDiscTrack) null : all.OrderBy<IDiscTrack, int>((Func<IDiscTrack, int>) (track => track.Index)).First<IDiscTrack>();
|
||||
}
|
||||
}
|
||||
|
||||
public IDiscTrack LastDataTrack
|
||||
{
|
||||
get
|
||||
{
|
||||
List<IDiscTrack> all = this.tracks.FindAll((Predicate<IDiscTrack>) (track => track.TrackData == TrackModeType.Data));
|
||||
return all.Count <= 0 ? (IDiscTrack) null : all.OrderBy<IDiscTrack, int>((Func<IDiscTrack, int>) (track => track.Index)).Last<IDiscTrack>();
|
||||
}
|
||||
}
|
||||
|
||||
public List<IDiscTrack> AudioTracks => this.tracks.FindAll((Predicate<IDiscTrack>) (track => track.TrackData == TrackModeType.Audio));
|
||||
|
||||
public int Index => this.index;
|
||||
|
||||
public string Name => this.name;
|
||||
|
||||
public DirectoryRecord MainBinary
|
||||
{
|
||||
get => this.mainBinary;
|
||||
set => this.mainBinary = value;
|
||||
}
|
||||
|
||||
public DirectoryRecord RootDirectoryRecord
|
||||
{
|
||||
get => this.rootDirectoryRecord;
|
||||
set => this.rootDirectoryRecord = value;
|
||||
}
|
||||
|
||||
public InitialProgram BootStrap
|
||||
{
|
||||
get => this.ip;
|
||||
set => this.ip = value;
|
||||
}
|
||||
|
||||
public PrimaryVolumeDescriptor PrimaryVolumeDescriptor
|
||||
{
|
||||
get => this.primaryVolumeDescriptor;
|
||||
set => this.primaryVolumeDescriptor = value;
|
||||
}
|
||||
|
||||
public IDiscFileSystem Disc
|
||||
{
|
||||
get => this.disc;
|
||||
set => this.disc = value;
|
||||
}
|
||||
|
||||
public DiscSession(int index, string name, List<IDiscTrack> tracks)
|
||||
{
|
||||
this.index = index;
|
||||
this.name = name;
|
||||
this.tracks = tracks.OrderBy<IDiscTrack, uint>((Func<IDiscTrack, uint>) (track => track.LogicalBlockAddress)).ToList<IDiscTrack>();
|
||||
this.tracks.ForEach((Action<IDiscTrack>) (track => track.Session = (IDiscSession) this));
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
this.ip = (InitialProgram) null;
|
||||
this.mainBinary = (DirectoryRecord) null;
|
||||
this.rootDirectoryRecord = (DirectoryRecord) null;
|
||||
this.primaryVolumeDescriptor = (PrimaryVolumeDescriptor) null;
|
||||
if (this.tracks != null)
|
||||
{
|
||||
foreach (IDiscTrack track in this.tracks)
|
||||
track.Close();
|
||||
this.tracks.Clear();
|
||||
this.tracks = (List<IDiscTrack>) null;
|
||||
}
|
||||
this.disc = (IDiscFileSystem) null;
|
||||
}
|
||||
}
|
||||
}
|
87
SEGATools/DiscFileSystem/DiscTrack.cs
Normal file
87
SEGATools/DiscFileSystem/DiscTrack.cs
Normal file
|
@ -0,0 +1,87 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.DiscTrack
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
using SEGATools.Stream;
|
||||
using SEGATools.VirtualFile;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
internal sealed class DiscTrack : IDiscTrack, IVirtualFile, IDisposable
|
||||
{
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
private bool disposed;
|
||||
|
||||
public string FileName { get; private set; }
|
||||
|
||||
public string Name => string.Format("Track {0:00}", (object) this.Index);
|
||||
|
||||
public int Index { get; private set; }
|
||||
|
||||
public uint LogicalBlockAddress { get; private set; }
|
||||
|
||||
public long Length { get; private set; }
|
||||
|
||||
public long Offset { get; private set; }
|
||||
|
||||
public TrackModeType TrackData { get; private set; }
|
||||
|
||||
public IDiscSector TrackSector { get; private set; }
|
||||
|
||||
public IDiscSession Session { get; set; }
|
||||
|
||||
public static IDiscTrack CreateCopyFrom(IDiscTrack source, string newFileName) => (IDiscTrack) new DiscTrack(newFileName, source.Offset, source.Length, source.LogicalBlockAddress, source.Index, source.TrackData, source.TrackSector);
|
||||
|
||||
internal DiscTrack(
|
||||
string fileName,
|
||||
long offset,
|
||||
long length,
|
||||
uint logicalBlockAdress,
|
||||
int index,
|
||||
TrackModeType trackData,
|
||||
IDiscSector trackSector)
|
||||
{
|
||||
this.disposed = false;
|
||||
this.LogicalBlockAddress = logicalBlockAdress;
|
||||
this.FileName = Path.GetFullPath(fileName);
|
||||
this.OriginalFileName = fileName;
|
||||
this.Index = index;
|
||||
this.TrackData = trackData;
|
||||
this.Offset = offset;
|
||||
this.Length = length;
|
||||
this.TrackSector = trackSector;
|
||||
}
|
||||
|
||||
public void Close() => this.Session = (IDiscSession) null;
|
||||
|
||||
public override string ToString() => this.Name;
|
||||
|
||||
public System.IO.Stream FileInputStream => (System.IO.Stream) new SubStream((System.IO.Stream) File.Open(this.FileName, FileMode.Open, FileAccess.Read, FileShare.Read), this.Offset, this.Length, true);
|
||||
|
||||
public string OriginalFileName { get; set; }
|
||||
|
||||
public System.IO.Stream FileOutputStream => (System.IO.Stream) new SubStream((System.IO.Stream) File.Open(this.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read), this.Offset, this.Length, true);
|
||||
|
||||
public string VirtualName => Path.ChangeExtension(string.Format("track{0:00}", (object) this.Index), DiscFileUtils.GetExtensionForDiscTrack((IDiscTrack) this));
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize((object) this);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (this.disposed)
|
||||
return;
|
||||
if (disposing)
|
||||
this.Close();
|
||||
this.disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
149
SEGATools/DiscFileSystem/GenericImageConverter.cs
Normal file
149
SEGATools/DiscFileSystem/GenericImageConverter.cs
Normal file
|
@ -0,0 +1,149 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.GenericImageConverter
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
using ImageReader.ImageReader;
|
||||
using ImageReader.Stream;
|
||||
using SEGATools.Security;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
public class GenericImageConverter : IDiscFileSystemConverter
|
||||
{
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
private static readonly Regex FIND_NEXT_FILE = new Regex("^(?<prefix>.*)(?<index>[0-9]{2}?)$", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline);
|
||||
private static readonly int INVALID_FILE_INDEX = -1;
|
||||
private static readonly int DEFAULT_FILE_INDEX = 1;
|
||||
private IDiscSector discSector;
|
||||
|
||||
public GenericImageConverter(IDiscSector discSector) => this.discSector = discSector;
|
||||
|
||||
public IDiscFileSystem ToDiscFileSystem(string imageFileName)
|
||||
{
|
||||
InitialProgram initialProgram = this.GetInitialProgram(imageFileName, this.discSector);
|
||||
List<IDiscTrack> tracks = new List<IDiscTrack>();
|
||||
int index = this.GetIndexFromFileName(imageFileName);
|
||||
if (index == GenericImageConverter.INVALID_FILE_INDEX)
|
||||
index = GenericImageConverter.DEFAULT_FILE_INDEX;
|
||||
GenericImageConverter.TrackFile trackFile = new GenericImageConverter.TrackFile(index, imageFileName);
|
||||
uint num = 0;
|
||||
if (this.ContainsNonEmptyISO9660FileSystem(trackFile, num))
|
||||
{
|
||||
IDiscTrack discTrack = (IDiscTrack) new DiscTrack(trackFile.FileName, 0L, trackFile.Length, num, trackFile.Index, TrackModeType.Data, this.discSector);
|
||||
tracks.Add(discTrack);
|
||||
}
|
||||
else if (initialProgram != null && initialProgram.TableOfContent != null && this.ContainsNonEmptyISO9660FileSystem(trackFile, initialProgram.TableOfContent.FirstTrack.FrameAddress))
|
||||
{
|
||||
uint frameAddress = initialProgram.TableOfContent.FirstTrack.FrameAddress;
|
||||
IDiscTrack discTrack1 = (IDiscTrack) new DiscTrack(trackFile.FileName, 0L, trackFile.Length, frameAddress, trackFile.Index, TrackModeType.Data, this.discSector);
|
||||
tracks.Add(discTrack1);
|
||||
GenericImageConverter.TrackFile nextImageFile = this.FindNextImageFile(imageFileName);
|
||||
if (initialProgram.TableOfContent.HasSplitedDataTracks && nextImageFile != null)
|
||||
{
|
||||
IDiscTrack discTrack2 = (IDiscTrack) new DiscTrack(nextImageFile.FileName, 0L, nextImageFile.Length, initialProgram.TableOfContent.LastTrack.FrameAddress, nextImageFile.Index, TrackModeType.Data, this.discSector);
|
||||
tracks.Add(discTrack2);
|
||||
}
|
||||
}
|
||||
IDiscSession discSession = (IDiscSession) new DiscSession(1, string.Format(DiscSession.DEFAULT_SESSION_NAME_WITH_FORMAT, (object) 1), tracks);
|
||||
List<IDiscSession> sessions = new List<IDiscSession>();
|
||||
sessions.Add(discSession);
|
||||
bool supportCueSheet = tracks.Count == 1;
|
||||
return (IDiscFileSystem) new SEGATools.DiscFileSystem.DiscFileSystem(imageFileName, sessions, true, supportCueSheet);
|
||||
}
|
||||
|
||||
private bool ContainsNonEmptyISO9660FileSystem(
|
||||
GenericImageConverter.TrackFile trackFile,
|
||||
uint lba)
|
||||
{
|
||||
IDiscTrack discTrack = (IDiscTrack) new DiscTrack(trackFile.FileName, 0L, trackFile.Length, lba, trackFile.Index, TrackModeType.Data, this.discSector);
|
||||
using (DiscImageReader discImageReader = new DiscImageReader())
|
||||
{
|
||||
try
|
||||
{
|
||||
discImageReader.Open(discTrack.FileInputStream, discTrack.LogicalBlockAddress, this.discSector);
|
||||
return discImageReader.RootDirectoryRecord.UsedSpace > 0U;
|
||||
}
|
||||
catch (DiscImageReaderException ex)
|
||||
{
|
||||
logger.Error(ex);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private InitialProgram GetInitialProgram(string imageFileName, IDiscSector sector)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] buffer;
|
||||
using (DiscSectorStream discSectorStream = new DiscSectorStream(imageFileName, sector, 0U, InitialProgram.IP_FILESIZE))
|
||||
{
|
||||
buffer = new byte[discSectorStream.Length];
|
||||
discSectorStream.Read(buffer, 0, buffer.Length);
|
||||
}
|
||||
return InitialProgramConverter.ToInitialProgram(buffer, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
return (InitialProgram) null;
|
||||
}
|
||||
|
||||
private GenericImageConverter.TrackFile FindNextImageFile(string fileName)
|
||||
{
|
||||
int startIndex = this.GetIndexFromFileName(fileName);
|
||||
if (startIndex == GenericImageConverter.INVALID_FILE_INDEX)
|
||||
return (GenericImageConverter.TrackFile) null;
|
||||
string prefixFromFileName = this.GetFileNamePrefixFromFileName(fileName);
|
||||
if (string.IsNullOrEmpty(prefixFromFileName))
|
||||
return (GenericImageConverter.TrackFile) null;
|
||||
string[] array = ((IEnumerable<string>) Directory.GetFiles(Path.GetDirectoryName(fileName), prefixFromFileName + "*" + Path.GetExtension(fileName))).Where<string>((Func<string, bool>) (FilePath => this.GetIndexFromFileName(FilePath) > startIndex)).ToArray<string>();
|
||||
if (array.Length <= 0)
|
||||
return (GenericImageConverter.TrackFile) null;
|
||||
string fileName1 = array[0];
|
||||
return new GenericImageConverter.TrackFile(this.GetIndexFromFileName(fileName1), fileName1);
|
||||
}
|
||||
|
||||
private string GetFileNamePrefixFromFileName(string fileName)
|
||||
{
|
||||
string withoutExtension = Path.GetFileNameWithoutExtension(fileName);
|
||||
Match match = GenericImageConverter.FIND_NEXT_FILE.Match(withoutExtension);
|
||||
return match.Success ? match.Groups["prefix"].Value : string.Empty;
|
||||
}
|
||||
|
||||
private int GetIndexFromFileName(string fileName)
|
||||
{
|
||||
string withoutExtension = Path.GetFileNameWithoutExtension(fileName);
|
||||
Match match = GenericImageConverter.FIND_NEXT_FILE.Match(withoutExtension);
|
||||
return match.Success ? int.Parse(match.Groups["index"].Value) : GenericImageConverter.INVALID_FILE_INDEX;
|
||||
}
|
||||
|
||||
private class TrackFile
|
||||
{
|
||||
public int Index { get; private set; }
|
||||
|
||||
public long Length { get; private set; }
|
||||
|
||||
public string FileName { get; private set; }
|
||||
|
||||
public TrackFile(int index, string fileName)
|
||||
{
|
||||
this.Index = index;
|
||||
this.FileName = fileName;
|
||||
this.Length = new FileInfo(fileName).Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
45
SEGATools/DiscFileSystem/IDiscFileSystem.cs
Normal file
45
SEGATools/DiscFileSystem/IDiscFileSystem.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.IDiscFileSystem
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.ISO9660.DirectoryRecords;
|
||||
using ImageReader.Stream;
|
||||
using SEGATools.Binary;
|
||||
using SEGATools.Encrypt;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
public interface IDiscFileSystem
|
||||
{
|
||||
bool CanExtractData { get; }
|
||||
|
||||
bool CanBeExportedToCueSheet { get; }
|
||||
|
||||
bool CanBeExportedToGdi { get; }
|
||||
|
||||
List<IDiscSession> Sessions { get; }
|
||||
|
||||
string FileName { get; }
|
||||
|
||||
string DiscName { get; set; }
|
||||
|
||||
DirectoryRecord MainBinary { get; set; }
|
||||
|
||||
DiscImageType DiscType { get; set; }
|
||||
|
||||
List<IDiscTrack> AllTracks { get; }
|
||||
|
||||
DiscSectorStream GetDiscStreamForDirectoryRecord(DirectoryRecord directoryRecord);
|
||||
|
||||
void RegisterLibraries(object file, List<SEGALibrary> Libraries);
|
||||
|
||||
List<SEGALibrary> GetSEGALibraries(object file);
|
||||
|
||||
DESKey NaomiDESKey { get; set; }
|
||||
|
||||
void Close();
|
||||
}
|
||||
}
|
13
SEGATools/DiscFileSystem/IDiscFileSystemConverter.cs
Normal file
13
SEGATools/DiscFileSystem/IDiscFileSystemConverter.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.IDiscFileSystemConverter
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
public interface IDiscFileSystemConverter
|
||||
{
|
||||
IDiscFileSystem ToDiscFileSystem(string imageFileName);
|
||||
}
|
||||
}
|
42
SEGATools/DiscFileSystem/IDiscSession.cs
Normal file
42
SEGATools/DiscFileSystem/IDiscSession.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.IDiscSession
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.ISO9660.DirectoryRecords;
|
||||
using ImageReader.ISO9660.VolumeDescriptors;
|
||||
using SEGATools.Security;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
public interface IDiscSession
|
||||
{
|
||||
List<IDiscTrack> Tracks { get; }
|
||||
|
||||
List<IDiscTrack> DataTracks { get; }
|
||||
|
||||
IDiscTrack FirstDataTrack { get; }
|
||||
|
||||
IDiscTrack LastDataTrack { get; }
|
||||
|
||||
List<IDiscTrack> AudioTracks { get; }
|
||||
|
||||
int Index { get; }
|
||||
|
||||
string Name { get; }
|
||||
|
||||
DirectoryRecord MainBinary { get; set; }
|
||||
|
||||
InitialProgram BootStrap { get; set; }
|
||||
|
||||
PrimaryVolumeDescriptor PrimaryVolumeDescriptor { get; set; }
|
||||
|
||||
DirectoryRecord RootDirectoryRecord { get; set; }
|
||||
|
||||
IDiscFileSystem Disc { get; set; }
|
||||
|
||||
void Close();
|
||||
}
|
||||
}
|
35
SEGATools/DiscFileSystem/IDiscTrack.cs
Normal file
35
SEGATools/DiscFileSystem/IDiscTrack.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.IDiscTrack
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
using SEGATools.VirtualFile;
|
||||
using System;
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
public interface IDiscTrack : IVirtualFile, IDisposable
|
||||
{
|
||||
string FileName { get; }
|
||||
|
||||
string Name { get; }
|
||||
|
||||
int Index { get; }
|
||||
|
||||
long Length { get; }
|
||||
|
||||
uint LogicalBlockAddress { get; }
|
||||
|
||||
long Offset { get; }
|
||||
|
||||
TrackModeType TrackData { get; }
|
||||
|
||||
IDiscSector TrackSector { get; }
|
||||
|
||||
IDiscSession Session { get; set; }
|
||||
|
||||
void Close();
|
||||
}
|
||||
}
|
14
SEGATools/DiscFileSystem/TrackModeType.cs
Normal file
14
SEGATools/DiscFileSystem/TrackModeType.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.DiscFileSystem.TrackModeType
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.DiscFileSystem
|
||||
{
|
||||
public enum TrackModeType : short
|
||||
{
|
||||
Audio = 0,
|
||||
Data = 4,
|
||||
}
|
||||
}
|
80
SEGATools/Encrypt/DESKey.cs
Normal file
80
SEGATools/Encrypt/DESKey.cs
Normal file
|
@ -0,0 +1,80 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Encrypt.DESKey
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SEGATools.Encrypt
|
||||
{
|
||||
public class DESKey
|
||||
{
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
|
||||
private static readonly byte[] DEFAULT_NAOMI_IV = new byte[8];
|
||||
private static readonly Regex VALID_KEY_STRING = new Regex("[a-f0-9]{16}", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
public byte[] Key { get; private set; }
|
||||
|
||||
public byte[] IV => DESKey.DEFAULT_NAOMI_IV;
|
||||
|
||||
public ICryptoTransform DecryptionCryptoTransform { get; private set; }
|
||||
|
||||
public ICryptoTransform EncryptionCryptoTransform { get; private set; }
|
||||
|
||||
private DESKey(
|
||||
byte[] Key,
|
||||
ICryptoTransform encryptionCryptoTransform,
|
||||
ICryptoTransform decryptionCryptoTransform)
|
||||
{
|
||||
this.Key = Key;
|
||||
this.EncryptionCryptoTransform = encryptionCryptoTransform;
|
||||
this.DecryptionCryptoTransform = decryptionCryptoTransform;
|
||||
}
|
||||
|
||||
public string KeyString => string.Format("{7:X}{6:X}{5:X}{4:X}{3:X}{2:X}{1:X}{0:X}", (object) this.Key[0], (object) this.Key[1], (object) this.Key[2], (object) this.Key[3], (object) this.Key[4], (object) this.Key[5], (object) this.Key[6], (object) this.Key[7]);
|
||||
|
||||
public override string ToString() => string.Format("DESKey: 0x{0}", (object) this.KeyString);
|
||||
|
||||
public static DESKey Parse(string key)
|
||||
{
|
||||
byte[] numArray = new byte[key.Length / 2];
|
||||
for (int index = 0; index < numArray.Length; ++index)
|
||||
{
|
||||
numArray[index] = (byte) ((key[2 * index] > 'F' ? (int) key[2 * index] - 87 : (key[2 * index] > '9' ? (int) key[2 * index] - 55 : (int) key[2 * index] - 48)) << 4);
|
||||
numArray[index] |= key[2 * index + 1] > 'F' ? (byte) ((int) key[2 * index + 1] - 87) : (key[2 * index + 1] > '9' ? (byte) ((int) key[2 * index + 1] - 55) : (byte) ((int) key[2 * index + 1] - 48));
|
||||
}
|
||||
if (BitConverter.IsLittleEndian)
|
||||
Array.Reverse((Array) numArray);
|
||||
DES des = (DES) new DESCryptoServiceProvider();
|
||||
des.KeySize = 64;
|
||||
des.Padding = PaddingMode.None;
|
||||
des.Mode = CipherMode.ECB;
|
||||
ICryptoTransform encryptor = des.CreateEncryptor(numArray, DESKey.DEFAULT_NAOMI_IV);
|
||||
ICryptoTransform decryptor = des.CreateDecryptor(numArray, DESKey.DEFAULT_NAOMI_IV);
|
||||
return new DESKey(numArray, encryptor, decryptor);
|
||||
}
|
||||
|
||||
public static bool TryParse(string key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
return false;
|
||||
string str = key.Trim();
|
||||
if (!DESKey.VALID_KEY_STRING.Match(str).Success)
|
||||
return false;
|
||||
try
|
||||
{
|
||||
DESKey.Parse(str);
|
||||
return true;
|
||||
}
|
||||
catch (CryptographicException ex)
|
||||
{
|
||||
logger.Error(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
SEGATools/Encrypt/DesEncryptDecryptTool.cs
Normal file
133
SEGATools/Encrypt/DesEncryptDecryptTool.cs
Normal file
|
@ -0,0 +1,133 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Encrypt.DesEncryptDecryptTool
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.UserProcess;
|
||||
using SEGATools.VirtualFile;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace SEGATools.Encrypt
|
||||
{
|
||||
public class DesEncryptDecryptTool : UserProcessBase
|
||||
{
|
||||
private const int BUFFER_SIZE = 65536;
|
||||
|
||||
public event AsyncOperationProgressChangedEventHandler DecryptionProgressChanged
|
||||
{
|
||||
add => this.AsyncOperationProgressChanged += value;
|
||||
remove => this.AsyncOperationProgressChanged -= value;
|
||||
}
|
||||
|
||||
public event AsyncOperationCompletedEventHandler DecryptionCompleted
|
||||
{
|
||||
add => this.AsyncOperationCompleted += value;
|
||||
remove => this.AsyncOperationCompleted -= value;
|
||||
}
|
||||
|
||||
public void EncryptAsync(
|
||||
IVirtualFile inputFile,
|
||||
IVirtualFile outputFile,
|
||||
DESKey Key,
|
||||
object taskId)
|
||||
{
|
||||
AsyncOperation asyncOperation = this.CreateAsyncOperation(taskId);
|
||||
new DesEncryptDecryptTool.WorkerEventHandler(this.EncryptOrDecryptWorker).BeginInvoke(inputFile, outputFile, Key.EncryptionCryptoTransform, asyncOperation, (AsyncCallback) null, (object) null);
|
||||
}
|
||||
|
||||
public void DecryptAsync(
|
||||
IVirtualFile inputFile,
|
||||
IVirtualFile outputFile,
|
||||
DESKey Key,
|
||||
object taskId)
|
||||
{
|
||||
AsyncOperation asyncOperation = this.CreateAsyncOperation(taskId);
|
||||
new DesEncryptDecryptTool.WorkerEventHandler(this.EncryptOrDecryptWorker).BeginInvoke(inputFile, outputFile, Key.DecryptionCryptoTransform, asyncOperation, (AsyncCallback) null, (object) null);
|
||||
}
|
||||
|
||||
private void EncryptOrDecryptWorker(
|
||||
IVirtualFile inputFile,
|
||||
IVirtualFile outputFile,
|
||||
ICryptoTransform CryptoTransform,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
byte[] numArray = new byte[65536];
|
||||
Exception exception = (Exception) null;
|
||||
try
|
||||
{
|
||||
using (System.IO.Stream fileInputStream = inputFile.FileInputStream)
|
||||
{
|
||||
using (System.IO.Stream fileOutputStream = outputFile.FileOutputStream)
|
||||
{
|
||||
fileInputStream.Seek(0L, SeekOrigin.Begin);
|
||||
while (fileInputStream.Position < fileInputStream.Length)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(numArray))
|
||||
{
|
||||
using (CryptoStream CryptoStream = new CryptoStream((System.IO.Stream) memoryStream, CryptoTransform, CryptoStreamMode.Write))
|
||||
this.EncryptOrDecryptBuffer(numArray, CryptoStream, fileInputStream, fileOutputStream);
|
||||
}
|
||||
int num = (int) ((double) fileInputStream.Position / (double) fileInputStream.Length * 100.0);
|
||||
this.ReportProgress(new UserProcessProgressChangedEventArgs(inputFile.OriginalFileName, outputFile.OriginalFileName, num, num, asyncOp.UserSuppliedState), asyncOp);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
}
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
{
|
||||
if (exception == null)
|
||||
goto label_27;
|
||||
}
|
||||
try
|
||||
{
|
||||
File.Delete(outputFile.OriginalFileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UserProcessBase.logger.ErrorFormat("Unable to delete the file {0}: {1}", (object) outputFile.OriginalFileName, (object) ex.Message);
|
||||
}
|
||||
label_27:
|
||||
this.ReportCompletion(outputFile.OriginalFileName, exception, asyncOp);
|
||||
}
|
||||
|
||||
private void EncryptOrDecryptBuffer(
|
||||
byte[] Buffer,
|
||||
CryptoStream CryptoStream,
|
||||
System.IO.Stream InputStream,
|
||||
System.IO.Stream OutputStream)
|
||||
{
|
||||
int num1 = 0;
|
||||
int num2 = Buffer.Length / 8;
|
||||
InputStream.Read(Buffer, 0, Buffer.Length);
|
||||
while (num1 < num2)
|
||||
{
|
||||
int num3 = num1++ * 8;
|
||||
if (BitConverter.IsLittleEndian)
|
||||
Array.Reverse((Array) Buffer, num3, 8);
|
||||
CryptoStream.Write(Buffer, num3, 8);
|
||||
if (BitConverter.IsLittleEndian)
|
||||
Array.Reverse((Array) Buffer, num3, 8);
|
||||
}
|
||||
OutputStream.Write(Buffer, 0, Buffer.Length);
|
||||
}
|
||||
|
||||
private delegate void WorkerEventHandler(
|
||||
IVirtualFile inputFile,
|
||||
IVirtualFile outputFile,
|
||||
ICryptoTransform CryptoTransform,
|
||||
AsyncOperation asyncOp);
|
||||
}
|
||||
}
|
33
SEGATools/FileFormat/AbstractImageFileFormat.cs
Normal file
33
SEGATools/FileFormat/AbstractImageFileFormat.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.FileFormat.AbstractImageFileFormat
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.DiscFileSystem;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace SEGATools.FileFormat
|
||||
{
|
||||
public abstract class AbstractImageFileFormat : IImageFileFormat
|
||||
{
|
||||
public abstract string[] FileExtentions { get; }
|
||||
|
||||
public abstract string[] FileExtentionDescriptions { get; }
|
||||
|
||||
public abstract IDiscFileSystemConverter ImageFileConverter { get; }
|
||||
|
||||
public string PluginAssemblyFileName { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || !typeof (IImageFileFormat).IsAssignableFrom(obj.GetType()))
|
||||
return false;
|
||||
IImageFileFormat imageFileFormat = (IImageFileFormat) obj;
|
||||
return ((IEnumerable<string>) this.FileExtentions).SequenceEqual<string>((IEnumerable<string>) imageFileFormat.FileExtentions) && ((IEnumerable<string>) this.FileExtentionDescriptions).SequenceEqual<string>((IEnumerable<string>) imageFileFormat.FileExtentionDescriptions);
|
||||
}
|
||||
|
||||
public override int GetHashCode() => 1 + 17 * this.FileExtentions.GetHashCode() + 31 * this.FileExtentionDescriptions.GetHashCode();
|
||||
}
|
||||
}
|
21
SEGATools/FileFormat/IImageFileFormat.cs
Normal file
21
SEGATools/FileFormat/IImageFileFormat.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.FileFormat.IImageFileFormat
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.DiscFileSystem;
|
||||
|
||||
namespace SEGATools.FileFormat
|
||||
{
|
||||
public interface IImageFileFormat
|
||||
{
|
||||
string[] FileExtentions { get; }
|
||||
|
||||
string[] FileExtentionDescriptions { get; }
|
||||
|
||||
IDiscFileSystemConverter ImageFileConverter { get; }
|
||||
|
||||
string PluginAssemblyFileName { get; set; }
|
||||
}
|
||||
}
|
27
SEGATools/Formater/SizeFormater.cs
Normal file
27
SEGATools/Formater/SizeFormater.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Formater.SizeFormater
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Formater
|
||||
{
|
||||
public static class SizeFormater
|
||||
{
|
||||
public static string ToHumanReadableSize(long Size)
|
||||
{
|
||||
double num = Convert.ToDouble(Size);
|
||||
if (num >= Math.Pow(1024.0, 4.0))
|
||||
return Math.Round(num / Math.Pow(1024.0, 4.0), 2).ToString() + " TB";
|
||||
if (num >= Math.Pow(1024.0, 3.0))
|
||||
return Math.Round(num / Math.Pow(1024.0, 3.0), 2).ToString() + " GB";
|
||||
if (num >= Math.Pow(1024.0, 2.0))
|
||||
return Math.Round(num / Math.Pow(1024.0, 2.0), 2).ToString() + " MB";
|
||||
if (num >= 1024.0)
|
||||
return Math.Round(num / 1024.0, 2).ToString() + " KB";
|
||||
return num == 0.0 ? num.ToString() + " Byte" : num.ToString() + " Bytes";
|
||||
}
|
||||
}
|
||||
}
|
55
SEGATools/GDEmu/DiscTrackCopyInfo.cs
Normal file
55
SEGATools/GDEmu/DiscTrackCopyInfo.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.GDEmu.DiscTrackCopyInfo
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
using SEGATools.Binary;
|
||||
using SEGATools.DiscFileSystem;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace SEGATools.GDEmu
|
||||
{
|
||||
internal class DiscTrackCopyInfo
|
||||
{
|
||||
private HashSet<BinaryPatch> patchesApplied;
|
||||
|
||||
public IDiscTrack SourceTrack { get; private set; }
|
||||
|
||||
public IDiscTrack DestinationTrack { get; private set; }
|
||||
|
||||
public int[] ModifiedSectors
|
||||
{
|
||||
get
|
||||
{
|
||||
HashSet<int> source = new HashSet<int>();
|
||||
foreach (BinaryPatch binaryPatch in this.patchesApplied)
|
||||
{
|
||||
int num1 = (int) binaryPatch.Offset / DiscSectorCommon.LogicalSectorSize;
|
||||
int num2 = (int) (binaryPatch.Offset + (long) binaryPatch.Data.Length) / DiscSectorCommon.LogicalSectorSize;
|
||||
for (int index = num1; index <= num2; ++index)
|
||||
source.Add(index);
|
||||
}
|
||||
return source.ToArray<int>();
|
||||
}
|
||||
}
|
||||
|
||||
public static DiscTrackCopyInfo CreateFrom(
|
||||
IDiscTrack source,
|
||||
string newFileName)
|
||||
{
|
||||
return new DiscTrackCopyInfo(source, DiscTrack.CreateCopyFrom(source, newFileName));
|
||||
}
|
||||
|
||||
private DiscTrackCopyInfo(IDiscTrack source, IDiscTrack destination)
|
||||
{
|
||||
this.SourceTrack = source;
|
||||
this.DestinationTrack = destination;
|
||||
this.patchesApplied = new HashSet<BinaryPatch>();
|
||||
}
|
||||
|
||||
public void AddPatches(params BinaryPatch[] patches) => this.patchesApplied.UnionWith((IEnumerable<BinaryPatch>) patches);
|
||||
}
|
||||
}
|
328
SEGATools/GDEmu/GDEmuConverter.cs
Normal file
328
SEGATools/GDEmu/GDEmuConverter.cs
Normal file
|
@ -0,0 +1,328 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.GDEmu.GDEmuConverter
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
using ImageReader.Stream;
|
||||
using SEGATools.Binary;
|
||||
using SEGATools.Disc;
|
||||
using SEGATools.DiscFileSystem;
|
||||
using SEGATools.UserProcess;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace SEGATools.GDEmu
|
||||
{
|
||||
public class GDEmuConverter : UserProcessBase
|
||||
{
|
||||
private static readonly int OutputFileStreamBuffer = 524288;
|
||||
private static readonly string FileConflictQuestionTitle = "GDEmuExporterFileConflictQuestionTitle";
|
||||
private static readonly string FileConflictQuestionContent = "GDEmuExporterFileConflictQuestionContent";
|
||||
private static readonly string BinaryPatcherHint = "GDEmuExporterBinaryPatcherHint";
|
||||
private static readonly string DiscSectorEncoderHint = "GDEmuExporterDiscSectorEncoderHint";
|
||||
private BinaryPatcher binaryPatcher = new BinaryPatcher();
|
||||
private DiscSectorEncoder discSectorEncoder = new DiscSectorEncoder();
|
||||
|
||||
public event AsyncOperationProgressChangedEventHandler ConversionProgressChanged
|
||||
{
|
||||
add => this.AsyncOperationProgressChanged += value;
|
||||
remove => this.AsyncOperationProgressChanged -= value;
|
||||
}
|
||||
|
||||
public event AsyncOperationCompletedEventHandler ConversionCompleted
|
||||
{
|
||||
add => this.AsyncOperationCompleted += value;
|
||||
remove => this.AsyncOperationCompleted -= value;
|
||||
}
|
||||
|
||||
public GDEmuConverter()
|
||||
{
|
||||
}
|
||||
|
||||
public GDEmuConverter(IContainer container)
|
||||
: base(container)
|
||||
{
|
||||
}
|
||||
|
||||
public void ConvertAsync(
|
||||
IDiscFileSystem GDIImageFile,
|
||||
GDEmuExportOptions ExportOptions,
|
||||
object taskId)
|
||||
{
|
||||
AsyncOperation asyncOperation = this.CreateAsyncOperation(taskId);
|
||||
new GDEmuConverter.FileConverterWorkerEventHandler(this.FileConverterWorker).BeginInvoke(GDIImageFile, ExportOptions, asyncOperation, (AsyncCallback) null, (object) null);
|
||||
}
|
||||
|
||||
private void FileConverterWorker(
|
||||
IDiscFileSystem GDIImageFile,
|
||||
GDEmuExportOptions ExportOption,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
Exception exception = (Exception) null;
|
||||
HashSet<DiscTrackCopyInfo> trackOutputFiles = this.GetTrackOutputFiles(GDIImageFile, ExportOption);
|
||||
List<string> stringList = new List<string>();
|
||||
this.CheckForFileConflict(ExportOption, trackOutputFiles, asyncOp);
|
||||
if (this.TaskCanceled(asyncOp))
|
||||
{
|
||||
this.DoExtractionCleanupIfNeeded(stringList.ToArray(), exception, asyncOp);
|
||||
this.ReportCompletion(ExportOption.OutputPath, exception, asyncOp);
|
||||
}
|
||||
else
|
||||
{
|
||||
long requiredSpaceInBytes = this.ComputeRequiredSpaceInBytes(trackOutputFiles);
|
||||
long ofBytesToExtract = this.ComputeNumberOfBytesToExtract(trackOutputFiles);
|
||||
long totalNumberOfBytesRemaining = ofBytesToExtract;
|
||||
try
|
||||
{
|
||||
this.CheckForEnoughFreeDiscSpace(requiredSpaceInBytes, ExportOption.OutputPath);
|
||||
GDICreator.CreateGDIFile(GDIImageFile.AllTracks, ExportOption.GetOutputGDIFilePath());
|
||||
stringList.Add(ExportOption.GetOutputGDIFilePath());
|
||||
foreach (DiscTrackCopyInfo track in trackOutputFiles)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
{
|
||||
stringList.Add(track.DestinationTrack.FileName);
|
||||
totalNumberOfBytesRemaining = this.CopyTrack(track, ofBytesToExtract, totalNumberOfBytesRemaining, asyncOp);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
this.ApplyExportPatches(GDIImageFile, ExportOption, trackOutputFiles, asyncOp);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
UserProcessBase.logger.ErrorFormat("Unable to copy the track: {0}", (object) exception);
|
||||
}
|
||||
this.DoExtractionCleanupIfNeeded(stringList.ToArray(), exception, asyncOp);
|
||||
this.ReportCompletion(ExportOption.OutputPath, exception, asyncOp);
|
||||
}
|
||||
}
|
||||
|
||||
private long ComputeNumberOfBytesToExtract(HashSet<DiscTrackCopyInfo> tracks)
|
||||
{
|
||||
long num = 0;
|
||||
foreach (DiscTrackCopyInfo track in tracks)
|
||||
num += track.SourceTrack.Length;
|
||||
return num;
|
||||
}
|
||||
|
||||
private long ComputeRequiredSpaceInBytes(HashSet<DiscTrackCopyInfo> tracks)
|
||||
{
|
||||
long num = 0;
|
||||
foreach (DiscTrackCopyInfo track in tracks)
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(track.DestinationTrack.FileName);
|
||||
num += track.SourceTrack.Length;
|
||||
if (fileInfo.Exists)
|
||||
num -= fileInfo.Length;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
private void CheckForEnoughFreeDiscSpace(long requiredSpaceInBytes, string outputPath)
|
||||
{
|
||||
if (requiredSpaceInBytes > new DriveInfo(outputPath.Substring(0, 3)).AvailableFreeSpace)
|
||||
{
|
||||
UserProcessBase.logger.ErrorFormat("Extraction requires {0} bytes of free disc space in drive {1}", (object) requiredSpaceInBytes, (object) outputPath.Substring(0, 3));
|
||||
throw new IOException("Not enough free disc space!");
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckForFileConflict(
|
||||
GDEmuExportOptions exportOptions,
|
||||
HashSet<DiscTrackCopyInfo> inputFiles,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
List<string> stringList = new List<string>();
|
||||
if (File.Exists(exportOptions.GetOutputGDIFilePath()))
|
||||
stringList.Add(exportOptions.GetOutputGDIFilePath());
|
||||
foreach (DiscTrackCopyInfo inputFile in inputFiles)
|
||||
{
|
||||
if (File.Exists(inputFile.DestinationTrack.FileName))
|
||||
stringList.Add(inputFile.DestinationTrack.FileName);
|
||||
}
|
||||
if (stringList.Count == 0)
|
||||
return;
|
||||
this.AskForUserConsent(GDEmuConverter.GetNotifyFileConflictEventArgs(stringList.ToArray(), asyncOp), asyncOp);
|
||||
}
|
||||
|
||||
private long CopyTrack(
|
||||
DiscTrackCopyInfo track,
|
||||
long totalNumberOfBytesToExtract,
|
||||
long totalNumberOfBytesRemaining,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
using (System.IO.Stream fileInputStream = track.SourceTrack.FileInputStream)
|
||||
{
|
||||
using (System.IO.Stream fileOutputStream = track.DestinationTrack.FileOutputStream)
|
||||
{
|
||||
long length = fileInputStream.Length;
|
||||
byte[] buffer = new byte[GDEmuConverter.OutputFileStreamBuffer];
|
||||
while (length > 0L)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
{
|
||||
int count = fileInputStream.Read(buffer, 0, buffer.Length);
|
||||
length -= (long) count;
|
||||
totalNumberOfBytesRemaining -= (long) count;
|
||||
fileOutputStream.Write(buffer, 0, count);
|
||||
this.ReportProgress(GDEmuConverter.CreateProgressChangedEventArgs(track.SourceTrack.FileName, track.DestinationTrack.FileName, fileInputStream.Length, length, totalNumberOfBytesToExtract, totalNumberOfBytesRemaining, asyncOp), asyncOp);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return totalNumberOfBytesRemaining;
|
||||
}
|
||||
|
||||
private void ApplyExportPatches(
|
||||
IDiscFileSystem GDIImageFile,
|
||||
GDEmuExportOptions ExportOption,
|
||||
HashSet<DiscTrackCopyInfo> OutputTrackFiles,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
if (!ExportOption.ForceVGA && !ExportOption.RegionFree)
|
||||
{
|
||||
UserProcessBase.logger.Info((object) "No patch to apply");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.UpdateViewForBinaryPatcherStep(asyncOp);
|
||||
if (ExportOption.ForceVGA)
|
||||
this.ApplyVGAPatch(OutputTrackFiles, asyncOp);
|
||||
if (ExportOption.RegionFree)
|
||||
this.ApplyRegionFreePatch(OutputTrackFiles, asyncOp);
|
||||
if (this.TaskCanceled(asyncOp))
|
||||
return;
|
||||
this.CorrectModifiedSectors(OutputTrackFiles, asyncOp);
|
||||
}
|
||||
}
|
||||
|
||||
private void CorrectModifiedSectors(HashSet<DiscTrackCopyInfo> tracks, AsyncOperation asyncOp)
|
||||
{
|
||||
this.UpdateViewForDiscSectorEncoderStep(asyncOp);
|
||||
foreach (DiscTrackCopyInfo track in tracks.Where<DiscTrackCopyInfo>((Func<DiscTrackCopyInfo, bool>) (track => track.SourceTrack.TrackData == TrackModeType.Data && track.SourceTrack.TrackSector.GetType() == typeof (CDROMMode1RawSector))))
|
||||
{
|
||||
this.ReportPatchOrErrorDataEncoderProgress(track, asyncOp);
|
||||
if (this.TaskCanceled(asyncOp))
|
||||
break;
|
||||
using (System.IO.Stream fileOutputStream = track.DestinationTrack.FileOutputStream)
|
||||
this.discSectorEncoder.EncodeMode1Sectors(fileOutputStream, track.ModifiedSectors);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyPatches(DiscTrackCopyInfo track, BinaryPatch[] patches)
|
||||
{
|
||||
using (DiscSectorStream discSectorStream = new DiscSectorStream(track.DestinationTrack.FileOutputStream, track.DestinationTrack.TrackSector))
|
||||
this.binaryPatcher.ApplyPatches((System.IO.Stream) discSectorStream, patches);
|
||||
track.AddPatches(patches);
|
||||
}
|
||||
|
||||
private void ApplyVGAPatch(HashSet<DiscTrackCopyInfo> OutputTrackFiles, AsyncOperation asyncOp)
|
||||
{
|
||||
DiscTrackCopyInfo track1 = OutputTrackFiles.First<DiscTrackCopyInfo>((Func<DiscTrackCopyInfo, bool>) (track => track.SourceTrack.Index == 1));
|
||||
UserProcessBase.logger.InfoFormat("Applying VGA flag patches on {0}", (object) track1);
|
||||
this.ReportPatchOrErrorDataEncoderProgress(track1, asyncOp);
|
||||
this.ApplyPatches(track1, InitialProgramPatches.VGAFlagPatchesForTrack1);
|
||||
DiscTrackCopyInfo track2 = OutputTrackFiles.First<DiscTrackCopyInfo>((Func<DiscTrackCopyInfo, bool>) (track => track.SourceTrack.Index == 3));
|
||||
UserProcessBase.logger.InfoFormat("Applying VGA flag patches on {0}", (object) track2);
|
||||
this.ReportPatchOrErrorDataEncoderProgress(track2, asyncOp);
|
||||
this.ApplyPatches(track2, InitialProgramPatches.VGAFlagPatchesForTrack3);
|
||||
}
|
||||
|
||||
private void ApplyRegionFreePatch(
|
||||
HashSet<DiscTrackCopyInfo> OutputTrackFiles,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
DiscTrackCopyInfo track1 = OutputTrackFiles.First<DiscTrackCopyInfo>((Func<DiscTrackCopyInfo, bool>) (track => track.SourceTrack.Index == 1));
|
||||
UserProcessBase.logger.InfoFormat("Applying region free patches on {0}", (object) track1);
|
||||
this.ReportPatchOrErrorDataEncoderProgress(track1, asyncOp);
|
||||
this.ApplyPatches(track1, InitialProgramPatches.RegionFreePatchesForTrack1);
|
||||
DiscTrackCopyInfo track2 = OutputTrackFiles.First<DiscTrackCopyInfo>((Func<DiscTrackCopyInfo, bool>) (track => track.SourceTrack.Index == 3));
|
||||
UserProcessBase.logger.InfoFormat("Applying region free patches on {0}", (object) track2);
|
||||
this.ReportPatchOrErrorDataEncoderProgress(track2, asyncOp);
|
||||
this.ApplyPatches(track2, InitialProgramPatches.RegionFreePatchesForTrack3);
|
||||
}
|
||||
|
||||
private HashSet<DiscTrackCopyInfo> GetTrackOutputFiles(
|
||||
IDiscFileSystem GDIImageFile,
|
||||
GDEmuExportOptions ExportOption)
|
||||
{
|
||||
HashSet<DiscTrackCopyInfo> discTrackCopyInfoSet = new HashSet<DiscTrackCopyInfo>();
|
||||
foreach (IDiscTrack allTrack in GDIImageFile.AllTracks)
|
||||
{
|
||||
string newFileName = Path.Combine(ExportOption.OutputPath, allTrack.VirtualName);
|
||||
discTrackCopyInfoSet.Add(DiscTrackCopyInfo.CreateFrom(allTrack, newFileName));
|
||||
}
|
||||
return discTrackCopyInfoSet;
|
||||
}
|
||||
|
||||
private void DoExtractionCleanupIfNeeded(
|
||||
string[] fileToDelete,
|
||||
Exception exception,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
if (!this.TaskCanceled(asyncOp) && exception == null)
|
||||
return;
|
||||
foreach (string path in fileToDelete)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UserProcessBase.logger.ErrorFormat("Unable to delete the file {0}: {1}", (object) path, (object) ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static UserProcessProgressChangedEventArgs CreateProgressChangedEventArgs(
|
||||
string input,
|
||||
string output,
|
||||
long numberOfBytesToExtract,
|
||||
long remainingBytesToExtract,
|
||||
long totalNumberOfBytesToExtract,
|
||||
long totalNumberOfBytesRemaining,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
int progressPercentage = (int) ((double) (numberOfBytesToExtract - remainingBytesToExtract) / (double) numberOfBytesToExtract * 100.0);
|
||||
int totalProgressPercentage = (int) ((double) (totalNumberOfBytesToExtract - totalNumberOfBytesRemaining) / (double) totalNumberOfBytesToExtract * 100.0);
|
||||
return new UserProcessProgressChangedEventArgs(input, output, progressPercentage, totalProgressPercentage, asyncOp.UserSuppliedState);
|
||||
}
|
||||
|
||||
private static UserProcessWaitingForUserConsentEventArgs GetNotifyFileConflictEventArgs(
|
||||
string[] files,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
return (UserProcessWaitingForUserConsentEventArgs) new UserProcessWaitingForUserConsentFileConflictEventArgs(GDEmuConverter.FileConflictQuestionTitle, GDEmuConverter.FileConflictQuestionContent, files, (object) asyncOp);
|
||||
}
|
||||
|
||||
private void ReportPatchOrErrorDataEncoderProgress(
|
||||
DiscTrackCopyInfo track,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
this.ReportProgress(new UserProcessProgressChangedEventArgs(track.SourceTrack.FileName, track.DestinationTrack.FileName, 100, 100, asyncOp.UserSuppliedState), asyncOp);
|
||||
}
|
||||
|
||||
private void UpdateViewForBinaryPatcherStep(AsyncOperation asyncOp) => this.UpdateUIView(UserProcessUpdateUIViewEventArgs.OneProgressBarWithoutPercentage(GDEmuConverter.BinaryPatcherHint, false), asyncOp);
|
||||
|
||||
private void UpdateViewForDiscSectorEncoderStep(AsyncOperation asyncOp) => this.UpdateUIView(UserProcessUpdateUIViewEventArgs.OneProgressBarWithoutPercentage(GDEmuConverter.DiscSectorEncoderHint, false), asyncOp);
|
||||
|
||||
private delegate void FileConverterWorkerEventHandler(
|
||||
IDiscFileSystem imageFile,
|
||||
GDEmuExportOptions ExportOption,
|
||||
AsyncOperation asyncOp);
|
||||
}
|
||||
}
|
22
SEGATools/GDEmu/GDEmuExportOptions.cs
Normal file
22
SEGATools/GDEmu/GDEmuExportOptions.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.GDEmu.GDEmuExportOptions
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System.IO;
|
||||
|
||||
namespace SEGATools.GDEmu
|
||||
{
|
||||
public class GDEmuExportOptions
|
||||
{
|
||||
private static readonly string GDEMU_DEFAULT_DISC_IMAGE_FILE_NAME = "disc.gdi";
|
||||
public bool RegionFree;
|
||||
public bool ForceVGA;
|
||||
public string OutputPath;
|
||||
|
||||
public string GDIFileName => GDEmuExportOptions.GDEMU_DEFAULT_DISC_IMAGE_FILE_NAME;
|
||||
|
||||
public string GetOutputGDIFilePath() => Path.Combine(this.OutputPath, this.GDIFileName);
|
||||
}
|
||||
}
|
31
SEGATools/GDEmu/GDICreator.cs
Normal file
31
SEGATools/GDEmu/GDICreator.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.GDEmu.GDICreator
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.DiscFileSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace SEGATools.GDEmu
|
||||
{
|
||||
public class GDICreator
|
||||
{
|
||||
public static void CreateGDIFile(List<IDiscTrack> Tracks, string OutputGDIFile)
|
||||
{
|
||||
List<IDiscTrack> list = Tracks.OrderBy<IDiscTrack, uint>((Func<IDiscTrack, uint>) (track => track.LogicalBlockAddress)).ToList<IDiscTrack>();
|
||||
using (StreamWriter streamWriter = new StreamWriter(OutputGDIFile))
|
||||
{
|
||||
streamWriter.WriteLine(list.Count);
|
||||
for (int index = 0; index < list.Count; ++index)
|
||||
{
|
||||
IDiscTrack discTrack = list[index];
|
||||
streamWriter.WriteLine("{0} {1} {2} {3} {4} {5}", (object) (index + 1), (object) discTrack.LogicalBlockAddress, (object) (short) discTrack.TrackData, (object) discTrack.TrackSector.Size, (object) discTrack.VirtualName, (object) discTrack.Offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
74
SEGATools/Graphics/MRImage.cs
Normal file
74
SEGATools/Graphics/MRImage.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Graphics.MRImage
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
|
||||
namespace SEGATools.Graphics
|
||||
{
|
||||
public class MRImage
|
||||
{
|
||||
private MRImageHeader header;
|
||||
private Bitmap imageBitmap;
|
||||
|
||||
public Size ImageSize => new Size(this.header.Width, this.header.Height);
|
||||
|
||||
public int UncompressedSize => this.Pixels.Length;
|
||||
|
||||
public int FileSize => this.header.Size;
|
||||
|
||||
public int CompressedSize => this.header.Size - this.header.Offset;
|
||||
|
||||
public float CompressionRatio => (float) this.UncompressedSize / (float) this.CompressedSize;
|
||||
|
||||
public int Offset { get; private set; }
|
||||
|
||||
public byte[] Pixels { get; private set; }
|
||||
|
||||
public Color[] ColorPalette { get; private set; }
|
||||
|
||||
private byte[] RawData { get; set; }
|
||||
|
||||
public System.IO.Stream FileStream => (System.IO.Stream) new MemoryStream(this.RawData, 0, this.RawData.Length, false);
|
||||
|
||||
internal MRImage(
|
||||
MRImageHeader header,
|
||||
Color[] colorPalette,
|
||||
byte[] pixels,
|
||||
int offset,
|
||||
byte[] rawData)
|
||||
{
|
||||
this.header = header;
|
||||
this.ColorPalette = colorPalette;
|
||||
this.Pixels = pixels;
|
||||
this.Offset = offset;
|
||||
this.RawData = rawData;
|
||||
this.ToBitmap();
|
||||
}
|
||||
|
||||
private byte GetPixel(int x, int y) => this.Pixels[y * this.header.Width + x];
|
||||
|
||||
private Color GetColorForPixel(int x, int y) => this.ColorPalette[(int) this.GetPixel(x, y)];
|
||||
|
||||
public Bitmap ToBitmap()
|
||||
{
|
||||
if (this.imageBitmap != null)
|
||||
return this.imageBitmap;
|
||||
Bitmap bitmap = new Bitmap(this.ImageSize.Width, this.ImageSize.Height, PixelFormat.Format24bppRgb);
|
||||
for (int y = 0; y < bitmap.Height; ++y)
|
||||
{
|
||||
for (int x = 0; x < bitmap.Width; ++x)
|
||||
{
|
||||
Color colorForPixel = this.GetColorForPixel(x, y);
|
||||
bitmap.SetPixel(x, y, colorForPixel);
|
||||
}
|
||||
}
|
||||
this.imageBitmap = bitmap;
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
}
|
23
SEGATools/Graphics/MRImageColor.cs
Normal file
23
SEGATools/Graphics/MRImageColor.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Graphics.MRImageColor
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SEGATools.Graphics
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 4, Pack = 1)]
|
||||
internal struct MRImageColor
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
internal byte Blue;
|
||||
[FieldOffset(1)]
|
||||
internal byte Green;
|
||||
[FieldOffset(2)]
|
||||
internal byte Red;
|
||||
[FieldOffset(3)]
|
||||
internal byte Alpha;
|
||||
}
|
||||
}
|
117
SEGATools/Graphics/MRImageConverter.cs
Normal file
117
SEGATools/Graphics/MRImageConverter.cs
Normal file
|
@ -0,0 +1,117 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Graphics.MRImageConverter
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace SEGATools.Graphics
|
||||
{
|
||||
public class MRImageConverter
|
||||
{
|
||||
private static readonly string MR_ID = "MR";
|
||||
private static readonly int MR_HEADER_OFFSET = 2;
|
||||
private static readonly int MR_COLOR_PALETTE_OFFSET = MRImageConverter.MR_HEADER_OFFSET + 28;
|
||||
private static readonly int MR_HEADER_MINIMUM_SIZE = 30;
|
||||
private static readonly int MR_COLOR_SIZE = 4;
|
||||
|
||||
public static MRImage ToMRImage(byte[] buffer, int startIndex)
|
||||
{
|
||||
if (startIndex < 0 || buffer.Length - startIndex < MRImageConverter.MR_HEADER_MINIMUM_SIZE)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
string str = Encoding.ASCII.GetString(buffer, startIndex, MRImageConverter.MR_ID.Length);
|
||||
if (!MRImageConverter.MR_ID.Equals(str))
|
||||
throw new MRImageIdentifierMissingException("Wrong MR file identifier");
|
||||
MRImageHeader structure1 = (MRImageHeader) Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement((Array) buffer, startIndex + MRImageConverter.MR_HEADER_OFFSET), typeof (MRImageHeader));
|
||||
if (structure1.NumberOfColors <= 0U || (long) (buffer.Length - startIndex - MRImageConverter.MR_COLOR_PALETTE_OFFSET) < (long) structure1.NumberOfColors * (long) MRImageConverter.MR_COLOR_SIZE)
|
||||
throw new MRImageDecompressionException("Color palette too big");
|
||||
Color[] colorArray = new Color[(int) structure1.NumberOfColors];
|
||||
for (int index1 = 0; index1 < colorArray.Length; ++index1)
|
||||
{
|
||||
int index2 = startIndex + MRImageConverter.MR_COLOR_PALETTE_OFFSET + index1 * MRImageConverter.MR_COLOR_SIZE;
|
||||
MRImageColor structure2 = (MRImageColor) Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement((Array) buffer, index2), typeof (MRImageColor));
|
||||
colorArray[index1] = Color.FromArgb((int) structure2.Alpha, (int) structure2.Red, (int) structure2.Green, (int) structure2.Blue);
|
||||
}
|
||||
int length = structure1.Size - structure1.Offset;
|
||||
int startIndex1 = startIndex + structure1.Offset;
|
||||
try
|
||||
{
|
||||
byte[] rawData = new byte[structure1.Size];
|
||||
Buffer.BlockCopy((Array) buffer, startIndex, (Array) rawData, 0, rawData.Length);
|
||||
byte[] pixels = MRImageConverter.DecompressPixelData(structure1, colorArray, buffer, startIndex1, length);
|
||||
return new MRImage(structure1, colorArray, pixels, startIndex, rawData);
|
||||
}
|
||||
catch (MRImageUnknownColorException ex)
|
||||
{
|
||||
throw new MRImageDecompressionException("Unable to decompress the image", (Exception) ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new MRImageDecompressionException("Unable to decompress the image", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] DecompressPixelData(
|
||||
MRImageHeader mrHeader,
|
||||
Color[] palette,
|
||||
byte[] buffer,
|
||||
int startIndex,
|
||||
int length)
|
||||
{
|
||||
int length1 = palette.Length;
|
||||
int index1 = 0;
|
||||
byte[] buffer1 = new byte[mrHeader.Width * mrHeader.Height];
|
||||
for (int index2 = startIndex; index2 < startIndex + length; ++index2)
|
||||
{
|
||||
if (buffer[index2] < (byte) 128)
|
||||
{
|
||||
byte colorNumber = buffer[index2];
|
||||
index1 = MRImageConverter.decodePixels(buffer1, index1, colorNumber, length1, 1);
|
||||
}
|
||||
else if (buffer[index2] == (byte) 129)
|
||||
{
|
||||
int numberOfPixels = (int) buffer[index2 + 1];
|
||||
byte colorNumber = buffer[index2 + 2];
|
||||
index1 = MRImageConverter.decodePixels(buffer1, index1, colorNumber, length1, numberOfPixels);
|
||||
index2 += 2;
|
||||
}
|
||||
else if (buffer[index2] == (byte) 130 && buffer[index2 + 1] >= (byte) 128)
|
||||
{
|
||||
int numberOfPixels = (int) buffer[index2 + 1] - 128 + 256;
|
||||
byte colorNumber = buffer[index2 + 2];
|
||||
index1 = MRImageConverter.decodePixels(buffer1, index1, colorNumber, length1, numberOfPixels);
|
||||
index2 += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
int numberOfPixels = (int) buffer[index2] - 128;
|
||||
byte colorNumber = buffer[index2 + 1];
|
||||
index1 = MRImageConverter.decodePixels(buffer1, index1, colorNumber, length1, numberOfPixels);
|
||||
++index2;
|
||||
}
|
||||
}
|
||||
return buffer1;
|
||||
}
|
||||
|
||||
private static int decodePixels(
|
||||
byte[] buffer,
|
||||
int index,
|
||||
byte colorNumber,
|
||||
int numberOfColors,
|
||||
int numberOfPixels)
|
||||
{
|
||||
for (int index1 = 0; index1 < numberOfPixels && index < buffer.Length; ++index1)
|
||||
{
|
||||
if ((int) colorNumber >= numberOfColors)
|
||||
colorNumber = colorNumber == (byte) 154 ? (byte) 0 : throw MRImageUnknownColorException.anUnknownColor(colorNumber);
|
||||
buffer[index] = colorNumber;
|
||||
++index;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
23
SEGATools/Graphics/MRImageDecompressionException.cs
Normal file
23
SEGATools/Graphics/MRImageDecompressionException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Graphics.MRImageDecompressionException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Graphics
|
||||
{
|
||||
internal class MRImageDecompressionException : MRImageReadingException
|
||||
{
|
||||
public MRImageDecompressionException(string message)
|
||||
: base(string.Format("MR Image Decompression Error: {0}", (object) message))
|
||||
{
|
||||
}
|
||||
|
||||
public MRImageDecompressionException(string message, Exception innerException)
|
||||
: base(string.Format("MR Image Decompression Error: {0}", (object) message), innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
99
SEGATools/Graphics/MRImageExporter.cs
Normal file
99
SEGATools/Graphics/MRImageExporter.cs
Normal file
|
@ -0,0 +1,99 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Graphics.MRImageExporter
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
|
||||
namespace SEGATools.Graphics
|
||||
{
|
||||
public class MRImageExporter
|
||||
{
|
||||
private static List<MRImageExporter.MRImageFormat> supportedMRImageFormats;
|
||||
|
||||
public MRImageExporter()
|
||||
{
|
||||
if (MRImageExporter.supportedMRImageFormats != null)
|
||||
return;
|
||||
MRImageExporter.supportedMRImageFormats = new List<MRImageExporter.MRImageFormat>();
|
||||
MRImageExporter.supportedMRImageFormats.Add(new MRImageExporter.MRImageFormat(".mr", "MR image"));
|
||||
MRImageExporter.supportedMRImageFormats.Add(new MRImageExporter.MRImageFormat(".bmp", "Bitmap image", ImageFormat.Bmp));
|
||||
MRImageExporter.supportedMRImageFormats.Add(new MRImageExporter.MRImageFormat(".png", "PNG image", ImageFormat.Png));
|
||||
MRImageExporter.supportedMRImageFormats.Add(new MRImageExporter.MRImageFormat(".jpeg", "JPEG image", ImageFormat.Jpeg));
|
||||
MRImageExporter.supportedMRImageFormats.Add(new MRImageExporter.MRImageFormat(".gif", "GIF image", ImageFormat.Gif));
|
||||
}
|
||||
|
||||
public string CreateSaveFileDialogFilter()
|
||||
{
|
||||
string str = string.Empty;
|
||||
foreach (MRImageExporter.MRImageFormat supportedMrImageFormat in MRImageExporter.supportedMRImageFormats)
|
||||
str = str + "|" + supportedMrImageFormat.Description + "|*" + supportedMrImageFormat.Extension;
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
str = str.Substring(1);
|
||||
return str;
|
||||
}
|
||||
|
||||
public MRImageExporter.MRImageFormat GetMRImageFormatFromFilterIndex(int index) => index < 1 || index > MRImageExporter.supportedMRImageFormats.Count ? (MRImageExporter.MRImageFormat) null : MRImageExporter.supportedMRImageFormats[index - 1];
|
||||
|
||||
public MRImageExporter.MRImageFormat FindMRImageFileFormatForFileExtension(
|
||||
string fileExtension)
|
||||
{
|
||||
return string.IsNullOrEmpty(fileExtension) ? (MRImageExporter.MRImageFormat) null : MRImageExporter.supportedMRImageFormats.Find((Predicate<MRImageExporter.MRImageFormat>) (mrImageFileFormat => mrImageFileFormat.Extension.Equals(fileExtension, StringComparison.InvariantCultureIgnoreCase)));
|
||||
}
|
||||
|
||||
public bool IsImageExtensionSupported(string fileExtension) => this.FindMRImageFileFormatForFileExtension(fileExtension) != null;
|
||||
|
||||
public void Save(
|
||||
MRImage mrImage,
|
||||
string outputFileName,
|
||||
MRImageExporter.MRImageFormat imageFormat)
|
||||
{
|
||||
if (imageFormat == null)
|
||||
throw new ArgumentException(nameof (imageFormat));
|
||||
if (imageFormat.IsRawMR)
|
||||
{
|
||||
using (System.IO.Stream fileStream1 = mrImage.FileStream)
|
||||
{
|
||||
byte[] buffer = new byte[fileStream1.Length];
|
||||
using (FileStream fileStream2 = new FileStream(outputFileName, FileMode.OpenOrCreate))
|
||||
{
|
||||
fileStream1.Read(buffer, 0, buffer.Length);
|
||||
fileStream2.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
mrImage.ToBitmap().Save(outputFileName, imageFormat.Format);
|
||||
}
|
||||
|
||||
public class MRImageFormat
|
||||
{
|
||||
public bool IsRawMR { get; set; }
|
||||
|
||||
public string Extension { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public ImageFormat Format { get; set; }
|
||||
|
||||
public MRImageFormat(string extension, string description, ImageFormat imageFormat)
|
||||
{
|
||||
this.Extension = extension;
|
||||
this.Description = description;
|
||||
this.Format = imageFormat;
|
||||
this.IsRawMR = false;
|
||||
}
|
||||
|
||||
public MRImageFormat(string extension, string description)
|
||||
{
|
||||
this.Extension = extension;
|
||||
this.Description = description;
|
||||
this.IsRawMR = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
SEGATools/Graphics/MRImageHeader.cs
Normal file
25
SEGATools/Graphics/MRImageHeader.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Graphics.MRImageHeader
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SEGATools.Graphics
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 28, Pack = 1)]
|
||||
internal struct MRImageHeader
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
internal int Size;
|
||||
[FieldOffset(8)]
|
||||
internal int Offset;
|
||||
[FieldOffset(12)]
|
||||
internal int Width;
|
||||
[FieldOffset(16)]
|
||||
internal int Height;
|
||||
[FieldOffset(24)]
|
||||
internal uint NumberOfColors;
|
||||
}
|
||||
}
|
23
SEGATools/Graphics/MRImageIdentifierMissingException.cs
Normal file
23
SEGATools/Graphics/MRImageIdentifierMissingException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Graphics.MRImageIdentifierMissingException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Graphics
|
||||
{
|
||||
internal class MRImageIdentifierMissingException : MRImageReadingException
|
||||
{
|
||||
public MRImageIdentifierMissingException(string message)
|
||||
: base(string.Format("MR Image Identifier Missing Error: {0}", (object) message))
|
||||
{
|
||||
}
|
||||
|
||||
public MRImageIdentifierMissingException(string message, Exception innerException)
|
||||
: base(string.Format("MR Image Identifier Missing Error: {0}", (object) message), innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
23
SEGATools/Graphics/MRImageReadingException.cs
Normal file
23
SEGATools/Graphics/MRImageReadingException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Graphics.MRImageReadingException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Graphics
|
||||
{
|
||||
internal class MRImageReadingException : Exception
|
||||
{
|
||||
public MRImageReadingException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public MRImageReadingException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
22
SEGATools/Graphics/MRImageUnknownColorException.cs
Normal file
22
SEGATools/Graphics/MRImageUnknownColorException.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Graphics.MRImageUnknownColorException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.Graphics
|
||||
{
|
||||
internal class MRImageUnknownColorException : MRImageReadingException
|
||||
{
|
||||
public MRImageUnknownColorException(string message)
|
||||
: base(string.Format("MR Image Unknown Color Error: {0}", (object) message))
|
||||
{
|
||||
}
|
||||
|
||||
public static MRImageUnknownColorException anUnknownColor(
|
||||
byte colorNumber)
|
||||
{
|
||||
return new MRImageUnknownColorException(string.Format("color number {0} does not exist", (object) colorNumber));
|
||||
}
|
||||
}
|
||||
}
|
284
SEGATools/Graphics/MRImageViewer.cs
Normal file
284
SEGATools/Graphics/MRImageViewer.cs
Normal file
|
@ -0,0 +1,284 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Graphics.MRImageViewer
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.Formater;
|
||||
using SEGATools.Properties;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SEGATools.Graphics
|
||||
{
|
||||
public class MRImageViewer : UserControl
|
||||
{
|
||||
private MRImageExporter mrImageExporter;
|
||||
private string basePath;
|
||||
private IContainer components;
|
||||
private PictureBox pictureBox;
|
||||
private GroupBox gbMRImageInfo;
|
||||
private Label lbColors;
|
||||
private Label lbImageSize;
|
||||
private Label lbNumberOfColorsValue;
|
||||
private Label lbImageSizeValue;
|
||||
private Label lbFileSizeValue;
|
||||
private Label lbFileSize;
|
||||
private Label lbCompressedSizeValue;
|
||||
private Label lbSize;
|
||||
private Label lbUncompressedSizeValue;
|
||||
private Label lbUncompressedSize;
|
||||
private Label lbCompressionRatioValue;
|
||||
private Label lbCompressionRatio;
|
||||
private Button btExportMRImage;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private Label lbNoMrImage;
|
||||
|
||||
public MRImage MRImage { get; private set; }
|
||||
|
||||
public string BasePath
|
||||
{
|
||||
get => this.basePath;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return;
|
||||
this.basePath = value;
|
||||
this.saveFileDialog.InitialDirectory = this.basePath;
|
||||
}
|
||||
}
|
||||
|
||||
private bool DisplayNoImageMessage => true;
|
||||
|
||||
public MRImageViewer()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.pictureBox.Resize += new EventHandler(this.pictureBox_Resize);
|
||||
this.mrImageExporter = new MRImageExporter();
|
||||
this.saveFileDialog.Title = Resources.SfdMRImageTitle;
|
||||
this.saveFileDialog.Filter = this.mrImageExporter.CreateSaveFileDialogFilter();
|
||||
this.lbNoMrImage.Text = Resources.MRImageNoImageMessage;
|
||||
this.CenterImageInDisplayArea((Control) this.lbNoMrImage);
|
||||
this.UpdateViewAndDisplayNoImage();
|
||||
}
|
||||
|
||||
public void LoadMRImage(MRImage mrImage, string imageName)
|
||||
{
|
||||
this.MRImage = mrImage;
|
||||
this.saveFileDialog.FileName = imageName;
|
||||
this.SetImageProperties(this.MRImage);
|
||||
this.UpdateViewAndDisplayImages();
|
||||
}
|
||||
|
||||
private void SetImageProperties(MRImage mrImage)
|
||||
{
|
||||
this.lbImageSizeValue.Text = string.Format("{0}x{1}", (object) mrImage.ImageSize.Width, (object) mrImage.ImageSize.Height);
|
||||
this.lbNumberOfColorsValue.Text = string.Format("{0}", (object) mrImage.ColorPalette.Length);
|
||||
this.lbFileSizeValue.Text = string.Format("{0} ({1} bytes)", (object) SizeFormater.ToHumanReadableSize((long) mrImage.FileSize), (object) mrImage.FileSize);
|
||||
this.lbCompressedSizeValue.Text = string.Format("{0} bytes", (object) mrImage.CompressedSize);
|
||||
this.lbUncompressedSizeValue.Text = string.Format("{0} bytes", (object) mrImage.UncompressedSize);
|
||||
this.lbCompressionRatioValue.Text = string.Format("{0:0.0}:1", (object) mrImage.CompressionRatio);
|
||||
this.pictureBox.Image = (Image) mrImage.ToBitmap();
|
||||
}
|
||||
|
||||
private void CenterImageInDisplayArea(Control control)
|
||||
{
|
||||
int x = (this.Width - control.Size.Width) / 2;
|
||||
int y = (this.gbMRImageInfo.Location.Y - control.Size.Height) / 2;
|
||||
control.Location = new Point(x, y);
|
||||
}
|
||||
|
||||
private void OpenFileDialogAndExportImage(Image image)
|
||||
{
|
||||
if (this.saveFileDialog.ShowDialog((IWin32Window) this) != DialogResult.OK)
|
||||
return;
|
||||
this.mrImageExporter.Save(this.MRImage, this.saveFileDialog.FileName, this.mrImageExporter.GetMRImageFormatFromFilterIndex(this.saveFileDialog.FilterIndex));
|
||||
this.saveFileDialog.InitialDirectory = Path.GetDirectoryName(this.saveFileDialog.FileName);
|
||||
this.saveFileDialog.FileName = Path.GetFileName(this.saveFileDialog.FileName);
|
||||
}
|
||||
|
||||
private void UpdateViewAndDisplayNoImage()
|
||||
{
|
||||
this.lbNoMrImage.Visible = this.DisplayNoImageMessage;
|
||||
this.gbMRImageInfo.Visible = false;
|
||||
this.btExportMRImage.Visible = false;
|
||||
this.pictureBox.Visible = false;
|
||||
}
|
||||
|
||||
private void UpdateViewAndDisplayImages()
|
||||
{
|
||||
this.lbNoMrImage.Visible = false;
|
||||
this.gbMRImageInfo.Visible = true;
|
||||
this.btExportMRImage.Visible = true;
|
||||
this.pictureBox.Visible = true;
|
||||
}
|
||||
|
||||
private void pictureBox_Resize(object sender, EventArgs e) => this.CenterImageInDisplayArea((Control) this.pictureBox);
|
||||
|
||||
private void btExportMRImage_Click(object sender, EventArgs e) => this.OpenFileDialogAndExportImage(this.pictureBox.Image);
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && this.components != null)
|
||||
this.components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBox = new PictureBox();
|
||||
this.gbMRImageInfo = new GroupBox();
|
||||
this.lbCompressionRatioValue = new Label();
|
||||
this.lbCompressionRatio = new Label();
|
||||
this.lbUncompressedSizeValue = new Label();
|
||||
this.lbUncompressedSize = new Label();
|
||||
this.lbCompressedSizeValue = new Label();
|
||||
this.lbSize = new Label();
|
||||
this.lbFileSizeValue = new Label();
|
||||
this.lbFileSize = new Label();
|
||||
this.lbNumberOfColorsValue = new Label();
|
||||
this.lbImageSizeValue = new Label();
|
||||
this.lbColors = new Label();
|
||||
this.lbImageSize = new Label();
|
||||
this.btExportMRImage = new Button();
|
||||
this.saveFileDialog = new SaveFileDialog();
|
||||
this.lbNoMrImage = new Label();
|
||||
((ISupportInitialize) this.pictureBox).BeginInit();
|
||||
this.gbMRImageInfo.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
this.pictureBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom;
|
||||
this.pictureBox.BorderStyle = BorderStyle.FixedSingle;
|
||||
this.pictureBox.Location = new Point(6, 3);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new Size(448, 90);
|
||||
this.pictureBox.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBox.TabIndex = 0;
|
||||
this.pictureBox.TabStop = false;
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbCompressionRatioValue);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbCompressionRatio);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbUncompressedSizeValue);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbUncompressedSize);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbCompressedSizeValue);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbSize);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbFileSizeValue);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbFileSize);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbNumberOfColorsValue);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbImageSizeValue);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbColors);
|
||||
this.gbMRImageInfo.Controls.Add((Control) this.lbImageSize);
|
||||
this.gbMRImageInfo.Location = new Point(6, 99);
|
||||
this.gbMRImageInfo.Name = "gbMRImageInfo";
|
||||
this.gbMRImageInfo.Size = new Size(448, 75);
|
||||
this.gbMRImageInfo.TabIndex = 0;
|
||||
this.gbMRImageInfo.TabStop = false;
|
||||
this.gbMRImageInfo.Text = "Properties:";
|
||||
this.lbCompressionRatioValue.AutoSize = true;
|
||||
this.lbCompressionRatioValue.Location = new Point(345, 54);
|
||||
this.lbCompressionRatioValue.Name = "lbCompressionRatioValue";
|
||||
this.lbCompressionRatioValue.Size = new Size(89, 13);
|
||||
this.lbCompressionRatioValue.TabIndex = 0;
|
||||
this.lbCompressionRatioValue.Text = "compression ratio";
|
||||
this.lbCompressionRatio.AutoSize = true;
|
||||
this.lbCompressionRatio.Location = new Point(235, 54);
|
||||
this.lbCompressionRatio.Name = "lbCompressionRatio";
|
||||
this.lbCompressionRatio.Size = new Size(98, 13);
|
||||
this.lbCompressionRatio.TabIndex = 0;
|
||||
this.lbCompressionRatio.Text = "Compression Ratio:";
|
||||
this.lbUncompressedSizeValue.AutoSize = true;
|
||||
this.lbUncompressedSizeValue.Location = new Point(345, 37);
|
||||
this.lbUncompressedSizeValue.Name = "lbUncompressedSizeValue";
|
||||
this.lbUncompressedSizeValue.Size = new Size(97, 13);
|
||||
this.lbUncompressedSizeValue.TabIndex = 0;
|
||||
this.lbUncompressedSizeValue.Text = "uncompressed size";
|
||||
this.lbUncompressedSize.AutoSize = true;
|
||||
this.lbUncompressedSize.Location = new Point(234, 37);
|
||||
this.lbUncompressedSize.Name = "lbUncompressedSize";
|
||||
this.lbUncompressedSize.Size = new Size(104, 13);
|
||||
this.lbUncompressedSize.TabIndex = 0;
|
||||
this.lbUncompressedSize.Text = "Uncompressed Size:";
|
||||
this.lbCompressedSizeValue.AutoSize = true;
|
||||
this.lbCompressedSizeValue.Location = new Point(345, 20);
|
||||
this.lbCompressedSizeValue.Name = "lbCompressedSizeValue";
|
||||
this.lbCompressedSizeValue.Size = new Size(85, 13);
|
||||
this.lbCompressedSizeValue.TabIndex = 0;
|
||||
this.lbCompressedSizeValue.Text = "compressed size";
|
||||
this.lbSize.AutoSize = true;
|
||||
this.lbSize.Location = new Point(235, 20);
|
||||
this.lbSize.Name = "lbSize";
|
||||
this.lbSize.Size = new Size(91, 13);
|
||||
this.lbSize.TabIndex = 0;
|
||||
this.lbSize.Text = "Compressed Size:";
|
||||
this.lbFileSizeValue.AutoSize = true;
|
||||
this.lbFileSizeValue.Location = new Point(106, 54);
|
||||
this.lbFileSizeValue.Name = "lbFileSizeValue";
|
||||
this.lbFileSizeValue.Size = new Size(64, 13);
|
||||
this.lbFileSizeValue.TabIndex = 0;
|
||||
this.lbFileSizeValue.Text = "size in bytes";
|
||||
this.lbFileSize.AutoSize = true;
|
||||
this.lbFileSize.Location = new Point(7, 54);
|
||||
this.lbFileSize.Name = "lbFileSize";
|
||||
this.lbFileSize.Size = new Size(49, 13);
|
||||
this.lbFileSize.TabIndex = 0;
|
||||
this.lbFileSize.Text = "File Size:";
|
||||
this.lbNumberOfColorsValue.AutoSize = true;
|
||||
this.lbNumberOfColorsValue.Location = new Point(103, 37);
|
||||
this.lbNumberOfColorsValue.Name = "lbNumberOfColorsValue";
|
||||
this.lbNumberOfColorsValue.Size = new Size(13, 13);
|
||||
this.lbNumberOfColorsValue.TabIndex = 0;
|
||||
this.lbNumberOfColorsValue.Text = "0";
|
||||
this.lbImageSizeValue.AutoSize = true;
|
||||
this.lbImageSizeValue.Location = new Point(103, 20);
|
||||
this.lbImageSizeValue.Name = "lbImageSizeValue";
|
||||
this.lbImageSizeValue.Size = new Size(54, 13);
|
||||
this.lbImageSizeValue.TabIndex = 0;
|
||||
this.lbImageSizeValue.Text = "XXXxYYY";
|
||||
this.lbColors.AutoSize = true;
|
||||
this.lbColors.Location = new Point(7, 37);
|
||||
this.lbColors.Name = "lbColors";
|
||||
this.lbColors.Size = new Size(90, 13);
|
||||
this.lbColors.TabIndex = 0;
|
||||
this.lbColors.Text = "Number of colors:";
|
||||
this.lbImageSize.AutoSize = true;
|
||||
this.lbImageSize.Location = new Point(7, 20);
|
||||
this.lbImageSize.Name = "lbImageSize";
|
||||
this.lbImageSize.Size = new Size(62, 13);
|
||||
this.lbImageSize.TabIndex = 0;
|
||||
this.lbImageSize.Text = "Image Size:";
|
||||
this.btExportMRImage.CausesValidation = false;
|
||||
this.btExportMRImage.FlatStyle = FlatStyle.Popup;
|
||||
this.btExportMRImage.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, (byte) 0);
|
||||
this.btExportMRImage.ForeColor = Color.FromArgb(248, 48, 0);
|
||||
this.btExportMRImage.Location = new Point(6, 180);
|
||||
this.btExportMRImage.Name = "btExportMRImage";
|
||||
this.btExportMRImage.Size = new Size(108, 22);
|
||||
this.btExportMRImage.TabIndex = 1;
|
||||
this.btExportMRImage.Text = "Export Image...";
|
||||
this.btExportMRImage.UseVisualStyleBackColor = false;
|
||||
this.btExportMRImage.Click += new EventHandler(this.btExportMRImage_Click);
|
||||
this.lbNoMrImage.AutoSize = true;
|
||||
this.lbNoMrImage.Font = new Font("Microsoft Sans Serif", 15.75f, FontStyle.Bold, GraphicsUnit.Point, (byte) 0);
|
||||
this.lbNoMrImage.Location = new Point(117, 35);
|
||||
this.lbNoMrImage.Name = "lbNoMrImage";
|
||||
this.lbNoMrImage.Size = new Size(226, 25);
|
||||
this.lbNoMrImage.TabIndex = 2;
|
||||
this.lbNoMrImage.Text = "No MR Image found!";
|
||||
this.lbNoMrImage.TextAlign = ContentAlignment.MiddleCenter;
|
||||
this.AutoScaleDimensions = new SizeF(6f, 13f);
|
||||
this.AutoScaleMode = AutoScaleMode.Font;
|
||||
this.Controls.Add((Control) this.lbNoMrImage);
|
||||
this.Controls.Add((Control) this.btExportMRImage);
|
||||
this.Controls.Add((Control) this.gbMRImageInfo);
|
||||
this.Controls.Add((Control) this.pictureBox);
|
||||
this.Name = nameof (MRImageViewer);
|
||||
this.Size = new Size(460, 209);
|
||||
((ISupportInitialize) this.pictureBox).EndInit();
|
||||
this.gbMRImageInfo.ResumeLayout(false);
|
||||
this.gbMRImageInfo.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
}
|
||||
}
|
120
SEGATools/Graphics/MRImageViewer.resx
Normal file
120
SEGATools/Graphics/MRImageViewer.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
607
SEGATools/HashAlgorithm/ECC.cs
Normal file
607
SEGATools/HashAlgorithm/ECC.cs
Normal file
|
@ -0,0 +1,607 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.HashAlgorithm.ECC
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
using System;
|
||||
|
||||
namespace SEGATools.HashAlgorithm
|
||||
{
|
||||
public static class ECC
|
||||
{
|
||||
private static readonly byte[] ECC_F_LOOKUP_TABLE = new byte[256]
|
||||
{
|
||||
(byte) 0,
|
||||
(byte) 2,
|
||||
(byte) 4,
|
||||
(byte) 6,
|
||||
(byte) 8,
|
||||
(byte) 10,
|
||||
(byte) 12,
|
||||
(byte) 14,
|
||||
(byte) 16,
|
||||
(byte) 18,
|
||||
(byte) 20,
|
||||
(byte) 22,
|
||||
(byte) 24,
|
||||
(byte) 26,
|
||||
(byte) 28,
|
||||
(byte) 30,
|
||||
(byte) 32,
|
||||
(byte) 34,
|
||||
(byte) 36,
|
||||
(byte) 38,
|
||||
(byte) 40,
|
||||
(byte) 42,
|
||||
(byte) 44,
|
||||
(byte) 46,
|
||||
(byte) 48,
|
||||
(byte) 50,
|
||||
(byte) 52,
|
||||
(byte) 54,
|
||||
(byte) 56,
|
||||
(byte) 58,
|
||||
(byte) 60,
|
||||
(byte) 62,
|
||||
(byte) 64,
|
||||
(byte) 66,
|
||||
(byte) 68,
|
||||
(byte) 70,
|
||||
(byte) 72,
|
||||
(byte) 74,
|
||||
(byte) 76,
|
||||
(byte) 78,
|
||||
(byte) 80,
|
||||
(byte) 82,
|
||||
(byte) 84,
|
||||
(byte) 86,
|
||||
(byte) 88,
|
||||
(byte) 90,
|
||||
(byte) 92,
|
||||
(byte) 94,
|
||||
(byte) 96,
|
||||
(byte) 98,
|
||||
(byte) 100,
|
||||
(byte) 102,
|
||||
(byte) 104,
|
||||
(byte) 106,
|
||||
(byte) 108,
|
||||
(byte) 110,
|
||||
(byte) 112,
|
||||
(byte) 114,
|
||||
(byte) 116,
|
||||
(byte) 118,
|
||||
(byte) 120,
|
||||
(byte) 122,
|
||||
(byte) 124,
|
||||
(byte) 126,
|
||||
(byte) 128,
|
||||
(byte) 130,
|
||||
(byte) 132,
|
||||
(byte) 134,
|
||||
(byte) 136,
|
||||
(byte) 138,
|
||||
(byte) 140,
|
||||
(byte) 142,
|
||||
(byte) 144,
|
||||
(byte) 146,
|
||||
(byte) 148,
|
||||
(byte) 150,
|
||||
(byte) 152,
|
||||
(byte) 154,
|
||||
(byte) 156,
|
||||
(byte) 158,
|
||||
(byte) 160,
|
||||
(byte) 162,
|
||||
(byte) 164,
|
||||
(byte) 166,
|
||||
(byte) 168,
|
||||
(byte) 170,
|
||||
(byte) 172,
|
||||
(byte) 174,
|
||||
(byte) 176,
|
||||
(byte) 178,
|
||||
(byte) 180,
|
||||
(byte) 182,
|
||||
(byte) 184,
|
||||
(byte) 186,
|
||||
(byte) 188,
|
||||
(byte) 190,
|
||||
(byte) 192,
|
||||
(byte) 194,
|
||||
(byte) 196,
|
||||
(byte) 198,
|
||||
(byte) 200,
|
||||
(byte) 202,
|
||||
(byte) 204,
|
||||
(byte) 206,
|
||||
(byte) 208,
|
||||
(byte) 210,
|
||||
(byte) 212,
|
||||
(byte) 214,
|
||||
(byte) 216,
|
||||
(byte) 218,
|
||||
(byte) 220,
|
||||
(byte) 222,
|
||||
(byte) 224,
|
||||
(byte) 226,
|
||||
(byte) 228,
|
||||
(byte) 230,
|
||||
(byte) 232,
|
||||
(byte) 234,
|
||||
(byte) 236,
|
||||
(byte) 238,
|
||||
(byte) 240,
|
||||
(byte) 242,
|
||||
(byte) 244,
|
||||
(byte) 246,
|
||||
(byte) 248,
|
||||
(byte) 250,
|
||||
(byte) 252,
|
||||
(byte) 254,
|
||||
(byte) 29,
|
||||
(byte) 31,
|
||||
(byte) 25,
|
||||
(byte) 27,
|
||||
(byte) 21,
|
||||
(byte) 23,
|
||||
(byte) 17,
|
||||
(byte) 19,
|
||||
(byte) 13,
|
||||
(byte) 15,
|
||||
(byte) 9,
|
||||
(byte) 11,
|
||||
(byte) 5,
|
||||
(byte) 7,
|
||||
(byte) 1,
|
||||
(byte) 3,
|
||||
(byte) 61,
|
||||
(byte) 63,
|
||||
(byte) 57,
|
||||
(byte) 59,
|
||||
(byte) 53,
|
||||
(byte) 55,
|
||||
(byte) 49,
|
||||
(byte) 51,
|
||||
(byte) 45,
|
||||
(byte) 47,
|
||||
(byte) 41,
|
||||
(byte) 43,
|
||||
(byte) 37,
|
||||
(byte) 39,
|
||||
(byte) 33,
|
||||
(byte) 35,
|
||||
(byte) 93,
|
||||
(byte) 95,
|
||||
(byte) 89,
|
||||
(byte) 91,
|
||||
(byte) 85,
|
||||
(byte) 87,
|
||||
(byte) 81,
|
||||
(byte) 83,
|
||||
(byte) 77,
|
||||
(byte) 79,
|
||||
(byte) 73,
|
||||
(byte) 75,
|
||||
(byte) 69,
|
||||
(byte) 71,
|
||||
(byte) 65,
|
||||
(byte) 67,
|
||||
(byte) 125,
|
||||
(byte) 127,
|
||||
(byte) 121,
|
||||
(byte) 123,
|
||||
(byte) 117,
|
||||
(byte) 119,
|
||||
(byte) 113,
|
||||
(byte) 115,
|
||||
(byte) 109,
|
||||
(byte) 111,
|
||||
(byte) 105,
|
||||
(byte) 107,
|
||||
(byte) 101,
|
||||
(byte) 103,
|
||||
(byte) 97,
|
||||
(byte) 99,
|
||||
(byte) 157,
|
||||
(byte) 159,
|
||||
(byte) 153,
|
||||
(byte) 155,
|
||||
(byte) 149,
|
||||
(byte) 151,
|
||||
(byte) 145,
|
||||
(byte) 147,
|
||||
(byte) 141,
|
||||
(byte) 143,
|
||||
(byte) 137,
|
||||
(byte) 139,
|
||||
(byte) 133,
|
||||
(byte) 135,
|
||||
(byte) 129,
|
||||
(byte) 131,
|
||||
(byte) 189,
|
||||
(byte) 191,
|
||||
(byte) 185,
|
||||
(byte) 187,
|
||||
(byte) 181,
|
||||
(byte) 183,
|
||||
(byte) 177,
|
||||
(byte) 179,
|
||||
(byte) 173,
|
||||
(byte) 175,
|
||||
(byte) 169,
|
||||
(byte) 171,
|
||||
(byte) 165,
|
||||
(byte) 167,
|
||||
(byte) 161,
|
||||
(byte) 163,
|
||||
(byte) 221,
|
||||
(byte) 223,
|
||||
(byte) 217,
|
||||
(byte) 219,
|
||||
(byte) 213,
|
||||
(byte) 215,
|
||||
(byte) 209,
|
||||
(byte) 211,
|
||||
(byte) 205,
|
||||
(byte) 207,
|
||||
(byte) 201,
|
||||
(byte) 203,
|
||||
(byte) 197,
|
||||
(byte) 199,
|
||||
(byte) 193,
|
||||
(byte) 195,
|
||||
(byte) 253,
|
||||
byte.MaxValue,
|
||||
(byte) 249,
|
||||
(byte) 251,
|
||||
(byte) 245,
|
||||
(byte) 247,
|
||||
(byte) 241,
|
||||
(byte) 243,
|
||||
(byte) 237,
|
||||
(byte) 239,
|
||||
(byte) 233,
|
||||
(byte) 235,
|
||||
(byte) 229,
|
||||
(byte) 231,
|
||||
(byte) 225,
|
||||
(byte) 227
|
||||
};
|
||||
private static readonly byte[] ECC_B_LOOKUP_TABLE = new byte[256]
|
||||
{
|
||||
(byte) 0,
|
||||
(byte) 244,
|
||||
(byte) 245,
|
||||
(byte) 1,
|
||||
(byte) 247,
|
||||
(byte) 3,
|
||||
(byte) 2,
|
||||
(byte) 246,
|
||||
(byte) 243,
|
||||
(byte) 7,
|
||||
(byte) 6,
|
||||
(byte) 242,
|
||||
(byte) 4,
|
||||
(byte) 240,
|
||||
(byte) 241,
|
||||
(byte) 5,
|
||||
(byte) 251,
|
||||
(byte) 15,
|
||||
(byte) 14,
|
||||
(byte) 250,
|
||||
(byte) 12,
|
||||
(byte) 248,
|
||||
(byte) 249,
|
||||
(byte) 13,
|
||||
(byte) 8,
|
||||
(byte) 252,
|
||||
(byte) 253,
|
||||
(byte) 9,
|
||||
byte.MaxValue,
|
||||
(byte) 11,
|
||||
(byte) 10,
|
||||
(byte) 254,
|
||||
(byte) 235,
|
||||
(byte) 31,
|
||||
(byte) 30,
|
||||
(byte) 234,
|
||||
(byte) 28,
|
||||
(byte) 232,
|
||||
(byte) 233,
|
||||
(byte) 29,
|
||||
(byte) 24,
|
||||
(byte) 236,
|
||||
(byte) 237,
|
||||
(byte) 25,
|
||||
(byte) 239,
|
||||
(byte) 27,
|
||||
(byte) 26,
|
||||
(byte) 238,
|
||||
(byte) 16,
|
||||
(byte) 228,
|
||||
(byte) 229,
|
||||
(byte) 17,
|
||||
(byte) 231,
|
||||
(byte) 19,
|
||||
(byte) 18,
|
||||
(byte) 230,
|
||||
(byte) 227,
|
||||
(byte) 23,
|
||||
(byte) 22,
|
||||
(byte) 226,
|
||||
(byte) 20,
|
||||
(byte) 224,
|
||||
(byte) 225,
|
||||
(byte) 21,
|
||||
(byte) 203,
|
||||
(byte) 63,
|
||||
(byte) 62,
|
||||
(byte) 202,
|
||||
(byte) 60,
|
||||
(byte) 200,
|
||||
(byte) 201,
|
||||
(byte) 61,
|
||||
(byte) 56,
|
||||
(byte) 204,
|
||||
(byte) 205,
|
||||
(byte) 57,
|
||||
(byte) 207,
|
||||
(byte) 59,
|
||||
(byte) 58,
|
||||
(byte) 206,
|
||||
(byte) 48,
|
||||
(byte) 196,
|
||||
(byte) 197,
|
||||
(byte) 49,
|
||||
(byte) 199,
|
||||
(byte) 51,
|
||||
(byte) 50,
|
||||
(byte) 198,
|
||||
(byte) 195,
|
||||
(byte) 55,
|
||||
(byte) 54,
|
||||
(byte) 194,
|
||||
(byte) 52,
|
||||
(byte) 192,
|
||||
(byte) 193,
|
||||
(byte) 53,
|
||||
(byte) 32,
|
||||
(byte) 212,
|
||||
(byte) 213,
|
||||
(byte) 33,
|
||||
(byte) 215,
|
||||
(byte) 35,
|
||||
(byte) 34,
|
||||
(byte) 214,
|
||||
(byte) 211,
|
||||
(byte) 39,
|
||||
(byte) 38,
|
||||
(byte) 210,
|
||||
(byte) 36,
|
||||
(byte) 208,
|
||||
(byte) 209,
|
||||
(byte) 37,
|
||||
(byte) 219,
|
||||
(byte) 47,
|
||||
(byte) 46,
|
||||
(byte) 218,
|
||||
(byte) 44,
|
||||
(byte) 216,
|
||||
(byte) 217,
|
||||
(byte) 45,
|
||||
(byte) 40,
|
||||
(byte) 220,
|
||||
(byte) 221,
|
||||
(byte) 41,
|
||||
(byte) 223,
|
||||
(byte) 43,
|
||||
(byte) 42,
|
||||
(byte) 222,
|
||||
(byte) 139,
|
||||
(byte) 127,
|
||||
(byte) 126,
|
||||
(byte) 138,
|
||||
(byte) 124,
|
||||
(byte) 136,
|
||||
(byte) 137,
|
||||
(byte) 125,
|
||||
(byte) 120,
|
||||
(byte) 140,
|
||||
(byte) 141,
|
||||
(byte) 121,
|
||||
(byte) 143,
|
||||
(byte) 123,
|
||||
(byte) 122,
|
||||
(byte) 142,
|
||||
(byte) 112,
|
||||
(byte) 132,
|
||||
(byte) 133,
|
||||
(byte) 113,
|
||||
(byte) 135,
|
||||
(byte) 115,
|
||||
(byte) 114,
|
||||
(byte) 134,
|
||||
(byte) 131,
|
||||
(byte) 119,
|
||||
(byte) 118,
|
||||
(byte) 130,
|
||||
(byte) 116,
|
||||
(byte) 128,
|
||||
(byte) 129,
|
||||
(byte) 117,
|
||||
(byte) 96,
|
||||
(byte) 148,
|
||||
(byte) 149,
|
||||
(byte) 97,
|
||||
(byte) 151,
|
||||
(byte) 99,
|
||||
(byte) 98,
|
||||
(byte) 150,
|
||||
(byte) 147,
|
||||
(byte) 103,
|
||||
(byte) 102,
|
||||
(byte) 146,
|
||||
(byte) 100,
|
||||
(byte) 144,
|
||||
(byte) 145,
|
||||
(byte) 101,
|
||||
(byte) 155,
|
||||
(byte) 111,
|
||||
(byte) 110,
|
||||
(byte) 154,
|
||||
(byte) 108,
|
||||
(byte) 152,
|
||||
(byte) 153,
|
||||
(byte) 109,
|
||||
(byte) 104,
|
||||
(byte) 156,
|
||||
(byte) 157,
|
||||
(byte) 105,
|
||||
(byte) 159,
|
||||
(byte) 107,
|
||||
(byte) 106,
|
||||
(byte) 158,
|
||||
(byte) 64,
|
||||
(byte) 180,
|
||||
(byte) 181,
|
||||
(byte) 65,
|
||||
(byte) 183,
|
||||
(byte) 67,
|
||||
(byte) 66,
|
||||
(byte) 182,
|
||||
(byte) 179,
|
||||
(byte) 71,
|
||||
(byte) 70,
|
||||
(byte) 178,
|
||||
(byte) 68,
|
||||
(byte) 176,
|
||||
(byte) 177,
|
||||
(byte) 69,
|
||||
(byte) 187,
|
||||
(byte) 79,
|
||||
(byte) 78,
|
||||
(byte) 186,
|
||||
(byte) 76,
|
||||
(byte) 184,
|
||||
(byte) 185,
|
||||
(byte) 77,
|
||||
(byte) 72,
|
||||
(byte) 188,
|
||||
(byte) 189,
|
||||
(byte) 73,
|
||||
(byte) 191,
|
||||
(byte) 75,
|
||||
(byte) 74,
|
||||
(byte) 190,
|
||||
(byte) 171,
|
||||
(byte) 95,
|
||||
(byte) 94,
|
||||
(byte) 170,
|
||||
(byte) 92,
|
||||
(byte) 168,
|
||||
(byte) 169,
|
||||
(byte) 93,
|
||||
(byte) 88,
|
||||
(byte) 172,
|
||||
(byte) 173,
|
||||
(byte) 89,
|
||||
(byte) 175,
|
||||
(byte) 91,
|
||||
(byte) 90,
|
||||
(byte) 174,
|
||||
(byte) 80,
|
||||
(byte) 164,
|
||||
(byte) 165,
|
||||
(byte) 81,
|
||||
(byte) 167,
|
||||
(byte) 83,
|
||||
(byte) 82,
|
||||
(byte) 166,
|
||||
(byte) 163,
|
||||
(byte) 87,
|
||||
(byte) 86,
|
||||
(byte) 162,
|
||||
(byte) 84,
|
||||
(byte) 160,
|
||||
(byte) 161,
|
||||
(byte) 85
|
||||
};
|
||||
|
||||
internal static int ComputeECCBlock(
|
||||
byte[] src,
|
||||
int srcOffset,
|
||||
byte[] dest,
|
||||
int destOffset,
|
||||
uint majorCount,
|
||||
uint minorCount,
|
||||
uint majorMult,
|
||||
uint minorInc)
|
||||
{
|
||||
uint num1 = majorCount * minorCount;
|
||||
for (uint index1 = 0; index1 < majorCount; ++index1)
|
||||
{
|
||||
uint num2 = (uint) ((int) (index1 >> 1) * (int) majorMult + ((int) index1 & 1));
|
||||
byte num3 = 0;
|
||||
byte num4 = 0;
|
||||
for (uint index2 = 0; index2 < minorCount; ++index2)
|
||||
{
|
||||
byte num5 = src[(long) srcOffset + (long) num2];
|
||||
num2 += minorInc;
|
||||
if (num2 >= num1)
|
||||
num2 -= num1;
|
||||
byte num6 = (byte) ((uint) num3 ^ (uint) num5);
|
||||
num4 ^= num5;
|
||||
num3 = ECC.ECC_F_LOOKUP_TABLE[(int) num6];
|
||||
}
|
||||
byte num7 = ECC.ECC_B_LOOKUP_TABLE[(int) ECC.ECC_F_LOOKUP_TABLE[(int) num3] ^ (int) num4];
|
||||
dest[(long) destOffset + (long) index1] = num7;
|
||||
dest[(long) destOffset + (long) index1 + (long) majorCount] = (byte) ((uint) num7 ^ (uint) num4);
|
||||
}
|
||||
return (int) majorCount * 2;
|
||||
}
|
||||
|
||||
internal static void CheckBufferSize(byte[] buffer)
|
||||
{
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException(nameof (buffer));
|
||||
if (buffer.Length != DiscSectorCommon.RawSectorSize)
|
||||
throw new ArgumentException(string.Format("length must be {0} bytes", (object) DiscSectorCommon.RawSectorSize), nameof (buffer));
|
||||
}
|
||||
|
||||
public interface ECCParityVectorAlgorithm
|
||||
{
|
||||
void ComputeVectors(byte[] buffer);
|
||||
}
|
||||
|
||||
public class PParity : ECC.ECCParityVectorAlgorithm
|
||||
{
|
||||
public static readonly int P_PARITY_VECTOR_LENGTH = ECC.PParity.P_PARITY_VECTORS * 2 * 2;
|
||||
public static readonly int P_PARITY_VECTOR_OFFSET = 2076;
|
||||
private static readonly int P_PARITY_VECTORS = 43;
|
||||
private static readonly int P_PARITY_DATA_OFFSET = 12;
|
||||
|
||||
public void ComputeVectors(byte[] buffer)
|
||||
{
|
||||
ECC.CheckBufferSize(buffer);
|
||||
ECC.ComputeECCBlock(buffer, ECC.PParity.P_PARITY_DATA_OFFSET, buffer, ECC.PParity.P_PARITY_VECTOR_OFFSET, (uint) (ECC.PParity.P_PARITY_VECTORS * 2), 24U, 2U, 86U);
|
||||
}
|
||||
}
|
||||
|
||||
public class QParity : ECC.ECCParityVectorAlgorithm
|
||||
{
|
||||
public static readonly int Q_PARITY_VECTOR_LENGTH = ECC.QParity.Q_PARITY_VECTORS * 2 * 2;
|
||||
public static readonly int Q_PARITY_VECTOR_OFFSET = 2248;
|
||||
private static readonly int Q_PARITY_VECTORS = 26;
|
||||
private static readonly int Q_PARITY_DATA_OFFSET = 12;
|
||||
|
||||
public void ComputeVectors(byte[] buffer)
|
||||
{
|
||||
ECC.CheckBufferSize(buffer);
|
||||
ECC.ComputeECCBlock(buffer, ECC.QParity.Q_PARITY_DATA_OFFSET, buffer, ECC.QParity.Q_PARITY_VECTOR_OFFSET, (uint) (ECC.QParity.Q_PARITY_VECTORS * 2), 43U, 86U, 88U);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
322
SEGATools/HashAlgorithm/EDC.cs
Normal file
322
SEGATools/HashAlgorithm/EDC.cs
Normal file
|
@ -0,0 +1,322 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.HashAlgorithm.EDC
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.HashAlgorithm
|
||||
{
|
||||
public class EDC : System.Security.Cryptography.HashAlgorithm
|
||||
{
|
||||
public static readonly int SECTOR_DATA_LENGTH_FOR_EDC_COMPUTATION = 2064;
|
||||
public static readonly int EDC_DATA_OFFSET = EDC.SECTOR_DATA_LENGTH_FOR_EDC_COMPUTATION;
|
||||
public static readonly int EDC_DATA_LENGTH = 4;
|
||||
private static readonly uint EDC_POLYNOMIAL = 3623976961;
|
||||
private static readonly uint[] EDC_CRC_LOOKUP_TABLE = new uint[256]
|
||||
{
|
||||
0U,
|
||||
2425422081U,
|
||||
2434859521U,
|
||||
28312320U,
|
||||
2453734401U,
|
||||
47187200U,
|
||||
56624640U,
|
||||
2482046721U,
|
||||
2491484161U,
|
||||
68159744U,
|
||||
94374400U,
|
||||
2503019265U,
|
||||
113249280U,
|
||||
2521894145U,
|
||||
2548108801U,
|
||||
124784384U,
|
||||
2566983681U,
|
||||
160436480U,
|
||||
136319488U,
|
||||
2561741569U,
|
||||
188748800U,
|
||||
2614170881U,
|
||||
2590053889U,
|
||||
183506688U,
|
||||
226498560U,
|
||||
2635143425U,
|
||||
2627803649U,
|
||||
204479232U,
|
||||
2680232961U,
|
||||
256908544U,
|
||||
249568768U,
|
||||
2658213633U,
|
||||
2181111809U,
|
||||
311435520U,
|
||||
320872960U,
|
||||
2209424129U,
|
||||
272638976U,
|
||||
2161190145U,
|
||||
2170627585U,
|
||||
300951296U,
|
||||
377497600U,
|
||||
2249271553U,
|
||||
2275486209U,
|
||||
389032704U,
|
||||
2227252225U,
|
||||
340798720U,
|
||||
367013376U,
|
||||
2238787329U,
|
||||
452997120U,
|
||||
2341548289U,
|
||||
2317431297U,
|
||||
447755008U,
|
||||
2302751745U,
|
||||
433075456U,
|
||||
408958464U,
|
||||
2297509633U,
|
||||
2407610369U,
|
||||
521156864U,
|
||||
513817088U,
|
||||
2385591041U,
|
||||
499137536U,
|
||||
2370911489U,
|
||||
2363571713U,
|
||||
477118208U,
|
||||
3019980801U,
|
||||
613433600U,
|
||||
622871040U,
|
||||
3048293121U,
|
||||
641745920U,
|
||||
3067168001U,
|
||||
3076605441U,
|
||||
670058240U,
|
||||
545277952U,
|
||||
2953922817U,
|
||||
2980137473U,
|
||||
556813056U,
|
||||
2999012353U,
|
||||
575687936U,
|
||||
601902592U,
|
||||
3010547457U,
|
||||
754995200U,
|
||||
3180417281U,
|
||||
3156300289U,
|
||||
749753088U,
|
||||
3208729601U,
|
||||
802182400U,
|
||||
778065408U,
|
||||
3203487489U,
|
||||
3112261633U,
|
||||
688937216U,
|
||||
681597440U,
|
||||
3090242305U,
|
||||
734026752U,
|
||||
3142671617U,
|
||||
3135331841U,
|
||||
712007424U,
|
||||
905994240U,
|
||||
2794545409U,
|
||||
2803982849U,
|
||||
934306560U,
|
||||
2755748865U,
|
||||
886072576U,
|
||||
895510016U,
|
||||
2784061185U,
|
||||
2726389761U,
|
||||
839936256U,
|
||||
866150912U,
|
||||
2737924865U,
|
||||
817916928U,
|
||||
2689690881U,
|
||||
2715905537U,
|
||||
829452032U,
|
||||
2936107009U,
|
||||
1066430720U,
|
||||
1042313728U,
|
||||
2930864897U,
|
||||
1027634176U,
|
||||
2916185345U,
|
||||
2892068353U,
|
||||
1022392064U,
|
||||
998275072U,
|
||||
2870049025U,
|
||||
2862709249U,
|
||||
976255744U,
|
||||
2848029697U,
|
||||
961576192U,
|
||||
954236416U,
|
||||
2826010369U,
|
||||
3623976961U,
|
||||
1217429760U,
|
||||
1226867200U,
|
||||
3652289281U,
|
||||
1245742080U,
|
||||
3671164161U,
|
||||
3680601601U,
|
||||
1274054400U,
|
||||
1283491840U,
|
||||
3692136705U,
|
||||
3718351361U,
|
||||
1295026944U,
|
||||
3737226241U,
|
||||
1313901824U,
|
||||
1340116480U,
|
||||
3748761345U,
|
||||
1090555904U,
|
||||
3515977985U,
|
||||
3491860993U,
|
||||
1085313792U,
|
||||
3544290305U,
|
||||
1137743104U,
|
||||
1113626112U,
|
||||
3539048193U,
|
||||
3582040065U,
|
||||
1158715648U,
|
||||
1151375872U,
|
||||
3560020737U,
|
||||
1203805184U,
|
||||
3612450049U,
|
||||
3605110273U,
|
||||
1181785856U,
|
||||
1509990400U,
|
||||
3398541569U,
|
||||
3407979009U,
|
||||
1538302720U,
|
||||
3359745025U,
|
||||
1490068736U,
|
||||
1499506176U,
|
||||
3388057345U,
|
||||
3464603649U,
|
||||
1578150144U,
|
||||
1604364800U,
|
||||
3476138753U,
|
||||
1556130816U,
|
||||
3427904769U,
|
||||
3454119425U,
|
||||
1567665920U,
|
||||
3271667713U,
|
||||
1401991424U,
|
||||
1377874432U,
|
||||
3266425601U,
|
||||
1363194880U,
|
||||
3251746049U,
|
||||
3227629057U,
|
||||
1357952768U,
|
||||
1468053504U,
|
||||
3339827457U,
|
||||
3332487681U,
|
||||
1446034176U,
|
||||
3317808129U,
|
||||
1431354624U,
|
||||
1424014848U,
|
||||
3295788801U,
|
||||
1811988480U,
|
||||
4237410561U,
|
||||
4246848001U,
|
||||
1840300800U,
|
||||
4265722881U,
|
||||
1859175680U,
|
||||
1868613120U,
|
||||
4294035201U,
|
||||
4169254913U,
|
||||
1745930496U,
|
||||
1772145152U,
|
||||
4180790017U,
|
||||
1791020032U,
|
||||
4199664897U,
|
||||
4225879553U,
|
||||
1802555136U,
|
||||
4110536705U,
|
||||
1703989504U,
|
||||
1679872512U,
|
||||
4105294593U,
|
||||
1732301824U,
|
||||
4157723905U,
|
||||
4133606913U,
|
||||
1727059712U,
|
||||
1635833856U,
|
||||
4044478721U,
|
||||
4037138945U,
|
||||
1613814528U,
|
||||
4089568257U,
|
||||
1666243840U,
|
||||
1658904064U,
|
||||
4067548929U,
|
||||
3993100289U,
|
||||
2123424000U,
|
||||
2132861440U,
|
||||
4021412609U,
|
||||
2084627456U,
|
||||
3973178625U,
|
||||
3982616065U,
|
||||
2112939776U,
|
||||
2055268352U,
|
||||
3927042305U,
|
||||
3953256961U,
|
||||
2066803456U,
|
||||
3905022977U,
|
||||
2018569472U,
|
||||
2044784128U,
|
||||
3916558081U,
|
||||
1996550144U,
|
||||
3885101313U,
|
||||
3860984321U,
|
||||
1991308032U,
|
||||
3846304769U,
|
||||
1976628480U,
|
||||
1952511488U,
|
||||
3841062657U,
|
||||
3816945665U,
|
||||
1930492160U,
|
||||
1923152384U,
|
||||
3794926337U,
|
||||
1908472832U,
|
||||
3780246785U,
|
||||
3772907009U,
|
||||
1886453504U
|
||||
};
|
||||
private uint hash;
|
||||
|
||||
protected override void HashCore(byte[] array, int ibStart, int cbSize)
|
||||
{
|
||||
EDC.CheckBufferSize(array, ibStart, cbSize);
|
||||
uint num1 = 0;
|
||||
for (int index = ibStart; index < ibStart + cbSize; ++index)
|
||||
{
|
||||
uint num2 = (uint) (((int) num1 ^ (int) array[ibStart + index]) & (int) byte.MaxValue);
|
||||
num1 = EDC.EDC_CRC_LOOKUP_TABLE[(int) num2] ^ num1 >> 8;
|
||||
}
|
||||
this.hash = num1;
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal() => BitConverter.GetBytes(this.hash);
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
private static uint[] GenerateCRCLookUpTable()
|
||||
{
|
||||
uint[] numArray = new uint[256];
|
||||
for (uint index1 = 0; (long) index1 < (long) numArray.Length; ++index1)
|
||||
{
|
||||
uint num = index1;
|
||||
for (int index2 = 8; index2 > 0; --index2)
|
||||
{
|
||||
if (((int) num & 1) != 0)
|
||||
num = num >> 1 ^ EDC.EDC_POLYNOMIAL;
|
||||
else
|
||||
num >>= 1;
|
||||
}
|
||||
numArray[(int) index1] = num;
|
||||
}
|
||||
return numArray;
|
||||
}
|
||||
|
||||
private static void CheckBufferSize(byte[] buffer, int ibStart, int cbSize)
|
||||
{
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException(nameof (buffer));
|
||||
if (buffer.Length - ibStart < cbSize)
|
||||
throw new ArgumentException("buffer too small");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscFileSystem.DiscFileSystemException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace ImageReader.DiscFileSystem
|
||||
{
|
||||
public class DiscFileSystemException : Exception
|
||||
{
|
||||
public DiscFileSystemException(string message)
|
||||
: base(string.Format("Disc File-System Error: {0}", (object) message))
|
||||
{
|
||||
}
|
||||
|
||||
public DiscFileSystemException(string message, Exception innerException)
|
||||
: base(string.Format("Disc File-System Error: {0}", (object) message), innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public static DiscFileSystemException noFileSystemFoundException() => new DiscFileSystemException("no file-system found!");
|
||||
}
|
||||
}
|
475
SEGATools/Logger.cs
Normal file
475
SEGATools/Logger.cs
Normal file
|
@ -0,0 +1,475 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Logger
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using log4net;
|
||||
using log4net.Core;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SEGATools
|
||||
{
|
||||
public static class Logger
|
||||
{
|
||||
private static readonly bool loggingIsOff = true;
|
||||
|
||||
static Logger()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Assembly.Load("log4net").GetType("log4net.Config.XmlConfigurator").GetMethod("Configure", new Type[0]).Invoke((object) null, (object[]) null);
|
||||
Assembly.Load("log4net");
|
||||
|
||||
Logger.loggingIsOff = false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static Logger.ILog CreateLog()
|
||||
{
|
||||
Type declaringType = new StackFrame(1, false).GetMethod().DeclaringType;
|
||||
return !Logger.loggingIsOff ? (Logger.ILog) new Logger.Log4NetLogger(declaringType) : (Logger.ILog) new Logger.NoLog();
|
||||
}
|
||||
|
||||
public interface ILog
|
||||
{
|
||||
bool IsDebugEnabled { get; }
|
||||
|
||||
bool IsInfoEnabled { get; }
|
||||
|
||||
bool IsWarnEnabled { get; }
|
||||
|
||||
bool IsErrorEnabled { get; }
|
||||
|
||||
bool IsFatalEnabled { get; }
|
||||
|
||||
void Debug(object message);
|
||||
|
||||
void Debug(object message, Exception exception);
|
||||
|
||||
void DebugFormat(string format, params object[] args);
|
||||
|
||||
void DebugFormat(string format, object arg0);
|
||||
|
||||
void DebugFormat(string format, object arg0, object arg1);
|
||||
|
||||
void DebugFormat(string format, object arg0, object arg1, object arg2);
|
||||
|
||||
void DebugFormat(IFormatProvider provider, string format, params object[] args);
|
||||
|
||||
void Info(object message);
|
||||
|
||||
void Info(object message, Exception exception);
|
||||
|
||||
void InfoFormat(string format, params object[] args);
|
||||
|
||||
void InfoFormat(string format, object arg0);
|
||||
|
||||
void InfoFormat(string format, object arg0, object arg1);
|
||||
|
||||
void InfoFormat(string format, object arg0, object arg1, object arg2);
|
||||
|
||||
void InfoFormat(IFormatProvider provider, string format, params object[] args);
|
||||
|
||||
void Warn(object message);
|
||||
|
||||
void Warn(object message, Exception exception);
|
||||
|
||||
void WarnFormat(string format, params object[] args);
|
||||
|
||||
void WarnFormat(string format, object arg0);
|
||||
|
||||
void WarnFormat(string format, object arg0, object arg1);
|
||||
|
||||
void WarnFormat(string format, object arg0, object arg1, object arg2);
|
||||
|
||||
void WarnFormat(IFormatProvider provider, string format, params object[] args);
|
||||
|
||||
void Error(object message);
|
||||
|
||||
void Error(object message, Exception exception);
|
||||
|
||||
void ErrorFormat(string format, params object[] args);
|
||||
|
||||
void ErrorFormat(string format, object arg0);
|
||||
|
||||
void ErrorFormat(string format, object arg0, object arg1);
|
||||
|
||||
void ErrorFormat(string format, object arg0, object arg1, object arg2);
|
||||
|
||||
void ErrorFormat(IFormatProvider provider, string format, params object[] args);
|
||||
|
||||
void Fatal(object message);
|
||||
|
||||
void Fatal(object message, Exception exception);
|
||||
|
||||
void FatalFormat(string format, params object[] args);
|
||||
|
||||
void FatalFormat(string format, object arg0);
|
||||
|
||||
void FatalFormat(string format, object arg0, object arg1);
|
||||
|
||||
void FatalFormat(string format, object arg0, object arg1, object arg2);
|
||||
|
||||
void FatalFormat(IFormatProvider provider, string format, params object[] args);
|
||||
}
|
||||
|
||||
private class NoLog : Logger.ILog
|
||||
{
|
||||
public bool IsDebugEnabled => false;
|
||||
|
||||
public bool IsInfoEnabled => false;
|
||||
|
||||
public bool IsWarnEnabled => false;
|
||||
|
||||
public bool IsErrorEnabled => false;
|
||||
|
||||
public bool IsFatalEnabled => false;
|
||||
|
||||
public void Debug(object message)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug(object message, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
}
|
||||
|
||||
public void DebugFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void Info(object message)
|
||||
{
|
||||
}
|
||||
|
||||
public void Info(object message, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
}
|
||||
|
||||
public void InfoFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warn(object message)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warn(object message, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
}
|
||||
|
||||
public void WarnFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error(object message)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error(object message, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorFormat(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorFormat(string format, object arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal(object message)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal(object message, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalFormat(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalFormat(string format, object arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class Log4NetLogger : Logger.ILog
|
||||
{
|
||||
private readonly log4net.ILog rootLogger;
|
||||
private readonly Type loggingType;
|
||||
private readonly ILogger logger;
|
||||
|
||||
public Log4NetLogger(Type type)
|
||||
{
|
||||
this.loggingType = type;
|
||||
this.rootLogger = LogManager.GetLogger(this.loggingType);
|
||||
this.logger = ((ILoggerWrapper) this.rootLogger).Logger;
|
||||
}
|
||||
|
||||
public bool IsDebugEnabled => this.rootLogger.IsDebugEnabled;
|
||||
|
||||
public bool IsInfoEnabled => this.rootLogger.IsInfoEnabled;
|
||||
|
||||
public bool IsWarnEnabled => this.rootLogger.IsWarnEnabled;
|
||||
|
||||
public bool IsErrorEnabled => this.rootLogger.IsFatalEnabled;
|
||||
|
||||
public bool IsFatalEnabled => this.rootLogger.IsFatalEnabled;
|
||||
|
||||
public void Debug(object message)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, message, (Exception) null);
|
||||
}
|
||||
|
||||
public void Debug(object message, Exception exception)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, message, exception);
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, params object[] args)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0), (Exception) null);
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1), (Exception) null);
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1, arg2), (Exception) null);
|
||||
}
|
||||
|
||||
public void DebugFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, (object) string.Format(provider, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void Info(object message)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, message, (Exception) null);
|
||||
}
|
||||
|
||||
public void Info(object message, Exception exception)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, message, exception);
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, params object[] args)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0), (Exception) null);
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1), (Exception) null);
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1, arg2), (Exception) null);
|
||||
}
|
||||
|
||||
public void InfoFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, (object) string.Format(provider, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void Warn(object message)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, message, (Exception) null);
|
||||
}
|
||||
|
||||
public void Warn(object message, Exception exception)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, message, exception);
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, params object[] args)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0), (Exception) null);
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1), (Exception) null);
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1, arg2), (Exception) null);
|
||||
}
|
||||
|
||||
public void WarnFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, (object) string.Format(provider, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void Error(object message) => this.logger.Log(this.loggingType, (Level) Level.Error, message, (Exception) null);
|
||||
|
||||
public void Error(object message, Exception exception) => this.logger.Log(this.loggingType, (Level) Level.Error, message, exception);
|
||||
|
||||
public void ErrorFormat(string format, params object[] args) => this.logger.Log(this.loggingType, (Level) Level.Error, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, args), (Exception) null);
|
||||
|
||||
public void ErrorFormat(string format, object arg0) => this.logger.Log(this.loggingType, (Level) Level.Error, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0), (Exception) null);
|
||||
|
||||
public void ErrorFormat(string format, object arg0, object arg1) => this.logger.Log(this.loggingType, (Level) Level.Error, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1), (Exception) null);
|
||||
|
||||
public void ErrorFormat(string format, object arg0, object arg1, object arg2) => this.logger.Log(this.loggingType, (Level) Level.Error, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1, arg2), (Exception) null);
|
||||
|
||||
public void ErrorFormat(IFormatProvider provider, string format, params object[] args) => this.logger.Log(this.loggingType, (Level) Level.Error, (object) string.Format(provider, format, args), (Exception) null);
|
||||
|
||||
public void Fatal(object message) => this.logger.Log(this.loggingType, (Level) Level.Fatal, message, (Exception) null);
|
||||
|
||||
public void Fatal(object message, Exception exception) => this.logger.Log(this.loggingType, (Level) Level.Fatal, message, exception);
|
||||
|
||||
public void FatalFormat(string format, params object[] args) => this.logger.Log(this.loggingType, (Level) Level.Fatal, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, args), (Exception) null);
|
||||
|
||||
public void FatalFormat(string format, object arg0) => this.logger.Log(this.loggingType, (Level) Level.Fatal, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0), (Exception) null);
|
||||
|
||||
public void FatalFormat(string format, object arg0, object arg1) => this.logger.Log(this.loggingType, (Level) Level.Fatal, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1), (Exception) null);
|
||||
|
||||
public void FatalFormat(string format, object arg0, object arg1, object arg2) => this.logger.Log(this.loggingType, (Level) Level.Fatal, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1, arg2), (Exception) null);
|
||||
|
||||
public void FatalFormat(IFormatProvider provider, string format, params object[] args) => this.logger.Log(this.loggingType, (Level) Level.Fatal, (object) string.Format(provider, format, args), (Exception) null);
|
||||
}
|
||||
}
|
||||
}
|
94
SEGATools/Properties/Resources.cs
Normal file
94
SEGATools/Properties/Resources.cs
Normal file
|
@ -0,0 +1,94 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Properties.Resources
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System.CodeDom.Compiler;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace SEGATools.Properties
|
||||
{
|
||||
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[DebuggerNonUserCode]
|
||||
[CompilerGenerated]
|
||||
internal class Resources
|
||||
{
|
||||
private static ResourceManager resourceMan;
|
||||
private static CultureInfo resourceCulture;
|
||||
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals((object) SEGATools.Properties.Resources.resourceMan, (object) null))
|
||||
SEGATools.Properties.Resources.resourceMan = new ResourceManager("SEGATools.Properties.Resources", typeof (SEGATools.Properties.Resources).Assembly);
|
||||
return SEGATools.Properties.Resources.resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static CultureInfo Culture
|
||||
{
|
||||
get => SEGATools.Properties.Resources.resourceCulture;
|
||||
set => SEGATools.Properties.Resources.resourceCulture = value;
|
||||
}
|
||||
|
||||
internal static string DiscFormatProviderAllExtensions => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (DiscFormatProviderAllExtensions), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string LibRefColumnBuildDate => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (LibRefColumnBuildDate), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string LibRefColumnName => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (LibRefColumnName), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string LibRefColumnVersion => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (LibRefColumnVersion), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string LibRefHint => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (LibRefHint), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string LibRefNoLibFound => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (LibRefNoLibFound), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string LibRefNumberPlurial => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (LibRefNumberPlurial), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string LibRefNumberSingle => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (LibRefNumberSingle), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string MRImageNoImageMessage => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (MRImageNoImageMessage), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string MRIpImageSegaCustomBranding => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (MRIpImageSegaCustomBranding), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string MRIpImageSegaLicense => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (MRIpImageSegaLicense), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string MRIpImageSegaTM => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (MRIpImageSegaTM), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string SfdMRImageTitle => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (SfdMRImageTitle), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocColumnDataType => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocColumnDataType), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocColumnEnd => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocColumnEnd), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocColumnName => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocColumnName), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocColumnSize => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocColumnSize), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocColumnSizeInBytes => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocColumnSizeInBytes), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocColumnSizeInSectors => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocColumnSizeInSectors), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocColumnStart => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocColumnStart), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocHint => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocHint), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocNoTrackFound => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocNoTrackFound), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocTrackNumberPlurial => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocTrackNumberPlurial), SEGATools.Properties.Resources.resourceCulture);
|
||||
|
||||
internal static string TocTrackNumberSingle => SEGATools.Properties.Resources.ResourceManager.GetString(nameof (TocTrackNumberSingle), SEGATools.Properties.Resources.resourceCulture);
|
||||
}
|
||||
}
|
192
SEGATools/Properties/Resources.resx
Normal file
192
SEGATools/Properties/Resources.resx
Normal file
|
@ -0,0 +1,192 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="LibRefColumnVersion" xml:space="preserve">
|
||||
<value>Version</value>
|
||||
</data>
|
||||
<data name="LibRefColumnName" xml:space="preserve">
|
||||
<value>Library Name</value>
|
||||
</data>
|
||||
<data name="MRIpImageSegaTM" xml:space="preserve">
|
||||
<value>SEGA Trademark Image</value>
|
||||
</data>
|
||||
<data name="TocColumnName" xml:space="preserve">
|
||||
<value>Track</value>
|
||||
</data>
|
||||
<data name="TocColumnSize" xml:space="preserve">
|
||||
<value>Size</value>
|
||||
</data>
|
||||
<data name="TocColumnStart" xml:space="preserve">
|
||||
<value>Start LBA</value>
|
||||
</data>
|
||||
<data name="LibRefNoLibFound" xml:space="preserve">
|
||||
<value>no library found</value>
|
||||
</data>
|
||||
<data name="TocHint" xml:space="preserve">
|
||||
<value>Tracks in the initial program file: {0}</value>
|
||||
</data>
|
||||
<data name="MRImageNoImageMessage" xml:space="preserve">
|
||||
<value>No MR image found!</value>
|
||||
</data>
|
||||
<data name="DiscFormatProviderAllExtensions" xml:space="preserve">
|
||||
<value>All supported image files</value>
|
||||
</data>
|
||||
<data name="LibRefNumberSingle" xml:space="preserve">
|
||||
<value>1 library</value>
|
||||
</data>
|
||||
<data name="TocColumnSizeInBytes" xml:space="preserve">
|
||||
<value>Size (Bytes)</value>
|
||||
</data>
|
||||
<data name="LibRefHint" xml:space="preserve">
|
||||
<value>Libraries used by the initial program file: {0}</value>
|
||||
</data>
|
||||
<data name="SfdMRImageTitle" xml:space="preserve">
|
||||
<value>Save MR image as...</value>
|
||||
</data>
|
||||
<data name="TocTrackNumberSingle" xml:space="preserve">
|
||||
<value>1 track</value>
|
||||
</data>
|
||||
<data name="TocColumnEnd" xml:space="preserve">
|
||||
<value>End LBA</value>
|
||||
</data>
|
||||
<data name="TocNoTrackFound" xml:space="preserve">
|
||||
<value>no track found</value>
|
||||
</data>
|
||||
<data name="MRIpImageSegaCustomBranding" xml:space="preserve">
|
||||
<value>SEGA Custom Branding Image</value>
|
||||
</data>
|
||||
<data name="MRIpImageSegaLicense" xml:space="preserve">
|
||||
<value>SEGA License Image</value>
|
||||
</data>
|
||||
<data name="TocColumnDataType" xml:space="preserve">
|
||||
<value>Type</value>
|
||||
</data>
|
||||
<data name="TocTrackNumberPlurial" xml:space="preserve">
|
||||
<value>{0} tracks</value>
|
||||
</data>
|
||||
<data name="LibRefColumnBuildDate" xml:space="preserve">
|
||||
<value>Build Date</value>
|
||||
</data>
|
||||
<data name="TocColumnSizeInSectors" xml:space="preserve">
|
||||
<value>Size (Sectors)</value>
|
||||
</data>
|
||||
<data name="LibRefNumberPlurial" xml:space="preserve">
|
||||
<value>{0} libraries</value>
|
||||
</data>
|
||||
</root>
|
35
SEGATools/Registry/EditFlags.cs
Normal file
35
SEGATools/Registry/EditFlags.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Registry.EditFlags
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Registry
|
||||
{
|
||||
[Flags]
|
||||
public enum EditFlags : uint
|
||||
{
|
||||
None = 0,
|
||||
Exclude = 1,
|
||||
Show = 2,
|
||||
HasExtension = 4,
|
||||
NoEdit = 8,
|
||||
NoRemove = 16, // 0x00000010
|
||||
NoNewVerb = 32, // 0x00000020
|
||||
NoEditVerb = 64, // 0x00000040
|
||||
NoRemoveVerb = 128, // 0x00000080
|
||||
NoEditDesc = 256, // 0x00000100
|
||||
NoEditIcon = 512, // 0x00000200
|
||||
NoEditDflt = 1024, // 0x00000400
|
||||
NoEditVerbCmd = 2048, // 0x00000800
|
||||
NoEditVerbExe = 4096, // 0x00001000
|
||||
NoDDE = 8192, // 0x00002000
|
||||
NoEditMIME = 32768, // 0x00008000
|
||||
OpenIsSafe = 65536, // 0x00010000
|
||||
AlwaysUnsafe = 131072, // 0x00020000
|
||||
AlwaysShowExtension = 262144, // 0x00040000
|
||||
NoRecentDocuments = 1048576, // 0x00100000
|
||||
}
|
||||
}
|
249
SEGATools/Registry/FileAssociationInfo.cs
Normal file
249
SEGATools/Registry/FileAssociationInfo.cs
Normal file
|
@ -0,0 +1,249 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Registry.FileAssociationInfo
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace SEGATools.Registry
|
||||
{
|
||||
public class FileAssociationInfo
|
||||
{
|
||||
private RegistryWrapper registryWrapper = new RegistryWrapper();
|
||||
private string extension;
|
||||
|
||||
public static string[] GetExtensions()
|
||||
{
|
||||
RegistryKey classesRoot = Microsoft.Win32.Registry.ClassesRoot;
|
||||
List<string> stringList = new List<string>();
|
||||
foreach (string subKeyName in classesRoot.GetSubKeyNames())
|
||||
{
|
||||
if (subKeyName.StartsWith("."))
|
||||
stringList.Add(subKeyName);
|
||||
}
|
||||
return stringList.ToArray();
|
||||
}
|
||||
|
||||
public string ContentType
|
||||
{
|
||||
get => this.GetContentType(this);
|
||||
set => this.SetContentType(this, value);
|
||||
}
|
||||
|
||||
public bool Exists
|
||||
{
|
||||
get
|
||||
{
|
||||
RegistryKey classesRoot = Microsoft.Win32.Registry.ClassesRoot;
|
||||
try
|
||||
{
|
||||
if (classesRoot.OpenSubKey(this.extension) == null)
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public string Extension
|
||||
{
|
||||
get => this.extension;
|
||||
set => this.extension = value;
|
||||
}
|
||||
|
||||
public string[] OpenWithList
|
||||
{
|
||||
get => this.GetOpenWithList(this);
|
||||
set => this.SetOpenWithList(this, value);
|
||||
}
|
||||
|
||||
public PerceivedTypes PerceivedType
|
||||
{
|
||||
get => this.GetPerceivedType(this);
|
||||
set => this.SetPerceivedType(this, value);
|
||||
}
|
||||
|
||||
public Guid PersistentHandler
|
||||
{
|
||||
get => this.GetPersistentHandler(this);
|
||||
set => this.SetPersistentHandler(this, value);
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string ProgID
|
||||
{
|
||||
get => this.GetProgID(this);
|
||||
set => this.SetProgID(this, value);
|
||||
}
|
||||
|
||||
public void Create() => this.Create(this);
|
||||
|
||||
public void Delete() => this.Delete(this);
|
||||
|
||||
public bool IsValid(string extension, string progId)
|
||||
{
|
||||
FileAssociationInfo fileAssociationInfo = new FileAssociationInfo(extension);
|
||||
return fileAssociationInfo.Exists && !(progId != fileAssociationInfo.ProgID);
|
||||
}
|
||||
|
||||
public FileAssociationInfo(string extension) => this.extension = extension;
|
||||
|
||||
public FileAssociationInfo Create(string progId) => this.Create(progId, PerceivedTypes.None, string.Empty, (string[]) null);
|
||||
|
||||
public FileAssociationInfo Create(
|
||||
string progId,
|
||||
PerceivedTypes perceivedType)
|
||||
{
|
||||
return this.Create(progId, perceivedType, string.Empty, (string[]) null);
|
||||
}
|
||||
|
||||
public FileAssociationInfo Create(
|
||||
string progId,
|
||||
PerceivedTypes perceivedType,
|
||||
string contentType)
|
||||
{
|
||||
return this.Create(progId, PerceivedTypes.None, contentType, (string[]) null);
|
||||
}
|
||||
|
||||
public FileAssociationInfo Create(
|
||||
string progId,
|
||||
PerceivedTypes perceivedType,
|
||||
string contentType,
|
||||
string[] openwithList)
|
||||
{
|
||||
FileAssociationInfo fileAssociationInfo = new FileAssociationInfo(this.extension);
|
||||
if (fileAssociationInfo.Exists)
|
||||
fileAssociationInfo.Delete();
|
||||
fileAssociationInfo.Create();
|
||||
fileAssociationInfo.ProgID = progId;
|
||||
if (perceivedType != PerceivedTypes.None)
|
||||
fileAssociationInfo.PerceivedType = perceivedType;
|
||||
if (contentType != string.Empty)
|
||||
fileAssociationInfo.ContentType = contentType;
|
||||
if (openwithList != null)
|
||||
fileAssociationInfo.OpenWithList = openwithList;
|
||||
return fileAssociationInfo;
|
||||
}
|
||||
|
||||
protected string[] GetOpenWithList(FileAssociationInfo file)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(file.extension).OpenSubKey("OpenWithList");
|
||||
return registryKey == null ? new string[0] : registryKey.GetSubKeyNames();
|
||||
}
|
||||
|
||||
protected void SetOpenWithList(FileAssociationInfo file, string[] programList)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(file.extension, true);
|
||||
if (registryKey.OpenSubKey("OpenWithList", true) != null)
|
||||
registryKey.DeleteSubKeyTree("OpenWithList");
|
||||
RegistryKey subKey = registryKey.CreateSubKey("OpenWithList");
|
||||
foreach (string program in programList)
|
||||
subKey.CreateSubKey(program);
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected PerceivedTypes GetPerceivedType(FileAssociationInfo file)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
object obj = this.registryWrapper.Read(file.extension, "PerceivedType");
|
||||
PerceivedTypes perceivedTypes = PerceivedTypes.None;
|
||||
if (obj == null)
|
||||
return perceivedTypes;
|
||||
try
|
||||
{
|
||||
perceivedTypes = (PerceivedTypes) Enum.Parse(typeof (PerceivedTypes), obj.ToString(), true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
return perceivedTypes;
|
||||
}
|
||||
|
||||
protected void SetPerceivedType(FileAssociationInfo file, PerceivedTypes type)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
this.registryWrapper.Write(file.extension, "PerceivedType", (object) type.ToString());
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected Guid GetPersistentHandler(FileAssociationInfo file)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
object obj = this.registryWrapper.Read(file.extension + "\\PersistentHandler", string.Empty);
|
||||
return obj == null ? new Guid() : new Guid(obj.ToString());
|
||||
}
|
||||
|
||||
protected void SetPersistentHandler(FileAssociationInfo file, Guid persistentHandler)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
if (persistentHandler == Guid.Empty)
|
||||
return;
|
||||
this.registryWrapper.Write(file.extension + "\\" + (object) this.PersistentHandler, string.Empty, (object) persistentHandler);
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected string GetContentType(FileAssociationInfo file)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
object obj = this.registryWrapper.Read(file.extension, "Content Type");
|
||||
return obj == null ? string.Empty : obj.ToString();
|
||||
}
|
||||
|
||||
protected void SetContentType(FileAssociationInfo file, string type)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
this.registryWrapper.Write(file.extension, "Content Type", (object) type);
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected string GetProgID(FileAssociationInfo file)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
object obj = this.registryWrapper.Read(file.extension, string.Empty);
|
||||
return obj == null ? string.Empty : obj.ToString();
|
||||
}
|
||||
|
||||
protected void SetProgID(FileAssociationInfo file, string progId)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
this.registryWrapper.Write(file.extension, string.Empty, (object) progId);
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected void Create(FileAssociationInfo file)
|
||||
{
|
||||
if (file.Exists)
|
||||
file.Delete();
|
||||
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(file.extension);
|
||||
}
|
||||
|
||||
protected void Delete(FileAssociationInfo file)
|
||||
{
|
||||
if (!file.Exists)
|
||||
throw new Exception("Key not found.");
|
||||
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(file.extension);
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
}
|
||||
}
|
19
SEGATools/Registry/PerceivedTypes.cs
Normal file
19
SEGATools/Registry/PerceivedTypes.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Registry.PerceivedTypes
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.Registry
|
||||
{
|
||||
public enum PerceivedTypes
|
||||
{
|
||||
None,
|
||||
Image,
|
||||
Text,
|
||||
Audio,
|
||||
Video,
|
||||
Compressed,
|
||||
System,
|
||||
}
|
||||
}
|
328
SEGATools/Registry/ProgramAssociationInfo.cs
Normal file
328
SEGATools/Registry/ProgramAssociationInfo.cs
Normal file
|
@ -0,0 +1,328 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Registry.ProgramAssociationInfo
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SEGATools.Registry
|
||||
{
|
||||
public class ProgramAssociationInfo
|
||||
{
|
||||
private RegistryWrapper registryWrapper = new RegistryWrapper();
|
||||
protected string progId;
|
||||
|
||||
public bool AlwaysShowExtension
|
||||
{
|
||||
get => this.GetAlwaysShowExt();
|
||||
set => this.SetAlwaysShowExt(value);
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get => this.GetDescription();
|
||||
set => this.SetDescription(value);
|
||||
}
|
||||
|
||||
public EditFlags EditFlags
|
||||
{
|
||||
get => this.GetEditFlags();
|
||||
set => this.SetEditFlags(value);
|
||||
}
|
||||
|
||||
public ProgramIcon DefaultIcon
|
||||
{
|
||||
get => this.GetDefaultIcon();
|
||||
set => this.SetDefaultIcon(value);
|
||||
}
|
||||
|
||||
public ProgramVerb[] Verbs
|
||||
{
|
||||
get => this.GetVerbs();
|
||||
set => this.SetVerbs(value);
|
||||
}
|
||||
|
||||
public string ProgID => this.progId;
|
||||
|
||||
public bool Exists
|
||||
{
|
||||
get
|
||||
{
|
||||
RegistryKey classesRoot = Microsoft.Win32.Registry.ClassesRoot;
|
||||
try
|
||||
{
|
||||
if (this.progId == string.Empty)
|
||||
return false;
|
||||
if (classesRoot.OpenSubKey(this.progId) == null)
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Create()
|
||||
{
|
||||
if (this.Exists)
|
||||
return;
|
||||
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(this.progId);
|
||||
}
|
||||
|
||||
public ProgramAssociationInfo Create(ProgramVerb verb) => this.Create(string.Empty, EditFlags.None, new ProgramVerb[1]
|
||||
{
|
||||
verb
|
||||
});
|
||||
|
||||
public ProgramAssociationInfo Create(ProgramVerb[] verbs) => this.Create(string.Empty, EditFlags.None, verbs);
|
||||
|
||||
public ProgramAssociationInfo Create(string description, ProgramVerb verb) => this.Create(description, EditFlags.None, new ProgramVerb[1]
|
||||
{
|
||||
verb
|
||||
});
|
||||
|
||||
public ProgramAssociationInfo Create(
|
||||
string description,
|
||||
ProgramVerb[] verbs)
|
||||
{
|
||||
return this.Create(description, EditFlags.None, verbs);
|
||||
}
|
||||
|
||||
public ProgramAssociationInfo Create(
|
||||
string description,
|
||||
EditFlags editFlags,
|
||||
ProgramVerb verb)
|
||||
{
|
||||
return this.Create(description, editFlags, new ProgramVerb[1]
|
||||
{
|
||||
verb
|
||||
});
|
||||
}
|
||||
|
||||
public ProgramAssociationInfo Create(
|
||||
string description,
|
||||
EditFlags editFlags,
|
||||
ProgramVerb[] verbs)
|
||||
{
|
||||
if (this.Exists)
|
||||
this.Delete();
|
||||
this.Create();
|
||||
if (description != string.Empty)
|
||||
this.Description = description;
|
||||
if (editFlags != EditFlags.None)
|
||||
this.EditFlags = editFlags;
|
||||
this.Verbs = verbs;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected bool GetAlwaysShowExt()
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
return !(Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(this.progId).GetValue("AlwaysShowExt", (object) "ThisValueShouldNotExist").ToString() == "ThisValueShouldNotExist");
|
||||
}
|
||||
|
||||
protected void SetAlwaysShowExt(bool value)
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
if (value)
|
||||
this.registryWrapper.Write(this.progId, "AlwaysShowExt", (object) string.Empty);
|
||||
else
|
||||
this.registryWrapper.Delete(this.progId, "AlwaysShowExt");
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected string GetDescription()
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
object obj = this.registryWrapper.Read(this.progId, string.Empty);
|
||||
return obj == null ? string.Empty : obj.ToString();
|
||||
}
|
||||
|
||||
protected void SetDescription(string description)
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
this.registryWrapper.Write(this.progId, string.Empty, (object) description);
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected EditFlags GetEditFlags()
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
object obj = this.registryWrapper.Read(this.progId, "EditFlags");
|
||||
if (obj == null)
|
||||
return EditFlags.None;
|
||||
if (obj is byte[])
|
||||
{
|
||||
int val;
|
||||
if (!this.TryGetInt(obj as byte[], out val))
|
||||
return EditFlags.None;
|
||||
obj = (object) val;
|
||||
}
|
||||
try
|
||||
{
|
||||
return (EditFlags) Convert.ToUInt32(obj);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
return EditFlags.None;
|
||||
}
|
||||
|
||||
protected void SetEditFlags(EditFlags flags)
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
this.registryWrapper.Write(this.progId, "EditFlags", (object) flags);
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected ProgramIcon GetDefaultIcon()
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
object obj = this.registryWrapper.Read(this.progId + "\\DefaultIcon", "");
|
||||
return obj == null ? ProgramIcon.None : ProgramIcon.Parse(obj.ToString());
|
||||
}
|
||||
|
||||
protected void SetDefaultIcon(ProgramIcon icon)
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
if (!(icon != ProgramIcon.None))
|
||||
return;
|
||||
this.registryWrapper.Write(this.progId + "\\DefaultIcon", "", (object) icon.ToString());
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected ProgramVerb[] GetVerbs()
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
RegistryKey classesRoot = Microsoft.Win32.Registry.ClassesRoot;
|
||||
RegistryKey registryKey1 = classesRoot.OpenSubKey(this.progId);
|
||||
List<ProgramVerb> programVerbList = new List<ProgramVerb>();
|
||||
RegistryKey registryKey2 = registryKey1.OpenSubKey("shell", false);
|
||||
if (registryKey2 != null)
|
||||
{
|
||||
foreach (string subKeyName in registryKey2.GetSubKeyNames())
|
||||
{
|
||||
RegistryKey registryKey3 = registryKey2.OpenSubKey(subKeyName);
|
||||
if (registryKey3 != null)
|
||||
{
|
||||
RegistryKey registryKey4 = registryKey3.OpenSubKey("command");
|
||||
if (registryKey4 != null)
|
||||
{
|
||||
string command = (string) registryKey4.GetValue("", (object) "", RegistryValueOptions.DoNotExpandEnvironmentNames);
|
||||
programVerbList.Add(new ProgramVerb(subKeyName, command));
|
||||
}
|
||||
}
|
||||
}
|
||||
registryKey2.Close();
|
||||
}
|
||||
classesRoot.Close();
|
||||
return programVerbList.ToArray();
|
||||
}
|
||||
|
||||
protected void SetVerbs(ProgramVerb[] verbs)
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Extension does not exist");
|
||||
RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(this.progId, true);
|
||||
if (registryKey.OpenSubKey("shell", true) != null)
|
||||
registryKey.DeleteSubKeyTree("shell");
|
||||
RegistryKey subKey1 = registryKey.CreateSubKey("shell");
|
||||
foreach (ProgramVerb verb in verbs)
|
||||
{
|
||||
RegistryKey subKey2 = subKey1.CreateSubKey(verb.Name.ToLower());
|
||||
RegistryKey subKey3 = subKey2.CreateSubKey("command");
|
||||
subKey3.SetValue(string.Empty, (object) verb.Command, RegistryValueKind.ExpandString);
|
||||
subKey3.Close();
|
||||
subKey2.Close();
|
||||
}
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected void AddVerbInternal(ProgramVerb verb)
|
||||
{
|
||||
RegistryKey classesRoot = Microsoft.Win32.Registry.ClassesRoot;
|
||||
RegistryKey registryKey1 = classesRoot.OpenSubKey(this.progId).OpenSubKey("shell", true) ?? classesRoot.OpenSubKey(this.progId, true).CreateSubKey("shell");
|
||||
RegistryKey registryKey2 = registryKey1.OpenSubKey(verb.Name, true) ?? registryKey1.CreateSubKey(verb.Name);
|
||||
RegistryKey registryKey3 = registryKey2.OpenSubKey("command", true) ?? registryKey2.CreateSubKey("command");
|
||||
registryKey3.SetValue(string.Empty, (object) verb.Command, RegistryValueKind.ExpandString);
|
||||
registryKey3.Close();
|
||||
registryKey2.Close();
|
||||
classesRoot.Close();
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
protected void RemoveVerbInternal(string name)
|
||||
{
|
||||
RegistryKey classesRoot = Microsoft.Win32.Registry.ClassesRoot;
|
||||
RegistryKey registryKey = classesRoot.OpenSubKey(this.progId).OpenSubKey("shell", true);
|
||||
if (registryKey == null)
|
||||
throw new RegistryException("Shell key not found");
|
||||
foreach (string subKeyName in registryKey.GetSubKeyNames())
|
||||
{
|
||||
if (subKeyName == name)
|
||||
{
|
||||
registryKey.DeleteSubKeyTree(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
registryKey.Close();
|
||||
classesRoot.Close();
|
||||
ShellNotification.NotifyOfChange();
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
if (!this.Exists)
|
||||
throw new Exception("Key not found.");
|
||||
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(this.progId);
|
||||
}
|
||||
|
||||
public void AddVerb(ProgramVerb verb) => this.AddVerbInternal(verb);
|
||||
|
||||
public void RemoveVerb(ProgramVerb verb)
|
||||
{
|
||||
if (verb == null)
|
||||
throw new NullReferenceException();
|
||||
this.RemoveVerb(verb.Name);
|
||||
}
|
||||
|
||||
public void RemoveVerb(string name) => this.RemoveVerbInternal(name);
|
||||
|
||||
public ProgramAssociationInfo(string progId) => this.progId = progId;
|
||||
|
||||
private bool TryGetInt(byte[] arr, out int val)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (arr.Length == 0)
|
||||
{
|
||||
val = -1;
|
||||
return false;
|
||||
}
|
||||
val = arr.Length != 1 ? BitConverter.ToInt32(arr, 0) : (int) arr[0];
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
val = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
70
SEGATools/Registry/ProgramIcon.cs
Normal file
70
SEGATools/Registry/ProgramIcon.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Registry.ProgramIcon
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.Registry
|
||||
{
|
||||
public class ProgramIcon
|
||||
{
|
||||
public static readonly ProgramIcon None = new ProgramIcon();
|
||||
private string path;
|
||||
private int index;
|
||||
|
||||
public int Index
|
||||
{
|
||||
get => this.index;
|
||||
set => this.index = value;
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get => this.path;
|
||||
set => this.path = value;
|
||||
}
|
||||
|
||||
public ProgramIcon(string path, int index)
|
||||
{
|
||||
this.path = path;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public ProgramIcon(string path)
|
||||
{
|
||||
this.path = path;
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
public ProgramIcon()
|
||||
{
|
||||
this.path = string.Empty;
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
public override string ToString() => this.path + "," + this.index.ToString();
|
||||
|
||||
public static ProgramIcon Parse(string regString)
|
||||
{
|
||||
if (regString == string.Empty)
|
||||
return new ProgramIcon("");
|
||||
if (regString.StartsWith("\"") && regString.EndsWith("\"") && regString.Length > 3)
|
||||
regString = regString.Substring(1, regString.Length - 2);
|
||||
int index = 0;
|
||||
int length = regString.IndexOf(",");
|
||||
if (length == -1)
|
||||
length = regString.Length;
|
||||
else
|
||||
index = int.Parse(regString.Substring(length + 1));
|
||||
return new ProgramIcon(regString.Substring(0, length), index);
|
||||
}
|
||||
|
||||
public static bool operator ==(ProgramIcon lv, ProgramIcon rv) => object.ReferenceEquals((object) lv, (object) null) && object.ReferenceEquals((object) rv, (object) null) || !object.ReferenceEquals((object) lv, (object) null) && !object.ReferenceEquals((object) rv, (object) null) && (lv.path == rv.path && lv.index == rv.index);
|
||||
|
||||
public static bool operator !=(ProgramIcon lv, ProgramIcon rv) => !(lv == rv);
|
||||
|
||||
public override bool Equals(object obj) => this == obj as ProgramIcon;
|
||||
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
}
|
||||
}
|
24
SEGATools/Registry/ProgramVerb.cs
Normal file
24
SEGATools/Registry/ProgramVerb.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Registry.ProgramVerb
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.Registry
|
||||
{
|
||||
public class ProgramVerb
|
||||
{
|
||||
private string command;
|
||||
private string name;
|
||||
|
||||
public string Command => this.command;
|
||||
|
||||
public string Name => this.name;
|
||||
|
||||
public ProgramVerb(string name, string command)
|
||||
{
|
||||
this.name = name;
|
||||
this.command = command;
|
||||
}
|
||||
}
|
||||
}
|
27
SEGATools/Registry/RegistryException.cs
Normal file
27
SEGATools/Registry/RegistryException.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Registry.RegistryException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Registry
|
||||
{
|
||||
public class RegistryException : ApplicationException
|
||||
{
|
||||
public RegistryException()
|
||||
{
|
||||
}
|
||||
|
||||
public RegistryException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public RegistryException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
103
SEGATools/Registry/RegistryWrapper.cs
Normal file
103
SEGATools/Registry/RegistryWrapper.cs
Normal file
|
@ -0,0 +1,103 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Registry.RegistryWrapper
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Registry
|
||||
{
|
||||
internal class RegistryWrapper
|
||||
{
|
||||
public object Read(string path, string valueName)
|
||||
{
|
||||
RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot;
|
||||
string[] strArray = path.Split('\\');
|
||||
if (strArray == null || strArray.Length == 0)
|
||||
return (object) null;
|
||||
for (int index = 0; index < strArray.Length; ++index)
|
||||
{
|
||||
registryKey = registryKey.OpenSubKey(strArray[index]);
|
||||
if (registryKey == null)
|
||||
return (object) null;
|
||||
if (index == strArray.Length - 1)
|
||||
return registryKey.GetValue(valueName, (object) null, RegistryValueOptions.DoNotExpandEnvironmentNames);
|
||||
}
|
||||
return (object) null;
|
||||
}
|
||||
|
||||
public void Write(string path, string valueName, object value)
|
||||
{
|
||||
RegistryKey registryKey1 = Microsoft.Win32.Registry.ClassesRoot;
|
||||
RegistryKey registryKey2 = registryKey1;
|
||||
string[] strArray = path.Split('\\');
|
||||
if (strArray == null || strArray.Length == 0)
|
||||
return;
|
||||
for (int index = 0; index < strArray.Length; ++index)
|
||||
{
|
||||
registryKey1 = registryKey1.OpenSubKey(strArray[index], true) ?? registryKey2.CreateSubKey(strArray[index]);
|
||||
if (index == strArray.Length - 1)
|
||||
{
|
||||
if (value is string)
|
||||
registryKey1.SetValue(valueName, (object) value.ToString());
|
||||
else if (value is uint || value.GetType().IsEnum)
|
||||
{
|
||||
if (registryKey1.GetValue(valueName, (object) null) == null)
|
||||
{
|
||||
registryKey1.SetValue(valueName, value, RegistryValueKind.DWord);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (registryKey1.GetValueKind(valueName))
|
||||
{
|
||||
case RegistryValueKind.String:
|
||||
registryKey1.SetValue(valueName, (object) ("x" + ((uint) value).ToString("X8")));
|
||||
break;
|
||||
case RegistryValueKind.Binary:
|
||||
uint num = (uint) value;
|
||||
byte[] numArray = new byte[4]
|
||||
{
|
||||
(byte) (num & (uint) byte.MaxValue),
|
||||
(byte) ((num & 65280U) >> 1),
|
||||
(byte) ((num & 16711680U) >> 2),
|
||||
(byte) ((num & 4278190080U) >> 3)
|
||||
};
|
||||
numArray[0] = (byte) (num & (uint) byte.MaxValue);
|
||||
numArray[1] = (byte) ((num & 65280U) >> 8);
|
||||
numArray[2] = (byte) ((num & 16711680U) >> 16);
|
||||
numArray[3] = (byte) ((num & 4278190080U) >> 24);
|
||||
registryKey1.SetValue(valueName, (object) numArray, RegistryValueKind.Binary);
|
||||
break;
|
||||
case RegistryValueKind.DWord:
|
||||
registryKey1.SetValue(valueName, value, RegistryValueKind.DWord);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (value is Guid guid)
|
||||
registryKey1.SetValue(valueName, (object) guid.ToString("B"));
|
||||
}
|
||||
registryKey2 = registryKey1;
|
||||
}
|
||||
registryKey1?.Close();
|
||||
}
|
||||
|
||||
public void Delete(string path, string valueName)
|
||||
{
|
||||
RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot;
|
||||
string[] strArray = path.Split('\\');
|
||||
if (strArray == null || strArray.Length == 0)
|
||||
return;
|
||||
for (int index = 0; index < strArray.Length; ++index)
|
||||
{
|
||||
registryKey = registryKey.OpenSubKey(strArray[index], true);
|
||||
if (registryKey == null)
|
||||
break;
|
||||
if (index == strArray.Length - 1)
|
||||
registryKey.DeleteValue(valueName, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
66
SEGATools/Registry/ShellNotification.cs
Normal file
66
SEGATools/Registry/ShellNotification.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Registry.ShellNotification
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SEGATools.Registry
|
||||
{
|
||||
internal class ShellNotification
|
||||
{
|
||||
[DllImport("shell32.dll")]
|
||||
private static extern void SHChangeNotify(
|
||||
uint wEventId,
|
||||
uint uFlags,
|
||||
IntPtr dwItem1,
|
||||
IntPtr dwItem2);
|
||||
|
||||
public static void NotifyOfChange() => ShellNotification.SHChangeNotify(134217728U, 8192U, IntPtr.Zero, IntPtr.Zero);
|
||||
|
||||
[Flags]
|
||||
private enum ShellChangeNotificationEvents : uint
|
||||
{
|
||||
SHCNE_RENAMEITEM = 1,
|
||||
SHCNE_CREATE = 2,
|
||||
SHCNE_DELETE = 4,
|
||||
SHCNE_MKDIR = 8,
|
||||
SHCNE_RMDIR = 16, // 0x00000010
|
||||
SHCNE_MEDIAINSERTED = 32, // 0x00000020
|
||||
SHCNE_MEDIAREMOVED = 64, // 0x00000040
|
||||
SHCNE_DRIVEREMOVED = 128, // 0x00000080
|
||||
SHCNE_DRIVEADD = 256, // 0x00000100
|
||||
SHCNE_NETSHARE = 512, // 0x00000200
|
||||
SHCNE_NETUNSHARE = 1024, // 0x00000400
|
||||
SHCNE_ATTRIBUTES = 2048, // 0x00000800
|
||||
SHCNE_UPDATEDIR = 4096, // 0x00001000
|
||||
SHCNE_UPDATEITEM = 8192, // 0x00002000
|
||||
SHCNE_SERVERDISCONNECT = 16384, // 0x00004000
|
||||
SHCNE_UPDATEIMAGE = 32768, // 0x00008000
|
||||
SHCNE_DRIVEADDGUI = 65536, // 0x00010000
|
||||
SHCNE_RENAMEFOLDER = 131072, // 0x00020000
|
||||
SHCNE_FREESPACE = 262144, // 0x00040000
|
||||
SHCNE_EXTENDED_EVENT = 67108864, // 0x04000000
|
||||
SHCNE_ASSOCCHANGED = 134217728, // 0x08000000
|
||||
SHCNE_DISKEVENTS = SHCNE_RENAMEFOLDER | SHCNE_UPDATEITEM | SHCNE_UPDATEDIR | SHCNE_ATTRIBUTES | SHCNE_RMDIR | SHCNE_MKDIR | SHCNE_DELETE | SHCNE_CREATE | SHCNE_RENAMEITEM, // 0x0002381F
|
||||
SHCNE_GLOBALEVENTS = SHCNE_ASSOCCHANGED | SHCNE_EXTENDED_EVENT | SHCNE_FREESPACE | SHCNE_DRIVEADDGUI | SHCNE_UPDATEIMAGE | SHCNE_DRIVEADD | SHCNE_DRIVEREMOVED | SHCNE_MEDIAREMOVED | SHCNE_MEDIAINSERTED, // 0x0C0581E0
|
||||
SHCNE_ALLEVENTS = 2147483647, // 0x7FFFFFFF
|
||||
SHCNE_INTERRUPT = 2147483648, // 0x80000000
|
||||
}
|
||||
|
||||
private enum ShellChangeNotificationFlags
|
||||
{
|
||||
SHCNF_IDLIST = 0,
|
||||
SHCNF_PATHA = 1,
|
||||
SHCNF_PRINTERA = 2,
|
||||
SHCNF_DWORD = 3,
|
||||
SHCNF_PATHW = 5,
|
||||
SHCNF_PRINTERW = 6,
|
||||
SHCNF_TYPE = 255, // 0x000000FF
|
||||
SHCNF_FLUSH = 4096, // 0x00001000
|
||||
SHCNF_FLUSHNOWAIT = 8192, // 0x00002000
|
||||
}
|
||||
}
|
||||
}
|
229
SEGATools/SEGATools.csproj
Normal file
229
SEGATools/SEGATools.csproj
Normal file
|
@ -0,0 +1,229 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!--Project was exported from assembly: C:\Games\gdrom\SEGATools.dll-->
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{4D3AB913-88D2-4DD1-A403-EA46D14C98E6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AssemblyName>SEGATools</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<ApplicationVersion>1.0.3.0</ApplicationVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<RootNamespace>SEGATools</RootNamespace>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\GD-ROM Explorer\packages\log4net.2.0.12\lib\net35\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ImageReader\DiscFileSystem\DiscFileSystemException.cs" />
|
||||
<Compile Include="AssemblyGitBuildSHA1.cs" />
|
||||
<Compile Include="AssemblyGitBuildBranch.cs" />
|
||||
<Compile Include="AssemblyTest.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="Audio\AudioConversionSettings.cs" />
|
||||
<Compile Include="Audio\AudioConversionSettingsViewer.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Audio\Raw2WavConverter.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Audio\CanonicalWaveHeader.cs" />
|
||||
<Compile Include="Audio\UninitialiedSampleDataSizeException.cs" />
|
||||
<Compile Include="UserProcess\UserProcessBase.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserProcess\AsyncOperationProgressChangedEventHandler.cs" />
|
||||
<Compile Include="UserProcess\AsyncOperationCompletedEventHandler.cs" />
|
||||
<Compile Include="UserProcess\AsyncOperationProgressWaitingForUserConsentEventHa.cs" />
|
||||
<Compile Include="UserProcess\AsyncOperationProgressUpdateUIEventHandler.cs" />
|
||||
<Compile Include="UserProcess\UserProcessProgressChangedEventArgs.cs" />
|
||||
<Compile Include="UserProcess\UserProcessCompletedEventArgs.cs" />
|
||||
<Compile Include="UserProcess\UserProcessWaitingForUserConsentEventArgs.cs" />
|
||||
<Compile Include="UserProcess\UserProcessWaitingForUserConsentFileConflictEventA.cs" />
|
||||
<Compile Include="UserProcess\UserProcessUpdateUIViewEventArgs.cs" />
|
||||
<Compile Include="Binary\BinaryPatch.cs" />
|
||||
<Compile Include="Binary\BinaryPatcher.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Binary\InitialProgramPatches.cs" />
|
||||
<Compile Include="Binary\SEGALibraryType.cs" />
|
||||
<Compile Include="Binary\SEGALibrary.cs" />
|
||||
<Compile Include="Binary\SEGALibraryVersion.cs" />
|
||||
<Compile Include="Disc\DiscSectorEncoder.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Disc\DiscFormatProvider.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Disc\DiscExtractor.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Disc\DiscExtractorException.cs" />
|
||||
<Compile Include="Disc\DiscOpener.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GDEmu\DiscTrackCopyInfo.cs" />
|
||||
<Compile Include="GDEmu\GDEmuConverter.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GDEmu\GDEmuExportOptions.cs" />
|
||||
<Compile Include="GDEmu\GDICreator.cs" />
|
||||
<Compile Include="HashAlgorithm\ECC.cs" />
|
||||
<Compile Include="HashAlgorithm\EDC.cs" />
|
||||
<Compile Include="Scanner\IFileScannerResultConverter`1.cs" />
|
||||
<Compile Include="Scanner\FileScanner.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Scanner\FileScannerException.cs" />
|
||||
<Compile Include="Scanner\FileScannerWrongArgumentsException.cs" />
|
||||
<Compile Include="Scanner\FileScannerPattern.cs" />
|
||||
<Compile Include="Scanner\FileScannerResultConverterForSEGALibrary.cs" />
|
||||
<Compile Include="Scanner\FileScannerResultConverterException.cs" />
|
||||
<Compile Include="Security\InitialProgramException.cs" />
|
||||
<Compile Include="Security\InitialProgramReleaseDateParsingException.cs" />
|
||||
<Compile Include="Security\InitialProgramInvalidHardwareIdException.cs" />
|
||||
<Compile Include="Security\InitialProgramInvalidMakerIdException.cs" />
|
||||
<Compile Include="Security\InitialProgramInvalidMRImageException.cs" />
|
||||
<Compile Include="Security\InitialProgramFieldParsingException.cs" />
|
||||
<Compile Include="Security\InitialProgramGeneralSettingsViewer.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\InitialProgramLibraryReferences.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\InitialProgramPeripheralsViewer.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\InitialProgramToc.cs" />
|
||||
<Compile Include="Security\InitialProgramTocViewer.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\InitialProgram.cs" />
|
||||
<Compile Include="Security\InitialProgramExtended.cs" />
|
||||
<Compile Include="Security\InitialProgramTocException.cs" />
|
||||
<Compile Include="Security\InitialProgramTocIdentifierMissingException.cs" />
|
||||
<Compile Include="Security\InitialProgramTocWrongNumberOfTracksException.cs" />
|
||||
<Compile Include="Security\InitialProgramTocWrongControlDataException.cs" />
|
||||
<Compile Include="Security\InitialProgramTrackInfo.cs" />
|
||||
<Compile Include="Security\InitialProgramTocTrackBuilder.cs" />
|
||||
<Compile Include="Security\SupportedAreas.cs" />
|
||||
<Compile Include="Security\SupportedButtons.cs" />
|
||||
<Compile Include="Security\SupportedExpandedPeripherals.cs" />
|
||||
<Compile Include="Security\SupportedPeripherals.cs" />
|
||||
<Compile Include="Security\InitialProgramImagesViewer.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\InitialProgramConverter.cs" />
|
||||
<Compile Include="Security\InitialProgramTocConverter.cs" />
|
||||
<Compile Include="Security\InitialProgramUtils.cs" />
|
||||
<Compile Include="CueSheet\CueSheetCreator.cs" />
|
||||
<Compile Include="DiscFileSystem\DiscImageType.cs" />
|
||||
<Compile Include="DiscFileSystem\TrackModeType.cs" />
|
||||
<Compile Include="DiscFileSystem\IDiscFileSystem.cs" />
|
||||
<Compile Include="DiscFileSystem\DiscFileSystem.cs" />
|
||||
<Compile Include="DiscFileSystem\DiscFileUtils.cs" />
|
||||
<Compile Include="DiscFileSystem\IDiscSession.cs" />
|
||||
<Compile Include="DiscFileSystem\DiscSession.cs" />
|
||||
<Compile Include="DiscFileSystem\IDiscTrack.cs" />
|
||||
<Compile Include="DiscFileSystem\DiscTrack.cs" />
|
||||
<Compile Include="DiscFileSystem\DiscFileSystemBuilder.cs" />
|
||||
<Compile Include="DiscFileSystem\DiscFormatException.cs" />
|
||||
<Compile Include="DiscFileSystem\IDiscFileSystemConverter.cs" />
|
||||
<Compile Include="DiscFileSystem\GenericImageConverter.cs" />
|
||||
<Compile Include="VirtualFile\IVirtualFile.cs" />
|
||||
<Compile Include="VirtualFile\VirtualFileFactory.cs" />
|
||||
<Compile Include="VirtualFile\IVirtualFile`1.cs" />
|
||||
<Compile Include="VirtualFile\VirtualFileBase`1.cs" />
|
||||
<Compile Include="VirtualFile\VirtualFileOnDisc.cs" />
|
||||
<Compile Include="VirtualFile\VirtualFileStream.cs" />
|
||||
<Compile Include="VirtualFile\VirtualFileDirectoryRecord.cs" />
|
||||
<Compile Include="VirtualFile\VirtualFileInitialProgramExtended.cs" />
|
||||
<Compile Include="Stream\SubStream.cs" />
|
||||
<Compile Include="FileFormat\IImageFileFormat.cs" />
|
||||
<Compile Include="FileFormat\AbstractImageFileFormat.cs" />
|
||||
<Compile Include="Encrypt\DesEncryptDecryptTool.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Encrypt\DESKey.cs" />
|
||||
<Compile Include="Graphics\MRImage.cs" />
|
||||
<Compile Include="Graphics\MRImageHeader.cs" />
|
||||
<Compile Include="Graphics\MRImageColor.cs" />
|
||||
<Compile Include="Graphics\MRImageConverter.cs" />
|
||||
<Compile Include="Graphics\MRImageReadingException.cs" />
|
||||
<Compile Include="Graphics\MRImageDecompressionException.cs" />
|
||||
<Compile Include="Graphics\MRImageIdentifierMissingException.cs" />
|
||||
<Compile Include="Graphics\MRImageUnknownColorException.cs" />
|
||||
<Compile Include="Graphics\MRImageExporter.cs" />
|
||||
<Compile Include="Graphics\MRImageViewer.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.cs" />
|
||||
<Compile Include="SortFile\SortFileCreator.cs" />
|
||||
<Compile Include="Formater\SizeFormater.cs" />
|
||||
<Compile Include="Registry\PerceivedTypes.cs" />
|
||||
<Compile Include="Registry\FileAssociationInfo.cs" />
|
||||
<Compile Include="Registry\EditFlags.cs" />
|
||||
<Compile Include="Registry\ProgramAssociationInfo.cs" />
|
||||
<Compile Include="Registry\ProgramIcon.cs" />
|
||||
<Compile Include="Registry\ProgramVerb.cs" />
|
||||
<Compile Include="Registry\RegistryException.cs" />
|
||||
<Compile Include="Registry\RegistryWrapper.cs" />
|
||||
<Compile Include="Registry\ShellNotification.cs" />
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Audio\AudioConversionSettingsViewer.resx" />
|
||||
<EmbeddedResource Include="Graphics\MRImageViewer.resx" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx" />
|
||||
<EmbeddedResource Include="Security\InitialProgramGeneralSettingsViewer.resx" />
|
||||
<EmbeddedResource Include="Security\InitialProgramImagesViewer.resx" />
|
||||
<EmbeddedResource Include="Security\InitialProgramLibraryReferences.resx" />
|
||||
<EmbeddedResource Include="Security\InitialProgramPeripheralsViewer.resx" />
|
||||
<EmbeddedResource Include="Security\InitialProgramTocViewer.resx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ImageReader\ImageReader.csproj">
|
||||
<Project>{2185f55e-a4da-486f-acc8-3ee955205ce4}</Project>
|
||||
<Name>ImageReader</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
175
SEGATools/Scanner/FileScanner.cs
Normal file
175
SEGATools/Scanner/FileScanner.cs
Normal file
|
@ -0,0 +1,175 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Scanner.FileScanner
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.UserProcess;
|
||||
using SEGATools.VirtualFile;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SEGATools.Scanner
|
||||
{
|
||||
public class FileScanner : UserProcessBase
|
||||
{
|
||||
private static readonly int MAX_ASCII_STRING_LENGTH = 128;
|
||||
|
||||
public event AsyncOperationProgressChangedEventHandler FileScanningProgressChanged
|
||||
{
|
||||
add => this.AsyncOperationProgressChanged += value;
|
||||
remove => this.AsyncOperationProgressChanged -= value;
|
||||
}
|
||||
|
||||
public event AsyncOperationCompletedEventHandler FileScanningCompleted
|
||||
{
|
||||
add => this.AsyncOperationCompleted += value;
|
||||
remove => this.AsyncOperationCompleted -= value;
|
||||
}
|
||||
|
||||
public FileScanner()
|
||||
{
|
||||
}
|
||||
|
||||
public FileScanner(IContainer container)
|
||||
: base(container)
|
||||
{
|
||||
}
|
||||
|
||||
public List<T> ScanFile<T>(
|
||||
IVirtualFile file,
|
||||
FileScannerPattern pattern,
|
||||
IFileScannerResultConverter<T> resultConverter)
|
||||
{
|
||||
return this.DoFileScanning<T>(file, new List<FileScannerPattern>()
|
||||
{
|
||||
pattern
|
||||
}, resultConverter, (AsyncOperation) null)[pattern];
|
||||
}
|
||||
|
||||
public void ScanFileAsync<T>(
|
||||
IVirtualFile file,
|
||||
FileScannerPattern pattern,
|
||||
IFileScannerResultConverter<T> resultConverter,
|
||||
object taskId)
|
||||
{
|
||||
this.ScanFilesAsync<T>(file, new List<FileScannerPattern>()
|
||||
{
|
||||
pattern
|
||||
}, resultConverter, taskId);
|
||||
}
|
||||
|
||||
public void ScanFileAsync<T>(
|
||||
IVirtualFile file,
|
||||
List<FileScannerPattern> patterns,
|
||||
IFileScannerResultConverter<T> resultConverter,
|
||||
object taskId)
|
||||
{
|
||||
this.ScanFilesAsync<T>(file, patterns, resultConverter, taskId);
|
||||
}
|
||||
|
||||
public void ScanFilesAsync<T>(
|
||||
IVirtualFile file,
|
||||
List<FileScannerPattern> patterns,
|
||||
IFileScannerResultConverter<T> resultConverter,
|
||||
object taskId)
|
||||
{
|
||||
AsyncOperation asyncOperation = this.CreateAsyncOperation(taskId);
|
||||
new FileScanner.FileScannerWorkerEventHandler<T>(this.FileScannerWorker<T>).BeginInvoke(file, patterns, resultConverter, asyncOperation, (AsyncCallback) null, (object) null);
|
||||
}
|
||||
|
||||
private void FileScannerWorker<T>(
|
||||
IVirtualFile file,
|
||||
List<FileScannerPattern> patterns,
|
||||
IFileScannerResultConverter<T> resultConverter,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
Exception exception = (Exception) null;
|
||||
try
|
||||
{
|
||||
this.CheckArguments(file, patterns);
|
||||
this.DoFileScanning<T>(file, patterns, resultConverter, asyncOp);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
UserProcessBase.logger.DebugFormat("Unable to scan file {0}: {1}", (object) file.VirtualName, (object) ex);
|
||||
}
|
||||
if (!this.TaskCanceled(asyncOp))
|
||||
;
|
||||
this.ReportCompletion(string.Empty, exception, asyncOp);
|
||||
}
|
||||
|
||||
private void CheckArguments(IVirtualFile file, List<FileScannerPattern> patterns)
|
||||
{
|
||||
if (patterns == null || patterns.Count == 0)
|
||||
throw FileScannerWrongArgumentsException.aNotValidArgument(nameof (patterns));
|
||||
if (file == null || file.FileInputStream == null)
|
||||
throw FileScannerWrongArgumentsException.aNotValidArgument(nameof (file));
|
||||
}
|
||||
|
||||
private Dictionary<FileScannerPattern, List<T>> DoFileScanning<T>(
|
||||
IVirtualFile file,
|
||||
List<FileScannerPattern> patterns,
|
||||
IFileScannerResultConverter<T> resultConverter,
|
||||
AsyncOperation asyncOp)
|
||||
{
|
||||
Dictionary<FileScannerPattern, List<T>> dictionary = new Dictionary<FileScannerPattern, List<T>>(patterns.Count);
|
||||
foreach (FileScannerPattern pattern in patterns)
|
||||
dictionary[pattern] = new List<T>();
|
||||
UserProcessBase.logger.DebugFormat("Scanning {0}...", (object) file.VirtualName);
|
||||
foreach (FileScannerPattern pattern in patterns)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(file.FileInputStream, Encoding.ASCII))
|
||||
{
|
||||
binaryReader.BaseStream.Seek(0L, SeekOrigin.Begin);
|
||||
while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
|
||||
{
|
||||
try
|
||||
{
|
||||
int count = Math.Min(Convert.ToInt32(binaryReader.BaseStream.Length - binaryReader.BaseStream.Position), FileScanner.MAX_ASCII_STRING_LENGTH);
|
||||
string input = new string(binaryReader.ReadChars(count));
|
||||
if (pattern.Match(input))
|
||||
{
|
||||
UserProcessBase.logger.DebugFormat("Found string for pattern {0}: {1}", (object) pattern, (object) pattern.CapturedString);
|
||||
T obj = this.ConvertResult<T>(pattern.MatchResult, resultConverter);
|
||||
if ((object) obj != null)
|
||||
dictionary[pattern].Add(obj);
|
||||
}
|
||||
else if (count > 0)
|
||||
binaryReader.BaseStream.Seek((long) (-count + 1), SeekOrigin.Current);
|
||||
}
|
||||
catch (OverflowException ex)
|
||||
{
|
||||
UserProcessBase.logger.ErrorFormat("Unable to compute the number of remaining bytes in the stream: {0}", (object) ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
private T ConvertResult<T>(Match match, IFileScannerResultConverter<T> resultConverter)
|
||||
{
|
||||
try
|
||||
{
|
||||
return resultConverter.ToResult(match);
|
||||
}
|
||||
catch (FileScannerResultConverterException ex)
|
||||
{
|
||||
UserProcessBase.logger.ErrorFormat("Unable to convert match result with to {0}: {1}", (object) resultConverter.GetType().AssemblyQualifiedName, (object) ex);
|
||||
}
|
||||
return default (T);
|
||||
}
|
||||
|
||||
private delegate void FileScannerWorkerEventHandler<T>(
|
||||
IVirtualFile file,
|
||||
List<FileScannerPattern> patterns,
|
||||
IFileScannerResultConverter<T> resultConverter,
|
||||
AsyncOperation asyncOp);
|
||||
}
|
||||
}
|
23
SEGATools/Scanner/FileScannerException.cs
Normal file
23
SEGATools/Scanner/FileScannerException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Scanner.FileScannerException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Scanner
|
||||
{
|
||||
public class FileScannerException : Exception
|
||||
{
|
||||
protected FileScannerException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
protected FileScannerException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
46
SEGATools/Scanner/FileScannerPattern.cs
Normal file
46
SEGATools/Scanner/FileScannerPattern.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Scanner.FileScannerPattern
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.Binary;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SEGATools.Scanner
|
||||
{
|
||||
public sealed class FileScannerPattern
|
||||
{
|
||||
private static readonly string SEGA_IP_LIBRARIES = "^(?<library>\\w+)\\s(ver|version:)\\s(?<version_major>\\d+)(\\.)(?<version_minor>\\d+)(\\s|\\x00\\k<library>\\s)(build:)(?<date>\\w{3}\\s\\d{2}\\s\\d{4})\\s?(?<time>\\d{2}:\\d{2}:\\d{2})";
|
||||
|
||||
public string CapturedString { get; private set; }
|
||||
|
||||
public string Pattern { get; private set; }
|
||||
|
||||
public Regex RegularExpression { get; private set; }
|
||||
|
||||
public System.Text.RegularExpressions.Match MatchResult { get; private set; }
|
||||
|
||||
public Type ResultType { get; private set; }
|
||||
|
||||
public static FileScannerPattern aPatternForSEGALibraries() => new FileScannerPattern(FileScannerPattern.SEGA_IP_LIBRARIES, true, typeof (SEGALibrary));
|
||||
|
||||
private FileScannerPattern(string Pattern, bool IgnoreCase, Type ResultType)
|
||||
{
|
||||
RegexOptions options = RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.CultureInvariant;
|
||||
if (IgnoreCase)
|
||||
options |= RegexOptions.IgnoreCase;
|
||||
this.Pattern = Pattern;
|
||||
this.RegularExpression = new Regex(Pattern, options);
|
||||
this.ResultType = ResultType;
|
||||
}
|
||||
|
||||
public bool Match(string input)
|
||||
{
|
||||
this.MatchResult = this.RegularExpression.Match(input);
|
||||
this.CapturedString = this.MatchResult.Value.Replace(char.MinValue, ' ').Trim();
|
||||
return this.MatchResult.Success;
|
||||
}
|
||||
}
|
||||
}
|
29
SEGATools/Scanner/FileScannerResultConverterException.cs
Normal file
29
SEGATools/Scanner/FileScannerResultConverterException.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Scanner.FileScannerResultConverterException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Scanner
|
||||
{
|
||||
public class FileScannerResultConverterException : Exception
|
||||
{
|
||||
protected FileScannerResultConverterException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
protected FileScannerResultConverterException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public static FileScannerResultConverterException aParsingException(
|
||||
Exception innerException)
|
||||
{
|
||||
return new FileScannerResultConverterException("Unable to parse the FileScannerResult", innerException);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Scanner.FileScannerResultConverterForSEGALibrary
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.Binary;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SEGATools.Scanner
|
||||
{
|
||||
public class FileScannerResultConverterForSEGALibrary : IFileScannerResultConverter<SEGALibrary>
|
||||
{
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
|
||||
public SEGALibrary ToResult(Match match)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime exact = DateTime.ParseExact(match.Groups["date"].Value + " " + match.Groups["time"].Value, "MMM dd yyyy HH:mm:ss", (IFormatProvider) CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat);
|
||||
SEGALibraryVersion Version = new SEGALibraryVersion(match.Groups["version_major"].Value, match.Groups["version_minor"].Value);
|
||||
return new SEGALibrary(match.Groups["library"].Value, Version, exact);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw FileScannerResultConverterException.aParsingException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
SEGATools/Scanner/FileScannerWrongArgumentsException.cs
Normal file
29
SEGATools/Scanner/FileScannerWrongArgumentsException.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Scanner.FileScannerWrongArgumentsException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Scanner
|
||||
{
|
||||
public class FileScannerWrongArgumentsException : FileScannerException
|
||||
{
|
||||
private FileScannerWrongArgumentsException(string message)
|
||||
: base(string.Format("String Scanner Wrong Argument Error: {0}", (object) message))
|
||||
{
|
||||
}
|
||||
|
||||
private FileScannerWrongArgumentsException(string message, Exception innerException)
|
||||
: base(string.Format("String Scanner Wrong Argument Error: {0}", (object) message), innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public static FileScannerWrongArgumentsException aNotValidArgument(
|
||||
string argumentName)
|
||||
{
|
||||
return new FileScannerWrongArgumentsException(string.Format("the argument \"{0}\" is not valid", (object) argumentName));
|
||||
}
|
||||
}
|
||||
}
|
15
SEGATools/Scanner/IFileScannerResultConverter`1.cs
Normal file
15
SEGATools/Scanner/IFileScannerResultConverter`1.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Scanner.IFileScannerResultConverter`1
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SEGATools.Scanner
|
||||
{
|
||||
public interface IFileScannerResultConverter<T>
|
||||
{
|
||||
T ToResult(Match MatchResults);
|
||||
}
|
||||
}
|
133
SEGATools/Security/InitialProgram.cs
Normal file
133
SEGATools/Security/InitialProgram.cs
Normal file
|
@ -0,0 +1,133 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgram
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.Graphics;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgram
|
||||
{
|
||||
public static readonly uint IP_FILESIZE = 32768;
|
||||
private static readonly string IP_FILENAME = "IP.BIN";
|
||||
private static readonly string IP0000_FILENAME = "IP0000.BIN";
|
||||
|
||||
public byte[] RawData { get; internal set; }
|
||||
|
||||
public string RawPeripherals { get; internal set; }
|
||||
|
||||
public string HardwareID { get; internal set; }
|
||||
|
||||
public string MakerID { get; internal set; }
|
||||
|
||||
public string CRC { get; internal set; }
|
||||
|
||||
public string ComputedCRC { get; internal set; }
|
||||
|
||||
public bool IsCRCValid => this.CRC.Equals(this.ComputedCRC);
|
||||
|
||||
public string DeviceInformation { get; internal set; }
|
||||
|
||||
public string AreaSymbols { get; internal set; }
|
||||
|
||||
public string ProductID { get; internal set; }
|
||||
|
||||
public string ProductVersion { get; internal set; }
|
||||
|
||||
public string MainBinary { get; internal set; }
|
||||
|
||||
public string CompanyName { get; internal set; }
|
||||
|
||||
public string SoftwareName { get; internal set; }
|
||||
|
||||
public DateTime ReleaseDate { get; internal set; }
|
||||
|
||||
public InitialProgramToc TableOfContent { get; internal set; }
|
||||
|
||||
public MRImage SegaLicenseImage { get; internal set; }
|
||||
|
||||
public MRImage SegaTradeMarkImage { get; internal set; }
|
||||
|
||||
public MRImage CustomBrandingImage { get; internal set; }
|
||||
|
||||
public bool SupportVga => InitialProgramUtils.ConvertHexStringToBytes(this.RawPeripherals.Substring(5, 1))[0] == (byte) 1;
|
||||
|
||||
public bool UseWindowsCE => InitialProgramUtils.ConvertHexStringToBytes(this.RawPeripherals.Substring(6, 1))[0] == (byte) 1;
|
||||
|
||||
public bool SupportJapanArea => this.SupportArea(SupportedAreas.Japan);
|
||||
|
||||
public bool SupportUsaArea => this.SupportArea(SupportedAreas.Usa);
|
||||
|
||||
public bool SupportEuropeArea => this.SupportArea(SupportedAreas.Europe);
|
||||
|
||||
public bool SupportGun => this.SupportPeripheral(SupportedPeripherals.Gun);
|
||||
|
||||
public bool SupportKeyboard => this.SupportPeripheral(SupportedPeripherals.Keyboard);
|
||||
|
||||
public bool SupportMouse => this.SupportPeripheral(SupportedPeripherals.Mouse);
|
||||
|
||||
public bool SupportMemoryCard => this.SupportExpandedPeripheral(SupportedExpandedPeripherals.MemoryCard);
|
||||
|
||||
public bool SupportSoundInputPeripheral => this.SupportExpandedPeripheral(SupportedExpandedPeripherals.SoundInputPeripheral);
|
||||
|
||||
public bool SupportVibrator => this.SupportExpandedPeripheral(SupportedExpandedPeripherals.Vibrator);
|
||||
|
||||
public bool SupportOtherDevices => this.SupportExpandedPeripheral(SupportedExpandedPeripherals.OtherDevices);
|
||||
|
||||
public bool SupportStartABDirections => this.SupportButtons(SupportedButtons.StartABDirections);
|
||||
|
||||
public bool SupportCButton => this.SupportButtons(SupportedButtons.CButton);
|
||||
|
||||
public bool SupportDButton => this.SupportButtons(SupportedButtons.DButton);
|
||||
|
||||
public bool SupportXButton => this.SupportButtons(SupportedButtons.XButton);
|
||||
|
||||
public bool SupportYButton => this.SupportButtons(SupportedButtons.YButton);
|
||||
|
||||
public bool SupportZButton => this.SupportButtons(SupportedButtons.ZButton);
|
||||
|
||||
public bool SupportExpandedDirectionButtons => this.SupportButtons(SupportedButtons.ExpandedDirectionButtons);
|
||||
|
||||
public bool SupportAnalogRTrigger => this.SupportButtons(SupportedButtons.AnalogRTrigger);
|
||||
|
||||
public bool SupportAnalogLTrigger => this.SupportButtons(SupportedButtons.AnalogLTrigger);
|
||||
|
||||
public bool SupportAnalogHorizontalController => this.SupportButtons(SupportedButtons.AnalogHorizontalController);
|
||||
|
||||
public bool SupportAnalogVerticalController => this.SupportButtons(SupportedButtons.AnalogVerticalController);
|
||||
|
||||
public bool SupportExpandedAnalogHorizontal => this.SupportButtons(SupportedButtons.ExpandedAnalogHorizontal);
|
||||
|
||||
public bool SupportExpandedAnalogVertical => this.SupportButtons(SupportedButtons.ExpandedAnalogVertical);
|
||||
|
||||
public bool SupportArea(SupportedAreas supportedAreas)
|
||||
{
|
||||
SupportedAreas supportedAreas1 = SupportedAreas.None;
|
||||
if (this.AreaSymbols[0] == 'J')
|
||||
supportedAreas1 |= SupportedAreas.Japan;
|
||||
if (this.AreaSymbols[1] == 'U')
|
||||
supportedAreas1 |= SupportedAreas.Usa;
|
||||
if (this.AreaSymbols[2] == 'E')
|
||||
supportedAreas1 |= SupportedAreas.Europe;
|
||||
return (supportedAreas1 & supportedAreas) == supportedAreas;
|
||||
}
|
||||
|
||||
public bool SupportPeripheral(SupportedPeripherals supportedPeripherals) => ((SupportedPeripherals) InitialProgramUtils.ConvertHexStringToBytes(this.RawPeripherals.Substring(0, 1))[0] & supportedPeripherals) == supportedPeripherals;
|
||||
|
||||
public bool SupportExpandedPeripheral(
|
||||
SupportedExpandedPeripherals supportedExpandedPeripherals)
|
||||
{
|
||||
return ((SupportedExpandedPeripherals) InitialProgramUtils.ConvertHexStringToBytes(this.RawPeripherals.Substring(4, 1))[0] & supportedExpandedPeripherals) == supportedExpandedPeripherals;
|
||||
}
|
||||
|
||||
public bool SupportButtons(SupportedButtons supportedButtons) => ((SupportedButtons) BitConverter.ToUInt32(InitialProgramUtils.ConvertHexStringToBytes(this.RawPeripherals.Substring(0, 4)), 0) & supportedButtons) == supportedButtons;
|
||||
|
||||
public System.IO.Stream Stream => (System.IO.Stream) new MemoryStream(this.RawData, 0, this.RawData.Length, false);
|
||||
|
||||
public string FileName => this.SegaLicenseImage != null ? InitialProgram.IP_FILENAME : InitialProgram.IP0000_FILENAME;
|
||||
}
|
||||
}
|
114
SEGATools/Security/InitialProgramConverter.cs
Normal file
114
SEGATools/Security/InitialProgramConverter.cs
Normal file
|
@ -0,0 +1,114 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramConverter
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.Graphics;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramConverter
|
||||
{
|
||||
public static readonly int INITIAL_PROGRAM_SIZE = 32768;
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
private static readonly string HARDWARE_ID = "SEGA SEGAKATANA";
|
||||
private static readonly string MAKER_ID = "SEGA ENTERPRISES";
|
||||
private static readonly int OFFSET_HARDWARE_ID = 0;
|
||||
private static readonly int OFFSET_MAKER_ID = 16;
|
||||
private static readonly int OFFSET_CRC = 32;
|
||||
private static readonly int OFFSET_DEVICE_INFORMATION = 37;
|
||||
private static readonly int OFFSET_AREA_SYMBOLS = 48;
|
||||
private static readonly int OFFSET_PERIPHERALS = 56;
|
||||
private static readonly int OFFSET_PRODUCT_ID = 64;
|
||||
private static readonly int OFFSET_PRODUCT_VERSION = 74;
|
||||
private static readonly int OFFSET_RELEASE_DATE = 80;
|
||||
private static readonly int OFFSET_MAIN_BINARY = 96;
|
||||
private static readonly int OFFSET_COMPAGNY_NAME = 112;
|
||||
private static readonly int OFFSET_SOFWARE_NAME = 128;
|
||||
private static readonly int OFFSET_TOC = 256;
|
||||
private static readonly int OFFSET_SEGA_LICENSE_LOGO = 9111;
|
||||
private static readonly int OFFSET_SEGA_TRADEMARK_LOGO = 8812;
|
||||
private static readonly int OFFSET_SEGA_CUSTOM_BRANDING_LOGO = 14368;
|
||||
|
||||
public static InitialProgram ToInitialProgram(byte[] buffer, int startIndex)
|
||||
{
|
||||
if (startIndex < 0 || buffer.Length - startIndex < InitialProgramConverter.INITIAL_PROGRAM_SIZE)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
InitialProgram initialProgram = new InitialProgram();
|
||||
initialProgram.HardwareID = InitialProgramConverter.ParseField("hardware ID", buffer, startIndex + InitialProgramConverter.OFFSET_HARDWARE_ID, 15);
|
||||
if (!initialProgram.HardwareID.Equals(InitialProgramConverter.HARDWARE_ID))
|
||||
throw new InitialProgramInvalidHardwareIdException();
|
||||
initialProgram.MakerID = InitialProgramConverter.ParseField("maker ID", buffer, startIndex + InitialProgramConverter.OFFSET_MAKER_ID, 16);
|
||||
if (!initialProgram.MakerID.Equals(InitialProgramConverter.MAKER_ID))
|
||||
throw new InitialProgramInvalidMakerIdException();
|
||||
initialProgram.DeviceInformation = InitialProgramConverter.ParseField("device information", buffer, startIndex + InitialProgramConverter.OFFSET_DEVICE_INFORMATION, 11);
|
||||
initialProgram.AreaSymbols = InitialProgramConverter.ParseField("area symbols", buffer, startIndex + InitialProgramConverter.OFFSET_AREA_SYMBOLS, 7);
|
||||
initialProgram.RawPeripherals = InitialProgramConverter.ParseField("area symbols", buffer, startIndex + InitialProgramConverter.OFFSET_PERIPHERALS, 7);
|
||||
initialProgram.ProductID = InitialProgramConverter.ParseField("product ID", buffer, startIndex + InitialProgramConverter.OFFSET_PRODUCT_ID, 10);
|
||||
initialProgram.ProductVersion = InitialProgramConverter.ParseField("product version", buffer, startIndex + InitialProgramConverter.OFFSET_PRODUCT_VERSION, 6);
|
||||
initialProgram.CRC = InitialProgramConverter.ParseField("CRC", buffer, startIndex + InitialProgramConverter.OFFSET_CRC, 4);
|
||||
initialProgram.ComputedCRC = InitialProgramUtils.ComputeCRC(initialProgram.ProductID, initialProgram.ProductVersion).ToString("X4");
|
||||
string field = InitialProgramConverter.ParseField("release date", buffer, startIndex + InitialProgramConverter.OFFSET_RELEASE_DATE, 8);
|
||||
try
|
||||
{
|
||||
initialProgram.ReleaseDate = DateTime.ParseExact(field, "yyyyMMdd", (IFormatProvider) CultureInfo.InvariantCulture, DateTimeStyles.None);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InitialProgramReleaseDateParsingException(field, ex);
|
||||
}
|
||||
initialProgram.MainBinary = InitialProgramConverter.ParseField("main binary", buffer, startIndex + InitialProgramConverter.OFFSET_MAIN_BINARY, 16);
|
||||
initialProgram.CompanyName = InitialProgramConverter.ParseField("company name", buffer, startIndex + InitialProgramConverter.OFFSET_COMPAGNY_NAME, 16);
|
||||
initialProgram.SoftwareName = InitialProgramConverter.ParseField("software name", buffer, startIndex + InitialProgramConverter.OFFSET_SOFWARE_NAME, 128);
|
||||
try
|
||||
{
|
||||
initialProgram.TableOfContent = InitialProgramTocConverter.ToInitialProgramToc(buffer, startIndex + InitialProgramConverter.OFFSET_TOC);
|
||||
}
|
||||
catch (InitialProgramTocException ex)
|
||||
{
|
||||
logger.Error(ex);
|
||||
}
|
||||
byte[] numArray = new byte[InitialProgramConverter.INITIAL_PROGRAM_SIZE];
|
||||
Buffer.BlockCopy((Array) buffer, startIndex, (Array) numArray, 0, InitialProgramConverter.INITIAL_PROGRAM_SIZE);
|
||||
initialProgram.RawData = numArray;
|
||||
initialProgram.SegaLicenseImage = InitialProgramConverter.GetMRImage(buffer, startIndex + InitialProgramConverter.OFFSET_SEGA_LICENSE_LOGO);
|
||||
initialProgram.SegaTradeMarkImage = InitialProgramConverter.GetMRImage(buffer, startIndex + InitialProgramConverter.OFFSET_SEGA_TRADEMARK_LOGO);
|
||||
initialProgram.CustomBrandingImage = InitialProgramConverter.GetMRImage(buffer, startIndex + InitialProgramConverter.OFFSET_SEGA_CUSTOM_BRANDING_LOGO);
|
||||
return initialProgram;
|
||||
}
|
||||
|
||||
private static string ParseField(string fieldName, byte[] buffer, int startIndex, int lenght)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Encoding.Default.GetString(buffer, startIndex, lenght);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InitialProgramFieldParsingException(fieldName, startIndex, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static MRImage GetMRImage(byte[] buffer, int startIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return MRImageConverter.ToMRImage(buffer, startIndex);
|
||||
}
|
||||
catch (MRImageIdentifierMissingException ex)
|
||||
{
|
||||
logger.Error(ex);
|
||||
return (MRImage) null;
|
||||
}
|
||||
catch (MRImageDecompressionException ex)
|
||||
{
|
||||
InitialProgramConverter.logger.ErrorFormat("Unable to decompress MR image: {0}", (object) ex);
|
||||
throw new InitialProgramInvalidMRImageException(startIndex, (Exception) ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
23
SEGATools/Security/InitialProgramException.cs
Normal file
23
SEGATools/Security/InitialProgramException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramException : Exception
|
||||
{
|
||||
internal InitialProgramException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
internal InitialProgramException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
46
SEGATools/Security/InitialProgramExtended.cs
Normal file
46
SEGATools/Security/InitialProgramExtended.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramExtended
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.Binary;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramExtended : InitialProgram
|
||||
{
|
||||
public List<SEGALibrary> Libraries;
|
||||
|
||||
private InitialProgramExtended(InitialProgram ip, List<SEGALibrary> libraries)
|
||||
{
|
||||
this.AreaSymbols = ip.AreaSymbols;
|
||||
this.CompanyName = ip.CompanyName;
|
||||
this.ComputedCRC = ip.ComputedCRC;
|
||||
this.CRC = ip.CRC;
|
||||
this.CustomBrandingImage = ip.CustomBrandingImage;
|
||||
this.DeviceInformation = ip.DeviceInformation;
|
||||
this.HardwareID = ip.HardwareID;
|
||||
this.MainBinary = ip.MainBinary;
|
||||
this.MakerID = ip.MakerID;
|
||||
this.ProductID = ip.ProductID;
|
||||
this.ProductVersion = ip.ProductVersion;
|
||||
this.RawData = ip.RawData;
|
||||
this.RawPeripherals = ip.RawPeripherals;
|
||||
this.ReleaseDate = ip.ReleaseDate;
|
||||
this.SegaLicenseImage = ip.SegaLicenseImage;
|
||||
this.SegaTradeMarkImage = ip.SegaTradeMarkImage;
|
||||
this.SoftwareName = ip.SoftwareName;
|
||||
this.TableOfContent = ip.TableOfContent;
|
||||
this.Libraries = libraries;
|
||||
}
|
||||
|
||||
public static InitialProgramExtended create(
|
||||
InitialProgram ip,
|
||||
List<SEGALibrary> libraries)
|
||||
{
|
||||
return new InitialProgramExtended(ip, libraries);
|
||||
}
|
||||
}
|
||||
}
|
21
SEGATools/Security/InitialProgramFieldParsingException.cs
Normal file
21
SEGATools/Security/InitialProgramFieldParsingException.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramFieldParsingException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramFieldParsingException : InitialProgramException
|
||||
{
|
||||
public InitialProgramFieldParsingException(
|
||||
string fieldName,
|
||||
int offset,
|
||||
Exception innerException)
|
||||
: base(string.Format("the field {0} at offset 0x{1:X8} is not valid", (object) fieldName, (object) offset), innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
459
SEGATools/Security/InitialProgramGeneralSettingsViewer.cs
Normal file
459
SEGATools/Security/InitialProgramGeneralSettingsViewer.cs
Normal file
|
@ -0,0 +1,459 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramGeneralSettingsViewer
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.Binary;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramGeneralSettingsViewer : UserControl
|
||||
{
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
private IContainer components;
|
||||
private ToolTip toolTip;
|
||||
private Label lbHardwareId;
|
||||
private Label lbMakerId;
|
||||
private Label lbCrc;
|
||||
private Label lbReleaseDate;
|
||||
private Label lbMedia;
|
||||
private Label lbProductId;
|
||||
private FlowLayoutPanel fplArea;
|
||||
private CheckBox cbAreaJapan;
|
||||
private CheckBox cbAreaUs;
|
||||
private CheckBox cbAreaEurope;
|
||||
private GroupBox gbSupportedAreas;
|
||||
private Label lbFirstReadFilename;
|
||||
private Label lbCompagnyName;
|
||||
private Label lbApplicationTitle;
|
||||
private TextBox tbHardwareId;
|
||||
private TextBox tbMakerId;
|
||||
private TextBox tbProductId;
|
||||
private TextBox tbProductVersion;
|
||||
private TextBox tbMedia;
|
||||
private TextBox tbCrc;
|
||||
private TextBox tbReleaseDate;
|
||||
private TextBox tbFirstFileName;
|
||||
private FlowLayoutPanel flpSegaLibrary;
|
||||
private GroupBox gbSegaAIPLibrary;
|
||||
private TextBox tbCompagnyName;
|
||||
private TextBox tbApplicationName;
|
||||
private FlowLayoutPanel flpMediaOptions;
|
||||
private CheckBox cbMediaOptionsVgaSupport;
|
||||
private CheckBox cbMediaOptionsUseWindowsCe;
|
||||
private GroupBox gbMediaOptions;
|
||||
private RadioButton rbSegaLibraryRoundZero;
|
||||
private RadioButton rbSegaLibraryRoundNearest;
|
||||
|
||||
public InitialProgramGeneralSettingsViewer() => this.InitializeComponent();
|
||||
|
||||
public void LoadInitialProgram(InitialProgramExtended ip)
|
||||
{
|
||||
if (ip == null)
|
||||
return;
|
||||
this.tbApplicationName.Text = ip.SoftwareName.Trim();
|
||||
this.tbHardwareId.Text = ip.HardwareID;
|
||||
this.tbMakerId.Text = ip.MakerID;
|
||||
this.tbFirstFileName.Text = ip.MainBinary.Trim();
|
||||
this.tbCompagnyName.Text = ip.CompanyName.Trim();
|
||||
this.tbProductId.Text = ip.ProductID.Trim();
|
||||
this.tbProductVersion.Text = ip.ProductVersion.Trim();
|
||||
this.tbReleaseDate.Text = ip.ReleaseDate.Date.ToString("yyyy/MM/dd");
|
||||
this.tbMedia.Text = ip.DeviceInformation.Trim();
|
||||
this.SetCRC((InitialProgram) ip);
|
||||
this.SetAreaSymbols((InitialProgram) ip);
|
||||
this.SetOther((InitialProgram) ip);
|
||||
if (ip.Libraries == null)
|
||||
return;
|
||||
this.SetAIPLibrary(ip);
|
||||
}
|
||||
|
||||
private void SetCRC(InitialProgram ip)
|
||||
{
|
||||
this.tbCrc.Text = ip.CRC;
|
||||
this.tbCrc.ForeColor = Color.White;
|
||||
if (!ip.IsCRCValid)
|
||||
{
|
||||
this.tbCrc.BackColor = Color.Red;
|
||||
this.toolTip.SetToolTip((Control) this.tbCrc, string.Format("Incorrect CRC! Should be {0}", (object) ip.ComputedCRC));
|
||||
}
|
||||
else
|
||||
this.tbCrc.BackColor = Color.Green;
|
||||
}
|
||||
|
||||
private void SetAreaSymbols(InitialProgram ip)
|
||||
{
|
||||
this.cbAreaJapan.Checked = ip.SupportJapanArea;
|
||||
this.cbAreaUs.Checked = ip.SupportUsaArea;
|
||||
this.cbAreaEurope.Checked = ip.SupportEuropeArea;
|
||||
}
|
||||
|
||||
private void SetOther(InitialProgram ip)
|
||||
{
|
||||
this.cbMediaOptionsVgaSupport.Checked = ip.SupportVga;
|
||||
this.cbMediaOptionsUseWindowsCe.Checked = ip.UseWindowsCE;
|
||||
}
|
||||
|
||||
private void SetAIPLibrary(InitialProgramExtended ip)
|
||||
{
|
||||
this.rbSegaLibraryRoundZero.Enabled = this.rbSegaLibraryRoundNearest.Enabled = false;
|
||||
this.rbSegaLibraryRoundZero.Checked = this.rbSegaLibraryRoundNearest.Checked = false;
|
||||
SEGALibrary segaLibrary1 = ip.Libraries.Find((Predicate<SEGALibrary>) (library => library.GetLibraryType() == SEGALibraryType.AIP));
|
||||
if (segaLibrary1 == null)
|
||||
return;
|
||||
SEGALibrary segaLibrary2 = ip.Libraries.Find((Predicate<SEGALibrary>) (library => library.GetLibraryType() == SEGALibraryType.FLASH_MEMORY_MANAGER));
|
||||
SEGALibraryVersion version = SEGALibrary.AIP_103.Version;
|
||||
if (segaLibrary2 != null)
|
||||
version = SEGALibrary.AIPf_105.Version;
|
||||
this.rbSegaLibraryRoundZero.Enabled = this.rbSegaLibraryRoundNearest.Enabled = false;
|
||||
this.rbSegaLibraryRoundZero.Checked = this.rbSegaLibraryRoundNearest.Checked = false;
|
||||
if (segaLibrary1.Version.CompareTo(version) <= 0)
|
||||
this.rbSegaLibraryRoundZero.Checked = true;
|
||||
else
|
||||
this.rbSegaLibraryRoundNearest.Checked = true;
|
||||
if (!ip.UseWindowsCE)
|
||||
this.rbSegaLibraryRoundZero.Enabled = this.rbSegaLibraryRoundNearest.Enabled = true;
|
||||
this.gbSegaAIPLibrary.Text = "SEGA AIP Library: v" + (object) segaLibrary1.Version;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && this.components != null)
|
||||
this.components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = (IContainer) new Container();
|
||||
this.toolTip = new ToolTip(this.components);
|
||||
this.lbHardwareId = new Label();
|
||||
this.lbMakerId = new Label();
|
||||
this.lbCrc = new Label();
|
||||
this.lbReleaseDate = new Label();
|
||||
this.lbMedia = new Label();
|
||||
this.lbProductId = new Label();
|
||||
this.fplArea = new FlowLayoutPanel();
|
||||
this.cbAreaJapan = new CheckBox();
|
||||
this.cbAreaUs = new CheckBox();
|
||||
this.cbAreaEurope = new CheckBox();
|
||||
this.gbSupportedAreas = new GroupBox();
|
||||
this.lbFirstReadFilename = new Label();
|
||||
this.lbCompagnyName = new Label();
|
||||
this.lbApplicationTitle = new Label();
|
||||
this.tbHardwareId = new TextBox();
|
||||
this.tbMakerId = new TextBox();
|
||||
this.tbProductId = new TextBox();
|
||||
this.tbProductVersion = new TextBox();
|
||||
this.tbMedia = new TextBox();
|
||||
this.tbCrc = new TextBox();
|
||||
this.tbReleaseDate = new TextBox();
|
||||
this.tbFirstFileName = new TextBox();
|
||||
this.flpSegaLibrary = new FlowLayoutPanel();
|
||||
this.rbSegaLibraryRoundZero = new RadioButton();
|
||||
this.rbSegaLibraryRoundNearest = new RadioButton();
|
||||
this.gbSegaAIPLibrary = new GroupBox();
|
||||
this.tbCompagnyName = new TextBox();
|
||||
this.tbApplicationName = new TextBox();
|
||||
this.flpMediaOptions = new FlowLayoutPanel();
|
||||
this.cbMediaOptionsVgaSupport = new CheckBox();
|
||||
this.cbMediaOptionsUseWindowsCe = new CheckBox();
|
||||
this.gbMediaOptions = new GroupBox();
|
||||
this.fplArea.SuspendLayout();
|
||||
this.gbSupportedAreas.SuspendLayout();
|
||||
this.flpSegaLibrary.SuspendLayout();
|
||||
this.gbSegaAIPLibrary.SuspendLayout();
|
||||
this.flpMediaOptions.SuspendLayout();
|
||||
this.gbMediaOptions.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
this.lbHardwareId.AutoSize = true;
|
||||
this.lbHardwareId.Location = new Point(3, 55);
|
||||
this.lbHardwareId.Name = "lbHardwareId";
|
||||
this.lbHardwareId.Size = new Size(70, 13);
|
||||
this.lbHardwareId.TabIndex = 0;
|
||||
this.lbHardwareId.Text = "Hardware ID:";
|
||||
this.lbMakerId.AutoSize = true;
|
||||
this.lbMakerId.Location = new Point(3, 94);
|
||||
this.lbMakerId.Name = "lbMakerId";
|
||||
this.lbMakerId.Size = new Size(54, 13);
|
||||
this.lbMakerId.TabIndex = 0;
|
||||
this.lbMakerId.Text = "Maker ID:";
|
||||
this.lbCrc.AutoSize = true;
|
||||
this.lbCrc.Location = new Point(340, 152);
|
||||
this.lbCrc.Name = "lbCrc";
|
||||
this.lbCrc.Size = new Size(32, 13);
|
||||
this.lbCrc.TabIndex = 0;
|
||||
this.lbCrc.Text = "CRC:";
|
||||
this.lbReleaseDate.AutoSize = true;
|
||||
this.lbReleaseDate.Location = new Point(155, 133);
|
||||
this.lbReleaseDate.Name = "lbReleaseDate";
|
||||
this.lbReleaseDate.Size = new Size(73, 13);
|
||||
this.lbReleaseDate.TabIndex = 0;
|
||||
this.lbReleaseDate.Text = "Release date:";
|
||||
this.lbMedia.AutoSize = true;
|
||||
this.lbMedia.Location = new Point(245, 133);
|
||||
this.lbMedia.Name = "lbMedia";
|
||||
this.lbMedia.Size = new Size(39, 13);
|
||||
this.lbMedia.TabIndex = 0;
|
||||
this.lbMedia.Text = "Media:";
|
||||
this.lbProductId.AutoSize = true;
|
||||
this.lbProductId.Location = new Point(155, 94);
|
||||
this.lbProductId.Name = "lbProductId";
|
||||
this.lbProductId.Size = new Size(61, 13);
|
||||
this.lbProductId.TabIndex = 0;
|
||||
this.lbProductId.Text = "Product ID:";
|
||||
this.fplArea.AutoSize = true;
|
||||
this.fplArea.Controls.Add((Control) this.cbAreaJapan);
|
||||
this.fplArea.Controls.Add((Control) this.cbAreaUs);
|
||||
this.fplArea.Controls.Add((Control) this.cbAreaEurope);
|
||||
this.fplArea.Dock = DockStyle.Fill;
|
||||
this.fplArea.FlowDirection = FlowDirection.TopDown;
|
||||
this.fplArea.Location = new Point(3, 16);
|
||||
this.fplArea.Name = "fplArea";
|
||||
this.fplArea.Size = new Size(112, 69);
|
||||
this.fplArea.TabIndex = 0;
|
||||
this.cbAreaJapan.AutoCheck = false;
|
||||
this.cbAreaJapan.AutoSize = true;
|
||||
this.cbAreaJapan.Location = new Point(3, 3);
|
||||
this.cbAreaJapan.Name = "cbAreaJapan";
|
||||
this.cbAreaJapan.Size = new Size(55, 17);
|
||||
this.cbAreaJapan.TabIndex = 11;
|
||||
this.cbAreaJapan.Text = "Japan";
|
||||
this.cbAreaJapan.UseVisualStyleBackColor = true;
|
||||
this.cbAreaUs.AutoCheck = false;
|
||||
this.cbAreaUs.AutoSize = true;
|
||||
this.cbAreaUs.Location = new Point(3, 26);
|
||||
this.cbAreaUs.Name = "cbAreaUs";
|
||||
this.cbAreaUs.Size = new Size(48, 17);
|
||||
this.cbAreaUs.TabIndex = 12;
|
||||
this.cbAreaUs.Text = "USA";
|
||||
this.cbAreaUs.UseVisualStyleBackColor = true;
|
||||
this.cbAreaEurope.AutoCheck = false;
|
||||
this.cbAreaEurope.AutoSize = true;
|
||||
this.cbAreaEurope.Location = new Point(3, 49);
|
||||
this.cbAreaEurope.Name = "cbAreaEurope";
|
||||
this.cbAreaEurope.Size = new Size(60, 17);
|
||||
this.cbAreaEurope.TabIndex = 13;
|
||||
this.cbAreaEurope.Text = "Europe";
|
||||
this.cbAreaEurope.UseVisualStyleBackColor = true;
|
||||
this.gbSupportedAreas.AutoSize = true;
|
||||
this.gbSupportedAreas.Controls.Add((Control) this.fplArea);
|
||||
this.gbSupportedAreas.Location = new Point(336, 58);
|
||||
this.gbSupportedAreas.Name = "gbSupportedAreas";
|
||||
this.gbSupportedAreas.Size = new Size(118, 88);
|
||||
this.gbSupportedAreas.TabIndex = 0;
|
||||
this.gbSupportedAreas.TabStop = false;
|
||||
this.gbSupportedAreas.Text = "Supported area(s):";
|
||||
this.lbFirstReadFilename.AutoSize = true;
|
||||
this.lbFirstReadFilename.Location = new Point(3, 133);
|
||||
this.lbFirstReadFilename.Name = "lbFirstReadFilename";
|
||||
this.lbFirstReadFilename.Size = new Size(95, 13);
|
||||
this.lbFirstReadFilename.TabIndex = 0;
|
||||
this.lbFirstReadFilename.Text = "First read filename:";
|
||||
this.lbCompagnyName.AutoSize = true;
|
||||
this.lbCompagnyName.Location = new Point(155, 55);
|
||||
this.lbCompagnyName.Name = "lbCompagnyName";
|
||||
this.lbCompagnyName.Size = new Size(89, 13);
|
||||
this.lbCompagnyName.TabIndex = 0;
|
||||
this.lbCompagnyName.Text = "Compagny name:";
|
||||
this.lbApplicationTitle.AutoSize = true;
|
||||
this.lbApplicationTitle.Location = new Point(3, 0);
|
||||
this.lbApplicationTitle.Name = "lbApplicationTitle";
|
||||
this.lbApplicationTitle.Size = new Size(81, 13);
|
||||
this.lbApplicationTitle.TabIndex = 0;
|
||||
this.lbApplicationTitle.Text = "Application title:";
|
||||
this.tbHardwareId.BackColor = Color.White;
|
||||
this.tbHardwareId.Location = new Point(6, 71);
|
||||
this.tbHardwareId.MaxLength = 15;
|
||||
this.tbHardwareId.Name = "tbHardwareId";
|
||||
this.tbHardwareId.ReadOnly = true;
|
||||
this.tbHardwareId.Size = new Size(143, 20);
|
||||
this.tbHardwareId.TabIndex = 2;
|
||||
this.tbHardwareId.Text = "SEGA SEGAKATANA";
|
||||
this.tbHardwareId.TextAlign = HorizontalAlignment.Center;
|
||||
this.tbMakerId.BackColor = Color.White;
|
||||
this.tbMakerId.Location = new Point(6, 110);
|
||||
this.tbMakerId.Name = "tbMakerId";
|
||||
this.tbMakerId.ReadOnly = true;
|
||||
this.tbMakerId.Size = new Size(143, 20);
|
||||
this.tbMakerId.TabIndex = 4;
|
||||
this.tbMakerId.Text = "SEGA ENTERPRISES";
|
||||
this.tbMakerId.TextAlign = HorizontalAlignment.Center;
|
||||
this.tbProductId.BackColor = Color.White;
|
||||
this.tbProductId.Location = new Point(158, 110);
|
||||
this.tbProductId.Name = "tbProductId";
|
||||
this.tbProductId.ReadOnly = true;
|
||||
this.tbProductId.Size = new Size(81, 20);
|
||||
this.tbProductId.TabIndex = 5;
|
||||
this.tbProductId.TextAlign = HorizontalAlignment.Center;
|
||||
this.tbProductVersion.BackColor = Color.White;
|
||||
this.tbProductVersion.Location = new Point(248, 110);
|
||||
this.tbProductVersion.Name = "tbProductVersion";
|
||||
this.tbProductVersion.ReadOnly = true;
|
||||
this.tbProductVersion.Size = new Size(81, 20);
|
||||
this.tbProductVersion.TabIndex = 6;
|
||||
this.tbProductVersion.TextAlign = HorizontalAlignment.Center;
|
||||
this.tbMedia.BackColor = Color.White;
|
||||
this.tbMedia.Location = new Point(248, 149);
|
||||
this.tbMedia.Name = "tbMedia";
|
||||
this.tbMedia.ReadOnly = true;
|
||||
this.tbMedia.Size = new Size(81, 20);
|
||||
this.tbMedia.TabIndex = 9;
|
||||
this.tbMedia.TextAlign = HorizontalAlignment.Center;
|
||||
this.tbCrc.BackColor = Color.White;
|
||||
this.tbCrc.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold, GraphicsUnit.Point, (byte) 0);
|
||||
this.tbCrc.ForeColor = Color.White;
|
||||
this.tbCrc.Location = new Point(378, 149);
|
||||
this.tbCrc.Name = "tbCrc";
|
||||
this.tbCrc.ReadOnly = true;
|
||||
this.tbCrc.Size = new Size(76, 20);
|
||||
this.tbCrc.TabIndex = 10;
|
||||
this.tbCrc.Text = "FFFF";
|
||||
this.tbCrc.TextAlign = HorizontalAlignment.Center;
|
||||
this.tbReleaseDate.BackColor = Color.White;
|
||||
this.tbReleaseDate.Location = new Point(158, 149);
|
||||
this.tbReleaseDate.Name = "tbReleaseDate";
|
||||
this.tbReleaseDate.ReadOnly = true;
|
||||
this.tbReleaseDate.Size = new Size(81, 20);
|
||||
this.tbReleaseDate.TabIndex = 8;
|
||||
this.tbReleaseDate.TextAlign = HorizontalAlignment.Center;
|
||||
this.tbFirstFileName.BackColor = Color.White;
|
||||
this.tbFirstFileName.Location = new Point(6, 149);
|
||||
this.tbFirstFileName.Name = "tbFirstFileName";
|
||||
this.tbFirstFileName.ReadOnly = true;
|
||||
this.tbFirstFileName.Size = new Size(143, 20);
|
||||
this.tbFirstFileName.TabIndex = 7;
|
||||
this.tbFirstFileName.TextAlign = HorizontalAlignment.Center;
|
||||
this.flpSegaLibrary.AutoSize = true;
|
||||
this.flpSegaLibrary.Controls.Add((Control) this.rbSegaLibraryRoundZero);
|
||||
this.flpSegaLibrary.Controls.Add((Control) this.rbSegaLibraryRoundNearest);
|
||||
this.flpSegaLibrary.Dock = DockStyle.Fill;
|
||||
this.flpSegaLibrary.FlowDirection = FlowDirection.TopDown;
|
||||
this.flpSegaLibrary.Location = new Point(3, 16);
|
||||
this.flpSegaLibrary.Name = "flpSegaLibrary";
|
||||
this.flpSegaLibrary.Size = new Size(227, 46);
|
||||
this.flpSegaLibrary.TabIndex = 0;
|
||||
this.rbSegaLibraryRoundZero.AutoCheck = false;
|
||||
this.rbSegaLibraryRoundZero.AutoSize = true;
|
||||
this.rbSegaLibraryRoundZero.Location = new Point(3, 3);
|
||||
this.rbSegaLibraryRoundZero.Name = "rbSegaLibraryRoundZero";
|
||||
this.rbSegaLibraryRoundZero.Size = new Size(152, 17);
|
||||
this.rbSegaLibraryRoundZero.TabIndex = 23;
|
||||
this.rbSegaLibraryRoundZero.TabStop = true;
|
||||
this.rbSegaLibraryRoundZero.Text = "Floating Point: Round Zero";
|
||||
this.rbSegaLibraryRoundZero.UseVisualStyleBackColor = true;
|
||||
this.rbSegaLibraryRoundNearest.AutoCheck = false;
|
||||
this.rbSegaLibraryRoundNearest.AutoSize = true;
|
||||
this.rbSegaLibraryRoundNearest.Location = new Point(3, 26);
|
||||
this.rbSegaLibraryRoundNearest.Name = "rbSegaLibraryRoundNearest";
|
||||
this.rbSegaLibraryRoundNearest.Size = new Size(167, 17);
|
||||
this.rbSegaLibraryRoundNearest.TabIndex = 24;
|
||||
this.rbSegaLibraryRoundNearest.TabStop = true;
|
||||
this.rbSegaLibraryRoundNearest.Text = "Floating Point: Round Nearest";
|
||||
this.rbSegaLibraryRoundNearest.UseVisualStyleBackColor = true;
|
||||
this.gbSegaAIPLibrary.AutoSize = true;
|
||||
this.gbSegaAIPLibrary.Controls.Add((Control) this.flpSegaLibrary);
|
||||
this.gbSegaAIPLibrary.Location = new Point(6, 175);
|
||||
this.gbSegaAIPLibrary.Name = "gbSegaAIPLibrary";
|
||||
this.gbSegaAIPLibrary.Size = new Size(233, 65);
|
||||
this.gbSegaAIPLibrary.TabIndex = 0;
|
||||
this.gbSegaAIPLibrary.TabStop = false;
|
||||
this.gbSegaAIPLibrary.Text = "SEGA AIP Library:";
|
||||
this.tbCompagnyName.BackColor = Color.White;
|
||||
this.tbCompagnyName.Location = new Point(158, 71);
|
||||
this.tbCompagnyName.Name = "tbCompagnyName";
|
||||
this.tbCompagnyName.ReadOnly = true;
|
||||
this.tbCompagnyName.Size = new Size(171, 20);
|
||||
this.tbCompagnyName.TabIndex = 3;
|
||||
this.tbCompagnyName.TextAlign = HorizontalAlignment.Center;
|
||||
this.tbApplicationName.BackColor = Color.White;
|
||||
this.tbApplicationName.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold, GraphicsUnit.Point, (byte) 0);
|
||||
this.tbApplicationName.Location = new Point(6, 16);
|
||||
this.tbApplicationName.Multiline = true;
|
||||
this.tbApplicationName.Name = "tbApplicationName";
|
||||
this.tbApplicationName.ReadOnly = true;
|
||||
this.tbApplicationName.Size = new Size(448, 36);
|
||||
this.tbApplicationName.TabIndex = 1;
|
||||
this.tbApplicationName.Text = "THIS IS A SAMPLE DISK FOR USE INTHE OFFICE ONLY / DO NOT SELL / DO NOT CARRY OUT FROM THE OFFICE";
|
||||
this.tbApplicationName.TextAlign = HorizontalAlignment.Center;
|
||||
this.flpMediaOptions.AutoSize = true;
|
||||
this.flpMediaOptions.Controls.Add((Control) this.cbMediaOptionsVgaSupport);
|
||||
this.flpMediaOptions.Controls.Add((Control) this.cbMediaOptionsUseWindowsCe);
|
||||
this.flpMediaOptions.Dock = DockStyle.Fill;
|
||||
this.flpMediaOptions.FlowDirection = FlowDirection.TopDown;
|
||||
this.flpMediaOptions.Location = new Point(3, 16);
|
||||
this.flpMediaOptions.Name = "flpMediaOptions";
|
||||
this.flpMediaOptions.Size = new Size(200, 46);
|
||||
this.flpMediaOptions.TabIndex = 22;
|
||||
this.cbMediaOptionsVgaSupport.AutoCheck = false;
|
||||
this.cbMediaOptionsVgaSupport.AutoSize = true;
|
||||
this.cbMediaOptionsVgaSupport.Location = new Point(3, 3);
|
||||
this.cbMediaOptionsVgaSupport.Name = "cbMediaOptionsVgaSupport";
|
||||
this.cbMediaOptionsVgaSupport.Size = new Size(118, 17);
|
||||
this.cbMediaOptionsVgaSupport.TabIndex = 16;
|
||||
this.cbMediaOptionsVgaSupport.Text = "VGA box supported";
|
||||
this.cbMediaOptionsVgaSupport.UseVisualStyleBackColor = true;
|
||||
this.cbMediaOptionsUseWindowsCe.AutoCheck = false;
|
||||
this.cbMediaOptionsUseWindowsCe.AutoSize = true;
|
||||
this.cbMediaOptionsUseWindowsCe.Location = new Point(3, 26);
|
||||
this.cbMediaOptionsUseWindowsCe.Name = "cbMediaOptionsUseWindowsCe";
|
||||
this.cbMediaOptionsUseWindowsCe.Size = new Size(106, 17);
|
||||
this.cbMediaOptionsUseWindowsCe.TabIndex = 17;
|
||||
this.cbMediaOptionsUseWindowsCe.Text = "Use WindowsCE";
|
||||
this.cbMediaOptionsUseWindowsCe.UseVisualStyleBackColor = true;
|
||||
this.gbMediaOptions.AutoSize = true;
|
||||
this.gbMediaOptions.Controls.Add((Control) this.flpMediaOptions);
|
||||
this.gbMediaOptions.Location = new Point(248, 175);
|
||||
this.gbMediaOptions.Name = "gbMediaOptions";
|
||||
this.gbMediaOptions.Size = new Size(206, 65);
|
||||
this.gbMediaOptions.TabIndex = 0;
|
||||
this.gbMediaOptions.TabStop = false;
|
||||
this.gbMediaOptions.Text = "Other:";
|
||||
this.AutoScaleDimensions = new SizeF(6f, 13f);
|
||||
this.AutoScaleMode = AutoScaleMode.Font;
|
||||
this.Controls.Add((Control) this.gbMediaOptions);
|
||||
this.Controls.Add((Control) this.gbSegaAIPLibrary);
|
||||
this.Controls.Add((Control) this.tbApplicationName);
|
||||
this.Controls.Add((Control) this.tbCompagnyName);
|
||||
this.Controls.Add((Control) this.tbFirstFileName);
|
||||
this.Controls.Add((Control) this.tbReleaseDate);
|
||||
this.Controls.Add((Control) this.tbCrc);
|
||||
this.Controls.Add((Control) this.tbMedia);
|
||||
this.Controls.Add((Control) this.tbProductVersion);
|
||||
this.Controls.Add((Control) this.tbProductId);
|
||||
this.Controls.Add((Control) this.tbMakerId);
|
||||
this.Controls.Add((Control) this.tbHardwareId);
|
||||
this.Controls.Add((Control) this.lbApplicationTitle);
|
||||
this.Controls.Add((Control) this.lbCompagnyName);
|
||||
this.Controls.Add((Control) this.lbFirstReadFilename);
|
||||
this.Controls.Add((Control) this.gbSupportedAreas);
|
||||
this.Controls.Add((Control) this.lbProductId);
|
||||
this.Controls.Add((Control) this.lbMedia);
|
||||
this.Controls.Add((Control) this.lbReleaseDate);
|
||||
this.Controls.Add((Control) this.lbCrc);
|
||||
this.Controls.Add((Control) this.lbMakerId);
|
||||
this.Controls.Add((Control) this.lbHardwareId);
|
||||
this.Name = nameof (InitialProgramGeneralSettingsViewer);
|
||||
this.Size = new Size(460, 246);
|
||||
this.fplArea.ResumeLayout(false);
|
||||
this.fplArea.PerformLayout();
|
||||
this.gbSupportedAreas.ResumeLayout(false);
|
||||
this.gbSupportedAreas.PerformLayout();
|
||||
this.flpSegaLibrary.ResumeLayout(false);
|
||||
this.flpSegaLibrary.PerformLayout();
|
||||
this.gbSegaAIPLibrary.ResumeLayout(false);
|
||||
this.gbSegaAIPLibrary.PerformLayout();
|
||||
this.flpMediaOptions.ResumeLayout(false);
|
||||
this.flpMediaOptions.PerformLayout();
|
||||
this.gbMediaOptions.ResumeLayout(false);
|
||||
this.gbMediaOptions.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
}
|
||||
}
|
120
SEGATools/Security/InitialProgramGeneralSettingsViewer.resx
Normal file
120
SEGATools/Security/InitialProgramGeneralSettingsViewer.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
123
SEGATools/Security/InitialProgramImagesViewer.cs
Normal file
123
SEGATools/Security/InitialProgramImagesViewer.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramImagesViewer
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.Graphics;
|
||||
using SEGATools.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramImagesViewer : UserControl
|
||||
{
|
||||
private List<InitialProgramImagesViewer.MRImageItem> mrImageItems = new List<InitialProgramImagesViewer.MRImageItem>();
|
||||
private IContainer components;
|
||||
private ComboBox cbMRImages;
|
||||
private Label lbMRImage;
|
||||
private MRImageViewer mrImageViewer;
|
||||
|
||||
public InitialProgramImagesViewer()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.cbMRImages.SelectionChangeCommitted += new EventHandler(this.cbMRImages_SelectionChangeCommitted);
|
||||
}
|
||||
|
||||
public void LoadInitialProgram(InitialProgramExtended ip, string basePath)
|
||||
{
|
||||
this.mrImageViewer.BasePath = basePath;
|
||||
this.cbMRImages.Enabled = false;
|
||||
this.mrImageItems.Clear();
|
||||
this.addMRImage(ip.SegaLicenseImage, Resources.MRIpImageSegaLicense);
|
||||
this.addMRImage(ip.CustomBrandingImage, Resources.MRIpImageSegaCustomBranding);
|
||||
this.addMRImage(ip.SegaTradeMarkImage, Resources.MRIpImageSegaTM);
|
||||
this.cbMRImages.DataSource = (object) this.mrImageItems;
|
||||
this.cbMRImages.DisplayMember = InitialProgramImagesViewer.MRImageItem.DisplayMember;
|
||||
this.cbMRImages.ValueMember = InitialProgramImagesViewer.MRImageItem.ValueMember;
|
||||
if (this.mrImageItems.Count <= 0)
|
||||
return;
|
||||
this.cbMRImages.Enabled = true;
|
||||
this.cbMRImages.SelectedIndex = 0;
|
||||
this.mrImageViewer.LoadMRImage(this.mrImageItems[0].Image, this.mrImageItems[0].Name);
|
||||
}
|
||||
|
||||
private void addMRImage(MRImage mrImage, string displayName)
|
||||
{
|
||||
if (mrImage == null)
|
||||
return;
|
||||
this.mrImageItems.Add(new InitialProgramImagesViewer.MRImageItem(displayName, mrImage));
|
||||
}
|
||||
|
||||
private void cbMRImages_SelectionChangeCommitted(object sender, EventArgs e)
|
||||
{
|
||||
if (this.cbMRImages.SelectedItem == null)
|
||||
return;
|
||||
InitialProgramImagesViewer.MRImageItem selectedItem = (InitialProgramImagesViewer.MRImageItem) this.cbMRImages.SelectedItem;
|
||||
this.mrImageViewer.LoadMRImage(selectedItem.Image, selectedItem.Name);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && this.components != null)
|
||||
this.components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.cbMRImages = new ComboBox();
|
||||
this.lbMRImage = new Label();
|
||||
this.mrImageViewer = new MRImageViewer();
|
||||
this.SuspendLayout();
|
||||
this.cbMRImages.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
this.cbMRImages.FlatStyle = FlatStyle.Popup;
|
||||
this.cbMRImages.FormattingEnabled = true;
|
||||
this.cbMRImages.Location = new Point(76, 9);
|
||||
this.cbMRImages.Name = "cbMRImages";
|
||||
this.cbMRImages.Size = new Size(380, 21);
|
||||
this.cbMRImages.TabIndex = 0;
|
||||
this.lbMRImage.AutoSize = true;
|
||||
this.lbMRImage.Location = new Point(11, 12);
|
||||
this.lbMRImage.Name = "lbMRImage";
|
||||
this.lbMRImage.Size = new Size(59, 13);
|
||||
this.lbMRImage.TabIndex = 0;
|
||||
this.lbMRImage.Text = "MR Image:";
|
||||
this.mrImageViewer.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
this.mrImageViewer.Location = new Point(2, 35);
|
||||
this.mrImageViewer.Name = "mrImageViewer";
|
||||
this.mrImageViewer.Size = new Size(460, 205);
|
||||
this.mrImageViewer.TabIndex = 0;
|
||||
this.AutoScaleDimensions = new SizeF(6f, 13f);
|
||||
this.AutoScaleMode = AutoScaleMode.Font;
|
||||
this.Controls.Add((Control) this.cbMRImages);
|
||||
this.Controls.Add((Control) this.lbMRImage);
|
||||
this.Controls.Add((Control) this.mrImageViewer);
|
||||
this.Name = "MRInitialProgramImagesViewer";
|
||||
this.Size = new Size(463, 240);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
|
||||
internal sealed class MRImageItem
|
||||
{
|
||||
public static string DisplayMember => "Name";
|
||||
|
||||
public static string ValueMember => "Image";
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public MRImage Image { get; set; }
|
||||
|
||||
public MRImageItem(string name, MRImage image)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Image = image;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SEGATools/Security/InitialProgramImagesViewer.resx
Normal file
120
SEGATools/Security/InitialProgramImagesViewer.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,16 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramInvalidHardwareIdException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramInvalidHardwareIdException : InitialProgramException
|
||||
{
|
||||
public InitialProgramInvalidHardwareIdException()
|
||||
: base("invalid hardware ID")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
18
SEGATools/Security/InitialProgramInvalidMRImageException.cs
Normal file
18
SEGATools/Security/InitialProgramInvalidMRImageException.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramInvalidMRImageException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramInvalidMRImageException : InitialProgramException
|
||||
{
|
||||
public InitialProgramInvalidMRImageException(int offset, Exception innerException)
|
||||
: base(string.Format("data at offset 0x{0:X8} is not a valid MR image", (object) offset), innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
16
SEGATools/Security/InitialProgramInvalidMakerIdException.cs
Normal file
16
SEGATools/Security/InitialProgramInvalidMakerIdException.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramInvalidMakerIdException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramInvalidMakerIdException : InitialProgramException
|
||||
{
|
||||
public InitialProgramInvalidMakerIdException()
|
||||
: base("invalid maker ID")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
144
SEGATools/Security/InitialProgramLibraryReferences.cs
Normal file
144
SEGATools/Security/InitialProgramLibraryReferences.cs
Normal file
|
@ -0,0 +1,144 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramLibraryReferences
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using SEGATools.Binary;
|
||||
using SEGATools.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramLibraryReferences : UserControl
|
||||
{
|
||||
private IContainer components;
|
||||
private TableLayoutPanel tableLayoutPanel;
|
||||
private Label lbLibraryHint;
|
||||
private ListView listViewLibRef;
|
||||
|
||||
public InitialProgramLibraryReferences()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.InitializeHintText(0);
|
||||
this.InitializeListViewColumns();
|
||||
}
|
||||
|
||||
public void LoadInitialProgram(InitialProgramExtended ip)
|
||||
{
|
||||
if (ip == null)
|
||||
return;
|
||||
this.LoadLibraryReferences(ip);
|
||||
}
|
||||
|
||||
private void InitializeHintText(int NumberOfLibraries)
|
||||
{
|
||||
string str;
|
||||
switch (NumberOfLibraries)
|
||||
{
|
||||
case 0:
|
||||
str = Resources.LibRefNoLibFound;
|
||||
break;
|
||||
case 1:
|
||||
str = Resources.LibRefNumberSingle;
|
||||
break;
|
||||
default:
|
||||
str = string.Format(Resources.LibRefNumberPlurial, (object) NumberOfLibraries);
|
||||
break;
|
||||
}
|
||||
this.lbLibraryHint.Text = string.Format(Resources.LibRefHint, (object) str);
|
||||
}
|
||||
|
||||
private void InitializeListViewColumns()
|
||||
{
|
||||
this.listViewLibRef.Columns.Add(InitialProgramLibraryReferences.createColumn(Resources.LibRefColumnName, HorizontalAlignment.Left));
|
||||
this.listViewLibRef.Columns.Add(InitialProgramLibraryReferences.createColumn(Resources.LibRefColumnVersion, HorizontalAlignment.Right));
|
||||
this.listViewLibRef.Columns.Add(InitialProgramLibraryReferences.createColumn(Resources.LibRefColumnBuildDate, HorizontalAlignment.Right));
|
||||
this.ResizeListViewColumns();
|
||||
}
|
||||
|
||||
private void LoadLibraryReferences(InitialProgramExtended ip)
|
||||
{
|
||||
foreach (SEGALibrary segaLibrary in (IEnumerable<SEGALibrary>) ip.Libraries.OrderBy<SEGALibrary, string>((Func<SEGALibrary, string>) (lib => lib.Name)))
|
||||
this.listViewLibRef.Items.Add(new ListViewItem(new string[3]
|
||||
{
|
||||
segaLibrary.Name,
|
||||
segaLibrary.Version.ToString(),
|
||||
segaLibrary.BuildDate.ToString()
|
||||
}));
|
||||
this.InitializeHintText(ip.Libraries.Count);
|
||||
this.ResizeListViewColumns();
|
||||
}
|
||||
|
||||
private void ResizeListViewColumns() => this.listViewLibRef.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
|
||||
|
||||
private static ColumnHeader createColumn(string Name, HorizontalAlignment alignment) => new ColumnHeader()
|
||||
{
|
||||
Text = Name,
|
||||
TextAlign = alignment
|
||||
};
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && this.components != null)
|
||||
this.components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tableLayoutPanel = new TableLayoutPanel();
|
||||
this.lbLibraryHint = new Label();
|
||||
this.listViewLibRef = new ListView();
|
||||
this.tableLayoutPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
this.tableLayoutPanel.BackColor = Color.Transparent;
|
||||
this.tableLayoutPanel.ColumnCount = 1;
|
||||
this.tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100f));
|
||||
this.tableLayoutPanel.Controls.Add((Control) this.lbLibraryHint, 0, 0);
|
||||
this.tableLayoutPanel.Controls.Add((Control) this.listViewLibRef, 0, 1);
|
||||
this.tableLayoutPanel.Dock = DockStyle.Fill;
|
||||
this.tableLayoutPanel.Location = new Point(0, 0);
|
||||
this.tableLayoutPanel.Name = "tableLayoutPanel";
|
||||
this.tableLayoutPanel.RowCount = 2;
|
||||
this.tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 24f));
|
||||
this.tableLayoutPanel.RowStyles.Add(new RowStyle());
|
||||
this.tableLayoutPanel.Size = new Size(428, 150);
|
||||
this.tableLayoutPanel.TabIndex = 0;
|
||||
this.lbLibraryHint.BackColor = Color.Transparent;
|
||||
this.lbLibraryHint.Dock = DockStyle.Fill;
|
||||
this.lbLibraryHint.Location = new Point(3, 0);
|
||||
this.lbLibraryHint.Name = "lbLibraryHint";
|
||||
this.lbLibraryHint.Size = new Size(422, 24);
|
||||
this.lbLibraryHint.TabIndex = 0;
|
||||
this.lbLibraryHint.Text = "...";
|
||||
this.lbLibraryHint.TextAlign = ContentAlignment.MiddleLeft;
|
||||
this.listViewLibRef.BackColor = SystemColors.Window;
|
||||
this.listViewLibRef.Dock = DockStyle.Fill;
|
||||
this.listViewLibRef.FullRowSelect = true;
|
||||
this.listViewLibRef.HeaderStyle = ColumnHeaderStyle.Nonclickable;
|
||||
this.listViewLibRef.Location = new Point(0, 24);
|
||||
this.listViewLibRef.Margin = new Padding(0);
|
||||
this.listViewLibRef.MultiSelect = false;
|
||||
this.listViewLibRef.Name = "listViewLibRef";
|
||||
this.listViewLibRef.ShowGroups = false;
|
||||
this.listViewLibRef.Size = new Size(428, 126);
|
||||
this.listViewLibRef.TabIndex = 1;
|
||||
this.listViewLibRef.UseCompatibleStateImageBehavior = false;
|
||||
this.listViewLibRef.View = View.Details;
|
||||
this.AutoScaleDimensions = new SizeF(6f, 13f);
|
||||
this.AutoScaleMode = AutoScaleMode.Font;
|
||||
this.BackColor = SystemColors.Control;
|
||||
this.Controls.Add((Control) this.tableLayoutPanel);
|
||||
this.Name = nameof (InitialProgramLibraryReferences);
|
||||
this.Size = new Size(428, 150);
|
||||
this.tableLayoutPanel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
}
|
||||
}
|
120
SEGATools/Security/InitialProgramLibraryReferences.resx
Normal file
120
SEGATools/Security/InitialProgramLibraryReferences.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
373
SEGATools/Security/InitialProgramPeripheralsViewer.cs
Normal file
373
SEGATools/Security/InitialProgramPeripheralsViewer.cs
Normal file
|
@ -0,0 +1,373 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramPeripheralsViewer
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramPeripheralsViewer : UserControl
|
||||
{
|
||||
private IContainer components;
|
||||
private GroupBox gbSupportedPeripherals;
|
||||
private FlowLayoutPanel fplSupportedPeripherals;
|
||||
private CheckBox cbMouse;
|
||||
private CheckBox cbKeyboard;
|
||||
private CheckBox cbGunController;
|
||||
private GroupBox gbSupportedExpandedPeripherals;
|
||||
private FlowLayoutPanel flpSupportedExpandedPeripherals;
|
||||
private CheckBox cbMemoryCard;
|
||||
private CheckBox cbVibrator;
|
||||
private CheckBox cbSoundInputPeripheral;
|
||||
private CheckBox cbOtherDevices;
|
||||
private GroupBox gbMinimalSet;
|
||||
private FlowLayoutPanel flpMinimalSet;
|
||||
private CheckBox cbStartABDirButtons;
|
||||
private CheckBox cbCButton;
|
||||
private CheckBox cbDButton;
|
||||
private CheckBox cbXButton;
|
||||
private CheckBox cbYButton;
|
||||
private CheckBox cbZButton;
|
||||
private CheckBox cbAnalogLTrigger;
|
||||
private CheckBox cbAnalogRTrigger;
|
||||
private CheckBox cbStandardAnalogX;
|
||||
private CheckBox cbStandardAnalogY;
|
||||
private CheckBox cbExpandedDirectionButtons;
|
||||
private CheckBox cbExpandedAnalogX;
|
||||
private CheckBox cbExpandedAnalogY;
|
||||
|
||||
public InitialProgramPeripheralsViewer() => this.InitializeComponent();
|
||||
|
||||
public void LoadInitialProgram(InitialProgramExtended ip)
|
||||
{
|
||||
if (ip == null)
|
||||
return;
|
||||
this.SetSupportedPeripherals((InitialProgram) ip);
|
||||
this.SetSupportedExpandedPeripherals((InitialProgram) ip);
|
||||
this.SetSupportedButtons((InitialProgram) ip);
|
||||
}
|
||||
|
||||
private void SetSupportedPeripherals(InitialProgram ip)
|
||||
{
|
||||
this.cbGunController.Checked = ip.SupportGun;
|
||||
this.cbKeyboard.Checked = ip.SupportKeyboard;
|
||||
this.cbMouse.Checked = ip.SupportMouse;
|
||||
}
|
||||
|
||||
private void SetSupportedExpandedPeripherals(InitialProgram ip)
|
||||
{
|
||||
this.cbMemoryCard.Checked = ip.SupportMemoryCard;
|
||||
this.cbVibrator.Checked = ip.SupportVibrator;
|
||||
this.cbSoundInputPeripheral.Checked = ip.SupportSoundInputPeripheral;
|
||||
this.cbOtherDevices.Checked = ip.SupportOtherDevices;
|
||||
}
|
||||
|
||||
private void SetSupportedButtons(InitialProgram ip)
|
||||
{
|
||||
this.cbStartABDirButtons.Checked = ip.SupportStartABDirections;
|
||||
this.cbCButton.Checked = ip.SupportCButton;
|
||||
this.cbDButton.Checked = ip.SupportDButton;
|
||||
this.cbXButton.Checked = ip.SupportXButton;
|
||||
this.cbYButton.Checked = ip.SupportYButton;
|
||||
this.cbZButton.Checked = ip.SupportZButton;
|
||||
this.cbExpandedDirectionButtons.Checked = ip.SupportExpandedDirectionButtons;
|
||||
this.cbAnalogLTrigger.Checked = ip.SupportAnalogLTrigger;
|
||||
this.cbAnalogRTrigger.Checked = ip.SupportAnalogRTrigger;
|
||||
this.cbStandardAnalogX.Checked = ip.SupportAnalogHorizontalController;
|
||||
this.cbStandardAnalogY.Checked = ip.SupportAnalogVerticalController;
|
||||
this.cbExpandedAnalogX.Checked = ip.SupportExpandedAnalogHorizontal;
|
||||
this.cbExpandedAnalogY.Checked = ip.SupportExpandedAnalogVertical;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && this.components != null)
|
||||
this.components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.gbSupportedPeripherals = new GroupBox();
|
||||
this.fplSupportedPeripherals = new FlowLayoutPanel();
|
||||
this.cbMouse = new CheckBox();
|
||||
this.cbKeyboard = new CheckBox();
|
||||
this.cbGunController = new CheckBox();
|
||||
this.gbSupportedExpandedPeripherals = new GroupBox();
|
||||
this.flpSupportedExpandedPeripherals = new FlowLayoutPanel();
|
||||
this.cbMemoryCard = new CheckBox();
|
||||
this.cbVibrator = new CheckBox();
|
||||
this.cbSoundInputPeripheral = new CheckBox();
|
||||
this.cbOtherDevices = new CheckBox();
|
||||
this.gbMinimalSet = new GroupBox();
|
||||
this.flpMinimalSet = new FlowLayoutPanel();
|
||||
this.cbStartABDirButtons = new CheckBox();
|
||||
this.cbCButton = new CheckBox();
|
||||
this.cbDButton = new CheckBox();
|
||||
this.cbXButton = new CheckBox();
|
||||
this.cbYButton = new CheckBox();
|
||||
this.cbZButton = new CheckBox();
|
||||
this.cbAnalogLTrigger = new CheckBox();
|
||||
this.cbAnalogRTrigger = new CheckBox();
|
||||
this.cbStandardAnalogX = new CheckBox();
|
||||
this.cbStandardAnalogY = new CheckBox();
|
||||
this.cbExpandedDirectionButtons = new CheckBox();
|
||||
this.cbExpandedAnalogX = new CheckBox();
|
||||
this.cbExpandedAnalogY = new CheckBox();
|
||||
this.gbSupportedPeripherals.SuspendLayout();
|
||||
this.fplSupportedPeripherals.SuspendLayout();
|
||||
this.gbSupportedExpandedPeripherals.SuspendLayout();
|
||||
this.flpSupportedExpandedPeripherals.SuspendLayout();
|
||||
this.gbMinimalSet.SuspendLayout();
|
||||
this.flpMinimalSet.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
this.gbSupportedPeripherals.Controls.Add((Control) this.fplSupportedPeripherals);
|
||||
this.gbSupportedPeripherals.Location = new Point(6, 148);
|
||||
this.gbSupportedPeripherals.Name = "gbSupportedPeripherals";
|
||||
this.gbSupportedPeripherals.Size = new Size(147, 91);
|
||||
this.gbSupportedPeripherals.TabIndex = 0;
|
||||
this.gbSupportedPeripherals.TabStop = false;
|
||||
this.gbSupportedPeripherals.Text = "Supported peripherals:";
|
||||
this.fplSupportedPeripherals.AutoSize = true;
|
||||
this.fplSupportedPeripherals.Controls.Add((Control) this.cbMouse);
|
||||
this.fplSupportedPeripherals.Controls.Add((Control) this.cbKeyboard);
|
||||
this.fplSupportedPeripherals.Controls.Add((Control) this.cbGunController);
|
||||
this.fplSupportedPeripherals.Dock = DockStyle.Fill;
|
||||
this.fplSupportedPeripherals.FlowDirection = FlowDirection.TopDown;
|
||||
this.fplSupportedPeripherals.Location = new Point(3, 16);
|
||||
this.fplSupportedPeripherals.Name = "fplSupportedPeripherals";
|
||||
this.fplSupportedPeripherals.Size = new Size(141, 72);
|
||||
this.fplSupportedPeripherals.TabIndex = 0;
|
||||
this.cbMouse.AutoCheck = false;
|
||||
this.cbMouse.AutoSize = true;
|
||||
this.cbMouse.Location = new Point(3, 3);
|
||||
this.cbMouse.Name = "cbMouse";
|
||||
this.cbMouse.Size = new Size(58, 17);
|
||||
this.cbMouse.TabIndex = 14;
|
||||
this.cbMouse.Text = "Mouse";
|
||||
this.cbMouse.UseVisualStyleBackColor = true;
|
||||
this.cbKeyboard.AutoCheck = false;
|
||||
this.cbKeyboard.AutoSize = true;
|
||||
this.cbKeyboard.Location = new Point(3, 26);
|
||||
this.cbKeyboard.Name = "cbKeyboard";
|
||||
this.cbKeyboard.Size = new Size(71, 17);
|
||||
this.cbKeyboard.TabIndex = 15;
|
||||
this.cbKeyboard.Text = "Keyboard";
|
||||
this.cbKeyboard.UseVisualStyleBackColor = true;
|
||||
this.cbGunController.AutoCheck = false;
|
||||
this.cbGunController.AutoSize = true;
|
||||
this.cbGunController.Location = new Point(3, 49);
|
||||
this.cbGunController.Name = "cbGunController";
|
||||
this.cbGunController.Size = new Size(93, 17);
|
||||
this.cbGunController.TabIndex = 16;
|
||||
this.cbGunController.Text = "Gun Controller";
|
||||
this.cbGunController.UseVisualStyleBackColor = true;
|
||||
this.gbSupportedExpandedPeripherals.Controls.Add((Control) this.flpSupportedExpandedPeripherals);
|
||||
this.gbSupportedExpandedPeripherals.Location = new Point(163, 148);
|
||||
this.gbSupportedExpandedPeripherals.Name = "gbSupportedExpandedPeripherals";
|
||||
this.gbSupportedExpandedPeripherals.Size = new Size(292, 91);
|
||||
this.gbSupportedExpandedPeripherals.TabIndex = 0;
|
||||
this.gbSupportedExpandedPeripherals.TabStop = false;
|
||||
this.gbSupportedExpandedPeripherals.Text = "Supported Expanded Peripherals:";
|
||||
this.flpSupportedExpandedPeripherals.Controls.Add((Control) this.cbMemoryCard);
|
||||
this.flpSupportedExpandedPeripherals.Controls.Add((Control) this.cbVibrator);
|
||||
this.flpSupportedExpandedPeripherals.Controls.Add((Control) this.cbSoundInputPeripheral);
|
||||
this.flpSupportedExpandedPeripherals.Controls.Add((Control) this.cbOtherDevices);
|
||||
this.flpSupportedExpandedPeripherals.Dock = DockStyle.Fill;
|
||||
this.flpSupportedExpandedPeripherals.FlowDirection = FlowDirection.TopDown;
|
||||
this.flpSupportedExpandedPeripherals.Location = new Point(3, 16);
|
||||
this.flpSupportedExpandedPeripherals.Name = "flpSupportedExpandedPeripherals";
|
||||
this.flpSupportedExpandedPeripherals.Size = new Size(286, 72);
|
||||
this.flpSupportedExpandedPeripherals.TabIndex = 0;
|
||||
this.cbMemoryCard.AutoCheck = false;
|
||||
this.cbMemoryCard.AutoSize = true;
|
||||
this.cbMemoryCard.Location = new Point(3, 3);
|
||||
this.cbMemoryCard.Name = "cbMemoryCard";
|
||||
this.cbMemoryCard.Size = new Size(88, 17);
|
||||
this.cbMemoryCard.TabIndex = 17;
|
||||
this.cbMemoryCard.Text = "Memory Card";
|
||||
this.cbMemoryCard.UseVisualStyleBackColor = true;
|
||||
this.cbVibrator.AutoCheck = false;
|
||||
this.cbVibrator.AutoSize = true;
|
||||
this.cbVibrator.Location = new Point(3, 26);
|
||||
this.cbVibrator.Name = "cbVibrator";
|
||||
this.cbVibrator.Size = new Size(62, 17);
|
||||
this.cbVibrator.TabIndex = 18;
|
||||
this.cbVibrator.Text = "Vibrator";
|
||||
this.cbVibrator.UseVisualStyleBackColor = true;
|
||||
this.cbSoundInputPeripheral.AutoCheck = false;
|
||||
this.cbSoundInputPeripheral.AutoSize = true;
|
||||
this.cbSoundInputPeripheral.Location = new Point(3, 49);
|
||||
this.cbSoundInputPeripheral.Name = "cbSoundInputPeripheral";
|
||||
this.cbSoundInputPeripheral.Size = new Size(134, 17);
|
||||
this.cbSoundInputPeripheral.TabIndex = 19;
|
||||
this.cbSoundInputPeripheral.Text = "Sound Input Peripheral";
|
||||
this.cbSoundInputPeripheral.UseVisualStyleBackColor = true;
|
||||
this.cbOtherDevices.AutoCheck = false;
|
||||
this.cbOtherDevices.AutoSize = true;
|
||||
this.cbOtherDevices.Location = new Point(143, 3);
|
||||
this.cbOtherDevices.Name = "cbOtherDevices";
|
||||
this.cbOtherDevices.Size = new Size(94, 17);
|
||||
this.cbOtherDevices.TabIndex = 20;
|
||||
this.cbOtherDevices.Text = "Other Devices";
|
||||
this.cbOtherDevices.UseVisualStyleBackColor = true;
|
||||
this.gbMinimalSet.AutoSize = true;
|
||||
this.gbMinimalSet.BackColor = Color.Transparent;
|
||||
this.gbMinimalSet.Controls.Add((Control) this.flpMinimalSet);
|
||||
this.gbMinimalSet.Location = new Point(6, 3);
|
||||
this.gbMinimalSet.Name = "gbMinimalSet";
|
||||
this.gbMinimalSet.Size = new Size(449, 139);
|
||||
this.gbMinimalSet.TabIndex = 0;
|
||||
this.gbMinimalSet.TabStop = false;
|
||||
this.gbMinimalSet.Text = "Minimal set of buttons required by application:";
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbStartABDirButtons);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbCButton);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbDButton);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbXButton);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbYButton);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbZButton);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbAnalogLTrigger);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbAnalogRTrigger);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbStandardAnalogX);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbStandardAnalogY);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbExpandedDirectionButtons);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbExpandedAnalogX);
|
||||
this.flpMinimalSet.Controls.Add((Control) this.cbExpandedAnalogY);
|
||||
this.flpMinimalSet.Dock = DockStyle.Fill;
|
||||
this.flpMinimalSet.FlowDirection = FlowDirection.TopDown;
|
||||
this.flpMinimalSet.Location = new Point(3, 16);
|
||||
this.flpMinimalSet.Name = "flpMinimalSet";
|
||||
this.flpMinimalSet.Size = new Size(443, 120);
|
||||
this.flpMinimalSet.TabIndex = 0;
|
||||
this.cbStartABDirButtons.AutoCheck = false;
|
||||
this.cbStartABDirButtons.AutoSize = true;
|
||||
this.cbStartABDirButtons.Location = new Point(3, 3);
|
||||
this.cbStartABDirButtons.Name = "cbStartABDirButtons";
|
||||
this.cbStartABDirButtons.Size = new Size(161, 17);
|
||||
this.cbStartABDirButtons.TabIndex = 1;
|
||||
this.cbStartABDirButtons.Text = "Start, A, B, Direction Buttons";
|
||||
this.cbStartABDirButtons.UseVisualStyleBackColor = true;
|
||||
this.cbCButton.AutoCheck = false;
|
||||
this.cbCButton.AutoSize = true;
|
||||
this.cbCButton.Location = new Point(3, 26);
|
||||
this.cbCButton.Name = "cbCButton";
|
||||
this.cbCButton.Size = new Size(67, 17);
|
||||
this.cbCButton.TabIndex = 2;
|
||||
this.cbCButton.Text = "C Button";
|
||||
this.cbCButton.UseVisualStyleBackColor = true;
|
||||
this.cbDButton.AutoCheck = false;
|
||||
this.cbDButton.AutoSize = true;
|
||||
this.cbDButton.Location = new Point(3, 49);
|
||||
this.cbDButton.Name = "cbDButton";
|
||||
this.cbDButton.Size = new Size(68, 17);
|
||||
this.cbDButton.TabIndex = 3;
|
||||
this.cbDButton.Text = "D Button";
|
||||
this.cbDButton.UseVisualStyleBackColor = true;
|
||||
this.cbXButton.AutoCheck = false;
|
||||
this.cbXButton.AutoSize = true;
|
||||
this.cbXButton.Location = new Point(3, 72);
|
||||
this.cbXButton.Name = "cbXButton";
|
||||
this.cbXButton.Size = new Size(67, 17);
|
||||
this.cbXButton.TabIndex = 4;
|
||||
this.cbXButton.Text = "X Button";
|
||||
this.cbXButton.UseVisualStyleBackColor = true;
|
||||
this.cbYButton.AutoCheck = false;
|
||||
this.cbYButton.AutoSize = true;
|
||||
this.cbYButton.Location = new Point(3, 95);
|
||||
this.cbYButton.Name = "cbYButton";
|
||||
this.cbYButton.Size = new Size(67, 17);
|
||||
this.cbYButton.TabIndex = 5;
|
||||
this.cbYButton.Text = "Y Button";
|
||||
this.cbYButton.UseVisualStyleBackColor = true;
|
||||
this.cbZButton.AutoCheck = false;
|
||||
this.cbZButton.AutoSize = true;
|
||||
this.cbZButton.Location = new Point(170, 3);
|
||||
this.cbZButton.Name = "cbZButton";
|
||||
this.cbZButton.Size = new Size(67, 17);
|
||||
this.cbZButton.TabIndex = 6;
|
||||
this.cbZButton.Text = "Z Button";
|
||||
this.cbZButton.UseVisualStyleBackColor = true;
|
||||
this.cbAnalogLTrigger.AutoCheck = false;
|
||||
this.cbAnalogLTrigger.AutoSize = true;
|
||||
this.cbAnalogLTrigger.Location = new Point(170, 26);
|
||||
this.cbAnalogLTrigger.Name = "cbAnalogLTrigger";
|
||||
this.cbAnalogLTrigger.Size = new Size(104, 17);
|
||||
this.cbAnalogLTrigger.TabIndex = 7;
|
||||
this.cbAnalogLTrigger.Text = "Analog L Trigger";
|
||||
this.cbAnalogLTrigger.UseVisualStyleBackColor = true;
|
||||
this.cbAnalogRTrigger.AutoCheck = false;
|
||||
this.cbAnalogRTrigger.AutoSize = true;
|
||||
this.cbAnalogRTrigger.Location = new Point(170, 49);
|
||||
this.cbAnalogRTrigger.Name = "cbAnalogRTrigger";
|
||||
this.cbAnalogRTrigger.Size = new Size(106, 17);
|
||||
this.cbAnalogRTrigger.TabIndex = 8;
|
||||
this.cbAnalogRTrigger.Text = "Analog R Trigger";
|
||||
this.cbAnalogRTrigger.UseVisualStyleBackColor = true;
|
||||
this.cbStandardAnalogX.AutoCheck = false;
|
||||
this.cbStandardAnalogX.AutoSize = true;
|
||||
this.cbStandardAnalogX.Location = new Point(170, 72);
|
||||
this.cbStandardAnalogX.Name = "cbStandardAnalogX";
|
||||
this.cbStandardAnalogX.Size = new Size(115, 17);
|
||||
this.cbStandardAnalogX.TabIndex = 9;
|
||||
this.cbStandardAnalogX.Text = "Standard Analog X";
|
||||
this.cbStandardAnalogX.UseVisualStyleBackColor = true;
|
||||
this.cbStandardAnalogY.AutoCheck = false;
|
||||
this.cbStandardAnalogY.AutoSize = true;
|
||||
this.cbStandardAnalogY.Location = new Point(170, 95);
|
||||
this.cbStandardAnalogY.Name = "cbStandardAnalogY";
|
||||
this.cbStandardAnalogY.Size = new Size(115, 17);
|
||||
this.cbStandardAnalogY.TabIndex = 10;
|
||||
this.cbStandardAnalogY.Text = "Standard Analog Y";
|
||||
this.cbStandardAnalogY.UseVisualStyleBackColor = true;
|
||||
this.cbExpandedDirectionButtons.AutoCheck = false;
|
||||
this.cbExpandedDirectionButtons.AutoSize = true;
|
||||
this.cbExpandedDirectionButtons.Location = new Point(291, 3);
|
||||
this.cbExpandedDirectionButtons.Name = "cbExpandedDirectionButtons";
|
||||
this.cbExpandedDirectionButtons.Size = new Size(158, 17);
|
||||
this.cbExpandedDirectionButtons.TabIndex = 11;
|
||||
this.cbExpandedDirectionButtons.Text = "Expanded Direction Buttons";
|
||||
this.cbExpandedDirectionButtons.UseVisualStyleBackColor = true;
|
||||
this.cbExpandedAnalogX.AutoCheck = false;
|
||||
this.cbExpandedAnalogX.AutoSize = true;
|
||||
this.cbExpandedAnalogX.Location = new Point(291, 26);
|
||||
this.cbExpandedAnalogX.Name = "cbExpandedAnalogX";
|
||||
this.cbExpandedAnalogX.Size = new Size(120, 17);
|
||||
this.cbExpandedAnalogX.TabIndex = 12;
|
||||
this.cbExpandedAnalogX.Text = "Expanded Analog X";
|
||||
this.cbExpandedAnalogX.UseVisualStyleBackColor = true;
|
||||
this.cbExpandedAnalogY.AutoCheck = false;
|
||||
this.cbExpandedAnalogY.AutoSize = true;
|
||||
this.cbExpandedAnalogY.Location = new Point(291, 49);
|
||||
this.cbExpandedAnalogY.Name = "cbExpandedAnalogY";
|
||||
this.cbExpandedAnalogY.Size = new Size(120, 17);
|
||||
this.cbExpandedAnalogY.TabIndex = 13;
|
||||
this.cbExpandedAnalogY.Text = "Expanded Analog Y";
|
||||
this.cbExpandedAnalogY.UseVisualStyleBackColor = true;
|
||||
this.AutoScaleDimensions = new SizeF(6f, 13f);
|
||||
this.AutoScaleMode = AutoScaleMode.Font;
|
||||
this.AutoSize = true;
|
||||
this.BackColor = Color.Transparent;
|
||||
this.Controls.Add((Control) this.gbSupportedPeripherals);
|
||||
this.Controls.Add((Control) this.gbSupportedExpandedPeripherals);
|
||||
this.Controls.Add((Control) this.gbMinimalSet);
|
||||
this.Name = nameof (InitialProgramPeripheralsViewer);
|
||||
this.Size = new Size(460, 246);
|
||||
this.gbSupportedPeripherals.ResumeLayout(false);
|
||||
this.gbSupportedPeripherals.PerformLayout();
|
||||
this.fplSupportedPeripherals.ResumeLayout(false);
|
||||
this.fplSupportedPeripherals.PerformLayout();
|
||||
this.gbSupportedExpandedPeripherals.ResumeLayout(false);
|
||||
this.flpSupportedExpandedPeripherals.ResumeLayout(false);
|
||||
this.flpSupportedExpandedPeripherals.PerformLayout();
|
||||
this.gbMinimalSet.ResumeLayout(false);
|
||||
this.flpMinimalSet.ResumeLayout(false);
|
||||
this.flpMinimalSet.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
}
|
||||
}
|
120
SEGATools/Security/InitialProgramPeripheralsViewer.resx
Normal file
120
SEGATools/Security/InitialProgramPeripheralsViewer.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramReleaseDateParsingException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramReleaseDateParsingException : InitialProgramException
|
||||
{
|
||||
public InitialProgramReleaseDateParsingException(string releaseDate, Exception innerException)
|
||||
: base(string.Format("invalid release date \"{0}\"", (object) releaseDate), innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
25
SEGATools/Security/InitialProgramToc.cs
Normal file
25
SEGATools/Security/InitialProgramToc.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramToc
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramToc
|
||||
{
|
||||
public InitialProgramTrackInfo FirstTrack => this.Tracks.Aggregate<InitialProgramTrackInfo>((Func<InitialProgramTrackInfo, InitialProgramTrackInfo, InitialProgramTrackInfo>) ((a, b) => a.Index > b.Index ? b : a));
|
||||
|
||||
public InitialProgramTrackInfo LastTrack => this.Tracks.Aggregate<InitialProgramTrackInfo>((Func<InitialProgramTrackInfo, InitialProgramTrackInfo, InitialProgramTrackInfo>) ((a, b) => a.Index <= b.Index ? b : a));
|
||||
|
||||
public bool HasSplitedDataTracks => this.FirstTrack != null && this.LastTrack != null && this.FirstTrack.Index != this.LastTrack.Index;
|
||||
|
||||
public List<InitialProgramTrackInfo> Tracks { get; private set; }
|
||||
|
||||
internal InitialProgramToc(InitialProgramTrackInfo[] tracks) => this.Tracks = ((IEnumerable<InitialProgramTrackInfo>) tracks).OrderBy<InitialProgramTrackInfo, int>((Func<InitialProgramTrackInfo, int>) (track => track.Index)).ToList<InitialProgramTrackInfo>();
|
||||
}
|
||||
}
|
96
SEGATools/Security/InitialProgramTocConverter.cs
Normal file
96
SEGATools/Security/InitialProgramTocConverter.cs
Normal file
|
@ -0,0 +1,96 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramTocConverter
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
internal sealed class InitialProgramTocConverter
|
||||
{
|
||||
private const string TOC_ID = "TOC1";
|
||||
private const int TOC_ID_LENGTH = 4;
|
||||
private const int TOC_TRACKINFO_LENGTH = 4;
|
||||
private const int TOC_NUMBER_OF_TRACKINFO = 97;
|
||||
private const int TOC_TRACKINFO_SIZE = 388;
|
||||
private const int TOC_DATA_SIZE = 392;
|
||||
private const int TOC_TRACK_INDEX_OFFSET = 3;
|
||||
private const int TOC_TRACK_POST_GAP = 150;
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
|
||||
private static uint TocTrackNumber(uint n) => (n & 16711680U) >> 16;
|
||||
|
||||
private static uint TocTrackFAD(uint n) => n & 16777215U;
|
||||
|
||||
private static InitialProgramTrackInfo.ControlData TocTrackType(uint n) => (InitialProgramTrackInfo.ControlData) ((n & 4026531840U) >> 28);
|
||||
|
||||
internal static InitialProgramToc ToInitialProgramToc(
|
||||
byte[] buffer,
|
||||
int startIndex)
|
||||
{
|
||||
if (startIndex < 0 || buffer.Length - startIndex < 392)
|
||||
{
|
||||
InitialProgramTocConverter.logger.ErrorFormat("Buffer too small: {0} bytes", (object) (buffer.Length - startIndex));
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
string str = Encoding.ASCII.GetString(buffer, startIndex, "TOC1".Length);
|
||||
if (!"TOC1".Equals(str))
|
||||
{
|
||||
InitialProgramTocConverter.logger.ErrorFormat("Expected TOC identifier \"{0}\", got \"{1}\"", (object) "TOC1", (object) str);
|
||||
throw new InitialProgramTocIdentifierMissingException();
|
||||
}
|
||||
InitialProgramTocConverter.TOC structure = (InitialProgramTocConverter.TOC) Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement((Array) buffer, startIndex + 4), typeof (InitialProgramTocConverter.TOC));
|
||||
int length = (int) InitialProgramTocConverter.TocTrackNumber(structure.LastTrack) - (int) InitialProgramTocConverter.TocTrackNumber(structure.FirstTrack) + 1;
|
||||
InitialProgramTocConverter.logger.InfoFormat("Number Of Tracks = {0}", (object) length);
|
||||
InitialProgramTrackInfo[] tracks = length > 0 ? new InitialProgramTrackInfo[length] : throw new InitialProgramTocWrongNumberOfTracksException();
|
||||
int num = tracks.Length - 1;
|
||||
for (int trackNumber = num; trackNumber >= 0; --trackNumber)
|
||||
{
|
||||
uint track1 = structure.Tracks[trackNumber];
|
||||
uint StartFAD = InitialProgramTocConverter.TocTrackFAD(track1);
|
||||
InitialProgramTrackInfo.ControlData controlData = InitialProgramTocConverter.TocTrackType(track1);
|
||||
if (!Enum.IsDefined(typeof (InitialProgramTrackInfo.ControlData), (object) controlData))
|
||||
{
|
||||
InitialProgramTocConverter.logger.ErrorFormat("Track {0} control value is not supported: {1}", (object) trackNumber, (object) controlData);
|
||||
throw new InitialProgramTocWrongControlDataException(trackNumber, controlData);
|
||||
}
|
||||
InitialProgramTocTrackBuilder programTocTrackBuilder = InitialProgramTocTrackBuilder.aTrackWithIndex(3 + trackNumber).WithStartFAD(StartFAD).WithCtrl(controlData);
|
||||
uint LastFAD;
|
||||
if (trackNumber == num)
|
||||
{
|
||||
LastFAD = InitialProgramTocConverter.TocTrackFAD(structure.LeadOut) - 1U;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint track2 = structure.Tracks[trackNumber + 1];
|
||||
LastFAD = InitialProgramTocConverter.TocTrackFAD(track2) - 1U;
|
||||
if (controlData != InitialProgramTocConverter.TocTrackType(track2))
|
||||
LastFAD -= 150U;
|
||||
}
|
||||
programTocTrackBuilder.WithLastFAD(LastFAD);
|
||||
InitialProgramTrackInfo programTrackInfo = programTocTrackBuilder.Build();
|
||||
tracks[trackNumber] = programTrackInfo;
|
||||
InitialProgramTocConverter.logger.DebugFormat("IP TOC: found {0}", (object) programTrackInfo);
|
||||
}
|
||||
return new InitialProgramToc(tracks);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 388, Pack = 1)]
|
||||
private struct TOC
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 97, ArraySubType = UnmanagedType.U4)]
|
||||
[FieldOffset(0)]
|
||||
public uint[] Tracks;
|
||||
[FieldOffset(388)]
|
||||
public uint FirstTrack;
|
||||
[FieldOffset(392)]
|
||||
public uint LastTrack;
|
||||
[FieldOffset(396)]
|
||||
public uint LeadOut;
|
||||
}
|
||||
}
|
||||
}
|
23
SEGATools/Security/InitialProgramTocException.cs
Normal file
23
SEGATools/Security/InitialProgramTocException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramTocException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
internal class InitialProgramTocException : Exception
|
||||
{
|
||||
internal InitialProgramTocException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
internal InitialProgramTocException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramTocIdentifierMissingException
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
internal class InitialProgramTocIdentifierMissingException : InitialProgramTocException
|
||||
{
|
||||
public InitialProgramTocIdentifierMissingException()
|
||||
: base("TOC identifier missing")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
53
SEGATools/Security/InitialProgramTocTrackBuilder.cs
Normal file
53
SEGATools/Security/InitialProgramTocTrackBuilder.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: SEGATools.Security.InitialProgramTocTrackBuilder
|
||||
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: D631183F-57B1-40A1-B502-5364D288307A
|
||||
// Assembly location: SEGATools.dll
|
||||
|
||||
namespace SEGATools.Security
|
||||
{
|
||||
public class InitialProgramTocTrackBuilder
|
||||
{
|
||||
private int Index;
|
||||
private uint StartFAD;
|
||||
private uint Size;
|
||||
private InitialProgramTrackInfo.ControlData Ctrl;
|
||||
|
||||
private InitialProgramTocTrackBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
public InitialProgramTocTrackBuilder WithIndex(int Index)
|
||||
{
|
||||
this.Index = Index;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InitialProgramTocTrackBuilder WithStartFAD(uint StartFAD)
|
||||
{
|
||||
this.StartFAD = StartFAD;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InitialProgramTocTrackBuilder WithCtrl(
|
||||
InitialProgramTrackInfo.ControlData Ctrl)
|
||||
{
|
||||
this.Ctrl = Ctrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InitialProgramTocTrackBuilder WithLastFAD(uint LastFAD)
|
||||
{
|
||||
this.Size = LastFAD + 1U - this.StartFAD;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InitialProgramTrackInfo Build() => new InitialProgramTrackInfo(this.Index, this.StartFAD, this.Size, this.Ctrl);
|
||||
|
||||
public static InitialProgramTocTrackBuilder aTrackWithIndex(
|
||||
int Index)
|
||||
{
|
||||
return new InitialProgramTocTrackBuilder().WithIndex(Index);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue