[Aaru.Decoders] Reformat and cleanup.

This commit is contained in:
2023-10-03 23:09:28 +01:00
parent 4b26439847
commit 99e85ca762
123 changed files with 43962 additions and 30991 deletions

View File

@@ -50,8 +50,10 @@ namespace Aaru.Decoders.SCSI.MMC;
// T10/1675-D revision 2c
// T10/1675-D revision 4
// T10/1836-D revision 2g
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
public static class AACS
{
public static AACSVolumeIdentifier? DecodeAACSVolumeIdentifier(byte[] AACSVIResponse)
@@ -306,12 +308,12 @@ public static class AACS
decoded.Extents = new AACSLBAExtent[(AACSLBAExtsResponse.Length - 4) / 16];
for(int i = 0; i < (AACSLBAExtsResponse.Length - 4) / 16; i++)
for(var i = 0; i < (AACSLBAExtsResponse.Length - 4) / 16; i++)
{
decoded.Extents[i].Reserved = new byte[8];
Array.Copy(AACSLBAExtsResponse, 0 + (i * 16) + 4, decoded.Extents[i].Reserved, 0, 8);
decoded.Extents[i].StartLBA = BigEndianBitConverter.ToUInt32(AACSLBAExtsResponse, 8 + (i * 16) + 4);
decoded.Extents[i].LBACount = BigEndianBitConverter.ToUInt32(AACSLBAExtsResponse, 12 + (i * 16) + 4);
Array.Copy(AACSLBAExtsResponse, 0 + i * 16 + 4, decoded.Extents[i].Reserved, 0, 8);
decoded.Extents[i].StartLBA = BigEndianBitConverter.ToUInt32(AACSLBAExtsResponse, 8 + i * 16 + 4);
decoded.Extents[i].LBACount = BigEndianBitConverter.ToUInt32(AACSLBAExtsResponse, 12 + i * 16 + 4);
}
return decoded;
@@ -327,14 +329,19 @@ public static class AACS
var sb = new StringBuilder();
if(response.MaxLBAExtents == 0)
sb.AppendLine(response.DataLength > 2 ? Localization.Drive_can_store_256_LBA_Extents
{
sb.AppendLine(response.DataLength > 2
? Localization.Drive_can_store_256_LBA_Extents
: Localization.Drive_cannot_store_LBA_Extents);
}
else
sb.AppendFormat(Localization.Drive_can_store_0_LBA_Extents, response.MaxLBAExtents).AppendLine();
for(int i = 0; i < response.Extents.Length; i++)
for(var i = 0; i < response.Extents.Length; i++)
{
sb.AppendFormat(Localization.LBA_Extent_0_starts_at_LBA_1_and_goes_for_2_sectors, i,
response.Extents[i].StartLBA, response.Extents[i].LBACount);
}
return sb.ToString();
}
@@ -346,53 +353,7 @@ public static class AACS
return PrettifyAACSLBAExtents(decoded);
}
public struct AACSVolumeIdentifier
{
/// <summary>Bytes 0 to 1 Data length</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Bytes 4 to end AACS volume identifier data</summary>
public byte[] VolumeIdentifier;
}
public struct AACSMediaSerialNumber
{
/// <summary>Bytes 0 to 1 Data length</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Bytes 4 to end AACS media serial number</summary>
public byte[] MediaSerialNumber;
}
public struct AACSMediaIdentifier
{
/// <summary>Bytes 0 to 1 Data length</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Bytes 4 to end AACS media identifier data</summary>
public byte[] MediaIdentifier;
}
public struct AACSMediaKeyBlock
{
/// <summary>Bytes 0 to 1 Data length</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved;
/// <summary>Byte 3 Number of MKB packs available to transfer</summary>
public byte TotalPacks;
/// <summary>Bytes 4 to end AACS media key block packs</summary>
public byte[] MediaKeyBlockPacks;
}
#region Nested type: AACSDataKeys
public struct AACSDataKeys
{
@@ -406,6 +367,24 @@ public static class AACS
public byte[] DataKeys;
}
#endregion
#region Nested type: AACSLBAExtent
public struct AACSLBAExtent
{
/// <summary>Bytes 0 to 7 Reserved</summary>
public byte[] Reserved;
/// <summary>Bytes 8 to 11 Start LBA of extent</summary>
public uint StartLBA;
/// <summary>Bytes 12 to 15 Extent length</summary>
public uint LBACount;
}
#endregion
#region Nested type: AACSLBAExtentsResponse
public struct AACSLBAExtentsResponse
{
/// <summary>Bytes 0 to 1 Data Length</summary>
@@ -421,13 +400,69 @@ public static class AACS
public AACSLBAExtent[] Extents;
}
public struct AACSLBAExtent
#endregion
#region Nested type: AACSMediaIdentifier
public struct AACSMediaIdentifier
{
/// <summary>Bytes 0 to 7 Reserved</summary>
public byte[] Reserved;
/// <summary>Bytes 8 to 11 Start LBA of extent</summary>
public uint StartLBA;
/// <summary>Bytes 12 to 15 Extent length</summary>
public uint LBACount;
/// <summary>Bytes 0 to 1 Data length</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Bytes 4 to end AACS media identifier data</summary>
public byte[] MediaIdentifier;
}
#endregion
#region Nested type: AACSMediaKeyBlock
public struct AACSMediaKeyBlock
{
/// <summary>Bytes 0 to 1 Data length</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved;
/// <summary>Byte 3 Number of MKB packs available to transfer</summary>
public byte TotalPacks;
/// <summary>Bytes 4 to end AACS media key block packs</summary>
public byte[] MediaKeyBlockPacks;
}
#endregion
#region Nested type: AACSMediaSerialNumber
public struct AACSMediaSerialNumber
{
/// <summary>Bytes 0 to 1 Data length</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Bytes 4 to end AACS media serial number</summary>
public byte[] MediaSerialNumber;
}
#endregion
#region Nested type: AACSVolumeIdentifier
public struct AACSVolumeIdentifier
{
/// <summary>Bytes 0 to 1 Data length</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Bytes 4 to end AACS volume identifier data</summary>
public byte[] VolumeIdentifier;
}
#endregion
}

View File

@@ -50,8 +50,10 @@ namespace Aaru.Decoders.SCSI.MMC;
// T10/1675-D revision 2c
// T10/1675-D revision 4
// T10/1836-D revision 2g
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
public static class CPRM
{
public static CPRMMediaKeyBlock? DecodeCPRMMediaKeyBlock(byte[] CPRMMKBResponse)
@@ -101,6 +103,8 @@ public static class CPRM
return PrettifyCPRMMediaKeyBlock(decoded);
}
#region Nested type: CPRMMediaKeyBlock
public struct CPRMMediaKeyBlock
{
/// <summary>Bytes 0 to 1 Data Length</summary>
@@ -112,4 +116,6 @@ public static class CPRM
/// <summary>Byte 4 MKB Packs</summary>
public byte[] MKBPackData;
}
#endregion
}

View File

@@ -49,8 +49,10 @@ namespace Aaru.Decoders.SCSI.MMC;
// T10/1675-D revision 2c
// T10/1675-D revision 4
// T10/1836-D revision 2g
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
public static class DiscInformation
{
public static StandardDiscInformation? Decode000b(byte[] response)
@@ -95,7 +97,7 @@ public static class DiscInformation
decoded.LastPossibleLeadOutStartLBA =
(uint)((response[20] << 24) + (response[21] << 16) + (response[22] << 8) + response[23]);
byte[] temp = new byte[8];
var temp = new byte[8];
Array.Copy(response, 24, temp, 0, 8);
Array.Reverse(temp);
decoded.DiscBarcode = BitConverter.ToUInt64(temp, 0);
@@ -107,17 +109,17 @@ public static class DiscInformation
decoded.OPCTablesNumber = response[33];
if(decoded.OPCTablesNumber <= 0 ||
response.Length != (decoded.OPCTablesNumber * 8) + 34)
response.Length != decoded.OPCTablesNumber * 8 + 34)
return decoded;
decoded.OPCTables = new OPCTable[decoded.OPCTablesNumber];
for(int i = 0; i < decoded.OPCTablesNumber; i++)
for(var i = 0; i < decoded.OPCTablesNumber; i++)
{
decoded.OPCTables[i].Speed = (ushort)((response[34 + (i * 8) + 0] << 16) + response[34 + (i * 8) + 1]);
decoded.OPCTables[i].Speed = (ushort)((response[34 + i * 8 + 0] << 16) + response[34 + i * 8 + 1]);
decoded.OPCTables[i].OPCValues = new byte[6];
Array.Copy(response, 34 + (i * 8) + 2, decoded.OPCTables[i].OPCValues, 0, 6);
Array.Copy(response, 34 + i * 8 + 2, decoded.OPCTables[i].OPCValues, 0, 6);
}
return decoded;
@@ -214,7 +216,7 @@ public static class DiscInformation
sb.AppendLine(Localization.MRW_is_dirty);
sb.AppendFormat(Localization.First_track_on_disc_is_track_0, information.Value.FirstTrackNumber).AppendLine();
sb.AppendFormat(Localization.Disc_has_0_sessions, information.Value.Sessions).AppendLine();
sb.AppendFormat(Localization.Disc_has_0_sessions, information.Value.Sessions).AppendLine();
sb.AppendFormat(Localization.First_track_in_last_session_is_track_0, information.Value.FirstTrackLastSession).
AppendLine();
@@ -234,7 +236,8 @@ public static class DiscInformation
(information.Value.LastPossibleLeadOutStartLBA & 0xFF00) >> 8,
information.Value.LastPossibleLeadOutStartLBA & 0xFF).AppendLine();
sb.AppendLine(information.Value.URU ? Localization.Disc_is_defined_for_unrestricted_use
sb.AppendLine(information.Value.URU
? Localization.Disc_is_defined_for_unrestricted_use
: Localization.Disc_is_defined_for_restricted_use);
if(information.Value.DID_V)
@@ -250,9 +253,11 @@ public static class DiscInformation
return sb.ToString();
foreach(OPCTable table in information.Value.OPCTables)
{
sb.AppendFormat(Localization.OPC_values_for_0_Kbit_sec_1_2_3_4_5_6, table.Speed, table.OPCValues[0],
table.OPCValues[1], table.OPCValues[2], table.OPCValues[3], table.OPCValues[4],
table.OPCValues[5]).AppendLine();
}
return sb.ToString();
}
@@ -358,14 +363,50 @@ public static class DiscInformation
return null;
return (response[2] & 0xE0) switch
{
0x00 => Prettify000b(Decode000b(response)),
0x20 => Prettify001b(Decode001b(response)),
0x40 => Prettify010b(Decode010b(response)),
_ => null
};
{
0x00 => Prettify000b(Decode000b(response)),
0x20 => Prettify001b(Decode001b(response)),
0x40 => Prettify010b(Decode010b(response)),
_ => null
};
}
#region Nested type: OPCTable
public struct OPCTable
{
/// <summary>Bytes 0 to 1 kilobytes/sec this OPC table applies to</summary>
public ushort Speed;
/// <summary>Bytes 2 to 7 OPC values</summary>
public byte[] OPCValues;
}
#endregion
#region Nested type: POWResourcesInformation
public struct POWResourcesInformation
{
/// <summary>Bytes 0 to 1 14</summary>
public ushort DataLength;
/// <summary>Byte 2, bits 7 to 5 010b</summary>
public byte DataType;
/// <summary>Byte 2, bits 4 to 0 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Bytes 4 to 7 Remaining POW replacements</summary>
public uint RemainingPOWReplacements;
/// <summary>Bytes 8 to 11 Remaining POW reallocation map entries</summary>
public uint RemainingPOWReallocation;
/// <summary>Bytes 12 to 15 Number of remaining POW updates</summary>
public uint RemainingPOWUpdates;
}
#endregion
#region Nested type: StandardDiscInformation
public struct StandardDiscInformation
{
/// <summary>Bytes 0 to 1 32 + OPCTablesNumber*8</summary>
@@ -418,13 +459,9 @@ public static class DiscInformation
public OPCTable[] OPCTables;
}
public struct OPCTable
{
/// <summary>Bytes 0 to 1 kilobytes/sec this OPC table applies to</summary>
public ushort Speed;
/// <summary>Bytes 2 to 7 OPC values</summary>
public byte[] OPCValues;
}
#endregion
#region Nested type: TrackResourcesInformation
public struct TrackResourcesInformation
{
@@ -446,21 +483,5 @@ public static class DiscInformation
public ushort AppendableTracks;
}
public struct POWResourcesInformation
{
/// <summary>Bytes 0 to 1 14</summary>
public ushort DataLength;
/// <summary>Byte 2, bits 7 to 5 010b</summary>
public byte DataType;
/// <summary>Byte 2, bits 4 to 0 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Bytes 4 to 7 Remaining POW replacements</summary>
public uint RemainingPOWReplacements;
/// <summary>Bytes 8 to 11 Remaining POW reallocation map entries</summary>
public uint RemainingPOWReallocation;
/// <summary>Bytes 12 to 15 Number of remaining POW updates</summary>
public uint RemainingPOWUpdates;
}
#endregion
}

View File

@@ -34,43 +34,61 @@ using System.Diagnostics.CodeAnalysis;
namespace Aaru.Decoders.SCSI.MMC;
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
public enum FormatLayerTypeCodes : ushort
{
CDLayer = 0x0008, DVDLayer = 0x0010, BDLayer = 0x0040,
CDLayer = 0x0008,
DVDLayer = 0x0010,
BDLayer = 0x0040,
HDDVDLayer = 0x0050
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
public enum SessionStatusCodes : byte
{
Empty = 0x00, Incomplete = 0x01, ReservedOrDamaged = 0x02,
Complete = 0x03
Empty = 0x00,
Incomplete = 0x01,
ReservedOrDamaged = 0x02,
Complete = 0x03
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
public enum DiscStatusCodes : byte
{
Empty = 0x00, Incomplete = 0x01, Finalized = 0x02,
Others = 0x03
Empty = 0x00,
Incomplete = 0x01,
Finalized = 0x02,
Others = 0x03
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
public enum BGFormatStatusCodes : byte
{
NoFormattable = 0x00, IncompleteBackgroundFormat = 0x01, BackgroundFormatInProgress = 0x02,
FormatComplete = 0x03
NoFormattable = 0x00,
IncompleteBackgroundFormat = 0x01,
BackgroundFormatInProgress = 0x02,
FormatComplete = 0x03
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
public enum DiscTypeCodes : byte
{
/// <summary>Also valid for CD-DA, DVD and BD</summary>
CDROM = 0x00, CDi = 0x10, CDROMXA = 0x20, Undefined = 0xFF
CDROM = 0x00,
CDi = 0x10,
CDROMXA = 0x20,
Undefined = 0xFF
}
public enum LayerJumpRecordingStatus : byte
{
Incremental = 0, Unspecified = 1, Manual = 2,
Incremental = 0,
Unspecified = 1,
Manual = 2,
RegularInterval = 3
}

File diff suppressed because it is too large Load Diff

View File

@@ -49,8 +49,10 @@ namespace Aaru.Decoders.SCSI.MMC;
// T10/1675-D revision 2c
// T10/1675-D revision 4
// T10/1836-D revision 2g
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
public static class Hybrid
{
public static RecognizedFormatLayers? DecodeFormatLayers(byte[] FormatLayersResponse)
@@ -74,8 +76,8 @@ public static class Hybrid
FormatLayers = new ushort[(FormatLayersResponse.Length - 6) / 2]
};
for(int i = 0; i < (FormatLayersResponse.Length - 6) / 2; i++)
decoded.FormatLayers[i] = BigEndianBitConverter.ToUInt16(FormatLayersResponse, (i * 2) + 6);
for(var i = 0; i < (FormatLayersResponse.Length - 6) / 2; i++)
decoded.FormatLayers[i] = BigEndianBitConverter.ToUInt16(FormatLayersResponse, i * 2 + 6);
return decoded;
}
@@ -91,7 +93,8 @@ public static class Hybrid
sb.AppendFormat(Localization._0_format_layers_recognized, response.NumberOfLayers);
for(int i = 0; i < response.FormatLayers.Length; i++)
for(var i = 0; i < response.FormatLayers.Length; i++)
{
switch(response.FormatLayers[i])
{
case (ushort)FormatLayerTypeCodes.BDLayer:
@@ -160,6 +163,7 @@ public static class Hybrid
break;
}
}
}
return sb.ToString();
}
@@ -171,6 +175,8 @@ public static class Hybrid
return PrettifyFormatLayers(decoded);
}
#region Nested type: RecognizedFormatLayers
public struct RecognizedFormatLayers
{
/// <summary>Bytes 0 to 1 Data Length</summary>
@@ -192,4 +198,6 @@ public static class Hybrid
/// <summary>Bytes 6 to end Recognized format layers</summary>
public ushort[] FormatLayers;
}
#endregion
}

View File

@@ -50,8 +50,10 @@ namespace Aaru.Decoders.SCSI.MMC;
// T10/1675-D revision 2c
// T10/1675-D revision 4
// T10/1836-D revision 2g
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
public static class WriteProtect
{
public static WriteProtectionStatus? DecodeWriteProtectionStatus(byte[] WPSResponse)
@@ -128,6 +130,8 @@ public static class WriteProtect
return PrettifyWriteProtectionStatus(decoded);
}
#region Nested type: WriteProtectionStatus
public struct WriteProtectionStatus
{
/// <summary>Bytes 0 to 1 Data Length</summary>
@@ -153,4 +157,6 @@ public static class WriteProtect
/// <summary>Byte 7 Reserved</summary>
public byte Reserved6;
}
#endregion
}