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 Digital Research's DISKCOPY 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-12-19 10:45:18 +00:00
|
|
|
|
// Copyright © 2011-2025 Natalia Portillo
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.Helpers;
|
2025-08-17 05:50:25 +01:00
|
|
|
|
using Aaru.Logging;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2023-10-06 01:16:28 +01:00
|
|
|
|
namespace Aaru.Images;
|
2022-11-15 15:58:43 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public sealed partial class DriDiskCopy
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2023-10-03 23:34:59 +01:00
|
|
|
|
#region IWritableImage Members
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool Identify(IFilter imageFilter)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if((stream.Length - Marshal.SizeOf<Footer>()) % 512 != 0) return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2025-11-24 11:27:56 +00:00
|
|
|
|
var buffer = new byte[Marshal.SizeOf<Footer>()];
|
2022-03-06 13:29:38 +00:00
|
|
|
|
stream.Seek(-buffer.Length, SeekOrigin.End);
|
2022-11-14 09:43:16 +00:00
|
|
|
|
stream.EnsureRead(buffer, 0, buffer.Length);
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Footer tmpFooter = Marshal.ByteArrayToStructureLittleEndian<Footer>(buffer);
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
string sig = StringHandlers.CToString(tmpFooter.signature);
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2025-08-17 06:11:22 +01:00
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.signature = \"{0}\"", sig);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.five = {0}", tmpFooter.bpb.five);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2025-08-17 06:11:22 +01:00
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb._driveCode = {0}", tmpFooter.bpb._driveCode);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2025-08-17 06:11:22 +01:00
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.unknown = {0}", tmpFooter.bpb.unknown);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2025-08-17 06:11:22 +01:00
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.cylinders = {0}", tmpFooter.bpb.cylinders);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2025-08-17 06:11:22 +01:00
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.unknown2 = {0}", tmpFooter.bpb.unknown2);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.bps = {0}", tmpFooter.bpb.bps);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.spc = {0}", tmpFooter.bpb.spc);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.rsectors = {0}", tmpFooter.bpb.rsectors);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.fats_no = {0}", tmpFooter.bpb.fats_no);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.sectors = {0}", tmpFooter.bpb.sectors);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2025-11-24 11:27:56 +00:00
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.media_descriptor = {0}", tmpFooter.bpb.media_descriptor);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2025-08-17 06:11:22 +01:00
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.spfat = {0}", tmpFooter.bpb.spfat);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.sptrack = {0}", tmpFooter.bpb.sptrack);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.heads = {0}", tmpFooter.bpb.heads);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.hsectors = {0}", tmpFooter.bpb.hsectors);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.drive_no = {0}", tmpFooter.bpb.drive_no);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.unknown3 = {0}", tmpFooter.bpb.unknown3);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.unknown4 = {0}", tmpFooter.bpb.unknown4);
|
|
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "tmp_footer.bpb.sptrack2 = {0}", tmpFooter.bpb.sptrack2);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2025-08-17 06:11:22 +01:00
|
|
|
|
AaruLogging.Debug(MODULE_NAME,
|
2025-11-24 11:27:56 +00:00
|
|
|
|
"ArrayHelpers.ArrayIsNullOrEmpty(tmp_footer.bpb.unknown5) = {0}",
|
|
|
|
|
|
ArrayHelpers.ArrayIsNullOrEmpty(tmpFooter.bpb.unknown5));
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2025-11-24 11:27:56 +00:00
|
|
|
|
Regex regexSignature = DriRegex();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Match matchSignature = regexSignature.Match(sig);
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2025-08-17 06:11:22 +01:00
|
|
|
|
AaruLogging.Debug(MODULE_NAME, "MatchSignature.Success? = {0}", matchSignature.Success);
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(!matchSignature.Success) return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(tmpFooter.bpb.sptrack * tmpFooter.bpb.cylinders * tmpFooter.bpb.heads != tmpFooter.bpb.sectors) return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2023-10-03 23:34:59 +01:00
|
|
|
|
return tmpFooter.bpb.sectors * tmpFooter.bpb.bps + Marshal.SizeOf<Footer>() == stream.Length;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
2023-10-03 23:34:59 +01:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|