Refactor sector writing methods to include SectorStatus parameter and update related logic

This commit is contained in:
2025-10-22 20:25:23 +01:00
parent 0ac2a48fb6
commit ce0e0dff22
55 changed files with 927 additions and 676 deletions

View File

@@ -197,7 +197,7 @@ public partial class Dump
IbgLog ibgLog;
double duration;
bool ret = true;
var ret = true;
if(_dev.IsUsb &&
_dev.UsbDescriptors != null &&
@@ -294,7 +294,7 @@ public partial class Dump
_mediaGraph?.PaintSectorsBad(_resume.BadBlocks);
}
bool newTrim = false;
var newTrim = false;
_dumpStopwatch.Restart();
_speedStopwatch.Reset();
@@ -336,7 +336,13 @@ public partial class Dump
{
mhddLog.Write(i, duration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
outputFormat.WriteSectors(cmdBuf, i, blocksToRead);
outputFormat.WriteSectors(cmdBuf,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead)
.ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead);
@@ -350,7 +356,13 @@ public partial class Dump
mhddLog.Write(i, duration < 500 ? 65535 : duration, _skip);
ibgLog.Write(i, 0);
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectors(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)blocksToRead)
.ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
UpdateProgress?.Invoke(Localization.Core.Skipping_0_blocks_from_errored_block_1,
@@ -436,7 +448,7 @@ public partial class Dump
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputFormat.WriteSector(cmdBuf, badSector);
outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
}
@@ -453,8 +465,8 @@ public partial class Dump
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
int pass = 1;
bool forward = true;
var pass = 1;
var forward = true;
InitProgress?.Invoke();
repeatRetryLba:
@@ -504,7 +516,7 @@ public partial class Dump
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputFormat.WriteSector(cmdBuf, badSector);
outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
UpdateStatus?.Invoke(string.Format(Localization.Core
@@ -512,7 +524,7 @@ public partial class Dump
badSector,
pass));
}
else if(_persistent) outputFormat.WriteSector(cmdBuf, badSector);
else if(_persistent) outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Errored);
}
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
@@ -613,7 +625,9 @@ public partial class Dump
mhddLog.Write(currentBlock, duration);
ibgLog.Write(currentBlock, currentSpeed * 1024);
outputFormat.WriteSector(cmdBuf, (ulong)((cy * heads + hd) * sectors + (sc - 1)));
outputFormat.WriteSector(cmdBuf,
(ulong)((cy * heads + hd) * sectors + (sc - 1)),
SectorStatus.Dumped);
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(currentBlock);
@@ -627,7 +641,8 @@ public partial class Dump
ibgLog.Write(currentBlock, 0);
outputFormat.WriteSector(new byte[blockSize],
(ulong)((cy * heads + hd) * sectors + (sc - 1)));
(ulong)((cy * heads + hd) * sectors + (sc - 1)),
SectorStatus.Errored);
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
}

View File

@@ -38,6 +38,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.Core.Logging;
@@ -60,7 +61,7 @@ partial class Dump
byte[] syncMark = [0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00];
byte[] testMark = new byte[12];
var testMark = new byte[12];
Array.Copy(sector, 0, testMark, 0, 12);
return syncMark.SequenceEqual(testMark) && (sector[0xF] == 0 || sector[0xF] == 1 || sector[0xF] == 2);
@@ -79,9 +80,9 @@ partial class Dump
byte[] syncMark = [0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00];
byte[] testMark = new byte[12];
var testMark = new byte[12];
for(int i = 0; i <= 2336; i++)
for(var i = 0; i <= 2336; i++)
{
Array.Copy(sector, i, testMark, 0, 12);
@@ -179,7 +180,7 @@ partial class Dump
break;
}
uint firstSectorToRead = (uint)i;
var firstSectorToRead = (uint)i;
blocksToRead = _maximumReadable;
@@ -288,8 +289,8 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
byte[] data = new byte[sectorSize];
byte[] sub = new byte[subSize];
var data = new byte[sectorSize];
var sub = new byte[subSize];
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
@@ -297,7 +298,10 @@ partial class Dump
if(cdiReadyReadAsAudio) data = Sector.Scramble(data);
outputOptical.WriteSectorsLong(data, i + r, 1);
outputOptical.WriteSectorsLong(data,
i + r,
1,
Enumerable.Repeat(SectorStatus.Dumped, 1).ToArray());
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
desiredSubchannel,
@@ -329,7 +333,7 @@ partial class Dump
}
}
else
outputOptical.WriteSectorsLong(cmdBuf, i + r, 1);
outputOptical.WriteSectorsLong(cmdBuf, i + r, 1, [SectorStatus.Dumped]);
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
@@ -386,11 +390,11 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
byte[] data = new byte[sectorSize * blocksToRead];
byte[] sub = new byte[subSize * blocksToRead];
byte[] tmpData = new byte[sectorSize];
var data = new byte[sectorSize * blocksToRead];
var sub = new byte[subSize * blocksToRead];
var tmpData = new byte[sectorSize];
for(int b = 0; b < blocksToRead; b++)
for(var b = 0; b < blocksToRead; b++)
{
if(cdiReadyReadAsAudio)
{
@@ -404,7 +408,10 @@ partial class Dump
Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize);
}
outputOptical.WriteSectorsLong(data, i, blocksToRead);
outputOptical.WriteSectorsLong(data,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
desiredSubchannel,
@@ -447,20 +454,28 @@ partial class Dump
{
if(cdiReadyReadAsAudio)
{
byte[] tmpData = new byte[sectorSize];
byte[] data = new byte[sectorSize * blocksToRead];
var tmpData = new byte[sectorSize];
var data = new byte[sectorSize * blocksToRead];
for(int b = 0; b < blocksToRead; b++)
for(var b = 0; b < blocksToRead; b++)
{
Array.Copy(cmdBuf, (int)(b * sectorSize), tmpData, 0, sectorSize);
tmpData = Sector.Scramble(tmpData);
Array.Copy(tmpData, 0, data, sectorSize * b, sectorSize);
}
outputOptical.WriteSectorsLong(data, i, blocksToRead);
outputOptical.WriteSectorsLong(data,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead)
.ToArray());
}
else
outputOptical.WriteSectorsLong(cmdBuf, i, blocksToRead);
outputOptical.WriteSectorsLong(cmdBuf,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead)
.ToArray());
}
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;

View File

@@ -103,7 +103,7 @@ partial class Dump
{
ulong sectorSpeedStart = 0; // Used to calculate correct speed
uint blocksToRead; // How many sectors to read at once
bool sense = true; // Sense indicator
var sense = true; // Sense indicator
byte[] cmdBuf = null; // Data buffer
ReadOnlySpan<byte> senseBuf = null; // Sense buffer
double cmdDuration = 0; // Command execution time
@@ -122,10 +122,10 @@ partial class Dump
InitProgress?.Invoke();
int currentReadSpeed = _speed;
bool crossingLeadOut = false;
bool failedCrossingLeadOut = false;
bool skippingLead = false;
int currentReadSpeed = _speed;
var crossingLeadOut = false;
var failedCrossingLeadOut = false;
var skippingLead = false;
for(ulong i = _resume.NextBlock; (long)i <= lastSector; i += blocksToRead)
{
@@ -145,7 +145,7 @@ partial class Dump
if((long)i > lastSector) break;
uint firstSectorToRead = (uint)i;
var firstSectorToRead = (uint)i;
Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => i >= t.StartSector);
@@ -310,10 +310,10 @@ partial class Dump
// Try to workaround firmware
if(decSense?.ASC == 0x64)
{
bool goBackTrackTypeChange = false;
var goBackTrackTypeChange = false;
// Go one for one as the drive does not tell us which one failed
for(int bi = 0; bi < blocksToRead; bi++)
for(var bi = 0; bi < blocksToRead; bi++)
{
_speedStopwatch.Start();
@@ -584,7 +584,7 @@ partial class Dump
if(_supportsPlextorD8)
{
int adjustment = 0;
var adjustment = 0;
if(offsetBytes < 0) adjustment = -sectorsForOffset;
@@ -604,7 +604,7 @@ partial class Dump
if(!sense)
{
uint sectorsForFix = (uint)(1 + sectorsForOffset);
var sectorsForFix = (uint)(1 + sectorsForOffset);
FixOffsetData(offsetBytes,
sectorSize,
@@ -630,7 +630,7 @@ partial class Dump
{
case 0:
for(int c = 16; c < 2352; c++)
for(var c = 16; c < 2352; c++)
{
if(cmdBuf[c] == 0x00) continue;
@@ -768,28 +768,36 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
byte[] data = new byte[sectorSize];
byte[] sub = new byte[subSize];
var data = new byte[sectorSize];
var sub = new byte[subSize];
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
Array.Copy(cmdBuf, sectorSize, sub, 0, subSize);
if(supportsLongSectors)
outputFormat.WriteSectorsLong(data, i + r, 1);
outputFormat.WriteSectorsLong(data,
i + r,
1,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead)
.ToArray());
else
{
var cooked = new MemoryStream();
byte[] sector = new byte[sectorSize];
var cooked = new MemoryStream();
var sector = new byte[sectorSize];
for(int b = 0; b < blocksToRead; b++)
for(var b = 0; b < blocksToRead; b++)
{
Array.Copy(cmdBuf, (int)(0 + b * blockSize), sector, 0, sectorSize);
byte[] cookedSector = Sector.GetUserData(sector);
cooked.Write(cookedSector, 0, cookedSector.Length);
}
outputFormat.WriteSectors(cooked.ToArray(), i, blocksToRead);
outputFormat.WriteSectors(cooked.ToArray(),
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead)
.ToArray());
}
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
@@ -836,20 +844,24 @@ partial class Dump
else
{
if(supportsLongSectors)
outputFormat.WriteSectorsLong(cmdBuf, i + r, 1);
outputFormat.WriteSectorsLong(cmdBuf, i + r, 1, [SectorStatus.Dumped]);
else
{
var cooked = new MemoryStream();
byte[] sector = new byte[sectorSize];
var cooked = new MemoryStream();
var sector = new byte[sectorSize];
for(int b = 0; b < blocksToRead; b++)
for(var b = 0; b < blocksToRead; b++)
{
Array.Copy(cmdBuf, (int)(b * sectorSize), sector, 0, sectorSize);
byte[] cookedSector = Sector.GetUserData(sector);
cooked.Write(cookedSector, 0, cookedSector.Length);
}
outputFormat.WriteSectors(cooked.ToArray(), i, blocksToRead);
outputFormat.WriteSectors(cooked.ToArray(),
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead)
.ToArray());
}
}
@@ -866,7 +878,7 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
outputFormat.WriteSectorsLong(new byte[sectorSize], i + r, 1);
outputFormat.WriteSectorsLong(new byte[sectorSize], i + r, 1, [SectorStatus.Errored]);
if(desiredSubchannel != MmcSubchannel.None)
{
@@ -879,13 +891,16 @@ partial class Dump
else
{
if(supportsLongSectors)
outputFormat.WriteSectorsLong(new byte[blockSize], i + r, 1);
outputFormat.WriteSectorsLong(new byte[blockSize], i + r, 1, [SectorStatus.Errored]);
else
{
if(cmdBuf.Length % sectorSize == 0)
outputFormat.WriteSectors(new byte[2048], i + r, 1);
outputFormat.WriteSectors(new byte[2048], i + r, 1, [SectorStatus.Errored]);
else
outputFormat.WriteSectorsLong(new byte[blockSize], i + r, 1);
outputFormat.WriteSectorsLong(new byte[blockSize],
i + r,
1,
[SectorStatus.Errored]);
}
}
@@ -926,7 +941,7 @@ partial class Dump
{
if(crossingLeadOut && failedCrossingLeadOut)
{
byte[] tmp = new byte[cmdBuf.Length + blockSize];
var tmp = new byte[cmdBuf.Length + blockSize];
Array.Copy(cmdBuf, 0, tmp, 0, cmdBuf.Length);
}
@@ -951,10 +966,10 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
byte[] data = new byte[sectorSize * blocksToRead];
byte[] sub = new byte[subSize * blocksToRead];
var data = new byte[sectorSize * blocksToRead];
var sub = new byte[subSize * blocksToRead];
for(int b = 0; b < blocksToRead; b++)
for(var b = 0; b < blocksToRead; b++)
{
Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize);
@@ -962,20 +977,27 @@ partial class Dump
}
if(supportsLongSectors)
outputFormat.WriteSectorsLong(data, i, blocksToRead);
outputFormat.WriteSectorsLong(data,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead)
.ToArray());
else
{
var cooked = new MemoryStream();
byte[] sector = new byte[sectorSize];
var cooked = new MemoryStream();
var sector = new byte[sectorSize];
for(int b = 0; b < blocksToRead; b++)
for(var b = 0; b < blocksToRead; b++)
{
Array.Copy(cmdBuf, (int)(0 + b * blockSize), sector, 0, sectorSize);
byte[] cookedSector = Sector.GetUserData(sector);
cooked.Write(cookedSector, 0, cookedSector.Length);
}
outputFormat.WriteSectors(cooked.ToArray(), i, blocksToRead);
outputFormat.WriteSectors(cooked.ToArray(),
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
}
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
@@ -1021,20 +1043,27 @@ partial class Dump
else
{
if(supportsLongSectors)
outputFormat.WriteSectorsLong(cmdBuf, i, blocksToRead);
outputFormat.WriteSectorsLong(cmdBuf,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead)
.ToArray());
else
{
var cooked = new MemoryStream();
byte[] sector = new byte[sectorSize];
var cooked = new MemoryStream();
var sector = new byte[sectorSize];
for(int b = 0; b < blocksToRead; b++)
for(var b = 0; b < blocksToRead; b++)
{
Array.Copy(cmdBuf, (int)(b * sectorSize), sector, 0, sectorSize);
byte[] cookedSector = Sector.GetUserData(sector);
cooked.Write(cookedSector, 0, cookedSector.Length);
}
outputFormat.WriteSectors(cooked.ToArray(), i, blocksToRead);
outputFormat.WriteSectors(cooked.ToArray(),
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
}
}
@@ -1066,7 +1095,10 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
outputFormat.WriteSectorsLong(new byte[sectorSize * _skip], i, _skip);
outputFormat.WriteSectorsLong(new byte[sectorSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
if(desiredSubchannel != MmcSubchannel.None)
{
@@ -1079,13 +1111,23 @@ partial class Dump
else
{
if(supportsLongSectors)
outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectorsLong(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
else
{
if(cmdBuf.Length % sectorSize == 0)
outputFormat.WriteSectors(new byte[2048 * _skip], i, _skip);
outputFormat.WriteSectors(new byte[2048 * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
else
outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectorsLong(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip)
.ToArray());
}
}

View File

@@ -39,6 +39,7 @@ using System.Collections.Generic;
using System.Linq;
using Aaru.Checksums;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs.Devices.SCSI;
@@ -80,7 +81,7 @@ partial class Dump
ref string mcn, HashSet<int> subchannelExtents,
Dictionary<byte, int> smallestPregapLbaPerTrack, bool supportsLongSectors)
{
bool sense = true; // Sense indicator
var sense = true; // Sense indicator
byte[] cmdBuf = null; // Data buffer
double cmdDuration; // Command execution time
const uint sectorSize = 2352; // Full sector size
@@ -98,9 +99,9 @@ partial class Dump
if(_resume.BadBlocks.Count <= 0 || _aborted || _retryPasses <= 0) return;
int pass = 1;
bool forward = true;
bool runningPersistent = false;
var pass = 1;
var forward = true;
var runningPersistent = false;
Modes.ModePage? currentModePage = null;
byte[] md6;
@@ -217,7 +218,7 @@ partial class Dump
ulong[] tmpArray = _resume.BadBlocks.ToArray();
List<ulong> sectorsNotEvenPartial = [];
for(int i = 0; i < tmpArray.Length; i++)
for(var i = 0; i < tmpArray.Length; i++)
{
ulong badSector = tmpArray[i];
@@ -255,7 +256,7 @@ partial class Dump
Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector);
byte sectorsToReRead = 1;
uint badSectorToReRead = (uint)badSector;
var badSectorToReRead = (uint)badSector;
if(_fixOffset && audioExtents.Contains(badSector) && offsetBytes != 0)
{
@@ -421,7 +422,7 @@ partial class Dump
{
case 0:
for(int c = 16; c < 2352; c++)
for(var c = 16; c < 2352; c++)
{
if(cmdBuf[c] == 0x00) continue;
@@ -465,8 +466,9 @@ partial class Dump
// MEDIUM ERROR, retry with ignore error below
if(decSense is { ASC: 0x11 })
if(!sectorsNotEvenPartial.Contains(badSector))
sectorsNotEvenPartial.Add(badSector);
{
if(!sectorsNotEvenPartial.Contains(badSector)) sectorsNotEvenPartial.Add(badSector);
}
}
// Because one block has been partially used to fix the offset
@@ -502,15 +504,15 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
byte[] data = new byte[sectorSize];
byte[] sub = new byte[subSize];
var data = new byte[sectorSize];
var sub = new byte[subSize];
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
Array.Copy(cmdBuf, sectorSize, sub, 0, subSize);
if(supportsLongSectors)
outputOptical.WriteSectorLong(data, badSector);
outputOptical.WriteSectorLong(data, badSector, SectorStatus.Dumped);
else
outputOptical.WriteSector(Sector.GetUserData(data), badSector);
outputOptical.WriteSector(Sector.GetUserData(data), badSector, SectorStatus.Dumped);
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
desiredSubchannel,
@@ -541,9 +543,9 @@ partial class Dump
else
{
if(supportsLongSectors)
outputOptical.WriteSectorLong(cmdBuf, badSector);
outputOptical.WriteSectorLong(cmdBuf, badSector, SectorStatus.Dumped);
else
outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector);
outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, SectorStatus.Dumped);
}
}
@@ -605,7 +607,7 @@ partial class Dump
InitProgress?.Invoke();
for(int i = 0; i < sectorsNotEvenPartial.Count; i++)
for(var i = 0; i < sectorsNotEvenPartial.Count; i++)
{
ulong badSector = sectorsNotEvenPartial[i];
@@ -655,15 +657,15 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
byte[] data = new byte[sectorSize];
byte[] sub = new byte[subSize];
var data = new byte[sectorSize];
var sub = new byte[subSize];
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
Array.Copy(cmdBuf, sectorSize, sub, 0, subSize);
if(supportsLongSectors)
outputOptical.WriteSectorLong(data, badSector);
outputOptical.WriteSectorLong(data, badSector, SectorStatus.Errored);
else
outputOptical.WriteSector(Sector.GetUserData(data), badSector);
outputOptical.WriteSector(Sector.GetUserData(data), badSector, SectorStatus.Errored);
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
desiredSubchannel,
@@ -694,9 +696,9 @@ partial class Dump
else
{
if(supportsLongSectors)
outputOptical.WriteSectorLong(cmdBuf, badSector);
outputOptical.WriteSectorLong(cmdBuf, badSector, SectorStatus.Errored);
else
outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector);
outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, SectorStatus.Errored);
}
}
@@ -741,7 +743,7 @@ partial class Dump
Dictionary<byte, string> isrcs, ref string mcn, HashSet<int> subchannelExtents,
Dictionary<byte, int> smallestPregapLbaPerTrack)
{
bool sense = true; // Sense indicator
var sense = true; // Sense indicator
byte[] cmdBuf = null; // Data buffer
double cmdDuration; // Command execution time
ReadOnlySpan<byte> senseBuf = null; // Sense buffer
@@ -760,8 +762,8 @@ partial class Dump
if(_aborted) return;
int pass = 1;
bool forward = true;
var pass = 1;
var forward = true;
InitProgress?.Invoke();
@@ -777,7 +779,7 @@ partial class Dump
foreach(int bs in tmpArray)
{
uint badSector = (uint)bs;
var badSector = (uint)bs;
Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector);

View File

@@ -92,7 +92,7 @@ partial class Dump
{
byte[] cmdBuf = null; // Data buffer
const uint sectorSize = 2352; // Full sector size
bool sense = true; // Sense indicator
var sense = true; // Sense indicator
ReadOnlySpan<byte> senseBuf = null;
var outputOptical = _outputPlugin as IWritableOpticalImage;
@@ -205,17 +205,21 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
byte[] data = new byte[sectorSize * _maximumReadable];
byte[] sub = new byte[subSize * _maximumReadable];
var data = new byte[sectorSize * _maximumReadable];
var sub = new byte[subSize * _maximumReadable];
for(int b = 0; b < _maximumReadable; b++)
for(var b = 0; b < _maximumReadable; b++)
{
Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize);
Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize);
}
outputOptical.WriteSectorsLong(data, i, _maximumReadable);
outputOptical.WriteSectorsLong(data,
i,
_maximumReadable,
Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable)
.ToArray());
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
desiredSubchannel,
@@ -247,7 +251,11 @@ partial class Dump
}
}
else
outputOptical.WriteSectors(cmdBuf, i, _maximumReadable);
outputOptical.WriteSectors(cmdBuf,
i,
_maximumReadable,
Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable)
.ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
}
@@ -263,7 +271,7 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1);
outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1, new SectorStatus[1]);
outputOptical.WriteSectorsTag(new byte[subSize * _skip],
i,
@@ -271,7 +279,7 @@ partial class Dump
SectorTagType.CdSectorSubchannel);
}
else
outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1);
outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1, new SectorStatus[1]);
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
@@ -331,7 +339,7 @@ partial class Dump
{
byte[] cmdBuf = null; // Data buffer
const uint sectorSize = 2352; // Full sector size
bool sense = true; // Sense indicator
var sense = true; // Sense indicator
ReadOnlySpan<byte> senseBuf = null;
var outputOptical = _outputPlugin as IWritableOpticalImage;
@@ -444,17 +452,21 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
byte[] data = new byte[sectorSize * _maximumReadable];
byte[] sub = new byte[subSize * _maximumReadable];
var data = new byte[sectorSize * _maximumReadable];
var sub = new byte[subSize * _maximumReadable];
for(int b = 0; b < _maximumReadable; b++)
for(var b = 0; b < _maximumReadable; b++)
{
Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize);
Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize);
}
outputOptical.WriteSectorsLong(data, i, _maximumReadable);
outputOptical.WriteSectorsLong(data,
i,
_maximumReadable,
Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable)
.ToArray());
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
desiredSubchannel,
@@ -486,7 +498,11 @@ partial class Dump
}
}
else
outputOptical.WriteSectors(cmdBuf, i, _maximumReadable);
outputOptical.WriteSectors(cmdBuf,
i,
_maximumReadable,
Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable)
.ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
}
@@ -502,7 +518,7 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1);
outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1, new SectorStatus[1]);
if(desiredSubchannel != MmcSubchannel.None)
{
@@ -513,7 +529,7 @@ partial class Dump
}
}
else
outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1);
outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1, new SectorStatus[1]);
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;

View File

@@ -72,7 +72,7 @@ partial class Dump
if(track is null) continue;
byte[] sector = new byte[2352];
var sector = new byte[2352];
switch(track.Type)
{
@@ -102,9 +102,9 @@ partial class Dump
}
if(supportsLongSectors)
outputOptical.WriteSectorLong(sector, s);
outputOptical.WriteSectorLong(sector, s, SectorStatus.Dumped);
else
outputOptical.WriteSector(Sector.GetUserData(sector), s);
outputOptical.WriteSector(Sector.GetUserData(sector), s, SectorStatus.Dumped);
_resume.BadBlocks.Remove(s);
extents.Add(s);

View File

@@ -39,6 +39,7 @@ using System.Collections.Generic;
using System.Linq;
using Aaru.Checksums;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.Core.Logging;
@@ -84,7 +85,7 @@ partial class Dump
Dictionary<byte, string> isrcs, ref string mcn, HashSet<int> subchannelExtents,
Dictionary<byte, int> smallestPregapLbaPerTrack)
{
bool sense = true; // Sense indicator
var sense = true; // Sense indicator
byte[] cmdBuf = null; // Data buffer
double cmdDuration = 0; // Command execution time
const uint sectorSize = 2352; // Full sector size
@@ -109,7 +110,7 @@ partial class Dump
trimStart:
ulong[] tmpArray = _resume.BadBlocks.ToArray();
for(int b = 0; b < tmpArray.Length; b++)
for(var b = 0; b < tmpArray.Length; b++)
{
ulong badSector = tmpArray[b];
@@ -126,7 +127,7 @@ partial class Dump
Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector);
byte sectorsToTrim = 1;
uint badSectorToRead = (uint)badSector;
var badSectorToRead = (uint)badSector;
if(_fixOffset && audioExtents.Contains(badSector) && offsetBytes != 0)
{
@@ -290,7 +291,7 @@ partial class Dump
{
case 0:
for(int c = 16; c < 2352; c++)
for(var c = 16; c < 2352; c++)
{
if(cmdBuf[c] == 0x00) continue;
@@ -417,15 +418,15 @@ partial class Dump
if(supportedSubchannel != MmcSubchannel.None)
{
byte[] data = new byte[sectorSize];
byte[] sub = new byte[subSize];
var data = new byte[sectorSize];
var sub = new byte[subSize];
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
Array.Copy(cmdBuf, sectorSize, sub, 0, subSize);
if(supportsLongSectors)
outputOptical.WriteSectorLong(data, badSector);
outputOptical.WriteSectorLong(data, badSector, SectorStatus.Dumped);
else
outputOptical.WriteSector(Sector.GetUserData(data), badSector);
outputOptical.WriteSector(Sector.GetUserData(data), badSector, SectorStatus.Dumped);
ulong trkStartBefore = track.StartSector;
@@ -467,9 +468,9 @@ partial class Dump
}
if(supportsLongSectors)
outputOptical.WriteSectorLong(cmdBuf, badSector);
outputOptical.WriteSectorLong(cmdBuf, badSector, SectorStatus.Dumped);
else
outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector);
outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, SectorStatus.Dumped);
}
_trimStopwatch.Stop();

View File

@@ -230,7 +230,7 @@ partial class Dump
if(decMode?.Pages != null)
{
bool setGeometry = false;
var setGeometry = false;
foreach(Modes.ModePage page in decMode.Value.Pages)
{
@@ -327,7 +327,7 @@ partial class Dump
_mediaGraph?.PaintSectorsBad(_resume.BadBlocks);
}
bool newTrim = false;
var newTrim = false;
_speedStopwatch.Reset();
ulong sectorSpeedStart = 0;
InitProgress?.Invoke();
@@ -374,7 +374,12 @@ partial class Dump
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
_writeStopwatch.Restart();
outputFormat.WriteSectors(readBuffer, i, blocksToRead);
outputFormat.WriteSectors(readBuffer,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead);
@@ -388,7 +393,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectors(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b);
@@ -470,7 +480,7 @@ partial class Dump
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputFormat.WriteSector(readBuffer, badSector);
outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
}
@@ -487,9 +497,9 @@ partial class Dump
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
int pass = 1;
bool forward = true;
bool runningPersistent = false;
var pass = 1;
var forward = true;
var runningPersistent = false;
Modes.ModePage? currentModePage = null;
byte[] md6;
@@ -637,14 +647,14 @@ partial class Dump
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputFormat.WriteSector(readBuffer, badSector);
outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1,
badSector,
pass));
}
else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector);
else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Errored);
}
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)

View File

@@ -86,7 +86,7 @@ public partial class Dump
return;
}
uint blocks = (uint)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]);
var blocks = (uint)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]);
blocks++;
@@ -191,7 +191,7 @@ public partial class Dump
_mediaGraph?.PaintSectorsBad(_resume.BadBlocks);
}
bool newTrim = false;
var newTrim = false;
_speedStopwatch.Restart();
ulong sectorSpeedStart = 0;
@@ -246,7 +246,12 @@ public partial class Dump
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
_writeStopwatch.Restart();
outputFormat.WriteSectors(readBuffer, i, blocksToRead);
outputFormat.WriteSectors(readBuffer,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead);
@@ -262,7 +267,12 @@ public partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectors(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b);
@@ -363,7 +373,7 @@ public partial class Dump
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputFormat.WriteSector(readBuffer, badSector);
outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
}
@@ -380,9 +390,9 @@ public partial class Dump
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
int pass = 1;
bool forward = true;
bool runningPersistent = false;
var pass = 1;
var forward = true;
var runningPersistent = false;
Modes.ModePage? currentModePage = null;
byte[] md6;
@@ -562,14 +572,14 @@ public partial class Dump
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputFormat.WriteSector(readBuffer, badSector);
outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1,
badSector,
pass));
}
else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector);
else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Errored);
}
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)

View File

@@ -96,11 +96,11 @@ public partial class Dump
return;
}
ushort fatStart = (ushort)((readBuffer[0x0F] << 8) + readBuffer[0x0E]);
ushort sectorsPerFat = (ushort)((readBuffer[0x17] << 8) + readBuffer[0x16]);
ushort rootStart = (ushort)(sectorsPerFat * 2 + fatStart);
ushort rootSize = (ushort)(((readBuffer[0x12] << 8) + readBuffer[0x11]) * 32 / 512);
ushort umdStart = (ushort)(rootStart + rootSize);
var fatStart = (ushort)((readBuffer[0x0F] << 8) + readBuffer[0x0E]);
var sectorsPerFat = (ushort)((readBuffer[0x17] << 8) + readBuffer[0x16]);
var rootStart = (ushort)(sectorsPerFat * 2 + fatStart);
var rootSize = (ushort)(((readBuffer[0x12] << 8) + readBuffer[0x11]) * 32 / 512);
var umdStart = (ushort)(rootStart + rootSize);
UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_root_directory_in_sector_0, rootStart));
@@ -126,7 +126,7 @@ public partial class Dump
return;
}
uint umdSizeInBytes = BitConverter.ToUInt32(readBuffer, 0x3C);
var umdSizeInBytes = BitConverter.ToUInt32(readBuffer, 0x3C);
ulong blocks = umdSizeInBytes / blockSize;
string mediaPartNumber = Encoding.ASCII.GetString(readBuffer, 0, 11).Trim();
@@ -229,7 +229,7 @@ public partial class Dump
_mediaGraph?.PaintSectorsBad(_resume.BadBlocks);
}
bool newTrim = false;
var newTrim = false;
_speedStopwatch.Reset();
ulong sectorSpeedStart = 0;
@@ -285,7 +285,12 @@ public partial class Dump
{
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
outputOptical.WriteSectors(readBuffer, i, blocksToRead);
outputOptical.WriteSectors(readBuffer,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead);
@@ -300,7 +305,11 @@ public partial class Dump
if(i + _skip > blocks) _skip = (uint)(blocks - i);
// Write empty data
outputOptical.WriteSectors(new byte[blockSize * _skip], i, _skip);
outputOptical.WriteSectors(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b);
@@ -400,7 +409,7 @@ public partial class Dump
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputOptical.WriteSector(readBuffer, badSector);
outputOptical.WriteSector(readBuffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
}
@@ -417,9 +426,9 @@ public partial class Dump
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
int pass = 1;
bool forward = true;
bool runningPersistent = false;
var pass = 1;
var forward = true;
var runningPersistent = false;
Modes.ModePage? currentModePage = null;
byte[] md6;
@@ -576,14 +585,14 @@ public partial class Dump
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputOptical.WriteSector(readBuffer, badSector);
outputOptical.WriteSector(readBuffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1,
badSector,
pass));
}
else if(runningPersistent) outputOptical.WriteSector(readBuffer, badSector);
else if(runningPersistent) outputOptical.WriteSector(readBuffer, badSector, SectorStatus.Errored);
}
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)

View File

@@ -285,9 +285,8 @@ partial class Dump
Modes.DecodedMode? decMode = null;
if(!sense && !_dev.Error)
{
if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType);
}
if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue)
decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType);
UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6);
@@ -315,9 +314,8 @@ partial class Dump
if(sense || _dev.Error) sense = _dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration);
if(!sense && !_dev.Error)
{
if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType);
}
if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType);
// TODO: Check partitions page
if(decMode.HasValue)
@@ -361,12 +359,12 @@ partial class Dump
UpdateStatus?.Invoke(string.Format(Localization.Core.Media_identified_as_0, dskType.Humanize()));
bool endOfMedia = false;
var endOfMedia = false;
ulong currentBlock = 0;
uint currentFile = 0;
byte currentPartition = 0;
byte totalPartitions = 1; // TODO: Handle partitions.
bool fixedLen = false;
var fixedLen = false;
uint transferLen = blockSize;
firstRead:
@@ -601,8 +599,8 @@ partial class Dump
return;
}
bool canLocateLong = false;
bool canLocate = false;
var canLocateLong = false;
var canLocate = false;
UpdateStatus?.Invoke(Localization.Core.Positioning_tape_to_block_1);
@@ -1092,7 +1090,7 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputTape.WriteSector(new byte[blockSize], currentBlock);
outputTape.WriteSector(new byte[blockSize], currentBlock, SectorStatus.NotDumped);
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration);
@@ -1104,7 +1102,7 @@ partial class Dump
mhddLog.Write(currentBlock, duration);
ibgLog.Write(currentBlock, currentSpeed * 1024);
_writeStopwatch.Restart();
outputTape.WriteSector(cmdBuf, currentBlock);
outputTape.WriteSector(cmdBuf, currentBlock, SectorStatus.Dumped);
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(currentBlock, 1, true);
}
@@ -1167,8 +1165,8 @@ partial class Dump
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0 && (canLocate || canLocateLong))
{
int pass = 1;
bool forward = false;
var pass = 1;
var forward = false;
const bool runningPersistent = false;
Modes.ModePage? currentModePage;
@@ -1299,13 +1297,13 @@ partial class Dump
{
_resume.BadBlocks.Remove(badBlock);
extents.Add(badBlock);
outputTape.WriteSector(cmdBuf, badBlock);
outputTape.WriteSector(cmdBuf, badBlock, SectorStatus.Dumped);
UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1,
badBlock,
pass));
}
else if(runningPersistent) outputTape.WriteSector(cmdBuf, badBlock);
else if(runningPersistent) outputTape.WriteSector(cmdBuf, badBlock, SectorStatus.Errored);
}
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)

View File

@@ -118,7 +118,7 @@ partial class Dump
_writeStopwatch.Restart();
byte[] tmpBuf;
byte[] cmi = new byte[blocksToRead];
var cmi = new byte[blocksToRead];
for(uint j = 0; j < blocksToRead; j++)
{
@@ -160,7 +160,10 @@ partial class Dump
buffer = CSS.DecryptSectorLong(buffer, titleKey, cmi, blocksToRead);
}
outputFormat.WriteSectorsLong(buffer, i, blocksToRead);
outputFormat.WriteSectorsLong(buffer,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
@@ -175,7 +178,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectorsLong(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b);

View File

@@ -189,7 +189,12 @@ partial class Dump
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
_writeStopwatch.Restart();
outputFormat.WriteSectors(buffer, i, blocksToRead);
outputFormat.WriteSectors(buffer,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead);
@@ -217,7 +222,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectors(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b);

View File

@@ -57,9 +57,9 @@ partial class Dump
void RetrySbcData(Reader scsiReader, DumpHardware currentTry, ExtentsULong extents, ref double totalDuration,
ExtentsULong blankExtents, byte[] discKey)
{
int pass = 1;
bool forward = true;
bool runningPersistent = false;
var pass = 1;
var forward = true;
var runningPersistent = false;
bool sense;
byte[] buffer;
bool recoveredError;
@@ -67,7 +67,7 @@ partial class Dump
byte[] md6;
byte[] md10;
bool blankCheck;
bool newBlank = false;
var newBlank = false;
var outputFormat = _outputPlugin as IWritableImage;
if(_persistent)
@@ -310,7 +310,7 @@ partial class Dump
if(scsiReader.LiteOnReadRaw || scsiReader.HldtstReadRaw)
{
byte[] cmi = new byte[1];
var cmi = new byte[1];
byte[] key = buffer.Skip(7).Take(5).ToArray();
@@ -348,10 +348,10 @@ partial class Dump
}
_resume.BadBlocks.Remove(badSector);
outputFormat.WriteSectorLong(buffer, badSector);
outputFormat.WriteSectorLong(buffer, badSector, SectorStatus.Dumped);
}
else
outputFormat.WriteSector(buffer, badSector);
outputFormat.WriteSector(buffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
@@ -359,7 +359,7 @@ partial class Dump
badSector,
pass));
}
else if(runningPersistent) outputFormat.WriteSector(buffer, badSector);
else if(runningPersistent) outputFormat.WriteSector(buffer, badSector, SectorStatus.Errored);
}
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
@@ -397,8 +397,8 @@ partial class Dump
void RetryTitleKeys(DVDDecryption dvdDecrypt, byte[] discKey, ref double totalDuration)
{
int pass = 1;
bool forward = true;
var pass = 1;
var forward = true;
bool sense;
byte[] buffer;

View File

@@ -5,6 +5,7 @@
using System;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.Core.Logging;
@@ -52,7 +53,7 @@ partial class Dump
bool sense;
byte[] buffer;
ulong sectorSpeedStart = 0;
bool canMediumScan = true;
var canMediumScan = true;
var outputFormat = _outputPlugin as IWritableImage;
InitProgress?.Invoke();
@@ -179,9 +180,8 @@ partial class Dump
writtenExtents.Add(0, blocks - 1);
foreach(Tuple<ulong, ulong> blank in blankExtents.ToArray())
{
for(ulong b = blank.Item1; b <= blank.Item2; b++) writtenExtents.Remove(b);
}
for(ulong b = blank.Item1; b <= blank.Item2; b++)
writtenExtents.Remove(b);
}
if(writtenExtents.Count == 0)
@@ -236,7 +236,12 @@ partial class Dump
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
_writeStopwatch.Restart();
outputFormat.WriteSectors(buffer, i, blocksToRead);
outputFormat.WriteSectors(buffer,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
}
@@ -249,7 +254,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectors(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b);

View File

@@ -52,7 +52,7 @@ partial class Dump
bool recoveredError;
bool blankCheck;
byte[] buffer;
bool newBlank = false;
var newBlank = false;
if(_outputPlugin is not IWritableImage outputFormat)
{
@@ -101,7 +101,7 @@ partial class Dump
if(scsiReader.LiteOnReadRaw || scsiReader.HldtstReadRaw)
{
byte[] cmi = new byte[1];
var cmi = new byte[1];
byte[] key = buffer.Skip(7).Take(5).ToArray();
@@ -138,10 +138,10 @@ partial class Dump
}
_resume.BadBlocks.Remove(badSector);
outputFormat.WriteSectorLong(buffer, badSector);
outputFormat.WriteSectorLong(buffer, badSector, SectorStatus.Dumped);
}
else
outputFormat.WriteSector(buffer, badSector);
outputFormat.WriteSector(buffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
}

View File

@@ -87,9 +87,9 @@ public partial class Dump
byte[] ecsd = null;
byte[] scr = null;
uint physicalBlockSize = 0;
bool byteAddressed = true;
var byteAddressed = true;
uint[] response;
bool supportsCmd23 = false;
var supportsCmd23 = false;
var outputFormat = _outputPlugin as IWritableImage;
Dictionary<MediaTagType, byte[]> mediaTags = new();
@@ -412,7 +412,7 @@ public partial class Dump
return;
}
bool ret = true;
var ret = true;
foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputFormat.SupportedMediaTags.Contains(tag)))
{
@@ -592,7 +592,7 @@ public partial class Dump
_dumpStopwatch.Restart();
_speedStopwatch.Reset();
double imageWriteDuration = 0;
bool newTrim = false;
var newTrim = false;
ulong sectorSpeedStart = 0;
InitProgress?.Invoke();
@@ -664,7 +664,12 @@ public partial class Dump
mhddLog.Write(i, duration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
_writeStopwatch.Restart();
outputFormat.WriteSectors(cmdBuf, i, blocksToRead);
outputFormat.WriteSectors(cmdBuf,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead);
@@ -681,7 +686,12 @@ public partial class Dump
ibgLog.Write(i, 0);
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectors(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
AaruLogging.WriteLine(Localization.Core.Skipping_0_blocks_from_errored_block_1, _skip, i);
i += _skip - blocksToRead;
@@ -771,7 +781,7 @@ public partial class Dump
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputFormat.WriteSector(cmdBuf, badSector);
outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
}
@@ -788,8 +798,8 @@ public partial class Dump
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
int pass = 1;
bool forward = true;
var pass = 1;
var forward = true;
InitProgress?.Invoke();
repeatRetryLba:
@@ -832,7 +842,7 @@ public partial class Dump
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputFormat.WriteSector(cmdBuf, badSector);
outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1,

View File

@@ -150,7 +150,7 @@ partial class Dump
return;
}
byte[] tmpBuf = new byte[ssBuf.Length - 4];
var tmpBuf = new byte[ssBuf.Length - 4];
Array.Copy(ssBuf, 4, tmpBuf, 0, ssBuf.Length - 4);
mediaTags.Add(MediaTagType.Xbox_SecuritySector, tmpBuf);
@@ -475,7 +475,7 @@ partial class Dump
if(_skip < blocksToRead) _skip = blocksToRead;
bool ret = true;
var ret = true;
foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputFormat.SupportedMediaTags.Contains(tag)))
{
@@ -579,14 +579,14 @@ partial class Dump
if(_resume.NextBlock > 0)
UpdateStatus?.Invoke(string.Format(Localization.Core.Resuming_from_block_0, _resume.NextBlock));
bool newTrim = false;
var newTrim = false;
UpdateStatus?.Invoke(Localization.Core.Reading_game_partition);
_speedStopwatch.Reset();
ulong sectorSpeedStart = 0;
InitProgress?.Invoke();
for(int e = 0; e <= 16; e++)
for(var e = 0; e <= 16; e++)
{
if(_aborted)
{
@@ -683,7 +683,12 @@ partial class Dump
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
_writeStopwatch.Restart();
outputFormat.WriteSectors(readBuffer, i, blocksToRead);
outputFormat.WriteSectors(readBuffer,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead);
@@ -699,7 +704,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectors(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b);
@@ -757,7 +767,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * blocksToRead], i, blocksToRead);
outputFormat.WriteSectors(new byte[blockSize * blocksToRead],
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
blocksToRead = saveBlocksToRead;
extents.Add(i, blocksToRead, true);
@@ -802,7 +817,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * blocksToRead], middle + currentSector, blocksToRead);
outputFormat.WriteSectors(new byte[blockSize * blocksToRead],
middle + currentSector,
blocksToRead,
Enumerable.Repeat(SectorStatus.NotDumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(currentSector, blocksToRead, true);
_writeStopwatch.Stop();
@@ -887,7 +907,12 @@ partial class Dump
mhddLog.Write(currentSector, cmdDuration, blocksToRead);
ibgLog.Write(currentSector, currentSpeed * 1024);
_writeStopwatch.Restart();
outputFormat.WriteSectors(readBuffer, currentSector, blocksToRead);
outputFormat.WriteSectors(readBuffer,
currentSector,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(currentSector, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(currentSector, blocksToRead);
@@ -901,7 +926,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], currentSector, _skip);
outputFormat.WriteSectors(new byte[blockSize * _skip],
currentSector,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
// TODO: Handle errors in video partition
@@ -1030,7 +1060,7 @@ partial class Dump
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputFormat.WriteSector(readBuffer, badSector);
outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
}
@@ -1050,14 +1080,15 @@ partial class Dump
List<ulong> tmpList = [];
foreach(ulong ur in _resume.BadBlocks)
for(ulong i = ur; i < ur + blocksToRead; i++)
tmpList.Add(i);
{
for(ulong i = ur; i < ur + blocksToRead; i++) tmpList.Add(i);
}
tmpList.Sort();
int pass = 1;
bool forward = true;
bool runningPersistent = false;
var pass = 1;
var forward = true;
var runningPersistent = false;
_resume.BadBlocks = tmpList;
Modes.ModePage? currentModePage = null;
@@ -1230,14 +1261,14 @@ partial class Dump
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
outputFormat.WriteSector(readBuffer, badSector);
outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1,
badSector,
pass));
}
else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector);
else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Errored);
}
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)