REFACTOR: All refactor in DiscImageChef.Decoders.

This commit is contained in:
2017-12-22 02:04:18 +00:00
parent 7f829422a8
commit 49144eeb01
148 changed files with 2606 additions and 1939 deletions

View File

@@ -31,11 +31,16 @@
// ****************************************************************************/
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using DiscImageChef.Decoders.DVD;
namespace DiscImageChef.Decoders.Xbox
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
public static class SS
{
public struct SecuritySector
@@ -221,82 +226,92 @@ namespace DiscImageChef.Decoders.Xbox
if(response.Length < 2048) return null;
SecuritySector ss = new SecuritySector();
SecuritySector ss = new SecuritySector
{
DiskCategory = (DiskCategory)((response[0] & 0xF0) >> 4),
PartVersion = (byte)(response[0] & 0x0F),
DiscSize = (DVDSize)((response[1] & 0xF0) >> 4),
MaximumRate = (MaximumRateField)(response[1] & 0x0F),
Reserved3 = (response[2] & 0x80) == 0x80,
Layers = (byte)((response[2] & 0x60) >> 5),
TrackPath = (response[2] & 0x08) == 0x08,
LayerType = (LayerTypeFieldMask)(response[2] & 0x07),
LinearDensity = (LinearDensityField)((response[3] & 0xF0) >> 4),
TrackDensity = (TrackDensityField)(response[3] & 0x0F),
DataAreaStartPSN = (uint)((response[4] << 24) + (response[5] << 16) + (response[6] << 8) + response[7]),
DataAreaEndPSN = (uint)((response[8] << 24) + (response[9] << 16) + (response[10] << 8) + response[11]),
Layer0EndPSN = (uint)((response[12] << 24) + (response[13] << 16) + (response[14] << 8) + response[15]),
Unknown1 = response[27],
Unknown2 = new byte[28],
Unknown3 = new byte[436],
Unknown4 = new byte[4],
Unknown5 = new byte[43],
ChallengeTableVersion = response[768],
NoChallengeEntries = response[769],
ChallengeEntries = new ChallengeEntry[23],
Unknown6 = response[1023],
Unknown7 = new byte[48],
Unknown8 = new byte[16],
Unknown9 = new byte[16],
Unknown10 = new byte[303],
Unknown11 = new byte[104],
Extents = new SecuritySectorExtent[23],
ExtentsCopy = new SecuritySectorExtent[23]
};
// Common
ss.DiskCategory = (DiskCategory)((response[0] & 0xF0) >> 4);
ss.PartVersion = (byte)(response[0] & 0x0F);
ss.DiscSize = (DVDSize)((response[1] & 0xF0) >> 4);
ss.MaximumRate = (MaximumRateField)(response[1] & 0x0F);
ss.Reserved3 |= (response[2] & 0x80) == 0x80;
ss.Layers = (byte)((response[2] & 0x60) >> 5);
ss.TrackPath |= (response[2] & 0x08) == 0x08;
ss.LayerType = (LayerTypeFieldMask)(response[2] & 0x07);
ss.LinearDensity = (LinearDensityField)((response[3] & 0xF0) >> 4);
ss.TrackDensity = (TrackDensityField)(response[3] & 0x0F);
ss.DataAreaStartPSN = (uint)((response[4] << 24) + (response[5] << 16) + (response[6] << 8) + response[7]);
ss.DataAreaEndPSN = (uint)((response[8] << 24) + (response[9] << 16) + (response[10] << 8) + response[11]);
ss.Layer0EndPSN = (uint)((response[12] << 24) + (response[13] << 16) + (response[14] << 8) + response[15]);
ss.Unknown1 = response[27];
ss.Unknown2 = new byte[28];
Array.Copy(response, 256, ss.Unknown2, 0, 28);
ss.Unknown3 = new byte[436];
Array.Copy(response, 284, ss.Unknown3, 0, 436);
ss.Unknown4 = new byte[4];
Array.Copy(response, 720, ss.Unknown4, 0, 4);
ss.Unknown5 = new byte[43];
Array.Copy(response, 724, ss.Unknown5, 0, 43);
ss.ChallengeTableVersion = response[768];
ss.NoChallengeEntries = response[769];
ss.ChallengeEntries = new ChallengeEntry[23];
for(int i = 0; i < 23; i++)
{
ss.ChallengeEntries[i] = new ChallengeEntry();
ss.ChallengeEntries[i].Level = response[770 + i * 11 + 0];
ss.ChallengeEntries[i].ChallengeId = response[770 + i * 11 + 1];
ss.ChallengeEntries[i].ChallengeValue =
(uint)((response[770 + i * 11 + 2] << 24) + (response[770 + i * 11 + 3] << 16) +
(response[770 + i * 11 + 4] << 8) + response[770 + i * 11 + 5]);
ss.ChallengeEntries[i].ResponseModifier = response[770 + i * 11 + 6];
ss.ChallengeEntries[i].ResponseValue =
(uint)((response[770 + i * 11 + 7] << 24) + (response[770 + i * 11 + 8] << 16) +
(response[770 + i * 11 + 9] << 8) + response[770 + i * 11 + 10]);
ss.ChallengeEntries[i] = new ChallengeEntry
{
Level = response[770 + i * 11 + 0],
ChallengeId = response[770 + i * 11 + 1],
ChallengeValue =
(uint)((response[770 + i * 11 + 2] << 24) + (response[770 + i * 11 + 3] << 16) +
(response[770 + i * 11 + 4] << 8) + response[770 + i * 11 + 5]),
ResponseModifier = response[770 + i * 11 + 6],
ResponseValue = (uint)((response[770 + i * 11 + 7] << 24) + (response[770 + i * 11 + 8] << 16) +
(response[770 + i * 11 + 9] << 8) + response[770 + i * 11 + 10])
};
}
ss.Unknown6 = response[1023];
ss.Unknown7 = new byte[48];
Array.Copy(response, 1052, ss.Unknown7, 0, 48);
ss.Unknown8 = new byte[16];
Array.Copy(response, 1120, ss.Unknown8, 0, 16);
ss.Unknown9 = new byte[16];
Array.Copy(response, 1180, ss.Unknown9, 0, 16);
ss.Unknown10 = new byte[303];
Array.Copy(response, 1208, ss.Unknown10, 0, 303);
ss.Unknown11 = new byte[104];
Array.Copy(response, 1528, ss.Unknown11, 0, 104);
ss.Extents = new SecuritySectorExtent[23];
for(int i = 0; i < 23; i++)
{
ss.Extents[i] = new SecuritySectorExtent();
ss.Extents[i].Unknown = (uint)((response[1633 + i * 9 + 0] << 16) + (response[1633 + i * 9 + 1] << 8) +
response[1633 + i * 9 + 2]);
ss.Extents[i].StartPSN = (uint)((response[1633 + i * 9 + 3] << 16) + (response[1633 + i * 9 + 4] << 8) +
response[1633 + i * 9 + 5]);
ss.Extents[i].EndPSN = (uint)((response[1633 + i * 9 + 6] << 16) + (response[1633 + i * 9 + 7] << 8) +
response[1633 + i * 9 + 8]);
ss.Extents[i] = new SecuritySectorExtent
{
Unknown =
(uint)((response[1633 + i * 9 + 0] << 16) + (response[1633 + i * 9 + 1] << 8) +
response[1633 + i * 9 + 2]),
StartPSN =
(uint)((response[1633 + i * 9 + 3] << 16) + (response[1633 + i * 9 + 4] << 8) +
response[1633 + i * 9 + 5]),
EndPSN = (uint)((response[1633 + i * 9 + 6] << 16) + (response[1633 + i * 9 + 7] << 8) +
response[1633 + i * 9 + 8])
};
}
ss.ExtentsCopy = new SecuritySectorExtent[23];
for(int i = 0; i < 23; i++)
{
ss.ExtentsCopy[i] = new SecuritySectorExtent();
ss.ExtentsCopy[i].Unknown = (uint)((response[1840 + i * 9 + 0] << 16) +
(response[1840 + i * 9 + 1] << 8) + response[1840 + i * 9 + 2]);
ss.ExtentsCopy[i].StartPSN = (uint)((response[1840 + i * 9 + 3] << 16) +
(response[1840 + i * 9 + 4] << 8) + response[1840 + i * 9 + 5]);
ss.ExtentsCopy[i].EndPSN = (uint)((response[1840 + i * 9 + 6] << 16) +
(response[1840 + i * 9 + 7] << 8) + response[1840 + i * 9 + 8]);
ss.ExtentsCopy[i] = new SecuritySectorExtent
{
Unknown =
(uint)((response[1840 + i * 9 + 0] << 16) + (response[1840 + i * 9 + 1] << 8) +
response[1840 + i * 9 + 2]),
StartPSN =
(uint)((response[1840 + i * 9 + 3] << 16) + (response[1840 + i * 9 + 4] << 8) +
response[1840 + i * 9 + 5]),
EndPSN = (uint)((response[1840 + i * 9 + 6] << 16) + (response[1840 + i * 9 + 7] << 8) +
response[1840 + i * 9 + 8])
};
}
return ss;
@@ -323,7 +338,7 @@ namespace DiscImageChef.Decoders.Xbox
break;
}
string categorySentence = "Disc is a {0} {1} version {2}";
const string categorySentence = "Disc is a {0} {1} version {2}";
switch(decoded.DiskCategory)
{