2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-07-28 18:13:49 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Nero.cs
|
|
|
|
|
// 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 ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Manages Nero Burning ROM disc images.
|
|
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
// ****************************************************************************/
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2017-12-22 06:55:04 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
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;
|
|
|
|
|
using DiscImageChef.Checksums;
|
2015-11-23 21:44:58 +00:00
|
|
|
using DiscImageChef.CommonTypes;
|
2017-12-19 19:33:46 +00:00
|
|
|
using DiscImageChef.Console;
|
2016-09-05 17:37:31 +01:00
|
|
|
using DiscImageChef.Filters;
|
2017-12-22 06:55:04 +00:00
|
|
|
#pragma warning disable 414
|
|
|
|
|
#pragma warning disable 169
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
namespace DiscImageChef.DiscImages
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
|
|
|
|
[SuppressMessage("ReSharper", "CollectionNeverQueried.Local")]
|
2017-12-19 20:33:03 +00:00
|
|
|
public class Nero : ImagePlugin
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
#region Internal structures
|
|
|
|
|
struct NeroV1Footer
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "NERO"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset of first chunk in file
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint FirstChunkOffset;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct NeroV2Footer
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "NER5"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset of first chunk in file
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ulong FirstChunkOffset;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct NeroV2CueEntry
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Track mode. 0x01 for audio, 0x21 for copy-protected audio, 0x41 for data
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte Mode;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Track number in BCD
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte TrackNumber;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Index number in BCD
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte IndexNumber;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Always zero
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte Dummy;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// LBA sector start for this entry
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public int LbaStart;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct NeroV2Cuesheet
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "CUEX"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Cuesheet entries
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<NeroV2CueEntry> Entries;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct NeroV1CueEntry
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Track mode. 0x01 for audio, 0x21 for copy-protected audio, 0x41 for data
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte Mode;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Track number in BCD
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte TrackNumber;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Index number in BCD
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte IndexNumber;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Always zero
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort Dummy;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MSF start sector's minute for this entry
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte Minute;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MSF start sector's second for this entry
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte Second;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MSF start sector's frame for this entry
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte Frame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct NeroV1Cuesheet
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "CUES"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Cuesheet entries
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<NeroV1CueEntry> Entries;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroV1DaoEntry
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ISRC (12 bytes)
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public byte[] Isrc;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Size of sector inside image (in bytes)
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort SectorSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sector mode in image
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort Mode;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unknown
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort Unknown;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Index 0 start
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Index0;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Index 1 start
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Index1;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// End of track + 1
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint EndOfTrack;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroV1Dao
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "DAOI"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size (big endian)
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSizeBe;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size (little endian)
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSizeLe;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UPC (14 bytes, null-padded)
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public byte[] Upc;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// TOC type
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort TocType;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// First track
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte FirstTrack;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Last track
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte LastTrack;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tracks
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public List<NeroV1DaoEntry> Tracks;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroV2DaoEntry
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ISRC (12 bytes)
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public byte[] Isrc;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Size of sector inside image (in bytes)
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort SectorSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sector mode in image
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort Mode;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Seems to be always 0.
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort Unknown;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Index 0 start
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ulong Index0;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Index 1 start
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ulong Index1;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// End of track + 1
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ulong EndOfTrack;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroV2Dao
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "DAOX"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size (big endian)
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSizeBe;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size (little endian)
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSizeLe;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UPC (14 bytes, null-padded)
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public byte[] Upc;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// TOC type
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort TocType;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// First track
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte FirstTrack;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Last track
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte LastTrack;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tracks
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public List<NeroV2DaoEntry> Tracks;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroCdTextPack
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Pack type
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte PackType;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Track number
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte TrackNumber;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Pack number in block
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte PackNumber;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Block number
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte BlockNumber;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 12 bytes of data
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte[] Text;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CRC
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public ushort Crc;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroCdText
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "CDTX"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CD-TEXT packs
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public List<NeroCdTextPack> Packs;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroV1TaoEntry
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset of track on image
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Offset;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Length of track in bytes
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Length;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Track mode
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Mode;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// LBA track start (plus 150 lead in sectors)
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint StartLba;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unknown
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Unknown;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroV1Tao
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "ETNF"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CD-TEXT packs
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public List<NeroV1TaoEntry> Tracks;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroV2TaoEntry
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset of track on image
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ulong Offset;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Length of track in bytes
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ulong Length;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Track mode
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Mode;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// LBA track start (plus 150 lead in sectors)
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint StartLba;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unknown
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Unknown;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Track length in sectors
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Sectors;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroV2Tao
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "ETN2"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CD-TEXT packs
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public List<NeroV2TaoEntry> Tracks;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct NeroSession
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "SINF"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tracks in session
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Tracks;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct NeroMediaType
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "MTYP"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Media type
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Type;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct NeroDiscInformation
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "DINF"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unknown
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Unknown;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroTocChunk
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "TOCT"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unknown
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort Unknown;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
struct NeroReloChunk
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "RELO"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unknown
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint Unknown;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct NeroEndOfChunkChain
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// "END!"
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
public uint ChunkId;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Chunk size
|
|
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint ChunkSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Internal use only
|
|
|
|
|
struct NeroTrack
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
public byte[] Isrc;
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort SectorSize;
|
|
|
|
|
public ulong Offset;
|
|
|
|
|
public ulong Length;
|
|
|
|
|
public ulong EndOfTrack;
|
|
|
|
|
public uint Mode;
|
2017-12-20 17:15:26 +00:00
|
|
|
public ulong StartLba;
|
2016-07-28 22:25:26 +01:00
|
|
|
public ulong Sectors;
|
|
|
|
|
public ulong Index0;
|
|
|
|
|
public ulong Index1;
|
|
|
|
|
public uint Sequence;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Internal consts
|
|
|
|
|
// "NERO"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_FOOTER_V1 = 0x4E45524F;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "NER5"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_FOOTER_V2 = 0x4E455235;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "CUES"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_CUE_V1 = 0x43554553;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "CUEX"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_CUE_V2 = 0x43554558;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "ETNF"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_TAO_V1 = 0x45544E46;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "ETN2"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_TAO_V2 = 0x45544E32;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "DAOI"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_DAO_V1 = 0x44414F49;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "DAOX"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_DAO_V2 = 0x44414F58;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "CDTX"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_CDTEXT = 0x43445458;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "SINF"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_SESSION = 0x53494E46;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "MTYP"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_DISC_TYPE = 0x4D545950;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "DINF"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_DISC_INFO = 0x44494E46;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "TOCT"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_TOC = 0x544F4354;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "RELO"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_RELOCATION = 0x52454C4F;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
// "END!"
|
2017-12-22 06:55:04 +00:00
|
|
|
const uint NERO_END = 0x454E4421;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
enum DaoMode : ushort
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
Data = 0x0000,
|
|
|
|
|
DataM2F1 = 0x0002,
|
|
|
|
|
DataM2F2 = 0x0003,
|
|
|
|
|
DataRaw = 0x0005,
|
|
|
|
|
DataM2Raw = 0x0006,
|
|
|
|
|
Audio = 0x0007,
|
|
|
|
|
DataRawSub = 0x000F,
|
|
|
|
|
AudioSub = 0x0010,
|
|
|
|
|
DataM2RawSub = 0x0011
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
[Flags]
|
2017-12-22 06:55:04 +00:00
|
|
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
|
|
|
enum NeroMediaTypes : uint
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// No media
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypNone = 0x00000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CD-R/RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypCd = 0x00001,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DDCD-R/RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDdcd = 0x00002,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DVD-R/RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdM = 0x00004,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DVD+RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdP = 0x00008,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DVD-RAM
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdRam = 0x00010,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Multi-level disc
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypMl = 0x00020,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Mount Rainier
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypMrw = 0x00040,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Exclude CD-R
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypNoCdr = 0x00080,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Exclude CD-RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypNoCdrw = 0x00100,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CD-RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypCdrw = NeroMtypCd | NeroMtypNoCdr,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CD-R
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypCdr = NeroMtypCd | NeroMtypNoCdrw,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DVD-ROM
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdRom = 0x00200,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CD-ROM
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypCdrom = 0x00400,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Exclude DVD-RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypNoDvdMRw = 0x00800,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Exclude DVD-R
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypNoDvdMR = 0x01000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Exclude DVD+RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypNoDvdPRw = 0x02000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Exclude DVD+R
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypNoDvdPR = 0x04000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DVD-R
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdMR = NeroMtypDvdM | NeroMtypNoDvdMRw,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DVD-RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdMRw = NeroMtypDvdM | NeroMtypNoDvdMR,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DVD+R
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdPR = NeroMtypDvdP | NeroMtypNoDvdPRw,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DVD+RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdPRw = NeroMtypDvdP | NeroMtypNoDvdPR,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Packet-writing (fixed)
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypFpacket = 0x08000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Packet-writing (variable)
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypVpacket = 0x10000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Packet-writing (any)
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypPacketw = NeroMtypMrw | NeroMtypFpacket | NeroMtypVpacket,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// HD-Burn
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypHdb = 0x20000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DVD+R DL
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdPR9 = 0x40000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// DVD-R DL
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdMR9 = 0x80000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Any DVD double-layer
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdAnyR9 = NeroMtypDvdPR9 | NeroMtypDvdMR9,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Any DVD
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypDvdAny = NeroMtypDvdM | NeroMtypDvdP | NeroMtypDvdRam | NeroMtypDvdAnyR9,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// BD-ROM
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypBdRom = 0x100000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// BD-R
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypBdR = 0x200000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// BD-RE
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypBdRe = 0x400000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// BD-R/RE
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypBd = NeroMtypBdR | NeroMtypBdRe,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Any BD
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypBdAny = NeroMtypBd | NeroMtypBdRom,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// HD DVD-ROM
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypHdDvdRom = 0x0800000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// HD DVD-R
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypHdDvdR = 0x1000000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// HD DVD-RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypHdDvdRw = 0x2000000,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// HD DVD-R/RW
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypHdDvd = NeroMtypHdDvdR | NeroMtypHdDvdRw,
|
2014-07-09 19:52:00 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Any HD DVD
|
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroMtypHdDvdAny = NeroMtypHdDvd | NeroMtypHdDvdRom,
|
2016-08-08 18:44:08 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Any DVD, old
|
|
|
|
|
/// </summary>
|
2017-12-21 02:52:12 +00:00
|
|
|
NeroMtypDvdAnyOld = NeroMtypDvdM | NeroMtypDvdP | NeroMtypDvdRam
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Internal variables
|
2017-12-22 06:55:04 +00:00
|
|
|
Filter neroFilter;
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream imageStream;
|
2014-07-09 19:52:00 +01:00
|
|
|
bool imageNewFormat;
|
2016-07-28 22:25:26 +01:00
|
|
|
Dictionary<ushort, uint> neroSessions;
|
2014-07-09 19:52:00 +01:00
|
|
|
NeroV1Cuesheet neroCuesheetV1;
|
|
|
|
|
NeroV2Cuesheet neroCuesheetV2;
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroV1Dao neroDaov1;
|
|
|
|
|
NeroV2Dao neroDaov2;
|
|
|
|
|
NeroCdText neroCdtxt;
|
|
|
|
|
NeroV1Tao neroTaov1;
|
|
|
|
|
NeroV2Tao neroTaov2;
|
2014-07-09 19:52:00 +01:00
|
|
|
NeroMediaType neroMediaTyp;
|
|
|
|
|
NeroDiscInformation neroDiscInfo;
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroTocChunk neroToc;
|
|
|
|
|
NeroReloChunk neroRelo;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
List<Track> imageTracks;
|
2017-12-20 17:15:26 +00:00
|
|
|
Dictionary<uint, byte[]> trackIsrCs;
|
|
|
|
|
byte[] upc;
|
2014-07-09 19:52:00 +01:00
|
|
|
Dictionary<uint, NeroTrack> neroTracks;
|
2016-07-28 22:25:26 +01:00
|
|
|
Dictionary<uint, ulong> offsetmap;
|
2014-07-09 19:52:00 +01:00
|
|
|
List<Session> imageSessions;
|
2017-12-20 17:15:26 +00:00
|
|
|
List<Partition> imagePartitions;
|
2014-07-09 19:52:00 +01:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Methods
|
2015-10-05 19:45:07 +01:00
|
|
|
public Nero()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
Name = "Nero Burning ROM image";
|
2017-12-20 17:15:26 +00:00
|
|
|
PluginUuid = new Guid("D160F9FF-5941-43FC-B037-AD81DD141F05");
|
2014-07-09 19:52:00 +01:00
|
|
|
imageNewFormat = false;
|
2017-12-22 06:55:04 +00:00
|
|
|
ImageInfo = new ImageInfo
|
|
|
|
|
{
|
|
|
|
|
ReadableSectorTags = new List<SectorTagType>(),
|
|
|
|
|
ReadableMediaTags = new List<MediaTagType>()
|
|
|
|
|
};
|
2016-07-28 22:25:26 +01:00
|
|
|
neroSessions = new Dictionary<ushort, uint>();
|
2014-07-09 19:52:00 +01:00
|
|
|
neroTracks = new Dictionary<uint, NeroTrack>();
|
|
|
|
|
offsetmap = new Dictionary<uint, ulong>();
|
|
|
|
|
imageSessions = new List<Session>();
|
2017-12-20 17:15:26 +00:00
|
|
|
imagePartitions = new List<Partition>();
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Due to .cue format, this method must parse whole file, ignoring errors (those will be thrown by OpenImage()).
|
2016-09-05 17:37:31 +01:00
|
|
|
public override bool IdentifyImage(Filter imageFilter)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
imageStream = imageFilter.GetDataForkStream();
|
2014-07-09 19:52:00 +01:00
|
|
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
|
|
|
|
|
|
|
|
|
NeroV1Footer footerV1 = new NeroV1Footer();
|
|
|
|
|
NeroV2Footer footerV2 = new NeroV2Footer();
|
|
|
|
|
|
|
|
|
|
imageStream.Seek(-8, SeekOrigin.End);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] buffer = new byte[8];
|
2014-07-09 19:52:00 +01:00
|
|
|
imageStream.Read(buffer, 0, 8);
|
2017-12-20 17:15:26 +00:00
|
|
|
footerV1.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
footerV1.FirstChunkOffset = BigEndianBitConverter.ToUInt32(buffer, 4);
|
|
|
|
|
|
|
|
|
|
imageStream.Seek(-12, SeekOrigin.End);
|
|
|
|
|
buffer = new byte[12];
|
|
|
|
|
imageStream.Read(buffer, 0, 12);
|
2017-12-20 17:15:26 +00:00
|
|
|
footerV2.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
footerV2.FirstChunkOffset = BigEndianBitConverter.ToUInt64(buffer, 4);
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "imageStream.Length = {0}", imageStream.Length);
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "footerV1.ChunkID = 0x{0:X8}", footerV1.ChunkId);
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "footerV1.FirstChunkOffset = {0}", footerV1.FirstChunkOffset);
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "footerV2.ChunkID = 0x{0:X8}", footerV2.ChunkId);
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "footerV2.FirstChunkOffset = {0}", footerV2.FirstChunkOffset);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(footerV2.ChunkId == NERO_FOOTER_V2 && footerV2.FirstChunkOffset < (ulong)imageStream.Length) return true;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
return footerV1.ChunkId == NERO_FOOTER_V1 && footerV1.FirstChunkOffset < (ulong)imageStream.Length;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
public override bool OpenImage(Filter imageFilter)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
imageStream = imageFilter.GetDataForkStream();
|
2014-07-09 19:52:00 +01:00
|
|
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
|
|
|
|
|
|
|
|
|
NeroV1Footer footerV1 = new NeroV1Footer();
|
|
|
|
|
NeroV2Footer footerV2 = new NeroV2Footer();
|
|
|
|
|
|
|
|
|
|
imageStream.Seek(-8, SeekOrigin.End);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] buffer = new byte[8];
|
2014-07-09 19:52:00 +01:00
|
|
|
imageStream.Read(buffer, 0, 8);
|
2017-12-20 17:15:26 +00:00
|
|
|
footerV1.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
footerV1.FirstChunkOffset = BigEndianBitConverter.ToUInt32(buffer, 4);
|
|
|
|
|
|
|
|
|
|
imageStream.Seek(-12, SeekOrigin.End);
|
|
|
|
|
buffer = new byte[12];
|
|
|
|
|
imageStream.Read(buffer, 0, 12);
|
2017-12-20 17:15:26 +00:00
|
|
|
footerV2.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
footerV2.FirstChunkOffset = BigEndianBitConverter.ToUInt64(buffer, 4);
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "imageStream.Length = {0}", imageStream.Length);
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "footerV1.ChunkID = 0x{0:X8} (\"{1}\")", footerV1.ChunkId,
|
2017-12-21 14:30:38 +00:00
|
|
|
Encoding.ASCII
|
2017-12-20 17:15:26 +00:00
|
|
|
.GetString(BigEndianBitConverter.GetBytes(footerV1.ChunkId)));
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "footerV1.FirstChunkOffset = {0}", footerV1.FirstChunkOffset);
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "footerV2.ChunkID = 0x{0:X8} (\"{1}\")", footerV2.ChunkId,
|
2017-12-21 14:30:38 +00:00
|
|
|
Encoding.ASCII
|
2017-12-20 17:15:26 +00:00
|
|
|
.GetString(BigEndianBitConverter.GetBytes(footerV2.ChunkId)));
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "footerV2.FirstChunkOffset = {0}", footerV2.FirstChunkOffset);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(footerV1.ChunkId == NERO_FOOTER_V1 && footerV1.FirstChunkOffset < (ulong)imageStream.Length)
|
2017-12-19 20:33:03 +00:00
|
|
|
imageNewFormat = false;
|
2017-12-22 06:55:04 +00:00
|
|
|
else if(footerV2.ChunkId == NERO_FOOTER_V2 && footerV2.FirstChunkOffset < (ulong)imageStream.Length)
|
2017-12-19 20:33:03 +00:00
|
|
|
imageNewFormat = true;
|
2014-07-09 19:52:00 +01:00
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWrite("Nero plugin", "Nero version not recognized.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(imageNewFormat) imageStream.Seek((long)footerV2.FirstChunkOffset, SeekOrigin.Begin);
|
|
|
|
|
else imageStream.Seek(footerV1.FirstChunkOffset, SeekOrigin.Begin);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
bool parsing = true;
|
|
|
|
|
ushort currentsession = 1;
|
|
|
|
|
uint currenttrack = 1;
|
|
|
|
|
|
|
|
|
|
imageTracks = new List<Track>();
|
2017-12-20 17:15:26 +00:00
|
|
|
trackIsrCs = new Dictionary<uint, byte[]>();
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.MediaType = MediaType.CD;
|
|
|
|
|
ImageInfo.Sectors = 0;
|
|
|
|
|
ImageInfo.SectorSize = 0;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
while(parsing)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] chunkHeaderBuffer = new byte[8];
|
|
|
|
|
uint chunkId;
|
|
|
|
|
uint chunkLength;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
imageStream.Read(chunkHeaderBuffer, 0, 8);
|
|
|
|
|
chunkId = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 0);
|
|
|
|
|
chunkLength = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 4);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "ChunkID = 0x{0:X8} (\"{1}\")", chunkId,
|
2017-12-21 14:30:38 +00:00
|
|
|
Encoding.ASCII
|
2017-12-20 17:15:26 +00:00
|
|
|
.GetString(BigEndianBitConverter.GetBytes(chunkId)));
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "ChunkLength = {0}", chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
switch(chunkId)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_CUE_V1:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"CUES\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroCuesheetV1 = new NeroV1Cuesheet
|
|
|
|
|
{
|
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
ChunkSize = chunkLength,
|
|
|
|
|
Entries = new List<NeroV1CueEntry>()
|
|
|
|
|
};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
byte[] tmpbuffer = new byte[8];
|
|
|
|
|
for(int i = 0; i < neroCuesheetV1.ChunkSize; i += 8)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroV1CueEntry entry = new NeroV1CueEntry();
|
2017-12-19 20:33:03 +00:00
|
|
|
imageStream.Read(tmpbuffer, 0, 8);
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Mode = tmpbuffer[0];
|
|
|
|
|
entry.TrackNumber = tmpbuffer[1];
|
|
|
|
|
entry.IndexNumber = tmpbuffer[2];
|
|
|
|
|
entry.Dummy = BigEndianBitConverter.ToUInt16(tmpbuffer, 3);
|
|
|
|
|
entry.Minute = tmpbuffer[5];
|
|
|
|
|
entry.Second = tmpbuffer[6];
|
|
|
|
|
entry.Frame = tmpbuffer[7];
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", i / 8 + 1);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1:X2}", i / 8 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Mode);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = {1:X2}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 8 + 1, entry.TrackNumber);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].IndexNumber = {1:X2}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 8 + 1, entry.IndexNumber);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X4}", i / 8 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Dummy);
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Minute = {1:X2}", i / 8 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Minute);
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Second = {1:X2}", i / 8 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Second);
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Frame = {1:X2}", i / 8 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Frame);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
neroCuesheetV1.Entries.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_CUE_V2:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"CUEX\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroCuesheetV2 = new NeroV2Cuesheet
|
|
|
|
|
{
|
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
ChunkSize = chunkLength,
|
|
|
|
|
Entries = new List<NeroV2CueEntry>()
|
|
|
|
|
};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
byte[] tmpbuffer = new byte[8];
|
|
|
|
|
for(int i = 0; i < neroCuesheetV2.ChunkSize; i += 8)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroV2CueEntry entry = new NeroV2CueEntry();
|
2017-12-19 20:33:03 +00:00
|
|
|
imageStream.Read(tmpbuffer, 0, 8);
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Mode = tmpbuffer[0];
|
|
|
|
|
entry.TrackNumber = tmpbuffer[1];
|
|
|
|
|
entry.IndexNumber = tmpbuffer[2];
|
|
|
|
|
entry.Dummy = tmpbuffer[3];
|
|
|
|
|
entry.LbaStart = BigEndianBitConverter.ToInt32(tmpbuffer, 4);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", i / 8 + 1);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = 0x{1:X2}", i / 8 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Mode);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = {1:X2}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 8 + 1, entry.TrackNumber);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].IndexNumber = {1:X2}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 8 + 1, entry.IndexNumber);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X2}", i / 8 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Dummy);
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].LBAStart = {1}", i / 8 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.LbaStart);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
neroCuesheetV2.Entries.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_DAO_V1:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"DAOI\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroDaov1 = new NeroV1Dao {ChunkId = chunkId, ChunkSizeBe = chunkLength};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
byte[] tmpbuffer = new byte[22];
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 22);
|
2017-12-20 17:15:26 +00:00
|
|
|
neroDaov1.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
|
|
|
|
neroDaov1.Upc = new byte[14];
|
|
|
|
|
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<NeroV1DaoEntry>();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!ImageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN))
|
|
|
|
|
ImageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "neroDAOV1.ChunkSizeLe = {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
neroDaov1.ChunkSizeLe);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "neroDAOV1.UPC = \"{0}\"",
|
2017-12-20 17:15:26 +00:00
|
|
|
StringHandlers.CToString(neroDaov1.Upc));
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "neroDAOV1.TocType = 0x{0:X4}", neroDaov1.TocType);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "neroDAOV1.FirstTrack = {0}",
|
2017-12-20 17:15:26 +00:00
|
|
|
neroDaov1.FirstTrack);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "neroDAOV1.LastTrack = {0}", neroDaov1.LastTrack);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
upc = neroDaov1.Upc;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
tmpbuffer = new byte[30];
|
2017-12-20 17:26:28 +00:00
|
|
|
for(int i = 0; i < neroDaov1.ChunkSizeBe - 22; i += 30)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroV1DaoEntry entry = new NeroV1DaoEntry();
|
2017-12-19 20:33:03 +00:00
|
|
|
imageStream.Read(tmpbuffer, 0, 30);
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Isrc = new byte[12];
|
|
|
|
|
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);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", i / 32 + 1);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", i / 32 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
StringHandlers.CToString(entry.Isrc));
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].SectorSize = {1}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, entry.SectorSize);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, (DaoMode)entry.Mode, entry.Mode);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, entry.Unknown);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", i / 32 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Index0);
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", i / 32 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Index1);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, entry.EndOfTrack);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
neroDaov1.Tracks.Add(entry);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(entry.SectorSize > ImageInfo.SectorSize) ImageInfo.SectorSize = entry.SectorSize;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
trackIsrCs.Add(currenttrack, entry.Isrc);
|
|
|
|
|
if(currenttrack == 1) entry.Index0 = entry.Index1;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
NeroTrack neroTrack = new NeroTrack
|
|
|
|
|
{
|
|
|
|
|
EndOfTrack = entry.EndOfTrack,
|
|
|
|
|
Isrc = entry.Isrc,
|
|
|
|
|
Length = entry.EndOfTrack - entry.Index0,
|
|
|
|
|
Mode = entry.Mode,
|
|
|
|
|
Offset = entry.Index0,
|
|
|
|
|
SectorSize = entry.SectorSize,
|
|
|
|
|
StartLba = ImageInfo.Sectors,
|
|
|
|
|
Index0 = entry.Index0,
|
|
|
|
|
Index1 = entry.Index1,
|
|
|
|
|
Sequence = currenttrack
|
|
|
|
|
};
|
2017-12-20 17:15:26 +00:00
|
|
|
neroTrack.Sectors = neroTrack.Length / entry.SectorSize;
|
|
|
|
|
neroTracks.Add(currenttrack, neroTrack);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.Sectors += neroTrack.Sectors;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
currenttrack++;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_DAO_V2:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"DAOX\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroDaov2 = new NeroV2Dao {ChunkId = chunkId, ChunkSizeBe = chunkLength};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
byte[] tmpbuffer = new byte[22];
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 22);
|
2017-12-20 17:15:26 +00:00
|
|
|
neroDaov2.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
|
|
|
|
neroDaov2.Upc = new byte[14];
|
|
|
|
|
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<NeroV2DaoEntry>();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!ImageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN))
|
|
|
|
|
ImageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
upc = neroDaov2.Upc;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "neroDAOV2.ChunkSizeLe = {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
neroDaov2.ChunkSizeLe);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "neroDAOV2.UPC = \"{0}\"",
|
2017-12-20 17:15:26 +00:00
|
|
|
StringHandlers.CToString(neroDaov2.Upc));
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "neroDAOV2.TocType = 0x{0:X4}", neroDaov2.TocType);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "neroDAOV2.FirstTrack = {0}",
|
2017-12-20 17:15:26 +00:00
|
|
|
neroDaov2.FirstTrack);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "neroDAOV2.LastTrack = {0}", neroDaov2.LastTrack);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
tmpbuffer = new byte[42];
|
2017-12-20 17:26:28 +00:00
|
|
|
for(int i = 0; i < neroDaov2.ChunkSizeBe - 22; i += 42)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroV2DaoEntry entry = new NeroV2DaoEntry();
|
2017-12-19 20:33:03 +00:00
|
|
|
imageStream.Read(tmpbuffer, 0, 42);
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Isrc = new byte[12];
|
|
|
|
|
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);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", i / 32 + 1);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", i / 32 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
StringHandlers.CToString(entry.Isrc));
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].SectorSize = {1}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, entry.SectorSize);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, (DaoMode)entry.Mode, entry.Mode);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = {1:X2}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, entry.Unknown);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", i / 32 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Index0);
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", i / 32 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Index1);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, entry.EndOfTrack);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
neroDaov2.Tracks.Add(entry);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(entry.SectorSize > ImageInfo.SectorSize) ImageInfo.SectorSize = entry.SectorSize;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
trackIsrCs.Add(currenttrack, entry.Isrc);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(currenttrack == 1) entry.Index0 = entry.Index1;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
NeroTrack neroTrack = new NeroTrack
|
|
|
|
|
{
|
|
|
|
|
EndOfTrack = entry.EndOfTrack,
|
|
|
|
|
Isrc = entry.Isrc,
|
|
|
|
|
Length = entry.EndOfTrack - entry.Index0,
|
|
|
|
|
Mode = entry.Mode,
|
|
|
|
|
Offset = entry.Index0,
|
|
|
|
|
SectorSize = entry.SectorSize,
|
|
|
|
|
StartLba = ImageInfo.Sectors,
|
|
|
|
|
Index0 = entry.Index0,
|
|
|
|
|
Index1 = entry.Index1,
|
|
|
|
|
Sequence = currenttrack
|
|
|
|
|
};
|
2017-12-20 17:15:26 +00:00
|
|
|
neroTrack.Sectors = neroTrack.Length / entry.SectorSize;
|
|
|
|
|
neroTracks.Add(currenttrack, neroTrack);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.Sectors += neroTrack.Sectors;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
currenttrack++;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_CDTEXT:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"CDTX\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroCdtxt = new NeroCdText
|
|
|
|
|
{
|
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
ChunkSize = chunkLength,
|
|
|
|
|
Packs = new List<NeroCdTextPack>()
|
|
|
|
|
};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
byte[] tmpbuffer = new byte[18];
|
2017-12-20 17:26:28 +00:00
|
|
|
for(int i = 0; i < neroCdtxt.ChunkSize; i += 18)
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroCdTextPack entry = new NeroCdTextPack();
|
2017-12-19 20:33:03 +00:00
|
|
|
imageStream.Read(tmpbuffer, 0, 18);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.PackType = tmpbuffer[0];
|
|
|
|
|
entry.TrackNumber = tmpbuffer[1];
|
|
|
|
|
entry.PackNumber = tmpbuffer[2];
|
|
|
|
|
entry.BlockNumber = tmpbuffer[3];
|
|
|
|
|
entry.Text = new byte[12];
|
|
|
|
|
Array.Copy(tmpbuffer, 4, entry.Text, 0, 12);
|
|
|
|
|
entry.Crc = BigEndianBitConverter.ToUInt16(tmpbuffer, 16);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "CD-TEXT entry {0}", i / 18 + 1);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].PackType = 0x{1:X2}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 18 + 1, entry.PackType);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = 0x{1:X2}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 18 + 1, entry.TrackNumber);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].PackNumber = 0x{1:X2}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 18 + 1, entry.PackNumber);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].BlockNumber = 0x{1:X2}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 18 + 1, entry.BlockNumber);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Text = \"{1}\"", i / 18 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
StringHandlers.CToString(entry.Text));
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].CRC = 0x{1:X4}", i / 18 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Crc);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
neroCdtxt.Packs.Add(entry);
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_TAO_V1:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"ETNF\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroTaov1 = new NeroV1Tao
|
|
|
|
|
{
|
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
ChunkSize = chunkLength,
|
|
|
|
|
Tracks = new List<NeroV1TaoEntry>()
|
|
|
|
|
};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
byte[] tmpbuffer = new byte[20];
|
2017-12-20 17:26:28 +00:00
|
|
|
for(int i = 0; i < neroTaov1.ChunkSize; i += 20)
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroV1TaoEntry entry = new NeroV1TaoEntry();
|
2017-12-19 20:33:03 +00:00
|
|
|
imageStream.Read(tmpbuffer, 0, 20);
|
|
|
|
|
|
2017-12-20 17:15:26 +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);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", i / 20 + 1);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", i / 20 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Offset);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 20 + 1, entry.Length);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 20 + 1, (DaoMode)entry.Mode, entry.Mode);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", i / 20 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.StartLba);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 20 + 1, entry.Unknown);
|
2017-12-20 17:15:26 +00:00
|
|
|
|
|
|
|
|
neroTaov1.Tracks.Add(entry);
|
|
|
|
|
|
|
|
|
|
if(NeroTrackModeToBytesPerSector((DaoMode)entry.Mode) > ImageInfo.SectorSize)
|
|
|
|
|
ImageInfo.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
NeroTrack neroTrack = new NeroTrack
|
|
|
|
|
{
|
|
|
|
|
EndOfTrack = entry.Offset + entry.Length,
|
|
|
|
|
Isrc = new byte[12],
|
|
|
|
|
Length = entry.Length,
|
|
|
|
|
Mode = entry.Mode,
|
|
|
|
|
Offset = entry.Offset,
|
|
|
|
|
SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode),
|
|
|
|
|
StartLba = ImageInfo.Sectors,
|
|
|
|
|
Index0 = entry.Offset,
|
|
|
|
|
Index1 = entry.Offset,
|
|
|
|
|
Sequence = currenttrack
|
|
|
|
|
};
|
2017-12-20 17:15:26 +00:00
|
|
|
neroTrack.Sectors =
|
|
|
|
|
neroTrack.Length / NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
|
|
|
|
neroTracks.Add(currenttrack, neroTrack);
|
|
|
|
|
|
|
|
|
|
ImageInfo.Sectors += neroTrack.Sectors;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
currenttrack++;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_TAO_V2:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"ETN2\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroTaov2 = new NeroV2Tao
|
|
|
|
|
{
|
|
|
|
|
ChunkId = chunkId,
|
|
|
|
|
ChunkSize = chunkLength,
|
|
|
|
|
Tracks = new List<NeroV2TaoEntry>()
|
|
|
|
|
};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
byte[] tmpbuffer = new byte[32];
|
2017-12-20 17:26:28 +00:00
|
|
|
for(int i = 0; i < neroTaov2.ChunkSize; i += 32)
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
NeroV2TaoEntry entry = new NeroV2TaoEntry();
|
2017-12-19 20:33:03 +00:00
|
|
|
imageStream.Read(tmpbuffer, 0, 32);
|
|
|
|
|
|
2017-12-20 17:15:26 +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);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", i / 32 + 1);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", i / 32 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Offset);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, entry.Length);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, (DaoMode)entry.Mode, entry.Mode);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", i / 32 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.StartLba);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}",
|
2017-12-20 17:26:28 +00:00
|
|
|
i / 32 + 1, entry.Unknown);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Sectors = {1}", i / 32 + 1,
|
2017-12-20 17:15:26 +00:00
|
|
|
entry.Sectors);
|
|
|
|
|
|
|
|
|
|
neroTaov2.Tracks.Add(entry);
|
|
|
|
|
|
|
|
|
|
if(NeroTrackModeToBytesPerSector((DaoMode)entry.Mode) > ImageInfo.SectorSize)
|
|
|
|
|
ImageInfo.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
NeroTrack neroTrack = new NeroTrack
|
|
|
|
|
{
|
|
|
|
|
EndOfTrack = entry.Offset + entry.Length,
|
|
|
|
|
Isrc = new byte[12],
|
|
|
|
|
Length = entry.Length,
|
|
|
|
|
Mode = entry.Mode,
|
|
|
|
|
Offset = entry.Offset
|
|
|
|
|
};
|
2017-12-20 17:15:26 +00:00
|
|
|
neroTrack.Sectors =
|
|
|
|
|
neroTrack.Length / NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
|
|
|
|
neroTrack.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode);
|
|
|
|
|
neroTrack.StartLba = ImageInfo.Sectors;
|
|
|
|
|
neroTrack.Index0 = entry.Offset;
|
|
|
|
|
neroTrack.Index1 = entry.Offset;
|
|
|
|
|
neroTrack.Sequence = currenttrack;
|
|
|
|
|
neroTracks.Add(currenttrack, neroTrack);
|
|
|
|
|
|
|
|
|
|
ImageInfo.Sectors += neroTrack.Sectors;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
currenttrack++;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_SESSION:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"SINF\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
uint sessionTracks;
|
|
|
|
|
byte[] tmpbuffer = new byte[4];
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 4);
|
|
|
|
|
sessionTracks = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
|
|
|
|
neroSessions.Add(currentsession, sessionTracks);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\tSession {0} has {1} tracks", currentsession,
|
|
|
|
|
sessionTracks);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
currentsession++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_DISC_TYPE:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"MTYP\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroMediaTyp = new NeroMediaType {ChunkId = chunkId, ChunkSize = chunkLength};
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
byte[] tmpbuffer = new byte[4];
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 4);
|
|
|
|
|
neroMediaTyp.Type = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\tMedia type is {0} ({1})",
|
|
|
|
|
(NeroMediaTypes)neroMediaTyp.Type, neroMediaTyp.Type);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.MediaType = NeroMediaTypeToMediaType((NeroMediaTypes)neroMediaTyp.Type);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_DISC_INFO:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"DINF\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroDiscInfo = new NeroDiscInformation {ChunkId = chunkId, ChunkSize = chunkLength};
|
2017-12-19 20:33:03 +00:00
|
|
|
byte[] tmpbuffer = new byte[4];
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 4);
|
|
|
|
|
neroDiscInfo.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\tneroDiscInfo.Unknown = 0x{0:X4} ({0})",
|
|
|
|
|
neroDiscInfo.Unknown);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_RELOCATION:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"RELO\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroRelo = new NeroReloChunk {ChunkId = chunkId, ChunkSize = chunkLength};
|
2017-12-19 20:33:03 +00:00
|
|
|
byte[] tmpbuffer = new byte[4];
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
neroRelo.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\tneroRELO.Unknown = 0x{0:X4} ({0})",
|
2017-12-20 17:15:26 +00:00
|
|
|
neroRelo.Unknown);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_TOC:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"TOCT\" chunk, parsing {0} bytes",
|
2017-12-20 17:15:26 +00:00
|
|
|
chunkLength);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroToc = new NeroTocChunk {ChunkId = chunkId, ChunkSize = chunkLength};
|
2017-12-19 20:33:03 +00:00
|
|
|
byte[] tmpbuffer = new byte[2];
|
|
|
|
|
imageStream.Read(tmpbuffer, 0, 2);
|
2017-12-20 17:15:26 +00:00
|
|
|
neroToc.Unknown = BigEndianBitConverter.ToUInt16(tmpbuffer, 0);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\tneroTOC.Unknown = 0x{0:X4} ({0})",
|
2017-12-20 17:15:26 +00:00
|
|
|
neroToc.Unknown);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case NERO_END:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Found \"END!\" chunk, finishing parse");
|
|
|
|
|
parsing = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
default:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Unknown chunk ID \"{0}\", skipping...",
|
2017-12-21 14:30:38 +00:00
|
|
|
Encoding.ASCII.GetString(BigEndianBitConverter
|
2017-12-20 17:15:26 +00:00
|
|
|
.GetBytes(chunkId)));
|
|
|
|
|
imageStream.Seek(chunkLength, SeekOrigin.Current);
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.ImageHasPartitions = true;
|
|
|
|
|
ImageInfo.ImageHasSessions = true;
|
|
|
|
|
ImageInfo.ImageCreator = null;
|
|
|
|
|
ImageInfo.ImageCreationTime = imageFilter.GetCreationTime();
|
|
|
|
|
ImageInfo.ImageLastModificationTime = imageFilter.GetLastWriteTime();
|
|
|
|
|
ImageInfo.ImageName = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
|
|
|
|
|
ImageInfo.ImageComments = 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;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(imageNewFormat)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.ImageSize = footerV2.FirstChunkOffset;
|
|
|
|
|
ImageInfo.ImageVersion = "Nero Burning ROM >= 5.5";
|
|
|
|
|
ImageInfo.ImageApplication = "Nero Burning ROM";
|
|
|
|
|
ImageInfo.ImageApplicationVersion = ">= 5.5";
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.ImageSize = footerV1.FirstChunkOffset;
|
|
|
|
|
ImageInfo.ImageVersion = "Nero Burning ROM <= 5.0";
|
|
|
|
|
ImageInfo.ImageApplication = "Nero Burning ROM";
|
|
|
|
|
ImageInfo.ImageApplicationVersion = "<= 5.0";
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(neroSessions.Count == 0) neroSessions.Add(1, currenttrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "Building offset, track and session maps");
|
2014-07-09 19:52:00 +01:00
|
|
|
|
|
|
|
|
currentsession = 1;
|
2017-12-22 06:55:04 +00:00
|
|
|
neroSessions.TryGetValue(1, out uint currentsessionmaxtrack);
|
2014-07-09 19:52:00 +01:00
|
|
|
uint currentsessioncurrenttrack = 1;
|
|
|
|
|
Session currentsessionstruct = new Session();
|
2017-12-20 17:15:26 +00:00
|
|
|
ulong partitionSequence = 0;
|
2016-08-08 18:44:08 +01:00
|
|
|
ulong partitionStartByte = 0;
|
2016-04-19 02:11:47 +01:00
|
|
|
for(uint i = 1; i <= neroTracks.Count; i++)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
if(!neroTracks.TryGetValue(i, out NeroTrack neroTrack)) continue;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\tcurrentsession = {0}", currentsession);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\tcurrentsessionmaxtrack = {0}",
|
|
|
|
|
currentsessionmaxtrack);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\tcurrentsessioncurrenttrack = {0}",
|
|
|
|
|
currentsessioncurrenttrack);
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
Track track = new Track();
|
2017-12-21 06:06:19 +00:00
|
|
|
if(neroTrack.Sequence == 1) neroTrack.Index0 = neroTrack.Index1;
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
track.Indexes = new Dictionary<int, ulong>();
|
2017-12-21 06:06:19 +00:00
|
|
|
if(neroTrack.Index0 < neroTrack.Index1)
|
2017-12-22 06:55:04 +00:00
|
|
|
track.Indexes.Add(0, neroTrack.Index0 / neroTrack.SectorSize);
|
|
|
|
|
track.Indexes.Add(1, neroTrack.Index1 / neroTrack.SectorSize);
|
|
|
|
|
track.TrackDescription = StringHandlers.CToString(neroTrack.Isrc);
|
|
|
|
|
track.TrackEndSector = neroTrack.Length / neroTrack.SectorSize + neroTrack.StartLba - 1;
|
|
|
|
|
track.TrackPregap = (neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize;
|
|
|
|
|
track.TrackSequence = neroTrack.Sequence;
|
|
|
|
|
track.TrackSession = currentsession;
|
|
|
|
|
track.TrackStartSector = neroTrack.StartLba;
|
|
|
|
|
track.TrackType = NeroTrackModeToTrackType((DaoMode)neroTrack.Mode);
|
|
|
|
|
track.TrackFile = imageFilter.GetFilename();
|
|
|
|
|
track.TrackFilter = imageFilter;
|
|
|
|
|
track.TrackFileOffset = neroTrack.Offset;
|
|
|
|
|
track.TrackFileType = "BINARY";
|
|
|
|
|
track.TrackSubchannelType = TrackSubchannelType.None;
|
2017-12-21 06:06:19 +00:00
|
|
|
switch((DaoMode)neroTrack.Mode)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-21 06:06:19 +00:00
|
|
|
case DaoMode.Audio:
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackBytesPerSector = 2352;
|
|
|
|
|
track.TrackRawBytesPerSector = 2352;
|
2017-12-21 06:06:19 +00:00
|
|
|
break;
|
|
|
|
|
case DaoMode.AudioSub:
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackBytesPerSector = 2352;
|
|
|
|
|
track.TrackRawBytesPerSector = 2448;
|
|
|
|
|
track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
|
2017-12-21 06:06:19 +00:00
|
|
|
break;
|
|
|
|
|
case DaoMode.Data:
|
|
|
|
|
case DaoMode.DataM2F1:
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackBytesPerSector = 2048;
|
|
|
|
|
track.TrackRawBytesPerSector = 2048;
|
2017-12-21 06:06:19 +00:00
|
|
|
break;
|
|
|
|
|
case DaoMode.DataM2F2:
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackBytesPerSector = 2336;
|
|
|
|
|
track.TrackRawBytesPerSector = 2336;
|
2017-12-21 06:06:19 +00:00
|
|
|
break;
|
|
|
|
|
case DaoMode.DataM2Raw:
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackBytesPerSector = 2352;
|
|
|
|
|
track.TrackRawBytesPerSector = 2352;
|
2017-12-21 06:06:19 +00:00
|
|
|
break;
|
|
|
|
|
case DaoMode.DataM2RawSub:
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackBytesPerSector = 2352;
|
|
|
|
|
track.TrackRawBytesPerSector = 2448;
|
|
|
|
|
track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
|
2017-12-21 06:06:19 +00:00
|
|
|
break;
|
|
|
|
|
case DaoMode.DataRaw:
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackBytesPerSector = 2048;
|
|
|
|
|
track.TrackRawBytesPerSector = 2352;
|
2017-12-21 06:06:19 +00:00
|
|
|
break;
|
|
|
|
|
case DaoMode.DataRawSub:
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackBytesPerSector = 2048;
|
|
|
|
|
track.TrackRawBytesPerSector = 2448;
|
|
|
|
|
track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
|
2017-12-21 06:06:19 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2015-12-06 05:09:31 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(track.TrackSubchannelType == TrackSubchannelType.RawInterleaved)
|
2017-12-21 06:06:19 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackSubchannelFilter = imageFilter;
|
|
|
|
|
track.TrackSubchannelFile = imageFilter.GetFilename();
|
|
|
|
|
track.TrackSubchannelOffset = neroTrack.Offset;
|
2017-12-21 06:06:19 +00:00
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
imageTracks.Add(track);
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackDescription = {0}",
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackDescription);
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackEndSector = {0}",
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackEndSector);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackPregap = {0}", track.TrackPregap);
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackSequence = {0}",
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackSequence);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackSession = {0}", track.TrackSession);
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackStartSector = {0}",
|
2017-12-22 06:55:04 +00:00
|
|
|
track.TrackStartSector);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackType = {0}", track.TrackType);
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
if(currentsessioncurrenttrack == 1)
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
currentsessionstruct = new Session
|
|
|
|
|
{
|
|
|
|
|
SessionSequence = currentsession,
|
|
|
|
|
StartSector = track.TrackStartSector,
|
|
|
|
|
StartTrack = track.TrackSequence
|
|
|
|
|
};
|
2017-12-21 06:06:19 +00:00
|
|
|
}
|
|
|
|
|
currentsessioncurrenttrack++;
|
|
|
|
|
if(currentsessioncurrenttrack > currentsessionmaxtrack)
|
|
|
|
|
{
|
|
|
|
|
currentsession++;
|
|
|
|
|
neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack);
|
|
|
|
|
currentsessioncurrenttrack = 1;
|
2017-12-22 06:55:04 +00:00
|
|
|
currentsessionstruct.EndTrack = track.TrackSequence;
|
|
|
|
|
currentsessionstruct.EndSector = track.TrackEndSector;
|
2017-12-21 06:06:19 +00:00
|
|
|
imageSessions.Add(currentsessionstruct);
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
if(i == neroTracks.Count)
|
|
|
|
|
{
|
|
|
|
|
neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack);
|
|
|
|
|
currentsessioncurrenttrack = 1;
|
2017-12-22 06:55:04 +00:00
|
|
|
currentsessionstruct.EndTrack = track.TrackSequence;
|
|
|
|
|
currentsessionstruct.EndSector = track.TrackEndSector;
|
2017-12-21 06:06:19 +00:00
|
|
|
imageSessions.Add(currentsessionstruct);
|
|
|
|
|
}
|
2016-08-08 18:44:08 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
offsetmap.Add(track.TrackSequence, track.TrackStartSector);
|
|
|
|
|
DicConsole.DebugWriteLine("Nero plugin", "\t\t Offset[{0}]: {1}", track.TrackSequence,
|
|
|
|
|
track.TrackStartSector);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
/*if(_neroTrack.Index0 < _neroTrack.Index1)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2016-07-28 22:25:26 +01:00
|
|
|
partition = new Partition();
|
|
|
|
|
partition.PartitionDescription = string.Format("Track {0} Index 0", _track.TrackSequence);
|
2014-07-09 19:52:00 +01:00
|
|
|
partition.PartitionLength = (_neroTrack.Index1 - _neroTrack.Index0);
|
|
|
|
|
partition.PartitionName = StringHandlers.CToString(_neroTrack.ISRC);
|
|
|
|
|
partition.PartitionSectors = partition.PartitionLength / _neroTrack.SectorSize;
|
|
|
|
|
partition.PartitionSequence = PartitionSequence;
|
|
|
|
|
partition.PartitionStart = _neroTrack.Index0;
|
|
|
|
|
partition.PartitionStartSector = _neroTrack.StartLBA;
|
|
|
|
|
partition.PartitionType = NeroTrackModeToTrackType((DAOMode)_neroTrack.Mode).ToString();
|
|
|
|
|
ImagePartitions.Add(partition);
|
|
|
|
|
PartitionSequence++;
|
2016-08-08 18:44:08 +01:00
|
|
|
}*/
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
Partition partition = new Partition
|
|
|
|
|
{
|
|
|
|
|
Description = $"Track {track.TrackSequence} Index 1",
|
|
|
|
|
Size = neroTrack.EndOfTrack - neroTrack.Index1,
|
|
|
|
|
Name = StringHandlers.CToString(neroTrack.Isrc),
|
|
|
|
|
Sequence = partitionSequence,
|
|
|
|
|
Offset = partitionStartByte,
|
|
|
|
|
Start = neroTrack.StartLba + (neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize,
|
|
|
|
|
Type = NeroTrackModeToTrackType((DaoMode)neroTrack.Mode).ToString()
|
|
|
|
|
};
|
2017-12-21 06:06:19 +00:00
|
|
|
partition.Length = partition.Size / neroTrack.SectorSize;
|
|
|
|
|
imagePartitions.Add(partition);
|
|
|
|
|
partitionSequence++;
|
|
|
|
|
partitionStartByte += partition.Size;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
neroFilter = imageFilter;
|
2015-12-05 17:21:47 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(ImageInfo.MediaType == MediaType.Unknown || ImageInfo.MediaType == MediaType.CD)
|
2016-08-08 18:44:08 +01:00
|
|
|
{
|
|
|
|
|
bool data = false;
|
|
|
|
|
bool mode2 = false;
|
|
|
|
|
bool firstaudio = false;
|
|
|
|
|
bool firstdata = false;
|
|
|
|
|
bool audio = false;
|
|
|
|
|
|
2017-08-07 16:08:15 +01:00
|
|
|
for(int i = 0; i < neroTracks.Count; i++)
|
2016-08-08 18:44:08 +01:00
|
|
|
{
|
|
|
|
|
// First track is audio
|
2017-12-20 17:15:26 +00:00
|
|
|
firstaudio |= i == 0 && ((DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio ||
|
|
|
|
|
(DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioSub);
|
2016-08-08 18:44:08 +01:00
|
|
|
|
|
|
|
|
// First track is data
|
2017-12-20 17:26:28 +00:00
|
|
|
firstdata |= i == 0 && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub;
|
2016-08-08 18:44:08 +01:00
|
|
|
|
|
|
|
|
// Any non first track is data
|
2017-12-20 17:26:28 +00:00
|
|
|
data |= i != 0 && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub;
|
2016-08-08 18:44:08 +01:00
|
|
|
|
|
|
|
|
// Any non first track is audio
|
2017-12-20 17:15:26 +00:00
|
|
|
audio |= i != 0 && ((DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio ||
|
|
|
|
|
(DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioSub);
|
2016-08-08 18:44:08 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
switch((DaoMode)neroTracks.ElementAt(i).Value.Mode)
|
2016-08-08 18:44:08 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataM2F1:
|
|
|
|
|
case DaoMode.DataM2F2:
|
|
|
|
|
case DaoMode.DataM2Raw:
|
|
|
|
|
case DaoMode.DataM2RawSub:
|
2016-08-08 18:44:08 +01:00
|
|
|
mode2 = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!data && !firstdata) ImageInfo.MediaType = MediaType.CDDA;
|
2016-08-08 18:44:08 +01:00
|
|
|
else if(firstaudio && data && imageSessions.Count > 1 && mode2)
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.MediaType = MediaType.CDPLUS;
|
2017-12-20 17:26:28 +00:00
|
|
|
else if(firstdata && audio || mode2) ImageInfo.MediaType = MediaType.CDROMXA;
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(!audio) ImageInfo.MediaType = MediaType.CDROM;
|
|
|
|
|
else ImageInfo.MediaType = MediaType.CD;
|
2016-08-08 18:44:08 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.XmlMediaType = XmlMediaType.OpticalDisc;
|
|
|
|
|
DicConsole.VerboseWriteLine("Nero image contains a disc of type {0}", ImageInfo.MediaType);
|
2015-12-05 17:21:47 +00:00
|
|
|
|
2014-07-09 19:52:00 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWrite("Nero plugin", "Exception ocurred opening file.");
|
|
|
|
|
return false;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool ImageHasPartitions()
|
|
|
|
|
{
|
|
|
|
|
// Even if they only have 1 track, there is a partition (track 1)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override ulong GetImageSize()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override ulong GetSectors()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.Sectors;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override uint GetSectorSize()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.SectorSize;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
public override byte[] ReadDiskTag(MediaTagType tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case MediaTagType.CD_MCN: return upc;
|
2017-12-19 20:33:03 +00:00
|
|
|
case MediaTagType.CD_TEXT: throw new NotImplementedException("Not yet implemented");
|
2014-07-09 19:52:00 +01:00
|
|
|
default:
|
|
|
|
|
throw new FeaturedNotSupportedByDiscImageException("Requested disk tag not supported by image");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSector(ulong sectorAddress)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectors(sectorAddress, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectorsTag(sectorAddress, 1, tag);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSector(ulong sectorAddress, uint track)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectors(sectorAddress, 1, track);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectorsTag(sectorAddress, 1, track, tag);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectors(ulong sectorAddress, uint length)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap where sectorAddress >= kvp.Value from track in imageTracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector select kvp) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-21 17:58:51 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found");
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap where sectorAddress >= kvp.Value from track in imageTracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector select kvp) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-21 17:58:51 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found");
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
if(!neroTracks.TryGetValue(track, out NeroTrack dicTrack))
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track not found");
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(length > dicTrack.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
2017-12-22 06:55:04 +00:00
|
|
|
$"Requested more sectors ({length}) than present in track ({dicTrack.Sectors}), won't cross tracks");
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
uint sectorOffset;
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
uint sectorSkip;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
switch((DaoMode)dicTrack.Mode)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.Data:
|
|
|
|
|
case DaoMode.DataM2F1:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataM2F2:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 8;
|
|
|
|
|
sectorSize = 2324;
|
|
|
|
|
sectorSkip = 4;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.Audio:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2352;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataRaw:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 16;
|
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
sectorSkip = 288;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataM2Raw:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 16;
|
|
|
|
|
sectorSize = 2336;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
// TODO: Supposing Nero suffixes the subchannel to the channel
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataRawSub:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 16;
|
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
sectorSkip = 288 + 96;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataM2RawSub:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 16;
|
|
|
|
|
sectorSize = 2336;
|
|
|
|
|
sectorSkip = 96;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.AudioSub:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2352;
|
|
|
|
|
sectorSkip = 96;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
imageStream = neroFilter.GetDataForkStream();
|
2016-09-05 17:37:31 +01:00
|
|
|
BinaryReader br = new BinaryReader(imageStream);
|
2017-12-19 20:33:03 +00:00
|
|
|
br.BaseStream
|
2017-12-22 06:55:04 +00:00
|
|
|
.Seek((long)dicTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
2017-12-19 20:33:03 +00:00
|
|
|
SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length));
|
2016-09-05 17:37:31 +01:00
|
|
|
else
|
|
|
|
|
for(int i = 0; i < length; i++)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
|
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
if(!neroTracks.TryGetValue(track, out NeroTrack dicTrack))
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track not found");
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(length > dicTrack.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
2017-12-22 06:55:04 +00:00
|
|
|
$"Requested more sectors ({length}) than present in track ({dicTrack.Sectors}), won't cross tracks");
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
uint sectorOffset;
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
uint sectorSkip;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEcc:
|
|
|
|
|
case SectorTagType.CdSectorEccP:
|
|
|
|
|
case SectorTagType.CdSectorEccQ:
|
|
|
|
|
case SectorTagType.CdSectorEdc:
|
|
|
|
|
case SectorTagType.CdSectorHeader:
|
|
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
case SectorTagType.CdSectorSubHeader:
|
|
|
|
|
case SectorTagType.CdSectorSync: break;
|
|
|
|
|
case SectorTagType.CdTrackFlags:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
byte[] flags = new byte[1];
|
|
|
|
|
flags[0] = 0x00;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if((DaoMode)dicTrack.Mode != DaoMode.Audio && (DaoMode)dicTrack.Mode != DaoMode.AudioSub)
|
2017-12-19 20:33:03 +00:00
|
|
|
flags[0] += 0x40;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
return flags;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case SectorTagType.CdTrackIsrc: return dicTrack.Isrc;
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdTrackText:
|
2014-07-09 19:52:00 +01:00
|
|
|
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
|
2017-12-19 20:33:03 +00:00
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
switch((DaoMode)dicTrack.Mode)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.Data:
|
|
|
|
|
case DaoMode.DataM2F1: throw new ArgumentException("No tags in image for requested track", nameof(tag));
|
|
|
|
|
case DaoMode.DataM2F2:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
switch(tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSync:
|
|
|
|
|
case SectorTagType.CdSectorHeader:
|
|
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
case SectorTagType.CdSectorEcc:
|
|
|
|
|
case SectorTagType.CdSectorEccP:
|
|
|
|
|
case SectorTagType.CdSectorEccQ:
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubHeader:
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 8;
|
|
|
|
|
sectorSkip = 2328;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEdc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2332;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.Audio: throw new ArgumentException("There are no tags on audio tracks", nameof(tag));
|
|
|
|
|
case DaoMode.DataRaw:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
switch(tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSync:
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 12;
|
|
|
|
|
sectorSkip = 2340;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorHeader:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 12;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 2336;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
case SectorTagType.CdSectorSubHeader:
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEcc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2076;
|
|
|
|
|
sectorSize = 276;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEccP:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2076;
|
|
|
|
|
sectorSize = 172;
|
|
|
|
|
sectorSkip = 104;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEccQ:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2248;
|
|
|
|
|
sectorSize = 104;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEdc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2064;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 284;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
// TODO
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataM2RawSub:
|
2014-07-09 19:52:00 +01:00
|
|
|
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataRawSub:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
switch(tag)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSync:
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 12;
|
|
|
|
|
sectorSkip = 2340 + 96;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorHeader:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 12;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 2336 + 96;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubchannel:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2352;
|
|
|
|
|
sectorSize = 96;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubHeader:
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEcc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2076;
|
|
|
|
|
sectorSize = 276;
|
|
|
|
|
sectorSkip = 0 + 96;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEccP:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2076;
|
|
|
|
|
sectorSize = 172;
|
|
|
|
|
sectorSkip = 104 + 96;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEccQ:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2248;
|
|
|
|
|
sectorSize = 104;
|
|
|
|
|
sectorSkip = 0 + 96;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEdc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2064;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 284 + 96;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.AudioSub:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
if(tag != SectorTagType.CdSectorSubchannel)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2352;
|
|
|
|
|
sectorSize = 96;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
imageStream = neroFilter.GetDataForkStream();
|
2016-09-05 17:37:31 +01:00
|
|
|
BinaryReader br = new BinaryReader(imageStream);
|
2017-12-19 20:33:03 +00:00
|
|
|
br.BaseStream
|
2017-12-22 06:55:04 +00:00
|
|
|
.Seek((long)dicTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
2017-12-19 20:33:03 +00:00
|
|
|
SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length));
|
2016-09-05 17:37:31 +01:00
|
|
|
else
|
|
|
|
|
for(int i = 0; i < length; i++)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
|
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorLong(ulong sectorAddress)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectorsLong(sectorAddress, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
|
|
|
|
return ReadSectorsLong(sectorAddress, 1, track);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap where sectorAddress >= kvp.Value from track in imageTracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector select kvp) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-21 17:58:51 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found");
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
if(!neroTracks.TryGetValue(track, out NeroTrack dicTrack))
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track not found");
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(length > dicTrack.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
2017-12-22 06:55:04 +00:00
|
|
|
$"Requested more sectors ({length}) than present in track ({dicTrack.Sectors}), won't cross tracks");
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
uint sectorOffset;
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
uint sectorSkip;
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
switch((DaoMode)dicTrack.Mode)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.Data:
|
|
|
|
|
case DaoMode.DataM2F1:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataM2F2:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2336;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataRaw:
|
|
|
|
|
case DaoMode.DataM2Raw:
|
|
|
|
|
case DaoMode.Audio:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2352;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.DataRawSub:
|
|
|
|
|
case DaoMode.DataM2RawSub:
|
|
|
|
|
case DaoMode.AudioSub:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2448;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
imageStream = neroFilter.GetDataForkStream();
|
2014-07-09 19:52:00 +01:00
|
|
|
BinaryReader br = new BinaryReader(imageStream);
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
br.BaseStream
|
2017-12-22 06:55:04 +00:00
|
|
|
.Seek((long)dicTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
2017-12-19 20:33:03 +00:00
|
|
|
SeekOrigin.Begin);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length));
|
2014-07-09 19:52:00 +01:00
|
|
|
else
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < length; i++)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
2014-07-09 19:52:00 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageFormat()
|
|
|
|
|
{
|
|
|
|
|
return "Nero Burning ROM";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageVersion()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageVersion;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageApplication()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageApplication;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageApplicationVersion()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageApplicationVersion;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override DateTime GetImageCreationTime()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageCreationTime;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override DateTime GetImageLastModificationTime()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageLastModificationTime;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
public override string GetMediaBarcode()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaBarcode;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
public override MediaType GetMediaType()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaType;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override List<Partition> GetPartitions()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return imagePartitions;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override List<Track> GetTracks()
|
|
|
|
|
{
|
|
|
|
|
return imageTracks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override List<Track> GetSessionTracks(Session session)
|
|
|
|
|
{
|
|
|
|
|
return GetSessionTracks(session.SessionSequence);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override List<Track> GetSessionTracks(ushort session)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
return imageTracks.Where(track => track.TrackSession == session).ToList();
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override List<Session> GetSessions()
|
|
|
|
|
{
|
|
|
|
|
return imageSessions;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override bool? VerifySector(ulong sectorAddress)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorLong(sectorAddress);
|
2017-12-21 14:30:38 +00:00
|
|
|
return CdChecksums.CheckCdSector(buffer);
|
2014-08-25 05:00:25 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override bool? VerifySector(ulong sectorAddress, uint track)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorLong(sectorAddress, track);
|
2017-12-21 14:30:38 +00:00
|
|
|
return CdChecksums.CheckCdSector(buffer);
|
2014-08-25 05:00:25 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
|
|
|
|
|
out List<ulong> unknownLbas)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorsLong(sectorAddress, length);
|
|
|
|
|
int bps = (int)(buffer.Length / length);
|
|
|
|
|
byte[] sector = new byte[bps];
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2014-08-25 05:00:25 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < length; i++)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
Array.Copy(buffer, i * bps, sector, 0, bps);
|
2017-12-21 14:30:38 +00:00
|
|
|
bool? sectorStatus = CdChecksums.CheckCdSector(sector);
|
2014-08-25 05:00:25 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(sectorStatus)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
case null:
|
2017-12-20 17:15:26 +00:00
|
|
|
unknownLbas.Add((ulong)i + sectorAddress);
|
2014-08-25 05:00:25 +01:00
|
|
|
break;
|
|
|
|
|
case false:
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas.Add((ulong)i + sectorAddress);
|
2014-08-25 05:00:25 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(unknownLbas.Count > 0) return null;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
return failingLbas.Count <= 0;
|
2014-08-25 05:00:25 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
|
|
|
|
out List<ulong> unknownLbas)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorsLong(sectorAddress, length, track);
|
|
|
|
|
int bps = (int)(buffer.Length / length);
|
|
|
|
|
byte[] sector = new byte[bps];
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2014-08-25 05:00:25 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < length; i++)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
Array.Copy(buffer, i * bps, sector, 0, bps);
|
2017-12-21 14:30:38 +00:00
|
|
|
bool? sectorStatus = CdChecksums.CheckCdSector(sector);
|
2014-08-25 05:00:25 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(sectorStatus)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
case null:
|
2017-12-20 17:15:26 +00:00
|
|
|
unknownLbas.Add((ulong)i + sectorAddress);
|
2014-08-25 05:00:25 +01:00
|
|
|
break;
|
|
|
|
|
case false:
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas.Add((ulong)i + sectorAddress);
|
2014-08-25 05:00:25 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(unknownLbas.Count > 0) return null;
|
|
|
|
|
if(failingLbas.Count > 0) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2014-08-25 05:00:25 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
public override bool? VerifyMediaImage()
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2014-07-09 19:52:00 +01:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Private methods
|
2016-01-16 03:54:55 +00:00
|
|
|
static MediaType NeroMediaTypeToMediaType(NeroMediaTypes type)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(type)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case NeroMediaTypes.NeroMtypDdcd: return MediaType.DDCD;
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdM:
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdMR: return MediaType.DVDR;
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdP:
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdPR: return MediaType.DVDPR;
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdRam: return MediaType.DVDRAM;
|
|
|
|
|
case NeroMediaTypes.NeroMtypMl:
|
|
|
|
|
case NeroMediaTypes.NeroMtypMrw:
|
|
|
|
|
case NeroMediaTypes.NeroMtypCdrw: return MediaType.CDRW;
|
|
|
|
|
case NeroMediaTypes.NeroMtypCdr: return MediaType.CDR;
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdRom:
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdAny:
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdAnyR9:
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdAnyOld: return MediaType.DVDROM;
|
|
|
|
|
case NeroMediaTypes.NeroMtypCdrom: return MediaType.CDROM;
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdMRw: return MediaType.DVDRW;
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdPRw: return MediaType.DVDPRW;
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdPR9: return MediaType.DVDPRDL;
|
|
|
|
|
case NeroMediaTypes.NeroMtypDvdMR9: return MediaType.DVDRDL;
|
|
|
|
|
case NeroMediaTypes.NeroMtypBd:
|
|
|
|
|
case NeroMediaTypes.NeroMtypBdAny:
|
|
|
|
|
case NeroMediaTypes.NeroMtypBdRom: return MediaType.BDROM;
|
|
|
|
|
case NeroMediaTypes.NeroMtypBdR: return MediaType.BDR;
|
|
|
|
|
case NeroMediaTypes.NeroMtypBdRe: return MediaType.BDRE;
|
|
|
|
|
case NeroMediaTypes.NeroMtypHdDvd:
|
|
|
|
|
case NeroMediaTypes.NeroMtypHdDvdAny:
|
|
|
|
|
case NeroMediaTypes.NeroMtypHdDvdRom: return MediaType.HDDVDROM;
|
|
|
|
|
case NeroMediaTypes.NeroMtypHdDvdR: return MediaType.HDDVDR;
|
|
|
|
|
case NeroMediaTypes.NeroMtypHdDvdRw: return MediaType.HDDVDRW;
|
2017-12-19 20:33:03 +00:00
|
|
|
default: return MediaType.CD;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
static TrackType NeroTrackModeToTrackType(DaoMode mode)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(mode)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.Data:
|
|
|
|
|
case DaoMode.DataRaw:
|
|
|
|
|
case DaoMode.DataRawSub: return TrackType.CdMode1;
|
|
|
|
|
case DaoMode.DataM2F1: return TrackType.CdMode2Form1;
|
|
|
|
|
case DaoMode.DataM2F2: return TrackType.CdMode2Form2;
|
|
|
|
|
case DaoMode.DataM2RawSub:
|
|
|
|
|
case DaoMode.DataM2Raw: return TrackType.CdMode2Formless;
|
|
|
|
|
case DaoMode.Audio:
|
|
|
|
|
case DaoMode.AudioSub: return TrackType.Audio;
|
2017-12-19 20:33:03 +00:00
|
|
|
default: return TrackType.Data;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
static ushort NeroTrackModeToBytesPerSector(DaoMode mode)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(mode)
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case DaoMode.Data:
|
|
|
|
|
case DaoMode.DataM2F1: return 2048;
|
|
|
|
|
case DaoMode.DataM2F2: return 2336;
|
|
|
|
|
case DaoMode.DataRaw:
|
|
|
|
|
case DaoMode.DataM2Raw:
|
|
|
|
|
case DaoMode.Audio: return 2352;
|
|
|
|
|
case DaoMode.DataM2RawSub:
|
|
|
|
|
case DaoMode.DataRawSub:
|
|
|
|
|
case DaoMode.AudioSub: return 2448;
|
2017-12-19 20:33:03 +00:00
|
|
|
default: return 2352;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Unsupported features
|
2016-01-16 03:54:55 +00:00
|
|
|
public override int GetMediaSequence()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaSequence;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetLastDiskSequence()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.LastMediaSequence;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetDriveManufacturer()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.DriveManufacturer;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetDriveModel()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.DriveModel;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetDriveSerialNumber()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.DriveSerialNumber;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
public override string GetMediaPartNumber()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaPartNumber;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
public override string GetMediaManufacturer()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaManufacturer;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
public override string GetMediaModel()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaModel;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageName()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageName;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageCreator()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageCreator;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageComments()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageComments;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
public override string GetMediaSerialNumber()
|
2014-07-09 19:52:00 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaSerialNumber;
|
2014-07-09 19:52:00 +01:00
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|