mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Refactor sector writing methods to include SectorStatus parameter and update related logic
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user