initial commit

This commit is contained in:
what 2021-07-26 13:04:16 -07:00
commit 1b60743303
274 changed files with 25866 additions and 0 deletions

View file

@ -0,0 +1,14 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("GD-ROM Explorer BIN File Format")]
[assembly: AssemblyDescription("BIN File Format Plugin")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Japanese Cake")]
[assembly: AssemblyProduct("GD-ROM Explorer - BIN File Format Plugin")]
[assembly: AssemblyCopyright("2014 - 2016")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(true)]
[assembly: Guid("47b79a6e-d9b7-483d-8013-ffcdab185e81")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]

59
Formats/BIN/BIN.csproj Normal file
View file

@ -0,0 +1,59 @@
<?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\Formats\BIN.dll-->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9BE87EC9-C89C-4521-BB87-5BBD997FA627}</ProjectGuid>
<OutputType>Library</OutputType>
<AssemblyName>BIN</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ApplicationVersion>1.0.0.0</ApplicationVersion>
<FileAlignment>512</FileAlignment>
<RootNamespace>GDRomExplorer.ImageFileFormat.BIN</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\Formats\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\Release\Formats\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Compile Include="BinaryImageFormat.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ImageReader\ImageReader.csproj">
<Project>{2185f55e-a4da-486f-acc8-3ee955205ce4}</Project>
<Name>ImageReader</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\SEGATools\SEGATools.csproj">
<Project>{4d3ab913-88d2-4dd1-a403-ea46d14c98e6}</Project>
<Name>SEGATools</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

24
Formats/BIN/BIN.sln Normal file
View file

@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31424.327
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BIN", "BIN.csproj", "{9BE87EC9-C89C-4521-BB87-5BBD997FA627}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9BE87EC9-C89C-4521-BB87-5BBD997FA627}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BE87EC9-C89C-4521-BB87-5BBD997FA627}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BE87EC9-C89C-4521-BB87-5BBD997FA627}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BE87EC9-C89C-4521-BB87-5BBD997FA627}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C79035C8-8C85-4D9F-B588-D7C8F12994ED}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,27 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.BIN.BinaryImageFormat
// Assembly: BIN, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: 6DE81A29-0420-4189-8D61-5DDF40D77BD6
// Assembly location: C:\Games\gdrom\Formats\BIN.dll
using ImageReader.DiscSectors;
using SEGATools.DiscFileSystem;
using SEGATools.FileFormat;
namespace GDRomExplorer.ImageFileFormat.BIN
{
internal class BinaryImageFormat : AbstractImageFileFormat
{
public override string[] FileExtentions => new string[1]
{
".bin"
};
public override string[] FileExtentionDescriptions => new string[1]
{
"Binary image file"
};
public override IDiscFileSystemConverter ImageFileConverter => (IDiscFileSystemConverter) new GenericImageConverter((IDiscSector) new CDROMMode1RawSector());
}
}

View file

@ -0,0 +1,14 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("2014 - 2016")]
[assembly: AssemblyTitle("GD-ROM Explorer CDI File Format")]
[assembly: AssemblyDescription("CDI File Format Plugin")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Japanese Cake")]
[assembly: AssemblyProduct("GD-ROM Explorer - CDI File Format Plugin")]
[assembly: Guid("0dae2017-8888-4e40-a4aa-798856425b20")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(true)]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyVersion("1.0.1.0")]

64
Formats/CDI/CDI.csproj Normal file
View file

@ -0,0 +1,64 @@
<?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\Formats\CDI.dll-->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A3861387-BB2E-4C3A-9AB2-43B77C393C24}</ProjectGuid>
<OutputType>Library</OutputType>
<AssemblyName>CDI</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ApplicationVersion>1.0.1.0</ApplicationVersion>
<FileAlignment>512</FileAlignment>
<RootNamespace>GDRomExplorer.ImageFileFormat.CDI</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\Formats\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\Release\Formats\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Compile Include="CDIVersion.cs" />
<Compile Include="CDIHeader.cs" />
<Compile Include="CDIHeaderConverter.cs" />
<Compile Include="CDIImageBuilder.cs" />
<Compile Include="CDIImageFormat.cs" />
<Compile Include="CDIToc.cs" />
<Compile Include="CDITocConverter.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ImageReader\ImageReader.csproj">
<Project>{2185f55e-a4da-486f-acc8-3ee955205ce4}</Project>
<Name>ImageReader</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\SEGATools\SEGATools.csproj">
<Project>{4d3ab913-88d2-4dd1-a403-ea46d14c98e6}</Project>
<Name>SEGATools</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

20
Formats/CDI/CDI.sln Normal file
View file

@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CDI", "CDI.csproj", "{A3861387-BB2E-4C3A-9AB2-43B77C393C24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A3861387-BB2E-4C3A-9AB2-43B77C393C24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3861387-BB2E-4C3A-9AB2-43B77C393C24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3861387-BB2E-4C3A-9AB2-43B77C393C24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3861387-BB2E-4C3A-9AB2-43B77C393C24}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

15
Formats/CDI/CDIHeader.cs Normal file
View file

@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.CDI.CDIHeader
// Assembly: CDI, Version=1.0.1.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: B71D3BB5-2FC4-43C2-853E-907E3A458120
// Assembly location: Formats\CDI.dll
namespace GDRomExplorer.ImageFileFormat.CDI
{
internal class CDIHeader
{
internal CDIVersion cdiVersion;
internal uint rawCdiVersion;
internal uint headerOffset;
}
}

View file

@ -0,0 +1,35 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.CDI.CDIHeaderConverter
// Assembly: CDI, Version=1.0.1.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: B71D3BB5-2FC4-43C2-853E-907E3A458120
// Assembly location: Formats\CDI.dll
using SEGATools.DiscFileSystem;
using System;
using System.IO;
namespace GDRomExplorer.ImageFileFormat.CDI
{
internal class CDIHeaderConverter
{
private static readonly byte HEADER_MIN_SIZE = 8;
private static readonly short HEADER_OFFSET = -8;
private static readonly short HEADER_SIZE = 8;
internal static CDIHeader ToCDIHeader(Stream imageStream)
{
if (imageStream.Length < (long) CDIHeaderConverter.HEADER_MIN_SIZE)
throw new DiscFormatException("The stream is too small");
CDIHeader cdiHeader = new CDIHeader();
byte[] buffer = new byte[(int) CDIHeaderConverter.HEADER_SIZE];
imageStream.Seek((long) CDIHeaderConverter.HEADER_OFFSET, SeekOrigin.End);
imageStream.Read(buffer, 0, (int) CDIHeaderConverter.HEADER_SIZE);
cdiHeader.rawCdiVersion = BitConverter.ToUInt32(buffer, 0);
cdiHeader.cdiVersion = cdiHeader.rawCdiVersion == 2147483652U || cdiHeader.rawCdiVersion == 2147483653U || cdiHeader.rawCdiVersion == 2147483654U ? (CDIVersion) cdiHeader.rawCdiVersion : CDIVersion.CDI_VERSION_UNKNOWN;
cdiHeader.headerOffset = BitConverter.ToUInt32(buffer, 4);
if (cdiHeader.cdiVersion > CDIVersion.CDI_VERSION_3)
cdiHeader.headerOffset = (uint) imageStream.Length - cdiHeader.headerOffset;
return cdiHeader;
}
}
}

View file

@ -0,0 +1,27 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.CDI.CDIImageBuilder
// Assembly: CDI, Version=1.0.1.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: B71D3BB5-2FC4-43C2-853E-907E3A458120
// Assembly location: Formats\CDI.dll
using SEGATools.DiscFileSystem;
using System.IO;
namespace GDRomExplorer.ImageFileFormat.CDI
{
public class CDIImageBuilder : IDiscFileSystemConverter
{
public IDiscFileSystem ToDiscFileSystem(string imageFileName)
{
CDIHeader cdiHeader;
using (FileStream fileStream = File.Open(imageFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
cdiHeader = CDIHeaderConverter.ToCDIHeader((Stream) fileStream);
if (cdiHeader.cdiVersion == CDIVersion.CDI_VERSION_UNKNOWN)
throw new DiscFormatException(string.Format("Unsupported CDI version 0x{0:X}", (object) cdiHeader.rawCdiVersion));
CDIToc cdiToc = (CDIToc) null;
using (FileStream fileStream = File.Open(imageFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
cdiToc = CDITocConverter.ToCdiToc(cdiHeader, (Stream) fileStream, imageFileName);
return (IDiscFileSystem) new SEGATools.DiscFileSystem.DiscFileSystem(imageFileName, cdiToc.sessions, true, false);
}
}
}

View file

@ -0,0 +1,26 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.CDI.CDIImageFormat
// Assembly: CDI, Version=1.0.1.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: B71D3BB5-2FC4-43C2-853E-907E3A458120
// Assembly location: Formats\CDI.dll
using SEGATools.DiscFileSystem;
using SEGATools.FileFormat;
namespace GDRomExplorer.ImageFileFormat.CDI
{
internal class CDIImageFormat : AbstractImageFileFormat
{
public override string[] FileExtentions => new string[1]
{
".cdi"
};
public override string[] FileExtentionDescriptions => new string[1]
{
"DiscJuggler image file"
};
public override IDiscFileSystemConverter ImageFileConverter => (IDiscFileSystemConverter) new CDIImageBuilder();
}
}

25
Formats/CDI/CDIToc.cs Normal file
View file

@ -0,0 +1,25 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.CDI.CDIToc
// Assembly: CDI, Version=1.0.1.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: B71D3BB5-2FC4-43C2-853E-907E3A458120
// Assembly location: Formats\CDI.dll
using SEGATools.DiscFileSystem;
using System.Collections.Generic;
namespace GDRomExplorer.ImageFileFormat.CDI
{
internal class CDIToc
{
internal CDIHeader cdiHeader;
internal ushort numberOfSessions;
internal ushort[] numberOfTracks;
internal List<IDiscSession> sessions;
internal CDIToc(CDIHeader cdiHeader)
{
this.cdiHeader = cdiHeader;
this.sessions = new List<IDiscSession>();
}
}
}

View file

@ -0,0 +1,245 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.CDI.CDITocConverter
// Assembly: CDI, Version=1.0.1.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: B71D3BB5-2FC4-43C2-853E-907E3A458120
// Assembly location: Formats\CDI.dll
using ImageReader.DiscSectors;
using SEGATools;
using SEGATools.DiscFileSystem;
using System;
using System.Collections.Generic;
using System.IO;
namespace GDRomExplorer.ImageFileFormat.CDI
{
internal class CDITocConverter
{
private static readonly Logger.ILog logger = Logger.CreateLog();
private static readonly int NUMBER_OF_SESSIONS_OFFSET = 0;
private static readonly int TRACK_INFO_LENGTH = 58;
private static readonly int TRACK_INFO_TRACK_PREGAP_OFFSET = 0;
private static readonly int TRACK_INFO_TRACK_LENGTH_OFFSET = 4;
private static readonly int TRACK_INFO_TRACK_MODE_OFFSET = 14;
private static readonly int TRACK_INFO_TRACK_LBA_OFFSET = 30;
private static readonly int TRACK_INFO_TRACK_TOTAL_LENGTH_OFFSET = 34;
private static readonly int TRACK_INFO_TRACK_SECTOR_SIZE_OFFSET = 54;
private static readonly byte[] TRACK_START_MARKER = new byte[10]
{
(byte) 0,
(byte) 0,
(byte) 1,
(byte) 0,
(byte) 0,
(byte) 0,
byte.MaxValue,
byte.MaxValue,
byte.MaxValue,
byte.MaxValue
};
private static readonly byte[] TRACK_END_MARKER = new byte[5]
{
(byte) 0,
byte.MaxValue,
byte.MaxValue,
byte.MaxValue,
byte.MaxValue
};
internal static CDIToc ToCdiToc(
CDIHeader cdiHeader,
Stream imageStream,
string imageFileName)
{
CDIToc cdiToc = new CDIToc(cdiHeader);
imageStream.Seek((long) cdiHeader.headerOffset, SeekOrigin.Begin);
cdiToc.numberOfSessions = CDITocConverter.ReadNumberOfSessions(imageStream);
cdiToc.numberOfTracks = new ushort[(int) cdiToc.numberOfSessions];
ushort num1 = 0;
uint startOffset = 0;
for (; imageStream.Position < imageStream.Length && (int) num1 < (int) cdiToc.numberOfSessions; ++num1)
{
cdiToc.numberOfTracks[(int) num1] = CDITocConverter.ReadNumberOfTracks(imageStream);
ushort trackIndex = 0;
List<IDiscTrack> tracks = new List<IDiscTrack>();
byte[] buffer = new byte[4];
for (; (int) trackIndex < (int) cdiToc.numberOfTracks[(int) num1]; ++trackIndex)
{
imageStream.Read(buffer, 0, buffer.Length);
if (BitConverter.ToUInt32(buffer, 0) != 0U)
imageStream.Seek(8L, SeekOrigin.Current);
if (!CDITocConverter.HasTrackStartMarkers(imageStream))
throw new DiscFormatException("Invalid start-of-track marker");
imageStream.Seek(4L, SeekOrigin.Current);
int num2 = imageStream.ReadByte();
imageStream.Seek((long) (num2 + 1), SeekOrigin.Current);
imageStream.Seek(10L, SeekOrigin.Current);
imageStream.Read(buffer, 0, buffer.Length);
uint uint32 = BitConverter.ToUInt32(buffer, 0);
if (uint32 != 2U)
throw new DiscFormatException(string.Format("Invalid marker: {0}", (object) uint32));
imageStream.Seek(4L, SeekOrigin.Current);
if (cdiHeader.cdiVersion > CDIVersion.CDI_VERSION_3)
{
imageStream.Read(buffer, 0, buffer.Length);
if (BitConverter.ToUInt32(buffer, 0) == 2147483648U)
imageStream.Seek(8L, SeekOrigin.Current);
}
else
imageStream.Seek(4L, SeekOrigin.Current);
imageStream.Seek(2L, SeekOrigin.Current);
uint totalLength;
DiscTrack discTrack = CDITocConverter.ReadTrackInfo(imageStream, imageFileName, trackIndex, startOffset, out totalLength);
tracks.Add((IDiscTrack) discTrack);
startOffset += totalLength;
imageStream.Seek(25L, SeekOrigin.Current);
imageStream.Seek(4L, SeekOrigin.Current);
if (cdiHeader.cdiVersion > CDIVersion.CDI_VERSION_2)
{
if (!CDITocConverter.CheckTrackEndMarkers(imageStream))
throw new DiscFormatException("Invalid end-of-track marker");
imageStream.Read(buffer, 0, buffer.Length);
if (BitConverter.ToUInt32(buffer, 0) == uint.MaxValue)
imageStream.Seek(78L, SeekOrigin.Current);
}
}
if (tracks.Count > 0)
cdiToc.sessions.Add((IDiscSession) new DiscSession((int) num1 + 1, string.Format(DiscSession.DEFAULT_SESSION_NAME_WITH_FORMAT, (object) ((int) num1 + 1)), tracks));
imageStream.Seek(12L, SeekOrigin.Current);
if (cdiHeader.cdiVersion > CDIVersion.CDI_VERSION_2)
imageStream.Seek(1L, SeekOrigin.Current);
}
return cdiToc;
}
private static ushort ReadNumberOfSessions(Stream imageStream)
{
byte[] buffer = new byte[2];
imageStream.Read(buffer, 0, buffer.Length);
return BitConverter.ToUInt16(buffer, CDITocConverter.NUMBER_OF_SESSIONS_OFFSET);
}
private static ushort ReadNumberOfTracks(Stream imageStream)
{
byte[] buffer = new byte[2];
imageStream.Read(buffer, 0, buffer.Length);
ushort uint16 = BitConverter.ToUInt16(buffer, 0);
return uint16 <= (ushort) 99 ? uint16 : throw new DiscFormatException(string.Format("Too many tracks: maximum is 99, got {0}", (object) uint16));
}
private static DiscTrack ReadTrackInfo(
Stream imageStream,
string imageFileName,
ushort trackIndex,
uint startOffset,
out uint totalLength)
{
byte[] buffer1 = new byte[CDITocConverter.TRACK_INFO_LENGTH];
imageStream.Read(buffer1, 0, buffer1.Length);
uint uint32_1 = BitConverter.ToUInt32(buffer1, CDITocConverter.TRACK_INFO_TRACK_PREGAP_OFFSET);
uint uint32_2 = BitConverter.ToUInt32(buffer1, CDITocConverter.TRACK_INFO_TRACK_LENGTH_OFFSET);
uint uint32_3 = BitConverter.ToUInt32(buffer1, CDITocConverter.TRACK_INFO_TRACK_MODE_OFFSET);
uint uint32_4 = BitConverter.ToUInt32(buffer1, CDITocConverter.TRACK_INFO_TRACK_LBA_OFFSET);
uint uint32_5 = BitConverter.ToUInt32(buffer1, CDITocConverter.TRACK_INFO_TRACK_TOTAL_LENGTH_OFFSET);
uint uint32_6 = BitConverter.ToUInt32(buffer1, CDITocConverter.TRACK_INFO_TRACK_SECTOR_SIZE_OFFSET);
if ((int) uint32_1 + (int) uint32_2 != (int) uint32_5)
throw new DiscFormatException(string.Format("Truncated track {0}: expected {1} bytes, got {2} bytes", (object) ((int) trackIndex + 1), (object) uint32_5, (object) (uint) ((int) uint32_1 + (int) uint32_2)));
uint trackSectorSize = CDITocConverter.GetTrackSectorSize(uint32_6);
uint num = startOffset + uint32_1 * trackSectorSize;
totalLength = uint32_5 * trackSectorSize;
TrackModeType trackModeType = CDITocConverter.ValidateTrackMode(uint32_3);
IDiscSector trackSector = (IDiscSector) null;
try
{
using (FileStream fileStream = File.Open(imageFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
{
byte[] buffer2 = new byte[DiscSectorCommon.RawSectorSize];
fileStream.Seek((long) num, SeekOrigin.Begin);
fileStream.Read(buffer2, 0, buffer2.Length);
trackSector = CDITocConverter.ValidateTrackSector(trackSectorSize, trackModeType, buffer2);
}
}
catch (Exception ex)
{
logger.Error(ex);
throw new DiscFormatException(string.Format("Unable to read the track {0} of the file {1}", (object) ((int) trackIndex + 1), (object) imageFileName));
}
return new DiscTrack(imageFileName, (long) (int) num, (long) (uint32_2 * trackSectorSize), uint32_4, (int) trackIndex + 1, trackModeType, trackSector);
}
private static TrackModeType ValidateTrackMode(uint trackMode)
{
switch (trackMode)
{
case 0:
return TrackModeType.Audio;
case 2:
return TrackModeType.Data;
default:
throw new DiscFormatException(string.Format("Invalid track mode: {0:X}", (object) trackMode));
}
}
private static uint GetTrackSectorSize(uint trackSectorType)
{
switch (trackSectorType)
{
case 0:
return 2048;
case 1:
return 2336;
case 2:
return 2352;
default:
throw new DiscFormatException(string.Format("Invalid track sector: {0:X}", (object) trackSectorType));
}
}
private static IDiscSector ValidateTrackSector(
uint trackSector,
TrackModeType trackModeType,
byte[] buffer)
{
switch (trackSector)
{
case 2048:
return (IDiscSector) new ISO9660Sector();
case 2336:
return (IDiscSector) new CDROMXAMode2Form1Sector();
case 2352:
if (trackModeType == TrackModeType.Audio)
return (IDiscSector) new RawSector();
return CDROMFrameHeaderConverter.ToCDROMFrameHeader(buffer, 0) == CDROMDataModeType.MODE1_RAW ? (IDiscSector) new CDROMMode1RawSector() : (IDiscSector) new CDROMXAMode2Form1RawSector();
default:
throw new DiscFormatException(string.Format("Invalid track sector size: {0:X}", (object) trackSector));
}
}
private static bool HasTrackStartMarkers(Stream imageStream)
{
byte[] buffer = new byte[CDITocConverter.TRACK_START_MARKER.Length];
for (ushort index1 = 0; index1 < (ushort) 2; ++index1)
{
imageStream.Read(buffer, 0, buffer.Length);
for (ushort index2 = 0; (int) index2 < buffer.Length; ++index2)
{
if ((int) buffer[(int) index2] != (int) CDITocConverter.TRACK_START_MARKER[(int) index2])
return false;
}
}
return true;
}
private static bool CheckTrackEndMarkers(Stream imageStream)
{
byte[] buffer = new byte[CDITocConverter.TRACK_END_MARKER.Length];
imageStream.Read(buffer, 0, buffer.Length);
for (ushort index = 0; (int) index < buffer.Length; ++index)
{
if ((int) buffer[(int) index] != (int) CDITocConverter.TRACK_END_MARKER[(int) index])
return false;
}
return true;
}
}
}

16
Formats/CDI/CDIVersion.cs Normal file
View file

@ -0,0 +1,16 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.CDI.CDIVersion
// Assembly: CDI, Version=1.0.1.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: B71D3BB5-2FC4-43C2-853E-907E3A458120
// Assembly location: Formats\CDI.dll
namespace GDRomExplorer.ImageFileFormat.CDI
{
internal enum CDIVersion : uint
{
CDI_VERSION_UNKNOWN = 0,
CDI_VERSION_2 = 2147483652, // 0x80000004
CDI_VERSION_3 = 2147483653, // 0x80000005
CDI_VERSION_35 = 2147483654, // 0x80000006
}
}

View file

@ -0,0 +1,14 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("2014 - 2016")]
[assembly: AssemblyTitle("GD-ROM Explorer GDI File Format")]
[assembly: AssemblyDescription("GDI File Format Plugin")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Japanese Cake")]
[assembly: AssemblyProduct("GD-ROM Explorer - GDI File Format Plugin")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(true)]
[assembly: Guid("d7bec06d-acf2-4d01-a319-8978bb4c951a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]

67
Formats/GDI/GDI.csproj Normal file
View file

@ -0,0 +1,67 @@
<?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\Formats\GDI.dll-->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F2CB9EB0-0934-48B0-952F-8BFC5DC97BAA}</ProjectGuid>
<OutputType>Library</OutputType>
<AssemblyName>GDI</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ApplicationVersion>1.0.0.0</ApplicationVersion>
<FileAlignment>512</FileAlignment>
<RootNamespace>GDRomExplorer.ImageFileFormat.GDI</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\Formats\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\Release\Formats\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="IGDIFileSystemValidator.cs" />
<Compile Include="GDIFileSystemValidator.cs" />
<Compile Include="GDImageBuilder.cs" />
<Compile Include="GDImageFormat.cs" />
<Compile Include="IInitialProgramProvider.cs" />
<Compile Include="InitialProgramProvider.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ImageReader\ImageReader.csproj">
<Project>{2185f55e-a4da-486f-acc8-3ee955205ce4}</Project>
<Name>ImageReader</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\SEGATools\SEGATools.csproj">
<Project>{4d3ab913-88d2-4dd1-a403-ea46d14c98e6}</Project>
<Name>SEGATools</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,111 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.GDI.GDIFileSystemValidator
// Assembly: GDI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: F4295E7C-8421-4324-B5B1-F38932DD6235
// Assembly location: Formats\GDI.dll
using SEGATools.DiscFileSystem;
using SEGATools.Security;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace GDRomExplorer.ImageFileFormat.GDI
{
internal class GDIFileSystemValidator : IGDIFileSystemValidator
{
private static readonly int TRACK_MINIMUM_SIZE_IN_SECTORS = 300;
private IInitialProgramProvider IpProvider;
public GDIFileSystemValidator(IInitialProgramProvider IpProvider) => this.IpProvider = IpProvider;
public void CheckDiscFileSystem(IDiscFileSystem disc)
{
IDiscSession session1 = disc.Sessions[0];
IDiscSession session2 = disc.Sessions[1];
InitialProgram initialProgram = this.IpProvider.GetInitialProgram(session2.FirstDataTrack);
this.CheckInitialProgramAndHighDensityTracksMatch(initialProgram, session2);
this.CheckInitialProgramAndHighDensitySizesMatch(initialProgram, session2);
List<IDiscTrack> list = session1.Tracks.Concat<IDiscTrack>((IEnumerable<IDiscTrack>) session2.Tracks).ToList<IDiscTrack>();
this.CheckTrackIndexesAreConsecutive((IList<IDiscTrack>) list);
this.CheckTrackGapAndOverlap((IList<IDiscTrack>) list);
}
public void CheckDiscTrackSize(IDiscTrack track)
{
if (track.Length % (long) track.TrackSector.Size != 0L || track.Length / (long) track.TrackSector.Size < (long) GDIFileSystemValidator.TRACK_MINIMUM_SIZE_IN_SECTORS)
throw new DiscFormatException(string.Format("Invalid track size: {0} must be at least {1} bytes long and its size must a multiple of {2}.", (object) Path.GetFileName(track.FileName), (object) GDIFileSystemValidator.TRACK_MINIMUM_SIZE_IN_SECTORS, (object) track.TrackSector.Size));
}
private void CheckTrackIndexesAreConsecutive(IList<IDiscTrack> tracks)
{
IDiscTrack discTrack = (IDiscTrack) null;
foreach (IDiscTrack track in (IEnumerable<IDiscTrack>) tracks)
{
if (discTrack != null && discTrack.Index + 1 != track.Index)
throw new DiscFormatException(string.Format("Track indexes are not consecutive: track with index {0} is missing", (object) track.Index));
discTrack = track;
}
}
private void CheckTrackGapAndOverlap(IList<IDiscTrack> tracks)
{
IDiscTrack discTrack = (IDiscTrack) null;
foreach (IDiscTrack track in (IEnumerable<IDiscTrack>) tracks)
{
if (discTrack != null)
{
long num1 = (long) discTrack.LogicalBlockAddress + discTrack.Length / (long) discTrack.TrackSector.Size - 1L;
int num2 = discTrack.TrackData != track.TrackData ? 150 : 0;
if (this.AreTracksOverlapping(num1 + (long) num2, (long) track.LogicalBlockAddress))
throw new DiscFormatException(string.Format("Tracks overlap detected: track {0} overlaps track {1}", (object) Path.GetFileName(discTrack.FileName), (object) Path.GetFileName(track.FileName)));
if (discTrack.Session == track.Session && !this.AreTracksContinuous(num1 + (long) num2, (long) track.LogicalBlockAddress))
throw new DiscFormatException(string.Format("Gap between tracks: tracks {0} and {1} are not continuous", (object) Path.GetFileName(discTrack.FileName), (object) Path.GetFileName(track.FileName)));
}
discTrack = track;
}
}
private void CheckInitialProgramAndHighDensityTracksMatch(
InitialProgram initialProgram,
IDiscSession highDensity)
{
this.CheckInitialProgramAndHighDensityTrackCountsMatch(initialProgram, highDensity);
for (int index = 0; index < initialProgram.TableOfContent.Tracks.Count; ++index)
{
InitialProgramTrackInfo track1 = initialProgram.TableOfContent.Tracks[index];
IDiscTrack track2 = highDensity.Tracks[index];
long track2size = track2.Length / (long)track2.TrackSector.Size;
if (track2size != (long) track1.Size)
throw new DiscFormatException(string.Format("Invalid track size: {0} must be {1} sectors long", (object) track2, (object) track1.Size));
}
}
private void CheckInitialProgramAndHighDensitySizesMatch(
InitialProgram initialProgram,
IDiscSession highDensity)
{
long num1 = 0;
foreach (IDiscTrack track in highDensity.Tracks)
num1 += track.Length / (long) track.TrackSector.Size;
long num2 = initialProgram.TableOfContent.Tracks.Sum<InitialProgramTrackInfo>((Func<InitialProgramTrackInfo, long>) (track => (long) track.Size));
if (num1 != num2)
throw new DiscFormatException(string.Format("Invalid session size: the high density session must be {0} sectors long", (object) num2));
}
private void CheckInitialProgramAndHighDensityTrackCountsMatch(
InitialProgram initialProgram,
IDiscSession highDensity)
{
if (initialProgram.TableOfContent == null)
throw new DiscFormatException("Invalid boot sector: the boot sector does not contain a valid TOC");
if (initialProgram.TableOfContent.Tracks.Count != highDensity.Tracks.Count)
throw new DiscFormatException(string.Format("Invalid number of tracks: the boot sector indicates {0} tracks whereas the {1} contains {2}", (object) initialProgram.TableOfContent.Tracks.Count, (object) highDensity.Name, (object) highDensity.Tracks.Count));
}
private bool AreTracksOverlapping(long firstTrackEndLBA, long secondTrackStartLBA) => firstTrackEndLBA >= secondTrackStartLBA;
private bool AreTracksContinuous(long firstTrackEndLBA, long secondTrackStartLBA) => firstTrackEndLBA + 1L == secondTrackStartLBA;
}
}

View file

@ -0,0 +1,117 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.GDI.GDImageBuilder
// Assembly: GDI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: F4295E7C-8421-4324-B5B1-F38932DD6235
// Assembly location: Formats\GDI.dll
using ImageReader.DiscSectors;
using SEGATools.DiscFileSystem;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
namespace GDRomExplorer.ImageFileFormat.GDI
{
public class GDImageBuilder : IDiscFileSystemConverter
{
private static readonly Regex gdiRegex = new Regex("^(?<index>[1-9]|[1-9][0-9]?)[ \\t]+(?<lba>[0-9]{1,6}?)[ \\t]+(?<type>0|4?)[ \\t]+(?<mode>2352|2048?)[ \\t]+(?<filename>\".+\\.\\S{1,4}\"|\\S+\\.\\S{1,4}?)[ \\t]+(?<offset>[+-]*[0-9]{1,6}?)[ \\t]*$", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant);
private static readonly string FIRST_SESSION_NAME = "Single Density";
private static readonly string SECOND_SESSION_NAME = "High Density";
private static readonly int HIGH_DENSITY_START_LBA = 45000;
private static readonly bool SUPPORT_DATA_EXTRACTION = true;
private static readonly bool SUPPORT_CUE_EXPORT = true;
private static readonly bool SUPPORT_GDI_EXPORT = true;
protected IGDIFileSystemValidator Validator;
protected IInitialProgramProvider IpProvider;
public GDImageBuilder()
{
this.IpProvider = (IInitialProgramProvider) new InitialProgramProvider();
this.Validator = (IGDIFileSystemValidator) new GDIFileSystemValidator(this.IpProvider);
}
public IDiscFileSystem ToDiscFileSystem(string imageFileName)
{
short result1 = 0;
short num1 = 0;
List<IDiscTrack> tracks1 = new List<IDiscTrack>();
List<IDiscTrack> tracks2 = new List<IDiscTrack>();
short num2 = 1;
using (StreamReader streamReader = new StreamReader(imageFileName))
{
if (!short.TryParse(streamReader.ReadLine().Trim(), out result1))
throw new DiscFormatException(string.Format("Wrong track index at line {0}", (object) num2));
short num3 = (short) ((int) num2 + 1);
if (result1 > (short) 99)
throw new DiscFormatException(string.Format("Too many tracks: maximum is 99, got {0}", (object) result1));
while (!streamReader.EndOfStream)
{
string input = streamReader.ReadLine().Trim();
if (string.IsNullOrEmpty(input))
{
++num3;
}
else
{
Match match = GDImageBuilder.gdiRegex.Match(input);
if (!match.Success)
throw new DiscFormatException(string.Format("Unable to parse track at line {0}", (object) num3));
TrackModeType trackData;
if (match.Groups["type"].Value == "4")
{
trackData = TrackModeType.Data;
}
else
{
if (!(match.Groups["type"].Value == "0"))
throw new DiscFormatException(string.Format("Wrong track type: got {0} whereas 0 for audio or 4 for data was expected", (object) match.Groups["type"].Value));
trackData = TrackModeType.Audio;
}
IDiscSector trackSector;
if (match.Groups["mode"].Value == "2352")
{
trackSector = trackData != TrackModeType.Data ? (IDiscSector) new RawSector() : (IDiscSector) new CDROMMode1RawSector();
}
else
{
if (!(match.Groups["mode"].Value == "2048"))
throw new DiscFormatException(string.Format("Wrong track mode: got {0} whereas 2352 or 2048 was expected", (object) match.Groups["mode"].Value));
trackSector = (IDiscSector) new ISO9660Sector();
}
int result2;
if (!int.TryParse(match.Groups["index"].Value, out result2))
throw new DiscFormatException(string.Format("Wrong track index: {0}", (object) match.Groups["index"].Value));
uint result3;
if (!uint.TryParse(match.Groups["lba"].Value, out result3))
throw new DiscFormatException(string.Format("Wrong logical block address: {0}", (object) match.Groups["lba"].Value));
int result4;
if (!int.TryParse(match.Groups["offset"].Value, out result4))
throw new DiscFormatException(string.Format("Wrong offset: {0}", (object) match.Groups["offset"].Value));
string str = match.Groups["filename"].Value.Trim().Replace("\"", "");
if (!Path.IsPathRooted(str))
str = Path.Combine(Path.GetDirectoryName(imageFileName), str);
FileInfo fileInfo = File.Exists(str) ? new FileInfo(str) : throw new DiscFormatException(string.Format("File missing: {0}", (object) str));
IDiscTrack track = (IDiscTrack) new DiscTrack(str, (long) result4, fileInfo.Length, result3, result2, trackData, trackSector);
this.Validator.CheckDiscTrackSize(track);
if ((long) track.LogicalBlockAddress < (long) GDImageBuilder.HIGH_DENSITY_START_LBA)
tracks1.Add(track);
else
tracks2.Add(track);
++num1;
++num3;
}
}
if ((int) result1 != (int) num1)
throw new DiscFormatException(string.Format("Number of tracks doesn't match: expected {0}, got {1}", (object) result1, (object) num1));
}
List<IDiscSession> sessions = new List<IDiscSession>()
{
(IDiscSession) new DiscSession(1, GDImageBuilder.FIRST_SESSION_NAME, tracks1),
(IDiscSession) new DiscSession(2, GDImageBuilder.SECOND_SESSION_NAME, tracks2)
};
SEGATools.DiscFileSystem.DiscFileSystem discFileSystem = new SEGATools.DiscFileSystem.DiscFileSystem(imageFileName, sessions, GDImageBuilder.SUPPORT_DATA_EXTRACTION, GDImageBuilder.SUPPORT_CUE_EXPORT, GDImageBuilder.SUPPORT_GDI_EXPORT);
this.Validator.CheckDiscFileSystem((IDiscFileSystem) discFileSystem);
return (IDiscFileSystem) discFileSystem;
}
}
}

View file

@ -0,0 +1,26 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.GDI.GDImageFormat
// Assembly: GDI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: F4295E7C-8421-4324-B5B1-F38932DD6235
// Assembly location: Formats\GDI.dll
using SEGATools.DiscFileSystem;
using SEGATools.FileFormat;
namespace GDRomExplorer.ImageFileFormat.GDI
{
internal class GDImageFormat : AbstractImageFileFormat
{
public override string[] FileExtentions => new string[1]
{
".gdi"
};
public override string[] FileExtentionDescriptions => new string[1]
{
"GDROM image file"
};
public override IDiscFileSystemConverter ImageFileConverter => (IDiscFileSystemConverter) new GDImageBuilder();
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.GDI.IGDIFileSystemValidator
// Assembly: GDI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: F4295E7C-8421-4324-B5B1-F38932DD6235
// Assembly location: Formats\GDI.dll
using SEGATools.DiscFileSystem;
namespace GDRomExplorer.ImageFileFormat.GDI
{
public interface IGDIFileSystemValidator
{
void CheckDiscTrackSize(IDiscTrack track);
void CheckDiscFileSystem(IDiscFileSystem disc);
}
}

View file

@ -0,0 +1,16 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.GDI.IInitialProgramProvider
// Assembly: GDI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: F4295E7C-8421-4324-B5B1-F38932DD6235
// Assembly location: Formats\GDI.dll
using SEGATools.DiscFileSystem;
using SEGATools.Security;
namespace GDRomExplorer.ImageFileFormat.GDI
{
public interface IInitialProgramProvider
{
InitialProgram GetInitialProgram(IDiscTrack track);
}
}

View file

@ -0,0 +1,34 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.GDI.InitialProgramProvider
// Assembly: GDI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: F4295E7C-8421-4324-B5B1-F38932DD6235
// Assembly location: Formats\GDI.dll
using ImageReader.Stream;
using SEGATools.DiscFileSystem;
using SEGATools.Security;
using System;
namespace GDRomExplorer.ImageFileFormat.GDI
{
public class InitialProgramProvider : IInitialProgramProvider
{
public InitialProgram GetInitialProgram(IDiscTrack track)
{
try
{
byte[] buffer;
using (DiscSectorStream discSectorStream = new DiscSectorStream(track.FileInputStream, track.TrackSector))
{
buffer = new byte[(int) InitialProgram.IP_FILESIZE];
discSectorStream.Read(buffer, 0, buffer.Length);
}
return InitialProgramConverter.ToInitialProgram(buffer, 0);
}
catch (Exception ex)
{
throw new DiscFormatException(string.Format("Invalid boot sector: {0} does not contain a valid boot sector (IP)", (object) track), ex);
}
}
}
}

View file

@ -0,0 +1,14 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("GD-ROM Explorer ISO9660 File Format")]
[assembly: AssemblyDescription("ISO9660 File Format Plugin")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Japanese Cake")]
[assembly: AssemblyProduct("GD-ROM Explorer - ISO9660 File Format Plugin")]
[assembly: AssemblyCopyright("2014 - 2016")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(true)]
[assembly: Guid("f024f756-98ed-4ffa-b06b-baf386b755a5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]

View file

@ -0,0 +1,58 @@
<?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\Formats\ISO9660.dll-->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A0814BED-4F13-4C76-AAE6-BAA35F9EEB49}</ProjectGuid>
<OutputType>Library</OutputType>
<AssemblyName>ISO9660</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ApplicationVersion>1.0.0.0</ApplicationVersion>
<FileAlignment>512</FileAlignment>
<RootNamespace>GDRomExplorer.ImageFileFormat.ISO9660</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\Formats\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\Release\Formats\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Compile Include="ISO9660ImageFormat.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ImageReader\ImageReader.csproj">
<Project>{2185f55e-a4da-486f-acc8-3ee955205ce4}</Project>
<Name>ImageReader</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\SEGATools\SEGATools.csproj">
<Project>{4d3ab913-88d2-4dd1-a403-ea46d14c98e6}</Project>
<Name>SEGATools</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,27 @@
// Decompiled with JetBrains decompiler
// Type: GDRomExplorer.ImageFileFormat.ISO9660.ISO9660ImageFormat
// Assembly: ISO9660, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: 05C13092-F2D8-4D43-9750-90851EBE12FD
// Assembly location: Formats\ISO9660.dll
using ImageReader.DiscSectors;
using SEGATools.DiscFileSystem;
using SEGATools.FileFormat;
namespace GDRomExplorer.ImageFileFormat.ISO9660
{
internal class ISO9660ImageFormat : AbstractImageFileFormat
{
public override string[] FileExtentions => new string[1]
{
".iso"
};
public override string[] FileExtentionDescriptions => new string[1]
{
"ISO9660 image file"
};
public override IDiscFileSystemConverter ImageFileConverter => (IDiscFileSystemConverter) new GenericImageConverter((IDiscSector) new ISO9660Sector());
}
}