initial commit
This commit is contained in:
commit
1b60743303
274 changed files with 25866 additions and 0 deletions
14
Formats/CDI/AssemblyInfo.cs
Normal file
14
Formats/CDI/AssemblyInfo.cs
Normal 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
64
Formats/CDI/CDI.csproj
Normal 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
20
Formats/CDI/CDI.sln
Normal 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
15
Formats/CDI/CDIHeader.cs
Normal 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;
|
||||
}
|
||||
}
|
35
Formats/CDI/CDIHeaderConverter.cs
Normal file
35
Formats/CDI/CDIHeaderConverter.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
27
Formats/CDI/CDIImageBuilder.cs
Normal file
27
Formats/CDI/CDIImageBuilder.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
26
Formats/CDI/CDIImageFormat.cs
Normal file
26
Formats/CDI/CDIImageFormat.cs
Normal 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
25
Formats/CDI/CDIToc.cs
Normal 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>();
|
||||
}
|
||||
}
|
||||
}
|
245
Formats/CDI/CDITocConverter.cs
Normal file
245
Formats/CDI/CDITocConverter.cs
Normal 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
16
Formats/CDI/CDIVersion.cs
Normal 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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue