Refactor and code cleanup.

This commit is contained in:
2016-07-28 22:25:26 +01:00
parent c93d469da9
commit a63ba13b6b
199 changed files with 3614 additions and 3744 deletions

View File

@@ -49,71 +49,71 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Offset 0x00, magic
/// </summary>
public UInt32 magic;
public uint magic;
/// <summary>
/// Offset 0x04, disk image creator ID
/// </summary>
public UInt32 creator;
public uint creator;
/// <summary>
/// Offset 0x08, header size, constant 0x0040
/// </summary>
public UInt16 headerSize;
public ushort headerSize;
/// <summary>
/// Offset 0x0A, disk image version
/// </summary>
public UInt16 version;
public ushort version;
/// <summary>
/// Offset 0x0C, disk image format
/// </summary>
public UInt32 imageFormat;
public uint imageFormat;
/// <summary>
/// Offset 0x10, flags and volume number
/// </summary>
public UInt32 flags;
public uint flags;
/// <summary>
/// Offset 0x14, blocks for ProDOS, 0 otherwise
/// </summary>
public UInt32 blocks;
public uint blocks;
/// <summary>
/// Offset 0x18, offset to data
/// </summary>
public UInt32 dataOffset;
public uint dataOffset;
/// <summary>
/// Offset 0x1C, data size in bytes
/// </summary>
public UInt32 dataSize;
public uint dataSize;
/// <summary>
/// Offset 0x20, offset to optional comment
/// </summary>
public UInt32 commentOffset;
public uint commentOffset;
/// <summary>
/// Offset 0x24, length of optional comment
/// </summary>
public UInt32 commentSize;
public uint commentSize;
/// <summary>
/// Offset 0x28, offset to creator specific chunk
/// </summary>
public UInt32 creatorSpecificOffset;
public uint creatorSpecificOffset;
/// <summary>
/// Offset 0x2C, creator specific chunk size
/// </summary>
public UInt32 creatorSpecificSize;
public uint creatorSpecificSize;
/// <summary>
/// Offset 0x30, reserved, should be zero
/// </summary>
public UInt32 reserved1;
public uint reserved1;
/// <summary>
/// Offset 0x34, reserved, should be zero
/// </summary>
public UInt32 reserved2;
public uint reserved2;
/// <summary>
/// Offset 0x38, reserved, should be zero
/// </summary>
public UInt32 reserved3;
public uint reserved3;
/// <summary>
/// Offset 0x3C, reserved, should be zero
/// </summary>
public UInt32 reserved4;
public uint reserved4;
}
#endregion
@@ -123,39 +123,39 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Magic number, "2IMG"
/// </summary>
public const UInt32 MAGIC = 0x474D4932;
public const uint MAGIC = 0x474D4932;
/// <summary>
/// Disk image created by ASIMOV2, "!nfc"
/// </summary>
public const UInt32 CreatorAsimov = 0x63666E21;
public const uint CreatorAsimov = 0x63666E21;
/// <summary>
/// Disk image created by Bernie ][ the Rescue, "B2TR"
/// </summary>
public const UInt32 CreatorBernie = 0x52543242;
public const uint CreatorBernie = 0x52543242;
/// <summary>
/// Disk image created by Catakig, "CTKG"
/// </summary>
public const UInt32 CreatorCatakig = 0x474B5443;
public const uint CreatorCatakig = 0x474B5443;
/// <summary>
/// Disk image created by Sheppy's ImageMaker, "ShIm"
/// </summary>
public const UInt32 CreatorSheppy = 0x6D496853;
public const uint CreatorSheppy = 0x6D496853;
/// <summary>
/// Disk image created by Sweet16, "WOOF"
/// </summary>
public const UInt32 CreatorSweet = 0x464F4F57;
public const uint CreatorSweet = 0x464F4F57;
/// <summary>
/// Disk image created by XGS, "XGS!"
/// </summary>
public const UInt32 CreatorXGS = 0x21534758;
public const uint CreatorXGS = 0x21534758;
public const UInt32 DOSSectorOrder = 0x00000000;
public const UInt32 ProDOSSectorOrder = 0x00000001;
public const UInt32 NIBSectorOrder = 0x00000002;
public const uint DOSSectorOrder = 0x00000000;
public const uint ProDOSSectorOrder = 0x00000001;
public const uint NIBSectorOrder = 0x00000002;
public const UInt32 LockedDisk = 0x80000000;
public const UInt32 ValidVolumeNumber = 0x00000100;
public const UInt32 VolumeNumberMask = 0x000000FF;
public const uint LockedDisk = 0x80000000;
public const uint ValidVolumeNumber = 0x00000100;
public const uint VolumeNumberMask = 0x000000FF;
#endregion
@@ -203,34 +203,34 @@ namespace DiscImageChef.ImagePlugins
byte[] header = new byte[64];
stream.Read(header, 0, 64);
UInt32 magic = BitConverter.ToUInt32(header, 0x00);
uint magic = BitConverter.ToUInt32(header, 0x00);
if(magic != MAGIC)
return false;
UInt32 dataoff = BitConverter.ToUInt32(header, 0x18);
uint dataoff = BitConverter.ToUInt32(header, 0x18);
if(dataoff > stream.Length)
return false;
UInt32 datasize = BitConverter.ToUInt32(header, 0x1C);
uint datasize = BitConverter.ToUInt32(header, 0x1C);
// There seems to be incorrect endian in some images on the wild
if(datasize == 0x00800C00)
datasize = 0x000C8000;
if(dataoff + datasize > stream.Length)
return false;
UInt32 commentoff = BitConverter.ToUInt32(header, 0x20);
uint commentoff = BitConverter.ToUInt32(header, 0x20);
if(commentoff > stream.Length)
return false;
UInt32 commentsize = BitConverter.ToUInt32(header, 0x24);
uint commentsize = BitConverter.ToUInt32(header, 0x24);
if(commentoff + commentsize > stream.Length)
return false;
UInt32 creatoroff = BitConverter.ToUInt32(header, 0x28);
uint creatoroff = BitConverter.ToUInt32(header, 0x28);
if(creatoroff > stream.Length)
return false;
UInt32 creatorsize = BitConverter.ToUInt32(header, 0x2C);
uint creatorsize = BitConverter.ToUInt32(header, 0x2C);
return creatoroff + creatorsize <= stream.Length;
}
@@ -331,7 +331,7 @@ namespace DiscImageChef.ImagePlugins
ImageInfo.imageApplication = "XGS";
break;
default:
ImageInfo.imageApplication = String.Format("Unknown creator code \"{0}\"", Encoding.ASCII.GetString(creator));
ImageInfo.imageApplication = string.Format("Unknown creator code \"{0}\"", Encoding.ASCII.GetString(creator));
break;
}
@@ -454,10 +454,10 @@ namespace DiscImageChef.ImagePlugins
public override byte[] ReadSectors(ulong sectorAddress, uint length)
{
if(sectorAddress > ImageInfo.sectors - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
if(sectorAddress + length > ImageInfo.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
byte[] buffer = new byte[length * ImageInfo.sectorSize];
@@ -579,7 +579,7 @@ namespace DiscImageChef.ImagePlugins
return null;
}
public override List<CommonTypes.Partition> GetPartitions()
public override List<Partition> GetPartitions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}

View File

@@ -49,11 +49,11 @@ namespace DiscImageChef.ImagePlugins
struct CDRDAOTrackFile
{
/// <summary>Track #</summary>
public UInt32 sequence;
public uint sequence;
/// <summary>Path of file containing track</summary>
public string datafile;
/// <summary>Offset of track start in file</summary>
public UInt64 offset;
public ulong offset;
/// <summary>Type of file</summary>
public string filetype;
}
@@ -61,7 +61,7 @@ namespace DiscImageChef.ImagePlugins
struct CDRDAOTrack
{
/// <summary>Track #</summary>
public UInt32 sequence;
public uint sequence;
/// <summary>Track title (from CD-Text)</summary>
public string title;
/// <summary>Track genre (from CD-Text)</summary>
@@ -81,11 +81,11 @@ namespace DiscImageChef.ImagePlugins
/// <summary>File struct for this track</summary>
public CDRDAOTrackFile trackfile;
/// <summary>Indexes on this track</summary>
public Dictionary<int, UInt64> indexes;
public Dictionary<int, ulong> indexes;
/// <summary>Track pre-gap in sectors</summary>
public UInt64 pregap;
public ulong pregap;
/// <summary>Track post-gap in sectors</summary>
public UInt64 postgap;
public ulong postgap;
/// <summary>Digical Copy Permitted</summary>
public bool flag_dcp;
/// <summary>Track is quadraphonic</summary>
@@ -93,11 +93,11 @@ namespace DiscImageChef.ImagePlugins
/// <summary>Track has preemphasis</summary>
public bool flag_pre;
/// <summary>Bytes per sector</summary>
public UInt16 bps;
public ushort bps;
/// <summary>Sectors in track</summary>
public UInt64 sectors;
public ulong sectors;
/// <summary>Starting sector in track</summary>
public UInt64 startSector;
public ulong startSector;
/// <summary>Track type</summary>
public string tracktype;
public bool subchannel;
@@ -165,8 +165,8 @@ namespace DiscImageChef.ImagePlugins
StreamReader tocStream;
FileStream imageStream;
/// <summary>Dictionary, index is track #, value is TrackFile</summary>
Dictionary<UInt32, UInt64> offsetmap;
List<CommonTypes.Partition> partitions;
Dictionary<uint, ulong> offsetmap;
List<Partition> partitions;
CDRDAODisc discimage;
#endregion
@@ -476,7 +476,7 @@ namespace DiscImageChef.ImagePlugins
currenttrack.bps = 2336;
break;
default:
throw new NotSupportedException(String.Format("Track mode {0} is unsupported", MatchTrack.Groups["type"].Value));
throw new NotSupportedException(string.Format("Track mode {0} is unsupported", MatchTrack.Groups["type"].Value));
}
switch(MatchTrack.Groups["subchan"].Value)
@@ -491,7 +491,7 @@ namespace DiscImageChef.ImagePlugins
currenttrack.subchannel = true;
break;
default:
throw new NotSupportedException(String.Format("Track subchannel mode {0} is unsupported", MatchTrack.Groups["subchan"].Value));
throw new NotSupportedException(string.Format("Track subchannel mode {0} is unsupported", MatchTrack.Groups["subchan"].Value));
}
currenttrack.tracktype = MatchTrack.Groups["type"].Value;
@@ -685,7 +685,7 @@ namespace DiscImageChef.ImagePlugins
/*
else // Non-empty unknown field
{
throw new FeatureUnsupportedImageException(String.Format("Found unknown field defined at line {0}: \"{1}\"", line, _line));
throw new FeatureUnsupportedImageException(string.Format("Found unknown field defined at line {0}: \"{1}\"", line, _line));
}
*/
}
@@ -811,7 +811,7 @@ namespace DiscImageChef.ImagePlugins
Partition partition = new Partition();
// Index 01
partition.PartitionDescription = String.Format("Track {0}.", discimage.tracks[i].sequence);
partition.PartitionDescription = string.Format("Track {0}.", discimage.tracks[i].sequence);
partition.PartitionName = discimage.tracks[i].title;
partition.PartitionStartSector = discimage.tracks[i].startSector;
partition.PartitionLength = (discimage.tracks[i].sectors - index0_len) * discimage.tracks[i].bps;
@@ -961,17 +961,17 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.imageHasPartitions;
}
public override UInt64 GetImageSize()
public override ulong GetImageSize()
{
return ImageInfo.imageSize;
}
public override UInt64 GetSectors()
public override ulong GetSectors()
{
return ImageInfo.sectors;
}
public override UInt32 GetSectorSize()
public override uint GetSectorSize()
{
return ImageInfo.sectorSize;
}
@@ -993,27 +993,27 @@ namespace DiscImageChef.ImagePlugins
}
}
public override byte[] ReadSector(UInt64 sectorAddress)
public override byte[] ReadSector(ulong sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
{
return ReadSectorsTag(sectorAddress, 1, tag);
}
public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSector(ulong sectorAddress, uint track)
{
return ReadSectors(sectorAddress, 1, track);
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
{
return ReadSectorsTag(sectorAddress, 1, track, tag);
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectors(ulong sectorAddress, uint length)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -1030,10 +1030,10 @@ namespace DiscImageChef.ImagePlugins
}
}
throw new ArgumentOutOfRangeException("sectorAddress", String.Format("Sector address {0} not found", sectorAddress));
throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress));
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -1050,10 +1050,10 @@ namespace DiscImageChef.ImagePlugins
}
}
throw new ArgumentOutOfRangeException("sectorAddress", String.Format("Sector address {0} not found", sectorAddress));
throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress));
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
{
CDRDAOTrack _track = new CDRDAOTrack();
@@ -1069,10 +1069,10 @@ namespace DiscImageChef.ImagePlugins
}
if(_track.sequence == 0)
throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
if(length > _track.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -1155,7 +1155,7 @@ namespace DiscImageChef.ImagePlugins
return buffer;
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
{
CDRDAOTrack _track = new CDRDAOTrack();
@@ -1171,17 +1171,17 @@ namespace DiscImageChef.ImagePlugins
}
if(_track.sequence == 0)
throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
if(length > _track.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
uint sector_skip = 0;
if(!_track.subchannel && tag == SectorTagType.CDSectorSubchannel)
throw new ArgumentException("No tags in image for requested track", "tag");
throw new ArgumentException("No tags in image for requested track", nameof(tag));
switch(tag)
{
@@ -1215,7 +1215,7 @@ namespace DiscImageChef.ImagePlugins
case SectorTagType.CDTrackISRC:
return Encoding.UTF8.GetBytes(_track.isrc);
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
switch(_track.tracktype)
@@ -1228,7 +1228,7 @@ namespace DiscImageChef.ImagePlugins
sector_size = 96;
break;
}
throw new ArgumentException("No tags in image for requested track", "tag");
throw new ArgumentException("No tags in image for requested track", nameof(tag));
case CDRDAOTrackTypeMode2Form2:
case CDRDAOTrackTypeMode2Mix:
if(tag == SectorTagType.CDSectorSubchannel)
@@ -1237,7 +1237,7 @@ namespace DiscImageChef.ImagePlugins
sector_size = 96;
break;
}
throw new ArgumentException("No tags in image for requested track", "tag");
throw new ArgumentException("No tags in image for requested track", nameof(tag));
case CDRDAOTrackTypeAudio:
if(tag == SectorTagType.CDSectorSubchannel)
{
@@ -1245,7 +1245,7 @@ namespace DiscImageChef.ImagePlugins
sector_size = 96;
break;
}
throw new ArgumentException("No tags in image for requested track", "tag");
throw new ArgumentException("No tags in image for requested track", nameof(tag));
case CDRDAOTrackTypeMode1Raw:
{
switch(tag)
@@ -1271,7 +1271,7 @@ namespace DiscImageChef.ImagePlugins
break;
}
case SectorTagType.CDSectorSubHeader:
throw new ArgumentException("Unsupported tag requested for this track", "tag");
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
case SectorTagType.CDSectorECC:
{
sector_offset = 2076;
@@ -1301,7 +1301,7 @@ namespace DiscImageChef.ImagePlugins
break;
}
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
break;
}
@@ -1341,17 +1341,17 @@ namespace DiscImageChef.ImagePlugins
return buffer;
}
public override byte[] ReadSectorLong(UInt64 sectorAddress)
public override byte[] ReadSectorLong(ulong sectorAddress)
{
return ReadSectorsLong(sectorAddress, 1);
}
public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
{
return ReadSectorsLong(sectorAddress, 1, track);
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -1368,10 +1368,10 @@ namespace DiscImageChef.ImagePlugins
}
}
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
{
CDRDAOTrack _track = new CDRDAOTrack();
@@ -1387,10 +1387,10 @@ namespace DiscImageChef.ImagePlugins
}
if(_track.sequence == 0)
throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
if(length > _track.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -1574,25 +1574,25 @@ namespace DiscImageChef.ImagePlugins
throw new NotImplementedException();
}
public override bool? VerifySector(UInt64 sectorAddress)
public override bool? VerifySector(ulong sectorAddress)
{
byte[] buffer = ReadSectorLong(sectorAddress);
return Checksums.CDChecksums.CheckCDSector(buffer);
}
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
public override bool? VerifySector(ulong sectorAddress, uint track)
{
byte[] buffer = ReadSectorLong(sectorAddress, track);
return Checksums.CDChecksums.CheckCDSector(buffer);
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(int i = 0; i < length; i++)
{
@@ -1617,13 +1617,13 @@ namespace DiscImageChef.ImagePlugins
return true;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length, track);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(int i = 0; i < length; i++)
{
@@ -1657,7 +1657,7 @@ namespace DiscImageChef.ImagePlugins
#region Private methods
static UInt16 CDRDAOTrackTypeToBytesPerSector(string trackType)
static ushort CDRDAOTrackTypeToBytesPerSector(string trackType)
{
switch(trackType)
{
@@ -1678,7 +1678,7 @@ namespace DiscImageChef.ImagePlugins
}
}
static UInt16 CDRDAOTrackTypeToCookedBytesPerSector(string trackType)
static ushort CDRDAOTrackTypeToCookedBytesPerSector(string trackType)
{
switch(trackType)
{

View File

@@ -36,7 +36,6 @@ using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using DiscImageChef;
using DiscImageChef.Console;
using DiscImageChef.CommonTypes;
@@ -49,11 +48,11 @@ namespace DiscImageChef.ImagePlugins
struct CDRWinTrackFile
{
/// <summary>Track #</summary>
public UInt32 sequence;
public uint sequence;
/// <summary>Path of file containing track</summary>
public string datafile;
/// <summary>Offset of track start in file</summary>
public UInt64 offset;
public ulong offset;
/// <summary>Type of file</summary>
public string filetype;
}
@@ -61,7 +60,7 @@ namespace DiscImageChef.ImagePlugins
struct CDRWinTrack
{
/// <summary>Track #</summary>
public UInt32 sequence;
public uint sequence;
/// <summary>Track title (from CD-Text)</summary>
public string title;
/// <summary>Track genre (from CD-Text)</summary>
@@ -79,11 +78,11 @@ namespace DiscImageChef.ImagePlugins
/// <summary>File struct for this track</summary>
public CDRWinTrackFile trackfile;
/// <summary>Indexes on this track</summary>
public Dictionary<int, UInt64> indexes;
public Dictionary<int, ulong> indexes;
/// <summary>Track pre-gap in sectors</summary>
public UInt64 pregap;
public ulong pregap;
/// <summary>Track post-gap in sectors</summary>
public UInt64 postgap;
public ulong postgap;
/// <summary>Digical Copy Permitted</summary>
public bool flag_dcp;
/// <summary>Track is quadraphonic</summary>
@@ -93,13 +92,13 @@ namespace DiscImageChef.ImagePlugins
/// <summary>Track has SCMS</summary>
public bool flag_scms;
/// <summary>Bytes per sector</summary>
public UInt16 bps;
public ushort bps;
/// <summary>Sectors in track</summary>
public UInt64 sectors;
public ulong sectors;
/// <summary>Track type</summary>
public string tracktype;
/// <summary>Track session</summary>
public UInt16 session;
public ushort session;
}
#endregion
@@ -248,9 +247,9 @@ namespace DiscImageChef.ImagePlugins
StreamReader cueStream;
FileStream imageStream;
/// <summary>Dictionary, index is track #, value is TrackFile</summary>
Dictionary<UInt32, UInt64> offsetmap;
Dictionary<uint, ulong> offsetmap;
CDRWinDisc discimage;
List<CommonTypes.Partition> partitions;
List<Partition> partitions;
#endregion
@@ -443,7 +442,7 @@ namespace DiscImageChef.ImagePlugins
{
uint track_seq = uint.Parse(MatchTrack.Groups[1].Value);
if(track_count + 1 != track_seq)
throw new FeatureUnsupportedImageException(String.Format("Found TRACK {0} out of order in line {1}", track_seq, line));
throw new FeatureUnsupportedImageException(string.Format("Found TRACK {0} out of order in line {1}", track_seq, line));
track_count++;
}
@@ -482,12 +481,12 @@ namespace DiscImageChef.ImagePlugins
}
else if(MatchDiskType.Success && intrack)
{
throw new FeatureUnsupportedImageException(String.Format("Found REM ORIGINAL MEDIA TYPE field after a track in line {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found REM ORIGINAL MEDIA TYPE field after a track in line {0}", line));
}
else if(MatchSession.Success)
{
DicConsole.DebugWriteLine("CDRWin plugin", "Found REM SESSION at line {0}", line);
currentsession = Byte.Parse(MatchSession.Groups[1].Value);
currentsession = byte.Parse(MatchSession.Groups[1].Value);
// What happens between sessions
}
@@ -543,7 +542,7 @@ namespace DiscImageChef.ImagePlugins
if(!intrack)
discimage.barcode = MatchBarCode.Groups[1].Value;
else
throw new FeatureUnsupportedImageException(String.Format("Found barcode field in incorrect place at line {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found barcode field in incorrect place at line {0}", line));
}
else if(MatchCDText.Success)
{
@@ -551,7 +550,7 @@ namespace DiscImageChef.ImagePlugins
if(!intrack)
discimage.cdtextfile = MatchCDText.Groups[1].Value;
else
throw new FeatureUnsupportedImageException(String.Format("Found CD-Text file field in incorrect place at line {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found CD-Text file field in incorrect place at line {0}", line));
}
else if(MatchComposer.Success)
{
@@ -567,7 +566,7 @@ namespace DiscImageChef.ImagePlugins
if(!intrack)
discimage.disk_id = MatchDiskID.Groups[1].Value;
else
throw new FeatureUnsupportedImageException(String.Format("Found CDDB ID field in incorrect place at line {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found CDDB ID field in incorrect place at line {0}", line));
}
else if(MatchFile.Success)
{
@@ -612,11 +611,11 @@ namespace DiscImageChef.ImagePlugins
currentfile.datafile = path + Path.PathSeparator + currentfile.datafile;
if(!File.Exists(currentfile.datafile))
throw new FeatureUnsupportedImageException(String.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value));
throw new FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value));
}
}
else
throw new FeatureUnsupportedImageException(String.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value));
throw new FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value));
}
else if((currentfile.datafile[1] == ':' && currentfile.datafile[2] == '\\') ||
(currentfile.datafile[0] == '\\' && currentfile.datafile[1] == '\\') ||
@@ -634,11 +633,11 @@ namespace DiscImageChef.ImagePlugins
currentfile.datafile = path + Path.PathSeparator + currentfile.datafile;
if(!File.Exists(currentfile.datafile))
throw new FeatureUnsupportedImageException(String.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value));
throw new FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value));
}
}
else
throw new FeatureUnsupportedImageException(String.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value));
throw new FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value));
}
else
{
@@ -646,7 +645,7 @@ namespace DiscImageChef.ImagePlugins
currentfile.datafile = path + Path.DirectorySeparatorChar + currentfile.datafile;
if(!File.Exists(currentfile.datafile))
throw new FeatureUnsupportedImageException(String.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value));
throw new FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value));
}
}
@@ -661,9 +660,9 @@ namespace DiscImageChef.ImagePlugins
case CDRWinDiskTypeAIFF:
case CDRWinDiskTypeRIFF:
case CDRWinDiskTypeMP3:
throw new FeatureSupportedButNotImplementedImageException(String.Format("Unsupported file type {0}", currentfile.filetype));
throw new FeatureSupportedButNotImplementedImageException(string.Format("Unsupported file type {0}", currentfile.filetype));
default:
throw new FeatureUnsupportedImageException(String.Format("Unknown file type {0}", currentfile.filetype));
throw new FeatureUnsupportedImageException(string.Format("Unknown file type {0}", currentfile.filetype));
}
currentfile.offset = 0;
@@ -673,9 +672,8 @@ namespace DiscImageChef.ImagePlugins
{
DicConsole.DebugWriteLine("CDRWin plugin", "Found FLAGS at line {0}", line);
if(!intrack)
throw new FeatureUnsupportedImageException(String.Format("Found FLAGS field in incorrect place at line {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found FLAGS field in incorrect place at line {0}", line));
const string FlagsRegEx = "FLAGS\\s+(((?<dcp>DCP)|(?<quad>4CH)|(?<pre>PRE)|(?<scms>SCMS))\\s*)+$";
currenttrack.flag_dcp |= MatchFile.Groups["dcp"].Value == "DCP";
currenttrack.flag_4ch |= MatchFile.Groups["quad"].Value == "4CH";
currenttrack.flag_pre |= MatchFile.Groups["pre"].Value == "PRE";
@@ -693,14 +691,14 @@ namespace DiscImageChef.ImagePlugins
{
DicConsole.DebugWriteLine("CDRWin plugin", "Found INDEX at line {0}", line);
if(!intrack)
throw new FeatureUnsupportedImageException(String.Format("Found INDEX before a track {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found INDEX before a track {0}", line));
else
{
int index = int.Parse(MatchIndex.Groups[1].Value);
ulong offset = CDRWinMSFToLBA(MatchIndex.Groups[2].Value);
if((index != 0 && index != 1) && currenttrack.indexes.Count == 0)
throw new FeatureUnsupportedImageException(String.Format("Found INDEX {0} before INDEX 00 or INDEX 01", index));
throw new FeatureUnsupportedImageException(string.Format("Found INDEX {0} before INDEX 00 or INDEX 01", index));
if((index == 0 || (index == 1 && !currenttrack.indexes.ContainsKey(0))))
{
@@ -728,7 +726,7 @@ namespace DiscImageChef.ImagePlugins
{
DicConsole.DebugWriteLine("CDRWin plugin", "Found ISRC at line {0}", line);
if(!intrack)
throw new FeatureUnsupportedImageException(String.Format("Found ISRC before a track {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found ISRC before a track {0}", line));
currenttrack.isrc = MatchISRC.Groups[1].Value;
}
else if(MatchMCN.Success)
@@ -737,7 +735,7 @@ namespace DiscImageChef.ImagePlugins
if(!intrack)
discimage.mcn = MatchMCN.Groups[1].Value;
else
throw new FeatureUnsupportedImageException(String.Format("Found CATALOG field in incorrect place at line {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found CATALOG field in incorrect place at line {0}", line));
}
else if(MatchPerformer.Success)
{
@@ -755,7 +753,7 @@ namespace DiscImageChef.ImagePlugins
currenttrack.postgap = CDRWinMSFToLBA(MatchPostgap.Groups[1].Value);
}
else
throw new FeatureUnsupportedImageException(String.Format("Found POSTGAP field before a track at line {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found POSTGAP field before a track at line {0}", line));
}
else if(MatchPregap.Success)
{
@@ -765,7 +763,7 @@ namespace DiscImageChef.ImagePlugins
currenttrack.pregap = CDRWinMSFToLBA(MatchPregap.Groups[1].Value);
}
else
throw new FeatureUnsupportedImageException(String.Format("Found PREGAP field before a track at line {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found PREGAP field before a track at line {0}", line));
}
else if(MatchSongWriter.Success)
{
@@ -787,7 +785,7 @@ namespace DiscImageChef.ImagePlugins
{
DicConsole.DebugWriteLine("CDRWin plugin", "Found TRACK at line {0}", line);
if(currentfile.datafile == "")
throw new FeatureUnsupportedImageException(String.Format("Found TRACK field before a file is defined at line {0}", line));
throw new FeatureUnsupportedImageException(string.Format("Found TRACK field before a file is defined at line {0}", line));
if(intrack)
{
if(currenttrack.indexes.ContainsKey(0) && currenttrack.pregap == 0)
@@ -814,7 +812,7 @@ namespace DiscImageChef.ImagePlugins
}
else // Non-empty unknown field
{
throw new FeatureUnsupportedImageException(String.Format("Found unknown field defined at line {0}: \"{1}\"", line, _line));
throw new FeatureUnsupportedImageException(string.Format("Found unknown field defined at line {0}: \"{1}\"", line, _line));
}
}
}
@@ -1044,7 +1042,7 @@ namespace DiscImageChef.ImagePlugins
DicConsole.DebugWriteLine("CDRWin plugin", "Building offset map");
partitions = new List<CommonTypes.Partition>();
partitions = new List<Partition>();
ulong byte_offset = 0;
ulong sector_offset = 0;
@@ -1062,11 +1060,11 @@ namespace DiscImageChef.ImagePlugins
if(discimage.tracks[i].sequence == 1 && i != 0)
throw new ImageNotSupportedException("Unordered tracks");
CommonTypes.Partition partition = new CommonTypes.Partition();
Partition partition = new Partition();
if(discimage.tracks[i].pregap > 0)
{
partition.PartitionDescription = String.Format("Track {0} pregap.", discimage.tracks[i].sequence);
partition.PartitionDescription = string.Format("Track {0} pregap.", discimage.tracks[i].sequence);
partition.PartitionName = discimage.tracks[i].title;
partition.PartitionStartSector = sector_offset;
partition.PartitionLength = discimage.tracks[i].pregap * discimage.tracks[i].bps;
@@ -1094,17 +1092,17 @@ namespace DiscImageChef.ImagePlugins
}
partitions.Add(partition);
partition = new CommonTypes.Partition();
partition = new Partition();
}
index_zero |= discimage.tracks[i].indexes.TryGetValue(0, out index_zero_offset);
if(!discimage.tracks[i].indexes.TryGetValue(1, out index_one_offset))
throw new ImageNotSupportedException(String.Format("Track {0} lacks index 01", discimage.tracks[i].sequence));
throw new ImageNotSupportedException(string.Format("Track {0} lacks index 01", discimage.tracks[i].sequence));
if(index_zero && index_one_offset > index_zero_offset)
{
partition.PartitionDescription = String.Format("Track {0} index 00.", discimage.tracks[i].sequence);
partition.PartitionDescription = string.Format("Track {0} index 00.", discimage.tracks[i].sequence);
partition.PartitionName = discimage.tracks[i].title;
partition.PartitionStartSector = sector_offset;
partition.PartitionLength = (index_one_offset - index_zero_offset) * discimage.tracks[i].bps;
@@ -1133,11 +1131,11 @@ namespace DiscImageChef.ImagePlugins
}
partitions.Add(partition);
partition = new CommonTypes.Partition();
partition = new Partition();
}
// Index 01
partition.PartitionDescription = String.Format("Track {0}.", discimage.tracks[i].sequence);
partition.PartitionDescription = string.Format("Track {0}.", discimage.tracks[i].sequence);
partition.PartitionName = discimage.tracks[i].title;
partition.PartitionStartSector = sector_offset;
partition.PartitionLength = (discimage.tracks[i].sectors - index0_len) * discimage.tracks[i].bps;
@@ -1165,12 +1163,12 @@ namespace DiscImageChef.ImagePlugins
}
partitions.Add(partition);
partition = new CommonTypes.Partition();
partition = new Partition();
}
// Print offset map
DicConsole.DebugWriteLine("CDRWin plugin", "printing partition map");
foreach(CommonTypes.Partition partition in partitions)
foreach(Partition partition in partitions)
{
DicConsole.DebugWriteLine("CDRWin plugin", "Partition sequence: {0}", partition.PartitionSequence);
DicConsole.DebugWriteLine("CDRWin plugin", "\tPartition name: {0}", partition.PartitionName);
@@ -1296,17 +1294,17 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.imageHasPartitions;
}
public override UInt64 GetImageSize()
public override ulong GetImageSize()
{
return ImageInfo.imageSize;
}
public override UInt64 GetSectors()
public override ulong GetSectors()
{
return ImageInfo.sectors;
}
public override UInt32 GetSectorSize()
public override uint GetSectorSize()
{
return ImageInfo.sectorSize;
}
@@ -1335,27 +1333,27 @@ namespace DiscImageChef.ImagePlugins
}
}
public override byte[] ReadSector(UInt64 sectorAddress)
public override byte[] ReadSector(ulong sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
{
return ReadSectorsTag(sectorAddress, 1, tag);
}
public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSector(ulong sectorAddress, uint track)
{
return ReadSectors(sectorAddress, 1, track);
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
{
return ReadSectorsTag(sectorAddress, 1, track, tag);
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectors(ulong sectorAddress, uint length)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -1372,10 +1370,10 @@ namespace DiscImageChef.ImagePlugins
}
}
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -1392,10 +1390,10 @@ namespace DiscImageChef.ImagePlugins
}
}
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
{
CDRWinTrack _track = new CDRWinTrack();
@@ -1411,10 +1409,10 @@ namespace DiscImageChef.ImagePlugins
}
if(_track.sequence == 0)
throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
if(length > _track.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -1510,7 +1508,7 @@ namespace DiscImageChef.ImagePlugins
return buffer;
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
{
CDRWinTrack _track = new CDRWinTrack();
@@ -1526,10 +1524,10 @@ namespace DiscImageChef.ImagePlugins
}
if(_track.sequence == 0)
throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
if(length > _track.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -1569,7 +1567,7 @@ namespace DiscImageChef.ImagePlugins
case SectorTagType.CDTrackText:
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
switch(_track.tracktype)
@@ -1577,7 +1575,7 @@ namespace DiscImageChef.ImagePlugins
case CDRWinTrackTypeMode1:
case CDRWinTrackTypeMode2Form1:
case CDRWinTrackTypeMode2Form2:
throw new ArgumentException("No tags in image for requested track", "tag");
throw new ArgumentException("No tags in image for requested track", nameof(tag));
case CDRWinTrackTypeMode2Formless:
case CDRWinTrackTypeCDI:
{
@@ -1589,7 +1587,7 @@ namespace DiscImageChef.ImagePlugins
case SectorTagType.CDSectorECC:
case SectorTagType.CDSectorECC_P:
case SectorTagType.CDSectorECC_Q:
throw new ArgumentException("Unsupported tag requested for this track", "tag");
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
case SectorTagType.CDSectorSubHeader:
{
sector_offset = 0;
@@ -1605,12 +1603,12 @@ namespace DiscImageChef.ImagePlugins
break;
}
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
break;
}
case CDRWinTrackTypeAudio:
throw new ArgumentException("There are no tags on audio tracks", "tag");
throw new ArgumentException("There are no tags on audio tracks", nameof(tag));
case CDRWinTrackTypeMode1Raw:
{
switch(tag)
@@ -1631,7 +1629,7 @@ namespace DiscImageChef.ImagePlugins
}
case SectorTagType.CDSectorSubchannel:
case SectorTagType.CDSectorSubHeader:
throw new ArgumentException("Unsupported tag requested for this track", "tag");
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
case SectorTagType.CDSectorECC:
{
sector_offset = 2076;
@@ -1661,7 +1659,7 @@ namespace DiscImageChef.ImagePlugins
break;
}
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
break;
}
@@ -1671,7 +1669,7 @@ namespace DiscImageChef.ImagePlugins
case CDRWinTrackTypeCDG:
{
if(tag != SectorTagType.CDSectorSubchannel)
throw new ArgumentException("Unsupported tag requested for this track", "tag");
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
sector_offset = 2352;
sector_size = 96;
@@ -1708,17 +1706,17 @@ namespace DiscImageChef.ImagePlugins
return buffer;
}
public override byte[] ReadSectorLong(UInt64 sectorAddress)
public override byte[] ReadSectorLong(ulong sectorAddress)
{
return ReadSectorsLong(sectorAddress, 1);
}
public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
{
return ReadSectorsLong(sectorAddress, 1, track);
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -1735,10 +1733,10 @@ namespace DiscImageChef.ImagePlugins
}
}
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
{
CDRWinTrack _track = new CDRWinTrack();
@@ -1754,10 +1752,10 @@ namespace DiscImageChef.ImagePlugins
}
if(_track.sequence == 0)
throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
if(length > _track.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -1884,7 +1882,7 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.mediaType;
}
public override List<CommonTypes.Partition> GetPartitions()
public override List<Partition> GetPartitions()
{
return partitions;
}
@@ -1893,7 +1891,7 @@ namespace DiscImageChef.ImagePlugins
{
List<Track> tracks = new List<Track>();
UInt64 previousStartSector = 0;
ulong previousStartSector = 0;
foreach(CDRWinTrack cdr_track in discimage.tracks)
{
@@ -1939,7 +1937,7 @@ namespace DiscImageChef.ImagePlugins
throw new ImageNotSupportedException("Session does not exist in disc image");
}
public override List<Track> GetSessionTracks(UInt16 session)
public override List<Track> GetSessionTracks(ushort session)
{
List<Track> tracks = new List<Track>();
@@ -1984,25 +1982,25 @@ namespace DiscImageChef.ImagePlugins
return discimage.sessions;
}
public override bool? VerifySector(UInt64 sectorAddress)
public override bool? VerifySector(ulong sectorAddress)
{
byte[] buffer = ReadSectorLong(sectorAddress);
return Checksums.CDChecksums.CheckCDSector(buffer);
}
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
public override bool? VerifySector(ulong sectorAddress, uint track)
{
byte[] buffer = ReadSectorLong(sectorAddress, track);
return Checksums.CDChecksums.CheckCDSector(buffer);
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(int i = 0; i < length; i++)
{
@@ -2027,13 +2025,13 @@ namespace DiscImageChef.ImagePlugins
return true;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length, track);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(int i = 0; i < length; i++)
{
@@ -2067,22 +2065,22 @@ namespace DiscImageChef.ImagePlugins
#region Private methods
static UInt64 CDRWinMSFToLBA(string MSF)
static ulong CDRWinMSFToLBA(string MSF)
{
string[] MSFElements;
UInt64 minute, second, frame, sectors;
ulong minute, second, frame, sectors;
MSFElements = MSF.Split(':');
minute = UInt64.Parse(MSFElements[0]);
second = UInt64.Parse(MSFElements[1]);
frame = UInt64.Parse(MSFElements[2]);
minute = ulong.Parse(MSFElements[0]);
second = ulong.Parse(MSFElements[1]);
frame = ulong.Parse(MSFElements[2]);
sectors = (minute * 60 * 75) + (second * 75) + frame;
return sectors;
}
static UInt16 CDRWinTrackTypeToBytesPerSector(string trackType)
static ushort CDRWinTrackTypeToBytesPerSector(string trackType)
{
switch(trackType)
{
@@ -2106,7 +2104,7 @@ namespace DiscImageChef.ImagePlugins
}
}
static UInt16 CDRWinTrackTypeToCookedBytesPerSector(string trackType)
static ushort CDRWinTrackTypeToCookedBytesPerSector(string trackType)
{
switch(trackType)
{

View File

@@ -1,3 +1,17 @@
2016-07-28 Natalia Portillo <claunia@claunia.com>
* VHD.cs:
* GDI.cs:
* Nero.cs:
* CDRDAO.cs:
* CDRWin.cs:
* Apple2MG.cs:
* TeleDisk.cs:
* ImageInfo.cs:
* DiskCopy42.cs:
* ImagePlugin.cs:
* ZZZRawImage.cs: Refactor and code cleanup.
2016-02-03 Natalia Portillo <claunia@claunia.com>
* CDRWin.cs:

View File

@@ -49,13 +49,13 @@ namespace DiscImageChef.ImagePlugins
/// <summary>0x00, 64 bytes, pascal string, disk name or "-not a Macintosh disk-", filled with garbage</summary>
public string diskName;
/// <summary>0x40, size of data in bytes (usually sectors*512)</summary>
public UInt32 dataSize;
public uint dataSize;
/// <summary>0x44, size of tags in bytes (usually sectors*12)</summary>
public UInt32 tagSize;
public uint tagSize;
/// <summary>0x48, checksum of data bytes</summary>
public UInt32 dataChecksum;
public uint dataChecksum;
/// <summary>0x4C, checksum of tag bytes</summary>
public UInt32 tagChecksum;
public uint tagChecksum;
/// <summary>0x50, format of disk, see constants</summary>
public byte format;
/// <summary>0x51, format of sectors, see constants</summary>
@@ -114,11 +114,11 @@ namespace DiscImageChef.ImagePlugins
#region Internal variables
/// <summary>Start of data sectors in disk image, should be 0x58</summary>
UInt32 dataOffset;
uint dataOffset;
/// <summary>Start of tags in disk image, after data sectors</summary>
UInt32 tagOffset;
uint tagOffset;
/// <summary>Bytes per tag, should be 12</summary>
UInt32 bptag;
uint bptag;
/// <summary>Header of opened image</summary>
DC42Header header;
/// <summary>Disk image file</summary>
@@ -372,33 +372,33 @@ namespace DiscImageChef.ImagePlugins
return true;
}
public override bool? VerifySector(UInt64 sectorAddress)
public override bool? VerifySector(ulong sectorAddress)
{
return null;
}
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
public override bool? VerifySector(ulong sectorAddress, uint track)
{
return null;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(UInt64 i = sectorAddress; i < sectorAddress + length; i++)
for(ulong i = sectorAddress; i < sectorAddress + length; i++)
UnknownLBAs.Add(i);
return null;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(UInt64 i = sectorAddress; i < sectorAddress + length; i++)
for(ulong i = sectorAddress; i < sectorAddress + length; i++)
UnknownLBAs.Add(i);
return null;
@@ -408,12 +408,12 @@ namespace DiscImageChef.ImagePlugins
{
byte[] data = new byte[header.dataSize];
byte[] tags = new byte[header.tagSize];
UInt32 dataChk;
UInt32 tagsChk = 0;
uint dataChk;
uint tagsChk = 0;
DicConsole.DebugWriteLine("DC42 plugin", "Reading data");
FileStream datastream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
datastream.Seek((long)(dataOffset), SeekOrigin.Begin);
datastream.Seek((dataOffset), SeekOrigin.Begin);
datastream.Read(data, 0, (int)header.dataSize);
datastream.Close();
@@ -426,7 +426,7 @@ namespace DiscImageChef.ImagePlugins
{
DicConsole.DebugWriteLine("DC42 plugin", "Reading tags");
FileStream tagstream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
tagstream.Seek((long)(tagOffset), SeekOrigin.Begin);
tagstream.Seek((tagOffset), SeekOrigin.Begin);
tagstream.Read(tags, 0, (int)header.tagSize);
tagstream.Close();
@@ -444,38 +444,38 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.imageHasPartitions;
}
public override UInt64 GetImageSize()
public override ulong GetImageSize()
{
return ImageInfo.imageSize;
}
public override UInt64 GetSectors()
public override ulong GetSectors()
{
return ImageInfo.sectors;
}
public override UInt32 GetSectorSize()
public override uint GetSectorSize()
{
return ImageInfo.sectorSize;
}
public override byte[] ReadSector(UInt64 sectorAddress)
public override byte[] ReadSector(ulong sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
{
return ReadSectorsTag(sectorAddress, 1, tag);
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectors(ulong sectorAddress, uint length)
{
if(sectorAddress > ImageInfo.sectors - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
if(sectorAddress + length > ImageInfo.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
byte[] buffer = new byte[length * ImageInfo.sectorSize];
@@ -490,19 +490,19 @@ namespace DiscImageChef.ImagePlugins
return buffer;
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
{
if(tag != SectorTagType.AppleSectorTag)
throw new FeatureUnsupportedImageException(String.Format("Tag {0} not supported by image format", tag));
throw new FeatureUnsupportedImageException(string.Format("Tag {0} not supported by image format", tag));
if(header.tagSize == 0)
throw new FeatureNotPresentImageException("Disk image does not have tags");
if(sectorAddress > ImageInfo.sectors - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
if(sectorAddress + length > ImageInfo.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
byte[] buffer = new byte[length * bptag];
@@ -517,18 +517,18 @@ namespace DiscImageChef.ImagePlugins
return buffer;
}
public override byte[] ReadSectorLong(UInt64 sectorAddress)
public override byte[] ReadSectorLong(ulong sectorAddress)
{
return ReadSectorsLong(sectorAddress, 1);
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
{
if(sectorAddress > ImageInfo.sectors - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
if(sectorAddress + length > ImageInfo.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
byte[] data = ReadSectors(sectorAddress, length);
byte[] tags = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSectorTag);
@@ -650,7 +650,7 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.driveSerialNumber;
}
public override List<CommonTypes.Partition> GetPartitions()
public override List<Partition> GetPartitions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
@@ -665,7 +665,7 @@ namespace DiscImageChef.ImagePlugins
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetSessionTracks(UInt16 session)
public override List<Track> GetSessionTracks(ushort session)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
@@ -675,32 +675,32 @@ namespace DiscImageChef.ImagePlugins
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSector(ulong sectorAddress, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
@@ -709,13 +709,13 @@ namespace DiscImageChef.ImagePlugins
#region Private methods
private static UInt32 DC42CheckSum(byte[] buffer)
private static uint DC42CheckSum(byte[] buffer)
{
UInt32 dc42chk = 0;
uint dc42chk = 0;
if((buffer.Length & 0x01) == 0x01)
return 0xFFFFFFFF;
for(UInt32 i = 0; i < buffer.Length; i += 2)
for(uint i = 0; i < buffer.Length; i += 2)
{
dc42chk += (uint)(buffer[i] << 8);
dc42chk += buffer[i + 1];

View File

@@ -48,7 +48,7 @@ namespace DiscImageChef.ImagePlugins
struct GDITrack
{
/// <summary>Track #</summary>
public UInt32 sequence;
public uint sequence;
/// <summary>Track file</summary>
public string trackfile;
/// <summary>Track byte offset in file</summary>
@@ -58,9 +58,9 @@ namespace DiscImageChef.ImagePlugins
/// <summary>Track starting sector</summary>
public ulong startSector;
/// <summary>Bytes per sector</summary>
public UInt16 bps;
public ushort bps;
/// <summary>Sectors in track</summary>
public UInt64 sectors;
public ulong sectors;
/// <summary>Track type</summary>
public TrackType tracktype;
/// <summary>Track session</summary>
@@ -87,7 +87,7 @@ namespace DiscImageChef.ImagePlugins
StreamReader gdiStream;
FileStream imageStream;
/// <summary>Dictionary, index is track #, value is track number, or 0 if a TOC</summary>
Dictionary<UInt32, UInt64> offsetmap;
Dictionary<uint, ulong> offsetmap;
GDIDisc discimage;
List<Partition> partitions;
ulong densitySeparationSectors;
@@ -224,7 +224,7 @@ namespace DiscImageChef.ImagePlugins
TrackMatch = RegexTrack.Match(_line);
if(!TrackMatch.Success)
throw new ImageNotSupportedException(String.Format("Unknown line \"{0}\" at line {1}", _line, line));
throw new ImageNotSupportedException(string.Format("Unknown line \"{0}\" at line {1}", _line, line));
tracksFound++;
@@ -379,7 +379,7 @@ namespace DiscImageChef.ImagePlugins
Partition partition = new Partition();
// Index 01
partition.PartitionDescription = String.Format("Track {0}.", discimage.tracks[i].sequence);
partition.PartitionDescription = string.Format("Track {0}.", discimage.tracks[i].sequence);
partition.PartitionName = null;
partition.PartitionStartSector = discimage.tracks[i].startSector;
partition.PartitionLength = discimage.tracks[i].sectors * discimage.tracks[i].bps;
@@ -443,17 +443,17 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.imageHasPartitions;
}
public override UInt64 GetImageSize()
public override ulong GetImageSize()
{
return ImageInfo.imageSize;
}
public override UInt64 GetSectors()
public override ulong GetSectors()
{
return ImageInfo.sectors;
}
public override UInt32 GetSectorSize()
public override uint GetSectorSize()
{
return ImageInfo.sectorSize;
}
@@ -463,27 +463,27 @@ namespace DiscImageChef.ImagePlugins
throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format");
}
public override byte[] ReadSector(UInt64 sectorAddress)
public override byte[] ReadSector(ulong sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
{
return ReadSectorsTag(sectorAddress, 1, tag);
}
public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSector(ulong sectorAddress, uint track)
{
return ReadSectors(sectorAddress, 1, track);
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
{
return ReadSectorsTag(sectorAddress, 1, track, tag);
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectors(ulong sectorAddress, uint length)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -505,10 +505,10 @@ namespace DiscImageChef.ImagePlugins
if(sectorAddress >= transitionStart && sectorAddress < (densitySeparationSectors + transitionStart))
return ReadSectors((sectorAddress - transitionStart), length, 0);
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -530,15 +530,15 @@ namespace DiscImageChef.ImagePlugins
if(sectorAddress >= transitionStart && sectorAddress < (densitySeparationSectors + transitionStart))
return ReadSectorsTag((sectorAddress - transitionStart), length, 0, tag);
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
{
if(track == 0)
{
if((sectorAddress + length) > densitySeparationSectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
return new byte[length * 2352];
}
@@ -557,10 +557,10 @@ namespace DiscImageChef.ImagePlugins
}
if(_track.sequence == 0)
throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
if((sectorAddress + length) > _track.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -642,17 +642,17 @@ namespace DiscImageChef.ImagePlugins
return buffer;
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
{
if(track == 0)
{
if((sectorAddress + length) > densitySeparationSectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
if(tag == SectorTagType.CDTrackFlags)
return new byte[] { 0x00 };
throw new ArgumentException("Unsupported tag requested for this track", "tag");
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
}
GDITrack _track = new GDITrack();
@@ -669,10 +669,10 @@ namespace DiscImageChef.ImagePlugins
}
if(_track.sequence == 0)
throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
if(length > _track.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -696,13 +696,13 @@ namespace DiscImageChef.ImagePlugins
return flags;
}
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
switch(_track.tracktype)
{
case TrackType.Audio:
throw new ArgumentException("There are no tags on audio tracks", "tag");
throw new ArgumentException("There are no tags on audio tracks", nameof(tag));
case TrackType.CDMode1:
{
if(_track.bps != 2352)
@@ -726,7 +726,7 @@ namespace DiscImageChef.ImagePlugins
}
case SectorTagType.CDSectorSubchannel:
case SectorTagType.CDSectorSubHeader:
throw new ArgumentException("Unsupported tag requested for this track", "tag");
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
case SectorTagType.CDSectorECC:
{
sector_offset = 2076;
@@ -756,7 +756,7 @@ namespace DiscImageChef.ImagePlugins
break;
}
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
break;
}
@@ -811,17 +811,17 @@ namespace DiscImageChef.ImagePlugins
return buffer;
}
public override byte[] ReadSectorLong(UInt64 sectorAddress)
public override byte[] ReadSectorLong(ulong sectorAddress)
{
return ReadSectorsLong(sectorAddress, 1);
}
public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
{
return ReadSectorsLong(sectorAddress, 1, track);
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -838,15 +838,15 @@ namespace DiscImageChef.ImagePlugins
}
}
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
{
if(track == 0)
{
if((sectorAddress + length) > densitySeparationSectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
return new byte[length * 2352];
}
@@ -865,10 +865,10 @@ namespace DiscImageChef.ImagePlugins
}
if(_track.sequence == 0)
throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
if((sectorAddress + length) > _track.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -1049,7 +1049,7 @@ namespace DiscImageChef.ImagePlugins
throw new ImageNotSupportedException("Session does not exist in disc image");
}
public override List<Track> GetSessionTracks(UInt16 session)
public override List<Track> GetSessionTracks(ushort session)
{
List<Track> tracks = new List<Track>();
bool expectedDensity;
@@ -1105,25 +1105,25 @@ namespace DiscImageChef.ImagePlugins
return discimage.sessions;
}
public override bool? VerifySector(UInt64 sectorAddress)
public override bool? VerifySector(ulong sectorAddress)
{
byte[] buffer = ReadSectorLong(sectorAddress);
return Checksums.CDChecksums.CheckCDSector(buffer);
}
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
public override bool? VerifySector(ulong sectorAddress, uint track)
{
byte[] buffer = ReadSectorLong(sectorAddress, track);
return Checksums.CDChecksums.CheckCDSector(buffer);
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(int i = 0; i < length; i++)
{
@@ -1148,13 +1148,13 @@ namespace DiscImageChef.ImagePlugins
return true;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length, track);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(int i = 0; i < length; i++)
{

View File

@@ -40,9 +40,9 @@ namespace DiscImageChef.ImagePlugins
{
public bool imageHasPartitions;
public bool imageHasSessions;
public UInt64 imageSize;
public UInt64 sectors;
public UInt32 sectorSize;
public ulong imageSize;
public ulong sectors;
public uint sectorSize;
public List<MediaTagType> readableMediaTags;
public List<SectorTagType> readableSectorTags;
public string imageVersion;

View File

@@ -80,19 +80,19 @@ namespace DiscImageChef.ImagePlugins
/// Gets the size of the image, without headers.
/// </summary>
/// <returns>The image size.</returns>
public abstract UInt64 GetImageSize();
public abstract ulong GetImageSize();
/// <summary>
/// Gets the number of sectors in the image.
/// </summary>
/// <returns>Sectors in image.</returns>
public abstract UInt64 GetSectors();
public abstract ulong GetSectors();
/// <summary>
/// Returns the size of the biggest sector, counting user data only.
/// </summary>
/// <returns>Biggest sector size (user data only).</returns>
public abstract UInt32 GetSectorSize();
public abstract uint GetSectorSize();
// Image reading functions
@@ -108,7 +108,7 @@ namespace DiscImageChef.ImagePlugins
/// </summary>
/// <returns>The sector's user data.</returns>
/// <param name="sectorAddress">Sector address (LBA).</param>
public abstract byte[] ReadSector(UInt64 sectorAddress);
public abstract byte[] ReadSector(ulong sectorAddress);
/// <summary>
/// Reads a sector's tag.
@@ -116,7 +116,7 @@ namespace DiscImageChef.ImagePlugins
/// <returns>The sector's tag.</returns>
/// <param name="sectorAddress">Sector address (LBA).</param>
/// <param name="tag">Tag type.</param>
public abstract byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag);
public abstract byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag);
/// <summary>
/// Reads a sector's user data, relative to track.
@@ -124,7 +124,7 @@ namespace DiscImageChef.ImagePlugins
/// <returns>The sector's user data.</returns>
/// <param name="sectorAddress">Sector address (relative LBA).</param>
/// <param name="track">Track.</param>
public abstract byte[] ReadSector(UInt64 sectorAddress, UInt32 track);
public abstract byte[] ReadSector(ulong sectorAddress, uint track);
/// <summary>
/// Reads a sector's tag, relative to track.
@@ -133,7 +133,7 @@ namespace DiscImageChef.ImagePlugins
/// <param name="sectorAddress">Sector address (relative LBA).</param>
/// <param name="track">Track.</param>
/// <param name="tag">Tag type.</param>
public abstract byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag);
public abstract byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag);
/// <summary>
/// Reads user data from several sectors.
@@ -141,7 +141,7 @@ namespace DiscImageChef.ImagePlugins
/// <returns>The sectors user data.</returns>
/// <param name="sectorAddress">Starting sector address (LBA).</param>
/// <param name="length">How many sectors to read.</param>
public abstract byte[] ReadSectors(UInt64 sectorAddress, UInt32 length);
public abstract byte[] ReadSectors(ulong sectorAddress, uint length);
/// <summary>
/// Reads tag from several sectors.
@@ -150,7 +150,7 @@ namespace DiscImageChef.ImagePlugins
/// <param name="sectorAddress">Starting sector address (LBA).</param>
/// <param name="length">How many sectors to read.</param>
/// <param name="tag">Tag type.</param>
public abstract byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag);
public abstract byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag);
/// <summary>
/// Reads user data from several sectors, relative to track.
@@ -159,7 +159,7 @@ namespace DiscImageChef.ImagePlugins
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
/// <param name="length">How many sectors to read.</param>
/// <param name="track">Track.</param>
public abstract byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track);
public abstract byte[] ReadSectors(ulong sectorAddress, uint length, uint track);
/// <summary>
/// Reads tag from several sectors, relative to track.
@@ -169,14 +169,14 @@ namespace DiscImageChef.ImagePlugins
/// <param name="length">How many sectors to read.</param>
/// <param name="track">Track.</param>
/// <param name="tag">Tag type.</param>
public abstract byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag);
public abstract byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag);
/// <summary>
/// Reads a complete sector (user data + all tags).
/// </summary>
/// <returns>The complete sector. Format depends on disk type.</returns>
/// <param name="sectorAddress">Sector address (LBA).</param>
public abstract byte[] ReadSectorLong(UInt64 sectorAddress);
public abstract byte[] ReadSectorLong(ulong sectorAddress);
/// <summary>
/// Reads a complete sector (user data + all tags), relative to track.
@@ -184,7 +184,7 @@ namespace DiscImageChef.ImagePlugins
/// <returns>The complete sector. Format depends on disk type.</returns>
/// <param name="sectorAddress">Sector address (relative LBA).</param>
/// <param name="track">Track.</param>
public abstract byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track);
public abstract byte[] ReadSectorLong(ulong sectorAddress, uint track);
/// <summary>
/// Reads several complete sector (user data + all tags).
@@ -192,7 +192,7 @@ namespace DiscImageChef.ImagePlugins
/// <returns>The complete sectors. Format depends on disk type.</returns>
/// <param name="sectorAddress">Starting sector address (LBA).</param>
/// <param name="length">How many sectors to read.</param>
public abstract byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length);
public abstract byte[] ReadSectorsLong(ulong sectorAddress, uint length);
/// <summary>
/// Reads several complete sector (user data + all tags), relative to track.
@@ -201,7 +201,7 @@ namespace DiscImageChef.ImagePlugins
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
/// <param name="length">How many sectors to read.</param>
/// <param name="track">Track.</param>
public abstract byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track);
public abstract byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track);
// Image information functions
@@ -337,7 +337,7 @@ namespace DiscImageChef.ImagePlugins
/// reads can be relative to them.
/// </summary>
/// <returns>The partitions.</returns>
public abstract List<CommonTypes.Partition> GetPartitions();
public abstract List<Partition> GetPartitions();
/// <summary>
/// Gets the disc track extents (start, length).
@@ -357,7 +357,7 @@ namespace DiscImageChef.ImagePlugins
/// </summary>
/// <returns>The track exents for that session.</returns>
/// <param name="session">Session.</param>
public abstract List<Track> GetSessionTracks(UInt16 session);
public abstract List<Track> GetSessionTracks(ushort session);
/// <summary>
/// Gets the sessions (optical discs only).
@@ -371,7 +371,7 @@ namespace DiscImageChef.ImagePlugins
/// </summary>
/// <returns>True if correct, false if incorrect, null if uncheckable.</returns>
/// <param name="sectorAddress">Sector address (LBA).</param>
public abstract bool? VerifySector(UInt64 sectorAddress);
public abstract bool? VerifySector(ulong sectorAddress);
/// <summary>
/// Verifies a sector, relative to track.
@@ -379,7 +379,7 @@ namespace DiscImageChef.ImagePlugins
/// <returns>True if correct, false if incorrect, null if uncheckable.</returns>
/// <param name="sectorAddress">Sector address (relative LBA).</param>
/// <param name="track">Track.</param>
public abstract bool? VerifySector(UInt64 sectorAddress, UInt32 track);
public abstract bool? VerifySector(ulong sectorAddress, uint track);
/// <summary>
/// Verifies several sectors.
@@ -389,7 +389,7 @@ namespace DiscImageChef.ImagePlugins
/// <param name="length">How many sectors to read.</param>
/// <param name="FailingLBAs">List of incorrect sectors</param>
/// <param name="UnknownLBAs">List of uncheckable sectors</param>
public abstract bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs);
public abstract bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs);
/// <summary>
/// Verifies several sectors, relative to track.
@@ -400,7 +400,7 @@ namespace DiscImageChef.ImagePlugins
/// <param name="track">Track.</param>
/// <param name="FailingLBAs">List of incorrect sectors</param>
/// <param name="UnknownLBAs">List of uncheckable sectors</param>
public abstract bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs);
public abstract bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs);
/// <summary>
/// Verifies media image internal checksum.
@@ -446,21 +446,21 @@ namespace DiscImageChef.ImagePlugins
public struct Track
{
/// <summary>Track number, 1-started</summary>
public UInt32 TrackSequence;
public uint TrackSequence;
/// <summary>Partition type</summary>
public TrackType TrackType;
/// <summary>Track starting sector</summary>
public UInt64 TrackStartSector;
public ulong TrackStartSector;
/// <summary>Track ending sector</summary>
public UInt64 TrackEndSector;
public ulong TrackEndSector;
/// <summary>Track pre-gap</summary>
public UInt64 TrackPregap;
public ulong TrackPregap;
/// <summary>Session this track belongs to</summary>
public UInt16 TrackSession;
public ushort TrackSession;
/// <summary>Information that does not find space in this struct</summary>
public string TrackDescription;
/// <summary>Indexes, 00 to 99 and sector offset</summary>
public Dictionary<int, UInt64> Indexes;
public Dictionary<int, ulong> Indexes;
/// <summary>Which file stores this track</summary>
public string TrackFile;
/// <summary>Starting at which byte is this track stored</summary>
@@ -512,15 +512,15 @@ namespace DiscImageChef.ImagePlugins
public struct Session
{
/// <summary>Session number, 1-started</summary>
public UInt16 SessionSequence;
public ushort SessionSequence;
/// <summary>First track present on this session</summary>
public UInt32 StartTrack;
public uint StartTrack;
/// <summary>Last track present on this session</summary>
public UInt32 EndTrack;
public uint EndTrack;
/// <summary>First sector present on this session</summary>
public UInt64 StartSector;
public ulong StartSector;
/// <summary>Last sector present on this session</summary>
public UInt64 EndSector;
public ulong EndSector;
}
/// <summary>
@@ -722,7 +722,7 @@ namespace DiscImageChef.ImagePlugins
System.Runtime.Serialization.StreamingContext context)
{
if(info == null)
throw new ArgumentNullException("info");
throw new ArgumentNullException(nameof(info));
}
}
@@ -758,7 +758,7 @@ namespace DiscImageChef.ImagePlugins
System.Runtime.Serialization.StreamingContext context)
{
if(info == null)
throw new ArgumentNullException("info");
throw new ArgumentNullException(nameof(info));
}
}
@@ -794,7 +794,7 @@ namespace DiscImageChef.ImagePlugins
System.Runtime.Serialization.StreamingContext context)
{
if(info == null)
throw new ArgumentNullException("info");
throw new ArgumentNullException(nameof(info));
}
}
@@ -830,7 +830,7 @@ namespace DiscImageChef.ImagePlugins
System.Runtime.Serialization.StreamingContext context)
{
if(info == null)
throw new ArgumentNullException("info");
throw new ArgumentNullException(nameof(info));
}
}
@@ -866,7 +866,7 @@ namespace DiscImageChef.ImagePlugins
System.Runtime.Serialization.StreamingContext context)
{
if(info == null)
throw new ArgumentNullException("info");
throw new ArgumentNullException(nameof(info));
}
}
}

View File

@@ -33,7 +33,6 @@
using System;
using System.IO;
using System.Collections.Generic;
using DiscImageChef;
using DiscImageChef.Console;
using DiscImageChef.CommonTypes;
@@ -48,12 +47,12 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "NERO"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Offset of first chunk in file
/// </summary>
public UInt32 FirstChunkOffset;
public uint FirstChunkOffset;
}
struct NeroV2Footer
@@ -61,12 +60,12 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "NER5"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Offset of first chunk in file
/// </summary>
public UInt64 FirstChunkOffset;
public ulong FirstChunkOffset;
}
struct NeroV2CueEntry
@@ -94,7 +93,7 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// LBA sector start for this entry
/// </summary>
public Int32 LBAStart;
public int LBAStart;
}
struct NeroV2Cuesheet
@@ -102,12 +101,12 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "CUEX"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
/// <summary>
/// Cuesheet entries
@@ -135,7 +134,7 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Always zero
/// </summary>
public UInt16 Dummy;
public ushort Dummy;
/// <summary>
/// MSF start sector's minute for this entry
@@ -158,12 +157,12 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "CUES"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
/// <summary>
/// Cuesheet entries
@@ -181,32 +180,32 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Size of sector inside image (in bytes)
/// </summary>
public UInt16 SectorSize;
public ushort SectorSize;
/// <summary>
/// Sector mode in image
/// </summary>
public UInt16 Mode;
public ushort Mode;
/// <summary>
/// Unknown
/// </summary>
public UInt16 Unknown;
public ushort Unknown;
/// <summary>
/// Index 0 start
/// </summary>
public UInt32 Index0;
public uint Index0;
/// <summary>
/// Index 1 start
/// </summary>
public UInt32 Index1;
public uint Index1;
/// <summary>
/// End of track + 1
/// </summary>
public UInt32 EndOfTrack;
public uint EndOfTrack;
}
struct NeroV1DAO
@@ -214,17 +213,17 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "DAOI"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size (big endian)
/// </summary>
public UInt32 ChunkSizeBe;
public uint ChunkSizeBe;
/// <summary>
/// Chunk size (little endian)
/// </summary>
public UInt32 ChunkSizeLe;
public uint ChunkSizeLe;
/// <summary>
/// UPC (14 bytes, null-padded)
@@ -234,7 +233,7 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// TOC type
/// </summary>
public UInt16 TocType;
public ushort TocType;
/// <summary>
/// First track
@@ -262,32 +261,32 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Size of sector inside image (in bytes)
/// </summary>
public UInt16 SectorSize;
public ushort SectorSize;
/// <summary>
/// Sector mode in image
/// </summary>
public UInt16 Mode;
public ushort Mode;
/// <summary>
/// Seems to be always 0.
/// </summary>
public UInt16 Unknown;
public ushort Unknown;
/// <summary>
/// Index 0 start
/// </summary>
public UInt64 Index0;
public ulong Index0;
/// <summary>
/// Index 1 start
/// </summary>
public UInt64 Index1;
public ulong Index1;
/// <summary>
/// End of track + 1
/// </summary>
public UInt64 EndOfTrack;
public ulong EndOfTrack;
}
struct NeroV2DAO
@@ -295,17 +294,17 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "DAOX"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size (big endian)
/// </summary>
public UInt32 ChunkSizeBe;
public uint ChunkSizeBe;
/// <summary>
/// Chunk size (little endian)
/// </summary>
public UInt32 ChunkSizeLe;
public uint ChunkSizeLe;
/// <summary>
/// UPC (14 bytes, null-padded)
@@ -315,7 +314,7 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// TOC type
/// </summary>
public UInt16 TocType;
public ushort TocType;
/// <summary>
/// First track
@@ -363,7 +362,7 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// CRC
/// </summary>
public UInt16 CRC;
public ushort CRC;
}
struct NeroCDText
@@ -371,12 +370,12 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "CDTX"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
/// <summary>
/// CD-TEXT packs
@@ -389,27 +388,27 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Offset of track on image
/// </summary>
public UInt32 Offset;
public uint Offset;
/// <summary>
/// Length of track in bytes
/// </summary>
public UInt32 Length;
public uint Length;
/// <summary>
/// Track mode
/// </summary>
public UInt32 Mode;
public uint Mode;
/// <summary>
/// LBA track start (plus 150 lead in sectors)
/// </summary>
public UInt32 StartLBA;
public uint StartLBA;
/// <summary>
/// Unknown
/// </summary>
public UInt32 Unknown;
public uint Unknown;
}
struct NeroV1TAO
@@ -417,12 +416,12 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "ETNF"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
/// <summary>
/// CD-TEXT packs
@@ -435,32 +434,32 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Offset of track on image
/// </summary>
public UInt64 Offset;
public ulong Offset;
/// <summary>
/// Length of track in bytes
/// </summary>
public UInt64 Length;
public ulong Length;
/// <summary>
/// Track mode
/// </summary>
public UInt32 Mode;
public uint Mode;
/// <summary>
/// LBA track start (plus 150 lead in sectors)
/// </summary>
public UInt32 StartLBA;
public uint StartLBA;
/// <summary>
/// Unknown
/// </summary>
public UInt32 Unknown;
public uint Unknown;
/// <summary>
/// Track length in sectors
/// </summary>
public UInt32 Sectors;
public uint Sectors;
}
struct NeroV2TAO
@@ -468,12 +467,12 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "ETN2"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
/// <summary>
/// CD-TEXT packs
@@ -486,17 +485,17 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "SINF"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
/// <summary>
/// Tracks in session
/// </summary>
public UInt32 Tracks;
public uint Tracks;
}
struct NeroMediaType
@@ -504,17 +503,17 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "MTYP"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
/// <summary>
/// Media type
/// </summary>
public UInt32 Type;
public uint Type;
}
struct NeroDiscInformation
@@ -522,17 +521,17 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "DINF"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
/// <summary>
/// Unknown
/// </summary>
public UInt32 Unknown;
public uint Unknown;
}
struct NeroTOCChunk
@@ -540,17 +539,17 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "TOCT"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
/// <summary>
/// Unknown
/// </summary>
public UInt16 Unknown;
public ushort Unknown;
}
struct NeroRELOChunk
@@ -558,17 +557,17 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "RELO"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
/// <summary>
/// Unknown
/// </summary>
public UInt32 Unknown;
public uint Unknown;
}
struct NeroEndOfChunkChain
@@ -576,28 +575,28 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// "END!"
/// </summary>
public UInt32 ChunkID;
public uint ChunkID;
/// <summary>
/// Chunk size
/// </summary>
public UInt32 ChunkSize;
public uint ChunkSize;
}
// Internal use only
struct NeroTrack
{
public byte[] ISRC;
public UInt16 SectorSize;
public UInt64 Offset;
public UInt64 Length;
public UInt64 EndOfTrack;
public UInt32 Mode;
public UInt64 StartLBA;
public UInt64 Sectors;
public UInt64 Index0;
public UInt64 Index1;
public UInt32 Sequence;
public ushort SectorSize;
public ulong Offset;
public ulong Length;
public ulong EndOfTrack;
public uint Mode;
public ulong StartLBA;
public ulong Sectors;
public ulong Index0;
public ulong Index1;
public uint Sequence;
}
#endregion
@@ -605,49 +604,49 @@ namespace DiscImageChef.ImagePlugins
#region Internal consts
// "NERO"
public const UInt32 NeroV1FooterID = 0x4E45524F;
public const uint NeroV1FooterID = 0x4E45524F;
// "NER5"
public const UInt32 NeroV2FooterID = 0x4E455235;
public const uint NeroV2FooterID = 0x4E455235;
// "CUES"
public const UInt32 NeroV1CUEID = 0x43554553;
public const uint NeroV1CUEID = 0x43554553;
// "CUEX"
public const UInt32 NeroV2CUEID = 0x43554558;
public const uint NeroV2CUEID = 0x43554558;
// "ETNF"
public const UInt32 NeroV1TAOID = 0x45544E46;
public const uint NeroV1TAOID = 0x45544E46;
// "ETN2"
public const UInt32 NeroV2TAOID = 0x45544E32;
public const uint NeroV2TAOID = 0x45544E32;
// "DAOI"
public const UInt32 NeroV1DAOID = 0x44414F49;
public const uint NeroV1DAOID = 0x44414F49;
// "DAOX"
public const UInt32 NeroV2DAOID = 0x44414F58;
public const uint NeroV2DAOID = 0x44414F58;
// "CDTX"
public const UInt32 NeroCDTextID = 0x43445458;
public const uint NeroCDTextID = 0x43445458;
// "SINF"
public const UInt32 NeroSessionID = 0x53494E46;
public const uint NeroSessionID = 0x53494E46;
// "MTYP"
public const UInt32 NeroDiskTypeID = 0x4D545950;
public const uint NeroDiskTypeID = 0x4D545950;
// "DINF"
public const UInt32 NeroDiscInfoID = 0x44494E46;
public const uint NeroDiscInfoID = 0x44494E46;
// "TOCT"
public const UInt32 NeroTOCID = 0x544F4354;
public const uint NeroTOCID = 0x544F4354;
// "RELO"
public const UInt32 NeroReloID = 0x52454C4F;
public const uint NeroReloID = 0x52454C4F;
// "END!"
public const UInt32 NeroEndID = 0x454E4421;
public const uint NeroEndID = 0x454E4421;
public enum DAOMode : ushort
{
@@ -662,6 +661,7 @@ namespace DiscImageChef.ImagePlugins
DataM2RawSub = 0x0011
}
[Flags]
public enum NeroMediaTypes : uint
{
/// <summary>
@@ -834,7 +834,7 @@ namespace DiscImageChef.ImagePlugins
FileStream imageStream;
FileInfo imageInfo;
bool imageNewFormat;
Dictionary<ushort, UInt32> neroSessions;
Dictionary<ushort, uint> neroSessions;
NeroV1Cuesheet neroCuesheetV1;
NeroV2Cuesheet neroCuesheetV2;
NeroV1DAO neroDAOV1;
@@ -851,9 +851,9 @@ namespace DiscImageChef.ImagePlugins
Dictionary<uint, byte[]> TrackISRCs;
byte[] UPC;
Dictionary<uint, NeroTrack> neroTracks;
Dictionary<UInt32, UInt64> offsetmap;
Dictionary<uint, ulong> offsetmap;
List<Session> imageSessions;
List<CommonTypes.Partition> ImagePartitions;
List<Partition> ImagePartitions;
#endregion
@@ -868,11 +868,11 @@ namespace DiscImageChef.ImagePlugins
ImageInfo = new ImageInfo();
ImageInfo.readableSectorTags = new List<SectorTagType>();
ImageInfo.readableMediaTags = new List<MediaTagType>();
neroSessions = new Dictionary<ushort, UInt32>();
neroSessions = new Dictionary<ushort, uint>();
neroTracks = new Dictionary<uint, NeroTrack>();
offsetmap = new Dictionary<uint, ulong>();
imageSessions = new List<Session>();
ImagePartitions = new List<CommonTypes.Partition>();
ImagePartitions = new List<Partition>();
}
// Due to .cue format, this method must parse whole file, ignoring errors (those will be thrown by OpenImage()).
@@ -978,8 +978,8 @@ namespace DiscImageChef.ImagePlugins
while(parsing)
{
byte[] ChunkHeaderBuffer = new byte[8];
UInt32 ChunkID;
UInt32 ChunkLength;
uint ChunkID;
uint ChunkLength;
imageStream.Read(ChunkHeaderBuffer, 0, 8);
ChunkID = BigEndianBitConverter.ToUInt32(ChunkHeaderBuffer, 0);
@@ -1374,7 +1374,7 @@ namespace DiscImageChef.ImagePlugins
{
DicConsole.DebugWriteLine("Nero plugin", "Found \"SINF\" chunk, parsing {0} bytes", ChunkLength);
UInt32 sessionTracks;
uint sessionTracks;
byte[] tmpbuffer = new byte[4];
imageStream.Read(tmpbuffer, 0, 4);
sessionTracks = BigEndianBitConverter.ToUInt32(tmpbuffer, 0);
@@ -1608,12 +1608,12 @@ namespace DiscImageChef.ImagePlugins
offsetmap.Add(_track.TrackSequence, _track.TrackStartSector);
DicConsole.DebugWriteLine("Nero plugin", "\t\t Offset[{0}]: {1}", _track.TrackSequence, _track.TrackStartSector);
CommonTypes.Partition partition;
Partition partition;
if(_neroTrack.Index0 < _neroTrack.Index1)
{
partition = new CommonTypes.Partition();
partition.PartitionDescription = String.Format("Track {0} Index 0", _track.TrackSequence);
partition = new Partition();
partition.PartitionDescription = string.Format("Track {0} Index 0", _track.TrackSequence);
partition.PartitionLength = (_neroTrack.Index1 - _neroTrack.Index0);
partition.PartitionName = StringHandlers.CToString(_neroTrack.ISRC);
partition.PartitionSectors = partition.PartitionLength / _neroTrack.SectorSize;
@@ -1625,8 +1625,8 @@ namespace DiscImageChef.ImagePlugins
PartitionSequence++;
}
partition = new CommonTypes.Partition();
partition.PartitionDescription = String.Format("Track {0} Index 1", _track.TrackSequence);
partition = new Partition();
partition.PartitionDescription = string.Format("Track {0} Index 1", _track.TrackSequence);
partition.PartitionLength = (_neroTrack.EndOfTrack - _neroTrack.Index1);
partition.PartitionName = StringHandlers.CToString(_neroTrack.ISRC);
partition.PartitionSectors = partition.PartitionLength / _neroTrack.SectorSize;
@@ -1658,17 +1658,17 @@ namespace DiscImageChef.ImagePlugins
return true;
}
public override UInt64 GetImageSize()
public override ulong GetImageSize()
{
return ImageInfo.imageSize;
}
public override UInt64 GetSectors()
public override ulong GetSectors()
{
return ImageInfo.sectors;
}
public override UInt32 GetSectorSize()
public override uint GetSectorSize()
{
return ImageInfo.sectorSize;
}
@@ -1686,27 +1686,27 @@ namespace DiscImageChef.ImagePlugins
}
}
public override byte[] ReadSector(UInt64 sectorAddress)
public override byte[] ReadSector(ulong sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
{
return ReadSectorsTag(sectorAddress, 1, tag);
}
public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSector(ulong sectorAddress, uint track)
{
return ReadSectors(sectorAddress, 1, track);
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
{
return ReadSectorsTag(sectorAddress, 1, track, tag);
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectors(ulong sectorAddress, uint length)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -1723,10 +1723,10 @@ namespace DiscImageChef.ImagePlugins
}
}
throw new ArgumentOutOfRangeException("sectorAddress", String.Format("Sector address {0} not found", sectorAddress));
throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress));
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -1743,18 +1743,18 @@ namespace DiscImageChef.ImagePlugins
}
}
throw new ArgumentOutOfRangeException("sectorAddress", String.Format("Sector address {0} not found", sectorAddress));
throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress));
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
{
NeroTrack _track;
if(!neroTracks.TryGetValue(track, out _track))
throw new ArgumentOutOfRangeException("track", "Track not found");
throw new ArgumentOutOfRangeException(nameof(track), "Track not found");
if(length > _track.Sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -1849,15 +1849,15 @@ namespace DiscImageChef.ImagePlugins
return buffer;
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
{
NeroTrack _track;
if(!neroTracks.TryGetValue(track, out _track))
throw new ArgumentOutOfRangeException("track", "Track not found");
throw new ArgumentOutOfRangeException(nameof(track), "Track not found");
if(length > _track.Sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -1889,14 +1889,14 @@ namespace DiscImageChef.ImagePlugins
case SectorTagType.CDTrackText:
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
switch((DAOMode)_track.Mode)
{
case DAOMode.Data:
case DAOMode.DataM2F1:
throw new ArgumentException("No tags in image for requested track", "tag");
throw new ArgumentException("No tags in image for requested track", nameof(tag));
case DAOMode.DataM2F2:
{
switch(tag)
@@ -1907,7 +1907,7 @@ namespace DiscImageChef.ImagePlugins
case SectorTagType.CDSectorECC:
case SectorTagType.CDSectorECC_P:
case SectorTagType.CDSectorECC_Q:
throw new ArgumentException("Unsupported tag requested for this track", "tag");
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
case SectorTagType.CDSectorSubHeader:
{
sector_offset = 0;
@@ -1923,12 +1923,12 @@ namespace DiscImageChef.ImagePlugins
break;
}
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
break;
}
case DAOMode.Audio:
throw new ArgumentException("There are no tags on audio tracks", "tag");
throw new ArgumentException("There are no tags on audio tracks", nameof(tag));
case DAOMode.DataRaw:
{
switch(tag)
@@ -1949,7 +1949,7 @@ namespace DiscImageChef.ImagePlugins
}
case SectorTagType.CDSectorSubchannel:
case SectorTagType.CDSectorSubHeader:
throw new ArgumentException("Unsupported tag requested for this track", "tag");
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
case SectorTagType.CDSectorECC:
{
sector_offset = 2076;
@@ -1979,7 +1979,7 @@ namespace DiscImageChef.ImagePlugins
break;
}
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
break;
}
@@ -2012,7 +2012,7 @@ namespace DiscImageChef.ImagePlugins
break;
}
case SectorTagType.CDSectorSubHeader:
throw new ArgumentException("Unsupported tag requested for this track", "tag");
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
case SectorTagType.CDSectorECC:
{
sector_offset = 2076;
@@ -2042,14 +2042,14 @@ namespace DiscImageChef.ImagePlugins
break;
}
default:
throw new ArgumentException("Unsupported tag requested", "tag");
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
break;
}
case DAOMode.AudioSub:
{
if(tag != SectorTagType.CDSectorSubchannel)
throw new ArgumentException("Unsupported tag requested for this track", "tag");
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
sector_offset = 2352;
sector_size = 96;
@@ -2085,17 +2085,17 @@ namespace DiscImageChef.ImagePlugins
return buffer;
}
public override byte[] ReadSectorLong(UInt64 sectorAddress)
public override byte[] ReadSectorLong(ulong sectorAddress)
{
return ReadSectorsLong(sectorAddress, 1);
}
public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
{
return ReadSectorsLong(sectorAddress, 1, track);
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
{
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
{
@@ -2112,18 +2112,18 @@ namespace DiscImageChef.ImagePlugins
}
}
throw new ArgumentOutOfRangeException("sectorAddress", String.Format("Sector address {0} not found", sectorAddress));
throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress));
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
{
NeroTrack _track;
if(!neroTracks.TryGetValue(track, out _track))
throw new ArgumentOutOfRangeException("track", "Track not found");
throw new ArgumentOutOfRangeException(nameof(track), "Track not found");
if(length > _track.Sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
uint sector_offset;
uint sector_size;
@@ -2234,7 +2234,7 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.mediaType;
}
public override List<CommonTypes.Partition> GetPartitions()
public override List<Partition> GetPartitions()
{
return ImagePartitions;
}
@@ -2249,7 +2249,7 @@ namespace DiscImageChef.ImagePlugins
return GetSessionTracks(session.SessionSequence);
}
public override List<Track> GetSessionTracks(UInt16 session)
public override List<Track> GetSessionTracks(ushort session)
{
List<Track> sessionTracks = new List<Track>();
foreach(Track _track in imageTracks)
@@ -2264,25 +2264,25 @@ namespace DiscImageChef.ImagePlugins
return imageSessions;
}
public override bool? VerifySector(UInt64 sectorAddress)
public override bool? VerifySector(ulong sectorAddress)
{
byte[] buffer = ReadSectorLong(sectorAddress);
return Checksums.CDChecksums.CheckCDSector(buffer);
}
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
public override bool? VerifySector(ulong sectorAddress, uint track)
{
byte[] buffer = ReadSectorLong(sectorAddress, track);
return Checksums.CDChecksums.CheckCDSector(buffer);
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(int i = 0; i < length; i++)
{
@@ -2307,13 +2307,13 @@ namespace DiscImageChef.ImagePlugins
return true;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length, track);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(int i = 0; i < length; i++)
{
@@ -2423,7 +2423,7 @@ namespace DiscImageChef.ImagePlugins
}
}
static UInt16 NeroTrackModeToBytesPerSector(DAOMode mode)
static ushort NeroTrackModeToBytesPerSector(DAOMode mode)
{
switch(mode)
{

View File

@@ -33,15 +33,13 @@
using System;
using System.IO;
using System.Collections.Generic;
// Created following notes from Dave Dunfield
// http://www.classiccmp.org/dunfield/img54306/td0notes.txt
using DiscImageChef.Console;
using DiscImageChef.CommonTypes;
namespace DiscImageChef.ImagePlugins
{
// Created following notes from Dave Dunfield
// http://www.classiccmp.org/dunfield/img54306/td0notes.txt
class TeleDisk : ImagePlugin
{
#region Internal Structures
@@ -49,7 +47,7 @@ namespace DiscImageChef.ImagePlugins
struct TD0Header
{
/// <summary>"TD" or "td" depending on compression</summary>
public UInt16 signature;
public ushort signature;
/// <summary>Sequence, but TeleDisk seems to complaing if != 0</summary>
public byte sequence;
/// <summary>Random, same byte for all disks in the same set</summary>
@@ -67,15 +65,15 @@ namespace DiscImageChef.ImagePlugins
/// <summary>Sides of disk</summary>
public byte sides;
/// <summary>CRC of all the previous</summary>
public UInt16 crc;
public ushort crc;
}
struct TDCommentBlockHeader
{
/// <summary>CRC of comment block after crc field</summary>
public UInt16 crc;
public ushort crc;
/// <summary>Length of comment</summary>
public UInt16 length;
public ushort length;
public byte year;
public byte month;
public byte day;
@@ -115,7 +113,7 @@ namespace DiscImageChef.ImagePlugins
struct TDDataHeader
{
/// <summary>Size of all data (encoded) + next field (1)</summary>
public UInt16 dataSize;
public ushort dataSize;
/// <summary>Encoding used for data block</summary>
public byte dataEncoding;
}
@@ -125,9 +123,9 @@ namespace DiscImageChef.ImagePlugins
#region Internal Constants
// "TD" as little endian uint.
const UInt16 tdMagic = 0x4454;
const ushort tdMagic = 0x4454;
// "td" as little endian uint. Means whole file is compressed (aka Advanced Compression)
const UInt16 tdAdvCompMagic = 0x6474;
const ushort tdAdvCompMagic = 0x6474;
// DataRates
const byte DataRate250kbps = 0x00;
@@ -151,7 +149,7 @@ namespace DiscImageChef.ImagePlugins
const byte CommentBlockPresent = 0x80;
// CRC polynomial
const UInt16 TeleDiskCRCPoly = 0xA097;
const ushort TeleDiskCRCPoly = 0xA097;
// Sector sizes table
const byte SectorSize128 = 0x00;
@@ -191,11 +189,11 @@ namespace DiscImageChef.ImagePlugins
TD0Header header;
TDCommentBlockHeader commentHeader;
byte[] commentBlock;
Dictionary<UInt32, byte[]> sectorsData;
Dictionary<uint, byte[]> sectorsData;
// LBA, data
UInt32 totalDiskSize;
uint totalDiskSize;
bool ADiskCRCHasFailed;
List<UInt64> SectorsWhereCRCHasFailed;
List<ulong> SectorsWhereCRCHasFailed;
#endregion
@@ -222,7 +220,7 @@ namespace DiscImageChef.ImagePlugins
ImageInfo.driveModel = null;
ImageInfo.driveSerialNumber = null;
ADiskCRCHasFailed = false;
SectorsWhereCRCHasFailed = new List<UInt64>();
SectorsWhereCRCHasFailed = new List<ulong>();
}
public override bool IdentifyImage(string imagePath)
@@ -251,7 +249,7 @@ namespace DiscImageChef.ImagePlugins
byte[] headerBytesForCRC = new byte[10];
Array.Copy(headerBytes, headerBytesForCRC, 10);
UInt16 calculatedHeaderCRC = TeleDiskCRC(0x0000, headerBytesForCRC);
ushort calculatedHeaderCRC = TeleDiskCRC(0x0000, headerBytesForCRC);
DicConsole.DebugWriteLine("TeleDisk plugin", "header.signature = 0x{0:X4}", header.signature);
DicConsole.DebugWriteLine("TeleDisk plugin", "header.sequence = 0x{0:X2}", header.sequence);
@@ -309,12 +307,12 @@ namespace DiscImageChef.ImagePlugins
header.crc = BitConverter.ToUInt16(headerBytes, 10);
ImageInfo.imageName = Path.GetFileNameWithoutExtension(imagePath);
ImageInfo.imageVersion = String.Format("{0}.{1}", (header.version & 0xF0) >> 4, header.version & 0x0F);
ImageInfo.imageVersion = string.Format("{0}.{1}", (header.version & 0xF0) >> 4, header.version & 0x0F);
ImageInfo.imageApplication = ImageInfo.imageVersion;
byte[] headerBytesForCRC = new byte[10];
Array.Copy(headerBytes, headerBytesForCRC, 10);
UInt16 calculatedHeaderCRC = TeleDiskCRC(0x0000, headerBytesForCRC);
ushort calculatedHeaderCRC = TeleDiskCRC(0x0000, headerBytesForCRC);
DicConsole.DebugWriteLine("TeleDisk plugin", "header.signature = 0x{0:X4}", header.signature);
DicConsole.DebugWriteLine("TeleDisk plugin", "header.sequence = 0x{0:X2}", header.sequence);
@@ -377,7 +375,7 @@ namespace DiscImageChef.ImagePlugins
Array.Copy(commentHeaderBytes, 2, commentBlockForCRC, 0, 8);
Array.Copy(commentBlock, 0, commentBlockForCRC, 8, commentHeader.length);
UInt16 cmtcrc = TeleDiskCRC(0, commentBlockForCRC);
ushort cmtcrc = TeleDiskCRC(0, commentBlockForCRC);
DicConsole.DebugWriteLine("TeleDisk plugin", "Comment header");
DicConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.crc = 0x{0:X4}", commentHeader.crc);
@@ -486,7 +484,7 @@ namespace DiscImageChef.ImagePlugins
DicConsole.DebugWriteLine("TeleDisk plugin", "\t\tSector flags: 0x{0:X2}", TDSector.flags);
DicConsole.DebugWriteLine("TeleDisk plugin", "\t\tSector CRC (plus headers): 0x{0:X2}", TDSector.crc);
UInt32 LBA = (uint)((TDSector.cylinder * header.sides * spt) + (TDSector.head * spt) + (TDSector.sectorNumber - 1));
uint LBA = (uint)((TDSector.cylinder * header.sides * spt) + (TDSector.head * spt) + (TDSector.sectorNumber - 1));
if((TDSector.flags & FlagsSectorDataless) != FlagsSectorDataless && (TDSector.flags & FlagsSectorSkipped) != FlagsSectorSkipped)
{
stream.Read(dataSizeBytes, 0, 2);
@@ -508,7 +506,7 @@ namespace DiscImageChef.ImagePlugins
DicConsole.DebugWriteLine("TeleDisk plugin", "Sector LBA {0} calculated CRC 0x{1:X2} differs from stored CRC 0x{2:X2}", LBA, TDSectorCalculatedCRC, TDSector.crc);
if((TDSector.flags & FlagsSectorNoID) != FlagsSectorNoID)
if(!sectorsData.ContainsKey(LBA) && (TDSector.flags & FlagsSectorDuplicate) != FlagsSectorDuplicate)
SectorsWhereCRCHasFailed.Add((UInt64)LBA);
SectorsWhereCRCHasFailed.Add(LBA);
}
}
else
@@ -537,7 +535,7 @@ namespace DiscImageChef.ImagePlugins
decodedData = new byte[8192];
break;
default:
throw new ImageNotSupportedException(String.Format("Sector size {0} for cylinder {1} head {2} sector {3} is incorrect.",
throw new ImageNotSupportedException(string.Format("Sector size {0} for cylinder {1} head {2} sector {3} is incorrect.",
TDSector.sectorSize, TDSector.cylinder, TDSector.head, TDSector.sectorNumber));
}
ArrayHelpers.ArrayFill(decodedData, (byte)0);
@@ -585,33 +583,33 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.imageHasPartitions;
}
public override UInt64 GetImageSize()
public override ulong GetImageSize()
{
return ImageInfo.imageSize;
}
public override UInt64 GetSectors()
public override ulong GetSectors()
{
return ImageInfo.sectors;
}
public override UInt32 GetSectorSize()
public override uint GetSectorSize()
{
return ImageInfo.sectorSize;
}
public override byte[] ReadSector(UInt64 sectorAddress)
public override byte[] ReadSector(ulong sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectors(ulong sectorAddress, uint length)
{
if(sectorAddress > (ulong)sectorsData.Count - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
if(sectorAddress + length > (ulong)sectorsData.Count)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
byte[] data = new byte[1]; // To make compiler happy
bool first = true;
@@ -620,12 +618,12 @@ namespace DiscImageChef.ImagePlugins
for(ulong i = sectorAddress; i < (sectorAddress + length); i++)
{
if(!sectorsData.ContainsKey((uint)i))
throw new ImageNotSupportedException(String.Format("Requested sector {0} not found", i));
throw new ImageNotSupportedException(string.Format("Requested sector {0} not found", i));
byte[] sector;
if(!sectorsData.TryGetValue((uint)i, out sector))
throw new ImageNotSupportedException(String.Format("Error reading sector {0}", i));
throw new ImageNotSupportedException(string.Format("Error reading sector {0}", i));
if(first)
{
@@ -644,12 +642,12 @@ namespace DiscImageChef.ImagePlugins
return data;
}
public override byte[] ReadSectorLong(UInt64 sectorAddress)
public override byte[] ReadSectorLong(ulong sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
{
return ReadSectors(sectorAddress, length);
}
@@ -694,34 +692,34 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.mediaType;
}
public override bool? VerifySector(UInt64 sectorAddress)
public override bool? VerifySector(ulong sectorAddress)
{
return !SectorsWhereCRCHasFailed.Contains(sectorAddress);
}
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
public override bool? VerifySector(ulong sectorAddress, uint track)
{
return null;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(UInt64 i = sectorAddress; i < sectorAddress + length; i++)
for(ulong i = sectorAddress; i < sectorAddress + length; i++)
if(SectorsWhereCRCHasFailed.Contains(sectorAddress))
FailingLBAs.Add(sectorAddress);
return FailingLBAs.Count <= 0;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(UInt64 i = sectorAddress; i < sectorAddress + length; i++)
for(ulong i = sectorAddress; i < sectorAddress + length; i++)
UnknownLBAs.Add(i);
return null;
@@ -734,20 +732,20 @@ namespace DiscImageChef.ImagePlugins
#region Private methods
static UInt16 TeleDiskCRC(UInt16 crc, byte[] buffer)
static ushort TeleDiskCRC(ushort crc, byte[] buffer)
{
int counter = 0;
while(counter < buffer.Length)
{
crc ^= (UInt16)((buffer[counter] & 0xFF) << 8);
crc ^= (ushort)((buffer[counter] & 0xFF) << 8);
for(int i = 0; i < 8; i++)
{
if((crc & 0x8000) > 0)
crc = (UInt16)((crc << 1) ^ TeleDiskCRCPoly);
crc = (ushort)((crc << 1) ^ TeleDiskCRCPoly);
else
crc = (UInt16)(crc << 1);
crc = (ushort)(crc << 1);
}
counter++;
@@ -783,7 +781,7 @@ namespace DiscImageChef.ImagePlugins
decodedData = new byte[8192];
break;
default:
throw new ImageNotSupportedException(String.Format("Sector size {0} is incorrect.", sectorSize));
throw new ImageNotSupportedException(string.Format("Sector size {0} is incorrect.", sectorSize));
}
switch(encodingType)
@@ -797,7 +795,7 @@ namespace DiscImageChef.ImagePlugins
int outs = 0;
while(ins < encodedData.Length)
{
UInt16 repeatNumber;
ushort repeatNumber;
byte[] repeatValue = new byte[2];
repeatNumber = BitConverter.ToUInt16(encodedData, ins);
@@ -856,7 +854,7 @@ namespace DiscImageChef.ImagePlugins
break;
}
default:
throw new ImageNotSupportedException(String.Format("Data encoding {0} is incorrect.", encodingType));
throw new ImageNotSupportedException(string.Format("Data encoding {0} is incorrect.", encodingType));
}
return decodedData;
@@ -877,24 +875,24 @@ namespace DiscImageChef.ImagePlugins
// Acorn disk uses 256 bytes/sector
if(ImageInfo.sectorSize == 256)
return MediaType.ACORN_525_SS_DD_40;
else // DOS disks use 512 bytes/sector
return MediaType.DOS_525_SS_DD_8;
// DOS disks use 512 bytes/sector
return MediaType.DOS_525_SS_DD_8;
}
case 184320:
{
// Atari disk uses 256 bytes/sector
if(ImageInfo.sectorSize == 256)
return MediaType.ATARI_525_DD;
else // DOS disks use 512 bytes/sector
return MediaType.DOS_525_SS_DD_9;
// DOS disks use 512 bytes/sector
return MediaType.DOS_525_SS_DD_9;
}
case 327680:
{
// Acorn disk uses 256 bytes/sector
if(ImageInfo.sectorSize == 256)
return MediaType.ACORN_525_SS_DD_80;
else // DOS disks use 512 bytes/sector
return MediaType.DOS_525_DS_DD_8;
// DOS disks use 512 bytes/sector
return MediaType.DOS_525_DS_DD_8;
}
case 368640:
return MediaType.DOS_525_DS_DD_9;
@@ -1011,8 +1009,8 @@ namespace DiscImageChef.ImagePlugins
// DEC disk uses 256 bytes/sector
if(ImageInfo.sectorSize == 256)
return MediaType.RX02;
else // ECMA disks use 128 bytes/sector
return MediaType.ECMA_59;
// ECMA disks use 128 bytes/sector
return MediaType.ECMA_59;
}
case 1261568:
return MediaType.NEC_8_DD;
@@ -1042,12 +1040,12 @@ namespace DiscImageChef.ImagePlugins
#region Unsupported features
public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
@@ -1117,7 +1115,7 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.driveSerialNumber;
}
public override List<CommonTypes.Partition> GetPartitions()
public override List<Partition> GetPartitions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
@@ -1132,7 +1130,7 @@ namespace DiscImageChef.ImagePlugins
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetSessionTracks(UInt16 session)
public override List<Track> GetSessionTracks(ushort session)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
@@ -1142,32 +1140,32 @@ namespace DiscImageChef.ImagePlugins
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSector(ulong sectorAddress, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}

View File

@@ -55,58 +55,58 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Offset 0x00, File magic number, <see cref="ImageCookie"/>
/// </summary>
public UInt64 cookie;
public ulong cookie;
/// <summary>
/// Offset 0x08, Specific feature support
/// </summary>
public UInt32 features;
public uint features;
/// <summary>
/// Offset 0x0C, File format version
/// </summary>
public UInt32 version;
public uint version;
/// <summary>
/// Offset 0x10, Offset from beginning of file to next structure
/// </summary>
public UInt64 offset;
public ulong offset;
/// <summary>
/// Offset 0x18, Creation date seconds since 2000/01/01 00:00:00 UTC
/// </summary>
public UInt32 timestamp;
public uint timestamp;
/// <summary>
/// Offset 0x1C, Application that created this disk image
/// </summary>
public UInt32 creatorApplication;
public uint creatorApplication;
/// <summary>
/// Offset 0x20, Version of the application that created this disk image
/// </summary>
public UInt32 creatorVersion;
public uint creatorVersion;
/// <summary>
/// Offset 0x24, Host operating system of the application that created this disk image
/// </summary>
public UInt32 creatorHostOS;
public uint creatorHostOS;
/// <summary>
/// Offset 0x28, Original hard disk size, in bytes
/// </summary>
public UInt64 originalSize;
public ulong originalSize;
/// <summary>
/// Offset 0x30, Current hard disk size, in bytes
/// </summary>
public UInt64 currentSize;
public ulong currentSize;
/// <summary>
/// Offset 0x38, CHS geometry
/// Cylinder mask = 0xFFFF0000
/// Heads mask = 0x0000FF00
/// Sectors mask = 0x000000FF
/// </summary>
public UInt32 diskGeometry;
public uint diskGeometry;
/// <summary>
/// Offset 0x3C, Disk image type
/// </summary>
public UInt32 diskType;
public uint diskType;
/// <summary>
/// Offset 0x40, Checksum for this structure
/// </summary>
public UInt32 checksum;
public uint checksum;
/// <summary>
/// Offset 0x44, UUID, used to associate parent with differencing disk images
/// </summary>
@@ -126,23 +126,23 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Offset 0x00, Describes the platform specific type this entry belongs to
/// </summary>
public UInt32 platformCode;
public uint platformCode;
/// <summary>
/// Offset 0x04, Describes the number of 512 bytes sectors used by this entry
/// </summary>
public UInt32 platformDataSpace;
public uint platformDataSpace;
/// <summary>
/// Offset 0x08, Describes this entry's size in bytes
/// </summary>
public UInt32 platformDataLength;
public uint platformDataLength;
/// <summary>
/// Offset 0x0c, Reserved
/// </summary>
public UInt32 reserved;
public uint reserved;
/// <summary>
/// Offset 0x10, Offset on disk image this entry resides on
/// </summary>
public UInt64 platformDataOffset;
public ulong platformDataOffset;
}
struct DynamicDiskHeader
@@ -150,33 +150,33 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Offset 0x00, Header magic, <see cref="DynamicCookie"/>
/// </summary>
public UInt64 cookie;
public ulong cookie;
/// <summary>
/// Offset 0x08, Offset to next structure on disk image.
/// Currently unused, 0xFFFFFFFF
/// </summary>
public UInt64 dataOffset;
public ulong dataOffset;
/// <summary>
/// Offset 0x10, Offset of the Block Allocation Table (BAT)
/// </summary>
public UInt64 tableOffset;
public ulong tableOffset;
/// <summary>
/// Offset 0x18, Version of this header
/// </summary>
public UInt32 headerVersion;
public uint headerVersion;
/// <summary>
/// Offset 0x1C, Maximum entries present in the BAT
/// </summary>
public UInt32 maxTableEntries;
public uint maxTableEntries;
/// <summary>
/// Offset 0x20, Size of a block in bytes
/// Should always be a power of two of 512
/// </summary>
public UInt32 blockSize;
public uint blockSize;
/// <summary>
/// Offset 0x24, Checksum of this header
/// </summary>
public UInt32 checksum;
public uint checksum;
/// <summary>
/// Offset 0x28, UUID of parent disk image for differencing type
/// </summary>
@@ -184,11 +184,11 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// Offset 0x38, Timestamp of parent disk image
/// </summary>
public UInt32 parentTimestamp;
public uint parentTimestamp;
/// <summary>
/// Offset 0x3C, Reserved
/// </summary>
public UInt32 reserved;
public uint reserved;
/// <summary>
/// Offset 0x40, 512 bytes UTF-16 of parent disk image filename
/// </summary>
@@ -207,7 +207,7 @@ namespace DiscImageChef.ImagePlugins
struct BATSector
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public UInt32[] blockPointer;
public uint[] blockPointer;
}
#endregion
@@ -217,134 +217,134 @@ namespace DiscImageChef.ImagePlugins
/// <summary>
/// File magic number, "conectix"
/// </summary>
const UInt64 ImageCookie = 0x636F6E6563746978;
const ulong ImageCookie = 0x636F6E6563746978;
/// <summary>
/// Dynamic disk header magic, "cxsparse"
/// </summary>
const UInt64 DynamicCookie = 0x6378737061727365;
const ulong DynamicCookie = 0x6378737061727365;
/// <summary>
/// Disk image is candidate for deletion on shutdown
/// </summary>
const UInt32 FeaturesTemporary = 0x00000001;
const uint FeaturesTemporary = 0x00000001;
/// <summary>
/// Unknown, set from Virtual PC for Mac 7 onwards
/// </summary>
const UInt32 FeaturesReserved = 0x00000002;
const uint FeaturesReserved = 0x00000002;
/// <summary>
/// Unknown
/// </summary>
const UInt32 FeaturesUnknown = 0x00000100;
const uint FeaturesUnknown = 0x00000100;
/// <summary>
/// Only known version
/// </summary>
const UInt32 Version1 = 0x00010000;
const uint Version1 = 0x00010000;
/// <summary>
/// Created by Virtual PC, "vpc "
/// </summary>
const UInt32 CreatorVirtualPC = 0x76706320;
const uint CreatorVirtualPC = 0x76706320;
/// <summary>
/// Created by Virtual Server, "vs "
/// </summary>
const UInt32 CreatorVirtualServer = 0x76732020;
const uint CreatorVirtualServer = 0x76732020;
/// <summary>
/// Created by QEMU, "qemu"
/// </summary>
const UInt32 CreatorQEMU = 0x71656D75;
const uint CreatorQEMU = 0x71656D75;
/// <summary>
/// Created by VirtualBox, "vbox"
/// </summary>
const UInt32 CreatorVirtualBox = 0x76626F78;
const uint CreatorVirtualBox = 0x76626F78;
/// <summary>
/// Disk image created by Virtual Server 2004
/// </summary>
const UInt32 VersionVirtualServer2004 = 0x00010000;
const uint VersionVirtualServer2004 = 0x00010000;
/// <summary>
/// Disk image created by Virtual PC 2004
/// </summary>
const UInt32 VersionVirtualPC2004 = 0x00050000;
const uint VersionVirtualPC2004 = 0x00050000;
/// <summary>
/// Disk image created by Virtual PC 2007
/// </summary>
const UInt32 VersionVirtualPC2007 = 0x00050003;
const uint VersionVirtualPC2007 = 0x00050003;
/// <summary>
/// Disk image created by Virtual PC for Mac 5, 6 or 7
/// </summary>
const UInt32 VersionVirtualPCMac = 0x00040000;
const uint VersionVirtualPCMac = 0x00040000;
/// <summary>
/// Disk image created in Windows, "Wi2k"
/// </summary>
const UInt32 CreatorWindows = 0x5769326B;
const uint CreatorWindows = 0x5769326B;
/// <summary>
/// Disk image created in Macintosh, "Mac "
/// </summary>
const UInt32 CreatorMacintosh = 0x4D616320;
const uint CreatorMacintosh = 0x4D616320;
/// <summary>
/// Seen in Virtual PC for Mac for dynamic and fixed images
/// </summary>
const UInt32 CreatorMacintoshOld = 0x00000000;
const uint CreatorMacintoshOld = 0x00000000;
/// <summary>
/// Disk image type is none, useless?
/// </summary>
const UInt32 typeNone = 0;
const uint typeNone = 0;
/// <summary>
/// Deprecated disk image type
/// </summary>
const UInt32 typeDeprecated1 = 1;
const uint typeDeprecated1 = 1;
/// <summary>
/// Fixed disk image type
/// </summary>
const UInt32 typeFixed = 2;
const uint typeFixed = 2;
/// <summary>
/// Dynamic disk image type
/// </summary>
const UInt32 typeDynamic = 3;
const uint typeDynamic = 3;
/// <summary>
/// Differencing disk image type
/// </summary>
const UInt32 typeDifferencing = 4;
const uint typeDifferencing = 4;
/// <summary>
/// Deprecated disk image type
/// </summary>
const UInt32 typeDeprecated2 = 5;
const uint typeDeprecated2 = 5;
/// <summary>
/// Deprecated disk image type
/// </summary>
const UInt32 typeDeprecated3 = 6;
const uint typeDeprecated3 = 6;
/// <summary>
/// Means platform locator is unused
/// </summary>
const UInt32 platformCodeUnused = 0x00000000;
const uint platformCodeUnused = 0x00000000;
/// <summary>
/// Stores a relative path string for Windows, unknown locale used, deprecated, "Wi2r"
/// </summary>
const UInt32 platformCodeWindowsRelative = 0x57693272;
const uint platformCodeWindowsRelative = 0x57693272;
/// <summary>
/// Stores an absolute path string for Windows, unknown locale used, deprecated, "Wi2k"
/// </summary>
const UInt32 platformCodeWindowsAbsolute = 0x5769326B;
const uint platformCodeWindowsAbsolute = 0x5769326B;
/// <summary>
/// Stores a relative path string for Windows in UTF-16, "W2ru"
/// </summary>
const UInt32 platformCodeWindowsRelativeU = 0x57327275;
const uint platformCodeWindowsRelativeU = 0x57327275;
/// <summary>
/// Stores an absolute path string for Windows in UTF-16, "W2ku"
/// </summary>
const UInt32 platformCodeWindowsAbsoluteU = 0x57326B75;
const uint platformCodeWindowsAbsoluteU = 0x57326B75;
/// <summary>
/// Stores a Mac OS alias as a blob, "Mac "
/// </summary>
const UInt32 platformCodeMacintoshAlias = 0x4D616320;
const uint platformCodeMacintoshAlias = 0x4D616320;
/// <summary>
/// Stores a Mac OS X URI (RFC-2396) absolute path in UTF-8, "MacX"
/// </summary>
const UInt32 platformCodeMacintoshURI = 0x4D616358;
const uint platformCodeMacintoshURI = 0x4D616358;
#endregion
@@ -355,8 +355,8 @@ namespace DiscImageChef.ImagePlugins
DateTime thisDateTime;
DateTime parentDateTime;
string thisPath;
UInt32[] blockAllocationTable;
UInt32 bitmapSize;
uint[] blockAllocationTable;
uint bitmapSize;
byte[][] locatorEntriesData;
ImagePlugin parentImage;
@@ -393,8 +393,8 @@ namespace DiscImageChef.ImagePlugins
public override bool IdentifyImage(string imagePath)
{
FileStream imageStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
UInt64 headerCookie;
UInt64 footerCookie;
ulong headerCookie;
ulong footerCookie;
byte[] headerCookieBytes = new byte[8];
byte[] footerCookieBytes = new byte[8];
@@ -439,10 +439,10 @@ namespace DiscImageChef.ImagePlugins
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
UInt32 headerChecksum = BigEndianBitConverter.ToUInt32(header, 0x40);
UInt32 footerChecksum = BigEndianBitConverter.ToUInt32(footer, 0x40);
UInt64 headerCookie = BigEndianBitConverter.ToUInt64(header, 0);
UInt64 footerCookie = BigEndianBitConverter.ToUInt64(footer, 0);
uint headerChecksum = BigEndianBitConverter.ToUInt32(header, 0x40);
uint footerChecksum = BigEndianBitConverter.ToUInt32(footer, 0x40);
ulong headerCookie = BigEndianBitConverter.ToUInt64(header, 0);
ulong footerCookie = BigEndianBitConverter.ToUInt64(footer, 0);
header[0x40] = 0;
header[0x41] = 0;
@@ -453,14 +453,14 @@ namespace DiscImageChef.ImagePlugins
footer[0x42] = 0;
footer[0x43] = 0;
UInt32 headerCalculatedChecksum = VHDChecksum(header);
UInt32 footerCalculatedChecksum = VHDChecksum(footer);
uint headerCalculatedChecksum = VHDChecksum(header);
uint footerCalculatedChecksum = VHDChecksum(footer);
DicConsole.DebugWriteLine("VirtualPC plugin", "Header checksum = 0x{0:X8}, calculated = 0x{1:X8}", headerChecksum, headerCalculatedChecksum);
DicConsole.DebugWriteLine("VirtualPC plugin", "Header checksum = 0x{0:X8}, calculated = 0x{1:X8}", footerChecksum, footerCalculatedChecksum);
byte[] usableHeader;
UInt32 usableChecksum;
uint usableChecksum;
if(headerCookie == ImageCookie && headerChecksum == headerCalculatedChecksum)
{
@@ -524,7 +524,7 @@ namespace DiscImageChef.ImagePlugins
if(thisFooter.version == Version1)
ImageInfo.imageVersion = "1.0";
else
throw new ImageNotSupportedException(String.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType));
throw new ImageNotSupportedException(string.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType));
switch(thisFooter.creatorApplication)
{
@@ -538,7 +538,7 @@ namespace DiscImageChef.ImagePlugins
}
case CreatorVirtualBox:
{
ImageInfo.imageApplicationVersion = String.Format("{0}.{1:D2}", (thisFooter.creatorVersion & 0xFFFF0000) >> 16, (thisFooter.creatorVersion & 0x0000FFFF));
ImageInfo.imageApplicationVersion = string.Format("{0}.{1:D2}", (thisFooter.creatorVersion & 0xFFFF0000) >> 16, (thisFooter.creatorVersion & 0x0000FFFF));
switch(thisFooter.creatorHostOS)
{
case CreatorMacintosh:
@@ -550,7 +550,7 @@ namespace DiscImageChef.ImagePlugins
ImageInfo.imageApplication = "VirtualBox";
break;
default:
ImageInfo.imageApplication = String.Format("VirtualBox for unknown OS \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS)));
ImageInfo.imageApplication = string.Format("VirtualBox for unknown OS \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS)));
break;
}
break;
@@ -564,7 +564,7 @@ namespace DiscImageChef.ImagePlugins
ImageInfo.imageApplicationVersion = "2004";
break;
default:
ImageInfo.imageApplicationVersion = String.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion);
ImageInfo.imageApplicationVersion = string.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion);
break;
}
break;
@@ -582,7 +582,7 @@ namespace DiscImageChef.ImagePlugins
ImageInfo.imageApplicationVersion = "5, 6 or 7";
break;
default:
ImageInfo.imageApplicationVersion = String.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion);
ImageInfo.imageApplicationVersion = string.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion);
break;
}
break;
@@ -602,21 +602,21 @@ namespace DiscImageChef.ImagePlugins
ImageInfo.imageApplicationVersion = "2007";
break;
default:
ImageInfo.imageApplicationVersion = String.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion);
ImageInfo.imageApplicationVersion = string.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion);
break;
}
break;
default:
ImageInfo.imageApplication = String.Format("Virtual PC for unknown OS \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS)));
ImageInfo.imageApplicationVersion = String.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion);
ImageInfo.imageApplication = string.Format("Virtual PC for unknown OS \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS)));
ImageInfo.imageApplicationVersion = string.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion);
break;
}
break;
}
default:
{
ImageInfo.imageApplication = String.Format("Unknown application \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS)));
ImageInfo.imageApplicationVersion = String.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion);
ImageInfo.imageApplication = string.Format("Unknown application \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS)));
ImageInfo.imageApplicationVersion = string.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion);
break;
}
}
@@ -637,14 +637,14 @@ namespace DiscImageChef.ImagePlugins
byte[] dynamicBytes = new byte[1024];
imageStream.Read(dynamicBytes, 0, 1024);
UInt32 dynamicChecksum = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x24);
uint dynamicChecksum = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x24);
dynamicBytes[0x24] = 0;
dynamicBytes[0x25] = 0;
dynamicBytes[0x26] = 0;
dynamicBytes[0x27] = 0;
UInt32 dynamicChecksumCalculated = VHDChecksum(dynamicBytes);
uint dynamicChecksumCalculated = VHDChecksum(dynamicBytes);
DicConsole.DebugWriteLine("VirtualPC plugin", "Dynamic header checksum = 0x{0:X8}, calculated = 0x{1:X8}", dynamicChecksum, dynamicChecksumCalculated);
@@ -711,7 +711,7 @@ namespace DiscImageChef.ImagePlugins
DicConsole.DebugWriteLine("VirtualPC plugin", "dynamic.reserved2's SHA1 = 0x{0}", sha1Ctx.End());
if(thisDynamic.headerVersion != Version1)
throw new ImageNotSupportedException(String.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType));
throw new ImageNotSupportedException(string.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType));
DateTime startTime = DateTime.UtcNow;
@@ -730,7 +730,7 @@ namespace DiscImageChef.ImagePlugins
*/
// How many sectors uses the BAT
UInt32 batSectorCount = (uint)Math.Ceiling(((double)thisDynamic.maxTableEntries * 4) / 512);
uint batSectorCount = (uint)Math.Ceiling(((double)thisDynamic.maxTableEntries * 4) / 512);
byte[] batSectorBytes = new byte[512];
BATSector batSector = new BATSector();
@@ -891,7 +891,7 @@ namespace DiscImageChef.ImagePlugins
}
default:
{
throw new ImageNotSupportedException(String.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType));
throw new ImageNotSupportedException(string.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType));
}
}
}
@@ -978,14 +978,14 @@ namespace DiscImageChef.ImagePlugins
case typeDifferencing:
{
// Block number for BAT searching
UInt32 blockNumber = (uint)Math.Floor((double)(sectorAddress / (thisDynamic.blockSize / 512)));
uint blockNumber = (uint)Math.Floor((double)(sectorAddress / (thisDynamic.blockSize / 512)));
// Sector number inside of block
UInt32 sectorInBlock = (uint)(sectorAddress % (thisDynamic.blockSize / 512));
uint sectorInBlock = (uint)(sectorAddress % (thisDynamic.blockSize / 512));
byte[] bitmap = new byte[bitmapSize * 512];
// Offset of block in file
UInt32 blockOffset = blockAllocationTable[blockNumber] * 512;
uint blockOffset = blockAllocationTable[blockNumber] * 512;
int bitmapByte = (int)Math.Floor((double)sectorInBlock / 8);
int bitmapBit = (int)(sectorInBlock % 8);
@@ -1021,10 +1021,10 @@ namespace DiscImageChef.ImagePlugins
*/
byte[] data = new byte[512];
UInt32 sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock;
uint sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock;
thisStream = new FileStream(thisPath, FileMode.Open, FileAccess.Read);
thisStream.Seek((long)(sectorOffset * 512), SeekOrigin.Begin);
thisStream.Seek((sectorOffset * 512), SeekOrigin.Begin);
thisStream.Read(data, 0, 512);
thisStream.Close();
@@ -1070,11 +1070,11 @@ namespace DiscImageChef.ImagePlugins
FileStream thisStream;
// Block number for BAT searching
UInt32 blockNumber = (uint)Math.Floor((double)(sectorAddress / (thisDynamic.blockSize / 512)));
uint blockNumber = (uint)Math.Floor((double)(sectorAddress / (thisDynamic.blockSize / 512)));
// Sector number inside of block
UInt32 sectorInBlock = (uint)(sectorAddress % (thisDynamic.blockSize / 512));
uint sectorInBlock = (uint)(sectorAddress % (thisDynamic.blockSize / 512));
// How many sectors before reaching end of block
UInt32 remainingInBlock = (thisDynamic.blockSize / 512) - sectorInBlock;
uint remainingInBlock = (thisDynamic.blockSize / 512) - sectorInBlock;
// Data that can be read in this block
byte[] prefix;
@@ -1082,7 +1082,7 @@ namespace DiscImageChef.ImagePlugins
byte[] suffix = null;
// How many sectors to read from this block
UInt32 sectorsToReadHere;
uint sectorsToReadHere;
// Asked to read more sectors than are remaining in block
if(length > remainingInBlock)
@@ -1094,14 +1094,14 @@ namespace DiscImageChef.ImagePlugins
sectorsToReadHere = length;
// Offset of sector in file
UInt32 sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock;
uint sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock;
prefix = new byte[sectorsToReadHere * 512];
// 0xFFFFFFFF means unallocated
if(sectorOffset != 0xFFFFFFFF)
{
thisStream = new FileStream(thisPath, FileMode.Open, FileAccess.Read);
thisStream.Seek((long)(sectorOffset * 512), SeekOrigin.Begin);
thisStream.Seek((sectorOffset * 512), SeekOrigin.Begin);
thisStream.Read(prefix, 0, (int)(512 * sectorsToReadHere));
thisStream.Close();
}
@@ -1140,7 +1140,7 @@ namespace DiscImageChef.ImagePlugins
}
default:
{
throw new ImageNotSupportedException(String.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType));
throw new ImageNotSupportedException(string.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType));
}
}
}
@@ -1149,9 +1149,9 @@ namespace DiscImageChef.ImagePlugins
#region private methods
static UInt32 VHDChecksum(byte[] data)
static uint VHDChecksum(byte[] data)
{
UInt32 checksum = 0;
uint checksum = 0;
foreach(byte b in data)
checksum += b;
return ~checksum;
@@ -1271,7 +1271,7 @@ namespace DiscImageChef.ImagePlugins
return null;
}
public override List<CommonTypes.Partition> GetPartitions()
public override List<Partition> GetPartitions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}

View File

@@ -281,27 +281,27 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.imageHasPartitions;
}
public override UInt64 GetImageSize()
public override ulong GetImageSize()
{
return ImageInfo.imageSize;
}
public override UInt64 GetSectors()
public override ulong GetSectors()
{
return ImageInfo.sectors;
}
public override UInt32 GetSectorSize()
public override uint GetSectorSize()
{
return ImageInfo.sectorSize;
}
public override byte[] ReadSector(UInt64 sectorAddress)
public override byte[] ReadSector(ulong sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectors(ulong sectorAddress, uint length)
{
if(differentTrackZeroSize)
{
@@ -310,10 +310,10 @@ namespace DiscImageChef.ImagePlugins
else
{
if(sectorAddress > ImageInfo.sectors - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
if(sectorAddress + length > ImageInfo.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
byte[] buffer = new byte[length * ImageInfo.sectorSize];
@@ -355,33 +355,33 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.mediaType;
}
public override bool? VerifySector(UInt64 sectorAddress)
public override bool? VerifySector(ulong sectorAddress)
{
return null;
}
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
public override bool? VerifySector(ulong sectorAddress, uint track)
{
return null;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(UInt64 i = sectorAddress; i < sectorAddress + length; i++)
for(ulong i = sectorAddress; i < sectorAddress + length; i++)
UnknownLBAs.Add(i);
return null;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for(UInt64 i = sectorAddress; i < sectorAddress + length; i++)
for(ulong i = sectorAddress; i < sectorAddress + length; i++)
UnknownLBAs.Add(i);
return null;
@@ -421,7 +421,7 @@ namespace DiscImageChef.ImagePlugins
if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc)
{
if(session.SessionSequence != 1)
throw new ArgumentOutOfRangeException("session", "Only a single session is supported");
throw new ArgumentOutOfRangeException(nameof(session), "Only a single session is supported");
Track trk = new Track();
trk.TrackBytesPerSector = (int)ImageInfo.sectorSize;
@@ -443,12 +443,12 @@ namespace DiscImageChef.ImagePlugins
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetSessionTracks(UInt16 session)
public override List<Track> GetSessionTracks(ushort session)
{
if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc)
{
if(session != 1)
throw new ArgumentOutOfRangeException("session", "Only a single session is supported");
throw new ArgumentOutOfRangeException(nameof(session), "Only a single session is supported");
Track trk = new Track();
trk.TrackBytesPerSector = (int)ImageInfo.sectorSize;
@@ -488,12 +488,12 @@ namespace DiscImageChef.ImagePlugins
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSector(ulong sectorAddress, uint track)
{
if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc)
{
if(track != 1)
throw new ArgumentOutOfRangeException("track", "Only a single session is supported");
throw new ArgumentOutOfRangeException(nameof(track), "Only a single session is supported");
return ReadSector(sectorAddress);
}
@@ -501,12 +501,12 @@ namespace DiscImageChef.ImagePlugins
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
{
if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc)
{
if(track != 1)
throw new ArgumentOutOfRangeException("track", "Only a single session is supported");
throw new ArgumentOutOfRangeException(nameof(track), "Only a single session is supported");
return ReadSectors(sectorAddress, length);
}
@@ -514,12 +514,12 @@ namespace DiscImageChef.ImagePlugins
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
{
if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc)
{
if(track != 1)
throw new ArgumentOutOfRangeException("track", "Only a single session is supported");
throw new ArgumentOutOfRangeException(nameof(track), "Only a single session is supported");
return ReadSector(sectorAddress);
}
@@ -527,12 +527,12 @@ namespace DiscImageChef.ImagePlugins
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
{
if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc)
{
if(track != 1)
throw new ArgumentOutOfRangeException("track", "Only a single session is supported");
throw new ArgumentOutOfRangeException(nameof(track), "Only a single session is supported");
return ReadSectors(sectorAddress, length);
}
@@ -682,22 +682,22 @@ namespace DiscImageChef.ImagePlugins
#region Unsupported features
public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorLong(UInt64 sectorAddress)
public override byte[] ReadSectorLong(ulong sectorAddress)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
@@ -782,17 +782,17 @@ namespace DiscImageChef.ImagePlugins
return ImageInfo.driveSerialNumber;
}
public override List<CommonTypes.Partition> GetPartitions()
public override List<Partition> GetPartitions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}