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-12-31 23:08:23 +00:00
|
|
|
|
// Copyright © 2011-2021 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;
|
2020-07-20 15:43:52 +01:00
|
|
|
|
using Aaru.Helpers;
|
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
|
|
|
|
{
|
2020-07-22 13:20:25 +01:00
|
|
|
|
public sealed 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
|
|
|
|
|
|
{
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Look for the footer
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageStream = imageFilter.GetDataForkStream();
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var footerV1 = new FooterV1();
|
|
|
|
|
|
var footerV2 = new FooterV2();
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageStream.Seek(-8, SeekOrigin.End);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
byte[] buffer = new byte[8];
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_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
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageStream.Seek(-12, SeekOrigin.End);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
buffer = new byte[12];
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_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-07-20 21:11:32 +01: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
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Check footer version
|
2020-01-11 22:44:25 +00:00
|
|
|
|
if(footerV1.ChunkId == NERO_FOOTER_V1 &&
|
2020-07-20 21:11:32 +01:00
|
|
|
|
footerV1.FirstChunkOffset < (ulong)_imageStream.Length)
|
|
|
|
|
|
_imageNewFormat = false;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
else if(footerV2.ChunkId == NERO_FOOTER_V2 &&
|
2020-07-20 21:11:32 +01:00
|
|
|
|
footerV2.FirstChunkOffset < (ulong)_imageStream.Length)
|
|
|
|
|
|
_imageNewFormat = true;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
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
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Seek to first chunk
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(_imageNewFormat)
|
|
|
|
|
|
_imageStream.Seek((long)footerV2.FirstChunkOffset, SeekOrigin.Begin);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
else
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_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;
|
2020-11-11 04:19:18 +00:00
|
|
|
|
ushort currentSession = 1;
|
|
|
|
|
|
uint currentTrack = 1;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
Tracks = new List<Track>();
|
|
|
|
|
|
_trackIsrCs = new Dictionary<uint, byte[]>();
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_imageInfo.MediaType = CommonTypes.MediaType.CD;
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageInfo.Sectors = 0;
|
|
|
|
|
|
_imageInfo.SectorSize = 0;
|
2020-06-21 01:30:30 +01:00
|
|
|
|
ulong currentSector = 0;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Parse chunks
|
2017-12-24 00:12:31 +00:00
|
|
|
|
while(parsing)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] chunkHeaderBuffer = new byte[8];
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01: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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var newCuesheetV1 = new CuesheetV1
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSize = chunkLength,
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Entries = new List<CueEntryV1>()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[8];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-06-21 01:30:30 +01:00
|
|
|
|
for(int i = 0; i < newCuesheetV1.ChunkSize; i += 8)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var entry = new CueEntryV1();
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 8);
|
2021-06-11 01:32:51 +01:00
|
|
|
|
entry.Mode = tmpBuffer[0];
|
|
|
|
|
|
|
|
|
|
|
|
entry.TrackNumber = (byte)((((tmpBuffer[1] & 0xF0) >> 4) * 10) + (tmpBuffer[1] & 0xF));
|
|
|
|
|
|
entry.IndexNumber = (byte)((((tmpBuffer[2] & 0xF0) >> 4) * 10) + (tmpBuffer[2] & 0xF));
|
2020-11-11 04:19:18 +00:00
|
|
|
|
entry.Dummy = BigEndianBitConverter.ToUInt16(tmpBuffer, 3);
|
2021-06-11 01:32:51 +01:00
|
|
|
|
entry.Minute = (byte)((((tmpBuffer[5] & 0xF0) >> 4) * 10) + (tmpBuffer[5] & 0xF));
|
|
|
|
|
|
entry.Second = (byte)((((tmpBuffer[6] & 0xF0) >> 4) * 10) + (tmpBuffer[6] & 0xF));
|
|
|
|
|
|
entry.Frame = (byte)((((tmpBuffer[7] & 0xF0) >> 4) * 10) + (tmpBuffer[7] & 0xF));
|
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
|
|
|
|
|
2020-06-21 01:30:30 +01:00
|
|
|
|
newCuesheetV1.Entries.Add(entry);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
if(_cuesheetV1 is null)
|
|
|
|
|
|
_cuesheetV1 = newCuesheetV1;
|
2020-06-21 01:30:30 +01:00
|
|
|
|
else
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_cuesheetV1.Entries.AddRange(newCuesheetV1.Entries);
|
2020-06-21 01:30:30 +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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var newCuesheetV2 = new CuesheetV2
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSize = chunkLength,
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Entries = new List<CueEntryV2>()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[8];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-06-21 01:30:30 +01:00
|
|
|
|
for(int i = 0; i < newCuesheetV2.ChunkSize; i += 8)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var entry = new CueEntryV2();
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 8);
|
|
|
|
|
|
entry.Mode = tmpBuffer[0];
|
2021-06-11 01:32:51 +01:00
|
|
|
|
entry.TrackNumber = (byte)((((tmpBuffer[1] & 0xF0) >> 4) * 10) + (tmpBuffer[1] & 0xF));
|
|
|
|
|
|
;
|
|
|
|
|
|
entry.IndexNumber = (byte)((((tmpBuffer[2] & 0xF0) >> 4) * 10) + (tmpBuffer[2] & 0xF));
|
|
|
|
|
|
;
|
|
|
|
|
|
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
|
|
|
|
|
2020-06-21 01:30:30 +01:00
|
|
|
|
newCuesheetV2.Entries.Add(entry);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
if(_cuesheetV2 is null)
|
|
|
|
|
|
_cuesheetV2 = newCuesheetV2;
|
2020-06-21 01:30:30 +01:00
|
|
|
|
else
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_cuesheetV2.Entries.AddRange(newCuesheetV2.Entries);
|
2020-06-21 01:30:30 +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-11-11 04:19:18 +00:00
|
|
|
|
_neroDaov1 = new DaoV1
|
2020-01-11 22:44:25 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSizeBe = chunkLength
|
2020-01-11 22:44:25 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[22];
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 22);
|
|
|
|
|
|
_neroDaov1.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpBuffer, 0);
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_neroDaov1.Upc = new byte[14];
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Array.Copy(tmpBuffer, 4, _neroDaov1.Upc, 0, 14);
|
|
|
|
|
|
_neroDaov1.TocType = BigEndianBitConverter.ToUInt16(tmpBuffer, 18);
|
|
|
|
|
|
_neroDaov1.FirstTrack = tmpBuffer[20];
|
|
|
|
|
|
_neroDaov1.LastTrack = tmpBuffer[21];
|
|
|
|
|
|
_neroDaov1.Tracks = new List<DaoEntryV1>();
|
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-07-20 21:11:32 +01: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-07-20 21:11:32 +01: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}",
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_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-07-20 21:11:32 +01:00
|
|
|
|
_neroDaov1.FirstTrack);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.LastTrack = {0}",
|
|
|
|
|
|
_neroDaov1.LastTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_upc = _neroDaov1.Upc;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
tmpBuffer = new byte[30];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
for(int i = 0; i < _neroDaov1.ChunkSizeBe - 22; i += 30)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var entry = new DaoEntryV1();
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 30);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
entry.Isrc = new byte[12];
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Array.Copy(tmpBuffer, 4, entry.Isrc, 0, 12);
|
|
|
|
|
|
entry.SectorSize = BigEndianBitConverter.ToUInt16(tmpBuffer, 12);
|
|
|
|
|
|
entry.Mode = BitConverter.ToUInt16(tmpBuffer, 14);
|
|
|
|
|
|
entry.Unknown = BigEndianBitConverter.ToUInt16(tmpBuffer, 16);
|
|
|
|
|
|
entry.Index0 = BigEndianBitConverter.ToUInt32(tmpBuffer, 18);
|
|
|
|
|
|
entry.Index1 = BigEndianBitConverter.ToUInt32(tmpBuffer, 22);
|
|
|
|
|
|
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
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_neroDaov1.Tracks.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(entry.SectorSize > _imageInfo.SectorSize)
|
|
|
|
|
|
_imageInfo.SectorSize = entry.SectorSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_trackIsrCs.Add(currentTrack, entry.Isrc);
|
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-07-20 04:34:16 +01:00
|
|
|
|
EndOfTrack = entry.EndOfTrack,
|
|
|
|
|
|
Isrc = entry.Isrc,
|
|
|
|
|
|
Length = entry.EndOfTrack - entry.Index0,
|
|
|
|
|
|
Mode = entry.Mode,
|
|
|
|
|
|
Offset = entry.Index0,
|
|
|
|
|
|
SectorSize = entry.SectorSize,
|
|
|
|
|
|
Index0 = entry.Index0,
|
|
|
|
|
|
Index1 = entry.Index1,
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Sequence = currentTrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_neroTracks.Add(currentTrack, neroTrack);
|
|
|
|
|
|
currentTrack++;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
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-11-11 04:19:18 +00:00
|
|
|
|
_neroDaov2 = new DaoV2
|
2020-01-11 22:44:25 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSizeBe = chunkLength
|
2020-01-11 22:44:25 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[22];
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 22);
|
|
|
|
|
|
_neroDaov2.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpBuffer, 0);
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_neroDaov2.Upc = new byte[14];
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Array.Copy(tmpBuffer, 4, _neroDaov2.Upc, 0, 14);
|
|
|
|
|
|
_neroDaov2.TocType = BigEndianBitConverter.ToUInt16(tmpBuffer, 18);
|
|
|
|
|
|
_neroDaov2.FirstTrack = tmpBuffer[20];
|
|
|
|
|
|
_neroDaov2.LastTrack = tmpBuffer[21];
|
|
|
|
|
|
_neroDaov2.Tracks = new List<DaoEntryV2>();
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01: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-07-20 21:11:32 +01: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-07-20 21:11:32 +01: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}",
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_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-07-20 21:11:32 +01:00
|
|
|
|
_neroDaov2.FirstTrack);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.LastTrack = {0}",
|
|
|
|
|
|
_neroDaov2.LastTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
tmpBuffer = new byte[42];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
for(int i = 0; i < _neroDaov2.ChunkSizeBe - 22; i += 42)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var entry = new DaoEntryV2();
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 42);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
entry.Isrc = new byte[12];
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Array.Copy(tmpBuffer, 4, entry.Isrc, 0, 12);
|
|
|
|
|
|
entry.SectorSize = BigEndianBitConverter.ToUInt16(tmpBuffer, 12);
|
|
|
|
|
|
entry.Mode = BitConverter.ToUInt16(tmpBuffer, 14);
|
|
|
|
|
|
entry.Unknown = BigEndianBitConverter.ToUInt16(tmpBuffer, 16);
|
|
|
|
|
|
entry.Index0 = BigEndianBitConverter.ToUInt64(tmpBuffer, 18);
|
|
|
|
|
|
entry.Index1 = BigEndianBitConverter.ToUInt64(tmpBuffer, 26);
|
|
|
|
|
|
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
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_neroDaov2.Tracks.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(entry.SectorSize > _imageInfo.SectorSize)
|
|
|
|
|
|
_imageInfo.SectorSize = entry.SectorSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_trackIsrCs.Add(currentTrack, entry.Isrc);
|
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-07-20 04:34:16 +01:00
|
|
|
|
EndOfTrack = entry.EndOfTrack,
|
|
|
|
|
|
Isrc = entry.Isrc,
|
|
|
|
|
|
Length = entry.EndOfTrack - entry.Index0,
|
|
|
|
|
|
Mode = entry.Mode,
|
|
|
|
|
|
Offset = entry.Index0,
|
|
|
|
|
|
SectorSize = entry.SectorSize,
|
|
|
|
|
|
Index0 = entry.Index0,
|
|
|
|
|
|
Index1 = entry.Index1,
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Sequence = currentTrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_neroTracks.Add(currentTrack, neroTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
currentTrack++;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_cdtxt = new CdText
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSize = chunkLength,
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Packs = new List<CdTextPack>()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[18];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
for(int i = 0; i < _cdtxt.ChunkSize; i += 18)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var entry = new CdTextPack();
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 18);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
entry.PackType = tmpBuffer[0];
|
|
|
|
|
|
entry.TrackNumber = tmpBuffer[1];
|
|
|
|
|
|
entry.PackNumber = tmpBuffer[2];
|
|
|
|
|
|
entry.BlockNumber = tmpBuffer[3];
|
2018-01-01 21:32:12 +00:00
|
|
|
|
entry.Text = new byte[12];
|
2020-11-11 04:19:18 +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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_cdtxt.Packs.Add(entry);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_taoV1 = new TaoV1
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSize = chunkLength,
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Tracks = new List<TaoEntryV1>()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[20];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
for(int i = 0; i < _taoV1.ChunkSize; i += 20)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var entry = new TaoEntryV1();
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 20);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
entry.Offset = BigEndianBitConverter.ToUInt32(tmpBuffer, 0);
|
|
|
|
|
|
entry.Length = BigEndianBitConverter.ToUInt32(tmpBuffer, 4);
|
|
|
|
|
|
entry.Mode = BigEndianBitConverter.ToUInt32(tmpBuffer, 8);
|
|
|
|
|
|
entry.StartLba = BigEndianBitConverter.ToUInt32(tmpBuffer, 12);
|
|
|
|
|
|
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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_taoV1.Tracks.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(NeroTrackModeToBytesPerSector((DaoMode)entry.Mode) > _imageInfo.SectorSize)
|
|
|
|
|
|
_imageInfo.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// StartLba points to INDEX 0 and Nero always introduces a pregap of 150 sectors,
|
|
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var neroTrack = new NeroTrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
EndOfTrack = entry.Offset + entry.Length,
|
|
|
|
|
|
Isrc = new byte[12],
|
|
|
|
|
|
Length = entry.Length,
|
|
|
|
|
|
Mode = entry.Mode,
|
|
|
|
|
|
Offset = entry.Offset,
|
|
|
|
|
|
SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode),
|
|
|
|
|
|
UseLbaForIndex = true,
|
2021-06-11 01:32:51 +01:00
|
|
|
|
Sequence = currentTrack,
|
|
|
|
|
|
StartLba = entry.StartLba
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_neroTracks.Add(currentTrack, neroTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
currentTrack++;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_taoV2 = new TaoV2
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSize = chunkLength,
|
2020-11-11 04:19:18 +00:00
|
|
|
|
Tracks = new List<TaoEntryV2>()
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[32];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
for(int i = 0; i < _taoV2.ChunkSize; i += 32)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var entry = new TaoEntryV2();
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 32);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
entry.Offset = BigEndianBitConverter.ToUInt64(tmpBuffer, 0);
|
|
|
|
|
|
entry.Length = BigEndianBitConverter.ToUInt64(tmpBuffer, 8);
|
|
|
|
|
|
entry.Mode = BigEndianBitConverter.ToUInt32(tmpBuffer, 16);
|
|
|
|
|
|
entry.StartLba = BigEndianBitConverter.ToUInt32(tmpBuffer, 20);
|
|
|
|
|
|
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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_taoV2.Tracks.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
ushort v2Bps = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
|
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(NeroTrackModeToBytesPerSector((DaoMode)entry.Mode) > _imageInfo.SectorSize)
|
2021-06-11 01:32:51 +01:00
|
|
|
|
_imageInfo.SectorSize = v2Bps;
|
|
|
|
|
|
|
|
|
|
|
|
// StartLba points to INDEX 1 and Nero always introduces a pregap of 150 sectors,
|
|
|
|
|
|
// so let's move it to INDEX 0 and fix the pointers
|
|
|
|
|
|
if(entry.StartLba >= 150)
|
|
|
|
|
|
{
|
|
|
|
|
|
entry.StartLba -= 150;
|
|
|
|
|
|
entry.Offset -= (ulong)(150 * v2Bps);
|
|
|
|
|
|
entry.Length += (ulong)(150 * v2Bps);
|
|
|
|
|
|
}
|
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-07-20 04:34:16 +01:00
|
|
|
|
EndOfTrack = entry.Offset + entry.Length,
|
|
|
|
|
|
Isrc = new byte[12],
|
|
|
|
|
|
Length = entry.Length,
|
|
|
|
|
|
Mode = entry.Mode,
|
|
|
|
|
|
Offset = entry.Offset,
|
2021-06-11 01:32:51 +01:00
|
|
|
|
StartLba = entry.StartLba,
|
|
|
|
|
|
UseLbaForIndex = true,
|
|
|
|
|
|
SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode),
|
|
|
|
|
|
Sequence = currentTrack
|
2017-12-24 00:12:31 +00:00
|
|
|
|
};
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_neroTracks.Add(currentTrack, neroTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
currentTrack++;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[4];
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 4);
|
|
|
|
|
|
uint sessionTracks = BigEndianBitConverter.ToUInt32(tmpBuffer, 0);
|
|
|
|
|
|
_neroSessions.Add(currentSession, sessionTracks);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +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
|
|
|
|
|
2020-11-11 04:19:18 +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-11-11 04:19:18 +00:00
|
|
|
|
_mediaType = new MediaType
|
2020-01-11 22:44:25 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSize = chunkLength
|
2020-01-11 22:44:25 +00:00
|
|
|
|
};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[4];
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 4);
|
|
|
|
|
|
_mediaType.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-11-11 04:19:18 +00:00
|
|
|
|
(NeroMediaTypes)_mediaType.Type, _mediaType.Type);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_imageInfo.MediaType = NeroMediaTypeToMediaType((NeroMediaTypes)_mediaType.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-11-11 04:19:18 +00:00
|
|
|
|
_discInfo = new DiscInformation
|
2020-01-11 22:44:25 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSize = chunkLength
|
2020-01-11 22:44:25 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[4];
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 4);
|
|
|
|
|
|
_discInfo.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-11-11 04:19:18 +00:00
|
|
|
|
_discInfo.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-11-11 04:19:18 +00:00
|
|
|
|
_relo = new ReloChunk
|
2020-01-11 22:44:25 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSize = chunkLength
|
2020-01-11 22:44:25 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[4];
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 4);
|
|
|
|
|
|
_relo.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-11-11 04:19:18 +00:00
|
|
|
|
_relo.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-11-11 04:19:18 +00:00
|
|
|
|
_toc = new TocChunk
|
2020-01-11 22:44:25 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
|
ChunkSize = chunkLength
|
2020-01-11 22:44:25 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
byte[] tmpBuffer = new byte[2];
|
|
|
|
|
|
_imageStream.Read(tmpBuffer, 0, 2);
|
|
|
|
|
|
_toc.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-11-11 04:19:18 +00:00
|
|
|
|
_toc.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
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageStream.Seek(chunkLength, SeekOrigin.Current);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-20 21:11:32 +01: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;
|
|
|
|
|
|
_imageInfo.DriveFirmwareRevision = null;
|
|
|
|
|
|
_imageInfo.MediaSequence = 0;
|
|
|
|
|
|
_imageInfo.LastMediaSequence = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if(_imageNewFormat)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageInfo.ImageSize = footerV2.FirstChunkOffset;
|
|
|
|
|
|
_imageInfo.Version = "Nero Burning ROM >= 5.5";
|
|
|
|
|
|
_imageInfo.Application = "Nero Burning ROM";
|
|
|
|
|
|
_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
|
|
|
|
{
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageInfo.ImageSize = footerV1.FirstChunkOffset;
|
|
|
|
|
|
_imageInfo.Version = "Nero Burning ROM <= 5.0";
|
|
|
|
|
|
_imageInfo.Application = "Nero Burning ROM";
|
|
|
|
|
|
_imageInfo.ApplicationVersion = "<= 5.0";
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(_neroSessions.Count == 0)
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
currentSession = 1;
|
|
|
|
|
|
_neroSessions.TryGetValue(1, out uint currentSessionMaxTrack);
|
|
|
|
|
|
uint currentSessionCurrentTrack = 1;
|
|
|
|
|
|
var currentSessionStruct = new CommonTypes.Structs.Session();
|
2020-01-11 22:44:25 +00:00
|
|
|
|
ulong partitionSequence = 0;
|
|
|
|
|
|
ulong partitionStartByte = 0;
|
2021-06-11 01:32:51 +01:00
|
|
|
|
int trackCounter = 1;
|
|
|
|
|
|
_trackFlags = new Dictionary<uint, byte>();
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Process tracks
|
|
|
|
|
|
foreach(NeroTrack neroTrack in _neroTracks.Values)
|
2014-07-09 19:52:00 +01:00
|
|
|
|
{
|
2020-11-11 04:19:18 +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-11-11 04:19:18 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("Nero plugin", "\tcurrentSessionCurrentTrack = {0}",
|
|
|
|
|
|
currentSessionCurrentTrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var track = new Track();
|
|
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Process indexes
|
2020-11-11 04:19:18 +00:00
|
|
|
|
if(_cuesheetV1?.Entries?.Count > 0)
|
|
|
|
|
|
foreach(CueEntryV1 entry in _cuesheetV1.Entries.Where(e => e.TrackNumber == neroTrack.Sequence).
|
|
|
|
|
|
OrderBy(e => e.IndexNumber))
|
2020-06-21 01:30:30 +01:00
|
|
|
|
{
|
2021-06-11 01:32:51 +01:00
|
|
|
|
track.Indexes[entry.IndexNumber] =
|
|
|
|
|
|
(entry.Minute * 60 * 75) + (entry.Second * 75) + entry.Frame - 150;
|
2020-06-21 01:30:30 +01:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
_trackFlags[entry.TrackNumber] = (byte)((entry.Mode & 0xF0) >> 4);
|
2020-06-21 01:30:30 +01:00
|
|
|
|
}
|
2020-11-11 04:19:18 +00:00
|
|
|
|
else if(_cuesheetV2?.Entries?.Count > 0)
|
|
|
|
|
|
foreach(CueEntryV2 entry in _cuesheetV2.Entries.Where(e => e.TrackNumber == neroTrack.Sequence).
|
|
|
|
|
|
OrderBy(e => e.IndexNumber))
|
2021-06-11 01:32:51 +01:00
|
|
|
|
{
|
2020-06-21 01:30:30 +01:00
|
|
|
|
track.Indexes[entry.IndexNumber] = entry.LbaStart;
|
2021-06-11 01:32:51 +01:00
|
|
|
|
_trackFlags[entry.TrackNumber] = (byte)((entry.Mode & 0xF0) >> 4);
|
|
|
|
|
|
}
|
2020-06-21 01:30:30 +01:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Act if there are no indexes
|
|
|
|
|
|
if(track.Indexes.Count == 0)
|
2020-06-21 01:30:30 +01:00
|
|
|
|
{
|
2021-06-11 01:32:51 +01:00
|
|
|
|
if(!neroTrack.UseLbaForIndex)
|
|
|
|
|
|
continue; // This track start is unknown, continue and pray the goddess
|
|
|
|
|
|
|
|
|
|
|
|
// This always happens in TAO discs and Nero uses 150 sectors of pregap for them
|
|
|
|
|
|
// but we need to move the offsets if it's the first track of a session
|
|
|
|
|
|
if(currentSessionCurrentTrack == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
track.Indexes[1] = (int)neroTrack.StartLba;
|
|
|
|
|
|
track.Indexes[0] = track.Indexes[1] - 150;
|
|
|
|
|
|
neroTrack.Offset -= (ulong)(150 * neroTrack.SectorSize);
|
|
|
|
|
|
neroTrack.Length += (ulong)(150 * neroTrack.SectorSize);
|
|
|
|
|
|
}
|
2020-06-21 01:30:30 +01:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-06-11 01:32:51 +01:00
|
|
|
|
track.Indexes[0] = (int)neroTrack.StartLba;
|
|
|
|
|
|
track.Indexes[1] = track.Indexes[0] + 150;
|
2020-06-21 01:30:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Prevent duplicate index 0
|
2020-06-21 01:30:30 +01:00
|
|
|
|
if(track.Indexes.ContainsKey(0) &&
|
|
|
|
|
|
track.Indexes[0] == track.Indexes[1])
|
|
|
|
|
|
track.Indexes.Remove(0);
|
|
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// There's a pregap
|
|
|
|
|
|
if(track.Indexes.ContainsKey(0))
|
|
|
|
|
|
{
|
|
|
|
|
|
track.TrackPregap = (ulong)(track.Indexes[1] - track.Indexes[0]);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Negative pregap, skip it
|
|
|
|
|
|
if(track.Indexes[0] < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
neroTrack.Length -= track.TrackPregap * neroTrack.SectorSize;
|
|
|
|
|
|
neroTrack.Offset += track.TrackPregap * neroTrack.SectorSize;
|
|
|
|
|
|
track.TrackStartSector = (ulong)track.Indexes[1];
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
track.TrackStartSector = (ulong)track.Indexes[0];
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
track.TrackStartSector = (ulong)track.Indexes[1];
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Handle hidden tracks
|
|
|
|
|
|
if(neroTrack.Sequence == 1 &&
|
|
|
|
|
|
track.TrackStartSector > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
neroTrack.Length += track.TrackStartSector * neroTrack.SectorSize;
|
|
|
|
|
|
neroTrack.Offset -= track.TrackStartSector * neroTrack.SectorSize;
|
|
|
|
|
|
track.TrackStartSector = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Common track data
|
|
|
|
|
|
track.TrackDescription = StringHandlers.CToString(neroTrack.Isrc);
|
|
|
|
|
|
track.TrackEndSector = (neroTrack.Length / neroTrack.SectorSize) + track.TrackStartSector - 1;
|
|
|
|
|
|
track.TrackSequence = neroTrack.Sequence;
|
|
|
|
|
|
track.TrackSession = currentSession;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
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;
|
2021-06-11 01:32:51 +01:00
|
|
|
|
neroTrack.Sectors = neroTrack.Length / neroTrack.SectorSize;
|
|
|
|
|
|
|
|
|
|
|
|
// Flags not set for this track
|
|
|
|
|
|
if(!_trackFlags.ContainsKey(track.TrackSequence))
|
|
|
|
|
|
{
|
|
|
|
|
|
switch(track.TrackType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case TrackType.Audio:
|
|
|
|
|
|
_trackFlags[track.TrackSequence] = 0;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TrackType.Data:
|
|
|
|
|
|
case TrackType.CdMode1:
|
|
|
|
|
|
case TrackType.CdMode2Formless:
|
|
|
|
|
|
case TrackType.CdMode2Form1:
|
|
|
|
|
|
case TrackType.CdMode2Form2:
|
|
|
|
|
|
_trackFlags[track.TrackSequence] = 4;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If ISRC is not empty
|
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(track.TrackDescription))
|
|
|
|
|
|
{
|
|
|
|
|
|
_trackIsrCs[neroTrack.Sequence] = neroTrack.Isrc;
|
|
|
|
|
|
|
|
|
|
|
|
if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc))
|
|
|
|
|
|
_imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool rawMode1 = false;
|
|
|
|
|
|
bool rawMode2 = false;
|
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
|
|
|
|
{
|
2021-06-11 01:38:07 +01:00
|
|
|
|
case DaoMode.AudioAlt:
|
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;
|
2021-06-11 01:32:51 +01:00
|
|
|
|
rawMode2 = true;
|
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;
|
2021-06-11 01:32:51 +01:00
|
|
|
|
rawMode2 = true;
|
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;
|
2021-06-11 01:32:51 +01:00
|
|
|
|
rawMode1 = true;
|
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;
|
2021-06-11 01:32:51 +01:00
|
|
|
|
rawMode1 = 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-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
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Check readability of sector tags
|
|
|
|
|
|
if(rawMode1 || rawMode2)
|
|
|
|
|
|
{
|
|
|
|
|
|
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) && rawMode2)
|
|
|
|
|
|
_imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader);
|
|
|
|
|
|
|
|
|
|
|
|
if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
|
|
|
|
|
|
_imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(track.TrackSubchannelType == TrackSubchannelType.RawInterleaved)
|
|
|
|
|
|
{
|
|
|
|
|
|
track.TrackSubchannelFilter = imageFilter;
|
|
|
|
|
|
track.TrackSubchannelFile = imageFilter.GetFilename();
|
|
|
|
|
|
track.TrackSubchannelOffset = neroTrack.Offset;
|
|
|
|
|
|
|
|
|
|
|
|
if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel))
|
|
|
|
|
|
_imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Tracks.Add(track);
|
|
|
|
|
|
|
|
|
|
|
|
// Build session
|
2020-11-11 04:19:18 +00:00
|
|
|
|
if(currentSessionCurrentTrack == 1)
|
|
|
|
|
|
currentSessionStruct = new CommonTypes.Structs.Session
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
SessionSequence = currentSession,
|
2020-07-20 04:34:16 +01:00
|
|
|
|
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
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
currentSessionCurrentTrack++;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
if(currentSessionCurrentTrack > currentSessionMaxTrack)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
currentSession++;
|
|
|
|
|
|
_neroSessions.TryGetValue(currentSession, out currentSessionMaxTrack);
|
|
|
|
|
|
currentSessionCurrentTrack = 1;
|
|
|
|
|
|
currentSessionStruct.EndTrack = track.TrackSequence;
|
|
|
|
|
|
currentSessionStruct.EndSector = track.TrackEndSector;
|
|
|
|
|
|
Sessions.Add(currentSessionStruct);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2021-06-11 01:32:51 +01:00
|
|
|
|
else if(trackCounter == _neroTracks.Count)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_neroSessions.TryGetValue(currentSession, out currentSessionMaxTrack);
|
|
|
|
|
|
currentSessionCurrentTrack = 1;
|
|
|
|
|
|
currentSessionStruct.EndTrack = track.TrackSequence;
|
|
|
|
|
|
currentSessionStruct.EndSector = track.TrackEndSector;
|
|
|
|
|
|
Sessions.Add(currentSessionStruct);
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Add to offset map
|
2020-07-20 21:11:32 +01: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
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
// Create partition
|
2020-01-11 22:44:25 +00:00
|
|
|
|
var partition = new Partition
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
Description = $"Track {track.TrackSequence}",
|
|
|
|
|
|
Size = neroTrack.EndOfTrack - neroTrack.Index1,
|
|
|
|
|
|
Name = StringHandlers.CToString(neroTrack.Isrc),
|
|
|
|
|
|
Sequence = partitionSequence,
|
|
|
|
|
|
Offset = partitionStartByte,
|
|
|
|
|
|
Start = (ulong)track.Indexes[1],
|
2020-06-21 01:30:30 +01: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
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
if(track.TrackEndSector + 1 > _imageInfo.Sectors)
|
|
|
|
|
|
_imageInfo.Sectors = track.TrackEndSector + 1;
|
2020-06-21 01:30:30 +01:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
trackCounter++;
|
2020-06-21 01:30:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
if(_trackFlags.Count > 0 &&
|
|
|
|
|
|
!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags))
|
|
|
|
|
|
_imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags);
|
|
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_neroFilter = imageFilter;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
if(_imageInfo.MediaType == CommonTypes.MediaType.Unknown ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CD)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
2018-01-01 21:32:12 +00:00
|
|
|
|
bool data = false;
|
|
|
|
|
|
bool mode2 = false;
|
2020-11-11 04:19:18 +00:00
|
|
|
|
bool firstAudio = false;
|
|
|
|
|
|
bool firstData = false;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
bool audio = false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
for(int i = 0; i < _neroTracks.Count; i++)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
// First track is audio
|
2021-06-11 01:38:07 +01:00
|
|
|
|
firstAudio |= i == 0 && ((DaoMode)_neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio ||
|
|
|
|
|
|
(DaoMode)_neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioAlt ||
|
2020-07-20 21:11:32 +01: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
|
|
|
|
// First track is data
|
2020-11-11 04:19:18 +00:00
|
|
|
|
firstData |= i == 0 && (DaoMode)_neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio &&
|
2021-06-11 01:38:07 +01:00
|
|
|
|
(DaoMode)_neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioAlt &&
|
2020-07-20 21:11:32 +01: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-07-20 21:11:32 +01:00
|
|
|
|
data |= i != 0 && (DaoMode)_neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio &&
|
2021-06-11 01:38:07 +01:00
|
|
|
|
(DaoMode)_neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioAlt &&
|
2020-07-20 21:11:32 +01: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
|
2021-06-11 01:38:07 +01:00
|
|
|
|
audio |= i != 0 && ((DaoMode)_neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio ||
|
|
|
|
|
|
(DaoMode)_neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioAlt ||
|
2020-07-20 21:11:32 +01:00
|
|
|
|
(DaoMode)_neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioSub);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01: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 &&
|
2020-11-11 04:19:18 +00:00
|
|
|
|
!firstData)
|
|
|
|
|
|
_imageInfo.MediaType = CommonTypes.MediaType.CDDA;
|
|
|
|
|
|
else if(firstAudio &&
|
2020-01-11 22:44:25 +00:00
|
|
|
|
data &&
|
|
|
|
|
|
Sessions.Count > 1 &&
|
|
|
|
|
|
mode2)
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_imageInfo.MediaType = CommonTypes.MediaType.CDPLUS;
|
|
|
|
|
|
else if((firstData && audio) || mode2)
|
|
|
|
|
|
_imageInfo.MediaType = CommonTypes.MediaType.CDROMXA;
|
2018-01-01 21:32:12 +00:00
|
|
|
|
else if(!audio)
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_imageInfo.MediaType = CommonTypes.MediaType.CDROM;
|
2020-01-11 22:44:25 +00:00
|
|
|
|
else
|
2020-11-11 04:19:18 +00:00
|
|
|
|
_imageInfo.MediaType = CommonTypes.MediaType.CD;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageInfo.XmlMediaType = XmlMediaType.OpticalDisc;
|
|
|
|
|
|
AaruConsole.VerboseWriteLine("Nero image contains a disc of type {0}", _imageInfo.MediaType);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2020-06-21 22:30:07 +01:00
|
|
|
|
_sectorBuilder = new SectorBuilder();
|
|
|
|
|
|
|
2021-06-11 02:47:10 +01:00
|
|
|
|
_isCd = _imageInfo.MediaType == CommonTypes.MediaType.CD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDDA ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDG ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDEG ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDI ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDROM ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDROMXA ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDPLUS ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDMO ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDR ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDRW ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDMRW ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.VCD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.SVCD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.PCD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.DTSCD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDMIDI ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDV ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDIREADY ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.FMTOWNS ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.PS1CD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.PS2CD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.MEGACD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.SATURNCD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.GDROM ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.GDR ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.MilCD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.SuperCDROM2 ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.JaguarCD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.ThreeDO ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.PCFX ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.NeoGeoCD ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CDTV ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CD32 ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.Playdia ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.Pippin ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.VideoNow ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.VideoNowColor ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.VideoNowXp ||
|
|
|
|
|
|
_imageInfo.MediaType == CommonTypes.MediaType.CVD;
|
|
|
|
|
|
|
|
|
|
|
|
if(_isCd)
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
foreach(Track track in Tracks)
|
2021-06-06 14:58:40 +01:00
|
|
|
|
{
|
2021-06-11 02:47:10 +01:00
|
|
|
|
track.TrackPregap = 0;
|
|
|
|
|
|
track.Indexes?.Clear();
|
2021-06-06 14:58:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-06-11 02:47:10 +01:00
|
|
|
|
_imageInfo.ReadableMediaTags.Remove(MediaTagType.CD_MCN);
|
|
|
|
|
|
_imageInfo.ReadableSectorTags.Remove(SectorTagType.CdTrackIsrc);
|
|
|
|
|
|
_imageInfo.ReadableSectorTags.Remove(SectorTagType.CdTrackFlags);
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
2020-11-11 04:19:18 +00:00
|
|
|
|
AaruConsole.DebugWrite("Nero plugin", "Exception occurred 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)
|
|
|
|
|
|
{
|
2020-07-20 21:11:32 +01: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-07-20 21:11:32 +01:00
|
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value
|
2020-01-11 22:44:25 +00:00
|
|
|
|
from track in Tracks where track.TrackSequence == kvp.Key
|
2020-06-21 01:38:02 +01: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-07-20 21:11:32 +01:00
|
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value
|
2020-01-11 22:44:25 +00:00
|
|
|
|
from track in Tracks where track.TrackSequence == kvp.Key
|
2020-06-21 01:38:02 +01: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-07-20 21:11:32 +01: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:
|
2021-06-11 01:38:07 +01:00
|
|
|
|
case DaoMode.AudioAlt:
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageStream = _neroFilter.GetDataForkStream();
|
|
|
|
|
|
var br = new BinaryReader(_imageStream);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
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-07-20 21:11:32 +01: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:
|
2021-06-11 01:32:51 +01:00
|
|
|
|
if(_trackFlags.TryGetValue(track, out byte flag))
|
|
|
|
|
|
return new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
flag
|
|
|
|
|
|
};
|
2019-05-11 20:49:32 +01:00
|
|
|
|
|
2021-06-11 01:32:51 +01:00
|
|
|
|
throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
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
|
|
|
|
|
2021-06-11 01:38:07 +01:00
|
|
|
|
case DaoMode.Audio:
|
|
|
|
|
|
case DaoMode.AudioAlt: throw new ArgumentException("There are no tags on audio tracks", nameof(tag));
|
2017-12-24 00:12:31 +00:00
|
|
|
|
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
|
|
|
|
case DaoMode.DataM2RawSub:
|
2021-06-11 01:50:42 +01:00
|
|
|
|
switch(tag)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SectorTagType.CdSectorSync:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 0;
|
|
|
|
|
|
sectorSize = 12;
|
|
|
|
|
|
sectorSkip = 2340 + 96;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case SectorTagType.CdSectorHeader:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 12;
|
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
|
sectorSkip = 2336 + 96;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case SectorTagType.CdSectorSubHeader:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 16;
|
|
|
|
|
|
sectorSize = 8;
|
|
|
|
|
|
sectorSkip = 2328 + 96;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case SectorTagType.CdSectorEdc:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 2348;
|
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
|
sectorSkip = 0 + 96;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
|
{
|
|
|
|
|
|
sectorOffset = 2352;
|
|
|
|
|
|
sectorSize = 96;
|
|
|
|
|
|
sectorSkip = 0;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
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
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageStream = _neroFilter.GetDataForkStream();
|
|
|
|
|
|
var br = new BinaryReader(_imageStream);
|
2020-01-11 22:44:25 +00:00
|
|
|
|
|
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-07-20 21:11:32 +01:00
|
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value
|
2020-01-11 22:44:25 +00:00
|
|
|
|
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
|
|
|
|
{
|
2021-06-11 02:47:10 +01:00
|
|
|
|
if(!_isCd)
|
|
|
|
|
|
return ReadSectors(sectorAddress, length, track);
|
|
|
|
|
|
|
2020-07-20 21:11:32 +01: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:
|
2021-06-11 01:38:07 +01:00
|
|
|
|
case DaoMode.AudioAlt:
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
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
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
_imageStream = _neroFilter.GetDataForkStream();
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-21 22:30:07 +01:00
|
|
|
|
switch((DaoMode)aaruTrack.Mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case DaoMode.Data:
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] fullSector = new byte[2352];
|
|
|
|
|
|
byte[] fullBuffer = new byte[2352 * length];
|
|
|
|
|
|
|
|
|
|
|
|
for(uint i = 0; i < length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
Array.Copy(buffer, i * 2048, fullSector, 16, 2048);
|
|
|
|
|
|
_sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode1, (long)(sectorAddress + i));
|
|
|
|
|
|
_sectorBuilder.ReconstructEcc(ref fullSector, TrackType.CdMode1);
|
|
|
|
|
|
Array.Copy(fullSector, 0, fullBuffer, i * 2352, 2352);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
buffer = fullBuffer;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case DaoMode.DataM2F1:
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] fullSector = new byte[2352];
|
|
|
|
|
|
byte[] fullBuffer = new byte[2352 * length];
|
|
|
|
|
|
|
|
|
|
|
|
for(uint i = 0; i < length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
Array.Copy(buffer, i * 2048, fullSector, 24, 2048);
|
|
|
|
|
|
|
|
|
|
|
|
_sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form1,
|
|
|
|
|
|
(long)(sectorAddress + i));
|
|
|
|
|
|
|
|
|
|
|
|
_sectorBuilder.ReconstructEcc(ref fullSector, TrackType.CdMode2Form1);
|
|
|
|
|
|
Array.Copy(fullSector, 0, fullBuffer, i * 2352, 2352);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
buffer = fullBuffer;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case DaoMode.DataM2F2:
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] fullSector = new byte[2352];
|
|
|
|
|
|
byte[] fullBuffer = new byte[2352 * length];
|
|
|
|
|
|
|
|
|
|
|
|
for(uint i = 0; i < length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
_sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Formless,
|
|
|
|
|
|
(long)(sectorAddress + i));
|
|
|
|
|
|
|
|
|
|
|
|
Array.Copy(buffer, i * 2336, fullSector, 16, 2336);
|
|
|
|
|
|
Array.Copy(fullSector, 0, fullBuffer, i * 2352, 2352);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
buffer = fullBuffer;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
return buffer;
|
|
|
|
|
|
}
|
2015-12-05 17:21:47 +00:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
public List<Track> GetSessionTracks(CommonTypes.Structs.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
|
|
|
|
}
|
|
|
|
|
|
}
|