Remove the ability to support little endian from BigEndianBitConverter.

This commit is contained in:
2019-05-11 20:49:32 +01:00
parent e4c2890552
commit 71cb591368
16 changed files with 159 additions and 163 deletions

View File

@@ -227,8 +227,6 @@ namespace DiscImageChef.Decoders.SCSI.MMC
AACSVolumeIdentifier decoded = new AACSVolumeIdentifier();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
decoded.VolumeIdentifier = new byte[AACSVIResponse.Length - 4];
decoded.DataLength = BigEndianBitConverter.ToUInt16(AACSVIResponse, 0);
@@ -269,8 +267,6 @@ namespace DiscImageChef.Decoders.SCSI.MMC
AACSMediaSerialNumber decoded = new AACSMediaSerialNumber();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
decoded.MediaSerialNumber = new byte[AACSMSNResponse.Length - 4];
decoded.DataLength = BigEndianBitConverter.ToUInt16(AACSMSNResponse, 0);
@@ -311,8 +307,6 @@ namespace DiscImageChef.Decoders.SCSI.MMC
AACSMediaIdentifier decoded = new AACSMediaIdentifier();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
decoded.MediaIdentifier = new byte[AACSMIResponse.Length - 4];
decoded.DataLength = BigEndianBitConverter.ToUInt16(AACSMIResponse, 0);
@@ -353,8 +347,6 @@ namespace DiscImageChef.Decoders.SCSI.MMC
AACSMediaKeyBlock decoded = new AACSMediaKeyBlock();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
decoded.MediaKeyBlockPacks = new byte[AACSMKBResponse.Length - 4];
decoded.DataLength = BigEndianBitConverter.ToUInt16(AACSMKBResponse, 0);
@@ -396,8 +388,6 @@ namespace DiscImageChef.Decoders.SCSI.MMC
AACSDataKeys decoded = new AACSDataKeys();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
decoded.DataKeys = new byte[AACSDKResponse.Length - 4];
decoded.DataLength = BigEndianBitConverter.ToUInt16(AACSDKResponse, 0);
@@ -436,13 +426,12 @@ namespace DiscImageChef.Decoders.SCSI.MMC
{
if(AACSLBAExtsResponse == null) return null;
AACSLBAExtentsResponse decoded = new AACSLBAExtentsResponse();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
decoded.DataLength = BigEndianBitConverter.ToUInt16(AACSLBAExtsResponse, 0);
decoded.Reserved = AACSLBAExtsResponse[2];
decoded.MaxLBAExtents = AACSLBAExtsResponse[3];
AACSLBAExtentsResponse decoded = new AACSLBAExtentsResponse
{
DataLength = BigEndianBitConverter.ToUInt16(AACSLBAExtsResponse, 0),
Reserved = AACSLBAExtsResponse[2],
MaxLBAExtents = AACSLBAExtsResponse[3]
};
if((AACSLBAExtsResponse.Length - 4) % 16 != 0) return decoded;

View File

@@ -85,15 +85,14 @@ namespace DiscImageChef.Decoders.SCSI.MMC
{
if(CPRMMKBResponse == null) return null;
CPRMMediaKeyBlock decoded = new CPRMMediaKeyBlock();
CPRMMediaKeyBlock decoded = new CPRMMediaKeyBlock
{
MKBPackData = new byte[CPRMMKBResponse.Length - 4],
DataLength = BigEndianBitConverter.ToUInt16(CPRMMKBResponse, 0),
Reserved = CPRMMKBResponse[2],
TotalPacks = CPRMMKBResponse[3]
};
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
decoded.MKBPackData = new byte[CPRMMKBResponse.Length - 4];
decoded.DataLength = BigEndianBitConverter.ToUInt16(CPRMMKBResponse, 0);
decoded.Reserved = CPRMMKBResponse[2];
decoded.TotalPacks = CPRMMKBResponse[3];
Array.Copy(CPRMMKBResponse, 4, decoded.MKBPackData, 0, CPRMMKBResponse.Length - 4);
return decoded;

View File

@@ -30,7 +30,6 @@
// Copyright © 2011-2019 Natalia Portillo
// ****************************************************************************/
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
@@ -112,20 +111,18 @@ namespace DiscImageChef.Decoders.SCSI.MMC
if(FormatLayersResponse.Length < 8) return null;
RecognizedFormatLayers decoded = new RecognizedFormatLayers();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
decoded.DataLength = BigEndianBitConverter.ToUInt16(FormatLayersResponse, 0);
decoded.Reserved1 = FormatLayersResponse[2];
decoded.Reserved2 = FormatLayersResponse[3];
decoded.NumberOfLayers = FormatLayersResponse[4];
decoded.Reserved3 = (byte)((FormatLayersResponse[5] & 0xC0) >> 6);
decoded.DefaultFormatLayer = (byte)((FormatLayersResponse[5] & 0x30) >> 4);
decoded.Reserved4 = (byte)((FormatLayersResponse[5] & 0x0C) >> 2);
decoded.OnlineFormatLayer = (byte)(FormatLayersResponse[5] & 0x03);
decoded.FormatLayers = new ushort[(FormatLayersResponse.Length - 6) / 2];
RecognizedFormatLayers decoded = new RecognizedFormatLayers
{
DataLength = BigEndianBitConverter.ToUInt16(FormatLayersResponse, 0),
Reserved1 = FormatLayersResponse[2],
Reserved2 = FormatLayersResponse[3],
NumberOfLayers = FormatLayersResponse[4],
Reserved3 = (byte)((FormatLayersResponse[5] & 0xC0) >> 6),
DefaultFormatLayer = (byte)((FormatLayersResponse[5] & 0x30) >> 4),
Reserved4 = (byte)((FormatLayersResponse[5] & 0x0C) >> 2),
OnlineFormatLayer = (byte)(FormatLayersResponse[5] & 0x03),
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);
@@ -153,6 +150,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC
if(response.OnlineFormatLayer == i) sb.AppendLine("This is the layer actually in use.");
break;
}
case (ushort)FormatLayerTypeCodes.CDLayer:
{
sb.AppendFormat("Layer {0} is of type CD", i).AppendLine();
@@ -160,6 +158,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC
if(response.OnlineFormatLayer == i) sb.AppendLine("This is the layer actually in use.");
break;
}
case (ushort)FormatLayerTypeCodes.DVDLayer:
{
sb.AppendFormat("Layer {0} is of type DVD", i).AppendLine();
@@ -167,6 +166,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC
if(response.OnlineFormatLayer == i) sb.AppendLine("This is the layer actually in use.");
break;
}
case (ushort)FormatLayerTypeCodes.HDDVDLayer:
{
sb.AppendFormat("Layer {0} is of type HD DVD", i).AppendLine();
@@ -174,6 +174,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC
if(response.OnlineFormatLayer == i) sb.AppendLine("This is the layer actually in use.");
break;
}
default:
{
sb.AppendFormat("Layer {0} is of unknown type 0x{1:X4}", i, response.FormatLayers[i])

View File

@@ -120,21 +120,20 @@ namespace DiscImageChef.Decoders.SCSI.MMC
{
if(WPSResponse == null) return null;
WriteProtectionStatus decoded = new WriteProtectionStatus();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
decoded.DataLength = BigEndianBitConverter.ToUInt16(WPSResponse, 0);
decoded.Reserved1 = WPSResponse[2];
decoded.Reserved2 = WPSResponse[3];
decoded.Reserved3 = (byte)((WPSResponse[4] & 0xF0) >> 4);
decoded.MSWI = Convert.ToBoolean(WPSResponse[4] & 0x08);
decoded.CWP = Convert.ToBoolean(WPSResponse[4] & 0x04);
decoded.PWP = Convert.ToBoolean(WPSResponse[4] & 0x02);
decoded.SWPP = Convert.ToBoolean(WPSResponse[4] & 0x01);
decoded.Reserved4 = WPSResponse[5];
decoded.Reserved5 = WPSResponse[6];
decoded.Reserved6 = WPSResponse[7];
WriteProtectionStatus decoded = new WriteProtectionStatus
{
DataLength = BigEndianBitConverter.ToUInt16(WPSResponse, 0),
Reserved1 = WPSResponse[2],
Reserved2 = WPSResponse[3],
Reserved3 = (byte)((WPSResponse[4] & 0xF0) >> 4),
MSWI = Convert.ToBoolean(WPSResponse[4] & 0x08),
CWP = Convert.ToBoolean(WPSResponse[4] & 0x04),
PWP = Convert.ToBoolean(WPSResponse[4] & 0x02),
SWPP = Convert.ToBoolean(WPSResponse[4] & 0x01),
Reserved4 = WPSResponse[5],
Reserved5 = WPSResponse[6],
Reserved6 = WPSResponse[7]
};
return decoded;
}