mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: All refactor in DiscImageChef.Decoders.
This commit is contained in:
@@ -31,16 +31,20 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
namespace DiscImageChef.Decoders.Xbox
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
public static class DMI
|
||||
{
|
||||
public static bool IsXbox(byte[] dmi)
|
||||
{
|
||||
if(dmi == null) return false;
|
||||
if(dmi.Length != 2052) return false;
|
||||
if(dmi?.Length != 2052) return false;
|
||||
|
||||
// Version is 1
|
||||
if(BitConverter.ToUInt32(dmi, 4) != 1) return false;
|
||||
@@ -54,15 +58,12 @@ namespace DiscImageChef.Decoders.Xbox
|
||||
long timestamp = BitConverter.ToInt64(dmi, 20);
|
||||
|
||||
// Game cannot exist before the Xbox
|
||||
if(timestamp < 0x1BD164833DFC000) return false;
|
||||
|
||||
return true;
|
||||
return timestamp >= 0x1BD164833DFC000;
|
||||
}
|
||||
|
||||
public static bool IsXbox360(byte[] dmi)
|
||||
{
|
||||
if(dmi == null) return false;
|
||||
if(dmi.Length != 2052) return false;
|
||||
if(dmi?.Length != 2052) return false;
|
||||
|
||||
uint signature = BitConverter.ToUInt32(dmi, 0x7EC);
|
||||
|
||||
@@ -155,14 +156,15 @@ namespace DiscImageChef.Decoders.Xbox
|
||||
bool isXbox = IsXbox(response);
|
||||
if(!isXbox) return null;
|
||||
|
||||
XboxDMI dmi = new XboxDMI();
|
||||
XboxDMI dmi = new XboxDMI
|
||||
{
|
||||
DataLength = (ushort)((response[0] << 8) + response[1]),
|
||||
Reserved1 = response[2],
|
||||
Reserved2 = response[3],
|
||||
Version = BitConverter.ToUInt32(response, 4),
|
||||
Timestamp = BitConverter.ToInt64(response, 20)
|
||||
};
|
||||
|
||||
dmi.DataLength = (ushort)((response[0] << 8) + response[1]);
|
||||
dmi.Reserved1 = response[2];
|
||||
dmi.Reserved2 = response[3];
|
||||
|
||||
dmi.Version = BitConverter.ToUInt32(response, 4);
|
||||
dmi.Timestamp = BitConverter.ToInt64(response, 20);
|
||||
byte[] tmp = new byte[8];
|
||||
Array.Copy(response, 12, tmp, 0, 8);
|
||||
dmi.CatalogNumber = StringHandlers.CToString(tmp);
|
||||
@@ -175,23 +177,22 @@ namespace DiscImageChef.Decoders.Xbox
|
||||
bool isX360 = IsXbox360(response);
|
||||
if(!isX360) return null;
|
||||
|
||||
Xbox360DMI dmi = new Xbox360DMI();
|
||||
Xbox360DMI dmi = new Xbox360DMI
|
||||
{
|
||||
DataLength = (ushort)((response[0] << 8) + response[1]),
|
||||
Reserved1 = response[2],
|
||||
Reserved2 = response[3],
|
||||
Version = BitConverter.ToUInt32(response, 4),
|
||||
Timestamp = BitConverter.ToInt64(response, 20),
|
||||
MediaID = new byte[16]
|
||||
};
|
||||
|
||||
dmi.DataLength = (ushort)((response[0] << 8) + response[1]);
|
||||
dmi.Reserved1 = response[2];
|
||||
dmi.Reserved2 = response[3];
|
||||
|
||||
dmi.Version = BitConverter.ToUInt32(response, 4);
|
||||
dmi.Timestamp = BitConverter.ToInt64(response, 20);
|
||||
dmi.MediaID = new byte[16];
|
||||
Array.Copy(response, 36, dmi.MediaID, 0, 16);
|
||||
byte[] tmp = new byte[16];
|
||||
Array.Copy(response, 68, tmp, 0, 16);
|
||||
dmi.CatalogNumber = StringHandlers.CToString(tmp);
|
||||
|
||||
if(dmi.CatalogNumber == null || dmi.CatalogNumber.Length < 13) return null;
|
||||
|
||||
return dmi;
|
||||
return dmi.CatalogNumber == null || dmi.CatalogNumber.Length < 13 ? (Xbox360DMI?)null : dmi;
|
||||
}
|
||||
|
||||
public static string PrettifyXbox(XboxDMI? dmi)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user