2018-07-23 23:25:43 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// Filename : Read.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : Disk image plugins.
|
2016-07-28 18:13:49 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// Reads Nero Burning ROM disc images.
|
2016-07-28 18:13:49 +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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2020-01-03 17:51:30 +00:00
|
|
|
|
// Copyright © 2011-2020 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// ****************************************************************************/
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2017-12-19 19:33:46 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using System.Text;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
|
|
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
|
using Aaru.CommonTypes.Exceptions;
|
|
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.CommonTypes.Structs;
|
|
|
|
|
|
using Aaru.Console;
|
|
|
|
|
|
using Aaru.Decoders.CD;
|
|
|
|
|
|
using Session = Aaru.CommonTypes.Structs.Session;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
|
namespace Aaru.DiscImages
|
2014-07-09 19:52:00 +01:00
|
|
|
|
{
|
2018-07-23 23:25:43 +01:00
|
|
|
|
public partial class Nero
|
2014-07-09 19:52:00 +01:00
|
|
|
|
{
|
2017-12-28 19:56:36 +00:00
|
|
|
|
public bool Open(IFilter imageFilter)
|
2014-07-09 19:52:00 +01:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2019-05-11 20:49:32 +01:00
|
|
|
|
imageStream = imageFilter.GetDataForkStream();
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var footerV1 = new NeroV1Footer();
|
|
|
|
|
|
var footerV2 = new NeroV2Footer();
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Seek(-8, SeekOrigin.End);
|
|
|
|
|
|
byte[] buffer = new byte[8];
|
|
|
|
|
|
imageStream.Read(buffer, 0, 8);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
footerV1.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
footerV1.FirstChunkOffset = BigEndianBitConverter.ToUInt32(buffer, 4);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Seek(-12, SeekOrigin.End);
|
|
|
|
|
|
buffer = new byte[12];
|
|
|
|
|
|
imageStream.Read(buffer, 0, 12);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
footerV2.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
footerV2.FirstChunkOffset = BigEndianBitConverter.ToUInt64(buffer, 4);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "imageStream.Length = {0}", imageStream.Length);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "footerV1.ChunkID = 0x{0:X8} (\"{1}\")", footerV1.ChunkId,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(footerV1.ChunkId)));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "footerV1.FirstChunkOffset = {0}", footerV1.FirstChunkOffset);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "footerV2.ChunkID = 0x{0:X8} (\"{1}\")", footerV2.ChunkId,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(footerV2.ChunkId)));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "footerV2.FirstChunkOffset = {0}", footerV2.FirstChunkOffset);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(footerV1.ChunkId == NERO_FOOTER_V1 &&
|
|
|
|
|
|
footerV1.FirstChunkOffset < (ulong)imageStream.Length)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageNewFormat = false;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
else if(footerV2.ChunkId == NERO_FOOTER_V2 &&
|
|
|
|
|
|
footerV2.FirstChunkOffset < (ulong)imageStream.Length)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageNewFormat = true;
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWrite("Nero plugin", "Nero version not recognized.");
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(imageNewFormat)
|
|
|
|
|
|
imageStream.Seek((long)footerV2.FirstChunkOffset, SeekOrigin.Begin);
|
|
|
|
|
|
else
|
|
|
|
|
|
imageStream.Seek(footerV1.FirstChunkOffset, SeekOrigin.Begin);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2018-01-01 21:32:12 +00:00
|
|
|
|
bool parsing = true;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
ushort currentsession = 1;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
uint currenttrack = 1;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2018-01-01 21:32:12 +00:00
|
|
|
|
Tracks = new List<Track>();
|
2017-12-24 00:12:31 +00:00
|
|
|
|
trackIsrCs = new Dictionary<uint, byte[]>();
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2018-01-01 21:32:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.CD;
|
|
|
|
|
|
imageInfo.Sectors = 0;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorSize = 0;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
while(parsing)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] chunkHeaderBuffer = new byte[8];
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Read(chunkHeaderBuffer, 0, 8);
|
2018-06-22 08:08:38 +01:00
|
|
|
|
uint chunkId = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 0);
|
2018-06-20 22:22:21 +01:00
|
|
|
|
uint chunkLength = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 4);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "ChunkID = 0x{0:X8} (\"{1}\")", chunkId,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(chunkId)));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "ChunkLength = {0}", chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
switch(chunkId)
|
|
|
|
|
|
{
|
|
|
|
|
|
case NERO_CUE_V1:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"CUES\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroCuesheetV1 = new NeroV1Cuesheet
|
|
|
|
|
|
{
|
2018-12-31 13:17:27 +00:00
|
|
|
|
ChunkId = chunkId, ChunkSize = chunkLength, Entries = new List<NeroV1CueEntry>()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[8];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
for(int i = 0; i < neroCuesheetV1.ChunkSize; i += 8)
|
|
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var entry = new NeroV1CueEntry();
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Read(tmpbuffer, 0, 8);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Mode = tmpbuffer[0];
|
2017-12-24 00:12:31 +00:00
|
|
|
|
entry.TrackNumber = tmpbuffer[1];
|
|
|
|
|
|
entry.IndexNumber = tmpbuffer[2];
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Dummy = BigEndianBitConverter.ToUInt16(tmpbuffer, 3);
|
|
|
|
|
|
entry.Minute = tmpbuffer[5];
|
|
|
|
|
|
entry.Second = tmpbuffer[6];
|
|
|
|
|
|
entry.Frame = tmpbuffer[7];
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", (i / 8) + 1);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1:X2}", (i / 8) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Mode);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = {1:X2}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 8) + 1, entry.TrackNumber);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].IndexNumber = {1:X2}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 8) + 1, entry.IndexNumber);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X4}", (i / 8) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Dummy);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Minute = {1:X2}", (i / 8) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Minute);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Second = {1:X2}", (i / 8) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Second);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Frame = {1:X2}", (i / 8) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Frame);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroCuesheetV1.Entries.Add(entry);
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_CUE_V2:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"CUEX\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroCuesheetV2 = new NeroV2Cuesheet
|
|
|
|
|
|
{
|
2018-12-31 13:17:27 +00:00
|
|
|
|
ChunkId = chunkId, ChunkSize = chunkLength, Entries = new List<NeroV2CueEntry>()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[8];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
for(int i = 0; i < neroCuesheetV2.ChunkSize; i += 8)
|
|
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var entry = new NeroV2CueEntry();
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Read(tmpbuffer, 0, 8);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Mode = tmpbuffer[0];
|
2017-12-24 00:12:31 +00:00
|
|
|
|
entry.TrackNumber = tmpbuffer[1];
|
|
|
|
|
|
entry.IndexNumber = tmpbuffer[2];
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Dummy = tmpbuffer[3];
|
|
|
|
|
|
entry.LbaStart = BigEndianBitConverter.ToInt32(tmpbuffer, 4);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", (i / 8) + 1);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = 0x{1:X2}", (i / 8) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Mode);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = {1:X2}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 8) + 1, entry.TrackNumber);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].IndexNumber = {1:X2}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 8) + 1, entry.IndexNumber);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X2}", (i / 8) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Dummy);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].LBAStart = {1}", (i / 8) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.LbaStart);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroCuesheetV2.Entries.Add(entry);
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_DAO_V1:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"DAOI\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
neroDaov1 = new NeroV1Dao
|
|
|
|
|
|
{
|
|
|
|
|
|
ChunkId = chunkId, ChunkSizeBe = chunkLength
|
|
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[22];
|
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 22);
|
|
|
|
|
|
neroDaov1.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
neroDaov1.Upc = new byte[14];
|
2017-12-24 00:12:31 +00:00
|
|
|
|
Array.Copy(tmpbuffer, 4, neroDaov1.Upc, 0, 14);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
neroDaov1.TocType = BigEndianBitConverter.ToUInt16(tmpbuffer, 18);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroDaov1.FirstTrack = tmpbuffer[20];
|
2018-01-01 21:32:12 +00:00
|
|
|
|
neroDaov1.LastTrack = tmpbuffer[21];
|
|
|
|
|
|
neroDaov1.Tracks = new List<NeroV1DaoEntry>();
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(!imageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN))
|
|
|
|
|
|
imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc))
|
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.ChunkSizeLe = {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
neroDaov1.ChunkSizeLe);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.UPC = \"{0}\"",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
StringHandlers.CToString(neroDaov1.Upc));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.TocType = 0x{0:X4}",
|
|
|
|
|
|
neroDaov1.TocType);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.FirstTrack = {0}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
neroDaov1.FirstTrack);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.LastTrack = {0}", neroDaov1.LastTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
upc = neroDaov1.Upc;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
tmpbuffer = new byte[30];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
for(int i = 0; i < neroDaov1.ChunkSizeBe - 22; i += 30)
|
|
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var entry = new NeroV1DaoEntry();
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Read(tmpbuffer, 0, 30);
|
|
|
|
|
|
entry.Isrc = new byte[12];
|
|
|
|
|
|
Array.Copy(tmpbuffer, 4, entry.Isrc, 0, 12);
|
|
|
|
|
|
entry.SectorSize = BigEndianBitConverter.ToUInt16(tmpbuffer, 12);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Mode = BitConverter.ToUInt16(tmpbuffer, 14);
|
|
|
|
|
|
entry.Unknown = BigEndianBitConverter.ToUInt16(tmpbuffer, 16);
|
|
|
|
|
|
entry.Index0 = BigEndianBitConverter.ToUInt32(tmpbuffer, 18);
|
|
|
|
|
|
entry.Index1 = BigEndianBitConverter.ToUInt32(tmpbuffer, 22);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
entry.EndOfTrack = BigEndianBitConverter.ToUInt32(tmpbuffer, 26);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", (i / 32) + 1);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", (i / 32) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
StringHandlers.CToString(entry.Isrc));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].SectorSize = {1}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, entry.SectorSize);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, (DaoMode)entry.Mode, entry.Mode);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, entry.Unknown);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", (i / 32) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Index0);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", (i / 32) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Index1);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, entry.EndOfTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroDaov1.Tracks.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(entry.SectorSize > imageInfo.SectorSize)
|
|
|
|
|
|
imageInfo.SectorSize = entry.SectorSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
trackIsrCs.Add(currenttrack, entry.Isrc);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(currenttrack == 1)
|
|
|
|
|
|
entry.Index0 = entry.Index1;
|
|
|
|
|
|
|
|
|
|
|
|
var neroTrack = new NeroTrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-06-14 23:45:26 +01:00
|
|
|
|
EndOfTrack = entry.EndOfTrack, Isrc = entry.Isrc,
|
|
|
|
|
|
Length = entry.EndOfTrack - entry.Index0, Mode = entry.Mode, Offset = entry.Index0,
|
|
|
|
|
|
SectorSize = entry.SectorSize, StartLba = imageInfo.Sectors, Index0 = entry.Index0,
|
|
|
|
|
|
Index1 = entry.Index1, Sequence = currenttrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTrack.Sectors = neroTrack.Length / entry.SectorSize;
|
|
|
|
|
|
neroTracks.Add(currenttrack, neroTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.Sectors += neroTrack.Sectors;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
currenttrack++;
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_DAO_V2:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"DAOX\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
neroDaov2 = new NeroV2Dao
|
|
|
|
|
|
{
|
|
|
|
|
|
ChunkId = chunkId, ChunkSizeBe = chunkLength
|
|
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[22];
|
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 22);
|
|
|
|
|
|
neroDaov2.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
neroDaov2.Upc = new byte[14];
|
2017-12-24 00:12:31 +00:00
|
|
|
|
Array.Copy(tmpbuffer, 4, neroDaov2.Upc, 0, 14);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
neroDaov2.TocType = BigEndianBitConverter.ToUInt16(tmpbuffer, 18);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroDaov2.FirstTrack = tmpbuffer[20];
|
2018-01-01 21:32:12 +00:00
|
|
|
|
neroDaov2.LastTrack = tmpbuffer[21];
|
|
|
|
|
|
neroDaov2.Tracks = new List<NeroV2DaoEntry>();
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(!imageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN))
|
|
|
|
|
|
imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc))
|
|
|
|
|
|
imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
upc = neroDaov2.Upc;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.ChunkSizeLe = {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
neroDaov2.ChunkSizeLe);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.UPC = \"{0}\"",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
StringHandlers.CToString(neroDaov2.Upc));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.TocType = 0x{0:X4}",
|
|
|
|
|
|
neroDaov2.TocType);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.FirstTrack = {0}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
neroDaov2.FirstTrack);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.LastTrack = {0}", neroDaov2.LastTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
tmpbuffer = new byte[42];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
for(int i = 0; i < neroDaov2.ChunkSizeBe - 22; i += 42)
|
|
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var entry = new NeroV2DaoEntry();
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Read(tmpbuffer, 0, 42);
|
|
|
|
|
|
entry.Isrc = new byte[12];
|
|
|
|
|
|
Array.Copy(tmpbuffer, 4, entry.Isrc, 0, 12);
|
|
|
|
|
|
entry.SectorSize = BigEndianBitConverter.ToUInt16(tmpbuffer, 12);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Mode = BitConverter.ToUInt16(tmpbuffer, 14);
|
|
|
|
|
|
entry.Unknown = BigEndianBitConverter.ToUInt16(tmpbuffer, 16);
|
|
|
|
|
|
entry.Index0 = BigEndianBitConverter.ToUInt64(tmpbuffer, 18);
|
|
|
|
|
|
entry.Index1 = BigEndianBitConverter.ToUInt64(tmpbuffer, 26);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
entry.EndOfTrack = BigEndianBitConverter.ToUInt64(tmpbuffer, 34);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", (i / 32) + 1);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", (i / 32) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
StringHandlers.CToString(entry.Isrc));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].SectorSize = {1}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, entry.SectorSize);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, (DaoMode)entry.Mode, entry.Mode);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = {1:X2}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, entry.Unknown);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", (i / 32) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Index0);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", (i / 32) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Index1);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, entry.EndOfTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroDaov2.Tracks.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(entry.SectorSize > imageInfo.SectorSize)
|
|
|
|
|
|
imageInfo.SectorSize = entry.SectorSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
trackIsrCs.Add(currenttrack, entry.Isrc);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(currenttrack == 1)
|
|
|
|
|
|
entry.Index0 = entry.Index1;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var neroTrack = new NeroTrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-06-14 23:45:26 +01:00
|
|
|
|
EndOfTrack = entry.EndOfTrack, Isrc = entry.Isrc,
|
|
|
|
|
|
Length = entry.EndOfTrack - entry.Index0, Mode = entry.Mode, Offset = entry.Index0,
|
|
|
|
|
|
SectorSize = entry.SectorSize, StartLba = imageInfo.Sectors, Index0 = entry.Index0,
|
|
|
|
|
|
Index1 = entry.Index1, Sequence = currenttrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTrack.Sectors = neroTrack.Length / entry.SectorSize;
|
|
|
|
|
|
neroTracks.Add(currenttrack, neroTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.Sectors += neroTrack.Sectors;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
currenttrack++;
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_CDTEXT:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"CDTX\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroCdtxt = new NeroCdText
|
|
|
|
|
|
{
|
2018-12-31 13:17:27 +00:00
|
|
|
|
ChunkId = chunkId, ChunkSize = chunkLength, Packs = new List<NeroCdTextPack>()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[18];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
for(int i = 0; i < neroCdtxt.ChunkSize; i += 18)
|
|
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var entry = new NeroCdTextPack();
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Read(tmpbuffer, 0, 18);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.PackType = tmpbuffer[0];
|
2017-12-24 00:12:31 +00:00
|
|
|
|
entry.TrackNumber = tmpbuffer[1];
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.PackNumber = tmpbuffer[2];
|
2017-12-24 00:12:31 +00:00
|
|
|
|
entry.BlockNumber = tmpbuffer[3];
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Text = new byte[12];
|
2017-12-24 00:12:31 +00:00
|
|
|
|
Array.Copy(tmpbuffer, 4, entry.Text, 0, 12);
|
|
|
|
|
|
entry.Crc = BigEndianBitConverter.ToUInt16(tmpbuffer, 16);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "CD-TEXT entry {0}", (i / 18) + 1);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].PackType = 0x{1:X2}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 18) + 1, entry.PackType);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = 0x{1:X2}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 18) + 1, entry.TrackNumber);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].PackNumber = 0x{1:X2}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 18) + 1, entry.PackNumber);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].BlockNumber = 0x{1:X2}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 18) + 1, entry.BlockNumber);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Text = \"{1}\"", (i / 18) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
StringHandlers.CToString(entry.Text));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].CRC = 0x{1:X4}", (i / 18) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Crc);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroCdtxt.Packs.Add(entry);
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_TAO_V1:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"ETNF\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTaov1 = new NeroV1Tao
|
|
|
|
|
|
{
|
2018-12-31 13:17:27 +00:00
|
|
|
|
ChunkId = chunkId, ChunkSize = chunkLength, Tracks = new List<NeroV1TaoEntry>()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[20];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
for(int i = 0; i < neroTaov1.ChunkSize; i += 20)
|
|
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var entry = new NeroV1TaoEntry();
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Read(tmpbuffer, 0, 20);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Offset = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
|
|
|
|
|
entry.Length = BigEndianBitConverter.ToUInt32(tmpbuffer, 4);
|
|
|
|
|
|
entry.Mode = BigEndianBitConverter.ToUInt32(tmpbuffer, 8);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
entry.StartLba = BigEndianBitConverter.ToUInt32(tmpbuffer, 12);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 16);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", (i / 20) + 1);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", (i / 20) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Offset);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 20) + 1, entry.Length);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 20) + 1, (DaoMode)entry.Mode, entry.Mode);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", (i / 20) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.StartLba);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 20) + 1, entry.Unknown);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTaov1.Tracks.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(NeroTrackModeToBytesPerSector((DaoMode)entry.Mode) > imageInfo.SectorSize)
|
|
|
|
|
|
imageInfo.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var neroTrack = new NeroTrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
EndOfTrack = entry.Offset + entry.Length, Isrc = new byte[12],
|
|
|
|
|
|
Length = entry.Length, Mode = entry.Mode, Offset = entry.Offset,
|
2017-12-24 00:12:31 +00:00
|
|
|
|
SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode),
|
2020-01-11 22:44:25 +00:00
|
|
|
|
StartLba = imageInfo.Sectors, Index0 = entry.Offset, Index1 = entry.Offset,
|
2018-01-01 21:32:12 +00:00
|
|
|
|
Sequence = currenttrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTrack.Sectors =
|
|
|
|
|
|
neroTrack.Length / NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTracks.Add(currenttrack, neroTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.Sectors += neroTrack.Sectors;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
currenttrack++;
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_TAO_V2:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"ETN2\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTaov2 = new NeroV2Tao
|
|
|
|
|
|
{
|
2018-12-31 13:17:27 +00:00
|
|
|
|
ChunkId = chunkId, ChunkSize = chunkLength, Tracks = new List<NeroV2TaoEntry>()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[32];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
for(int i = 0; i < neroTaov2.ChunkSize; i += 32)
|
|
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var entry = new NeroV2TaoEntry();
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Read(tmpbuffer, 0, 32);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Offset = BigEndianBitConverter.ToUInt64(tmpbuffer, 0);
|
|
|
|
|
|
entry.Length = BigEndianBitConverter.ToUInt64(tmpbuffer, 8);
|
|
|
|
|
|
entry.Mode = BigEndianBitConverter.ToUInt32(tmpbuffer, 16);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
entry.StartLba = BigEndianBitConverter.ToUInt32(tmpbuffer, 20);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 24);
|
|
|
|
|
|
entry.Sectors = BigEndianBitConverter.ToUInt32(tmpbuffer, 28);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", (i / 32) + 1);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", (i / 32) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Offset);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, entry.Length);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, (DaoMode)entry.Mode, entry.Mode);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", (i / 32) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.StartLba);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(i / 32) + 1, entry.Unknown);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Sectors = {1}", (i / 32) + 1,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
entry.Sectors);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTaov2.Tracks.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(NeroTrackModeToBytesPerSector((DaoMode)entry.Mode) > imageInfo.SectorSize)
|
|
|
|
|
|
imageInfo.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var neroTrack = new NeroTrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
EndOfTrack = entry.Offset + entry.Length, Isrc = new byte[12],
|
|
|
|
|
|
Length = entry.Length, Mode = entry.Mode, Offset = entry.Offset
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTrack.Sectors =
|
|
|
|
|
|
neroTrack.Length / NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTrack.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
neroTrack.StartLba = imageInfo.Sectors;
|
|
|
|
|
|
neroTrack.Index0 = entry.Offset;
|
|
|
|
|
|
neroTrack.Index1 = entry.Offset;
|
|
|
|
|
|
neroTrack.Sequence = currenttrack;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroTracks.Add(currenttrack, neroTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.Sectors += neroTrack.Sectors;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
currenttrack++;
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_SESSION:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"SINF\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[4];
|
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 4);
|
2018-06-20 22:22:21 +01:00
|
|
|
|
uint sessionTracks = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroSessions.Add(currentsession, sessionTracks);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\tSession {0} has {1} tracks", currentsession,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
sessionTracks);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
currentsession++;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_DISC_TYPE:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"MTYP\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
neroMediaTyp = new NeroMediaType
|
|
|
|
|
|
{
|
|
|
|
|
|
ChunkId = chunkId, ChunkSize = chunkLength
|
|
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[4];
|
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 4);
|
|
|
|
|
|
neroMediaTyp.Type = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\tMedia type is {0} ({1})",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
(NeroMediaTypes)neroMediaTyp.Type, neroMediaTyp.Type);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = NeroMediaTypeToMediaType((NeroMediaTypes)neroMediaTyp.Type);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_DISC_INFO:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"DINF\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
neroDiscInfo = new NeroDiscInformation
|
|
|
|
|
|
{
|
|
|
|
|
|
ChunkId = chunkId, ChunkSize = chunkLength
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[4];
|
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 4);
|
|
|
|
|
|
neroDiscInfo.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\tneroDiscInfo.Unknown = 0x{0:X4} ({0})",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
neroDiscInfo.Unknown);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_RELOCATION:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"RELO\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
neroRelo = new NeroReloChunk
|
|
|
|
|
|
{
|
|
|
|
|
|
ChunkId = chunkId, ChunkSize = chunkLength
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[4];
|
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 4);
|
|
|
|
|
|
neroRelo.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\tneroRELO.Unknown = 0x{0:X4} ({0})",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
neroRelo.Unknown);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_TOC:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"TOCT\" chunk, parsing {0} bytes",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
neroToc = new NeroTocChunk
|
|
|
|
|
|
{
|
|
|
|
|
|
ChunkId = chunkId, ChunkSize = chunkLength
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] tmpbuffer = new byte[2];
|
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 2);
|
|
|
|
|
|
neroToc.Unknown = BigEndianBitConverter.ToUInt16(tmpbuffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\tneroTOC.Unknown = 0x{0:X4} ({0})",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
neroToc.Unknown);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case NERO_END:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Found \"END!\" chunk, finishing parse");
|
2017-12-24 00:12:31 +00:00
|
|
|
|
parsing = false;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
default:
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Unknown chunk ID \"{0}\", skipping...",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Encoding.ASCII.GetString(BigEndianBitConverter.
|
|
|
|
|
|
GetBytes(chunkId)));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
imageStream.Seek(chunkLength, SeekOrigin.Current);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-01 21:32:12 +00:00
|
|
|
|
imageInfo.HasPartitions = true;
|
|
|
|
|
|
imageInfo.HasSessions = true;
|
|
|
|
|
|
imageInfo.Creator = null;
|
|
|
|
|
|
imageInfo.CreationTime = imageFilter.GetCreationTime();
|
|
|
|
|
|
imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
|
|
|
|
|
|
imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
|
|
|
|
|
|
imageInfo.Comments = null;
|
|
|
|
|
|
imageInfo.MediaManufacturer = null;
|
|
|
|
|
|
imageInfo.MediaModel = null;
|
|
|
|
|
|
imageInfo.MediaSerialNumber = null;
|
|
|
|
|
|
imageInfo.MediaBarcode = null;
|
|
|
|
|
|
imageInfo.MediaPartNumber = null;
|
|
|
|
|
|
imageInfo.DriveManufacturer = null;
|
|
|
|
|
|
imageInfo.DriveModel = null;
|
|
|
|
|
|
imageInfo.DriveSerialNumber = null;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.DriveFirmwareRevision = null;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
imageInfo.MediaSequence = 0;
|
|
|
|
|
|
imageInfo.LastMediaSequence = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
if(imageNewFormat)
|
|
|
|
|
|
{
|
2018-01-01 21:32:12 +00:00
|
|
|
|
imageInfo.ImageSize = footerV2.FirstChunkOffset;
|
|
|
|
|
|
imageInfo.Version = "Nero Burning ROM >= 5.5";
|
|
|
|
|
|
imageInfo.Application = "Nero Burning ROM";
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.ApplicationVersion = ">= 5.5";
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2018-01-01 21:32:12 +00:00
|
|
|
|
imageInfo.ImageSize = footerV1.FirstChunkOffset;
|
|
|
|
|
|
imageInfo.Version = "Nero Burning ROM <= 5.0";
|
|
|
|
|
|
imageInfo.Application = "Nero Burning ROM";
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.ApplicationVersion = "<= 5.0";
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(neroSessions.Count == 0)
|
|
|
|
|
|
neroSessions.Add(1, currenttrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "Building offset, track and session maps");
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
currentsession = 1;
|
|
|
|
|
|
neroSessions.TryGetValue(1, out uint currentsessionmaxtrack);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
uint currentsessioncurrenttrack = 1;
|
|
|
|
|
|
var currentsessionstruct = new Session();
|
|
|
|
|
|
ulong partitionSequence = 0;
|
|
|
|
|
|
ulong partitionStartByte = 0;
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
for(uint i = 1; i <= neroTracks.Count; i++)
|
2014-07-09 19:52:00 +01:00
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(!neroTracks.TryGetValue(i, out NeroTrack neroTrack))
|
|
|
|
|
|
continue;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\tcurrentsession = {0}", currentsession);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\tcurrentsessionmaxtrack = {0}", currentsessionmaxtrack);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\tcurrentsessioncurrenttrack = {0}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
currentsessioncurrenttrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var track = new Track();
|
|
|
|
|
|
|
|
|
|
|
|
if(neroTrack.Sequence == 1)
|
|
|
|
|
|
neroTrack.Index0 = neroTrack.Index1;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
if(neroTrack.Index0 < neroTrack.Index1)
|
2020-06-17 21:32:19 +01:00
|
|
|
|
track.Indexes.Add(0, (int)(neroTrack.Index0 / neroTrack.SectorSize));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-06-17 21:32:19 +01:00
|
|
|
|
track.Indexes.Add(1, (int)(neroTrack.Index1 / neroTrack.SectorSize));
|
2020-01-11 22:44:25 +00:00
|
|
|
|
track.TrackDescription = StringHandlers.CToString(neroTrack.Isrc);
|
|
|
|
|
|
track.TrackEndSector = ((neroTrack.Length / neroTrack.SectorSize) + neroTrack.StartLba) - 1;
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
track.TrackPregap = (neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackSequence = neroTrack.Sequence;
|
|
|
|
|
|
track.TrackSession = currentsession;
|
|
|
|
|
|
track.TrackStartSector = neroTrack.StartLba;
|
|
|
|
|
|
track.TrackType = NeroTrackModeToTrackType((DaoMode)neroTrack.Mode);
|
|
|
|
|
|
track.TrackFile = imageFilter.GetFilename();
|
|
|
|
|
|
track.TrackFilter = imageFilter;
|
|
|
|
|
|
track.TrackFileOffset = neroTrack.Offset;
|
|
|
|
|
|
track.TrackFileType = "BINARY";
|
2017-12-24 00:12:31 +00:00
|
|
|
|
track.TrackSubchannelType = TrackSubchannelType.None;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
switch((DaoMode)neroTrack.Mode)
|
2014-07-09 19:52:00 +01:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.Audio:
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackBytesPerSector = 2352;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
track.TrackRawBytesPerSector = 2352;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case DaoMode.AudioSub:
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackBytesPerSector = 2352;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
track.TrackRawBytesPerSector = 2448;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case DaoMode.Data:
|
|
|
|
|
|
case DaoMode.DataM2F1:
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackBytesPerSector = 2048;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
track.TrackRawBytesPerSector = 2048;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case DaoMode.DataM2F2:
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackBytesPerSector = 2336;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
track.TrackRawBytesPerSector = 2336;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case DaoMode.DataM2Raw:
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackBytesPerSector = 2352;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
track.TrackRawBytesPerSector = 2352;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case DaoMode.DataM2RawSub:
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackBytesPerSector = 2352;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
track.TrackRawBytesPerSector = 2448;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case DaoMode.DataRaw:
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackBytesPerSector = 2048;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
track.TrackRawBytesPerSector = 2352;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case DaoMode.DataRawSub:
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackBytesPerSector = 2048;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
track.TrackRawBytesPerSector = 2448;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
if(track.TrackSubchannelType == TrackSubchannelType.RawInterleaved)
|
|
|
|
|
|
{
|
|
|
|
|
|
track.TrackSubchannelFilter = imageFilter;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
track.TrackSubchannelFile = imageFilter.GetFilename();
|
2017-12-24 00:12:31 +00:00
|
|
|
|
track.TrackSubchannelOffset = neroTrack.Offset;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2018-01-01 21:32:12 +00:00
|
|
|
|
Tracks.Add(track);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackDescription = {0}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
track.TrackDescription);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackEndSector = {0}", track.TrackEndSector);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackPregap = {0}", track.TrackPregap);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackSequence = {0}", track.TrackSequence);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackSession = {0}", track.TrackSession);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackStartSector = {0}",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
track.TrackStartSector);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackType = {0}", track.TrackType);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
if(currentsessioncurrenttrack == 1)
|
|
|
|
|
|
currentsessionstruct = new Session
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
SessionSequence = currentsession, StartSector = track.TrackStartSector,
|
2018-01-01 21:32:12 +00:00
|
|
|
|
StartTrack = track.TrackSequence
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
currentsessioncurrenttrack++;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
if(currentsessioncurrenttrack > currentsessionmaxtrack)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentsession++;
|
|
|
|
|
|
neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
currentsessioncurrenttrack = 1;
|
|
|
|
|
|
currentsessionstruct.EndTrack = track.TrackSequence;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
currentsessionstruct.EndSector = track.TrackEndSector;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
Sessions.Add(currentsessionstruct);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
if(i == neroTracks.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack);
|
2018-01-01 21:32:12 +00:00
|
|
|
|
currentsessioncurrenttrack = 1;
|
|
|
|
|
|
currentsessionstruct.EndTrack = track.TrackSequence;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
currentsessionstruct.EndSector = track.TrackEndSector;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
Sessions.Add(currentsessionstruct);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
offsetmap.Add(track.TrackSequence, track.TrackStartSector);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\t\t Offset[{0}]: {1}", track.TrackSequence,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
track.TrackStartSector);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
/*if(_neroTrack.Index0 < _neroTrack.Index1)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
partition = new Partition();
|
|
|
|
|
|
partition.PartitionDescription = string.Format("Track {0} Index 0", _track.TrackSequence);
|
|
|
|
|
|
partition.PartitionLength = (_neroTrack.Index1 - _neroTrack.Index0);
|
|
|
|
|
|
partition.PartitionName = StringHandlers.CToString(_neroTrack.ISRC);
|
|
|
|
|
|
partition.PartitionSectors = partition.PartitionLength / _neroTrack.SectorSize;
|
|
|
|
|
|
partition.PartitionSequence = PartitionSequence;
|
|
|
|
|
|
partition.PartitionStart = _neroTrack.Index0;
|
|
|
|
|
|
partition.PartitionStartSector = _neroTrack.StartLBA;
|
|
|
|
|
|
partition.PartitionType = NeroTrackModeToTrackType((DAOMode)_neroTrack.Mode).ToString();
|
|
|
|
|
|
ImagePartitions.Add(partition);
|
|
|
|
|
|
PartitionSequence++;
|
|
|
|
|
|
}*/
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var partition = new Partition
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
Description = $"Track {track.TrackSequence} Index 1",
|
2020-06-14 23:45:26 +01:00
|
|
|
|
Size = neroTrack.EndOfTrack - neroTrack.Index1, Name = StringHandlers.CToString(neroTrack.Isrc),
|
|
|
|
|
|
Sequence = partitionSequence, Offset = partitionStartByte,
|
|
|
|
|
|
Start = neroTrack.StartLba + ((neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize),
|
2020-01-11 22:44:25 +00:00
|
|
|
|
Type = NeroTrackModeToTrackType((DaoMode)neroTrack.Mode).ToString()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
partition.Length = partition.Size / neroTrack.SectorSize;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
Partitions.Add(partition);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
partitionSequence++;
|
|
|
|
|
|
partitionStartByte += partition.Size;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
neroFilter = imageFilter;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(imageInfo.MediaType == MediaType.Unknown ||
|
|
|
|
|
|
imageInfo.MediaType == MediaType.CD)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2018-01-01 21:32:12 +00:00
|
|
|
|
bool data = false;
|
|
|
|
|
|
bool mode2 = false;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
bool firstaudio = false;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
bool firstdata = false;
|
|
|
|
|
|
bool audio = false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
for(int i = 0; i < neroTracks.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// First track is audio
|
2018-06-22 08:08:38 +01:00
|
|
|
|
firstaudio |= i == 0 && ((DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio ||
|
|
|
|
|
|
(DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioSub);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
// First track is data
|
2020-06-14 23:45:26 +01:00
|
|
|
|
firstdata |= i == 0 && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio &&
|
2017-12-24 00:12:31 +00:00
|
|
|
|
(DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
// Any non first track is data
|
2020-06-14 23:45:26 +01:00
|
|
|
|
data |= i != 0 && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio &&
|
2017-12-24 00:12:31 +00:00
|
|
|
|
(DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
// Any non first track is audio
|
2018-06-22 08:08:38 +01:00
|
|
|
|
audio |= i != 0 && ((DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio ||
|
|
|
|
|
|
(DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioSub);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
switch((DaoMode)neroTracks.ElementAt(i).Value.Mode)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.DataM2F1:
|
|
|
|
|
|
case DaoMode.DataM2F2:
|
|
|
|
|
|
case DaoMode.DataM2Raw:
|
|
|
|
|
|
case DaoMode.DataM2RawSub:
|
|
|
|
|
|
mode2 = true;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(!data &&
|
|
|
|
|
|
!firstdata)
|
2018-06-22 08:08:38 +01:00
|
|
|
|
imageInfo.MediaType = MediaType.CDDA;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
else if(firstaudio &&
|
|
|
|
|
|
data &&
|
|
|
|
|
|
Sessions.Count > 1 &&
|
|
|
|
|
|
mode2)
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.CDPLUS;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
else if((firstdata && audio) || mode2)
|
2018-01-01 21:32:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.CDROMXA;
|
|
|
|
|
|
else if(!audio)
|
2020-01-11 22:44:25 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.CDROM;
|
|
|
|
|
|
else
|
|
|
|
|
|
imageInfo.MediaType = MediaType.CD;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.XmlMediaType = XmlMediaType.OpticalDisc;
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.VerboseWriteLine("Nero image contains a disc of type {0}", imageInfo.MediaType);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWrite("Nero plugin", "Exception ocurred opening file.");
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadDiskTag(MediaTagType tag)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
switch(tag)
|
|
|
|
|
|
{
|
2018-01-01 21:32:12 +00:00
|
|
|
|
case MediaTagType.CD_MCN: return upc;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case MediaTagType.CD_TEXT: throw new NotImplementedException("Not yet implemented");
|
|
|
|
|
|
default:
|
|
|
|
|
|
throw new FeaturedNotSupportedByDiscImageException("Requested disk tag not supported by image");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public byte[] ReadSector(ulong sectorAddress) => ReadSectors(sectorAddress, 1);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public byte[] ReadSector(ulong sectorAddress, uint track) => ReadSectors(sectorAddress, 1, track);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag) =>
|
|
|
|
|
|
ReadSectorsTag(sectorAddress, 1, track, tag);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-01-11 22:44:25 +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
|
2018-01-01 21:32:12 +00:00
|
|
|
|
where sectorAddress - kvp.Value <
|
2020-01-11 22:44:25 +00:00
|
|
|
|
track.TrackEndSector - track.TrackStartSector select kvp)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found");
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-01-11 22:44:25 +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
|
2018-01-01 21:32:12 +00:00
|
|
|
|
where sectorAddress - kvp.Value <
|
2020-01-11 22:44:25 +00:00
|
|
|
|
track.TrackEndSector - track.TrackStartSector select kvp)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found");
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-02-28 00:19:50 +00:00
|
|
|
|
if(!neroTracks.TryGetValue(track, out NeroTrack aaruTrack))
|
2017-12-24 00:12:31 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track not found");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-02-28 00:19:50 +00:00
|
|
|
|
if(length > aaruTrack.Sectors)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
2020-02-28 00:19:50 +00:00
|
|
|
|
$"Requested more sectors ({length}) than present in track ({aaruTrack.Sectors}), won't cross tracks");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
uint sectorOffset;
|
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
|
uint sectorSkip;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
bool mode2 = false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-02-28 00:19:50 +00:00
|
|
|
|
switch((DaoMode)aaruTrack.Mode)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
case DaoMode.Data:
|
|
|
|
|
|
case DaoMode.DataM2F1:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 0;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.DataM2F2:
|
|
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
mode2 = true;
|
|
|
|
|
|
sectorOffset = 0;
|
|
|
|
|
|
sectorSize = 2336;
|
|
|
|
|
|
sectorSkip = 0;
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.Audio:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 0;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 2352;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.DataRaw:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 16;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
|
sectorSkip = 288;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.DataM2Raw:
|
|
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
mode2 = true;
|
|
|
|
|
|
sectorOffset = 0;
|
|
|
|
|
|
sectorSize = 2352;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
// TODO: Supposing Nero suffixes the subchannel to the channel
|
|
|
|
|
|
case DaoMode.DataRawSub:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 16;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
|
sectorSkip = 288 + 96;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.DataM2RawSub:
|
|
|
|
|
|
{
|
2020-01-11 22:44:25 +00:00
|
|
|
|
mode2 = true;
|
|
|
|
|
|
sectorOffset = 0;
|
|
|
|
|
|
sectorSize = 2352;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSkip = 96;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.AudioSub:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 0;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 2352;
|
|
|
|
|
|
sectorSkip = 96;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
imageStream = neroFilter.GetDataForkStream();
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var br = new BinaryReader(imageStream);
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
br.BaseStream.
|
|
|
|
|
|
Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
|
|
|
|
|
SeekOrigin.Begin);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
|
|
|
|
|
if(mode2)
|
|
|
|
|
|
{
|
|
|
|
|
|
var mode2Ms = new MemoryStream((int)(sectorSize * length));
|
|
|
|
|
|
|
|
|
|
|
|
buffer = br.ReadBytes((int)((sectorSize + sectorSkip) * length));
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] sector = new byte[sectorSize];
|
|
|
|
|
|
Array.Copy(buffer, (sectorSize + sectorSkip) * i, sector, 0, sectorSize);
|
|
|
|
|
|
sector = Sector.GetUserDataFromMode2(sector);
|
|
|
|
|
|
mode2Ms.Write(sector, 0, sector.Length);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
buffer = mode2Ms.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(sectorOffset == 0 &&
|
|
|
|
|
|
sectorSkip == 0)
|
|
|
|
|
|
buffer = br.ReadBytes((int)(sectorSize * length));
|
2017-12-24 00:12:31 +00:00
|
|
|
|
else
|
|
|
|
|
|
for(int i = 0; i < length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
|
|
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
|
|
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
|
|
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return buffer;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-06-14 23:45:26 +01:00
|
|
|
|
if(tag == SectorTagType.CdTrackFlags ||
|
|
|
|
|
|
tag == SectorTagType.CdTrackIsrc)
|
|
|
|
|
|
track = (uint)sectorAddress;
|
|
|
|
|
|
|
2020-02-28 00:19:50 +00:00
|
|
|
|
if(!neroTracks.TryGetValue(track, out NeroTrack aaruTrack))
|
2017-12-24 00:12:31 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track not found");
|
2017-12-20 17:15:26 +00:00
|
|
|
|
|
2020-02-28 00:19:50 +00:00
|
|
|
|
if(length > aaruTrack.Sectors)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
2020-02-28 00:19:50 +00:00
|
|
|
|
$"Requested more sectors ({length}) than present in track ({aaruTrack.Sectors}), won't cross tracks");
|
2017-12-20 17:15:26 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
uint sectorOffset;
|
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
|
uint sectorSkip;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
switch(tag)
|
|
|
|
|
|
{
|
|
|
|
|
|
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:
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] flags = new byte[1];
|
2018-06-22 08:08:38 +01:00
|
|
|
|
flags[0] = 0x00;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
|
2020-02-28 00:19:50 +00:00
|
|
|
|
if((DaoMode)aaruTrack.Mode != DaoMode.Audio &&
|
|
|
|
|
|
(DaoMode)aaruTrack.Mode != DaoMode.AudioSub)
|
2018-01-01 21:32:12 +00:00
|
|
|
|
flags[0] += 0x4;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return flags;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2020-02-28 00:19:50 +00:00
|
|
|
|
case SectorTagType.CdTrackIsrc: return aaruTrack.Isrc;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdTrackText:
|
|
|
|
|
|
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
|
|
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-02-28 00:19:50 +00:00
|
|
|
|
switch((DaoMode)aaruTrack.Mode)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
case DaoMode.Data:
|
|
|
|
|
|
case DaoMode.DataM2F1: throw new ArgumentException("No tags in image for requested track", nameof(tag));
|
|
|
|
|
|
case DaoMode.DataM2F2:
|
|
|
|
|
|
{
|
|
|
|
|
|
switch(tag)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SectorTagType.CdSectorSync:
|
|
|
|
|
|
case SectorTagType.CdSectorHeader:
|
|
|
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
|
case SectorTagType.CdSectorEcc:
|
|
|
|
|
|
case SectorTagType.CdSectorEccP:
|
|
|
|
|
|
case SectorTagType.CdSectorEccQ:
|
|
|
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
|
|
|
|
|
case SectorTagType.CdSectorSubHeader:
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
sectorOffset = 0;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 8;
|
|
|
|
|
|
sectorSkip = 2328;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorEdc:
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
sectorOffset = 2332;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 4;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.Audio: throw new ArgumentException("There are no tags on audio tracks", nameof(tag));
|
|
|
|
|
|
case DaoMode.DataRaw:
|
|
|
|
|
|
{
|
|
|
|
|
|
switch(tag)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SectorTagType.CdSectorSync:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 0;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 12;
|
|
|
|
|
|
sectorSkip = 2340;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorHeader:
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
sectorOffset = 12;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 4;
|
|
|
|
|
|
sectorSkip = 2336;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
|
case SectorTagType.CdSectorSubHeader:
|
|
|
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
|
|
|
|
|
case SectorTagType.CdSectorEcc:
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
sectorOffset = 2076;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 276;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorEccP:
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
sectorOffset = 2076;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 172;
|
|
|
|
|
|
sectorSkip = 104;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorEccQ:
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
sectorOffset = 2248;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 104;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorEdc:
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
sectorOffset = 2064;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 4;
|
|
|
|
|
|
sectorSkip = 284;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2014-07-09 19:52:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
// TODO
|
|
|
|
|
|
case DaoMode.DataM2RawSub:
|
|
|
|
|
|
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
|
|
|
|
|
|
case DaoMode.DataRawSub:
|
2014-07-09 19:52:00 +01:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
switch(tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorSync:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 0;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 12;
|
|
|
|
|
|
sectorSkip = 2340 + 96;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorHeader:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 12;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 4;
|
|
|
|
|
|
sectorSkip = 2336 + 96;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 2352;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 96;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorSubHeader:
|
|
|
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
|
|
|
|
|
case SectorTagType.CdSectorEcc:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 2076;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 276;
|
|
|
|
|
|
sectorSkip = 0 + 96;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorEccP:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 2076;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 172;
|
|
|
|
|
|
sectorSkip = 104 + 96;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorEccQ:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 2248;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 104;
|
|
|
|
|
|
sectorSkip = 0 + 96;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case SectorTagType.CdSectorEdc:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 2064;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 4;
|
|
|
|
|
|
sectorSkip = 284 + 96;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2017-12-21 06:06:19 +00:00
|
|
|
|
}
|
2015-12-06 05:09:31 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.AudioSub:
|
|
|
|
|
|
{
|
|
|
|
|
|
if(tag != SectorTagType.CdSectorSubchannel)
|
|
|
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
sectorOffset = 2352;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 96;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
|
|
|
|
|
}
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
imageStream = neroFilter.GetDataForkStream();
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var br = new BinaryReader(imageStream);
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
br.BaseStream.
|
|
|
|
|
|
Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
|
|
|
|
|
SeekOrigin.Begin);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
|
|
|
|
|
if(sectorOffset == 0 &&
|
|
|
|
|
|
sectorSkip == 0)
|
|
|
|
|
|
buffer = br.ReadBytes((int)(sectorSize * length));
|
2017-12-24 00:12:31 +00:00
|
|
|
|
else
|
|
|
|
|
|
for(int i = 0; i < length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
|
|
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
|
|
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
|
|
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return buffer;
|
|
|
|
|
|
}
|
2016-08-08 18:44:08 +01:00
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress) => ReadSectorsLong(sectorAddress, 1);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress, uint track) => ReadSectorsLong(sectorAddress, 1, track);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsLong(ulong sectorAddress, uint length)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-01-11 22:44:25 +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
|
2020-03-09 22:23:24 +00:00
|
|
|
|
where sectorAddress - kvp.Value <=
|
2020-01-11 22:44:25 +00:00
|
|
|
|
track.TrackEndSector - track.TrackStartSector select kvp)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found");
|
|
|
|
|
|
}
|
2015-12-05 17:21:47 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-02-28 00:19:50 +00:00
|
|
|
|
if(!neroTracks.TryGetValue(track, out NeroTrack aaruTrack))
|
2017-12-24 00:12:31 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track not found");
|
2016-08-08 18:44:08 +01:00
|
|
|
|
|
2020-02-28 00:19:50 +00:00
|
|
|
|
if(length > aaruTrack.Sectors)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
2020-02-28 00:19:50 +00:00
|
|
|
|
$"Requested more sectors ({length}) than present in track ({aaruTrack.Sectors}), won't cross tracks");
|
2016-08-08 18:44:08 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
uint sectorOffset;
|
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
|
uint sectorSkip;
|
2016-08-08 18:44:08 +01:00
|
|
|
|
|
2020-02-28 00:19:50 +00:00
|
|
|
|
switch((DaoMode)aaruTrack.Mode)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
case DaoMode.Data:
|
|
|
|
|
|
case DaoMode.DataM2F1:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 0;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.DataM2F2:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 0;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 2336;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.DataRaw:
|
|
|
|
|
|
case DaoMode.DataM2Raw:
|
|
|
|
|
|
case DaoMode.Audio:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 0;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 2352;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case DaoMode.DataRawSub:
|
|
|
|
|
|
case DaoMode.DataM2RawSub:
|
|
|
|
|
|
case DaoMode.AudioSub:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 0;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
sectorSize = 2448;
|
|
|
|
|
|
sectorSkip = 0;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
|
|
|
|
|
}
|
2016-08-08 18:44:08 +01:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2016-08-08 18:44:08 +01:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
imageStream = neroFilter.GetDataForkStream();
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var br = new BinaryReader(imageStream);
|
2016-08-08 18:44:08 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
br.BaseStream.
|
|
|
|
|
|
Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
|
|
|
|
|
SeekOrigin.Begin);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(sectorOffset == 0 &&
|
|
|
|
|
|
sectorSkip == 0)
|
|
|
|
|
|
buffer = br.ReadBytes((int)(sectorSize * length));
|
2017-12-24 00:12:31 +00:00
|
|
|
|
else
|
|
|
|
|
|
for(int i = 0; i < length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
|
|
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
|
|
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
|
|
|
|
|
|
|
|
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
2016-08-08 18:44:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return buffer;
|
|
|
|
|
|
}
|
2015-12-05 17:21:47 +00:00
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public List<Track> GetSessionTracks(Session session) => GetSessionTracks(session.SessionSequence);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
public List<Track> GetSessionTracks(ushort session) =>
|
|
|
|
|
|
Tracks.Where(track => track.TrackSession == session).ToList();
|
2014-07-09 19:52:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|