mirror of
https://github.com/aaru-dps/Aaru.Checksums.git
synced 2025-12-16 19:24:29 +00:00
Reformatted.
This commit is contained in:
156
CDChecksums.cs
156
CDChecksums.cs
@@ -50,7 +50,7 @@ namespace DiscImageChef.Checksums
|
||||
|
||||
public static bool? CheckCDSector(byte[] buffer)
|
||||
{
|
||||
switch (buffer.Length)
|
||||
switch(buffer.Length)
|
||||
{
|
||||
case 2448:
|
||||
{
|
||||
@@ -64,15 +64,15 @@ namespace DiscImageChef.Checksums
|
||||
bool? subchannelStatus = CheckCDSectorSubChannel(subchannel);
|
||||
bool? status = null;
|
||||
|
||||
if (channelStatus == null && subchannelStatus == null)
|
||||
if(channelStatus == null && subchannelStatus == null)
|
||||
status = null;
|
||||
if (channelStatus == false || subchannelStatus == false)
|
||||
if(channelStatus == false || subchannelStatus == false)
|
||||
status = false;
|
||||
if (channelStatus == null && subchannelStatus == true)
|
||||
if(channelStatus == null && subchannelStatus == true)
|
||||
status = true;
|
||||
if (channelStatus == true && subchannelStatus == null)
|
||||
if(channelStatus == true && subchannelStatus == null)
|
||||
status = true;
|
||||
if (channelStatus == true && subchannelStatus == true)
|
||||
if(channelStatus == true && subchannelStatus == true)
|
||||
status = true;
|
||||
|
||||
return status;
|
||||
@@ -89,7 +89,7 @@ namespace DiscImageChef.Checksums
|
||||
ECC_F_Table = new byte[256];
|
||||
ECC_B_Table = new byte[256];
|
||||
|
||||
for (UInt32 i = 0; i < 256; i++)
|
||||
for(UInt32 i = 0; i < 256; i++)
|
||||
{
|
||||
UInt32 j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0));
|
||||
ECC_F_Table[i] = (byte)j;
|
||||
@@ -109,16 +109,16 @@ namespace DiscImageChef.Checksums
|
||||
{
|
||||
UInt32 size = major_count * minor_count;
|
||||
UInt32 major;
|
||||
for (major = 0; major < major_count; major++)
|
||||
for(major = 0; major < major_count; major++)
|
||||
{
|
||||
UInt32 index = (major >> 1) * major_mult + (major & 1);
|
||||
byte ecc_a = 0;
|
||||
byte ecc_b = 0;
|
||||
UInt32 minor;
|
||||
for (minor = 0; minor < minor_count; minor++)
|
||||
for(minor = 0; minor < minor_count; minor++)
|
||||
{
|
||||
byte temp;
|
||||
if (index < 4)
|
||||
if(index < 4)
|
||||
{
|
||||
temp = address[index];
|
||||
}
|
||||
@@ -127,7 +127,7 @@ namespace DiscImageChef.Checksums
|
||||
temp = data[index - 4];
|
||||
}
|
||||
index += minor_inc;
|
||||
if (index >= size)
|
||||
if(index >= size)
|
||||
{
|
||||
index -= size;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ namespace DiscImageChef.Checksums
|
||||
ecc_a = ECC_F_Table[ecc_a];
|
||||
}
|
||||
ecc_a = ECC_B_Table[ECC_F_Table[ecc_a] ^ ecc_b];
|
||||
if (
|
||||
if(
|
||||
ecc[major] != (ecc_a) ||
|
||||
ecc[major + major_count] != (ecc_a ^ ecc_b))
|
||||
{
|
||||
@@ -150,7 +150,7 @@ namespace DiscImageChef.Checksums
|
||||
{
|
||||
ECCInit();
|
||||
|
||||
if (
|
||||
if(
|
||||
channel[0x000] == 0x00 && // sync (12 bytes)
|
||||
channel[0x001] == 0xFF &&
|
||||
channel[0x002] == 0xFF &&
|
||||
@@ -166,12 +166,12 @@ namespace DiscImageChef.Checksums
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Data sector, address {0:X2}:{1:X2}:{2:X2}", channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
if (channel[0x00F] == 0x00) // mode (1 byte)
|
||||
if(channel[0x00F] == 0x00) // mode (1 byte)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 0 sector at address {0:X2}:{1:X2}:{2:X2}", channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
for (int i = 0x010; i < 0x930; i++)
|
||||
for(int i = 0x010; i < 0x930; i++)
|
||||
{
|
||||
if (channel[i] != 0x00)
|
||||
if(channel[i] != 0x00)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 0 sector with error at address: {0:X2}:{1:X2}:{2:X2}", channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
return false;
|
||||
@@ -179,11 +179,11 @@ namespace DiscImageChef.Checksums
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (channel[0x00F] == 0x01) // mode (1 byte)
|
||||
else if(channel[0x00F] == 0x01) // mode (1 byte)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 1 sector at address {0:X2}:{1:X2}:{2:X2}", channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
if (channel[0x814] != 0x00 || // reserved (8 bytes)
|
||||
if(channel[0x814] != 0x00 || // reserved (8 bytes)
|
||||
channel[0x815] != 0x00 ||
|
||||
channel[0x816] != 0x00 ||
|
||||
channel[0x817] != 0x00 ||
|
||||
@@ -211,12 +211,12 @@ namespace DiscImageChef.Checksums
|
||||
bool FailedECC_P = CheckECC(address, data, 86, 24, 2, 86, ecc_p);
|
||||
bool FailedECC_Q = CheckECC(address, data2, 52, 43, 86, 88, ecc_q);
|
||||
|
||||
if (FailedECC_P)
|
||||
if(FailedECC_P)
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC P check", channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
if (FailedECC_Q)
|
||||
if(FailedECC_Q)
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC Q check", channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
if (FailedECC_P || FailedECC_Q)
|
||||
if(FailedECC_P || FailedECC_Q)
|
||||
return false;
|
||||
|
||||
byte[] SectorForCheck = new byte[0x810];
|
||||
@@ -226,7 +226,7 @@ namespace DiscImageChef.Checksums
|
||||
CRC32Context.Data(SectorForCheck, 0x810, out CalculatedEDCBytes, CDCRC32Poly, CDCRC32Seed);
|
||||
UInt32 CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0);
|
||||
|
||||
if (CalculatedEDC != StoredEDC)
|
||||
if(CalculatedEDC != StoredEDC)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}", channel[0x00C], channel[0x00D], channel[0x00E], CalculatedEDC, StoredEDC);
|
||||
return false;
|
||||
@@ -234,13 +234,13 @@ namespace DiscImageChef.Checksums
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (channel[0x00F] == 0x02) // mode (1 byte)
|
||||
else if(channel[0x00F] == 0x02) // mode (1 byte)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 2 sector at address {0:X2}:{1:X2}:{2:X2}", channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
if ((channel[0x012] & 0x20) == 0x20) // mode 2 form 2
|
||||
if((channel[0x012] & 0x20) == 0x20) // mode 2 form 2
|
||||
{
|
||||
if (channel[0x010] != channel[0x014] || channel[0x011] != channel[0x015] || channel[0x012] != channel[0x016] || channel[0x013] != channel[0x017])
|
||||
if(channel[0x010] != channel[0x014] || channel[0x011] != channel[0x015] || channel[0x012] != channel[0x016] || channel[0x013] != channel[0x017])
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Subheader copies differ in mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}", channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
}
|
||||
@@ -252,7 +252,7 @@ namespace DiscImageChef.Checksums
|
||||
CRC32Context.Data(SectorForCheck, 0x91C, out CalculatedEDCBytes, CDCRC32Poly, CDCRC32Seed);
|
||||
UInt32 CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0);
|
||||
|
||||
if (CalculatedEDC != StoredEDC && StoredEDC != 0x00000000)
|
||||
if(CalculatedEDC != StoredEDC && StoredEDC != 0x00000000)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}", channel[0x00C], channel[0x00D], channel[0x00E], CalculatedEDC, StoredEDC);
|
||||
return false;
|
||||
@@ -260,7 +260,7 @@ namespace DiscImageChef.Checksums
|
||||
}
|
||||
else
|
||||
{
|
||||
if (channel[0x010] != channel[0x014] || channel[0x011] != channel[0x015] || channel[0x012] != channel[0x016] || channel[0x013] != channel[0x017])
|
||||
if(channel[0x010] != channel[0x014] || channel[0x011] != channel[0x015] || channel[0x012] != channel[0x016] || channel[0x013] != channel[0x017])
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Subheader copies differ in mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}", channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
}
|
||||
@@ -283,12 +283,12 @@ namespace DiscImageChef.Checksums
|
||||
bool FailedECC_P = CheckECC(address, data, 86, 24, 2, 86, ecc_p);
|
||||
bool FailedECC_Q = CheckECC(address, data2, 52, 43, 86, 88, ecc_q);
|
||||
|
||||
if (FailedECC_P)
|
||||
if(FailedECC_P)
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC P check", channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
if (FailedECC_Q)
|
||||
if(FailedECC_Q)
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC Q check", channel[0x00F], channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||
|
||||
if (FailedECC_P || FailedECC_Q)
|
||||
if(FailedECC_P || FailedECC_Q)
|
||||
return false;
|
||||
|
||||
byte[] SectorForCheck = new byte[0x808];
|
||||
@@ -298,7 +298,7 @@ namespace DiscImageChef.Checksums
|
||||
CRC32Context.Data(SectorForCheck, 0x808, out CalculatedEDCBytes, CDCRC32Poly, CDCRC32Seed);
|
||||
UInt32 CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0);
|
||||
|
||||
if (CalculatedEDC != StoredEDC)
|
||||
if(CalculatedEDC != StoredEDC)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}", channel[0x00C], channel[0x00D], channel[0x00E], CalculatedEDC, StoredEDC);
|
||||
return false;
|
||||
@@ -330,16 +330,16 @@ namespace DiscImageChef.Checksums
|
||||
byte[] CDSubRWPack4 = new byte[24];
|
||||
|
||||
int i = 0;
|
||||
for (int j = 0; j < 12; j++)
|
||||
for(int j = 0; j < 12; j++)
|
||||
QSubChannel[j] = 0;
|
||||
for (int j = 0; j < 18; j++)
|
||||
for(int j = 0; j < 18; j++)
|
||||
{
|
||||
CDTextPack1[j] = 0;
|
||||
CDTextPack2[j] = 0;
|
||||
CDTextPack3[j] = 0;
|
||||
CDTextPack4[j] = 0;
|
||||
}
|
||||
for (int j = 0; j < 24; j++)
|
||||
for(int j = 0; j < 24; j++)
|
||||
{
|
||||
CDSubRWPack1[j] = 0;
|
||||
CDSubRWPack2[j] = 0;
|
||||
@@ -347,7 +347,7 @@ namespace DiscImageChef.Checksums
|
||||
CDSubRWPack4[j] = 0;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 12; j++)
|
||||
for(int j = 0; j < 12; j++)
|
||||
{
|
||||
QSubChannel[j] = (byte)(QSubChannel[j] | ((subchannel[i++] & 0x40) << 1));
|
||||
QSubChannel[j] = (byte)(QSubChannel[j] | (subchannel[i++] & 0x40));
|
||||
@@ -360,86 +360,86 @@ namespace DiscImageChef.Checksums
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for (int j = 0; j < 18; j++)
|
||||
for(int j = 0; j < 18; j++)
|
||||
{
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack1[j] = (byte)(CDTextPack1[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack1[j] = (byte)(CDTextPack1[j++] | ((subchannel[i] & 0xC0) >> 4));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack1[j] = (byte)(CDTextPack1[j] | ((subchannel[i++] & 0x0F) << 4));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack1[j] = (byte)(CDTextPack1[j++] | ((subchannel[i] & 0x3C) >> 2));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack1[j] = (byte)(CDTextPack1[j] | ((subchannel[i++] & 0x03) << 6));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack1[j] = (byte)(CDTextPack1[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
for (int j = 0; j < 18; j++)
|
||||
for(int j = 0; j < 18; j++)
|
||||
{
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack2[j] = (byte)(CDTextPack2[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack2[j] = (byte)(CDTextPack2[j++] | ((subchannel[i] & 0xC0) >> 4));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack2[j] = (byte)(CDTextPack2[j] | ((subchannel[i++] & 0x0F) << 4));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack2[j] = (byte)(CDTextPack2[j++] | ((subchannel[i] & 0x3C) >> 2));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack2[j] = (byte)(CDTextPack2[j] | ((subchannel[i++] & 0x03) << 6));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack2[j] = (byte)(CDTextPack2[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
for (int j = 0; j < 18; j++)
|
||||
for(int j = 0; j < 18; j++)
|
||||
{
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack3[j] = (byte)(CDTextPack3[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack3[j] = (byte)(CDTextPack3[j++] | ((subchannel[i] & 0xC0) >> 4));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack3[j] = (byte)(CDTextPack3[j] | ((subchannel[i++] & 0x0F) << 4));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack3[j] = (byte)(CDTextPack3[j++] | ((subchannel[i] & 0x3C) >> 2));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack3[j] = (byte)(CDTextPack3[j] | ((subchannel[i++] & 0x03) << 6));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack3[j] = (byte)(CDTextPack3[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
for (int j = 0; j < 18; j++)
|
||||
for(int j = 0; j < 18; j++)
|
||||
{
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack4[j] = (byte)(CDTextPack4[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack4[j] = (byte)(CDTextPack4[j++] | ((subchannel[i] & 0xC0) >> 4));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack4[j] = (byte)(CDTextPack4[j] | ((subchannel[i++] & 0x0F) << 4));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack4[j] = (byte)(CDTextPack4[j++] | ((subchannel[i] & 0x3C) >> 2));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack4[j] = (byte)(CDTextPack4[j] | ((subchannel[i++] & 0x03) << 6));
|
||||
if (j < 18)
|
||||
if(j < 18)
|
||||
CDTextPack4[j] = (byte)(CDTextPack4[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for (int j = 0; j < 24; j++)
|
||||
for(int j = 0; j < 24; j++)
|
||||
{
|
||||
CDSubRWPack1[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
}
|
||||
for (int j = 0; j < 24; j++)
|
||||
for(int j = 0; j < 24; j++)
|
||||
{
|
||||
CDSubRWPack2[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
}
|
||||
for (int j = 0; j < 24; j++)
|
||||
for(int j = 0; j < 24; j++)
|
||||
{
|
||||
CDSubRWPack3[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
}
|
||||
for (int j = 0; j < 24; j++)
|
||||
for(int j = 0; j < 24; j++)
|
||||
{
|
||||
CDSubRWPack4[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
}
|
||||
|
||||
switch (CDSubRWPack1[0])
|
||||
switch(CDSubRWPack1[0])
|
||||
{
|
||||
case 0x00:
|
||||
DicConsole.DebugWriteLine("CD checksums", "Detected Zero Pack in subchannel");
|
||||
@@ -474,27 +474,27 @@ namespace DiscImageChef.Checksums
|
||||
Array.Copy(QSubChannel, 0, QSubChannelForCRC, 0, 10);
|
||||
UInt16 CalculatedQCRC = CalculateCCITT_CRC16(QSubChannelForCRC);
|
||||
|
||||
if (QSubChannelCRC != CalculatedQCRC)
|
||||
if(QSubChannelCRC != CalculatedQCRC)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "Q subchannel CRC 0x{0:X4}, expected 0x{1:X4}", CalculatedQCRC, QSubChannelCRC);
|
||||
status = false;
|
||||
}
|
||||
|
||||
if ((CDTextPack1[0] & 0x80) == 0x80)
|
||||
if((CDTextPack1[0] & 0x80) == 0x80)
|
||||
{
|
||||
UInt16 CDTextPack1CRC = BigEndianBitConverter.ToUInt16(CDTextPack1, 16);
|
||||
byte[] CDTextPack1ForCRC = new byte[16];
|
||||
Array.Copy(CDTextPack1, 0, CDTextPack1ForCRC, 0, 16);
|
||||
UInt16 CalculatedCDTP1CRC = CalculateCCITT_CRC16(CDTextPack1ForCRC);
|
||||
|
||||
if (CDTextPack1CRC != CalculatedCDTP1CRC && CDTextPack1CRC != 0)
|
||||
if(CDTextPack1CRC != CalculatedCDTP1CRC && CDTextPack1CRC != 0)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "CD-Text Pack 1 CRC 0x{0:X4}, expected 0x{1:X4}", CDTextPack1CRC, CalculatedCDTP1CRC);
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((CDTextPack2[0] & 0x80) == 0x80)
|
||||
if((CDTextPack2[0] & 0x80) == 0x80)
|
||||
{
|
||||
UInt16 CDTextPack2CRC = BigEndianBitConverter.ToUInt16(CDTextPack2, 16);
|
||||
byte[] CDTextPack2ForCRC = new byte[16];
|
||||
@@ -502,14 +502,14 @@ namespace DiscImageChef.Checksums
|
||||
UInt16 CalculatedCDTP2CRC = CalculateCCITT_CRC16(CDTextPack2ForCRC);
|
||||
DicConsole.DebugWriteLine("CD checksums", "Cyclic CDTP2 0x{0:X4}, Calc CDTP2 0x{1:X4}", CDTextPack2CRC, CalculatedCDTP2CRC);
|
||||
|
||||
if (CDTextPack2CRC != CalculatedCDTP2CRC && CDTextPack2CRC != 0)
|
||||
if(CDTextPack2CRC != CalculatedCDTP2CRC && CDTextPack2CRC != 0)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "CD-Text Pack 2 CRC 0x{0:X4}, expected 0x{1:X4}", CDTextPack2CRC, CalculatedCDTP2CRC);
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((CDTextPack3[0] & 0x80) == 0x80)
|
||||
if((CDTextPack3[0] & 0x80) == 0x80)
|
||||
{
|
||||
UInt16 CDTextPack3CRC = BigEndianBitConverter.ToUInt16(CDTextPack3, 16);
|
||||
byte[] CDTextPack3ForCRC = new byte[16];
|
||||
@@ -517,14 +517,14 @@ namespace DiscImageChef.Checksums
|
||||
UInt16 CalculatedCDTP3CRC = CalculateCCITT_CRC16(CDTextPack3ForCRC);
|
||||
DicConsole.DebugWriteLine("CD checksums", "Cyclic CDTP3 0x{0:X4}, Calc CDTP3 0x{1:X4}", CDTextPack3CRC, CalculatedCDTP3CRC);
|
||||
|
||||
if (CDTextPack3CRC != CalculatedCDTP3CRC && CDTextPack3CRC != 0)
|
||||
if(CDTextPack3CRC != CalculatedCDTP3CRC && CDTextPack3CRC != 0)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "CD-Text Pack 3 CRC 0x{0:X4}, expected 0x{1:X4}", CDTextPack3CRC, CalculatedCDTP3CRC);
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((CDTextPack4[0] & 0x80) == 0x80)
|
||||
if((CDTextPack4[0] & 0x80) == 0x80)
|
||||
{
|
||||
UInt16 CDTextPack4CRC = BigEndianBitConverter.ToUInt16(CDTextPack4, 16);
|
||||
byte[] CDTextPack4ForCRC = new byte[16];
|
||||
@@ -532,7 +532,7 @@ namespace DiscImageChef.Checksums
|
||||
UInt16 CalculatedCDTP4CRC = CalculateCCITT_CRC16(CDTextPack4ForCRC);
|
||||
DicConsole.DebugWriteLine("CD checksums", "Cyclic CDTP4 0x{0:X4}, Calc CDTP4 0x{1:X4}", CDTextPack4CRC, CalculatedCDTP4CRC);
|
||||
|
||||
if (CDTextPack4CRC != CalculatedCDTP4CRC && CDTextPack4CRC != 0)
|
||||
if(CDTextPack4CRC != CalculatedCDTP4CRC && CDTextPack4CRC != 0)
|
||||
{
|
||||
DicConsole.DebugWriteLine("CD checksums", "CD-Text Pack 4 CRC 0x{0:X4}, expected 0x{1:X4}", CDTextPack4CRC, CalculatedCDTP4CRC);
|
||||
status = false;
|
||||
@@ -581,7 +581,7 @@ namespace DiscImageChef.Checksums
|
||||
static ushort CalculateCCITT_CRC16(byte[] buffer)
|
||||
{
|
||||
UInt16 CRC16 = 0;
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
for(int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
CRC16 = (ushort)(CCITT_CRC16Table[(CRC16 >> 8) ^ buffer[i]] ^ (CRC16 << 8));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user