2018-07-23 23:25:43 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : Identify.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Disk image plugins.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Identifies Apple DiskCopy 4.2 disk images.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2020-12-31 23:08:23 +00:00
|
|
|
|
// Copyright © 2011-2021 Natalia Portillo
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.Console;
|
2020-07-20 15:43:52 +01:00
|
|
|
|
using Aaru.Helpers;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
using Claunia.Encoding;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
|
namespace Aaru.DiscImages
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2020-07-22 13:20:25 +01:00
|
|
|
|
public sealed partial class DiskCopy42
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2018-07-23 23:25:43 +01:00
|
|
|
|
public bool Identify(IFilter imageFilter)
|
|
|
|
|
|
{
|
|
|
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
byte[] buffer = new byte[0x58];
|
|
|
|
|
|
byte[] pString = new byte[64];
|
|
|
|
|
|
stream.Read(buffer, 0, 0x58);
|
|
|
|
|
|
|
|
|
|
|
|
// Incorrect pascal string length, not DC42
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(buffer[0] > 63)
|
|
|
|
|
|
return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2020-11-11 04:19:18 +00:00
|
|
|
|
var tmpHeader = new Header();
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
Array.Copy(buffer, 0, pString, 0, 64);
|
|
|
|
|
|
|
|
|
|
|
|
tmpHeader.DiskName = StringHandlers.PascalToString(pString, Encoding.GetEncoding("macintosh"));
|
|
|
|
|
|
tmpHeader.DataSize = BigEndianBitConverter.ToUInt32(buffer, 0x40);
|
|
|
|
|
|
tmpHeader.TagSize = BigEndianBitConverter.ToUInt32(buffer, 0x44);
|
|
|
|
|
|
tmpHeader.DataChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x48);
|
|
|
|
|
|
tmpHeader.TagChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x4C);
|
|
|
|
|
|
tmpHeader.Format = buffer[0x50];
|
|
|
|
|
|
tmpHeader.FmtByte = buffer[0x51];
|
|
|
|
|
|
tmpHeader.Valid = buffer[0x52];
|
|
|
|
|
|
tmpHeader.Reserved = buffer[0x53];
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "tmp_header.diskName = \"{0}\"", tmpHeader.DiskName);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "tmp_header.dataSize = {0} bytes", tmpHeader.DataSize);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "tmp_header.tagSize = {0} bytes", tmpHeader.TagSize);
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "tmp_header.dataChecksum = 0x{0:X8}", tmpHeader.DataChecksum);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "tmp_header.tagChecksum = 0x{0:X8}", tmpHeader.TagChecksum);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "tmp_header.format = 0x{0:X2}", tmpHeader.Format);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "tmp_header.fmtByte = 0x{0:X2}", tmpHeader.FmtByte);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "tmp_header.valid = {0}", tmpHeader.Valid);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "tmp_header.reserved = {0}", tmpHeader.Reserved);
|
|
|
|
|
|
|
|
|
|
|
|
if(tmpHeader.Valid != 1 ||
|
|
|
|
|
|
tmpHeader.Reserved != 0)
|
|
|
|
|
|
return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
// Some versions seem to incorrectly create little endian fields
|
|
|
|
|
|
if(tmpHeader.DataSize + tmpHeader.TagSize + 0x54 != imageFilter.GetDataForkLength() &&
|
|
|
|
|
|
tmpHeader.Format != kSigmaFormatTwiggy)
|
|
|
|
|
|
{
|
|
|
|
|
|
tmpHeader.DataSize = BitConverter.ToUInt32(buffer, 0x40);
|
|
|
|
|
|
tmpHeader.TagSize = BitConverter.ToUInt32(buffer, 0x44);
|
|
|
|
|
|
tmpHeader.DataChecksum = BitConverter.ToUInt32(buffer, 0x48);
|
|
|
|
|
|
tmpHeader.TagChecksum = BitConverter.ToUInt32(buffer, 0x4C);
|
|
|
|
|
|
|
|
|
|
|
|
if(tmpHeader.DataSize + tmpHeader.TagSize + 0x54 != imageFilter.GetDataForkLength() &&
|
2020-02-29 18:03:35 +00:00
|
|
|
|
tmpHeader.Format != kSigmaFormatTwiggy)
|
|
|
|
|
|
return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(tmpHeader.Format != kSonyFormat400K &&
|
|
|
|
|
|
tmpHeader.Format != kSonyFormat800K &&
|
|
|
|
|
|
tmpHeader.Format != kSonyFormat720K &&
|
|
|
|
|
|
tmpHeader.Format != kSonyFormat1440K &&
|
|
|
|
|
|
tmpHeader.Format != kSonyFormat1680K &&
|
|
|
|
|
|
tmpHeader.Format != kSigmaFormatTwiggy &&
|
2018-07-23 23:25:43 +01:00
|
|
|
|
tmpHeader.Format != kNotStandardFormat)
|
|
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.format = 0x{0:X2} value",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
tmpHeader.Format);
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(tmpHeader.FmtByte != kSonyFmtByte400K &&
|
|
|
|
|
|
tmpHeader.FmtByte != kSonyFmtByte800K &&
|
|
|
|
|
|
tmpHeader.FmtByte != kSonyFmtByte800KIncorrect &&
|
|
|
|
|
|
tmpHeader.FmtByte != kSonyFmtByteProDos &&
|
|
|
|
|
|
tmpHeader.FmtByte != kInvalidFmtByte &&
|
|
|
|
|
|
tmpHeader.FmtByte != kSigmaFmtByteTwiggy &&
|
|
|
|
|
|
tmpHeader.FmtByte != kFmtNotStandard &&
|
|
|
|
|
|
tmpHeader.FmtByte != kMacOSXFmtByte)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.fmtByte = 0x{0:X2} value",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
tmpHeader.FmtByte);
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(tmpHeader.FmtByte != kInvalidFmtByte)
|
|
|
|
|
|
return true;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("DC42 plugin", "Image says it's unformatted");
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|