2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-07-28 18:13:49 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Compare.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : Verbs.
|
|
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Implements the 'compare' verb.
|
|
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program 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 General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-05-19 20:28:49 +01:00
|
|
|
// Copyright © 2011-2017 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
// ****************************************************************************/
|
2014-07-03 18:34:43 +01:00
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using DiscImageChef.ImagePlugins;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Collections.Generic;
|
2015-10-18 22:04:03 +01:00
|
|
|
using DiscImageChef.Console;
|
2016-09-05 17:37:31 +01:00
|
|
|
using DiscImageChef.Filters;
|
2017-05-27 15:17:20 +01:00
|
|
|
using DiscImageChef.Core;
|
2014-06-16 01:45:04 +01:00
|
|
|
|
|
|
|
|
namespace DiscImageChef.Commands
|
|
|
|
|
{
|
|
|
|
|
public static class Compare
|
|
|
|
|
{
|
2016-04-08 01:13:42 +01:00
|
|
|
public static void doCompare(CompareOptions options)
|
2014-06-16 01:45:04 +01:00
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("Compare command", "--debug={0}", options.Debug);
|
|
|
|
|
DicConsole.DebugWriteLine("Compare command", "--verbose={0}", options.Verbose);
|
|
|
|
|
DicConsole.DebugWriteLine("Compare command", "--input1={0}", options.InputFile1);
|
|
|
|
|
DicConsole.DebugWriteLine("Compare command", "--input2={0}", options.InputFile2);
|
2014-07-03 18:34:43 +01:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
FiltersList filtersList = new FiltersList();
|
|
|
|
|
Filter inputFilter1 = filtersList.GetFilter(options.InputFile1);
|
2016-09-13 20:47:07 +01:00
|
|
|
filtersList = new FiltersList();
|
2016-09-05 17:37:31 +01:00
|
|
|
Filter inputFilter2 = filtersList.GetFilter(options.InputFile2);
|
|
|
|
|
|
|
|
|
|
if(inputFilter1 == null)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
DicConsole.ErrorWriteLine("Cannot open input file 1");
|
2014-07-03 18:34:43 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
if(inputFilter2 == null)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
DicConsole.ErrorWriteLine("Cannot open input file 2");
|
2014-07-03 18:34:43 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
ImagePlugin input1Format = ImageFormat.Detect(inputFilter1);
|
|
|
|
|
ImagePlugin input2Format = ImageFormat.Detect(inputFilter2);
|
2014-07-03 18:34:43 +01:00
|
|
|
|
|
|
|
|
if(input1Format == null)
|
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.ErrorWriteLine("Input file 1 format not identified, not proceeding with comparison.");
|
2014-07-03 18:34:43 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
if(options.Verbose)
|
|
|
|
|
DicConsole.VerboseWriteLine("Input file 1 format identified by {0} ({1}).", input1Format.Name, input1Format.PluginUUID);
|
2014-07-03 18:34:43 +01:00
|
|
|
else
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.WriteLine("Input file 1 format identified by {0}.", input1Format.Name);
|
2014-07-03 18:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(input2Format == null)
|
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.ErrorWriteLine("Input file 2 format not identified, not proceeding with comparison.");
|
2014-07-03 18:34:43 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
if(options.Verbose)
|
|
|
|
|
DicConsole.VerboseWriteLine("Input file 2 format identified by {0} ({1}).", input2Format.Name, input2Format.PluginUUID);
|
2014-07-03 18:34:43 +01:00
|
|
|
else
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.WriteLine("Input file 2 format identified by {0}.", input2Format.Name);
|
2014-07-03 18:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
input1Format.OpenImage(inputFilter1);
|
|
|
|
|
input2Format.OpenImage(inputFilter2);
|
2014-07-03 18:34:43 +01:00
|
|
|
|
* commandline:
* DiscImageChef.Settings/Settings.cs:
* DiscImageChef.Settings/docs/README.txt:
* DiscImageChef.Settings/packages.config:
* DiscImageChef.Settings/docs/LICENSE.txt:
* DiscImageChef.Settings/docs/ChangeLog.txt:
* DiscImageChef.Settings/docs/mono/index.xml:
* DiscImageChef.Settings/docs/html/index.html:
* DiscImageChef.Settings/Properties/AssemblyInfo.cs:
* DiscImageChef.Settings/DiscImageChef.Settings.csproj:
* DiscImageChef.Settings/docs/mono/ns-Claunia.PropertyList.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/UID.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/UID.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSSet.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/index.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSSet.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSDate.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSData.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSDate.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSData.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSArray.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSNumber.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSString.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSObject.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSArray.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSNumber.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSString.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSObject.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSDictionary.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSDictionary.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/PropertyListParser.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/PropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/XmlPropertyListParser.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/XmlPropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/ASCIIPropertyListParser.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/ASCIIPropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/BinaryPropertyListParser.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/BinaryPropertyListWriter.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/BinaryPropertyListWriter.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/BinaryPropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/PropertyListFormatException.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/PropertyListFormatException.html:
Added supports for settings
* DiscImageChef/Commands/Configure.cs:
Added support for settings.
* DiscImageChef/Core/Statistics.cs:
* DiscImageChef/Commands/Verify.cs:
* DiscImageChef/Commands/Entropy.cs:
* DiscImageChef/Commands/Formats.cs:
* DiscImageChef/Commands/PrintHex.cs:
* DiscImageChef/Commands/MediaInfo.cs:
* DiscImageChef/Commands/Statistics.cs:
Added statistics.
* DiscImageChef.Decoders/SCSI/Inquiry.cs:
Corrected bug on inquiry decoding.
* DiscImageChef.Decoders/SCSI/Modes.cs:
Corrected bug on decoding mode page 2Ah without write
performance descriptors.
Corrected bug when there is a vendor page 0 in mode sense
decoding.
* DiscImageChef.Devices/Device/Constructor.cs:
Corrected detecting USB or FireWire attached CD/DVD/BD and
tape drives.
Try ATA identify on USB or FireWire that don't have SCSI
INQUIRY.
* DiscImageChef.DiscImages/CDRWin.cs:
Corrected CD-ROM XA vs CD-ROM detection.
* DiscImageChef.Partitions/AppleMap.cs:
Corrected big endian working.
Added debug output.
* DiscImageChef.sln:
Added supports for settings.
* DiscImageChef/Commands/Decode.cs:
* DiscImageChef/Commands/Analyze.cs:
* DiscImageChef/Commands/Compare.cs:
* DiscImageChef/Commands/Checksum.cs:
* DiscImageChef/Commands/Benchmark.cs:
* DiscImageChef/Commands/DeviceInfo.cs:
* DiscImageChef/Commands/CreateSidecar.cs:
Added statistics.
* DiscImageChef/Commands/DeviceReport.cs:
Added statistics.
Correct handling empty inquiry string fields.
Suppose it is not removable, til proved wrong.
Corrected MODE SENSE (6/10) detection and calling order.
If device is MMC type but reports neither mode page 2Ah
neither GET CONFIGURATION, try all CDs (old drives work like
that).
Try reading Lead-In and Lead-Out in Audio CD using Audio READ
CD commands.
Corrected READ LONG information handling, some drives return
2s-complement in 32 bit. Upper 16 bits are ignored.
Added support for DVD raw block (37856 bytes).
Check READ LONG up to 36 times the cooked block size. That
should be enough to detect huge blocked media (like DVD and
BD) without taking ages.
If READ LONG size had to be bruteforced, and debug is
activated, save the result.
* DiscImageChef/Commands/DumpMedia.cs:
Added statistics.
Corrected READ LONG information handling, some drives return
2s-complement in 32 bit. Upper 16 bits are ignored.
Start trying with 64 blocks at a time. Some drives report to
be able to read 255 at a time, but they really don't, they
take a lot longer to read.
* DiscImageChef/Commands/MediaScan.cs:
Added statistics.
Start trying with 64 blocks at a time. Some drives report to
be able to read 255 at a time, but they really don't, they
take a lot longer to read.
* DiscImageChef/DiscImageChef.csproj:
Added support for settings.
Added statistics.
* DiscImageChef/Main.cs:
* DiscImageChef/Options.cs:
Added support for settings.
Added statistics.
2016-02-03 18:58:11 +00:00
|
|
|
Core.Statistics.AddMediaFormat(input1Format.GetImageFormat());
|
|
|
|
|
Core.Statistics.AddMediaFormat(input2Format.GetImageFormat());
|
|
|
|
|
Core.Statistics.AddMedia(input1Format.ImageInfo.mediaType, false);
|
|
|
|
|
Core.Statistics.AddMedia(input2Format.ImageInfo.mediaType, false);
|
2016-09-05 17:37:31 +01:00
|
|
|
Core.Statistics.AddFilter(inputFilter1.Name);
|
|
|
|
|
Core.Statistics.AddFilter(inputFilter2.Name);
|
* commandline:
* DiscImageChef.Settings/Settings.cs:
* DiscImageChef.Settings/docs/README.txt:
* DiscImageChef.Settings/packages.config:
* DiscImageChef.Settings/docs/LICENSE.txt:
* DiscImageChef.Settings/docs/ChangeLog.txt:
* DiscImageChef.Settings/docs/mono/index.xml:
* DiscImageChef.Settings/docs/html/index.html:
* DiscImageChef.Settings/Properties/AssemblyInfo.cs:
* DiscImageChef.Settings/DiscImageChef.Settings.csproj:
* DiscImageChef.Settings/docs/mono/ns-Claunia.PropertyList.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/UID.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/UID.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSSet.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/index.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSSet.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSDate.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSData.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSDate.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSData.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSArray.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSNumber.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSString.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSObject.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSArray.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSNumber.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSString.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSObject.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSDictionary.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSDictionary.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/PropertyListParser.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/PropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/XmlPropertyListParser.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/XmlPropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/ASCIIPropertyListParser.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/ASCIIPropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/BinaryPropertyListParser.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/BinaryPropertyListWriter.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/BinaryPropertyListWriter.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/BinaryPropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/PropertyListFormatException.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/PropertyListFormatException.html:
Added supports for settings
* DiscImageChef/Commands/Configure.cs:
Added support for settings.
* DiscImageChef/Core/Statistics.cs:
* DiscImageChef/Commands/Verify.cs:
* DiscImageChef/Commands/Entropy.cs:
* DiscImageChef/Commands/Formats.cs:
* DiscImageChef/Commands/PrintHex.cs:
* DiscImageChef/Commands/MediaInfo.cs:
* DiscImageChef/Commands/Statistics.cs:
Added statistics.
* DiscImageChef.Decoders/SCSI/Inquiry.cs:
Corrected bug on inquiry decoding.
* DiscImageChef.Decoders/SCSI/Modes.cs:
Corrected bug on decoding mode page 2Ah without write
performance descriptors.
Corrected bug when there is a vendor page 0 in mode sense
decoding.
* DiscImageChef.Devices/Device/Constructor.cs:
Corrected detecting USB or FireWire attached CD/DVD/BD and
tape drives.
Try ATA identify on USB or FireWire that don't have SCSI
INQUIRY.
* DiscImageChef.DiscImages/CDRWin.cs:
Corrected CD-ROM XA vs CD-ROM detection.
* DiscImageChef.Partitions/AppleMap.cs:
Corrected big endian working.
Added debug output.
* DiscImageChef.sln:
Added supports for settings.
* DiscImageChef/Commands/Decode.cs:
* DiscImageChef/Commands/Analyze.cs:
* DiscImageChef/Commands/Compare.cs:
* DiscImageChef/Commands/Checksum.cs:
* DiscImageChef/Commands/Benchmark.cs:
* DiscImageChef/Commands/DeviceInfo.cs:
* DiscImageChef/Commands/CreateSidecar.cs:
Added statistics.
* DiscImageChef/Commands/DeviceReport.cs:
Added statistics.
Correct handling empty inquiry string fields.
Suppose it is not removable, til proved wrong.
Corrected MODE SENSE (6/10) detection and calling order.
If device is MMC type but reports neither mode page 2Ah
neither GET CONFIGURATION, try all CDs (old drives work like
that).
Try reading Lead-In and Lead-Out in Audio CD using Audio READ
CD commands.
Corrected READ LONG information handling, some drives return
2s-complement in 32 bit. Upper 16 bits are ignored.
Added support for DVD raw block (37856 bytes).
Check READ LONG up to 36 times the cooked block size. That
should be enough to detect huge blocked media (like DVD and
BD) without taking ages.
If READ LONG size had to be bruteforced, and debug is
activated, save the result.
* DiscImageChef/Commands/DumpMedia.cs:
Added statistics.
Corrected READ LONG information handling, some drives return
2s-complement in 32 bit. Upper 16 bits are ignored.
Start trying with 64 blocks at a time. Some drives report to
be able to read 255 at a time, but they really don't, they
take a lot longer to read.
* DiscImageChef/Commands/MediaScan.cs:
Added statistics.
Start trying with 64 blocks at a time. Some drives report to
be able to read 255 at a time, but they really don't, they
take a lot longer to read.
* DiscImageChef/DiscImageChef.csproj:
Added support for settings.
Added statistics.
* DiscImageChef/Main.cs:
* DiscImageChef/Options.cs:
Added support for settings.
Added statistics.
2016-02-03 18:58:11 +00:00
|
|
|
|
2014-07-03 18:34:43 +01:00
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
if(options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
sb.AppendLine("\tDisc image 1\tDisc image 2");
|
|
|
|
|
sb.AppendLine("================================");
|
|
|
|
|
sb.AppendFormat("File\t{0}\t{1}", options.InputFile1, options.InputFile2).AppendLine();
|
|
|
|
|
sb.AppendFormat("Disc image format\t{0}\t{1}", input1Format.Name, input2Format.Name).AppendLine();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendFormat("Disc image 1: {0}", options.InputFile1).AppendLine();
|
|
|
|
|
sb.AppendFormat("Disc image 2: {0}", options.InputFile2).AppendLine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool imagesDiffer = false;
|
|
|
|
|
|
|
|
|
|
ImageInfo image1Info = new ImageInfo();
|
|
|
|
|
ImageInfo image2Info = new ImageInfo();
|
|
|
|
|
List<Session> image1Sessions = new List<Session>();
|
|
|
|
|
List<Session> image2Sessions = new List<Session>();
|
2016-01-16 03:54:55 +00:00
|
|
|
Dictionary<MediaTagType, byte[]> image1DiskTags = new Dictionary<MediaTagType, byte[]>();
|
|
|
|
|
Dictionary<MediaTagType, byte[]> image2DiskTags = new Dictionary<MediaTagType, byte[]>();
|
2014-07-03 18:34:43 +01:00
|
|
|
|
|
|
|
|
image1Info.imageHasPartitions = input1Format.ImageHasPartitions();
|
2016-07-28 22:25:26 +01:00
|
|
|
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2016-04-19 02:11:47 +01:00
|
|
|
try { image1Sessions = input1Format.GetSessions(); } catch { }
|
2016-07-28 22:25:26 +01:00
|
|
|
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
|
|
|
|
image1Info.imageHasSessions |= image1Sessions.Count > 0;
|
2014-07-03 18:34:43 +01:00
|
|
|
image1Info.imageSize = input1Format.GetImageSize();
|
|
|
|
|
image1Info.sectors = input1Format.GetSectors();
|
|
|
|
|
image1Info.sectorSize = input1Format.GetSectorSize();
|
|
|
|
|
image1Info.imageCreationTime = input1Format.GetImageCreationTime();
|
|
|
|
|
image1Info.imageLastModificationTime = input1Format.GetImageLastModificationTime();
|
2016-01-16 03:54:55 +00:00
|
|
|
image1Info.mediaType = input1Format.GetMediaType();
|
2016-04-19 02:11:47 +01:00
|
|
|
try { image1Info.imageVersion = input1Format.GetImageVersion(); } catch { image1Info.imageVersion = null; }
|
|
|
|
|
try { image1Info.imageApplication = input1Format.GetImageApplication(); } catch { image1Info.imageApplication = null; }
|
|
|
|
|
try { image1Info.imageApplicationVersion = input1Format.GetImageApplicationVersion(); } catch { image1Info.imageApplicationVersion = null; }
|
|
|
|
|
try { image1Info.imageCreator = input1Format.GetImageCreator(); } catch { image1Info.imageCreator = null; }
|
|
|
|
|
try { image1Info.imageName = input1Format.GetImageName(); } catch { image1Info.imageName = null; }
|
|
|
|
|
try { image1Info.imageComments = input1Format.GetImageComments(); } catch { image1Info.imageComments = null; }
|
|
|
|
|
try { image1Info.mediaManufacturer = input1Format.GetMediaManufacturer(); } catch { image1Info.mediaManufacturer = null; }
|
|
|
|
|
try { image1Info.mediaModel = input1Format.GetMediaModel(); } catch { image1Info.mediaModel = null; }
|
|
|
|
|
try { image1Info.mediaSerialNumber = input1Format.GetMediaSerialNumber(); } catch { image1Info.mediaSerialNumber = null; }
|
|
|
|
|
try { image1Info.mediaBarcode = input1Format.GetMediaBarcode(); } catch { image1Info.mediaBarcode = null; }
|
|
|
|
|
try { image1Info.mediaPartNumber = input1Format.GetMediaPartNumber(); } catch { image1Info.mediaPartNumber = null; }
|
|
|
|
|
try { image1Info.mediaSequence = input1Format.GetMediaSequence(); } catch { image1Info.mediaSequence = 0; }
|
|
|
|
|
try { image1Info.lastMediaSequence = input1Format.GetLastDiskSequence(); } catch { image1Info.lastMediaSequence = 0; }
|
|
|
|
|
try { image1Info.driveManufacturer = input1Format.GetDriveManufacturer(); } catch { image1Info.driveManufacturer = null; }
|
|
|
|
|
try { image1Info.driveModel = input1Format.GetDriveModel(); } catch { image1Info.driveModel = null; }
|
|
|
|
|
try { image1Info.driveSerialNumber = input1Format.GetDriveSerialNumber(); } catch { image1Info.driveSerialNumber = null; }
|
2016-08-18 00:05:24 +01:00
|
|
|
try { image1Info.driveFirmwareRevision = input1Format.ImageInfo.driveFirmwareRevision; } catch { image1Info.driveFirmwareRevision = null; }
|
2016-04-19 02:11:47 +01:00
|
|
|
foreach(MediaTagType disktag in Enum.GetValues(typeof(MediaTagType)))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-07-03 18:34:43 +01:00
|
|
|
byte[] temparray = input1Format.ReadDiskTag(disktag);
|
|
|
|
|
image1DiskTags.Add(disktag, temparray);
|
|
|
|
|
}
|
2016-07-28 22:25:26 +01:00
|
|
|
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2016-04-19 02:11:47 +01:00
|
|
|
catch
|
2016-07-28 22:25:26 +01:00
|
|
|
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2016-04-19 02:11:47 +01:00
|
|
|
{
|
2014-07-03 18:34:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
image2Info.imageHasPartitions = input2Format.ImageHasPartitions();
|
2016-07-28 22:25:26 +01:00
|
|
|
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2016-04-19 02:11:47 +01:00
|
|
|
try { image2Sessions = input2Format.GetSessions(); } catch { }
|
2016-07-28 22:25:26 +01:00
|
|
|
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
|
|
|
|
image2Info.imageHasSessions |= image2Sessions.Count > 0;
|
2014-07-03 18:34:43 +01:00
|
|
|
image2Info.imageSize = input2Format.GetImageSize();
|
|
|
|
|
image2Info.sectors = input2Format.GetSectors();
|
|
|
|
|
image2Info.sectorSize = input2Format.GetSectorSize();
|
|
|
|
|
image2Info.imageCreationTime = input2Format.GetImageCreationTime();
|
|
|
|
|
image2Info.imageLastModificationTime = input2Format.GetImageLastModificationTime();
|
2016-01-16 03:54:55 +00:00
|
|
|
image2Info.mediaType = input2Format.GetMediaType();
|
2016-04-19 02:11:47 +01:00
|
|
|
try { image2Info.imageVersion = input2Format.GetImageVersion(); } catch { image2Info.imageVersion = null; }
|
|
|
|
|
try { image2Info.imageApplication = input2Format.GetImageApplication(); } catch { image2Info.imageApplication = null; }
|
|
|
|
|
try { image2Info.imageApplicationVersion = input2Format.GetImageApplicationVersion(); } catch { image2Info.imageApplicationVersion = null; }
|
|
|
|
|
try { image2Info.imageCreator = input2Format.GetImageCreator(); } catch { image2Info.imageCreator = null; }
|
|
|
|
|
try { image2Info.imageName = input2Format.GetImageName(); } catch { image2Info.imageName = null; }
|
|
|
|
|
try { image2Info.imageComments = input2Format.GetImageComments(); } catch { image2Info.imageComments = null; }
|
|
|
|
|
try { image2Info.mediaManufacturer = input2Format.GetMediaManufacturer(); } catch { image2Info.mediaManufacturer = null; }
|
|
|
|
|
try { image2Info.mediaModel = input2Format.GetMediaModel(); } catch { image2Info.mediaModel = null; }
|
|
|
|
|
try { image2Info.mediaSerialNumber = input2Format.GetMediaSerialNumber(); } catch { image2Info.mediaSerialNumber = null; }
|
|
|
|
|
try { image2Info.mediaBarcode = input2Format.GetMediaBarcode(); } catch { image2Info.mediaBarcode = null; }
|
|
|
|
|
try { image2Info.mediaPartNumber = input2Format.GetMediaPartNumber(); } catch { image2Info.mediaPartNumber = null; }
|
|
|
|
|
try { image2Info.mediaSequence = input2Format.GetMediaSequence(); } catch { image2Info.mediaSequence = 0; }
|
|
|
|
|
try { image2Info.lastMediaSequence = input2Format.GetLastDiskSequence(); } catch { image2Info.lastMediaSequence = 0; }
|
|
|
|
|
try { image2Info.driveManufacturer = input2Format.GetDriveManufacturer(); } catch { image2Info.driveManufacturer = null; }
|
|
|
|
|
try { image2Info.driveModel = input2Format.GetDriveModel(); } catch { image2Info.driveModel = null; }
|
|
|
|
|
try { image2Info.driveSerialNumber = input2Format.GetDriveSerialNumber(); } catch { image2Info.driveSerialNumber = null; }
|
2016-08-18 00:05:24 +01:00
|
|
|
try { image2Info.driveFirmwareRevision = input2Format.ImageInfo.driveFirmwareRevision; } catch { image2Info.driveFirmwareRevision = null; }
|
2016-04-19 02:11:47 +01:00
|
|
|
foreach(MediaTagType disktag in Enum.GetValues(typeof(MediaTagType)))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-07-03 18:34:43 +01:00
|
|
|
byte[] temparray = input2Format.ReadDiskTag(disktag);
|
|
|
|
|
image2DiskTags.Add(disktag, temparray);
|
|
|
|
|
}
|
2016-07-28 22:25:26 +01:00
|
|
|
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2016-04-19 02:11:47 +01:00
|
|
|
catch
|
2016-07-28 22:25:26 +01:00
|
|
|
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2016-04-19 02:11:47 +01:00
|
|
|
{
|
2014-07-03 18:34:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
if(options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
sb.AppendFormat("Has partitions?\t{0}\t{1}", image1Info.imageHasPartitions, image2Info.imageHasPartitions).AppendLine();
|
|
|
|
|
sb.AppendFormat("Has sessions?\t{0}\t{1}", image1Info.imageHasSessions, image2Info.imageHasSessions).AppendLine();
|
|
|
|
|
sb.AppendFormat("Image size\t{0}\t{1}", image1Info.imageSize, image2Info.imageSize).AppendLine();
|
|
|
|
|
sb.AppendFormat("Sectors\t{0}\t{1}", image1Info.sectors, image2Info.sectors).AppendLine();
|
|
|
|
|
sb.AppendFormat("Sector size\t{0}\t{1}", image1Info.sectorSize, image2Info.sectorSize).AppendLine();
|
|
|
|
|
sb.AppendFormat("Creation time\t{0}\t{1}", image1Info.imageCreationTime, image2Info.imageCreationTime).AppendLine();
|
|
|
|
|
sb.AppendFormat("Last modification time\t{0}\t{1}", image1Info.imageLastModificationTime, image2Info.imageLastModificationTime).AppendLine();
|
2016-01-16 03:54:55 +00:00
|
|
|
sb.AppendFormat("Disk type\t{0}\t{1}", image1Info.mediaType, image2Info.mediaType).AppendLine();
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendFormat("Image version\t{0}\t{1}", image1Info.imageVersion, image2Info.imageVersion).AppendLine();
|
|
|
|
|
sb.AppendFormat("Image application\t{0}\t{1}", image1Info.imageApplication, image2Info.imageApplication).AppendLine();
|
|
|
|
|
sb.AppendFormat("Image application version\t{0}\t{1}", image1Info.imageApplicationVersion, image2Info.imageApplicationVersion).AppendLine();
|
|
|
|
|
sb.AppendFormat("Image creator\t{0}\t{1}", image1Info.imageCreator, image2Info.imageCreator).AppendLine();
|
|
|
|
|
sb.AppendFormat("Image name\t{0}\t{1}", image1Info.imageName, image2Info.imageName).AppendLine();
|
|
|
|
|
sb.AppendFormat("Image comments\t{0}\t{1}", image1Info.imageComments, image2Info.imageComments).AppendLine();
|
2016-01-16 03:54:55 +00:00
|
|
|
sb.AppendFormat("Disk manufacturer\t{0}\t{1}", image1Info.mediaManufacturer, image2Info.mediaManufacturer).AppendLine();
|
|
|
|
|
sb.AppendFormat("Disk model\t{0}\t{1}", image1Info.mediaModel, image2Info.mediaModel).AppendLine();
|
|
|
|
|
sb.AppendFormat("Disk serial number\t{0}\t{1}", image1Info.mediaSerialNumber, image2Info.mediaSerialNumber).AppendLine();
|
|
|
|
|
sb.AppendFormat("Disk barcode\t{0}\t{1}", image1Info.mediaBarcode, image2Info.mediaBarcode).AppendLine();
|
|
|
|
|
sb.AppendFormat("Disk part no.\t{0}\t{1}", image1Info.mediaPartNumber, image2Info.mediaPartNumber).AppendLine();
|
|
|
|
|
sb.AppendFormat("Disk sequence\t{0}\t{1}", image1Info.mediaSequence, image2Info.mediaSequence).AppendLine();
|
|
|
|
|
sb.AppendFormat("Last disk on sequence\t{0}\t{1}", image1Info.lastMediaSequence, image2Info.lastMediaSequence).AppendLine();
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendFormat("Drive manufacturer\t{0}\t{1}", image1Info.driveManufacturer, image2Info.driveManufacturer).AppendLine();
|
2016-08-18 00:05:24 +01:00
|
|
|
sb.AppendFormat("Drive firmware revision\t{0}\t{1}", image1Info.driveFirmwareRevision, image2Info.driveFirmwareRevision).AppendLine();
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendFormat("Drive model\t{0}\t{1}", image1Info.driveModel, image2Info.driveModel).AppendLine();
|
|
|
|
|
sb.AppendFormat("Drive serial number\t{0}\t{1}", image1Info.driveSerialNumber, image2Info.driveSerialNumber).AppendLine();
|
2016-04-19 02:11:47 +01:00
|
|
|
foreach(MediaTagType disktag in Enum.GetValues(typeof(MediaTagType)))
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
sb.AppendFormat("Has {0}?\t{1}\t{2}", disktag, image1DiskTags.ContainsKey(disktag), image2DiskTags.ContainsKey(disktag)).AppendLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.WriteLine("Comparing disk image characteristics");
|
2014-07-03 18:34:43 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageHasPartitions != image2Info.imageHasPartitions)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image partitioned status differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageHasSessions != image2Info.imageHasSessions)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image session status differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageSize != image2Info.imageSize)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image size differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.sectors != image2Info.sectors)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image sectors differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.sectorSize != image2Info.sectorSize)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image sector size differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageCreationTime != image2Info.imageCreationTime)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image creation time differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageLastModificationTime != image2Info.imageLastModificationTime)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image last modification time differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.mediaType != image2Info.mediaType)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Disk type differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageVersion != image2Info.imageVersion)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image version differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageApplication != image2Info.imageApplication)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image application differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageApplicationVersion != image2Info.imageApplicationVersion)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image application version differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageCreator != image2Info.imageCreator)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image creator differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageName != image2Info.imageName)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image name differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.imageComments != image2Info.imageComments)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image comments differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.mediaManufacturer != image2Info.mediaManufacturer)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Disk manufacturer differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.mediaModel != image2Info.mediaModel)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Disk model differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.mediaSerialNumber != image2Info.mediaSerialNumber)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Disk serial number differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.mediaBarcode != image2Info.mediaBarcode)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Disk barcode differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.mediaPartNumber != image2Info.mediaPartNumber)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Disk part number differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.mediaSequence != image2Info.mediaSequence)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Disk sequence differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.lastMediaSequence != image2Info.lastMediaSequence)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Last disk in sequence differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.driveManufacturer != image2Info.driveManufacturer)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Drive manufacturer differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.driveModel != image2Info.driveModel)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Drive model differ");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.driveSerialNumber != image2Info.driveSerialNumber)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Drive serial number differ");
|
|
|
|
|
}
|
2016-08-18 00:05:24 +01:00
|
|
|
if(image1Info.driveFirmwareRevision != image2Info.driveFirmwareRevision)
|
|
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
|
|
|
|
if(!options.Verbose)
|
|
|
|
|
sb.AppendLine("Drive firmware revision differ");
|
|
|
|
|
}
|
2014-07-03 18:34:43 +01:00
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
ulong leastSectors;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(image1Info.sectors < image2Info.sectors)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
|
|
|
|
leastSectors = image1Info.sectors;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image 2 has more sectors");
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
else if(image1Info.sectors > image2Info.sectors)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
|
|
|
|
leastSectors = image2Info.sectors;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!options.Verbose)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Image 1 has more sectors");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
leastSectors = image1Info.sectors;
|
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.WriteLine("Comparing sectors...");
|
2014-07-03 18:34:43 +01:00
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
for(ulong sector = 0; sector < leastSectors; sector++)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
DicConsole.Write("\rComparing sector {0} of {1}...", sector + 1, leastSectors);
|
2014-07-03 18:34:43 +01:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
byte[] image1Sector = input1Format.ReadSector(sector);
|
|
|
|
|
byte[] image2Sector = input2Format.ReadSector(sector);
|
|
|
|
|
bool different, sameSize;
|
|
|
|
|
CompareBytes(out different, out sameSize, image1Sector, image2Sector);
|
|
|
|
|
if(different)
|
|
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
|
|
|
|
sb.AppendFormat("Sector {0} is different", sector).AppendLine();
|
|
|
|
|
}
|
|
|
|
|
else if(!sameSize)
|
|
|
|
|
{
|
|
|
|
|
imagesDiffer = true;
|
|
|
|
|
sb.AppendFormat("Sector {0} has different sizes ({1} bytes in image 1, {2} in image 2) but are otherwise identical",
|
|
|
|
|
sector, image1Sector.LongLength, image2Sector.LongLength).AppendLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-28 22:25:26 +01:00
|
|
|
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2016-04-19 02:11:47 +01:00
|
|
|
catch { }
|
2016-07-28 22:25:26 +01:00
|
|
|
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2014-07-03 18:34:43 +01:00
|
|
|
}
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.WriteLine();
|
2014-07-03 18:34:43 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
if(imagesDiffer)
|
2014-07-03 18:34:43 +01:00
|
|
|
sb.AppendLine("Images differ");
|
|
|
|
|
else
|
|
|
|
|
sb.AppendLine("Images do not differ");
|
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.WriteLine(sb.ToString());
|
* commandline:
* DiscImageChef.Settings/Settings.cs:
* DiscImageChef.Settings/docs/README.txt:
* DiscImageChef.Settings/packages.config:
* DiscImageChef.Settings/docs/LICENSE.txt:
* DiscImageChef.Settings/docs/ChangeLog.txt:
* DiscImageChef.Settings/docs/mono/index.xml:
* DiscImageChef.Settings/docs/html/index.html:
* DiscImageChef.Settings/Properties/AssemblyInfo.cs:
* DiscImageChef.Settings/DiscImageChef.Settings.csproj:
* DiscImageChef.Settings/docs/mono/ns-Claunia.PropertyList.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/UID.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/UID.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSSet.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/index.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSSet.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSDate.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSData.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSDate.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSData.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSArray.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSNumber.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSString.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSObject.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSArray.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSNumber.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSString.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSObject.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSDictionary.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSDictionary.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/PropertyListParser.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/PropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/XmlPropertyListParser.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/XmlPropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/ASCIIPropertyListParser.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/ASCIIPropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/BinaryPropertyListParser.xml:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/BinaryPropertyListWriter.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/BinaryPropertyListWriter.html:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/BinaryPropertyListParser.html:
* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/PropertyListFormatException.xml:
* DiscImageChef.Settings/docs/html/Claunia.PropertyList/PropertyListFormatException.html:
Added supports for settings
* DiscImageChef/Commands/Configure.cs:
Added support for settings.
* DiscImageChef/Core/Statistics.cs:
* DiscImageChef/Commands/Verify.cs:
* DiscImageChef/Commands/Entropy.cs:
* DiscImageChef/Commands/Formats.cs:
* DiscImageChef/Commands/PrintHex.cs:
* DiscImageChef/Commands/MediaInfo.cs:
* DiscImageChef/Commands/Statistics.cs:
Added statistics.
* DiscImageChef.Decoders/SCSI/Inquiry.cs:
Corrected bug on inquiry decoding.
* DiscImageChef.Decoders/SCSI/Modes.cs:
Corrected bug on decoding mode page 2Ah without write
performance descriptors.
Corrected bug when there is a vendor page 0 in mode sense
decoding.
* DiscImageChef.Devices/Device/Constructor.cs:
Corrected detecting USB or FireWire attached CD/DVD/BD and
tape drives.
Try ATA identify on USB or FireWire that don't have SCSI
INQUIRY.
* DiscImageChef.DiscImages/CDRWin.cs:
Corrected CD-ROM XA vs CD-ROM detection.
* DiscImageChef.Partitions/AppleMap.cs:
Corrected big endian working.
Added debug output.
* DiscImageChef.sln:
Added supports for settings.
* DiscImageChef/Commands/Decode.cs:
* DiscImageChef/Commands/Analyze.cs:
* DiscImageChef/Commands/Compare.cs:
* DiscImageChef/Commands/Checksum.cs:
* DiscImageChef/Commands/Benchmark.cs:
* DiscImageChef/Commands/DeviceInfo.cs:
* DiscImageChef/Commands/CreateSidecar.cs:
Added statistics.
* DiscImageChef/Commands/DeviceReport.cs:
Added statistics.
Correct handling empty inquiry string fields.
Suppose it is not removable, til proved wrong.
Corrected MODE SENSE (6/10) detection and calling order.
If device is MMC type but reports neither mode page 2Ah
neither GET CONFIGURATION, try all CDs (old drives work like
that).
Try reading Lead-In and Lead-Out in Audio CD using Audio READ
CD commands.
Corrected READ LONG information handling, some drives return
2s-complement in 32 bit. Upper 16 bits are ignored.
Added support for DVD raw block (37856 bytes).
Check READ LONG up to 36 times the cooked block size. That
should be enough to detect huge blocked media (like DVD and
BD) without taking ages.
If READ LONG size had to be bruteforced, and debug is
activated, save the result.
* DiscImageChef/Commands/DumpMedia.cs:
Added statistics.
Corrected READ LONG information handling, some drives return
2s-complement in 32 bit. Upper 16 bits are ignored.
Start trying with 64 blocks at a time. Some drives report to
be able to read 255 at a time, but they really don't, they
take a lot longer to read.
* DiscImageChef/Commands/MediaScan.cs:
Added statistics.
Start trying with 64 blocks at a time. Some drives report to
be able to read 255 at a time, but they really don't, they
take a lot longer to read.
* DiscImageChef/DiscImageChef.csproj:
Added support for settings.
Added statistics.
* DiscImageChef/Main.cs:
* DiscImageChef/Options.cs:
Added support for settings.
Added statistics.
2016-02-03 18:58:11 +00:00
|
|
|
|
|
|
|
|
Core.Statistics.AddCommand("compare");
|
2014-07-03 18:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
static void CompareBytes(out bool different, out bool sameSize, byte[] compareArray1, byte[] compareArray2)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
different = false;
|
|
|
|
|
sameSize = true;
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
long leastBytes;
|
2016-04-19 02:11:47 +01:00
|
|
|
if(compareArray1.LongLength < compareArray2.LongLength)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
sameSize = false;
|
|
|
|
|
leastBytes = compareArray1.LongLength;
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
else if(compareArray1.LongLength > compareArray2.LongLength)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
sameSize = false;
|
|
|
|
|
leastBytes = compareArray2.LongLength;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
leastBytes = compareArray1.LongLength;
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
for(long i = 0; i < leastBytes; i++)
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
if(compareArray1[i] != compareArray2[i])
|
2014-07-03 18:34:43 +01:00
|
|
|
{
|
|
|
|
|
different = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-16 01:45:04 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|