Invert 'if' statements to reduce nesting.

This commit is contained in:
2022-11-13 21:14:18 +00:00
parent c316cef523
commit d64c48dc6d
23 changed files with 955 additions and 949 deletions

View File

@@ -842,16 +842,16 @@ public sealed class Checksum
dataChecksums.Add(chk);
}
if(enabled.HasFlag(EnableChecksum.Fletcher32))
{
chk = new ChecksumType
{
type = ChecksumTypeType.fletcher32,
Value = f32CtxData.End()
};
if(!enabled.HasFlag(EnableChecksum.Fletcher32))
return dataChecksums;
dataChecksums.Add(chk);
}
chk = new ChecksumType
{
type = ChecksumTypeType.fletcher32,
Value = f32CtxData.End()
};
dataChecksums.Add(chk);
return dataChecksums;
}

View File

@@ -179,12 +179,12 @@ public partial class Dump
break;
}
if(tmp.SequenceEqual(_gbaExtension))
{
gbaFound = true;
if(!tmp.SequenceEqual(_gbaExtension))
continue;
break;
}
gbaFound = true;
break;
}
if(!sfcFound &&

View File

@@ -128,62 +128,62 @@ partial class Dump
bool tmpSense = dvdDecrypt.ReadTitleKey(out tmpBuf, out _, DvdCssKeyClass.DvdCssCppmOrCprm,
i + j, _dev.Timeout, out _);
if(!tmpSense)
if(tmpSense)
continue;
CSS_CPRM.TitleKey? titleKey = CSS.DecodeTitleKey(tmpBuf, dvdDecrypt.BusKey);
if(titleKey.HasValue)
outputFormat.WriteSectorTag(new[]
{
titleKey.Value.CMI
}, i + j, SectorTagType.DvdCmi);
else
continue;
// If the CMI bit is 1, the sector is using copy protection, else it is not
if((titleKey.Value.CMI & 0x80) >> 7 == 0)
{
CSS_CPRM.TitleKey? titleKey = CSS.DecodeTitleKey(tmpBuf, dvdDecrypt.BusKey);
if(titleKey.HasValue)
outputFormat.WriteSectorTag(new[]
{
titleKey.Value.CMI
}, i + j, SectorTagType.DvdCmi);
else
continue;
// If the CMI bit is 1, the sector is using copy protection, else it is not
if((titleKey.Value.CMI & 0x80) >> 7 == 0)
// The CMI indicates this sector is not encrypted.
outputFormat.WriteSectorTag(new byte[]
{
// The CMI indicates this sector is not encrypted.
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdTitleKey);
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdTitleKey);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys.Remove(i + j);
continue;
}
// According to libdvdcss, if the key is all zeroes, the sector is actually
// not encrypted even if the CMI says it is.
if(titleKey.Value.Key.All(k => k == 0))
outputFormat.WriteSectorTag(new byte[]
{
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdTitleKey);
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdTitleKeyDecrypted);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys.Remove(i + j);
_resume.MissingTitleKeys.Remove(i + j);
continue;
}
outputFormat.WriteSectorTag(titleKey.Value.Key, i + j, SectorTagType.DvdTitleKey);
_resume.MissingTitleKeys.Remove(i + j);
CSS.DecryptTitleKey(0, discKey, titleKey.Value.Key, out tmpBuf);
outputFormat.WriteSectorTag(tmpBuf, i + j, SectorTagType.DvdTitleKeyDecrypted);
continue;
}
// According to libdvdcss, if the key is all zeroes, the sector is actually
// not encrypted even if the CMI says it is.
if(titleKey.Value.Key.All(k => k == 0))
{
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdTitleKey);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys.Remove(i + j);
continue;
}
outputFormat.WriteSectorTag(titleKey.Value.Key, i + j, SectorTagType.DvdTitleKey);
_resume.MissingTitleKeys.Remove(i + j);
CSS.DecryptTitleKey(0, discKey, titleKey.Value.Key, out tmpBuf);
outputFormat.WriteSectorTag(tmpBuf, i + j, SectorTagType.DvdTitleKeyDecrypted);
}
if(!_storeEncrypted)

View File

@@ -89,7 +89,7 @@ partial class Dump
if(dcMode10?.Pages != null)
foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage =>
modePage.Page == 0x01 && modePage.Subpage == 0x00))
modePage.Page == 0x01 && modePage.Subpage == 0x00))
currentModePage = modePage;
}
}
@@ -99,7 +99,7 @@ partial class Dump
if(dcMode6?.Pages != null)
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage.Page == 0x01 &&
modePage.Subpage == 0x00))
modePage.Subpage == 0x00))
currentModePage = modePage;
}
@@ -347,52 +347,51 @@ partial class Dump
totalDuration += cmdDuration;
if(!sense &&
!_dev.Error)
if(sense || _dev.Error)
continue;
CSS_CPRM.TitleKey? titleKey = CSS.DecodeTitleKey(buffer, dvdDecrypt.BusKey);
if(!titleKey.HasValue)
continue;
outputFormat.WriteSectorTag(new[]
{
CSS_CPRM.TitleKey? titleKey = CSS.DecodeTitleKey(buffer, dvdDecrypt.BusKey);
titleKey.Value.CMI
}, missingKey, SectorTagType.DvdCmi);
if(titleKey.HasValue)
// If the CMI bit is 1, the sector is using copy protection, else it is not
// If the decoded title key is zeroed, there should be no copy protection
if((titleKey.Value.CMI & 0x80) >> 7 == 0 ||
titleKey.Value.Key.All(k => k == 0))
{
outputFormat.WriteSectorTag(new byte[]
{
outputFormat.WriteSectorTag(new[]
{
titleKey.Value.CMI
}, missingKey, SectorTagType.DvdCmi);
0, 0, 0, 0, 0
}, missingKey, SectorTagType.DvdTitleKey);
// If the CMI bit is 1, the sector is using copy protection, else it is not
// If the decoded title key is zeroed, there should be no copy protection
if((titleKey.Value.CMI & 0x80) >> 7 == 0 ||
titleKey.Value.Key.All(k => k == 0))
{
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, missingKey, SectorTagType.DvdTitleKey);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, missingKey, SectorTagType.DvdTitleKeyDecrypted);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, missingKey, SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys.Remove(missingKey);
UpdateStatus?.Invoke($"Correctly retried title key {missingKey} in pass {pass}.");
_dumpLog.WriteLine("Correctly retried title key {0} in pass {1}.", missingKey, pass);
}
else
{
outputFormat.WriteSectorTag(titleKey.Value.Key, missingKey, SectorTagType.DvdTitleKey);
_resume.MissingTitleKeys.Remove(missingKey);
_resume.MissingTitleKeys.Remove(missingKey);
UpdateStatus?.Invoke($"Correctly retried title key {missingKey} in pass {pass}.");
_dumpLog.WriteLine("Correctly retried title key {0} in pass {1}.", missingKey, pass);
}
else
{
outputFormat.WriteSectorTag(titleKey.Value.Key, missingKey, SectorTagType.DvdTitleKey);
_resume.MissingTitleKeys.Remove(missingKey);
if(discKey != null)
{
CSS.DecryptTitleKey(0, discKey, titleKey.Value.Key, out buffer);
outputFormat.WriteSectorTag(buffer, missingKey, SectorTagType.DvdTitleKeyDecrypted);
}
UpdateStatus?.Invoke($"Correctly retried title key {missingKey} in pass {pass}.");
_dumpLog.WriteLine("Correctly retried title key {0} in pass {1}.", missingKey, pass);
}
if(discKey != null)
{
CSS.DecryptTitleKey(0, discKey, titleKey.Value.Key, out buffer);
outputFormat.WriteSectorTag(buffer, missingKey, SectorTagType.DvdTitleKeyDecrypted);
}
UpdateStatus?.Invoke($"Correctly retried title key {missingKey} in pass {pass}.");
_dumpLog.WriteLine("Correctly retried title key {0} in pass {1}.", missingKey, pass);
}
}

View File

@@ -2022,83 +2022,83 @@ public sealed partial class DeviceReport
{
ctx.AddTask("Trying MediaTek READ DRAM command for Lead-Out...").IsIndeterminate();
if(mediaTest.Blocks > 0)
if(!(mediaTest.Blocks > 0))
return;
if(mediaType == "Audio CD" &&
mediaTest.SupportsReadCd == true)
{
if(mediaType == "Audio CD" &&
mediaTest.SupportsReadCd == true)
{
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.Cdda, false,
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
MmcSubchannel.None, _dev.Timeout, out _);
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.Cdda, false, false,
false, MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
_dev.Timeout, out _);
triedLeadOut = true;
}
else if((mediaType.StartsWith("CD", StringComparison.OrdinalIgnoreCase) ||
mediaType == "Enhanced CD (aka E-CD, CD-Plus or CD+)") &&
mediaTest.SupportsReadCdRaw == true)
{
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.AllTypes, false,
false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
MmcSubchannel.None, _dev.Timeout, out _);
triedLeadOut = true;
}
else if((mediaType.StartsWith("CD", StringComparison.OrdinalIgnoreCase) ||
mediaType == "Enhanced CD (aka E-CD, CD-Plus or CD+)") &&
mediaTest.SupportsReadCd == true)
{
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2048, 1, MmcSectorTypes.AllTypes, false,
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
MmcSubchannel.None, _dev.Timeout, out _);
triedLeadOut = true;
}
else if(mediaTest.SupportsRead6 == true)
{
_dev.Read6(out _, out _, (uint)(mediaTest.Blocks + 1), 2048, _dev.Timeout, out _);
triedLeadOut = true;
}
else if(mediaTest.SupportsRead10 == true)
{
_dev.Read10(out _, out _, 0, false, true, false, false, (uint)(mediaTest.Blocks + 1), 2048, 0,
1, _dev.Timeout, out _);
triedLeadOut = true;
}
else if(mediaTest.SupportsRead12 == true)
{
_dev.Read12(out _, out _, 0, false, true, false, false, (uint)(mediaTest.Blocks + 1), 2048, 0,
1, false, _dev.Timeout, out _);
triedLeadOut = true;
}
else if(mediaTest.SupportsRead16 == true)
{
_dev.Read16(out _, out _, 0, false, true, false, (ulong)(mediaTest.Blocks + 1), 2048, 0, 1,
false, _dev.Timeout, out _);
triedLeadOut = true;
}
if(triedLeadOut)
{
mediaTest.CanReadF1_06LeadOut =
!_dev.MediaTekReadDram(out buffer, out senseBuffer, 0, 0xB00, _dev.Timeout, out _);
mediaTest.ReadF1_06LeadOutData = mediaTest.CanReadF1_06LeadOut == true ? buffer : senseBuffer;
// This means it has returned the same as previous read, so not really lead-out.
if(mediaTest.CanReadF1_06 == true &&
mediaTest.CanReadF1_06LeadOut == true &&
mediaTest.ReadF1_06Data.SequenceEqual(mediaTest.ReadF1_06LeadOutData))
{
mediaTest.CanReadF1_06LeadOut = false;
mediaTest.ReadF1_06LeadOutData = senseBuffer;
}
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadF1_06LeadOut);
}
triedLeadOut = true;
}
else if((mediaType.StartsWith("CD", StringComparison.OrdinalIgnoreCase) ||
mediaType == "Enhanced CD (aka E-CD, CD-Plus or CD+)") &&
mediaTest.SupportsReadCdRaw == true)
{
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.AllTypes, false,
false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
MmcSubchannel.None, _dev.Timeout, out _);
triedLeadOut = true;
}
else if((mediaType.StartsWith("CD", StringComparison.OrdinalIgnoreCase) ||
mediaType == "Enhanced CD (aka E-CD, CD-Plus or CD+)") &&
mediaTest.SupportsReadCd == true)
{
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2048, 1, MmcSectorTypes.AllTypes, false,
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
_dev.Timeout, out _);
triedLeadOut = true;
}
else if(mediaTest.SupportsRead6 == true)
{
_dev.Read6(out _, out _, (uint)(mediaTest.Blocks + 1), 2048, _dev.Timeout, out _);
triedLeadOut = true;
}
else if(mediaTest.SupportsRead10 == true)
{
_dev.Read10(out _, out _, 0, false, true, false, false, (uint)(mediaTest.Blocks + 1), 2048, 0, 1,
_dev.Timeout, out _);
triedLeadOut = true;
}
else if(mediaTest.SupportsRead12 == true)
{
_dev.Read12(out _, out _, 0, false, true, false, false, (uint)(mediaTest.Blocks + 1), 2048, 0, 1,
false, _dev.Timeout, out _);
triedLeadOut = true;
}
else if(mediaTest.SupportsRead16 == true)
{
_dev.Read16(out _, out _, 0, false, true, false, (ulong)(mediaTest.Blocks + 1), 2048, 0, 1, false,
_dev.Timeout, out _);
triedLeadOut = true;
}
if(!triedLeadOut)
return;
mediaTest.CanReadF1_06LeadOut =
!_dev.MediaTekReadDram(out buffer, out senseBuffer, 0, 0xB00, _dev.Timeout, out _);
mediaTest.ReadF1_06LeadOutData = mediaTest.CanReadF1_06LeadOut == true ? buffer : senseBuffer;
// This means it has returned the same as previous read, so not really lead-out.
if(mediaTest.CanReadF1_06 == true &&
mediaTest.CanReadF1_06LeadOut == true &&
mediaTest.ReadF1_06Data.SequenceEqual(mediaTest.ReadF1_06LeadOutData))
{
mediaTest.CanReadF1_06LeadOut = false;
mediaTest.ReadF1_06LeadOutData = senseBuffer;
}
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadF1_06LeadOut);
});
}
@@ -2177,25 +2177,23 @@ public sealed partial class DeviceReport
false, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout, out _);
if(mediaTest.CanReadingIntersessionLeadOut != false)
return;
mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer,
firstSessionLeadOutLba, 2368, 1,
MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.AllHeaders, true,
false, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout, out _);
if(mediaTest.CanReadingIntersessionLeadOut == false)
{
mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer,
firstSessionLeadOutLba, 2368, 1,
firstSessionLeadOutLba, 2352, 1,
MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.AllHeaders, true,
false, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout, out _);
if(mediaTest.CanReadingIntersessionLeadOut == false)
mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer,
firstSessionLeadOutLba, 2352, 1,
MmcSectorTypes.AllTypes, false,
false, false,
MmcHeaderCodes.AllHeaders, true,
false, MmcErrorField.None,
MmcSubchannel.None, _dev.Timeout,
out _);
}
MmcSubchannel.None, _dev.Timeout, out _);
});
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadingIntersessionLeadOut);
@@ -2213,24 +2211,23 @@ public sealed partial class DeviceReport
false, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout, out _);
if(mediaTest.CanReadingIntersessionLeadIn != false)
return;
mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer,
secondSessionLeadInLba, 2368, 1,
MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.AllHeaders, true,
false, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout, out _);
if(mediaTest.CanReadingIntersessionLeadIn == false)
{
mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer,
secondSessionLeadInLba, 2368, 1,
secondSessionLeadInLba, 2352, 1,
MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.AllHeaders, true,
false, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout, out _);
if(mediaTest.CanReadingIntersessionLeadIn == false)
mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer,
secondSessionLeadInLba, 2352, 1,
MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.AllHeaders,
true, false, MmcErrorField.None,
MmcSubchannel.None, _dev.Timeout,
out _);
}
MmcSubchannel.None, _dev.Timeout, out _);
});
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadingIntersessionLeadIn);

View File

@@ -650,105 +650,107 @@ public sealed partial class DeviceReport
}
}
if((mediaTest.SupportsReadLong == true || mediaTest.SupportsReadLong16 == true) &&
mediaTest.LongBlockSize == mediaTest.BlockSize)
switch(mediaTest.BlockSize)
if(mediaTest.SupportsReadLong != true && mediaTest.SupportsReadLong16 != true ||
mediaTest.LongBlockSize != mediaTest.BlockSize)
return;
switch(mediaTest.BlockSize)
{
case 512:
{
case 512:
{
foreach(ushort testSize in new ushort[]
{
// Long sector sizes for floppies
514,
foreach(ushort testSize in new ushort[]
{
// Long sector sizes for floppies
514,
// Long sector sizes for SuperDisk
536, 558,
// Long sector sizes for SuperDisk
536, 558,
// Long sector sizes for 512-byte magneto-opticals
600, 610, 630
})
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
if(sense || _dev.Error)
continue;
mediaTest.LongBlockSize = testSize;
break;
}
break;
}
case 1024:
{
foreach(ushort testSize in new ushort[]
{
// Long sector sizes for floppies
1026,
// Long sector sizes for 1024-byte magneto-opticals
1200
})
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
if(sense || _dev.Error)
continue;
mediaTest.LongBlockSize = testSize;
break;
}
break;
}
case 2048:
// Long sector sizes for 512-byte magneto-opticals
600, 610, 630
})
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 2380, _dev.Timeout, out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, _dev.Timeout,
out _);
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
if(!sense &&
!_dev.Error)
mediaTest.LongBlockSize = 2380;
if(sense || _dev.Error)
continue;
mediaTest.LongBlockSize = testSize;
break;
}
case 4096:
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 4760, _dev.Timeout, out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, _dev.Timeout,
out _);
if(!sense &&
!_dev.Error)
mediaTest.LongBlockSize = 4760;
break;
}
case 8192:
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 9424, _dev.Timeout, out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, _dev.Timeout,
out _);
if(!sense &&
!_dev.Error)
mediaTest.LongBlockSize = 9424;
break;
}
break;
}
case 1024:
{
foreach(ushort testSize in new ushort[]
{
// Long sector sizes for floppies
1026,
// Long sector sizes for 1024-byte magneto-opticals
1200
})
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
if(sense || _dev.Error)
continue;
mediaTest.LongBlockSize = testSize;
break;
}
break;
}
case 2048:
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 2380, _dev.Timeout, out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, _dev.Timeout,
out _);
if(!sense &&
!_dev.Error)
mediaTest.LongBlockSize = 2380;
break;
}
case 4096:
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 4760, _dev.Timeout, out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, _dev.Timeout,
out _);
if(!sense &&
!_dev.Error)
mediaTest.LongBlockSize = 4760;
break;
}
case 8192:
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 9424, _dev.Timeout, out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, _dev.Timeout,
out _);
if(!sense &&
!_dev.Error)
mediaTest.LongBlockSize = 9424;
break;
}
}
});
Spectre.ProgressSingleSpinner(ctx =>

View File

@@ -2222,18 +2222,18 @@ public static class MMC
break;
}
if(line.StartsWith("BOOT2=cdrom0:", StringComparison.InvariantCultureIgnoreCase))
{
ps2BootFile = line.Substring(13);
if(!line.StartsWith("BOOT2=cdrom0:", StringComparison.InvariantCultureIgnoreCase))
continue;
if(ps2BootFile.StartsWith('\\'))
ps2BootFile = ps2BootFile.Substring(1);
ps2BootFile = line.Substring(13);
if(ps2BootFile.EndsWith(";1", StringComparison.InvariantCultureIgnoreCase))
ps2BootFile = ps2BootFile.Substring(0, ps2BootFile.Length - 2);
if(ps2BootFile.StartsWith('\\'))
ps2BootFile = ps2BootFile.Substring(1);
break;
}
if(ps2BootFile.EndsWith(";1", StringComparison.InvariantCultureIgnoreCase))
ps2BootFile = ps2BootFile.Substring(0, ps2BootFile.Length - 2);
break;
}
if(ps1BootFile != null &&

View File

@@ -216,11 +216,11 @@ public sealed partial class Device : Devices.Device
}
#endregion FireWire
#region PCMCIA
if(dev._remote.GetPcmciaData(out byte[] cisBuf))
{
dev.IsPcmcia = true;
dev.Cis = cisBuf;
}
if(!dev._remote.GetPcmciaData(out byte[] cisBuf))
return dev;
dev.IsPcmcia = true;
dev.Cis = cisBuf;
#endregion PCMCIA
return dev;

View File

@@ -1238,15 +1238,15 @@ public class Remote : IDisposable
Array.Copy(res.ocr, 0, ocr, 0, res.ocr_len);
}
if(res.scr_len > 0)
{
if(res.scr_len > 16)
res.scr_len = 16;
if(res.scr_len <= 0)
return res.isSdhci;
scr = new byte[res.scr_len];
if(res.scr_len > 16)
res.scr_len = 16;
Array.Copy(res.scr, 0, scr, 0, res.scr_len);
}
scr = new byte[res.scr_len];
Array.Copy(res.scr, 0, scr, 0, res.scr_len);
return res.isSdhci;
}
@@ -1576,7 +1576,7 @@ public class Remote : IDisposable
/// <param name="sense">Set to <c>true</c> if any of the commands returned an error status, <c>false</c> otherwise</param>
/// <param name="timeout">Maximum allowed time to execute a single command</param>
/// <returns>0 if no error occurred, otherwise, errno</returns>
public int SendMultipleMmcCommands(Device.MmcSingleCommand[] commands, out double duration, out bool sense,
public int SendMultipleMmcCommands(Devices.Device.MmcSingleCommand[] commands, out double duration, out bool sense,
uint timeout = 0)
{
if(ServerProtocolVersion < 2)
@@ -1588,7 +1588,7 @@ public class Remote : IDisposable
long packetSize = Marshal.SizeOf<AaruPacketMultiCmdSdhci>() +
Marshal.SizeOf<AaruCmdSdhci>() * commands.LongLength;
foreach(Device.MmcSingleCommand command in commands)
foreach(Devices.Device.MmcSingleCommand command in commands)
packetSize += command.buffer?.Length ?? 0;
var packet = new AaruPacketMultiCmdSdhci
@@ -1630,7 +1630,7 @@ public class Remote : IDisposable
off += tmp.Length;
}
foreach(Device.MmcSingleCommand command in commands.Where(command => (command.buffer?.Length ?? 0) != 0))
foreach(Devices.Device.MmcSingleCommand command in commands.Where(command => (command.buffer?.Length ?? 0) != 0))
{
Array.Copy(command.buffer, 0, buf, off, command.buffer.Length);
@@ -1699,7 +1699,7 @@ public class Remote : IDisposable
var error = 0;
foreach(Device.MmcSingleCommand command in commands)
foreach(Devices.Device.MmcSingleCommand command in commands)
{
AaruResSdhci cmdRes =
Marshal.ByteArrayToStructureLittleEndian<AaruResSdhci>(buf, off, Marshal.SizeOf<AaruResSdhci>());
@@ -1720,7 +1720,7 @@ public class Remote : IDisposable
off += Marshal.SizeOf<AaruResSdhci>();
}
foreach(Device.MmcSingleCommand command in commands)
foreach(Devices.Device.MmcSingleCommand command in commands)
{
Array.Copy(buf, off, command.buffer, 0, command.buffer.Length);
off += command.buffer.Length;
@@ -1738,13 +1738,13 @@ public class Remote : IDisposable
/// <param name="sense">Set to <c>true</c> if any of the commands returned an error status, <c>false</c> otherwise</param>
/// <param name="timeout">Maximum allowed time to execute a single command</param>
/// <returns>0 if no error occurred, otherwise, errno</returns>
int SendMultipleMmcCommandsV1(Device.MmcSingleCommand[] commands, out double duration, out bool sense, uint timeout)
int SendMultipleMmcCommandsV1(Devices.Device.MmcSingleCommand[] commands, out double duration, out bool sense, uint timeout)
{
sense = false;
duration = 0;
var error = 0;
foreach(Device.MmcSingleCommand command in commands)
foreach(Devices.Device.MmcSingleCommand command in commands)
{
error = SendMmcCommand(command.command, command.write, command.isApplication, command.flags,
command.argument, command.blockSize, command.blocks, ref command.buffer,

View File

@@ -785,28 +785,27 @@ public sealed partial class FAT
return BpbKind.Atari;
}
if(useApricotBpb)
{
fakeBpb.bps = apricotBpb.mainBPB.bps;
fakeBpb.spc = apricotBpb.mainBPB.spc;
fakeBpb.rsectors = apricotBpb.mainBPB.rsectors;
fakeBpb.fats_no = apricotBpb.mainBPB.fats_no;
fakeBpb.root_ent = apricotBpb.mainBPB.root_ent;
fakeBpb.sectors = apricotBpb.mainBPB.sectors;
fakeBpb.media = apricotBpb.mainBPB.media;
fakeBpb.spfat = apricotBpb.mainBPB.spfat;
fakeBpb.sptrk = apricotBpb.spt;
bootable = apricotBpb.bootType > 0;
if(!useApricotBpb)
return BpbKind.None;
if(apricotBpb.bootLocation > 0 &&
apricotBpb.bootLocation + apricotBpb.bootSize < imagePlugin.Info.Sectors)
imagePlugin.ReadSectors(apricotBpb.bootLocation,
(uint)(apricotBpb.sectorSize * apricotBpb.bootSize) /
imagePlugin.Info.SectorSize, out fakeBpb.boot_code);
fakeBpb.bps = apricotBpb.mainBPB.bps;
fakeBpb.spc = apricotBpb.mainBPB.spc;
fakeBpb.rsectors = apricotBpb.mainBPB.rsectors;
fakeBpb.fats_no = apricotBpb.mainBPB.fats_no;
fakeBpb.root_ent = apricotBpb.mainBPB.root_ent;
fakeBpb.sectors = apricotBpb.mainBPB.sectors;
fakeBpb.media = apricotBpb.mainBPB.media;
fakeBpb.spfat = apricotBpb.mainBPB.spfat;
fakeBpb.sptrk = apricotBpb.spt;
bootable = apricotBpb.bootType > 0;
return BpbKind.Apricot;
}
if(apricotBpb.bootLocation > 0 &&
apricotBpb.bootLocation + apricotBpb.bootSize < imagePlugin.Info.Sectors)
imagePlugin.ReadSectors(apricotBpb.bootLocation,
(uint)(apricotBpb.sectorSize * apricotBpb.bootSize) / imagePlugin.Info.SectorSize,
out fakeBpb.boot_code);
return BpbKind.Apricot;
return BpbKind.None;
}
}

View File

@@ -127,35 +127,40 @@ public sealed partial class ISO9660
offset += entry.XattrLength * _blockSize;
if(entry.CdiSystemArea?.attributes.HasFlag(CdiAttributes.DigitalAudio) == true &&
entry.Extents.Count == 1)
try
{
long firstSector = offset / 2352;
long offsetInSector = offset % 2352;
long sizeInSectors = (size + offsetInSector) / 2352;
if(entry.CdiSystemArea?.attributes.HasFlag(CdiAttributes.DigitalAudio) != true ||
entry.Extents.Count != 1)
return ReadWithExtents(offset, size, entry.Extents,
entry.XA?.signature == XA_MAGIC &&
entry.XA?.attributes.HasFlag(XaAttributes.Interleaved) == true,
entry.XA?.filenumber ?? 0, out buf);
if((size + offsetInSector) % 2352 > 0)
sizeInSectors++;
try
{
long firstSector = offset / 2352;
long offsetInSector = offset % 2352;
long sizeInSectors = (size + offsetInSector) / 2352;
ErrorNumber errno = _image.ReadSectorsLong((ulong)(entry.Extents[0].extent + firstSector),
(uint)sizeInSectors, out byte[] buffer);
if((size + offsetInSector) % 2352 > 0)
sizeInSectors++;
if(errno != ErrorNumber.NoError)
return errno;
ErrorNumber errno = _image.ReadSectorsLong((ulong)(entry.Extents[0].extent + firstSector),
(uint)sizeInSectors, out byte[] buffer);
buf = new byte[size];
Array.Copy(buffer, offsetInSector, buf, 0, size);
if(errno != ErrorNumber.NoError)
return errno;
return ErrorNumber.NoError;
}
catch(Exception e)
{
AaruConsole.DebugWriteLine("ISO9660 plugin", "Exception reading CD-i audio file");
AaruConsole.DebugWriteLine("ISO9660 plugin", "{0}", e);
buf = new byte[size];
Array.Copy(buffer, offsetInSector, buf, 0, size);
return ErrorNumber.UnexpectedException;
}
return ErrorNumber.NoError;
}
catch(Exception e)
{
AaruConsole.DebugWriteLine("ISO9660 plugin", "Exception reading CD-i audio file");
AaruConsole.DebugWriteLine("ISO9660 plugin", "{0}", e);
return ErrorNumber.UnexpectedException;
}
return ReadWithExtents(offset, size, entry.Extents,
entry.XA?.signature == XA_MAGIC &&

View File

@@ -127,17 +127,16 @@ public sealed partial class ISO9660
if(entry.AssociatedFile.Extents is null)
return ErrorNumber.InvalidArgument;
if(entry.AssociatedFile.Size == 0)
{
buf = Array.Empty<byte>();
if(entry.AssociatedFile.Size != 0)
return ReadWithExtents(0, (long)entry.AssociatedFile.Size, entry.AssociatedFile.Extents,
entry.AssociatedFile.XA?.signature == XA_MAGIC &&
entry.AssociatedFile.XA?.attributes.HasFlag(XaAttributes.Interleaved) ==
true, entry.AssociatedFile.XA?.filenumber ?? 0, out buf);
return ErrorNumber.NoError;
}
buf = Array.Empty<byte>();
return ErrorNumber.NoError;
return ReadWithExtents(0, (long)entry.AssociatedFile.Size, entry.AssociatedFile.Extents,
entry.AssociatedFile.XA?.signature == XA_MAGIC &&
entry.AssociatedFile.XA?.attributes.HasFlag(XaAttributes.Interleaved) == true,
entry.AssociatedFile.XA?.filenumber ?? 0, out buf);
case "com.apple.dos.type":
if(entry.AppleDosType is null)
return ErrorNumber.NoSuchExtendedAttribute;
@@ -160,17 +159,16 @@ public sealed partial class ISO9660
if(entry.ResourceFork.Extents is null)
return ErrorNumber.InvalidArgument;
if(entry.ResourceFork.Size == 0)
{
buf = Array.Empty<byte>();
if(entry.ResourceFork.Size != 0)
return ReadWithExtents(0, (long)entry.ResourceFork.Size, entry.ResourceFork.Extents,
entry.ResourceFork.XA?.signature == XA_MAGIC &&
entry.ResourceFork.XA?.attributes.HasFlag(XaAttributes.Interleaved) == true,
entry.ResourceFork.XA?.filenumber ?? 0, out buf);
return ErrorNumber.NoError;
}
buf = Array.Empty<byte>();
return ErrorNumber.NoError;
return ReadWithExtents(0, (long)entry.ResourceFork.Size, entry.ResourceFork.Extents,
entry.ResourceFork.XA?.signature == XA_MAGIC &&
entry.ResourceFork.XA?.attributes.HasFlag(XaAttributes.Interleaved) == true,
entry.ResourceFork.XA?.filenumber ?? 0, out buf);
case "com.apple.FinderInfo":
if(entry.FinderInfo is null)
return ErrorNumber.NoSuchExtendedAttribute;

View File

@@ -454,11 +454,11 @@ public sealed class BlockMap : ItemsControl
ctx.FillRectangle(new SolidColorBrush(color), new Rect(x, y, squareWidth, squareHeight));
x += squareWidth + 2 * borderWidth;
if(x >= sideLength)
{
x = 0;
y += squareHeight + 2 * borderWidth;
}
if(x < sideLength)
continue;
x = 0;
y += squareHeight + 2 * borderWidth;
}
}

View File

@@ -595,93 +595,93 @@ public sealed class ScsiInfoViewModel : ViewModelBase
});
}
if(_configuration != null)
{
Features.SeparatedFeatures ftr = Features.Separate(_configuration);
if(_configuration == null)
return;
AaruConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION length is {0} bytes", ftr.DataLength);
Features.SeparatedFeatures ftr = Features.Separate(_configuration);
AaruConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION current profile is {0:X4}h",
ftr.CurrentProfile);
AaruConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION length is {0} bytes", ftr.DataLength);
if(ftr.Descriptors != null)
foreach(Features.FeatureDescriptor desc in ftr.Descriptors)
AaruConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION current profile is {0:X4}h",
ftr.CurrentProfile);
if(ftr.Descriptors != null)
foreach(Features.FeatureDescriptor desc in ftr.Descriptors)
{
string featureNumber = $"Feature {desc.Code:X4}h";
AaruConsole.DebugWriteLine("Device-Info command", "Feature {0:X4}h", desc.Code);
string featureDescription = desc.Code switch
{
0x0000 => Features.Prettify_0000(desc.Data),
0x0001 => Features.Prettify_0001(desc.Data),
0x0002 => Features.Prettify_0002(desc.Data),
0x0003 => Features.Prettify_0003(desc.Data),
0x0004 => Features.Prettify_0004(desc.Data),
0x0010 => Features.Prettify_0010(desc.Data),
0x001D => Features.Prettify_001D(desc.Data),
0x001E => Features.Prettify_001E(desc.Data),
0x001F => Features.Prettify_001F(desc.Data),
0x0020 => Features.Prettify_0020(desc.Data),
0x0021 => Features.Prettify_0021(desc.Data),
0x0022 => Features.Prettify_0022(desc.Data),
0x0023 => Features.Prettify_0023(desc.Data),
0x0024 => Features.Prettify_0024(desc.Data),
0x0025 => Features.Prettify_0025(desc.Data),
0x0026 => Features.Prettify_0026(desc.Data),
0x0027 => Features.Prettify_0027(desc.Data),
0x0028 => Features.Prettify_0028(desc.Data),
0x0029 => Features.Prettify_0029(desc.Data),
0x002A => Features.Prettify_002A(desc.Data),
0x002B => Features.Prettify_002B(desc.Data),
0x002C => Features.Prettify_002C(desc.Data),
0x002D => Features.Prettify_002D(desc.Data),
0x002E => Features.Prettify_002E(desc.Data),
0x002F => Features.Prettify_002F(desc.Data),
0x0030 => Features.Prettify_0030(desc.Data),
0x0031 => Features.Prettify_0031(desc.Data),
0x0032 => Features.Prettify_0032(desc.Data),
0x0033 => Features.Prettify_0033(desc.Data),
0x0035 => Features.Prettify_0035(desc.Data),
0x0037 => Features.Prettify_0037(desc.Data),
0x0038 => Features.Prettify_0038(desc.Data),
0x003A => Features.Prettify_003A(desc.Data),
0x003B => Features.Prettify_003B(desc.Data),
0x0040 => Features.Prettify_0040(desc.Data),
0x0041 => Features.Prettify_0041(desc.Data),
0x0042 => Features.Prettify_0042(desc.Data),
0x0050 => Features.Prettify_0050(desc.Data),
0x0051 => Features.Prettify_0051(desc.Data),
0x0080 => Features.Prettify_0080(desc.Data),
0x0100 => Features.Prettify_0100(desc.Data),
0x0101 => Features.Prettify_0101(desc.Data),
0x0102 => Features.Prettify_0102(desc.Data),
0x0103 => Features.Prettify_0103(desc.Data),
0x0104 => Features.Prettify_0104(desc.Data),
0x0105 => Features.Prettify_0105(desc.Data),
0x0106 => Features.Prettify_0106(desc.Data),
0x0107 => Features.Prettify_0107(desc.Data),
0x0108 => Features.Prettify_0108(desc.Data),
0x0109 => Features.Prettify_0109(desc.Data),
0x010A => Features.Prettify_010A(desc.Data),
0x010B => Features.Prettify_010B(desc.Data),
0x010C => Features.Prettify_010C(desc.Data),
0x010D => Features.Prettify_010D(desc.Data),
0x010E => Features.Prettify_010E(desc.Data),
0x0110 => Features.Prettify_0110(desc.Data),
0x0113 => Features.Prettify_0113(desc.Data),
0x0142 => Features.Prettify_0142(desc.Data),
_ => "Unknown feature"
};
MmcFeatures.Add(new ScsiPageModel
{
string featureNumber = $"Feature {desc.Code:X4}h";
AaruConsole.DebugWriteLine("Device-Info command", "Feature {0:X4}h", desc.Code);
string featureDescription = desc.Code switch
{
0x0000 => Features.Prettify_0000(desc.Data),
0x0001 => Features.Prettify_0001(desc.Data),
0x0002 => Features.Prettify_0002(desc.Data),
0x0003 => Features.Prettify_0003(desc.Data),
0x0004 => Features.Prettify_0004(desc.Data),
0x0010 => Features.Prettify_0010(desc.Data),
0x001D => Features.Prettify_001D(desc.Data),
0x001E => Features.Prettify_001E(desc.Data),
0x001F => Features.Prettify_001F(desc.Data),
0x0020 => Features.Prettify_0020(desc.Data),
0x0021 => Features.Prettify_0021(desc.Data),
0x0022 => Features.Prettify_0022(desc.Data),
0x0023 => Features.Prettify_0023(desc.Data),
0x0024 => Features.Prettify_0024(desc.Data),
0x0025 => Features.Prettify_0025(desc.Data),
0x0026 => Features.Prettify_0026(desc.Data),
0x0027 => Features.Prettify_0027(desc.Data),
0x0028 => Features.Prettify_0028(desc.Data),
0x0029 => Features.Prettify_0029(desc.Data),
0x002A => Features.Prettify_002A(desc.Data),
0x002B => Features.Prettify_002B(desc.Data),
0x002C => Features.Prettify_002C(desc.Data),
0x002D => Features.Prettify_002D(desc.Data),
0x002E => Features.Prettify_002E(desc.Data),
0x002F => Features.Prettify_002F(desc.Data),
0x0030 => Features.Prettify_0030(desc.Data),
0x0031 => Features.Prettify_0031(desc.Data),
0x0032 => Features.Prettify_0032(desc.Data),
0x0033 => Features.Prettify_0033(desc.Data),
0x0035 => Features.Prettify_0035(desc.Data),
0x0037 => Features.Prettify_0037(desc.Data),
0x0038 => Features.Prettify_0038(desc.Data),
0x003A => Features.Prettify_003A(desc.Data),
0x003B => Features.Prettify_003B(desc.Data),
0x0040 => Features.Prettify_0040(desc.Data),
0x0041 => Features.Prettify_0041(desc.Data),
0x0042 => Features.Prettify_0042(desc.Data),
0x0050 => Features.Prettify_0050(desc.Data),
0x0051 => Features.Prettify_0051(desc.Data),
0x0080 => Features.Prettify_0080(desc.Data),
0x0100 => Features.Prettify_0100(desc.Data),
0x0101 => Features.Prettify_0101(desc.Data),
0x0102 => Features.Prettify_0102(desc.Data),
0x0103 => Features.Prettify_0103(desc.Data),
0x0104 => Features.Prettify_0104(desc.Data),
0x0105 => Features.Prettify_0105(desc.Data),
0x0106 => Features.Prettify_0106(desc.Data),
0x0107 => Features.Prettify_0107(desc.Data),
0x0108 => Features.Prettify_0108(desc.Data),
0x0109 => Features.Prettify_0109(desc.Data),
0x010A => Features.Prettify_010A(desc.Data),
0x010B => Features.Prettify_010B(desc.Data),
0x010C => Features.Prettify_010C(desc.Data),
0x010D => Features.Prettify_010D(desc.Data),
0x010E => Features.Prettify_010E(desc.Data),
0x0110 => Features.Prettify_0110(desc.Data),
0x0113 => Features.Prettify_0113(desc.Data),
0x0142 => Features.Prettify_0142(desc.Data),
_ => "Unknown feature"
};
MmcFeatures.Add(new ScsiPageModel
{
Page = featureNumber,
Description = featureDescription
});
}
else
AaruConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION returned no feature descriptors");
}
Page = featureNumber,
Description = featureDescription
});
}
else
AaruConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION returned no feature descriptors");
}
public byte[] InquiryData { get; }

View File

@@ -563,11 +563,11 @@ public sealed partial class Alcohol120
extraCount += _writingTracks.Count(t => t.Session == i);
if(i < sessions)
{
currentExtraOffset += Marshal.SizeOf<Track>() * 2;
extraCount += 2;
}
if(i >= sessions)
continue;
currentExtraOffset += Marshal.SizeOf<Track>() * 2;
extraCount += 2;
}
long footerOffset = currentExtraOffset + Marshal.SizeOf<TrackExtra>() * extraCount;

View File

@@ -1302,14 +1302,16 @@ public sealed partial class BlindWrite5
AaruConsole.VerboseWriteLine("BlindWrite image describes a disc of type {0}", _imageInfo.MediaType);
if(_header.profile != ProfileNumber.CDR &&
_header.profile != ProfileNumber.CDRW &&
_header.profile != ProfileNumber.CDROM)
foreach(Track track in Tracks)
{
track.Pregap = 0;
track.Indexes?.Clear();
}
if(_header.profile == ProfileNumber.CDR ||
_header.profile == ProfileNumber.CDRW ||
_header.profile == ProfileNumber.CDROM)
return ErrorNumber.NoError;
foreach(Track track in Tracks)
{
track.Pregap = 0;
track.Indexes?.Clear();
}
return ErrorNumber.NoError;
}

View File

@@ -726,229 +726,228 @@ public class GameBoy : IByteAddressableImage
[SuppressMessage("ReSharper", "StringLiteralTypo")]
string DecodeLicensee(byte headerLicensee, byte[] headerLicenseeNew)
{
if(headerLicensee == 0x33)
{
string licenseeNew = StringHandlers.CToString(headerLicenseeNew);
return licenseeNew switch
if(headerLicensee != 0x33)
return headerLicensee switch
{
"00" => "none",
"01" => "Nintendo R&D1",
"08" => "Capcom",
"13" => "Electronic Arts",
"18" => "Hudson Soft",
"19" => "b-ai",
"20" => "kss",
"22" => "pow",
"24" => "PCM Complete",
"25" => "san-x",
"28" => "Kemco Japan",
"29" => "seta",
"30" => "Viacom",
"31" => "Nintendo",
"32" => "Bandai",
"33" => "Ocean / Acclaim",
"34" => "Konami",
"35" => "Hector",
"37" => "Taito",
"38" => "Hudson",
"39" => "Banpresto",
"41" => "Ubi Soft",
"42" => "Atlus",
"44" => "Malibu",
"46" => "angel",
"47" => "Bullet -Proof",
"49" => "irem",
"50" => "Absolute",
"51" => "Acclaim",
"52" => "Activision",
"53" => "American sammy",
"54" => "Konami",
"55" => "Hi tech entertainment",
"56" => "LJN",
"57" => "Matchbox",
"58" => "Mattel",
"59" => "Milton Bradley",
"60" => "Titus",
"61" => "Virgin",
"64" => "LucasArts",
"67" => "Ocean",
"69" => "Electronic Arts",
"70" => "Infogrames",
"71" => "Interplay",
"72" => "Brøderbund",
"73" => "sculptured",
"75" => "sci",
"78" => "THQ",
"79" => "Accolade",
"80" => "misawa",
"83" => "lozc",
"86" => "tokuma shoten i",
"87" => "tsukuda ori",
"91" => "Chunsoft",
"92" => "Video system",
"93" => "Ocean / Acclaim",
"95" => "Varie",
"96" => "Yonezawa / s'pal",
"97" => "Kaneko",
"99" => "Pack in soft",
"A4" => "Konami",
0x00 => "none",
0x01 => "nintendo",
0x08 => "capcom",
0x09 => "hot-b",
0x0A => "jaleco",
0x0B => "coconuts",
0x0C => "elite systems",
0x13 => "electronic arts",
0x18 => "hudsonsoft",
0x19 => "itc entertainment",
0x1A => "yanoman",
0x1D => "clary",
0x1F => "virgin",
0x20 => "KSS",
0x24 => "pcm complete",
0x25 => "san-x",
0x28 => "kotobuki systems",
0x29 => "seta",
0x30 => "infogrames",
0x31 => "nintendo",
0x32 => "bandai",
0x33 => "'''GBC - see above'''",
0x34 => "konami",
0x35 => "hector",
0x38 => "Capcom",
0x39 => "Banpresto",
0x3C => "*entertainment i",
0x3E => "gremlin",
0x41 => "Ubisoft",
0x42 => "Atlus",
0x44 => "Malibu",
0x46 => "angel",
0x47 => "spectrum holoby",
0x49 => "irem",
0x4A => "virgin",
0x4D => "malibu",
0x4F => "u.s. gold",
0x50 => "absolute",
0x51 => "acclaim",
0x52 => "activision",
0x53 => "american sammy",
0x54 => "gametek",
0x55 => "park place",
0x56 => "ljn",
0x57 => "matchbox",
0x59 => "milton bradley",
0x5A => "mindscape",
0x5B => "romstar",
0x5C => "naxat soft",
0x5D => "tradewest",
0x60 => "titus",
0x61 => "virgin",
0x67 => "ocean",
0x69 => "electronic arts",
0x6E => "elite systems",
0x6F => "electro brain",
0x70 => "Infogrammes",
0x71 => "Interplay",
0x72 => "broderbund",
0x73 => "sculptered soft",
0x75 => "the sales curve",
0x78 => "t*hq",
0x79 => "accolade",
0x7A => "triffix entertainment",
0x7C => "microprose",
0x7F => "kemco",
0x80 => "misawa entertainment",
0x83 => "lozc",
0x86 => "tokuma shoten intermedia",
0x8B => "bullet-proof software",
0x8C => "vic tokai",
0x8E => "ape",
0x8F => "i'max",
0x91 => "chun soft",
0x92 => "video system",
0x93 => "tsuburava",
0x95 => "varie",
0x96 => "yonezawa/s'pal",
0x97 => "kaneko",
0x99 => "arc",
0x9A => "nihon bussan",
0x9B => "Tecmo",
0x9C => "imagineer",
0x9D => "Banpresto",
0x9F => "nova",
0xA1 => "Hori electric",
0xA2 => "Bandai",
0xA4 => "Konami",
0xA6 => "kawada",
0xA7 => "takara",
0xA9 => "technos japan",
0xAA => "broderbund",
0xAC => "Toei animation",
0xAD => "toho",
0xAF => "Namco",
0xB0 => "Acclaim",
0xB1 => "ascii or nexoft",
0xB2 => "Bandai",
0xB4 => "Enix",
0xB6 => "HAL",
0xB7 => "SNK",
0xB9 => "pony canyon",
0xBA => "*culture brain o",
0xBB => "Sunsoft",
0xBD => "Sony imagesoft",
0xBF => "sammy",
0xC0 => "Taito",
0xC2 => "Kemco",
0xC3 => "Squaresoft",
0xC4 => "tokuma shoten intermedia",
0xC5 => "data east",
0xC6 => "tonkin house",
0xC8 => "koei",
0xC9 => "ufl",
0xCA => "ultra",
0xCB => "vap",
0xCC => "use",
0xCD => "meldac",
0xCE => "*pony canyon or",
0xCF => "angel",
0xD0 => "Taito",
0xD1 => "sofel",
0xD2 => "quest",
0xD3 => "sigma enterprises",
0xD4 => "ask kodansha",
0xD6 => "naxat soft",
0xD7 => "copya systems",
0xD9 => "Banpresto",
0xDA => "tomy",
0xDB => "ljn",
0xDD => "ncs",
0xDE => "human",
0xDF => "altron",
0xE0 => "jaleco",
0xE1 => "towachiki",
0xE2 => "uutaka",
0xE3 => "varie",
0xE5 => "epoch",
0xE7 => "athena",
0xE8 => "asmik",
0xE9 => "natsume",
0xEA => "king records",
0xEB => "atlus",
0xEC => "Epic/Sony records",
0xEE => "igs",
0xF0 => "a wave",
0xF3 => "extreme entertainment",
0xFF => "ljn",
_ => "Unknown"
};
}
return headerLicensee switch
string licenseeNew = StringHandlers.CToString(headerLicenseeNew);
return licenseeNew switch
{
0x00 => "none",
0x01 => "nintendo",
0x08 => "capcom",
0x09 => "hot-b",
0x0A => "jaleco",
0x0B => "coconuts",
0x0C => "elite systems",
0x13 => "electronic arts",
0x18 => "hudsonsoft",
0x19 => "itc entertainment",
0x1A => "yanoman",
0x1D => "clary",
0x1F => "virgin",
0x20 => "KSS",
0x24 => "pcm complete",
0x25 => "san-x",
0x28 => "kotobuki systems",
0x29 => "seta",
0x30 => "infogrames",
0x31 => "nintendo",
0x32 => "bandai",
0x33 => "'''GBC - see above'''",
0x34 => "konami",
0x35 => "hector",
0x38 => "Capcom",
0x39 => "Banpresto",
0x3C => "*entertainment i",
0x3E => "gremlin",
0x41 => "Ubisoft",
0x42 => "Atlus",
0x44 => "Malibu",
0x46 => "angel",
0x47 => "spectrum holoby",
0x49 => "irem",
0x4A => "virgin",
0x4D => "malibu",
0x4F => "u.s. gold",
0x50 => "absolute",
0x51 => "acclaim",
0x52 => "activision",
0x53 => "american sammy",
0x54 => "gametek",
0x55 => "park place",
0x56 => "ljn",
0x57 => "matchbox",
0x59 => "milton bradley",
0x5A => "mindscape",
0x5B => "romstar",
0x5C => "naxat soft",
0x5D => "tradewest",
0x60 => "titus",
0x61 => "virgin",
0x67 => "ocean",
0x69 => "electronic arts",
0x6E => "elite systems",
0x6F => "electro brain",
0x70 => "Infogrammes",
0x71 => "Interplay",
0x72 => "broderbund",
0x73 => "sculptered soft",
0x75 => "the sales curve",
0x78 => "t*hq",
0x79 => "accolade",
0x7A => "triffix entertainment",
0x7C => "microprose",
0x7F => "kemco",
0x80 => "misawa entertainment",
0x83 => "lozc",
0x86 => "tokuma shoten intermedia",
0x8B => "bullet-proof software",
0x8C => "vic tokai",
0x8E => "ape",
0x8F => "i'max",
0x91 => "chun soft",
0x92 => "video system",
0x93 => "tsuburava",
0x95 => "varie",
0x96 => "yonezawa/s'pal",
0x97 => "kaneko",
0x99 => "arc",
0x9A => "nihon bussan",
0x9B => "Tecmo",
0x9C => "imagineer",
0x9D => "Banpresto",
0x9F => "nova",
0xA1 => "Hori electric",
0xA2 => "Bandai",
0xA4 => "Konami",
0xA6 => "kawada",
0xA7 => "takara",
0xA9 => "technos japan",
0xAA => "broderbund",
0xAC => "Toei animation",
0xAD => "toho",
0xAF => "Namco",
0xB0 => "Acclaim",
0xB1 => "ascii or nexoft",
0xB2 => "Bandai",
0xB4 => "Enix",
0xB6 => "HAL",
0xB7 => "SNK",
0xB9 => "pony canyon",
0xBA => "*culture brain o",
0xBB => "Sunsoft",
0xBD => "Sony imagesoft",
0xBF => "sammy",
0xC0 => "Taito",
0xC2 => "Kemco",
0xC3 => "Squaresoft",
0xC4 => "tokuma shoten intermedia",
0xC5 => "data east",
0xC6 => "tonkin house",
0xC8 => "koei",
0xC9 => "ufl",
0xCA => "ultra",
0xCB => "vap",
0xCC => "use",
0xCD => "meldac",
0xCE => "*pony canyon or",
0xCF => "angel",
0xD0 => "Taito",
0xD1 => "sofel",
0xD2 => "quest",
0xD3 => "sigma enterprises",
0xD4 => "ask kodansha",
0xD6 => "naxat soft",
0xD7 => "copya systems",
0xD9 => "Banpresto",
0xDA => "tomy",
0xDB => "ljn",
0xDD => "ncs",
0xDE => "human",
0xDF => "altron",
0xE0 => "jaleco",
0xE1 => "towachiki",
0xE2 => "uutaka",
0xE3 => "varie",
0xE5 => "epoch",
0xE7 => "athena",
0xE8 => "asmik",
0xE9 => "natsume",
0xEA => "king records",
0xEB => "atlus",
0xEC => "Epic/Sony records",
0xEE => "igs",
0xF0 => "a wave",
0xF3 => "extreme entertainment",
0xFF => "ljn",
"00" => "none",
"01" => "Nintendo R&D1",
"08" => "Capcom",
"13" => "Electronic Arts",
"18" => "Hudson Soft",
"19" => "b-ai",
"20" => "kss",
"22" => "pow",
"24" => "PCM Complete",
"25" => "san-x",
"28" => "Kemco Japan",
"29" => "seta",
"30" => "Viacom",
"31" => "Nintendo",
"32" => "Bandai",
"33" => "Ocean / Acclaim",
"34" => "Konami",
"35" => "Hector",
"37" => "Taito",
"38" => "Hudson",
"39" => "Banpresto",
"41" => "Ubi Soft",
"42" => "Atlus",
"44" => "Malibu",
"46" => "angel",
"47" => "Bullet -Proof",
"49" => "irem",
"50" => "Absolute",
"51" => "Acclaim",
"52" => "Activision",
"53" => "American sammy",
"54" => "Konami",
"55" => "Hi tech entertainment",
"56" => "LJN",
"57" => "Matchbox",
"58" => "Mattel",
"59" => "Milton Bradley",
"60" => "Titus",
"61" => "Virgin",
"64" => "LucasArts",
"67" => "Ocean",
"69" => "Electronic Arts",
"70" => "Infogrames",
"71" => "Interplay",
"72" => "Brøderbund",
"73" => "sculptured",
"75" => "sci",
"78" => "THQ",
"79" => "Accolade",
"80" => "misawa",
"83" => "lozc",
"86" => "tokuma shoten i",
"87" => "tsukuda ori",
"91" => "Chunsoft",
"92" => "Video system",
"93" => "Ocean / Acclaim",
"95" => "Varie",
"96" => "Yonezawa / s'pal",
"97" => "Kaneko",
"99" => "Pack in soft",
"A4" => "Konami",
_ => "Unknown"
};
}
static uint DecodeRomSize(byte headerRomType) => headerRomType switch

View File

@@ -83,12 +83,12 @@ public sealed partial class Gdi
if(lineNumber == 1)
{
if(!int.TryParse(line, out _))
{
AaruConsole.ErrorWriteLine("Not a correct Dreamcast GDI image");
if(int.TryParse(line, out _))
continue;
return ErrorNumber.InvalidArgument;
}
AaruConsole.ErrorWriteLine("Not a correct Dreamcast GDI image");
return ErrorNumber.InvalidArgument;
}
else
{

View File

@@ -168,101 +168,101 @@ public sealed class Xbox : IPartition
{
errno = imagePlugin.ReadSector((ulong)(XBOX_360DATA_OFF / imagePlugin.Info.SectorSize), out sector);
if(errno == ErrorNumber.NoError)
if(errno != ErrorNumber.NoError)
return false;
temp = BitConverter.ToUInt32(sector, 0);
if(temp != XBOX_CIGAM)
return false;
var securityPart = new Partition
{
temp = BitConverter.ToUInt32(sector, 0);
Description = "Security sectors",
Size = XBOX360_SECURITY_SECTOR_LEN,
Length = (ulong)(XBOX360_SECURITY_SECTOR_LEN / imagePlugin.Info.SectorSize),
Sequence = 1,
Offset = XBOX360_SECURITY_SECTOR_OFF,
Start = (ulong)(XBOX360_SECURITY_SECTOR_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
if(temp != XBOX_CIGAM)
return false;
var sysCachePart = new Partition
{
Description = "System cache",
Size = XBOX360_SYSTEM_CACHE_LEN,
Length = (ulong)(XBOX360_SYSTEM_CACHE_LEN / imagePlugin.Info.SectorSize),
Sequence = 2,
Offset = XBOX360_SYSTEM_CACHE_OFF,
Start = (ulong)(XBOX360_SYSTEM_CACHE_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var securityPart = new Partition
{
Description = "Security sectors",
Size = XBOX360_SECURITY_SECTOR_LEN,
Length = (ulong)(XBOX360_SECURITY_SECTOR_LEN / imagePlugin.Info.SectorSize),
Sequence = 1,
Offset = XBOX360_SECURITY_SECTOR_OFF,
Start = (ulong)(XBOX360_SECURITY_SECTOR_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var gameCachePart = new Partition
{
Description = "Game cache",
Size = XBOX360_GAME_CACHE_LEN,
Length = (ulong)(XBOX360_GAME_CACHE_LEN / imagePlugin.Info.SectorSize),
Sequence = 3,
Offset = XBOX360_GAME_CACHE_OFF,
Start = (ulong)(XBOX360_GAME_CACHE_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var sysCachePart = new Partition
{
Description = "System cache",
Size = XBOX360_SYSTEM_CACHE_LEN,
Length = (ulong)(XBOX360_SYSTEM_CACHE_LEN / imagePlugin.Info.SectorSize),
Sequence = 2,
Offset = XBOX360_SYSTEM_CACHE_OFF,
Start = (ulong)(XBOX360_SYSTEM_CACHE_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var sysExtPart = new Partition
{
Description = "System volume",
Size = XBOX368_SYS_EXT_LEN,
Length = (ulong)(XBOX368_SYS_EXT_LEN / imagePlugin.Info.SectorSize),
Sequence = 4,
Offset = XBOX368_SYS_EXT_OFF,
Start = (ulong)(XBOX368_SYS_EXT_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var gameCachePart = new Partition
{
Description = "Game cache",
Size = XBOX360_GAME_CACHE_LEN,
Length = (ulong)(XBOX360_GAME_CACHE_LEN / imagePlugin.Info.SectorSize),
Sequence = 3,
Offset = XBOX360_GAME_CACHE_OFF,
Start = (ulong)(XBOX360_GAME_CACHE_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var sysExt2Part = new Partition
{
Description = "System volume 2",
Size = XBOX360_SYS_EXT2_LEN,
Length = (ulong)(XBOX360_SYS_EXT2_LEN / imagePlugin.Info.SectorSize),
Sequence = 5,
Offset = XBOX360_SYS_EXT2_OFF,
Start = (ulong)(XBOX360_SYS_EXT2_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var sysExtPart = new Partition
{
Description = "System volume",
Size = XBOX368_SYS_EXT_LEN,
Length = (ulong)(XBOX368_SYS_EXT_LEN / imagePlugin.Info.SectorSize),
Sequence = 4,
Offset = XBOX368_SYS_EXT_OFF,
Start = (ulong)(XBOX368_SYS_EXT_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var xbox1Part = new Partition
{
Description = "Xbox backwards compatibility",
Size = XBOX360_COMPAT_LEN,
Length = (ulong)(XBOX360_COMPAT_LEN / imagePlugin.Info.SectorSize),
Sequence = 6,
Offset = XBOX360_COMPAT_OFF,
Start = (ulong)(XBOX360_COMPAT_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var sysExt2Part = new Partition
{
Description = "System volume 2",
Size = XBOX360_SYS_EXT2_LEN,
Length = (ulong)(XBOX360_SYS_EXT2_LEN / imagePlugin.Info.SectorSize),
Sequence = 5,
Offset = XBOX360_SYS_EXT2_OFF,
Start = (ulong)(XBOX360_SYS_EXT2_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var dataPart = new Partition
{
Description = "Data volume",
Sequence = 7,
Offset = XBOX_360DATA_OFF,
Start = (ulong)(XBOX_360DATA_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
var xbox1Part = new Partition
{
Description = "Xbox backwards compatibility",
Size = XBOX360_COMPAT_LEN,
Length = (ulong)(XBOX360_COMPAT_LEN / imagePlugin.Info.SectorSize),
Sequence = 6,
Offset = XBOX360_COMPAT_OFF,
Start = (ulong)(XBOX360_COMPAT_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
dataPart.Length = imagePlugin.Info.Sectors - dataPart.Start;
dataPart.Size = dataPart.Length * imagePlugin.Info.SectorSize;
var dataPart = new Partition
{
Description = "Data volume",
Sequence = 7,
Offset = XBOX_360DATA_OFF,
Start = (ulong)(XBOX_360DATA_OFF / imagePlugin.Info.SectorSize),
Scheme = Name
};
partitions.Add(securityPart);
partitions.Add(sysCachePart);
partitions.Add(gameCachePart);
partitions.Add(sysExtPart);
partitions.Add(sysExt2Part);
partitions.Add(xbox1Part);
partitions.Add(dataPart);
dataPart.Length = imagePlugin.Info.Sectors - dataPart.Start;
dataPart.Size = dataPart.Length * imagePlugin.Info.SectorSize;
partitions.Add(securityPart);
partitions.Add(sysCachePart);
partitions.Add(gameCachePart);
partitions.Add(sysExtPart);
partitions.Add(sysExt2Part);
partitions.Add(xbox1Part);
partitions.Add(dataPart);
return true;
}
return true;
}
return false;

View File

@@ -385,35 +385,35 @@ sealed class DecodeCommand : Command
break;
}
if(sectorTags)
if(!sectorTags)
return (int)ErrorNumber.NoError;
if(length.ToLowerInvariant() == "all") {}
else
{
if(length.ToLowerInvariant() == "all") {}
else
if(!ulong.TryParse(length, out ulong _))
{
if(!ulong.TryParse(length, out ulong _))
{
AaruConsole.WriteLine("Value \"{0}\" is not a valid number for length.", length);
AaruConsole.WriteLine("Not decoding sectors tags");
AaruConsole.WriteLine("Value \"{0}\" is not a valid number for length.", length);
AaruConsole.WriteLine("Not decoding sectors tags");
return 3;
}
return 3;
}
if(inputFormat.Info.ReadableSectorTags.Count == 0)
AaruConsole.WriteLine("There are no sector tags in chosen disc image.");
else
foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags)
switch(tag)
{
default:
AaruConsole.WriteLine("Decoder for disk tag type \"{0}\" not yet implemented, sorry.", tag);
break;
}
// TODO: Not implemented
}
if(inputFormat.Info.ReadableSectorTags.Count == 0)
AaruConsole.WriteLine("There are no sector tags in chosen disc image.");
else
foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags)
switch(tag)
{
default:
AaruConsole.WriteLine("Decoder for disk tag type \"{0}\" not yet implemented, sorry.", tag);
break;
}
// TODO: Not implemented
return (int)ErrorNumber.NoError;
}
}

View File

@@ -173,10 +173,12 @@ sealed class VerifyCommand : Command
return (int)ErrorNumber.NotVerifiable;
}
TimeSpan checkTime;
if(verifyDisc && verifiableImage != null)
{
bool? discCheckStatus = null;
TimeSpan checkTime = new();
checkTime = new TimeSpan();
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -208,110 +210,59 @@ sealed class VerifyCommand : Command
AaruConsole.VerboseWriteLine("Checking disc image checksums took {0} seconds", checkTime.TotalSeconds);
}
if(verifySectors)
if(!verifySectors)
return correctImage switch
{
null => (int)ErrorNumber.NotVerifiable,
false => (int)ErrorNumber.BadImageSectorsNotVerified,
true => (int)ErrorNumber.CorrectImageSectorsNotVerified
};
DateTime startCheck = DateTime.Now;
DateTime endCheck = startCheck;
List<ulong> failingLbas = new();
List<ulong> unknownLbas = new();
if(verifiableSectorsImage is IOpticalMediaImage { Tracks: {} } opticalMediaImage)
{
DateTime startCheck = DateTime.Now;
DateTime endCheck = startCheck;
List<ulong> failingLbas = new();
List<ulong> unknownLbas = new();
List<Track> inputTracks = opticalMediaImage.Tracks;
ulong currentSectorAll = 0;
if(verifiableSectorsImage is IOpticalMediaImage { Tracks: {} } opticalMediaImage)
{
List<Track> inputTracks = opticalMediaImage.Tracks;
ulong currentSectorAll = 0;
startCheck = DateTime.UtcNow;
startCheck = DateTime.UtcNow;
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
ProgressTask discTask = ctx.AddTask("Checking tracks...");
discTask.MaxValue = inputTracks.Count;
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
foreach(Track currentTrack in inputTracks)
{
ProgressTask discTask = ctx.AddTask("Checking tracks...");
discTask.MaxValue = inputTracks.Count;
discTask.Description = $"Checking track {discTask.Value + 1} of {inputTracks.Count}";
foreach(Track currentTrack in inputTracks)
{
discTask.Description =
$"Checking track {discTask.Value + 1} of {inputTracks.Count}";
ulong remainingSectors = currentTrack.EndSector - currentTrack.StartSector + 1;
ulong remainingSectors = currentTrack.EndSector - currentTrack.StartSector + 1;
ulong currentSector = 0;
ulong currentSector = 0;
ProgressTask trackTask = ctx.AddTask("Checking sector");
trackTask.MaxValue = remainingSectors;
while(remainingSectors > 0)
{
trackTask.Description = $"Checking sector {currentSectorAll} of {
inputFormat.Info.Sectors}, on track {currentTrack.Sequence}";
List<ulong> tempFailingLbas;
List<ulong> tempUnknownLbas;
if(remainingSectors < 512)
opticalMediaImage.VerifySectors(currentSector, (uint)remainingSectors,
currentTrack.Sequence, out tempFailingLbas,
out tempUnknownLbas);
else
opticalMediaImage.VerifySectors(currentSector, 512, currentTrack.Sequence,
out tempFailingLbas, out tempUnknownLbas);
failingLbas.AddRange(tempFailingLbas);
unknownLbas.AddRange(tempUnknownLbas);
if(remainingSectors < 512)
{
currentSector += remainingSectors;
currentSectorAll += remainingSectors;
trackTask.Value += remainingSectors;
remainingSectors = 0;
}
else
{
currentSector += 512;
currentSectorAll += 512;
trackTask.Value += 512;
remainingSectors -= 512;
}
}
trackTask.StopTask();
discTask.Increment(1);
}
endCheck = DateTime.UtcNow;
});
}
else if(verifiableSectorsImage != null)
{
ulong remainingSectors = inputFormat.Info.Sectors;
ulong currentSector = 0;
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
ProgressTask diskTask = ctx.AddTask("Checking sectors...");
diskTask.MaxValue = inputFormat.Info.Sectors;
startCheck = DateTime.UtcNow;
ProgressTask trackTask = ctx.AddTask("Checking sector");
trackTask.MaxValue = remainingSectors;
while(remainingSectors > 0)
{
diskTask.Description =
$"Checking sector {currentSector} of {inputFormat.Info.Sectors}";
trackTask.Description = $"Checking sector {currentSectorAll} of {
inputFormat.Info.Sectors}, on track {currentTrack.Sequence}";
List<ulong> tempFailingLbas;
List<ulong> tempUnknownLbas;
if(remainingSectors < 512)
verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors,
out tempFailingLbas, out tempUnknownLbas);
opticalMediaImage.VerifySectors(currentSector, (uint)remainingSectors,
currentTrack.Sequence, out tempFailingLbas,
out tempUnknownLbas);
else
verifiableSectorsImage.VerifySectors(currentSector, 512, out tempFailingLbas,
out tempUnknownLbas);
opticalMediaImage.VerifySectors(currentSector, 512, currentTrack.Sequence,
out tempFailingLbas, out tempUnknownLbas);
failingLbas.AddRange(tempFailingLbas);
@@ -320,64 +271,118 @@ sealed class VerifyCommand : Command
if(remainingSectors < 512)
{
currentSector += remainingSectors;
diskTask.Value += remainingSectors;
currentSectorAll += remainingSectors;
trackTask.Value += remainingSectors;
remainingSectors = 0;
}
else
{
currentSector += 512;
diskTask.Value += 512;
currentSectorAll += 512;
trackTask.Value += 512;
remainingSectors -= 512;
}
}
endCheck = DateTime.UtcNow;
});
}
trackTask.StopTask();
discTask.Increment(1);
}
TimeSpan checkTime = endCheck - startCheck;
if(unknownLbas.Count > 0)
AaruConsole.WriteLine("There is at least one sector that does not contain a checksum");
if(failingLbas.Count > 0)
AaruConsole.WriteLine("There is at least one sector with incorrect checksum or errors");
if(unknownLbas.Count == 0 &&
failingLbas.Count == 0)
AaruConsole.WriteLine("All sector checksums are correct");
AaruConsole.VerboseWriteLine("Checking sector checksums took {0} seconds", checkTime.TotalSeconds);
if(verbose)
{
AaruConsole.VerboseWriteLine("[red]LBAs with error:[/]");
if(failingLbas.Count == (int)inputFormat.Info.Sectors)
AaruConsole.VerboseWriteLine("\t[red]all sectors.[/]");
else
foreach(ulong t in failingLbas)
AaruConsole.VerboseWriteLine("\t{0}", t);
AaruConsole.WriteLine("[yellow3_1]LBAs without checksum:[/]");
if(unknownLbas.Count == (int)inputFormat.Info.Sectors)
AaruConsole.VerboseWriteLine("\t[yellow3_1]all sectors.[/]");
else
foreach(ulong t in unknownLbas)
AaruConsole.VerboseWriteLine("\t{0}", t);
}
AaruConsole.WriteLine("[italic]Total sectors...........[/] {0}", inputFormat.Info.Sectors);
AaruConsole.WriteLine("[italic]Total errors............[/] {0}", failingLbas.Count);
AaruConsole.WriteLine("[italic]Total unknowns..........[/] {0}", unknownLbas.Count);
AaruConsole.WriteLine("[italic]Total errors+unknowns...[/] {0}", failingLbas.Count + unknownLbas.Count);
if(failingLbas.Count > 0)
correctSectors = false;
else if((ulong)unknownLbas.Count < inputFormat.Info.Sectors)
correctSectors = true;
endCheck = DateTime.UtcNow;
});
}
else if(verifiableSectorsImage != null)
{
ulong remainingSectors = inputFormat.Info.Sectors;
ulong currentSector = 0;
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
ProgressTask diskTask = ctx.AddTask("Checking sectors...");
diskTask.MaxValue = inputFormat.Info.Sectors;
startCheck = DateTime.UtcNow;
while(remainingSectors > 0)
{
diskTask.Description = $"Checking sector {currentSector} of {inputFormat.Info.Sectors}";
List<ulong> tempFailingLbas;
List<ulong> tempUnknownLbas;
if(remainingSectors < 512)
verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors,
out tempFailingLbas, out tempUnknownLbas);
else
verifiableSectorsImage.VerifySectors(currentSector, 512, out tempFailingLbas,
out tempUnknownLbas);
failingLbas.AddRange(tempFailingLbas);
unknownLbas.AddRange(tempUnknownLbas);
if(remainingSectors < 512)
{
currentSector += remainingSectors;
diskTask.Value += remainingSectors;
remainingSectors = 0;
}
else
{
currentSector += 512;
diskTask.Value += 512;
remainingSectors -= 512;
}
}
endCheck = DateTime.UtcNow;
});
}
checkTime = endCheck - startCheck;
if(unknownLbas.Count > 0)
AaruConsole.WriteLine("There is at least one sector that does not contain a checksum");
if(failingLbas.Count > 0)
AaruConsole.WriteLine("There is at least one sector with incorrect checksum or errors");
if(unknownLbas.Count == 0 &&
failingLbas.Count == 0)
AaruConsole.WriteLine("All sector checksums are correct");
AaruConsole.VerboseWriteLine("Checking sector checksums took {0} seconds", checkTime.TotalSeconds);
if(verbose)
{
AaruConsole.VerboseWriteLine("[red]LBAs with error:[/]");
if(failingLbas.Count == (int)inputFormat.Info.Sectors)
AaruConsole.VerboseWriteLine("\t[red]all sectors.[/]");
else
foreach(ulong t in failingLbas)
AaruConsole.VerboseWriteLine("\t{0}", t);
AaruConsole.WriteLine("[yellow3_1]LBAs without checksum:[/]");
if(unknownLbas.Count == (int)inputFormat.Info.Sectors)
AaruConsole.VerboseWriteLine("\t[yellow3_1]all sectors.[/]");
else
foreach(ulong t in unknownLbas)
AaruConsole.VerboseWriteLine("\t{0}", t);
}
AaruConsole.WriteLine("[italic]Total sectors...........[/] {0}", inputFormat.Info.Sectors);
AaruConsole.WriteLine("[italic]Total errors............[/] {0}", failingLbas.Count);
AaruConsole.WriteLine("[italic]Total unknowns..........[/] {0}", unknownLbas.Count);
AaruConsole.WriteLine("[italic]Total errors+unknowns...[/] {0}", failingLbas.Count + unknownLbas.Count);
if(failingLbas.Count > 0)
correctSectors = false;
else if((ulong)unknownLbas.Count < inputFormat.Info.Sectors)
correctSectors = true;
return correctImage switch
{