2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-08-17 01:32:20 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : BlindWrite4.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
2016-08-17 01:33:48 +01:00
|
|
|
// Component : Disc image plugins.
|
2016-08-17 01:32:20 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-08-17 01:33:48 +01:00
|
|
|
// Manages BlindWrite 4 disc images.
|
2016-08-17 01:32:20 +01:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2016-08-17 01:32:20 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2017-12-19 19:33:46 +00:00
|
|
|
using System.Globalization;
|
2016-08-17 01:32:20 +01:00
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2017-12-19 19:33:46 +00:00
|
|
|
using System.Runtime.InteropServices;
|
2016-08-17 01:32:20 +01:00
|
|
|
using System.Text;
|
2017-12-21 14:30:38 +00:00
|
|
|
using DiscImageChef.Checksums;
|
2017-12-19 19:33:46 +00:00
|
|
|
using DiscImageChef.CommonTypes;
|
2016-08-17 01:32:20 +01:00
|
|
|
using DiscImageChef.Console;
|
2016-09-05 17:37:31 +01:00
|
|
|
using DiscImageChef.Filters;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
namespace DiscImageChef.DiscImages
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2018-01-08 20:37:27 +00:00
|
|
|
// TODO: Too many unknowns, plus a completely unknown footer, to make this writable
|
2017-12-26 06:05:12 +00:00
|
|
|
public class BlindWrite4 : IMediaImage
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>"BLINDWRITE TOC FILE"</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
readonly byte[] bw4Signature =
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
0x42, 0x4C, 0x49, 0x4E, 0x44, 0x57, 0x52, 0x49, 0x54, 0x45, 0x20, 0x54, 0x4F, 0x43, 0x20, 0x46, 0x49, 0x4C,
|
|
|
|
|
0x45
|
|
|
|
|
};
|
2017-12-24 00:12:31 +00:00
|
|
|
List<Bw4TrackDescriptor> bwTracks;
|
2017-12-26 06:05:12 +00:00
|
|
|
IFilter dataFilter, subFilter;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
Bw4Header header;
|
2017-12-26 06:05:12 +00:00
|
|
|
ImageInfo imageInfo;
|
2017-12-24 00:12:31 +00:00
|
|
|
Stream imageStream;
|
2016-08-17 01:32:20 +01:00
|
|
|
Dictionary<uint, ulong> offsetmap;
|
|
|
|
|
List<Partition> partitions;
|
|
|
|
|
List<Session> sessions;
|
|
|
|
|
Dictionary<uint, byte> trackFlags;
|
2017-12-24 00:12:31 +00:00
|
|
|
List<Track> tracks;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
public BlindWrite4()
|
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo = new ImageInfo
|
2017-12-22 06:55:04 +00:00
|
|
|
{
|
|
|
|
|
ReadableSectorTags = new List<SectorTagType>(),
|
|
|
|
|
ReadableMediaTags = new List<MediaTagType>(),
|
2017-12-26 02:51:10 +00:00
|
|
|
HasPartitions = true,
|
|
|
|
|
HasSessions = true,
|
|
|
|
|
Version = null,
|
|
|
|
|
ApplicationVersion = null,
|
|
|
|
|
MediaTitle = null,
|
|
|
|
|
Creator = null,
|
2017-12-22 06:55:04 +00:00
|
|
|
MediaManufacturer = null,
|
|
|
|
|
MediaModel = null,
|
|
|
|
|
MediaPartNumber = null,
|
|
|
|
|
MediaSequence = 0,
|
|
|
|
|
LastMediaSequence = 0,
|
|
|
|
|
DriveManufacturer = null,
|
|
|
|
|
DriveModel = null,
|
|
|
|
|
DriveSerialNumber = null,
|
|
|
|
|
DriveFirmwareRevision = null
|
|
|
|
|
};
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public ImageInfo Info => imageInfo;
|
2017-12-26 02:51:10 +00:00
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public string Name => "BlindWrite 4";
|
|
|
|
|
public Guid Id => new Guid("664568B2-15D4-4E64-8A7A-20BDA8B8386F");
|
2017-12-26 02:51:10 +00:00
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
public string Format => "BlindWrite 4 TOC file";
|
2017-12-26 02:51:10 +00:00
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Partition> Partitions => partitions;
|
2017-12-26 02:51:10 +00:00
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Track> Tracks => tracks;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Session> Sessions => sessions;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
public bool Identify(IFilter imageFilter)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
2016-08-17 01:32:20 +01:00
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
2017-12-19 20:33:03 +00:00
|
|
|
if(stream.Length < 19) return false;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
byte[] signature = new byte[19];
|
|
|
|
|
stream.Read(signature, 0, 19);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
return bw4Signature.SequenceEqual(signature);
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
public bool Open(IFilter imageFilter)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
2016-08-17 01:32:20 +01:00
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
2017-12-19 20:33:03 +00:00
|
|
|
if(stream.Length < 19) return false;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
byte[] tmpArray = new byte[19];
|
|
|
|
|
byte[] tmpUShort = new byte[2];
|
|
|
|
|
byte[] tmpUInt = new byte[4];
|
|
|
|
|
byte[] tmpULong = new byte[8];
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpArray, 0, 19);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!bw4Signature.SequenceEqual(tmpArray)) return false;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
header = new Bw4Header {Signature = tmpArray};
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
// Seems to always be 2
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.Unknown1 = BitConverter.ToUInt32(tmpUInt, 0);
|
2016-08-17 01:32:20 +01:00
|
|
|
// Seems to be a timetamp
|
|
|
|
|
stream.Read(tmpULong, 0, 8);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.Timestamp = BitConverter.ToUInt64(tmpULong, 0);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.VolumeIdLength = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[header.VolumeIdLength];
|
2016-08-17 01:32:20 +01:00
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.VolumeIdBytes = tmpArray;
|
|
|
|
|
header.VolumeIdentifier = StringHandlers.CToString(header.VolumeIdBytes, Encoding.Default);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.SysIdLength = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[header.SysIdLength];
|
2016-08-17 01:32:20 +01:00
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.SysIdBytes = tmpArray;
|
|
|
|
|
header.SystemIdentifier = StringHandlers.CToString(header.SysIdBytes, Encoding.Default);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.CommentsLength = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[header.CommentsLength];
|
2016-08-17 01:32:20 +01:00
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.CommentsBytes = tmpArray;
|
|
|
|
|
header.Comments = StringHandlers.CToString(header.CommentsBytes, Encoding.Default);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.TrackDescriptors = BitConverter.ToUInt32(tmpUInt, 0);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.DataFileLength = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[header.DataFileLength];
|
2016-08-17 01:32:20 +01:00
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.DataFileBytes = tmpArray;
|
|
|
|
|
header.DataFile = StringHandlers.CToString(header.DataFileBytes, Encoding.Default);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.SubchannelFileLength = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[header.SubchannelFileLength];
|
2016-08-17 01:32:20 +01:00
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.SubchannelFileBytes = tmpArray;
|
|
|
|
|
header.SubchannelFile = StringHandlers.CToString(header.SubchannelFileBytes, Encoding.Default);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
header.Unknown2 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
header.Unknown3 = (byte)stream.ReadByte();
|
|
|
|
|
tmpArray = new byte[header.Unknown3];
|
|
|
|
|
stream.Read(tmpArray, 0, header.Unknown3);
|
|
|
|
|
header.Unknown4 = tmpArray;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.signature = {0}",
|
2017-12-20 17:15:26 +00:00
|
|
|
StringHandlers.CToString(header.Signature));
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown1 = {0}", header.Unknown1);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.timestamp = {0}", header.Timestamp);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.volumeIdLength = {0}", header.VolumeIdLength);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.volumeIdentifier = {0}", header.VolumeIdentifier);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.sysIdLength = {0}", header.SysIdLength);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.systemIdentifier = {0}", header.SystemIdentifier);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.commentsLength = {0}", header.CommentsLength);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.comments = {0}", header.Comments);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.trackDescriptors = {0}", header.TrackDescriptors);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.dataFileLength = {0}", header.DataFileLength);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.dataFilter = {0}", header.DataFilter);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.dataFile = {0}", header.DataFile);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.subchannelFileLength = {0}",
|
2017-12-20 17:15:26 +00:00
|
|
|
header.SubchannelFileLength);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.subchannelFilter = {0}", header.SubchannelFilter);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.subchannelFile = {0}", header.SubchannelFile);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown2 = {0}", header.Unknown2);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown3 = {0}", header.Unknown3);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown4.Length = {0}", header.Unknown4.Length);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
bwTracks = new List<Bw4TrackDescriptor>();
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
for(int i = 0; i < header.TrackDescriptors; i++)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "stream.Position = {0}", stream.Position);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
Bw4TrackDescriptor track = new Bw4TrackDescriptor();
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.filenameLen = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.filenameLen];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.filenameBytes = tmpArray;
|
|
|
|
|
track.filename = StringHandlers.CToString(track.filenameBytes, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.offset = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
track.subchannel = (byte)stream.ReadByte();
|
|
|
|
|
|
|
|
|
|
tmpArray = new byte[3];
|
|
|
|
|
stream.Read(tmpArray, 0, 3);
|
|
|
|
|
track.unknown1 = tmpArray;
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unknown2 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
track.unknown3 = (byte)stream.ReadByte();
|
|
|
|
|
track.session = (byte)stream.ReadByte();
|
|
|
|
|
track.unknown4 = (byte)stream.ReadByte();
|
|
|
|
|
track.adrCtl = (byte)stream.ReadByte();
|
|
|
|
|
|
|
|
|
|
track.unknown5 = (byte)stream.ReadByte();
|
2017-12-20 17:15:26 +00:00
|
|
|
track.trackMode = (Bw4TrackType)stream.ReadByte();
|
2016-08-17 01:32:20 +01:00
|
|
|
track.unknown6 = (byte)stream.ReadByte();
|
|
|
|
|
track.point = (byte)stream.ReadByte();
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unknown7 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unknown8 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unknown9 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unknown10 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
stream.Read(tmpUShort, 0, 2);
|
|
|
|
|
track.unknown11 = BitConverter.ToUInt16(tmpUShort, 0);
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.lastSector = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
track.unknown12 = (byte)stream.ReadByte();
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.pregap = BitConverter.ToInt32(tmpUInt, 0);
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.startSector = BitConverter.ToInt32(tmpUInt, 0);
|
|
|
|
|
|
|
|
|
|
track.unknown13 = new uint[2];
|
|
|
|
|
for(int j = 0; j < track.unknown13.Length; j++)
|
|
|
|
|
{
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unknown13[j] = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.titleLen = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.titleLen];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.titleBytes = tmpArray;
|
|
|
|
|
track.title = StringHandlers.CToString(track.titleBytes, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.performerLen = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.performerLen];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.performerBytes = tmpArray;
|
|
|
|
|
track.performer = StringHandlers.CToString(track.performerBytes, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen1 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen1];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes1 = tmpArray;
|
|
|
|
|
track.unkString1 = StringHandlers.CToString(track.unkStrBytes1, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen2 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen2];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes2 = tmpArray;
|
|
|
|
|
track.unkString2 = StringHandlers.CToString(track.unkStrBytes2, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen3 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen3];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes3 = tmpArray;
|
|
|
|
|
track.unkString3 = StringHandlers.CToString(track.unkStrBytes3, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen4 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen4];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes4 = tmpArray;
|
|
|
|
|
track.unkString4 = StringHandlers.CToString(track.unkStrBytes4, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.discIdLen = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.discIdLen];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.discIdBytes = tmpArray;
|
|
|
|
|
track.discId = StringHandlers.CToString(track.discIdBytes, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen5 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen5];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes5 = tmpArray;
|
|
|
|
|
track.unkString5 = StringHandlers.CToString(track.unkStrBytes5, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen6 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen6];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes6 = tmpArray;
|
|
|
|
|
track.unkString6 = StringHandlers.CToString(track.unkStrBytes6, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen7 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen7];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes7 = tmpArray;
|
|
|
|
|
track.unkString7 = StringHandlers.CToString(track.unkStrBytes7, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen8 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen8];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes8 = tmpArray;
|
|
|
|
|
track.unkString8 = StringHandlers.CToString(track.unkStrBytes8, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen9 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen9];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes9 = tmpArray;
|
|
|
|
|
track.unkString9 = StringHandlers.CToString(track.unkStrBytes9, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen10 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen10];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes10 = tmpArray;
|
|
|
|
|
track.unkString10 = StringHandlers.CToString(track.unkStrBytes10, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.unkStrLen11 = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.unkStrLen11];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.unkStrBytes11 = tmpArray;
|
|
|
|
|
track.unkString11 = StringHandlers.CToString(track.unkStrBytes11, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
stream.Read(tmpUInt, 0, 4);
|
|
|
|
|
track.isrcLen = BitConverter.ToUInt32(tmpUInt, 0);
|
|
|
|
|
tmpArray = new byte[track.isrcLen];
|
|
|
|
|
stream.Read(tmpArray, 0, tmpArray.Length);
|
|
|
|
|
track.isrcBytes = tmpArray;
|
|
|
|
|
track.isrcUpc = StringHandlers.CToString(track.isrcBytes, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.filenameLen = {0}", track.filenameLen);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.filename = {0}", track.filename);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.offset = {0}", track.offset);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.subchannel = {0}", track.subchannel);
|
|
|
|
|
for(int j = 0; j < track.unknown1.Length; j++)
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown1[{1}] = 0x{0:X8}", track.unknown1[j],
|
|
|
|
|
j);
|
|
|
|
|
|
2016-08-17 01:32:20 +01:00
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown2 = {0}", track.unknown2);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown3 = {0}", track.unknown3);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.session = {0}", track.session);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown4 = {0}", track.unknown4);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.adrCtl = {0}", track.adrCtl);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown5 = {0}", track.unknown5);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.trackMode = {0}", track.trackMode);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown6 = {0}", track.unknown6);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.point = {0}", track.point);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown7 = {0}", track.unknown7);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown8 = {0}", track.unknown8);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown9 = {0}", track.unknown9);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown10 = {0}", track.unknown10);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown11 = {0}", track.unknown11);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.lastSector = {0}", track.lastSector);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown12 = {0}", track.unknown12);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.pregap = {0}", track.pregap);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.startSector = {0}", track.startSector);
|
|
|
|
|
for(int j = 0; j < track.unknown13.Length; j++)
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown13[{1}] = 0x{0:X8}",
|
|
|
|
|
track.unknown13[j], j);
|
|
|
|
|
|
2016-08-17 01:32:20 +01:00
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.titleLen = {0}", track.titleLen);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.title = {0}", track.title);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.performerLen = {0}", track.performerLen);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.performer = {0}", track.performer);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen1 = {0}", track.unkStrLen1);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString1 = {0}", track.unkString1);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen2 = {0}", track.unkStrLen2);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString2 = {0}", track.unkString2);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen3 = {0}", track.unkStrLen3);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString3 = {0}", track.unkString3);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen4 = {0}", track.unkStrLen4);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString4 = {0}", track.unkString4);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.discIdLen = {0}", track.discIdLen);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.discId = {0}", track.discId);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen5 = {0}", track.unkStrLen5);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString5 = {0}", track.unkString5);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen6 = {0}", track.unkStrLen6);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString6 = {0}", track.unkString6);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen7 = {0}", track.unkStrLen7);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString7 = {0}", track.unkString7);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen8 = {0}", track.unkStrLen8);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString8 = {0}", track.unkString8);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen9 = {0}", track.unkStrLen9);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString9 = {0}", track.unkString9);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen10 = {0}", track.unkStrLen10);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString10 = {0}", track.unkString10);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkStrLen11 = {0}", track.unkStrLen11);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.unkString11 = {0}", track.unkString11);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.isrcLen = {0}", track.isrcLen);
|
|
|
|
|
DicConsole.DebugWriteLine("BlindWrite4 plugin", "track.isrcUpc = {0}", track.isrcUpc);
|
|
|
|
|
|
|
|
|
|
bwTracks.Add(track);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
FiltersList filtersList = new FiltersList();
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!string.IsNullOrEmpty(header.DataFile))
|
2016-08-17 01:32:20 +01:00
|
|
|
while(true)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header.DataFile));
|
2017-12-19 20:33:03 +00:00
|
|
|
if(dataFilter != null) break;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
2017-12-20 17:15:26 +00:00
|
|
|
header.DataFile.ToLower(CultureInfo
|
2017-12-19 20:33:03 +00:00
|
|
|
.CurrentCulture)));
|
|
|
|
|
if(dataFilter != null) break;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
2017-12-20 17:15:26 +00:00
|
|
|
header.DataFile.ToUpper(CultureInfo
|
2017-12-19 20:33:03 +00:00
|
|
|
.CurrentCulture)));
|
|
|
|
|
if(dataFilter != null) break;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
2017-12-21 14:30:38 +00:00
|
|
|
header.DataFile.Split(new[] {'\\'},
|
2017-12-19 20:33:03 +00:00
|
|
|
StringSplitOptions
|
|
|
|
|
.RemoveEmptyEntries)
|
|
|
|
|
.Last()));
|
|
|
|
|
if(dataFilter != null) break;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
2017-12-21 14:30:38 +00:00
|
|
|
header.DataFile.Split(new[] {'\\'},
|
2017-12-19 20:33:03 +00:00
|
|
|
StringSplitOptions
|
|
|
|
|
.RemoveEmptyEntries)
|
|
|
|
|
.Last()
|
|
|
|
|
.ToLower(CultureInfo.CurrentCulture)));
|
|
|
|
|
if(dataFilter != null) break;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
2017-12-21 14:30:38 +00:00
|
|
|
header.DataFile.Split(new[] {'\\'},
|
2017-12-19 20:33:03 +00:00
|
|
|
StringSplitOptions
|
|
|
|
|
.RemoveEmptyEntries)
|
|
|
|
|
.Last()
|
|
|
|
|
.ToUpper(CultureInfo.CurrentCulture)));
|
|
|
|
|
if(dataFilter != null) break;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-21 17:58:51 +00:00
|
|
|
throw new ArgumentException($"Data file {header.DataFile} not found");
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
else throw new ArgumentException("Unable to find data file");
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!string.IsNullOrEmpty(header.SubchannelFile))
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
filtersList = new FiltersList();
|
2017-09-11 21:17:47 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
subFilter =
|
|
|
|
|
((((filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header.SubchannelFile)) ??
|
|
|
|
|
filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
|
|
|
|
header.SubchannelFile.ToLower(CultureInfo.CurrentCulture)))
|
|
|
|
|
) ??
|
|
|
|
|
filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
|
|
|
|
header.SubchannelFile.ToUpper(CultureInfo.CurrentCulture)))
|
|
|
|
|
) ??
|
|
|
|
|
filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
|
|
|
|
header.SubchannelFile.Split(new[] {'\\'},
|
|
|
|
|
StringSplitOptions
|
|
|
|
|
.RemoveEmptyEntries).Last()))
|
|
|
|
|
) ?? filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
|
|
|
|
header.SubchannelFile.Split(new[] {'\\'},
|
|
|
|
|
StringSplitOptions
|
|
|
|
|
.RemoveEmptyEntries).Last()
|
|
|
|
|
.ToLower(CultureInfo.CurrentCulture)))) ??
|
|
|
|
|
filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
|
|
|
|
header.SubchannelFile.Split(new[] {'\\'},
|
|
|
|
|
StringSplitOptions
|
|
|
|
|
.RemoveEmptyEntries).Last()
|
|
|
|
|
.ToUpper(CultureInfo.CurrentCulture)));
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tracks = new List<Track>();
|
|
|
|
|
partitions = new List<Partition>();
|
|
|
|
|
offsetmap = new Dictionary<uint, ulong>();
|
|
|
|
|
trackFlags = new Dictionary<uint, byte>();
|
|
|
|
|
ushort maxSession = 0;
|
|
|
|
|
ulong currentPos = 0;
|
2017-12-20 17:15:26 +00:00
|
|
|
foreach(Bw4TrackDescriptor bwTrack in bwTracks)
|
2016-08-17 01:32:20 +01:00
|
|
|
if(bwTrack.point < 0xA0)
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
Track track = new Track {TrackDescription = bwTrack.title, TrackEndSector = bwTrack.lastSector};
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
if(!string.IsNullOrEmpty(bwTrack.filename))
|
|
|
|
|
do
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
track.TrackFilter =
|
|
|
|
|
filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), bwTrack.filename));
|
|
|
|
|
if(track.TrackFilter != null) break;
|
|
|
|
|
|
|
|
|
|
track.TrackFilter =
|
|
|
|
|
filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
|
|
|
|
bwTrack.filename.ToLower(CultureInfo
|
|
|
|
|
.CurrentCulture)));
|
|
|
|
|
if(track.TrackFilter != null) break;
|
|
|
|
|
|
|
|
|
|
track.TrackFilter =
|
|
|
|
|
filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
|
|
|
|
bwTrack.filename.ToUpper(CultureInfo
|
|
|
|
|
.CurrentCulture)));
|
|
|
|
|
if(track.TrackFilter != null) break;
|
|
|
|
|
|
|
|
|
|
track.TrackFilter =
|
|
|
|
|
filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
2017-12-21 14:30:38 +00:00
|
|
|
bwTrack.filename.Split(new[] {'\\'},
|
2017-12-19 20:33:03 +00:00
|
|
|
StringSplitOptions
|
|
|
|
|
.RemoveEmptyEntries)
|
|
|
|
|
.Last()));
|
|
|
|
|
if(track.TrackFilter != null) break;
|
|
|
|
|
|
|
|
|
|
track.TrackFilter =
|
|
|
|
|
filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
2017-12-21 14:30:38 +00:00
|
|
|
bwTrack.filename.Split(new[] {'\\'},
|
2017-12-19 20:33:03 +00:00
|
|
|
StringSplitOptions
|
|
|
|
|
.RemoveEmptyEntries)
|
|
|
|
|
.Last()
|
|
|
|
|
.ToLower(CultureInfo.CurrentCulture)));
|
|
|
|
|
if(track.TrackFilter != null) break;
|
|
|
|
|
|
|
|
|
|
track.TrackFilter =
|
|
|
|
|
filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(),
|
2017-12-21 14:30:38 +00:00
|
|
|
bwTrack.filename.Split(new[] {'\\'},
|
2017-12-19 20:33:03 +00:00
|
|
|
StringSplitOptions
|
|
|
|
|
.RemoveEmptyEntries)
|
|
|
|
|
.Last()
|
|
|
|
|
.ToUpper(CultureInfo.CurrentCulture)));
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
track.TrackFilter = dataFilter;
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
while(true);
|
2017-12-19 20:33:03 +00:00
|
|
|
else track.TrackFilter = dataFilter;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
track.TrackFile = dataFilter.GetFilename();
|
2016-08-17 01:32:20 +01:00
|
|
|
track.TrackFileOffset = bwTrack.offset;
|
|
|
|
|
if(bwTrack.pregap > 0)
|
|
|
|
|
track.TrackFileOffset += (ulong)(bwTrack.startSector - bwTrack.pregap) * 2352;
|
|
|
|
|
track.TrackFileType = "BINARY";
|
|
|
|
|
track.TrackPregap = (ulong)(bwTrack.startSector - bwTrack.pregap);
|
|
|
|
|
track.TrackRawBytesPerSector = 2352;
|
|
|
|
|
track.TrackSequence = bwTrack.point;
|
|
|
|
|
track.TrackSession = bwTrack.session;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(track.TrackSession > maxSession) maxSession = track.TrackSession;
|
2016-08-17 01:32:20 +01:00
|
|
|
track.TrackStartSector = (ulong)bwTrack.startSector;
|
2016-09-05 17:37:31 +01:00
|
|
|
track.TrackSubchannelFilter = subFilter;
|
|
|
|
|
track.TrackSubchannelFile = subFilter.GetFilename();
|
2016-08-17 01:32:20 +01:00
|
|
|
track.TrackSubchannelOffset = track.TrackStartSector / 96;
|
2016-09-05 17:37:31 +01:00
|
|
|
if(subFilter != null && bwTrack.subchannel > 0)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
track.TrackSubchannelType = TrackSubchannelType.Packed;
|
2017-12-26 06:05:12 +00:00
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel))
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel);
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
else track.TrackSubchannelType = TrackSubchannelType.None;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
switch(bwTrack.trackMode)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case Bw4TrackType.Audio:
|
2016-08-17 01:32:20 +01:00
|
|
|
track.TrackType = TrackType.Audio;
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.SectorSize = 2352;
|
2016-08-17 01:32:20 +01:00
|
|
|
track.TrackBytesPerSector = 2352;
|
|
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case Bw4TrackType.Mode1:
|
|
|
|
|
track.TrackType = TrackType.CdMode1;
|
2017-12-26 06:05:12 +00:00
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
|
|
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
|
|
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader))
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader);
|
|
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc))
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc);
|
|
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP))
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP);
|
|
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ))
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ);
|
|
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
|
|
|
|
|
if(imageInfo.SectorSize < 2048) imageInfo.SectorSize = 2048;
|
2016-08-17 01:32:20 +01:00
|
|
|
track.TrackBytesPerSector = 2048;
|
|
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case Bw4TrackType.Mode2:
|
|
|
|
|
track.TrackType = TrackType.CdMode2Formless;
|
2017-12-26 06:05:12 +00:00
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
|
|
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
|
|
|
|
|
if(imageInfo.SectorSize < 2336) imageInfo.SectorSize = 2336;
|
2016-08-17 01:32:20 +01:00
|
|
|
track.TrackBytesPerSector = 2336;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
track.TrackType = TrackType.Data;
|
|
|
|
|
track.TrackRawBytesPerSector = 2048;
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.SectorSize = 2048;
|
2016-08-17 01:32:20 +01:00
|
|
|
track.TrackBytesPerSector = 2048;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
track.Indexes = new Dictionary<int, ulong>();
|
2017-12-19 20:33:03 +00:00
|
|
|
if(bwTrack.pregap > 0) track.Indexes.Add(0, (ulong)bwTrack.pregap);
|
2016-08-17 01:32:20 +01:00
|
|
|
track.Indexes.Add(1, (ulong)bwTrack.startSector);
|
|
|
|
|
|
|
|
|
|
Partition partition = new Partition();
|
2017-12-19 20:33:03 +00:00
|
|
|
if(bwTrack.pregap > 0) currentPos += (ulong)(bwTrack.startSector - bwTrack.pregap) * 2352;
|
2017-07-19 16:37:11 +01:00
|
|
|
partition.Description = track.TrackDescription;
|
|
|
|
|
partition.Size = (track.TrackEndSector - track.TrackStartSector + 1) * 2352;
|
|
|
|
|
partition.Length = track.TrackEndSector - track.TrackStartSector;
|
|
|
|
|
partition.Sequence = track.TrackSequence;
|
|
|
|
|
partition.Offset = currentPos;
|
|
|
|
|
partition.Start = track.TrackStartSector;
|
|
|
|
|
partition.Type = track.TrackType.ToString();
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
partitions.Add(partition);
|
|
|
|
|
tracks.Add(track);
|
2017-07-19 16:37:11 +01:00
|
|
|
currentPos += partition.Size;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
if(!offsetmap.ContainsKey(track.TrackSequence))
|
|
|
|
|
offsetmap.Add(track.TrackSequence, track.TrackStartSector);
|
|
|
|
|
|
|
|
|
|
if(!trackFlags.ContainsKey(track.TrackSequence))
|
|
|
|
|
trackFlags.Add(track.TrackSequence, (byte)(bwTrack.adrCtl & 0x0F));
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.Sectors += (ulong)(bwTrack.lastSector - bwTrack.startSector + 1);
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.MediaBarcode = bwTrack.isrcUpc;
|
|
|
|
|
imageInfo.MediaSerialNumber = bwTrack.discId;
|
|
|
|
|
imageInfo.MediaTitle = bwTrack.title;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(!string.IsNullOrEmpty(bwTrack.isrcUpc) &&
|
2017-12-26 06:05:12 +00:00
|
|
|
!imageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN))
|
|
|
|
|
imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN);
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sessions = new List<Session>();
|
|
|
|
|
for(ushort i = 1; i <= maxSession; i++)
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
Session session = new Session
|
|
|
|
|
{
|
|
|
|
|
SessionSequence = i,
|
|
|
|
|
StartTrack = uint.MaxValue,
|
|
|
|
|
StartSector = uint.MaxValue
|
|
|
|
|
};
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-21 16:33:16 +00:00
|
|
|
foreach(Track track in tracks.Where(track => track.TrackSession == i))
|
|
|
|
|
{
|
2017-12-21 07:08:26 +00:00
|
|
|
if(track.TrackSequence < session.StartTrack) session.StartTrack = track.TrackSequence;
|
|
|
|
|
if(track.TrackSequence > session.EndTrack) session.StartTrack = track.TrackSequence;
|
|
|
|
|
if(track.TrackStartSector < session.StartSector) session.StartSector = track.TrackStartSector;
|
|
|
|
|
if(track.TrackEndSector > session.EndSector) session.EndSector = track.TrackEndSector;
|
|
|
|
|
}
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
sessions.Add(session);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.MediaType = MediaType.CD;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.Application = "BlindWrite";
|
|
|
|
|
imageInfo.ApplicationVersion = "4";
|
|
|
|
|
imageInfo.Version = "4";
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.ImageSize = (ulong)dataFilter.GetDataForkLength();
|
|
|
|
|
imageInfo.CreationTime = dataFilter.GetCreationTime();
|
|
|
|
|
imageInfo.LastModificationTime = dataFilter.GetLastWriteTime();
|
|
|
|
|
imageInfo.XmlMediaType = XmlMediaType.OpticalDisc;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
bool data = false;
|
|
|
|
|
bool mode2 = false;
|
|
|
|
|
bool firstaudio = false;
|
|
|
|
|
bool firstdata = false;
|
|
|
|
|
bool audio = false;
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
foreach(Track bwTrack in tracks)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
// First track is audio
|
2017-12-22 06:55:04 +00:00
|
|
|
firstaudio |= bwTrack.TrackSequence == 1 && bwTrack.TrackType == TrackType.Audio;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
// First track is data
|
2017-12-22 06:55:04 +00:00
|
|
|
firstdata |= bwTrack.TrackSequence == 1 && bwTrack.TrackType != TrackType.Audio;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
// Any non first track is data
|
2017-12-22 06:55:04 +00:00
|
|
|
data |= bwTrack.TrackSequence != 1 && bwTrack.TrackType != TrackType.Audio;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
// Any non first track is audio
|
2017-12-22 06:55:04 +00:00
|
|
|
audio |= bwTrack.TrackSequence != 1 && bwTrack.TrackType == TrackType.Audio;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
switch(bwTrack.TrackType)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case TrackType.CdMode2Formless:
|
2016-08-17 01:32:20 +01:00
|
|
|
mode2 = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
if(!data && !firstdata) imageInfo.MediaType = MediaType.CDDA;
|
|
|
|
|
else if(firstaudio && data && sessions.Count > 1 && mode2) imageInfo.MediaType = MediaType.CDPLUS;
|
|
|
|
|
else if(firstdata && audio || mode2) imageInfo.MediaType = MediaType.CDROMXA;
|
|
|
|
|
else if(!audio) imageInfo.MediaType = MediaType.CDROM;
|
|
|
|
|
else imageInfo.MediaType = MediaType.CD;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.Comments = header.Comments;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
DicConsole.VerboseWriteLine("BlindWrite image describes a disc of type {0}", imageInfo.MediaType);
|
|
|
|
|
if(!string.IsNullOrEmpty(imageInfo.Comments))
|
|
|
|
|
DicConsole.VerboseWriteLine("BlindrWrite comments: {0}", imageInfo.Comments);
|
2016-08-21 17:35:35 +01:00
|
|
|
|
2016-08-17 01:32:20 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadDiskTag(MediaTagType tag)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
switch(tag)
|
|
|
|
|
{
|
|
|
|
|
case MediaTagType.CD_MCN:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
if(imageInfo.MediaSerialNumber != null) return Encoding.ASCII.GetBytes(imageInfo.MediaSerialNumber);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
throw new FeatureNotPresentImageException("Image does not contain MCN information.");
|
|
|
|
|
}
|
2016-08-17 01:32:20 +01:00
|
|
|
default:
|
|
|
|
|
throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSector(ulong sectorAddress)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectors(sectorAddress, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectorsTag(sectorAddress, 1, tag);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSector(ulong sectorAddress, uint track)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectors(sectorAddress, 1, track);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectorsTag(sectorAddress, 1, track, tag);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-21 16:33:16 +00:00
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap
|
|
|
|
|
where sectorAddress >= kvp.Value
|
|
|
|
|
from track in tracks
|
|
|
|
|
where track.TrackSequence == kvp.Key
|
|
|
|
|
where sectorAddress - kvp.Value <
|
|
|
|
|
track.TrackEndSector - track.TrackStartSector + 1
|
|
|
|
|
select kvp)
|
|
|
|
|
return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-21 16:33:16 +00:00
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap
|
|
|
|
|
where sectorAddress >= kvp.Value
|
|
|
|
|
from track in tracks
|
|
|
|
|
where track.TrackSequence == kvp.Key
|
|
|
|
|
where sectorAddress - kvp.Value <
|
|
|
|
|
track.TrackEndSector - track.TrackStartSector + 1
|
|
|
|
|
select kvp)
|
|
|
|
|
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
Track dicTrack = new Track {TrackSequence = 0};
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-21 16:33:16 +00:00
|
|
|
foreach(Track bwTrack in tracks.Where(bwTrack => bwTrack.TrackSequence == track))
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
dicTrack = bwTrack;
|
2017-12-21 07:08:26 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.TrackSequence == 0)
|
2016-08-17 01:32:20 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(length + sectorAddress > dicTrack.TrackEndSector - dicTrack.TrackStartSector + 1)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
2017-12-22 06:55:04 +00:00
|
|
|
$"Requested more sectors ({length + sectorAddress}) than present in track ({dicTrack.TrackEndSector - dicTrack.TrackStartSector + 1}), won't cross tracks");
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
uint sectorOffset;
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
uint sectorSkip;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
switch(dicTrack.TrackType)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case TrackType.CdMode1:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 16;
|
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
sectorSkip = 288;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case TrackType.CdMode2Formless:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 16;
|
|
|
|
|
sectorSize = 2336;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2016-08-17 01:32:20 +01:00
|
|
|
case TrackType.Audio:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2352;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2016-08-17 01:32:20 +01:00
|
|
|
case TrackType.Data:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
imageStream = dicTrack.TrackFilter.GetDataForkStream();
|
2016-09-05 17:37:31 +01:00
|
|
|
BinaryReader br = new BinaryReader(imageStream);
|
2017-12-19 20:33:03 +00:00
|
|
|
br.BaseStream
|
2017-12-22 06:55:04 +00:00
|
|
|
.Seek((long)dicTrack.TrackFileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
2017-12-19 20:33:03 +00:00
|
|
|
SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length));
|
2016-09-05 17:37:31 +01:00
|
|
|
else
|
|
|
|
|
for(int i = 0; i < length; i++)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
|
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
Track dicTrack = new Track {TrackSequence = 0};
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-21 16:33:16 +00:00
|
|
|
foreach(Track bwTrack in tracks.Where(bwTrack => bwTrack.TrackSequence == track))
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
dicTrack = bwTrack;
|
2017-12-21 07:08:26 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.TrackSequence == 0)
|
2016-08-17 01:32:20 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(length + sectorAddress > dicTrack.TrackEndSector - dicTrack.TrackStartSector + 1)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
2017-12-22 06:55:04 +00:00
|
|
|
$"Requested more sectors ({length + sectorAddress}) than present in track ({dicTrack.TrackEndSector - dicTrack.TrackStartSector + 1}), won't cross tracks");
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
uint sectorOffset;
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
uint sectorSkip;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.TrackType == TrackType.Data)
|
2016-08-17 01:32:20 +01:00
|
|
|
throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
|
|
|
|
|
|
|
|
|
switch(tag)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEcc:
|
|
|
|
|
case SectorTagType.CdSectorEccP:
|
|
|
|
|
case SectorTagType.CdSectorEccQ:
|
|
|
|
|
case SectorTagType.CdSectorEdc:
|
|
|
|
|
case SectorTagType.CdSectorHeader:
|
|
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
case SectorTagType.CdSectorSubHeader:
|
|
|
|
|
case SectorTagType.CdSectorSync: break;
|
|
|
|
|
case SectorTagType.CdTrackFlags:
|
2017-12-22 06:55:04 +00:00
|
|
|
if(trackFlags.TryGetValue(track, out byte flag)) return new[] {flag};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2016-08-17 01:32:20 +01:00
|
|
|
throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2017-12-19 20:33:03 +00:00
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
switch(dicTrack.TrackType)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case TrackType.CdMode1:
|
2016-08-17 01:32:20 +01:00
|
|
|
switch(tag)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSync:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 12;
|
|
|
|
|
sectorSkip = 2340;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorHeader:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 12;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 2336;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubHeader:
|
2016-08-17 01:32:20 +01:00
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEcc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2076;
|
|
|
|
|
sectorSize = 276;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEccP:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2076;
|
|
|
|
|
sectorSize = 172;
|
|
|
|
|
sectorSkip = 104;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEccQ:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2248;
|
|
|
|
|
sectorSize = 104;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEdc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2064;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 284;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubchannel:
|
2016-08-18 00:05:24 +01:00
|
|
|
throw new NotImplementedException("Packed subchannel not yet supported");
|
2017-12-19 20:33:03 +00:00
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2016-08-17 01:32:20 +01:00
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case TrackType.CdMode2Formless:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
switch(tag)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSync:
|
|
|
|
|
case SectorTagType.CdSectorHeader:
|
|
|
|
|
case SectorTagType.CdSectorEcc:
|
|
|
|
|
case SectorTagType.CdSectorEccP:
|
|
|
|
|
case SectorTagType.CdSectorEccQ:
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubHeader:
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 8;
|
|
|
|
|
sectorSkip = 2328;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEdc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2332;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubchannel:
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new NotImplementedException("Packed subchannel not yet supported");
|
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-08-17 01:32:20 +01:00
|
|
|
case TrackType.Audio:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
switch(tag)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubchannel:
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new NotImplementedException("Packed subchannel not yet supported");
|
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
imageStream = dicTrack.TrackFilter.GetDataForkStream();
|
2016-09-05 17:37:31 +01:00
|
|
|
BinaryReader br = new BinaryReader(imageStream);
|
2017-12-19 20:33:03 +00:00
|
|
|
br.BaseStream
|
2017-12-22 06:55:04 +00:00
|
|
|
.Seek((long)dicTrack.TrackFileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
2017-12-19 20:33:03 +00:00
|
|
|
SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length));
|
2016-09-05 17:37:31 +01:00
|
|
|
else
|
|
|
|
|
for(int i = 0; i < length; i++)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
|
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectorsLong(sectorAddress, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress, uint track)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectorsLong(sectorAddress, 1, track);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorsLong(ulong sectorAddress, uint length)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-21 16:33:16 +00:00
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap
|
|
|
|
|
where sectorAddress >= kvp.Value
|
|
|
|
|
from track in tracks
|
|
|
|
|
where track.TrackSequence == kvp.Key
|
|
|
|
|
where sectorAddress - kvp.Value <
|
|
|
|
|
track.TrackEndSector - track.TrackStartSector + 1
|
|
|
|
|
select kvp)
|
|
|
|
|
return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
Track dicTrack = new Track {TrackSequence = 0};
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-21 16:33:16 +00:00
|
|
|
foreach(Track bwTrack in tracks.Where(bwTrack => bwTrack.TrackSequence == track))
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
dicTrack = bwTrack;
|
2017-12-21 07:08:26 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.TrackSequence == 0)
|
2016-08-17 01:32:20 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(length + sectorAddress > dicTrack.TrackEndSector - dicTrack.TrackStartSector + 1)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
2017-12-22 06:55:04 +00:00
|
|
|
$"Requested more sectors ({length + sectorAddress}) than present in track ({dicTrack.TrackEndSector - dicTrack.TrackStartSector + 1}), won't cross tracks");
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
uint sectorOffset;
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
uint sectorSkip;
|
2016-08-17 01:32:20 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
switch(dicTrack.TrackType)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
case TrackType.Audio:
|
2017-12-20 17:15:26 +00:00
|
|
|
case TrackType.CdMode1:
|
|
|
|
|
case TrackType.CdMode2Formless:
|
2016-08-17 01:32:20 +01:00
|
|
|
case TrackType.Data:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
2017-12-22 06:55:04 +00:00
|
|
|
sectorSize = (uint)dicTrack.TrackRawBytesPerSector;
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
imageStream = dicTrack.TrackFilter.GetDataForkStream();
|
2016-09-05 17:37:31 +01:00
|
|
|
BinaryReader br = new BinaryReader(imageStream);
|
2017-12-19 20:33:03 +00:00
|
|
|
br.BaseStream
|
2017-12-22 06:55:04 +00:00
|
|
|
.Seek((long)dicTrack.TrackFileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
2017-12-19 20:33:03 +00:00
|
|
|
SeekOrigin.Begin);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] buffer = br.ReadBytes((int)(sectorSize * length));
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Track> GetSessionTracks(Session session)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-20 23:07:46 +00:00
|
|
|
if(sessions.Contains(session)) return GetSessionTracks(session.SessionSequence);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2016-08-17 01:32:20 +01:00
|
|
|
throw new ImageNotSupportedException("Session does not exist in disc image");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Track> GetSessionTracks(ushort session)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
return tracks.Where(track => track.TrackSession == session).ToList();
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifySector(ulong sectorAddress)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorLong(sectorAddress);
|
2017-12-21 14:30:38 +00:00
|
|
|
return CdChecksums.CheckCdSector(buffer);
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifySector(ulong sectorAddress, uint track)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorLong(sectorAddress, track);
|
2017-12-21 14:30:38 +00:00
|
|
|
return CdChecksums.CheckCdSector(buffer);
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
|
2017-12-20 17:15:26 +00:00
|
|
|
out List<ulong> unknownLbas)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorsLong(sectorAddress, length);
|
|
|
|
|
int bps = (int)(buffer.Length / length);
|
|
|
|
|
byte[] sector = new byte[bps];
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
for(int i = 0; i < length; i++)
|
|
|
|
|
{
|
|
|
|
|
Array.Copy(buffer, i * bps, sector, 0, bps);
|
2017-12-21 14:30:38 +00:00
|
|
|
bool? sectorStatus = CdChecksums.CheckCdSector(sector);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
switch(sectorStatus)
|
|
|
|
|
{
|
|
|
|
|
case null:
|
2017-12-20 17:15:26 +00:00
|
|
|
unknownLbas.Add((ulong)i + sectorAddress);
|
2016-08-17 01:32:20 +01:00
|
|
|
break;
|
|
|
|
|
case false:
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas.Add((ulong)i + sectorAddress);
|
2016-08-17 01:32:20 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(unknownLbas.Count > 0) return null;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
return failingLbas.Count <= 0;
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
2017-12-20 17:15:26 +00:00
|
|
|
out List<ulong> unknownLbas)
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorsLong(sectorAddress, length, track);
|
|
|
|
|
int bps = (int)(buffer.Length / length);
|
|
|
|
|
byte[] sector = new byte[bps];
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
for(int i = 0; i < length; i++)
|
|
|
|
|
{
|
|
|
|
|
Array.Copy(buffer, i * bps, sector, 0, bps);
|
2017-12-21 14:30:38 +00:00
|
|
|
bool? sectorStatus = CdChecksums.CheckCdSector(sector);
|
2016-08-17 01:32:20 +01:00
|
|
|
|
|
|
|
|
switch(sectorStatus)
|
|
|
|
|
{
|
|
|
|
|
case null:
|
2017-12-20 17:15:26 +00:00
|
|
|
unknownLbas.Add((ulong)i + sectorAddress);
|
2016-08-17 01:32:20 +01:00
|
|
|
break;
|
|
|
|
|
case false:
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas.Add((ulong)i + sectorAddress);
|
2016-08-17 01:32:20 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(unknownLbas.Count > 0) return null;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
return failingLbas.Count <= 0;
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifyMediaImage()
|
2016-08-17 01:32:20 +01:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
struct Bw4Header
|
|
|
|
|
{
|
|
|
|
|
public byte[] Signature;
|
|
|
|
|
public uint Unknown1;
|
|
|
|
|
public ulong Timestamp;
|
|
|
|
|
public uint VolumeIdLength;
|
|
|
|
|
public byte[] VolumeIdBytes;
|
|
|
|
|
public uint SysIdLength;
|
|
|
|
|
public byte[] SysIdBytes;
|
|
|
|
|
public uint CommentsLength;
|
|
|
|
|
public byte[] CommentsBytes;
|
|
|
|
|
public uint TrackDescriptors;
|
|
|
|
|
public uint DataFileLength;
|
|
|
|
|
public byte[] DataFileBytes;
|
|
|
|
|
public uint SubchannelFileLength;
|
|
|
|
|
public byte[] SubchannelFileBytes;
|
|
|
|
|
public uint Unknown2;
|
|
|
|
|
public byte Unknown3;
|
|
|
|
|
public byte[] Unknown4;
|
|
|
|
|
|
|
|
|
|
// On memory only
|
|
|
|
|
#pragma warning disable 649
|
|
|
|
|
public string VolumeIdentifier;
|
|
|
|
|
public string SystemIdentifier;
|
|
|
|
|
public string Comments;
|
2017-12-26 06:05:12 +00:00
|
|
|
public IFilter DataFilter;
|
|
|
|
|
public IFilter SubchannelFilter;
|
2017-12-24 00:12:31 +00:00
|
|
|
public string DataFile;
|
|
|
|
|
public string SubchannelFile;
|
|
|
|
|
#pragma warning restore 649
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
struct Bw4TrackDescriptor
|
|
|
|
|
{
|
|
|
|
|
public uint filenameLen;
|
|
|
|
|
public byte[] filenameBytes;
|
|
|
|
|
public uint offset;
|
|
|
|
|
public byte subchannel;
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] unknown1;
|
|
|
|
|
public uint unknown2;
|
|
|
|
|
public byte unknown3;
|
|
|
|
|
public byte session;
|
|
|
|
|
public byte unknown4;
|
|
|
|
|
public byte adrCtl;
|
|
|
|
|
public byte unknown5;
|
|
|
|
|
public Bw4TrackType trackMode;
|
|
|
|
|
public byte unknown6;
|
|
|
|
|
public byte point;
|
|
|
|
|
public uint unknown7;
|
|
|
|
|
public uint unknown8;
|
|
|
|
|
public uint unknown9;
|
|
|
|
|
public uint unknown10;
|
|
|
|
|
public ushort unknown11;
|
|
|
|
|
public uint lastSector;
|
|
|
|
|
public byte unknown12;
|
|
|
|
|
public int pregap;
|
|
|
|
|
public int startSector;
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] unknown13;
|
|
|
|
|
public uint titleLen;
|
|
|
|
|
public byte[] titleBytes;
|
|
|
|
|
public uint performerLen;
|
|
|
|
|
public byte[] performerBytes;
|
|
|
|
|
public uint unkStrLen1;
|
|
|
|
|
public byte[] unkStrBytes1;
|
|
|
|
|
public uint unkStrLen2;
|
|
|
|
|
public byte[] unkStrBytes2;
|
|
|
|
|
public uint unkStrLen3;
|
|
|
|
|
public byte[] unkStrBytes3;
|
|
|
|
|
public uint unkStrLen4;
|
|
|
|
|
public byte[] unkStrBytes4;
|
|
|
|
|
public uint discIdLen;
|
|
|
|
|
public byte[] discIdBytes;
|
|
|
|
|
public uint unkStrLen5;
|
|
|
|
|
public byte[] unkStrBytes5;
|
|
|
|
|
public uint unkStrLen6;
|
|
|
|
|
public byte[] unkStrBytes6;
|
|
|
|
|
public uint unkStrLen7;
|
|
|
|
|
public byte[] unkStrBytes7;
|
|
|
|
|
public uint unkStrLen8;
|
|
|
|
|
public byte[] unkStrBytes8;
|
|
|
|
|
public uint unkStrLen9;
|
|
|
|
|
public byte[] unkStrBytes9;
|
|
|
|
|
public uint unkStrLen10;
|
|
|
|
|
public byte[] unkStrBytes10;
|
|
|
|
|
public uint unkStrLen11;
|
|
|
|
|
public byte[] unkStrBytes11;
|
|
|
|
|
public uint isrcLen;
|
|
|
|
|
public byte[] isrcBytes;
|
|
|
|
|
|
|
|
|
|
// On memory only
|
|
|
|
|
public string filename;
|
|
|
|
|
public string title;
|
|
|
|
|
public string performer;
|
|
|
|
|
public string unkString1;
|
|
|
|
|
public string unkString2;
|
|
|
|
|
public string unkString3;
|
|
|
|
|
public string unkString4;
|
|
|
|
|
public string discId;
|
|
|
|
|
public string unkString5;
|
|
|
|
|
public string unkString6;
|
|
|
|
|
public string unkString7;
|
|
|
|
|
public string unkString8;
|
|
|
|
|
public string unkString9;
|
|
|
|
|
public string unkString10;
|
|
|
|
|
public string unkString11;
|
|
|
|
|
public string isrcUpc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum Bw4TrackType : byte
|
|
|
|
|
{
|
|
|
|
|
Audio = 0,
|
|
|
|
|
Mode1 = 1,
|
|
|
|
|
Mode2 = 2
|
|
|
|
|
}
|
2016-08-17 01:32:20 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|