Move to file scoped namespaces.

This commit is contained in:
2022-03-06 13:29:37 +00:00
parent c7178d94c6
commit 3b6091c02c
119 changed files with 38048 additions and 38172 deletions

View File

@@ -36,89 +36,88 @@ using System.Text;
using Aaru.Console;
using Aaru.Helpers;
namespace Aaru.Decoders.Bluray
namespace Aaru.Decoders.Bluray;
// Information from the following standards:
// ANSI X3.304-1997
// T10/1048-D revision 9.0
// T10/1048-D revision 10a
// T10/1228-D revision 7.0c
// T10/1228-D revision 11a
// T10/1363-D revision 10g
// T10/1545-D revision 1d
// T10/1545-D revision 5
// T10/1545-D revision 5a
// 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")]
public static class BCA
{
// Information from the following standards:
// ANSI X3.304-1997
// T10/1048-D revision 9.0
// T10/1048-D revision 10a
// T10/1228-D revision 7.0c
// T10/1228-D revision 11a
// T10/1363-D revision 10g
// T10/1545-D revision 1d
// T10/1545-D revision 5
// T10/1545-D revision 5a
// 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")]
public static class BCA
#region Public structures
public struct BurstCuttingArea
{
#region Public structures
public struct BurstCuttingArea
{
/// <summary>Bytes 0 to 1 Always 66</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Byte 4 to 67 BCA data</summary>
public byte[] BCA;
}
#endregion Public structures
#region Public methods
public static BurstCuttingArea? Decode(byte[] BCAResponse)
{
if(BCAResponse == null)
return null;
if(BCAResponse.Length != 68)
{
AaruConsole.DebugWriteLine("BD BCA decoder", "Found incorrect Blu-ray BCA size ({0} bytes)",
BCAResponse.Length);
return null;
}
var decoded = new BurstCuttingArea
{
DataLength = BigEndianBitConverter.ToUInt16(BCAResponse, 0),
Reserved1 = BCAResponse[2],
Reserved2 = BCAResponse[3],
BCA = new byte[64]
};
Array.Copy(BCAResponse, 4, decoded.BCA, 0, 64);
return decoded;
}
public static string Prettify(BurstCuttingArea? BCAResponse)
{
if(BCAResponse == null)
return null;
BurstCuttingArea response = BCAResponse.Value;
var sb = new StringBuilder();
#if DEBUG
if(response.Reserved1 != 0)
sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
if(response.Reserved2 != 0)
sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
#endif
sb.AppendFormat("Blu-ray Burst Cutting Area in hex follows:");
sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.BCA, 80));
return sb.ToString();
}
public static string Prettify(byte[] BCAResponse) => Prettify(Decode(BCAResponse));
#endregion Public methods
/// <summary>Bytes 0 to 1 Always 66</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Byte 4 to 67 BCA data</summary>
public byte[] BCA;
}
#endregion Public structures
#region Public methods
public static BurstCuttingArea? Decode(byte[] BCAResponse)
{
if(BCAResponse == null)
return null;
if(BCAResponse.Length != 68)
{
AaruConsole.DebugWriteLine("BD BCA decoder", "Found incorrect Blu-ray BCA size ({0} bytes)",
BCAResponse.Length);
return null;
}
var decoded = new BurstCuttingArea
{
DataLength = BigEndianBitConverter.ToUInt16(BCAResponse, 0),
Reserved1 = BCAResponse[2],
Reserved2 = BCAResponse[3],
BCA = new byte[64]
};
Array.Copy(BCAResponse, 4, decoded.BCA, 0, 64);
return decoded;
}
public static string Prettify(BurstCuttingArea? BCAResponse)
{
if(BCAResponse == null)
return null;
BurstCuttingArea response = BCAResponse.Value;
var sb = new StringBuilder();
#if DEBUG
if(response.Reserved1 != 0)
sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
if(response.Reserved2 != 0)
sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
#endif
sb.AppendFormat("Blu-ray Burst Cutting Area in hex follows:");
sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.BCA, 80));
return sb.ToString();
}
public static string Prettify(byte[] BCAResponse) => Prettify(Decode(BCAResponse));
#endregion Public methods
}

View File

@@ -36,145 +36,144 @@ using System.Text;
using Aaru.Console;
using Aaru.Helpers;
namespace Aaru.Decoders.Bluray
namespace Aaru.Decoders.Bluray;
// Information from the following standards:
// ANSI X3.304-1997
// T10/1048-D revision 9.0
// T10/1048-D revision 10a
// T10/1228-D revision 7.0c
// T10/1228-D revision 11a
// T10/1363-D revision 10g
// T10/1545-D revision 1d
// T10/1545-D revision 5
// T10/1545-D revision 5a
// 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", "UnassignedField.Global")]
public static class Cartridge
{
// Information from the following standards:
// ANSI X3.304-1997
// T10/1048-D revision 9.0
// T10/1048-D revision 10a
// T10/1228-D revision 7.0c
// T10/1228-D revision 11a
// T10/1363-D revision 10g
// T10/1545-D revision 1d
// T10/1545-D revision 5
// T10/1545-D revision 5a
// 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", "UnassignedField.Global")]
public static class Cartridge
#region Public structures
public struct CartridgeStatus
{
#region Public structures
public struct CartridgeStatus
/// <summary>Bytes 0 to 1 Always 6</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Byte 4, bit 7 Medium is inserted in a cartridge</summary>
public bool Cartridge;
/// <summary>Byte 4, bit 6 Medium taken out / put in a cartridge</summary>
public bool OUT;
/// <summary>Byte 4, bits 5 to 3 Reserved</summary>
public byte Reserved3;
/// <summary>Byte 4, bit 2 Cartridge sets write protection</summary>
public bool CWP;
/// <summary>Byte 4, bits 1 to 0 Reserved</summary>
public byte Reserved4;
/// <summary>Byte 5 Reserved</summary>
public byte Reserved5;
/// <summary>Byte 6 Reserved</summary>
public byte Reserved6;
/// <summary>Byte 7 Reserved</summary>
public byte Reserved7;
}
#endregion Public structures
#region Public methods
public static CartridgeStatus? Decode(byte[] CSResponse)
{
if(CSResponse == null)
return null;
if(CSResponse.Length != 8)
{
/// <summary>Bytes 0 to 1 Always 6</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Byte 4, bit 7 Medium is inserted in a cartridge</summary>
public bool Cartridge;
/// <summary>Byte 4, bit 6 Medium taken out / put in a cartridge</summary>
public bool OUT;
/// <summary>Byte 4, bits 5 to 3 Reserved</summary>
public byte Reserved3;
/// <summary>Byte 4, bit 2 Cartridge sets write protection</summary>
public bool CWP;
/// <summary>Byte 4, bits 1 to 0 Reserved</summary>
public byte Reserved4;
/// <summary>Byte 5 Reserved</summary>
public byte Reserved5;
/// <summary>Byte 6 Reserved</summary>
public byte Reserved6;
/// <summary>Byte 7 Reserved</summary>
public byte Reserved7;
}
#endregion Public structures
#region Public methods
public static CartridgeStatus? Decode(byte[] CSResponse)
{
if(CSResponse == null)
return null;
AaruConsole.DebugWriteLine("BD Cartridge Status decoder",
"Found incorrect Blu-ray Cartridge Status size ({0} bytes)",
CSResponse.Length);
if(CSResponse.Length != 8)
{
AaruConsole.DebugWriteLine("BD Cartridge Status decoder",
"Found incorrect Blu-ray Cartridge Status size ({0} bytes)",
CSResponse.Length);
return null;
}
var decoded = new CartridgeStatus
{
DataLength = BigEndianBitConverter.ToUInt16(CSResponse, 0),
Reserved1 = CSResponse[2],
Reserved2 = CSResponse[3],
Cartridge = Convert.ToBoolean(CSResponse[4] & 0x80),
OUT = Convert.ToBoolean(CSResponse[4] & 0x40),
Reserved3 = (byte)((CSResponse[4] & 0x38) >> 3),
CWP = Convert.ToBoolean(CSResponse[4] & 0x04),
Reserved4 = (byte)(CSResponse[4] & 0x03),
Reserved5 = CSResponse[5],
Reserved6 = CSResponse[6],
Reserved7 = CSResponse[7]
};
return decoded;
return null;
}
public static string Prettify(CartridgeStatus? CSResponse)
var decoded = new CartridgeStatus
{
if(CSResponse == null)
return null;
DataLength = BigEndianBitConverter.ToUInt16(CSResponse, 0),
Reserved1 = CSResponse[2],
Reserved2 = CSResponse[3],
Cartridge = Convert.ToBoolean(CSResponse[4] & 0x80),
OUT = Convert.ToBoolean(CSResponse[4] & 0x40),
Reserved3 = (byte)((CSResponse[4] & 0x38) >> 3),
CWP = Convert.ToBoolean(CSResponse[4] & 0x04),
Reserved4 = (byte)(CSResponse[4] & 0x03),
Reserved5 = CSResponse[5],
Reserved6 = CSResponse[6],
Reserved7 = CSResponse[7]
};
CartridgeStatus response = CSResponse.Value;
return decoded;
}
var sb = new StringBuilder();
public static string Prettify(CartridgeStatus? CSResponse)
{
if(CSResponse == null)
return null;
CartridgeStatus response = CSResponse.Value;
var sb = new StringBuilder();
#if DEBUG
if(response.Reserved1 != 0)
sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
if(response.Reserved2 != 0)
sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
if(response.Reserved3 != 0)
sb.AppendFormat("Reserved3 = 0x{0:X8}", response.Reserved3).AppendLine();
if(response.Reserved4 != 0)
sb.AppendFormat("Reserved4 = 0x{0:X8}", response.Reserved4).AppendLine();
if(response.Reserved5 != 0)
sb.AppendFormat("Reserved5 = 0x{0:X8}", response.Reserved5).AppendLine();
if(response.Reserved6 != 0)
sb.AppendFormat("Reserved6 = 0x{0:X8}", response.Reserved6).AppendLine();
if(response.Reserved7 != 0)
sb.AppendFormat("Reserved7 = 0x{0:X8}", response.Reserved7).AppendLine();
#endif
if(response.Cartridge)
{
sb.AppendLine("Media is inserted in a cartridge");
if(response.OUT)
sb.AppendLine("Media has been taken out, or inserted in, the cartridge");
if(response.CWP)
sb.AppendLine("Media is write protected");
}
else
{
sb.AppendLine("Media is not in a cartridge");
#if DEBUG
if(response.Reserved1 != 0)
sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
if(response.OUT)
sb.AppendLine("Media has out bit marked, shouldn't");
if(response.Reserved2 != 0)
sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
if(response.Reserved3 != 0)
sb.AppendFormat("Reserved3 = 0x{0:X8}", response.Reserved3).AppendLine();
if(response.Reserved4 != 0)
sb.AppendFormat("Reserved4 = 0x{0:X8}", response.Reserved4).AppendLine();
if(response.Reserved5 != 0)
sb.AppendFormat("Reserved5 = 0x{0:X8}", response.Reserved5).AppendLine();
if(response.Reserved6 != 0)
sb.AppendFormat("Reserved6 = 0x{0:X8}", response.Reserved6).AppendLine();
if(response.Reserved7 != 0)
sb.AppendFormat("Reserved7 = 0x{0:X8}", response.Reserved7).AppendLine();
if(response.CWP)
sb.AppendLine("Media has write protection bit marked, shouldn't");
#endif
if(response.Cartridge)
{
sb.AppendLine("Media is inserted in a cartridge");
if(response.OUT)
sb.AppendLine("Media has been taken out, or inserted in, the cartridge");
if(response.CWP)
sb.AppendLine("Media is write protected");
}
else
{
sb.AppendLine("Media is not in a cartridge");
#if DEBUG
if(response.OUT)
sb.AppendLine("Media has out bit marked, shouldn't");
if(response.CWP)
sb.AppendLine("Media has write protection bit marked, shouldn't");
#endif
}
return sb.ToString();
}
public static string Prettify(byte[] CSResponse) => Prettify(Decode(CSResponse));
#endregion Public methods
return sb.ToString();
}
public static string Prettify(byte[] CSResponse) => Prettify(Decode(CSResponse));
#endregion Public methods
}

View File

@@ -36,194 +36,193 @@ using System.Text;
using Aaru.Console;
using Aaru.Helpers;
namespace Aaru.Decoders.Bluray
namespace Aaru.Decoders.Bluray;
/// Information from the following standards:
/// ANSI X3.304-1997
/// T10/1048-D revision 9.0
/// T10/1048-D revision 10a
/// T10/1228-D revision 7.0c
/// T10/1228-D revision 11a
/// T10/1363-D revision 10g
/// T10/1545-D revision 1d
/// T10/1545-D revision 5
/// T10/1545-D revision 5a
/// 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")]
public static class DDS
{
/// Information from the following standards:
/// ANSI X3.304-1997
/// T10/1048-D revision 9.0
/// T10/1048-D revision 10a
/// T10/1228-D revision 7.0c
/// T10/1228-D revision 11a
/// T10/1363-D revision 10g
/// T10/1545-D revision 1d
/// T10/1545-D revision 5
/// T10/1545-D revision 5a
/// 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")]
public static class DDS
#region Private constants
/// <summary>Disc Definition Structure Identifier "DS"</summary>
const ushort DDSIdentifier = 0x4453;
#endregion Private constants
#region Public structures
public struct DiscDefinitionStructure
{
#region Private constants
/// <summary>Disc Definition Structure Identifier "DS"</summary>
const ushort DDSIdentifier = 0x4453;
#endregion Private constants
#region Public structures
public struct DiscDefinitionStructure
{
/// <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 5 "DS"</summary>
public ushort Signature;
/// <summary>Byte 6 DDS format</summary>
public byte Format;
/// <summary>Byte 7 Reserved</summary>
public byte Reserved3;
/// <summary>Bytes 8 to 11 DDS update count</summary>
public uint UpdateCount;
/// <summary>Bytes 12 to 19 Reserved</summary>
public ulong Reserved4;
/// <summary>Bytes 20 to 23 First PSN of Drive Area</summary>
public uint DriveAreaPSN;
/// <summary>Bytes 24 to 27 Reserved</summary>
public uint Reserved5;
/// <summary>Bytes 28 to 31 First PSN of Defect List</summary>
public uint DefectListPSN;
/// <summary>Bytes 32 to 35 Reserved</summary>
public uint Reserved6;
/// <summary>Bytes 36 to 39 PSN of LSN 0 of user data area</summary>
public uint PSNofLSNZero;
/// <summary>Bytes 40 to 43 Last LSN of user data area</summary>
public uint LastUserAreaLSN;
/// <summary>Bytes 44 to 47 ISA0 size</summary>
public uint ISA0;
/// <summary>Bytes 48 to 51 OSA size</summary>
public uint OSA;
/// <summary>Bytes 52 to 55 ISA1 size</summary>
public uint ISA1;
/// <summary>Byte 56 Spare Area full flags</summary>
public byte SpareAreaFullFlags;
/// <summary>Byte 57 Reserved</summary>
public byte Reserved7;
/// <summary>Byte 58 Disc type specific field</summary>
public byte DiscTypeSpecificField1;
/// <summary>Byte 59 Reserved</summary>
public byte Reserved8;
/// <summary>Byte 60 to 63 Disc type specific field</summary>
public uint DiscTypeSpecificField2;
/// <summary>Byte 64 to 67 Reserved</summary>
public uint Reserved9;
/// <summary>Bytes 68 to 99 Status bits of INFO1/2 and PAC1/2 on L0 and L1</summary>
public byte[] StatusBits;
/// <summary>Bytes 100 to end Disc type specific data</summary>
public byte[] DiscTypeSpecificData;
}
#endregion Public structures
#region Public methods
public static DiscDefinitionStructure? Decode(byte[] DDSResponse)
{
if(DDSResponse == null)
return null;
var decoded = new DiscDefinitionStructure
{
DataLength = BigEndianBitConverter.ToUInt16(DDSResponse, 0),
Reserved1 = DDSResponse[2],
Reserved2 = DDSResponse[3],
Signature = BigEndianBitConverter.ToUInt16(DDSResponse, 4)
};
if(decoded.Signature != DDSIdentifier)
{
AaruConsole.DebugWriteLine("BD DDS decoder", "Found incorrect DDS signature (0x{0:X4})",
decoded.Signature);
return null;
}
decoded.Format = DDSResponse[6];
decoded.Reserved3 = DDSResponse[7];
decoded.UpdateCount = BigEndianBitConverter.ToUInt32(DDSResponse, 8);
decoded.Reserved4 = BigEndianBitConverter.ToUInt64(DDSResponse, 12);
decoded.DriveAreaPSN = BigEndianBitConverter.ToUInt32(DDSResponse, 20);
decoded.Reserved5 = BigEndianBitConverter.ToUInt32(DDSResponse, 24);
decoded.DefectListPSN = BigEndianBitConverter.ToUInt32(DDSResponse, 28);
decoded.Reserved6 = BigEndianBitConverter.ToUInt32(DDSResponse, 32);
decoded.PSNofLSNZero = BigEndianBitConverter.ToUInt32(DDSResponse, 36);
decoded.LastUserAreaLSN = BigEndianBitConverter.ToUInt32(DDSResponse, 40);
decoded.ISA0 = BigEndianBitConverter.ToUInt32(DDSResponse, 44);
decoded.OSA = BigEndianBitConverter.ToUInt32(DDSResponse, 48);
decoded.ISA1 = BigEndianBitConverter.ToUInt32(DDSResponse, 52);
decoded.SpareAreaFullFlags = DDSResponse[56];
decoded.Reserved7 = DDSResponse[57];
decoded.DiscTypeSpecificField1 = DDSResponse[58];
decoded.Reserved8 = DDSResponse[59];
decoded.DiscTypeSpecificField2 = BigEndianBitConverter.ToUInt32(DDSResponse, 60);
decoded.Reserved9 = BigEndianBitConverter.ToUInt32(DDSResponse, 64);
decoded.StatusBits = new byte[32];
Array.Copy(DDSResponse, 68, decoded.StatusBits, 0, 32);
decoded.DiscTypeSpecificData = new byte[DDSResponse.Length - 100];
Array.Copy(DDSResponse, 100, decoded.DiscTypeSpecificData, 0, DDSResponse.Length - 100);
return decoded;
}
public static string Prettify(DiscDefinitionStructure? DDSResponse)
{
if(DDSResponse == null)
return null;
DiscDefinitionStructure response = DDSResponse.Value;
var sb = new StringBuilder();
sb.AppendFormat("DDS Format: 0x{0:X2}", response.Format).AppendLine();
sb.AppendFormat("DDS has ben updated {0} times", response.UpdateCount).AppendLine();
sb.AppendFormat("First PSN of Drive Area: 0x{0:X8}", response.DriveAreaPSN).AppendLine();
sb.AppendFormat("First PSN of Defect List: 0x{0:X8}", response.DefectListPSN).AppendLine();
sb.AppendFormat("PSN of User Data Area's LSN 0: 0x{0:X8}", response.PSNofLSNZero).AppendLine();
sb.AppendFormat("Last User Data Area's LSN 0: 0x{0:X8}", response.LastUserAreaLSN).AppendLine();
sb.AppendFormat("ISA0 size: {0}", response.ISA0).AppendLine();
sb.AppendFormat("OSA size: {0}", response.OSA).AppendLine();
sb.AppendFormat("ISA1 size: {0}", response.ISA1).AppendLine();
sb.AppendFormat("Spare Area Full Flags: 0x{0:X2}", response.SpareAreaFullFlags).AppendLine();
sb.AppendFormat("Disc Type Specific Field 1: 0x{0:X2}", response.DiscTypeSpecificField1).AppendLine();
sb.AppendFormat("Disc Type Specific Field 2: 0x{0:X8}", response.DiscTypeSpecificField2).AppendLine();
sb.AppendFormat("Blu-ray DDS Status Bits in hex follows:");
sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.StatusBits, 80));
sb.AppendFormat("Blu-ray DDS Disc Type Specific Data in hex follows:");
sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.DiscTypeSpecificData, 80));
#if DEBUG
if(response.Reserved1 != 0)
sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
if(response.Reserved2 != 0)
sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
if(response.Reserved3 != 0)
sb.AppendFormat("Reserved3 = 0x{0:X2}", response.Reserved3).AppendLine();
if(response.Reserved4 != 0)
sb.AppendFormat("Reserved4 = 0x{0:X16}", response.Reserved4).AppendLine();
if(response.Reserved5 != 0)
sb.AppendFormat("Reserved5 = 0x{0:X8}", response.Reserved5).AppendLine();
if(response.Reserved6 != 0)
sb.AppendFormat("Reserved6 = 0x{0:X8}", response.Reserved6).AppendLine();
if(response.Reserved7 != 0)
sb.AppendFormat("Reserved7 = 0x{0:X2}", response.Reserved7).AppendLine();
if(response.Reserved8 != 0)
sb.AppendFormat("Reserved8 = 0x{0:X2}", response.Reserved8).AppendLine();
if(response.Reserved9 != 0)
sb.AppendFormat("Reserved9 = 0x{0:X8}", response.Reserved9).AppendLine();
#endif
return sb.ToString();
}
public static string Prettify(byte[] DDSResponse) => Prettify(Decode(DDSResponse));
#endregion Public methods
/// <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 5 "DS"</summary>
public ushort Signature;
/// <summary>Byte 6 DDS format</summary>
public byte Format;
/// <summary>Byte 7 Reserved</summary>
public byte Reserved3;
/// <summary>Bytes 8 to 11 DDS update count</summary>
public uint UpdateCount;
/// <summary>Bytes 12 to 19 Reserved</summary>
public ulong Reserved4;
/// <summary>Bytes 20 to 23 First PSN of Drive Area</summary>
public uint DriveAreaPSN;
/// <summary>Bytes 24 to 27 Reserved</summary>
public uint Reserved5;
/// <summary>Bytes 28 to 31 First PSN of Defect List</summary>
public uint DefectListPSN;
/// <summary>Bytes 32 to 35 Reserved</summary>
public uint Reserved6;
/// <summary>Bytes 36 to 39 PSN of LSN 0 of user data area</summary>
public uint PSNofLSNZero;
/// <summary>Bytes 40 to 43 Last LSN of user data area</summary>
public uint LastUserAreaLSN;
/// <summary>Bytes 44 to 47 ISA0 size</summary>
public uint ISA0;
/// <summary>Bytes 48 to 51 OSA size</summary>
public uint OSA;
/// <summary>Bytes 52 to 55 ISA1 size</summary>
public uint ISA1;
/// <summary>Byte 56 Spare Area full flags</summary>
public byte SpareAreaFullFlags;
/// <summary>Byte 57 Reserved</summary>
public byte Reserved7;
/// <summary>Byte 58 Disc type specific field</summary>
public byte DiscTypeSpecificField1;
/// <summary>Byte 59 Reserved</summary>
public byte Reserved8;
/// <summary>Byte 60 to 63 Disc type specific field</summary>
public uint DiscTypeSpecificField2;
/// <summary>Byte 64 to 67 Reserved</summary>
public uint Reserved9;
/// <summary>Bytes 68 to 99 Status bits of INFO1/2 and PAC1/2 on L0 and L1</summary>
public byte[] StatusBits;
/// <summary>Bytes 100 to end Disc type specific data</summary>
public byte[] DiscTypeSpecificData;
}
#endregion Public structures
#region Public methods
public static DiscDefinitionStructure? Decode(byte[] DDSResponse)
{
if(DDSResponse == null)
return null;
var decoded = new DiscDefinitionStructure
{
DataLength = BigEndianBitConverter.ToUInt16(DDSResponse, 0),
Reserved1 = DDSResponse[2],
Reserved2 = DDSResponse[3],
Signature = BigEndianBitConverter.ToUInt16(DDSResponse, 4)
};
if(decoded.Signature != DDSIdentifier)
{
AaruConsole.DebugWriteLine("BD DDS decoder", "Found incorrect DDS signature (0x{0:X4})",
decoded.Signature);
return null;
}
decoded.Format = DDSResponse[6];
decoded.Reserved3 = DDSResponse[7];
decoded.UpdateCount = BigEndianBitConverter.ToUInt32(DDSResponse, 8);
decoded.Reserved4 = BigEndianBitConverter.ToUInt64(DDSResponse, 12);
decoded.DriveAreaPSN = BigEndianBitConverter.ToUInt32(DDSResponse, 20);
decoded.Reserved5 = BigEndianBitConverter.ToUInt32(DDSResponse, 24);
decoded.DefectListPSN = BigEndianBitConverter.ToUInt32(DDSResponse, 28);
decoded.Reserved6 = BigEndianBitConverter.ToUInt32(DDSResponse, 32);
decoded.PSNofLSNZero = BigEndianBitConverter.ToUInt32(DDSResponse, 36);
decoded.LastUserAreaLSN = BigEndianBitConverter.ToUInt32(DDSResponse, 40);
decoded.ISA0 = BigEndianBitConverter.ToUInt32(DDSResponse, 44);
decoded.OSA = BigEndianBitConverter.ToUInt32(DDSResponse, 48);
decoded.ISA1 = BigEndianBitConverter.ToUInt32(DDSResponse, 52);
decoded.SpareAreaFullFlags = DDSResponse[56];
decoded.Reserved7 = DDSResponse[57];
decoded.DiscTypeSpecificField1 = DDSResponse[58];
decoded.Reserved8 = DDSResponse[59];
decoded.DiscTypeSpecificField2 = BigEndianBitConverter.ToUInt32(DDSResponse, 60);
decoded.Reserved9 = BigEndianBitConverter.ToUInt32(DDSResponse, 64);
decoded.StatusBits = new byte[32];
Array.Copy(DDSResponse, 68, decoded.StatusBits, 0, 32);
decoded.DiscTypeSpecificData = new byte[DDSResponse.Length - 100];
Array.Copy(DDSResponse, 100, decoded.DiscTypeSpecificData, 0, DDSResponse.Length - 100);
return decoded;
}
public static string Prettify(DiscDefinitionStructure? DDSResponse)
{
if(DDSResponse == null)
return null;
DiscDefinitionStructure response = DDSResponse.Value;
var sb = new StringBuilder();
sb.AppendFormat("DDS Format: 0x{0:X2}", response.Format).AppendLine();
sb.AppendFormat("DDS has ben updated {0} times", response.UpdateCount).AppendLine();
sb.AppendFormat("First PSN of Drive Area: 0x{0:X8}", response.DriveAreaPSN).AppendLine();
sb.AppendFormat("First PSN of Defect List: 0x{0:X8}", response.DefectListPSN).AppendLine();
sb.AppendFormat("PSN of User Data Area's LSN 0: 0x{0:X8}", response.PSNofLSNZero).AppendLine();
sb.AppendFormat("Last User Data Area's LSN 0: 0x{0:X8}", response.LastUserAreaLSN).AppendLine();
sb.AppendFormat("ISA0 size: {0}", response.ISA0).AppendLine();
sb.AppendFormat("OSA size: {0}", response.OSA).AppendLine();
sb.AppendFormat("ISA1 size: {0}", response.ISA1).AppendLine();
sb.AppendFormat("Spare Area Full Flags: 0x{0:X2}", response.SpareAreaFullFlags).AppendLine();
sb.AppendFormat("Disc Type Specific Field 1: 0x{0:X2}", response.DiscTypeSpecificField1).AppendLine();
sb.AppendFormat("Disc Type Specific Field 2: 0x{0:X8}", response.DiscTypeSpecificField2).AppendLine();
sb.AppendFormat("Blu-ray DDS Status Bits in hex follows:");
sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.StatusBits, 80));
sb.AppendFormat("Blu-ray DDS Disc Type Specific Data in hex follows:");
sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.DiscTypeSpecificData, 80));
#if DEBUG
if(response.Reserved1 != 0)
sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
if(response.Reserved2 != 0)
sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
if(response.Reserved3 != 0)
sb.AppendFormat("Reserved3 = 0x{0:X2}", response.Reserved3).AppendLine();
if(response.Reserved4 != 0)
sb.AppendFormat("Reserved4 = 0x{0:X16}", response.Reserved4).AppendLine();
if(response.Reserved5 != 0)
sb.AppendFormat("Reserved5 = 0x{0:X8}", response.Reserved5).AppendLine();
if(response.Reserved6 != 0)
sb.AppendFormat("Reserved6 = 0x{0:X8}", response.Reserved6).AppendLine();
if(response.Reserved7 != 0)
sb.AppendFormat("Reserved7 = 0x{0:X2}", response.Reserved7).AppendLine();
if(response.Reserved8 != 0)
sb.AppendFormat("Reserved8 = 0x{0:X2}", response.Reserved8).AppendLine();
if(response.Reserved9 != 0)
sb.AppendFormat("Reserved9 = 0x{0:X8}", response.Reserved9).AppendLine();
#endif
return sb.ToString();
}
public static string Prettify(byte[] DDSResponse) => Prettify(Decode(DDSResponse));
#endregion Public methods
}

File diff suppressed because it is too large Load Diff

View File

@@ -35,96 +35,95 @@ using System.Text;
using Aaru.Console;
using Aaru.Helpers;
namespace Aaru.Decoders.Bluray
namespace Aaru.Decoders.Bluray;
// Information from the following standards:
// ANSI X3.304-1997
// T10/1048-D revision 9.0
// T10/1048-D revision 10a
// T10/1228-D revision 7.0c
// T10/1228-D revision 11a
// T10/1363-D revision 10g
// T10/1545-D revision 1d
// T10/1545-D revision 5
// T10/1545-D revision 5a
// 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")]
public static class Spare
{
// Information from the following standards:
// ANSI X3.304-1997
// T10/1048-D revision 9.0
// T10/1048-D revision 10a
// T10/1228-D revision 7.0c
// T10/1228-D revision 11a
// T10/1363-D revision 10g
// T10/1545-D revision 1d
// T10/1545-D revision 5
// T10/1545-D revision 5a
// 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")]
public static class Spare
#region Public structures
public struct SpareAreaInformation
{
#region Public structures
public struct SpareAreaInformation
{
/// <summary>Bytes 0 to 1 Always 14</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Bytes 4 to 7 Reserved</summary>
public uint Reserved3;
/// <summary>Bytes 8 to 11 Free spare blocks</summary>
public uint FreeSpareBlocks;
/// <summary>Bytes 12 to 15 Allocated spare blocks</summary>
public uint AllocatedSpareBlocks;
}
#endregion Public structures
#region Public methods
public static SpareAreaInformation? Decode(byte[] SAIResponse)
{
if(SAIResponse == null)
return null;
if(SAIResponse.Length != 16)
{
AaruConsole.DebugWriteLine("BD Spare Area Information decoder",
"Found incorrect Blu-ray Spare Area Information size ({0} bytes)",
SAIResponse.Length);
return null;
}
var decoded = new SpareAreaInformation
{
DataLength = BigEndianBitConverter.ToUInt16(SAIResponse, 0),
Reserved1 = SAIResponse[2],
Reserved2 = SAIResponse[3],
Reserved3 = BigEndianBitConverter.ToUInt32(SAIResponse, 4),
FreeSpareBlocks = BigEndianBitConverter.ToUInt32(SAIResponse, 8),
AllocatedSpareBlocks = BigEndianBitConverter.ToUInt32(SAIResponse, 12)
};
return decoded;
}
public static string Prettify(SpareAreaInformation? SAIResponse)
{
if(SAIResponse == null)
return null;
SpareAreaInformation response = SAIResponse.Value;
var sb = new StringBuilder();
#if DEBUG
if(response.Reserved1 != 0)
sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
if(response.Reserved2 != 0)
sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
if(response.Reserved3 != 0)
sb.AppendFormat("Reserved3 = 0x{0:X8}", response.Reserved3).AppendLine();
#endif
sb.AppendFormat("{0} free spare blocks", response.FreeSpareBlocks).AppendLine();
sb.AppendFormat("{0} allocated spare blocks", response.AllocatedSpareBlocks).AppendLine();
return sb.ToString();
}
public static string Prettify(byte[] SAIResponse) => Prettify(Decode(SAIResponse));
#endregion Public methods
/// <summary>Bytes 0 to 1 Always 14</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Bytes 4 to 7 Reserved</summary>
public uint Reserved3;
/// <summary>Bytes 8 to 11 Free spare blocks</summary>
public uint FreeSpareBlocks;
/// <summary>Bytes 12 to 15 Allocated spare blocks</summary>
public uint AllocatedSpareBlocks;
}
#endregion Public structures
#region Public methods
public static SpareAreaInformation? Decode(byte[] SAIResponse)
{
if(SAIResponse == null)
return null;
if(SAIResponse.Length != 16)
{
AaruConsole.DebugWriteLine("BD Spare Area Information decoder",
"Found incorrect Blu-ray Spare Area Information size ({0} bytes)",
SAIResponse.Length);
return null;
}
var decoded = new SpareAreaInformation
{
DataLength = BigEndianBitConverter.ToUInt16(SAIResponse, 0),
Reserved1 = SAIResponse[2],
Reserved2 = SAIResponse[3],
Reserved3 = BigEndianBitConverter.ToUInt32(SAIResponse, 4),
FreeSpareBlocks = BigEndianBitConverter.ToUInt32(SAIResponse, 8),
AllocatedSpareBlocks = BigEndianBitConverter.ToUInt32(SAIResponse, 12)
};
return decoded;
}
public static string Prettify(SpareAreaInformation? SAIResponse)
{
if(SAIResponse == null)
return null;
SpareAreaInformation response = SAIResponse.Value;
var sb = new StringBuilder();
#if DEBUG
if(response.Reserved1 != 0)
sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
if(response.Reserved2 != 0)
sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
if(response.Reserved3 != 0)
sb.AppendFormat("Reserved3 = 0x{0:X8}", response.Reserved3).AppendLine();
#endif
sb.AppendFormat("{0} free spare blocks", response.FreeSpareBlocks).AppendLine();
sb.AppendFormat("{0} allocated spare blocks", response.AllocatedSpareBlocks).AppendLine();
return sb.ToString();
}
public static string Prettify(byte[] SAIResponse) => Prettify(Decode(SAIResponse));
#endregion Public methods
}