2020-05-14 03:43:21 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : MiniDisc.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Core algorithms.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Dumps MiniDisc devices.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:10 +00:00
|
|
|
|
// Copyright © 2011-2023 Natalia Portillo
|
2020-05-14 03:43:21 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
// ReSharper disable JoinDeclarationAndInitializer
|
|
|
|
|
|
|
2020-05-14 03:43:21 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
using System.Text.Json.Serialization;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
using Aaru.CommonTypes;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Aaru.CommonTypes.AaruMetadata;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
|
using Aaru.CommonTypes.Extents;
|
|
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.CommonTypes.Metadata;
|
|
|
|
|
|
using Aaru.Console;
|
2022-12-05 21:29:04 +00:00
|
|
|
|
using Aaru.Core.Graphics;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
using Aaru.Core.Logging;
|
|
|
|
|
|
using Aaru.Decoders.SCSI;
|
|
|
|
|
|
using Aaru.Devices;
|
|
|
|
|
|
using MediaType = Aaru.CommonTypes.MediaType;
|
|
|
|
|
|
using Version = Aaru.CommonTypes.Interop.Version;
|
|
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Core.Devices.Dumping;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>Implements dumping MiniDisc Data devices</summary>
|
|
|
|
|
|
partial class Dump
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>Dumps a MiniDisc Data device</summary>
|
|
|
|
|
|
void MiniDisc()
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
bool sense;
|
|
|
|
|
|
byte scsiMediumType = 0;
|
|
|
|
|
|
const ushort sbcProfile = 0x0001;
|
|
|
|
|
|
DateTime start;
|
|
|
|
|
|
DateTime end;
|
|
|
|
|
|
double totalDuration = 0;
|
|
|
|
|
|
double currentSpeed = 0;
|
|
|
|
|
|
double maxSpeed = double.MinValue;
|
|
|
|
|
|
double minSpeed = double.MaxValue;
|
|
|
|
|
|
byte[] readBuffer;
|
|
|
|
|
|
Modes.DecodedMode? decMode = null;
|
|
|
|
|
|
Dictionary<MediaTagType, byte[]> mediaTags = new();
|
|
|
|
|
|
bool ret;
|
2022-03-17 00:46:26 +00:00
|
|
|
|
|
|
|
|
|
|
if(_outputPlugin is not IWritableImage outputFormat)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Image_is_not_writable_aborting);
|
2022-03-17 00:46:26 +00:00
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Initializing_reader);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var scsiReader = new Reader(_dev, _dev.Timeout, null, _errorLog);
|
|
|
|
|
|
ulong blocks = scsiReader.GetDeviceBlocks();
|
|
|
|
|
|
uint blockSize = scsiReader.LogicalBlockSize;
|
|
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Requesting_MODE_SENSE_6);
|
|
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-14 01:10:11 +00:00
|
|
|
|
sense = _dev.ModeSense6(out byte[] cmdBuf, out _, true, ScsiModeSensePageControl.Current, 0x3F, 5, out _);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(!sense &&
|
|
|
|
|
|
!_dev.Error &&
|
|
|
|
|
|
Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
|
|
|
|
|
|
decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType);
|
|
|
|
|
|
|
|
|
|
|
|
if(decMode.HasValue)
|
|
|
|
|
|
scsiMediumType = (byte)decMode.Value.Header.MediumType;
|
|
|
|
|
|
|
|
|
|
|
|
if(blockSize != 2048)
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
MiniDisc_albums_NetMD_discs_or_user_written_audio_MiniDisc_cannot_be_dumped);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
MiniDisc_albums_NetMD_discs_or_user_written_audio_MiniDisc_cannot_be_dumped);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-13 20:08:10 +00:00
|
|
|
|
const MediaType dskType = MediaType.MDData;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(scsiReader.FindReadCommand())
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.ERROR_Cannot_find_correct_read_command_0, scsiReader.ErrorMessage);
|
|
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Unable_to_read_medium);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-17 23:54:41 +00:00
|
|
|
|
if(blocks != 0)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
blocks++;
|
|
|
|
|
|
|
|
|
|
|
|
ulong totalSize = blocks * blockSize;
|
|
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
switch(totalSize)
|
|
|
|
|
|
{
|
|
|
|
|
|
case > 1099511627776:
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.
|
|
|
|
|
|
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_TiB,
|
|
|
|
|
|
blocks, blockSize, totalSize / 1099511627776d));
|
2022-11-13 19:38:03 +00:00
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case > 1073741824:
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.
|
|
|
|
|
|
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_GiB,
|
|
|
|
|
|
blocks, blockSize, totalSize / 1073741824d));
|
2022-11-13 19:38:03 +00:00
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case > 1048576:
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.
|
|
|
|
|
|
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_MiB,
|
|
|
|
|
|
blocks, blockSize, totalSize / 1048576d));
|
2022-11-13 19:38:03 +00:00
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case > 1024:
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.
|
|
|
|
|
|
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_KiB,
|
|
|
|
|
|
blocks, blockSize, totalSize / 1024d));
|
2022-11-13 19:38:03 +00:00
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.
|
|
|
|
|
|
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_bytes,
|
|
|
|
|
|
blocks, blockSize, totalSize));
|
2022-11-13 19:38:03 +00:00
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2020-07-12 15:15:22 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Check how many blocks to read, if error show and return
|
|
|
|
|
|
// 64 works, gets maximum speed (150KiB/s), slow I know...
|
|
|
|
|
|
if(scsiReader.GetBlocksToRead())
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.ERROR_Cannot_get_blocks_to_read_0, scsiReader.ErrorMessage);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(scsiReader.ErrorMessage);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
uint blocksToRead = scsiReader.BlocksToRead;
|
|
|
|
|
|
uint physicalBlockSize = scsiReader.PhysicalBlockSize;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(blocks == 0)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.ERROR_Unable_to_read_medium_or_empty_medium_present);
|
|
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Unable_to_read_medium_or_empty_medium_present);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, blocks,
|
|
|
|
|
|
blocks * blockSize));
|
|
|
|
|
|
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Device_can_read_0_blocks_at_a_time, blocksToRead));
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_bytes_per_logical_block, blockSize));
|
|
|
|
|
|
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_bytes_per_physical_block,
|
|
|
|
|
|
scsiReader.LongBlockSize));
|
|
|
|
|
|
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.SCSI_device_type_0, _dev.ScsiType));
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.SCSI_medium_type_0, scsiMediumType));
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Media_identified_as_0, dskType));
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_reports_0_blocks_1_bytes, blocks, blocks * blockSize);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_can_read_0_blocks_at_a_time, blocksToRead);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_reports_0_bytes_per_logical_block, blockSize);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_reports_0_bytes_per_physical_block, scsiReader.LongBlockSize);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.SCSI_device_type_0, _dev.ScsiType);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.SCSI_medium_type_0, scsiMediumType);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Media_identified_as_0, dskType);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.MiniDiscGetType(out cmdBuf, out _, _dev.Timeout, out _);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense &&
|
|
|
|
|
|
!_dev.Error)
|
|
|
|
|
|
mediaTags.Add(MediaTagType.MiniDiscType, cmdBuf);
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.MiniDiscD5(out cmdBuf, out _, _dev.Timeout, out _);
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense &&
|
|
|
|
|
|
!_dev.Error)
|
|
|
|
|
|
mediaTags.Add(MediaTagType.MiniDiscD5, cmdBuf);
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.MiniDiscReadDataTOC(out cmdBuf, out _, _dev.Timeout, out _);
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense &&
|
|
|
|
|
|
!_dev.Error)
|
|
|
|
|
|
mediaTags.Add(MediaTagType.MiniDiscDTOC, cmdBuf);
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var utocMs = new MemoryStream();
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
for(uint i = 0; i < 3; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
sense = _dev.MiniDiscReadUserTOC(out cmdBuf, out _, i, _dev.Timeout, out _);
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense || _dev.Error)
|
|
|
|
|
|
break;
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
utocMs.Write(cmdBuf, 0, 2336);
|
|
|
|
|
|
}
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(utocMs.Length > 0)
|
|
|
|
|
|
mediaTags.Add(MediaTagType.MiniDiscUTOC, utocMs.ToArray());
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ret = true;
|
2020-06-05 01:54:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputFormat.SupportedMediaTags.Contains(tag)))
|
|
|
|
|
|
{
|
|
|
|
|
|
ret = false;
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(string.Format(Localization.Core.Output_format_does_not_support_0, tag));
|
|
|
|
|
|
ErrorMessage?.Invoke(string.Format(Localization.Core.Output_format_does_not_support_0, tag));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!ret)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_force)
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Several_media_tags_not_supported_continuing);
|
|
|
|
|
|
ErrorMessage?.Invoke(Localization.Core.Several_media_tags_not_supported_continuing);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Several_media_tags_not_supported_not_continuing);
|
|
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Several_media_tags_not_supported_not_continuing);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead));
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private,
|
|
|
|
|
|
_dimensions);
|
|
|
|
|
|
|
|
|
|
|
|
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ret = outputFormat.Create(_outputPath, dskType, _formatOptions, blocks, blockSize);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Cannot create image
|
|
|
|
|
|
if(!ret)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Error_creating_output_image_not_continuing);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_dumpLog.WriteLine(outputFormat.ErrorMessage);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
|
|
|
|
|
|
Environment.NewLine + outputFormat.ErrorMessage);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
start = DateTime.UtcNow;
|
|
|
|
|
|
double imageWriteDuration = 0;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(decMode?.Pages != null)
|
|
|
|
|
|
{
|
2022-11-15 15:58:43 +00:00
|
|
|
|
bool setGeometry = false;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
foreach(Modes.ModePage page in decMode.Value.Pages)
|
2022-11-13 19:38:03 +00:00
|
|
|
|
switch(page.Page)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-11-13 19:38:03 +00:00
|
|
|
|
case 0x04 when page.Subpage == 0x00:
|
|
|
|
|
|
{
|
|
|
|
|
|
Modes.ModePage_04? rigidPage = Modes.DecodeModePage_04(page.PageResponse);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
if(!rigidPage.HasValue || setGeometry)
|
|
|
|
|
|
continue;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.
|
|
|
|
|
|
WriteLine(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
|
|
|
|
|
|
rigidPage.Value.Cylinders, rigidPage.Value.Heads,
|
|
|
|
|
|
(uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads)));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.
|
|
|
|
|
|
Invoke(string.
|
|
|
|
|
|
Format(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
|
|
|
|
|
|
rigidPage.Value.Cylinders, rigidPage.Value.Heads,
|
|
|
|
|
|
(uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
outputFormat.SetGeometry(rigidPage.Value.Cylinders, rigidPage.Value.Heads,
|
|
|
|
|
|
(uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads)));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
setGeometry = true;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case 0x05 when page.Subpage == 0x00:
|
|
|
|
|
|
{
|
|
|
|
|
|
Modes.ModePage_05? flexiblePage = Modes.DecodeModePage_05(page.PageResponse);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
if(!flexiblePage.HasValue)
|
|
|
|
|
|
continue;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.
|
|
|
|
|
|
WriteLine(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
|
|
|
|
|
|
flexiblePage.Value.Cylinders, flexiblePage.Value.Heads,
|
|
|
|
|
|
flexiblePage.Value.SectorsPerTrack);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.
|
|
|
|
|
|
Invoke(string.
|
|
|
|
|
|
Format(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
|
|
|
|
|
|
flexiblePage.Value.Cylinders, flexiblePage.Value.Heads,
|
|
|
|
|
|
flexiblePage.Value.SectorsPerTrack));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
outputFormat.SetGeometry(flexiblePage.Value.Cylinders, flexiblePage.Value.Heads,
|
|
|
|
|
|
flexiblePage.Value.SectorsPerTrack);
|
|
|
|
|
|
|
|
|
|
|
|
setGeometry = true;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
DumpHardware currentTry = null;
|
|
|
|
|
|
ExtentsULong extents = null;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
|
|
|
|
|
|
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
|
|
|
|
|
|
_private, _force);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(currentTry == null ||
|
|
|
|
|
|
extents == null)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_resume.NextBlock > 0)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Resuming_from_block_0, _resume.NextBlock));
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Resuming_from_block_0, _resume.NextBlock);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-12-05 21:29:04 +00:00
|
|
|
|
if(_createGraph)
|
|
|
|
|
|
{
|
|
|
|
|
|
Spiral.DiscParameters discSpiralParameters = Spiral.DiscParametersFromMediaType(dskType);
|
|
|
|
|
|
|
|
|
|
|
|
if(discSpiralParameters is not null)
|
|
|
|
|
|
_mediaGraph = new Spiral((int)_dimensions, (int)_dimensions, discSpiralParameters, blocks);
|
|
|
|
|
|
else
|
|
|
|
|
|
_mediaGraph = new BlockMap((int)_dimensions, (int)_dimensions, blocks);
|
|
|
|
|
|
|
|
|
|
|
|
if(_mediaGraph is not null)
|
|
|
|
|
|
foreach(Tuple<ulong, ulong> e in extents.ToArray())
|
|
|
|
|
|
_mediaGraph?.PaintSectorsGood(e.Item1, (uint)(e.Item2 - e.Item1 + 2));
|
|
|
|
|
|
|
|
|
|
|
|
_mediaGraph?.PaintSectorsBad(_resume.BadBlocks);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
bool newTrim = false;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
DateTime timeSpeedStart = DateTime.UtcNow;
|
|
|
|
|
|
ulong sectorSpeedStart = 0;
|
|
|
|
|
|
InitProgress?.Invoke();
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
for(ulong i = _resume.NextBlock; i < blocks; i += blocksToRead)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_aborted)
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Aborted);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Aborted);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(blocks - i < blocksToRead)
|
|
|
|
|
|
blocksToRead = (uint)(blocks - i);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(currentSpeed > maxSpeed &&
|
|
|
|
|
|
currentSpeed > 0)
|
|
|
|
|
|
maxSpeed = currentSpeed;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(currentSpeed < minSpeed &&
|
|
|
|
|
|
currentSpeed > 0)
|
|
|
|
|
|
minSpeed = currentSpeed;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateProgress?.
|
|
|
|
|
|
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2_MiB_sec, i, blocks, currentSpeed),
|
|
|
|
|
|
(long)i, (long)blocks);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Read6(out readBuffer, out _, (uint)i, blockSize, (byte)blocksToRead, _dev.Timeout,
|
|
|
|
|
|
out double cmdDuration);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
totalDuration += cmdDuration;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense &&
|
|
|
|
|
|
!_dev.Error)
|
|
|
|
|
|
{
|
2022-12-05 22:03:12 +00:00
|
|
|
|
mhddLog.Write(i, cmdDuration, blocksToRead);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ibgLog.Write(i, currentSpeed * 1024);
|
|
|
|
|
|
DateTime writeStart = DateTime.Now;
|
|
|
|
|
|
outputFormat.WriteSectors(readBuffer, i, blocksToRead);
|
|
|
|
|
|
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
|
|
|
|
|
extents.Add(i, blocksToRead, true);
|
2022-12-05 21:29:04 +00:00
|
|
|
|
_mediaGraph?.PaintSectorsGood(i, blocksToRead);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// TODO: Reset device after X errors
|
|
|
|
|
|
if(_stopOnError)
|
|
|
|
|
|
return; // TODO: Return more cleanly
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(i + _skip > blocks)
|
|
|
|
|
|
_skip = (uint)(blocks - i);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Write empty data
|
|
|
|
|
|
DateTime writeStart = DateTime.Now;
|
|
|
|
|
|
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
|
|
|
|
|
|
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
for(ulong b = i; b < i + _skip; b++)
|
|
|
|
|
|
_resume.BadBlocks.Add(b);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-12-05 22:03:12 +00:00
|
|
|
|
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ibgLog.Write(i, 0);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Skipping_0_blocks_from_errored_block_1, _skip, i);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
i += _skip - blocksToRead;
|
|
|
|
|
|
newTrim = true;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sectorSpeedStart += blocksToRead;
|
|
|
|
|
|
_resume.NextBlock = i + blocksToRead;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(elapsed <= 0)
|
|
|
|
|
|
continue;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
|
|
|
|
|
|
sectorSpeedStart = 0;
|
|
|
|
|
|
timeSpeedStart = DateTime.UtcNow;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
|
2020-11-03 01:40:10 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
end = DateTime.UtcNow;
|
|
|
|
|
|
EndProgress?.Invoke();
|
|
|
|
|
|
mhddLog.Close();
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
|
|
|
|
|
|
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0_seconds, (end - start).TotalSeconds));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0_KiB_sec,
|
|
|
|
|
|
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0_KiB_sec,
|
|
|
|
|
|
blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Dump_finished_in_0_seconds, (end - start).TotalSeconds);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Average_dump_speed_0_KiB_sec,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Average_write_speed_0_KiB_sec,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
#region Trimming
|
|
|
|
|
|
if(_resume.BadBlocks.Count > 0 &&
|
|
|
|
|
|
!_aborted &&
|
|
|
|
|
|
_trim &&
|
|
|
|
|
|
newTrim)
|
|
|
|
|
|
{
|
|
|
|
|
|
start = DateTime.UtcNow;
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
|
|
|
|
|
InitProgress?.Invoke();
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
foreach(ulong badSector in tmpArray)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_aborted)
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Aborted);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Aborted);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
PulseProgress?.Invoke(string.Format(Localization.Core.Trimming_sector_0, badSector));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
sense = _dev.Read6(out readBuffer, out _, (uint)badSector, blockSize, 1, _dev.Timeout, out double _);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense || _dev.Error)
|
|
|
|
|
|
continue;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_resume.BadBlocks.Remove(badSector);
|
|
|
|
|
|
extents.Add(badSector);
|
|
|
|
|
|
outputFormat.WriteSector(readBuffer, badSector);
|
2022-12-05 21:29:04 +00:00
|
|
|
|
_mediaGraph?.PaintSectorGood(badSector);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress?.Invoke();
|
|
|
|
|
|
end = DateTime.UtcNow;
|
2022-11-23 16:06:46 +00:00
|
|
|
|
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0_seconds,
|
|
|
|
|
|
(end - start).TotalSeconds));
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Trimming_finished_in_0_seconds, (end - start).TotalSeconds);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
#endregion Trimming
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
#region Error handling
|
|
|
|
|
|
if(_resume.BadBlocks.Count > 0 &&
|
|
|
|
|
|
!_aborted &&
|
|
|
|
|
|
_retryPasses > 0)
|
|
|
|
|
|
{
|
2022-11-15 15:58:43 +00:00
|
|
|
|
int pass = 1;
|
|
|
|
|
|
bool forward = true;
|
|
|
|
|
|
bool runningPersistent = false;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Modes.ModePage? currentModePage = null;
|
|
|
|
|
|
byte[] md6;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_persistent)
|
|
|
|
|
|
{
|
|
|
|
|
|
Modes.ModePage_01 pg;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.ModeSense6(out readBuffer, out _, false, ScsiModeSensePageControl.Current, 0x01,
|
|
|
|
|
|
_dev.Timeout, out _);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
Modes.DecodedMode? dcMode6 = Modes.DecodeMode6(readBuffer, _dev.ScsiType);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(dcMode6?.Pages != null)
|
|
|
|
|
|
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
|
2022-11-15 15:58:43 +00:00
|
|
|
|
modePage is { Page: 0x01, Subpage: 0x00 }))
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentModePage = modePage;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(currentModePage == null)
|
|
|
|
|
|
{
|
2020-05-14 03:43:21 +01:00
|
|
|
|
pg = new Modes.ModePage_01
|
|
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
PS = false,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
AWRE = true,
|
|
|
|
|
|
ARRE = true,
|
|
|
|
|
|
TB = false,
|
2020-07-20 04:34:16 +01:00
|
|
|
|
RC = false,
|
|
|
|
|
|
EER = true,
|
|
|
|
|
|
PER = false,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
DTE = true,
|
2020-07-20 04:34:16 +01:00
|
|
|
|
DCR = false,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ReadRetryCount = 32
|
2020-05-14 03:43:21 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentModePage = new Modes.ModePage
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Page = 0x01,
|
|
|
|
|
|
Subpage = 0x00,
|
|
|
|
|
|
PageResponse = Modes.EncodeModePage_01(pg)
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pg = new Modes.ModePage_01
|
|
|
|
|
|
{
|
|
|
|
|
|
PS = false,
|
|
|
|
|
|
AWRE = false,
|
|
|
|
|
|
ARRE = false,
|
|
|
|
|
|
TB = true,
|
|
|
|
|
|
RC = false,
|
|
|
|
|
|
EER = true,
|
|
|
|
|
|
PER = false,
|
|
|
|
|
|
DTE = false,
|
|
|
|
|
|
DCR = false,
|
|
|
|
|
|
ReadRetryCount = 255
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var md = new Modes.DecodedMode
|
|
|
|
|
|
{
|
|
|
|
|
|
Header = new Modes.ModeHeader(),
|
|
|
|
|
|
Pages = new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new Modes.ModePage
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Page = 0x01,
|
|
|
|
|
|
Subpage = 0x00,
|
|
|
|
|
|
PageResponse = Modes.EncodeModePage_01(pg)
|
2020-05-14 03:43:21 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
};
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
md6 = Modes.EncodeMode6(md, _dev.ScsiType);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Sending_MODE_SELECT_to_drive_return_damaged_blocks);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Sending_MODE_SELECT_to_drive_return_damaged_blocks);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.ModeSelect(md6, out byte[] senseBuf, true, false, _dev.Timeout, out _);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.
|
|
|
|
|
|
Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
AaruConsole.DebugWriteLine(Localization.Core.Error_0, Sense.PrettifySense(senseBuf));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
|
|
|
|
|
runningPersistent = true;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
InitProgress?.Invoke();
|
2022-11-15 15:58:43 +00:00
|
|
|
|
repeatRetry:
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
foreach(ulong badSector in tmpArray)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_aborted)
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Aborted);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Aborted);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
if(forward)
|
|
|
|
|
|
PulseProgress?.Invoke(runningPersistent
|
|
|
|
|
|
? string.
|
|
|
|
|
|
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward,
|
|
|
|
|
|
badSector, pass)
|
|
|
|
|
|
: string.Format(Localization.Core.Retrying_sector_0_pass_1_forward,
|
|
|
|
|
|
badSector, pass));
|
|
|
|
|
|
else
|
|
|
|
|
|
PulseProgress?.Invoke(runningPersistent
|
|
|
|
|
|
? string.
|
|
|
|
|
|
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse,
|
|
|
|
|
|
badSector, pass)
|
|
|
|
|
|
: string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse,
|
|
|
|
|
|
badSector, pass));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Read6(out readBuffer, out _, (uint)badSector, blockSize, 1, _dev.Timeout,
|
|
|
|
|
|
out double cmdDuration);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
totalDuration += cmdDuration;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense &&
|
|
|
|
|
|
!_dev.Error)
|
|
|
|
|
|
{
|
|
|
|
|
|
_resume.BadBlocks.Remove(badSector);
|
|
|
|
|
|
extents.Add(badSector);
|
|
|
|
|
|
outputFormat.WriteSector(readBuffer, badSector);
|
2022-12-05 21:29:04 +00:00
|
|
|
|
_mediaGraph?.PaintSectorGood(badSector);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector,
|
|
|
|
|
|
pass));
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else if(runningPersistent)
|
|
|
|
|
|
outputFormat.WriteSector(readBuffer, badSector);
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(pass < _retryPasses &&
|
|
|
|
|
|
!_aborted &&
|
|
|
|
|
|
_resume.BadBlocks.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
pass++;
|
|
|
|
|
|
forward = !forward;
|
|
|
|
|
|
_resume.BadBlocks.Sort();
|
2020-06-14 19:08:12 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!forward)
|
|
|
|
|
|
_resume.BadBlocks.Reverse();
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
goto repeatRetry;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(runningPersistent && currentModePage.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
var md = new Modes.DecodedMode
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Header = new Modes.ModeHeader(),
|
|
|
|
|
|
Pages = new[]
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentModePage.Value
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
md6 = Modes.EncodeMode6(md, _dev.ScsiType);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Sending_MODE_SELECT_to_drive_return_device_to_previous_status);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Sending_MODE_SELECT_to_drive_return_device_to_previous_status);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_dev.ModeSelect(md6, out _, true, false, _dev.Timeout, out _);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress?.Invoke();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion Error handling
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_resume.BadBlocks.Sort();
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
foreach(ulong bad in _resume.BadBlocks)
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
outputFormat.SetDumpHardware(_resume.Tries);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
var metadata = new CommonTypes.Structs.ImageInfo
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
Application = "Aaru",
|
|
|
|
|
|
ApplicationVersion = Version.GetVersion()
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
if(!outputFormat.SetImageInfo(metadata))
|
2022-11-23 16:06:46 +00:00
|
|
|
|
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
|
2022-03-06 13:29:38 +00:00
|
|
|
|
outputFormat.ErrorMessage);
|
|
|
|
|
|
|
|
|
|
|
|
if(_preSidecar != null)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
outputFormat.SetMetadata(_preSidecar);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
|
|
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
DateTime closeStart = DateTime.Now;
|
|
|
|
|
|
outputFormat.Close();
|
|
|
|
|
|
DateTime closeEnd = DateTime.Now;
|
2022-11-23 16:06:46 +00:00
|
|
|
|
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0_seconds,
|
|
|
|
|
|
(closeEnd - closeStart).TotalSeconds));
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Closed_in_0_seconds, (closeEnd - closeStart).TotalSeconds);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(_aborted)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Aborted);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Aborted);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
double totalChkDuration = 0;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_metadata)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Creating_sidecar);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Creating_sidecar);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var filters = new FiltersList();
|
|
|
|
|
|
IFilter filter = filters.GetFilter(_outputPath);
|
2022-03-07 07:36:44 +00:00
|
|
|
|
var inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorNumber opened = inputPlugin.Open(filter);
|
|
|
|
|
|
|
|
|
|
|
|
if(opened != ErrorNumber.NoError)
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(string.Format(Localization.Core.Error_0_opening_created_image, opened));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
DateTime chkStart = DateTime.UtcNow;
|
|
|
|
|
|
_sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding);
|
|
|
|
|
|
_sidecarClass.InitProgressEvent += InitProgress;
|
|
|
|
|
|
_sidecarClass.UpdateProgressEvent += UpdateProgress;
|
|
|
|
|
|
_sidecarClass.EndProgressEvent += EndProgress;
|
|
|
|
|
|
_sidecarClass.InitProgressEvent2 += InitProgress2;
|
|
|
|
|
|
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
|
|
|
|
|
|
_sidecarClass.EndProgressEvent2 += EndProgress2;
|
|
|
|
|
|
_sidecarClass.UpdateStatusEvent += UpdateStatus;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Metadata sidecar = _sidecarClass.Create();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
end = DateTime.UtcNow;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!_aborted)
|
2020-05-14 03:43:21 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
totalChkDuration = (end - chkStart).TotalMilliseconds;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0_seconds,
|
|
|
|
|
|
(end - chkStart).TotalSeconds));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0_KiB_sec,
|
|
|
|
|
|
blockSize * (double)(blocks + 1) / 1024 /
|
|
|
|
|
|
(totalChkDuration / 1000)));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0_seconds, (end - chkStart).TotalSeconds);
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0_KiB_sec,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_preSidecar != null)
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
_preSidecar.BlockMedias = sidecar.BlockMedias;
|
|
|
|
|
|
sidecar = _preSidecar;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
List<(ulong start, string type)> filesystems = new();
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
if(sidecar.BlockMedias[0].FileSystemInformation != null)
|
|
|
|
|
|
filesystems.AddRange(from partition in sidecar.BlockMedias[0].FileSystemInformation
|
2022-03-07 07:36:44 +00:00
|
|
|
|
where partition.FileSystems != null from fileSystem in partition.FileSystems
|
2022-03-06 13:29:38 +00:00
|
|
|
|
select (partition.StartSector, fileSystem.Type));
|
|
|
|
|
|
|
|
|
|
|
|
if(filesystems.Count > 0)
|
|
|
|
|
|
foreach(var filesystem in filesystems.Select(o => new
|
|
|
|
|
|
{
|
|
|
|
|
|
o.start,
|
|
|
|
|
|
o.type
|
|
|
|
|
|
}).Distinct())
|
2021-08-03 14:12:59 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1,
|
|
|
|
|
|
filesystem.type, filesystem.start));
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, filesystem.type,
|
|
|
|
|
|
filesystem.start);
|
2021-08-03 14:12:59 +01:00
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
(string type, string subType) xmlType = CommonTypes.Metadata.MediaType.MediaTypeToString(dskType);
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].MediaType = xmlType.type;
|
|
|
|
|
|
sidecar.BlockMedias[0].MediaSubType = xmlType.subType;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(!_dev.IsRemovable ||
|
|
|
|
|
|
_dev.IsUsb)
|
|
|
|
|
|
if(_dev.Type == DeviceType.ATAPI)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Interface = "ATAPI";
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else if(_dev.IsUsb)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Interface = "USB";
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else if(_dev.IsFireWire)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Interface = "FireWire";
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Interface = "SCSI";
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].LogicalBlocks = blocks;
|
|
|
|
|
|
sidecar.BlockMedias[0].PhysicalBlockSize = physicalBlockSize;
|
|
|
|
|
|
sidecar.BlockMedias[0].LogicalBlockSize = blockSize;
|
|
|
|
|
|
sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer;
|
|
|
|
|
|
sidecar.BlockMedias[0].Model = _dev.Model;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!_private)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Serial = _dev.Serial;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Size = blocks * blockSize;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_dev.IsRemovable)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].DumpHardware = _resume.Tries;
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
|
|
|
|
|
|
|
|
|
|
|
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
|
|
|
|
|
|
{
|
|
|
|
|
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
|
|
|
|
|
WriteIndented = true
|
|
|
|
|
|
});
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
jsonFs.Close();
|
2020-05-14 03:43:21 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
UpdateStatus?.Invoke("");
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.
|
|
|
|
|
|
Invoke(string.Format(Localization.Core.Took_a_total_of_0_seconds_1_processing_commands_2_checksumming_3_writing_4_closing,
|
|
|
|
|
|
(end - start).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000,
|
|
|
|
|
|
imageWriteDuration, (closeEnd - closeStart).TotalSeconds));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0_MiB_sec,
|
|
|
|
|
|
blockSize * (double)(blocks + 1) / 1048576 / (totalDuration / 1000)));
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(maxSpeed > 0)
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0_MiB_sec, maxSpeed));
|
2020-06-25 01:47:25 +01:00
|
|
|
|
|
2022-11-13 20:46:24 +00:00
|
|
|
|
if(minSpeed is > 0 and < double.MaxValue)
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0_MiB_sec, minSpeed));
|
2020-06-25 01:47:25 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
UpdateStatus?.Invoke("");
|
2020-05-14 03:43:21 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Statistics.AddMedia(dskType, true);
|
2020-05-14 03:43:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|