2016-07-28 18:13:49 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : DiskCopy42.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Disc image plugins.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Manages Apple DiskCopy 4.2 disc images, including unofficial modifications.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
// Copyright © 2011-2016 Natalia Portillo
|
|
|
|
|
|
// ****************************************************************************/
|
2014-04-17 19:58:14 +00:00
|
|
|
|
|
|
|
|
|
|
using System;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Collections.Generic;
|
2015-10-18 22:04:03 +01:00
|
|
|
|
using DiscImageChef.Console;
|
2015-11-23 21:44:58 +00:00
|
|
|
|
using DiscImageChef.CommonTypes;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2014-06-15 23:39:34 +01:00
|
|
|
|
namespace DiscImageChef.ImagePlugins
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2014-04-17 19:58:14 +00:00
|
|
|
|
// Checked using several images and strings inside Apple's DiskImages.framework
|
2014-04-15 21:04:04 +00:00
|
|
|
|
class DiskCopy42 : ImagePlugin
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Internal Structures
|
|
|
|
|
|
|
|
|
|
|
|
// DiskCopy 4.2 header, big-endian, data-fork, start of file, 84 bytes
|
|
|
|
|
|
struct DC42Header
|
|
|
|
|
|
{
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>0x00, 64 bytes, pascal string, disk name or "-not a Macintosh disk-", filled with garbage</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
public string diskName;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>0x40, size of data in bytes (usually sectors*512)</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
public UInt32 dataSize;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>0x44, size of tags in bytes (usually sectors*12)</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
public UInt32 tagSize;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>0x48, checksum of data bytes</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
public UInt32 dataChecksum;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>0x4C, checksum of tag bytes</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
public UInt32 tagChecksum;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>0x50, format of disk, see constants</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
public byte format;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>0x51, format of sectors, see constants</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
public byte fmtByte;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>0x52, is disk image valid? always 0x01</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
public byte valid;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>0x53, reserved, always 0x00</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
public byte reserved;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Internal Constants
|
|
|
|
|
|
|
|
|
|
|
|
// format byte
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>3.5", single side, double density, GCR</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
const byte kSonyFormat400K = 0x00;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>3.5", double side, double density, GCR</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
const byte kSonyFormat800K = 0x01;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>3.5", double side, double density, MFM</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
const byte kSonyFormat720K = 0x02;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>3.5", double side, high density, MFM</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
const byte kSonyFormat1440K = 0x03;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>3.5", double side, high density, MFM, 21 sectors/track (aka, Microsoft DMF)
|
|
|
|
|
|
// Unchecked value</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
const byte kSonyFormat1680K = 0x04;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>Defined by Sigma Seven's BLU</summary>
|
2014-04-17 03:19:27 +00:00
|
|
|
|
const byte kSigmaFormatTwiggy = 0x54;
|
2016-07-27 18:03:32 +01:00
|
|
|
|
/// <summary>Defined by LisaEm</summary>
|
|
|
|
|
|
const byte kNotStandardFormat = 0x5D;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
// There should be a value for Apple HD20 hard disks, unknown...
|
|
|
|
|
|
// fmyByte byte
|
|
|
|
|
|
// Based on GCR nibble
|
|
|
|
|
|
// Always 0x02 for MFM disks
|
|
|
|
|
|
// Unknown for Apple HD20
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>Defined by Sigma Seven's BLU</summary>
|
2014-08-24 17:49:16 +01:00
|
|
|
|
const byte kSigmaFmtByteTwiggy = 0x01;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>3.5" single side double density GCR and MFM all use same code</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
const byte kSonyFmtByte400K = 0x02;
|
|
|
|
|
|
const byte kSonyFmtByte720K = kSonyFmtByte400K;
|
|
|
|
|
|
const byte kSonyFmtByte1440K = kSonyFmtByte400K;
|
|
|
|
|
|
const byte kSonyFmtByte1680K = kSonyFmtByte400K;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>3.5" double side double density GCR, 512 bytes/sector, interleave 2:1</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
const byte kSonyFmtByte800K = 0x22;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>3.5" double side double density GCR, 512 bytes/sector, interleave 2:1, incorrect value (but appears on official documentation)</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
const byte kSonyFmtByte800KIncorrect = 0x12;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>3.5" double side double density GCR, ProDOS format, interleave 4:1</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
const byte kSonyFmtByteProDos = 0x24;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>Unformatted sectors</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
const byte kInvalidFmtByte = 0x96;
|
2016-07-27 18:03:32 +01:00
|
|
|
|
/// <summary>Defined by LisaEm</summary>
|
|
|
|
|
|
const byte kFmtNotStandard = 0x93;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Internal variables
|
|
|
|
|
|
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>Start of data sectors in disk image, should be 0x58</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
UInt32 dataOffset;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>Start of tags in disk image, after data sectors</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
UInt32 tagOffset;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>Bytes per tag, should be 12</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
UInt32 bptag;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>Header of opened image</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
DC42Header header;
|
2015-12-06 07:37:20 +00:00
|
|
|
|
/// <summary>Disk image file</summary>
|
2014-04-15 21:04:04 +00:00
|
|
|
|
string dc42ImagePath;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2015-10-05 19:45:07 +01:00
|
|
|
|
public DiskCopy42()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2014-06-07 17:32:14 +01:00
|
|
|
|
Name = "Apple DiskCopy 4.2";
|
2014-04-15 21:04:04 +00:00
|
|
|
|
PluginUUID = new Guid("0240B7B1-E959-4CDC-B0BD-386D6E467B88");
|
2014-08-28 19:29:18 +01:00
|
|
|
|
ImageInfo = new ImageInfo();
|
|
|
|
|
|
ImageInfo.readableSectorTags = new List<SectorTagType>();
|
2016-01-16 03:54:55 +00:00
|
|
|
|
ImageInfo.readableMediaTags = new List<MediaTagType>();
|
2014-08-28 19:29:18 +01:00
|
|
|
|
ImageInfo.imageHasPartitions = false;
|
|
|
|
|
|
ImageInfo.imageHasSessions = false;
|
|
|
|
|
|
ImageInfo.imageVersion = "4.2";
|
|
|
|
|
|
ImageInfo.imageApplication = "Apple DiskCopy";
|
|
|
|
|
|
ImageInfo.imageApplicationVersion = "4.2";
|
|
|
|
|
|
ImageInfo.imageCreator = null;
|
|
|
|
|
|
ImageInfo.imageComments = null;
|
2016-01-16 03:54:55 +00:00
|
|
|
|
ImageInfo.mediaManufacturer = null;
|
|
|
|
|
|
ImageInfo.mediaModel = null;
|
|
|
|
|
|
ImageInfo.mediaSerialNumber = null;
|
|
|
|
|
|
ImageInfo.mediaBarcode = null;
|
|
|
|
|
|
ImageInfo.mediaPartNumber = null;
|
|
|
|
|
|
ImageInfo.mediaSequence = 0;
|
|
|
|
|
|
ImageInfo.lastMediaSequence = 0;
|
2014-08-28 19:29:18 +01:00
|
|
|
|
ImageInfo.driveManufacturer = null;
|
|
|
|
|
|
ImageInfo.driveModel = null;
|
|
|
|
|
|
ImageInfo.driveSerialNumber = null;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool IdentifyImage(string imagePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
FileStream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
byte[] buffer = new byte[0x58];
|
|
|
|
|
|
byte[] pString = new byte[64];
|
|
|
|
|
|
stream.Read(buffer, 0, 0x58);
|
2014-07-03 18:31:27 +01:00
|
|
|
|
stream.Close();
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
// Incorrect pascal string length, not DC42
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(buffer[0] > 63)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
DC42Header tmp_header = new DC42Header();
|
|
|
|
|
|
|
|
|
|
|
|
Array.Copy(buffer, 0, pString, 0, 64);
|
2014-04-17 01:13:48 +00:00
|
|
|
|
|
|
|
|
|
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
|
|
|
|
|
|
2014-04-15 21:04:04 +00:00
|
|
|
|
tmp_header.diskName = StringHandlers.PascalToString(pString);
|
|
|
|
|
|
tmp_header.dataSize = BigEndianBitConverter.ToUInt32(buffer, 0x40);
|
|
|
|
|
|
tmp_header.tagSize = BigEndianBitConverter.ToUInt32(buffer, 0x44);
|
|
|
|
|
|
tmp_header.dataChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x48);
|
|
|
|
|
|
tmp_header.tagChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x4C);
|
|
|
|
|
|
tmp_header.format = buffer[0x50];
|
|
|
|
|
|
tmp_header.fmtByte = buffer[0x51];
|
|
|
|
|
|
tmp_header.valid = buffer[0x52];
|
2014-04-17 01:13:48 +00:00
|
|
|
|
tmp_header.reserved = buffer[0x53];
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "tmp_header.diskName = \"{0}\"", tmp_header.diskName);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "tmp_header.dataSize = {0} bytes", tmp_header.dataSize);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "tmp_header.tagSize = {0} bytes", tmp_header.tagSize);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "tmp_header.dataChecksum = 0x{0:X8}", tmp_header.dataChecksum);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "tmp_header.tagChecksum = 0x{0:X8}", tmp_header.tagChecksum);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "tmp_header.format = 0x{0:X2}", tmp_header.format);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "tmp_header.fmtByte = 0x{0:X2}", tmp_header.fmtByte);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "tmp_header.valid = {0}", tmp_header.valid);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "tmp_header.reserved = {0}", tmp_header.reserved);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(tmp_header.valid != 1 || tmp_header.reserved != 0)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2014-04-17 01:13:48 +00:00
|
|
|
|
FileInfo fi = new FileInfo(imagePath);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(tmp_header.dataSize + tmp_header.tagSize + 0x54 != fi.Length && tmp_header.format != kSigmaFormatTwiggy)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(tmp_header.format != kSonyFormat400K && tmp_header.format != kSonyFormat800K && tmp_header.format != kSonyFormat720K &&
|
2016-07-27 18:03:32 +01:00
|
|
|
|
tmp_header.format != kSonyFormat1440K && tmp_header.format != kSonyFormat1680K && tmp_header.format != kSigmaFormatTwiggy &&
|
|
|
|
|
|
tmp_header.format != kNotStandardFormat)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.format = 0x{0:X2} value", tmp_header.format);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(tmp_header.fmtByte != kSonyFmtByte400K && tmp_header.fmtByte != kSonyFmtByte800K && tmp_header.fmtByte != kSonyFmtByte800KIncorrect &&
|
2016-07-27 18:03:32 +01:00
|
|
|
|
tmp_header.fmtByte != kSonyFmtByteProDos && tmp_header.fmtByte != kInvalidFmtByte && tmp_header.fmtByte != kSigmaFmtByteTwiggy &&
|
|
|
|
|
|
tmp_header.fmtByte != kFmtNotStandard)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.fmtByte = 0x{0:X2} value", tmp_header.fmtByte);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(tmp_header.fmtByte == kInvalidFmtByte)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Image says it's unformatted");
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-12-05 17:21:47 +00:00
|
|
|
|
ImageInfo.xmlMediaType = XmlMediaType.BlockMedia;
|
|
|
|
|
|
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool OpenImage(string imagePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
FileStream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
byte[] buffer = new byte[0x58];
|
|
|
|
|
|
byte[] pString = new byte[64];
|
|
|
|
|
|
stream.Read(buffer, 0, 0x58);
|
2014-07-03 18:31:27 +01:00
|
|
|
|
stream.Close();
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
// Incorrect pascal string length, not DC42
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(buffer[0] > 63)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
header = new DC42Header();
|
2014-04-17 01:13:48 +00:00
|
|
|
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
Array.Copy(buffer, 0, pString, 0, 64);
|
|
|
|
|
|
header.diskName = StringHandlers.PascalToString(pString);
|
|
|
|
|
|
header.dataSize = BigEndianBitConverter.ToUInt32(buffer, 0x40);
|
|
|
|
|
|
header.tagSize = BigEndianBitConverter.ToUInt32(buffer, 0x44);
|
|
|
|
|
|
header.dataChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x48);
|
|
|
|
|
|
header.tagChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x4C);
|
|
|
|
|
|
header.format = buffer[0x50];
|
|
|
|
|
|
header.fmtByte = buffer[0x51];
|
|
|
|
|
|
header.valid = buffer[0x52];
|
2014-04-17 01:13:48 +00:00
|
|
|
|
header.reserved = buffer[0x53];
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "header.diskName = \"{0}\"", header.diskName);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "header.dataSize = {0} bytes", header.dataSize);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "header.tagSize = {0} bytes", header.tagSize);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "header.dataChecksum = 0x{0:X8}", header.dataChecksum);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "header.tagChecksum = 0x{0:X8}", header.tagChecksum);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "header.format = 0x{0:X2}", header.format);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "header.fmtByte = 0x{0:X2}", header.fmtByte);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "header.valid = {0}", header.valid);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "header.reserved = {0}", header.reserved);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(header.valid != 1 || header.reserved != 0)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2014-04-17 01:13:48 +00:00
|
|
|
|
FileInfo fi = new FileInfo(imagePath);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(header.dataSize + header.tagSize + 0x54 != fi.Length && header.format != kSigmaFormatTwiggy)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(header.format != kSonyFormat400K && header.format != kSonyFormat800K && header.format != kSonyFormat720K &&
|
2016-07-27 18:03:32 +01:00
|
|
|
|
header.format != kSonyFormat1440K && header.format != kSonyFormat1680K && header.format != kSigmaFormatTwiggy && header.format != kNotStandardFormat)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Unknown header.format = 0x{0:X2} value", header.format);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(header.fmtByte != kSonyFmtByte400K && header.fmtByte != kSonyFmtByte800K && header.fmtByte != kSonyFmtByte800KIncorrect &&
|
2016-07-27 18:03:32 +01:00
|
|
|
|
header.fmtByte != kSonyFmtByteProDos && header.fmtByte != kInvalidFmtByte && header.fmtByte != kSigmaFmtByteTwiggy && header.fmtByte != kFmtNotStandard)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.fmtByte = 0x{0:X2} value", header.fmtByte);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(header.fmtByte == kInvalidFmtByte)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Image says it's unformatted");
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dataOffset = 0x54;
|
|
|
|
|
|
tagOffset = header.tagSize != 0 ? 0x54 + header.dataSize : 0;
|
2014-08-28 19:29:18 +01:00
|
|
|
|
ImageInfo.sectorSize = 512;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
bptag = (uint)(header.tagSize != 0 ? 12 : 0);
|
|
|
|
|
|
dc42ImagePath = imagePath;
|
|
|
|
|
|
|
2014-08-28 19:29:18 +01:00
|
|
|
|
ImageInfo.sectors = header.dataSize / 512;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(header.tagSize != 0)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2016-07-27 18:03:32 +01:00
|
|
|
|
bptag = (uint)(header.tagSize / ImageInfo.sectors);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "bptag = {0} bytes", bptag);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2016-07-27 18:03:32 +01:00
|
|
|
|
if(bptag != 12 && bptag != 20 && bptag != 24)
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Unknown tag size");
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2014-08-24 17:46:29 +01:00
|
|
|
|
|
2014-08-28 19:29:18 +01:00
|
|
|
|
ImageInfo.readableSectorTags.Add(SectorTagType.AppleSectorTag);
|
2014-08-24 17:46:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-28 19:29:18 +01:00
|
|
|
|
ImageInfo.imageSize = ImageInfo.sectors * ImageInfo.sectorSize + ImageInfo.sectors * bptag;
|
|
|
|
|
|
ImageInfo.imageCreationTime = fi.CreationTimeUtc;
|
|
|
|
|
|
ImageInfo.imageLastModificationTime = fi.LastWriteTimeUtc;
|
|
|
|
|
|
ImageInfo.imageName = header.diskName;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
switch(header.format)
|
2014-08-24 17:46:29 +01:00
|
|
|
|
{
|
|
|
|
|
|
case kSonyFormat400K:
|
2016-01-16 03:54:55 +00:00
|
|
|
|
ImageInfo.mediaType = MediaType.AppleSonySS;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case kSonyFormat800K:
|
2016-01-16 03:54:55 +00:00
|
|
|
|
ImageInfo.mediaType = MediaType.AppleSonyDS;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case kSonyFormat720K:
|
2016-01-16 03:54:55 +00:00
|
|
|
|
ImageInfo.mediaType = MediaType.DOS_35_DS_DD_9;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case kSonyFormat1440K:
|
2016-01-16 03:54:55 +00:00
|
|
|
|
ImageInfo.mediaType = MediaType.DOS_35_HD;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case kSonyFormat1680K:
|
2016-01-16 03:54:55 +00:00
|
|
|
|
ImageInfo.mediaType = MediaType.DMF;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case kSigmaFormatTwiggy:
|
2016-01-16 03:54:55 +00:00
|
|
|
|
ImageInfo.mediaType = MediaType.AppleFileWare;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
break;
|
2016-07-27 18:03:32 +01:00
|
|
|
|
case kNotStandardFormat:
|
|
|
|
|
|
switch(ImageInfo.sectors)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 9728:
|
|
|
|
|
|
ImageInfo.mediaType = MediaType.AppleProfile;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 19456:
|
|
|
|
|
|
ImageInfo.mediaType = MediaType.AppleProfile;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 38912:
|
|
|
|
|
|
ImageInfo.mediaType = MediaType.AppleWidget;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 39040:
|
|
|
|
|
|
ImageInfo.mediaType = MediaType.AppleHD20;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
ImageInfo.mediaType = MediaType.Unknown;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
default:
|
2016-01-16 03:54:55 +00:00
|
|
|
|
ImageInfo.mediaType = MediaType.Unknown;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
break;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-25 05:00:25 +01:00
|
|
|
|
public override bool? VerifySector(UInt64 sectorAddress)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
|
|
|
|
|
|
{
|
|
|
|
|
|
FailingLBAs = new List<UInt64>();
|
|
|
|
|
|
UnknownLBAs = new List<UInt64>();
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
for(UInt64 i = sectorAddress; i < sectorAddress + length; i++)
|
2014-08-25 05:00:25 +01:00
|
|
|
|
UnknownLBAs.Add(i);
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
|
|
|
|
|
|
{
|
|
|
|
|
|
FailingLBAs = new List<UInt64>();
|
|
|
|
|
|
UnknownLBAs = new List<UInt64>();
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
for(UInt64 i = sectorAddress; i < sectorAddress + length; i++)
|
2014-08-25 05:00:25 +01:00
|
|
|
|
UnknownLBAs.Add(i);
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
|
public override bool? VerifyMediaImage()
|
2014-08-25 05:00:25 +01:00
|
|
|
|
{
|
|
|
|
|
|
byte[] data = new byte[header.dataSize];
|
|
|
|
|
|
byte[] tags = new byte[header.tagSize];
|
|
|
|
|
|
UInt32 dataChk;
|
|
|
|
|
|
UInt32 tagsChk = 0;
|
|
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Reading data");
|
2014-08-25 05:00:25 +01:00
|
|
|
|
FileStream datastream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
|
|
|
|
|
|
datastream.Seek((long)(dataOffset), SeekOrigin.Begin);
|
|
|
|
|
|
datastream.Read(data, 0, (int)header.dataSize);
|
|
|
|
|
|
datastream.Close();
|
|
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Calculating data checksum");
|
2014-08-25 05:00:25 +01:00
|
|
|
|
dataChk = DC42CheckSum(data);
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Calculated data checksum = 0x{0:X8}", dataChk);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Stored data checksum = 0x{0:X8}", header.dataChecksum);
|
2014-08-25 05:00:25 +01:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(header.tagSize > 0)
|
2014-08-25 05:00:25 +01:00
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Reading tags");
|
2014-08-25 05:00:25 +01:00
|
|
|
|
FileStream tagstream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
|
|
|
|
|
|
tagstream.Seek((long)(tagOffset), SeekOrigin.Begin);
|
|
|
|
|
|
tagstream.Read(tags, 0, (int)header.tagSize);
|
|
|
|
|
|
tagstream.Close();
|
|
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Calculating tag checksum");
|
2015-03-05 18:52:36 +00:00
|
|
|
|
tagsChk = DC42CheckSum(tags);
|
2015-10-18 22:04:03 +01:00
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Calculated tag checksum = 0x{0:X8}", tagsChk);
|
|
|
|
|
|
DicConsole.DebugWriteLine("DC42 plugin", "Stored tag checksum = 0x{0:X8}", header.tagChecksum);
|
2014-08-25 05:00:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dataChk == header.dataChecksum && tagsChk == header.tagChecksum;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-04-15 21:04:04 +00:00
|
|
|
|
public override bool ImageHasPartitions()
|
|
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.imageHasPartitions;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override UInt64 GetImageSize()
|
|
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.imageSize;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override UInt64 GetSectors()
|
|
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.sectors;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override UInt32 GetSectorSize()
|
|
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.sectorSize;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSector(UInt64 sectorAddress)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ReadSectors(sectorAddress, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ReadSectorsTag(sectorAddress, 1, tag);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
|
|
|
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(sectorAddress > ImageInfo.sectors - 1)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(sectorAddress + length > ImageInfo.sectors)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
|
|
|
|
|
|
|
2014-08-28 19:29:18 +01:00
|
|
|
|
byte[] buffer = new byte[length * ImageInfo.sectorSize];
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
|
|
|
|
|
FileStream stream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
|
|
|
|
|
|
|
2014-08-28 19:29:18 +01:00
|
|
|
|
stream.Seek((long)(dataOffset + sectorAddress * ImageInfo.sectorSize), SeekOrigin.Begin);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2014-08-28 19:29:18 +01:00
|
|
|
|
stream.Read(buffer, 0, (int)(length * ImageInfo.sectorSize));
|
2014-04-15 21:04:04 +00:00
|
|
|
|
|
2014-07-03 18:31:27 +01:00
|
|
|
|
stream.Close();
|
|
|
|
|
|
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return buffer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
|
|
|
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(tag != SectorTagType.AppleSectorTag)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
throw new FeatureUnsupportedImageException(String.Format("Tag {0} not supported by image format", tag));
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(header.tagSize == 0)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
throw new FeatureNotPresentImageException("Disk image does not have tags");
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(sectorAddress > ImageInfo.sectors - 1)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(sectorAddress + length > ImageInfo.sectors)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
|
|
|
|
|
|
|
|
|
|
|
|
byte[] buffer = new byte[length * bptag];
|
|
|
|
|
|
|
|
|
|
|
|
FileStream stream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
|
|
|
|
|
|
|
|
|
|
|
|
stream.Seek((long)(tagOffset + sectorAddress * bptag), SeekOrigin.Begin);
|
|
|
|
|
|
|
|
|
|
|
|
stream.Read(buffer, 0, (int)(length * bptag));
|
|
|
|
|
|
|
2014-07-03 18:31:27 +01:00
|
|
|
|
stream.Close();
|
|
|
|
|
|
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return buffer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorLong(UInt64 sectorAddress)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ReadSectorsLong(sectorAddress, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
|
|
|
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(sectorAddress > ImageInfo.sectors - 1)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(sectorAddress + length > ImageInfo.sectors)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
|
|
|
|
|
|
|
|
|
|
|
|
byte[] data = ReadSectors(sectorAddress, length);
|
|
|
|
|
|
byte[] tags = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSectorTag);
|
|
|
|
|
|
byte[] buffer = new byte[data.Length + tags.Length];
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
for(uint i = 0; i < length; i++)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
Array.Copy(data, i * (ImageInfo.sectorSize), buffer, i * (ImageInfo.sectorSize + bptag), ImageInfo.sectorSize);
|
|
|
|
|
|
Array.Copy(tags, i * (bptag), buffer, i * (ImageInfo.sectorSize + bptag) + ImageInfo.sectorSize, bptag);
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetImageFormat()
|
|
|
|
|
|
{
|
2014-04-15 21:04:04 +00:00
|
|
|
|
return "Apple DiskCopy 4.2";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetImageVersion()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.imageVersion;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetImageApplication()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.imageApplication;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetImageApplicationVersion()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.imageApplicationVersion;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override DateTime GetImageCreationTime()
|
|
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.imageCreationTime;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override DateTime GetImageLastModificationTime()
|
|
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.imageLastModificationTime;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetImageName()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.imageName;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
|
public override MediaType GetMediaType()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2016-01-16 03:54:55 +00:00
|
|
|
|
return ImageInfo.mediaType;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region Unsupported features
|
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
|
public override byte[] ReadDiskTag(MediaTagType tag)
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string GetImageCreator()
|
|
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.imageCreator;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetImageComments()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.imageComments;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetMediaManufacturer()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2016-01-16 03:54:55 +00:00
|
|
|
|
return ImageInfo.mediaManufacturer;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetMediaModel()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2016-01-16 03:54:55 +00:00
|
|
|
|
return ImageInfo.mediaModel;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetMediaSerialNumber()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2016-01-16 03:54:55 +00:00
|
|
|
|
return ImageInfo.mediaSerialNumber;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetMediaBarcode()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2016-01-16 03:54:55 +00:00
|
|
|
|
return ImageInfo.mediaBarcode;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override string GetMediaPartNumber()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2016-01-16 03:54:55 +00:00
|
|
|
|
return ImageInfo.mediaPartNumber;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override int GetMediaSequence()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2016-01-16 03:54:55 +00:00
|
|
|
|
return ImageInfo.mediaSequence;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
public override int GetLastDiskSequence()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
2016-01-16 03:54:55 +00:00
|
|
|
|
return ImageInfo.lastMediaSequence;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string GetDriveManufacturer()
|
|
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.driveManufacturer;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string GetDriveModel()
|
|
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.driveModel;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string GetDriveSerialNumber()
|
|
|
|
|
|
{
|
2014-08-28 19:29:18 +01:00
|
|
|
|
return ImageInfo.driveSerialNumber;
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-10-05 19:45:07 +01:00
|
|
|
|
public override List<CommonTypes.Partition> GetPartitions()
|
2014-04-15 21:04:04 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<Track> GetTracks()
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<Track> GetSessionTracks(Session session)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<Track> GetSessionTracks(UInt16 session)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<Session> GetSessions()
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion Unsupported features
|
2014-08-25 05:00:25 +01:00
|
|
|
|
|
|
|
|
|
|
#region Private methods
|
|
|
|
|
|
|
|
|
|
|
|
private static UInt32 DC42CheckSum(byte[] buffer)
|
2016-04-19 02:11:47 +01:00
|
|
|
|
{
|
2014-08-25 05:00:25 +01:00
|
|
|
|
UInt32 dc42chk = 0;
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if((buffer.Length & 0x01) == 0x01)
|
2014-08-25 05:00:25 +01:00
|
|
|
|
return 0xFFFFFFFF;
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
for(UInt32 i = 0; i < buffer.Length; i += 2)
|
2014-08-25 05:00:25 +01:00
|
|
|
|
{
|
|
|
|
|
|
dc42chk += (uint)(buffer[i] << 8);
|
|
|
|
|
|
dc42chk += buffer[i + 1];
|
|
|
|
|
|
dc42chk = (dc42chk >> 1) | (dc42chk << 31);
|
|
|
|
|
|
}
|
|
|
|
|
|
return dc42chk;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2014-04-15 21:04:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|