diff --git a/DiscImageChef.Checksums/CDChecksums.cs b/DiscImageChef.Checksums/CDChecksums.cs
index 0a5c118c9..6f959a970 100644
--- a/DiscImageChef.Checksums/CDChecksums.cs
+++ b/DiscImageChef.Checksums/CDChecksums.cs
@@ -124,73 +124,73 @@ namespace DiscImageChef.Checksums
{
EccInit();
- if(channel[0x000] == 0x00 && // sync (12 bytes)
- channel[0x001] == 0xFF && channel[0x002] == 0xFF && channel[0x003] == 0xFF && channel[0x004] == 0xFF &&
- channel[0x005] == 0xFF && channel[0x006] == 0xFF && channel[0x007] == 0xFF && channel[0x008] == 0xFF &&
- channel[0x009] == 0xFF && channel[0x00A] == 0xFF && channel[0x00B] == 0x00)
+ if(channel[0x000] != 0x00 || channel[0x001] != 0xFF || channel[0x002] != 0xFF || channel[0x003] != 0xFF ||
+ channel[0x004] != 0xFF || channel[0x005] != 0xFF || channel[0x006] != 0xFF || channel[0x007] != 0xFF ||
+ channel[0x008] != 0xFF || channel[0x009] != 0xFF || channel[0x00A] != 0xFF ||
+ channel[0x00B] != 0x00) return null;
+
+ 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)
{
- 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)
- {
- 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++)
- 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;
- }
-
- return true;
- }
-
- 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)
- channel[0x815] != 0x00 || channel[0x816] != 0x00 || channel[0x817] != 0x00 ||
- channel[0x818] != 0x00 || channel[0x819] != 0x00 || channel[0x81A] != 0x00 ||
- channel[0x81B] != 0x00)
+ 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++)
+ if(channel[i] != 0x00)
{
DicConsole.DebugWriteLine("CD checksums",
- "Mode 1 sector with data in reserved bytes at address: {0:X2}:{1:X2}:{2:X2}",
+ "Mode 0 sector with error at address: {0:X2}:{1:X2}:{2:X2}",
channel[0x00C], channel[0x00D], channel[0x00E]);
return false;
}
- byte[] address = new byte[4];
- byte[] data = new byte[2060];
- byte[] data2 = new byte[2232];
- byte[] eccP = new byte[172];
- byte[] eccQ = new byte[104];
+ return true;
+ }
- Array.Copy(channel, 0x0C, address, 0, 4);
- Array.Copy(channel, 0x0C, data, 0, 2060);
- Array.Copy(channel, 0x0C, data2, 0, 2232);
- Array.Copy(channel, 0x81C, eccP, 0, 172);
- Array.Copy(channel, 0x8C8, eccQ, 0, 104);
+ 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]);
- bool failedEccP = CheckEcc(address, data, 86, 24, 2, 86, eccP);
- bool failedEccQ = CheckEcc(address, data2, 52, 43, 86, 88, eccQ);
+ if(channel[0x814] != 0x00 || // reserved (8 bytes)
+ channel[0x815] != 0x00 || channel[0x816] != 0x00 || channel[0x817] != 0x00 ||
+ channel[0x818] != 0x00 || channel[0x819] != 0x00 || channel[0x81A] != 0x00 ||
+ channel[0x81B] != 0x00)
+ {
+ DicConsole.DebugWriteLine("CD checksums",
+ "Mode 1 sector with data in reserved bytes at address: {0:X2}:{1:X2}:{2:X2}",
+ channel[0x00C], channel[0x00D], channel[0x00E]);
+ return false;
+ }
- if(failedEccP)
- 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(failedEccQ)
- 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]);
+ byte[] address = new byte[4];
+ byte[] data = new byte[2060];
+ byte[] data2 = new byte[2232];
+ byte[] eccP = new byte[172];
+ byte[] eccQ = new byte[104];
- if(failedEccP || failedEccQ) return false;
+ Array.Copy(channel, 0x0C, address, 0, 4);
+ Array.Copy(channel, 0x0C, data, 0, 2060);
+ Array.Copy(channel, 0x0C, data2, 0, 2232);
+ Array.Copy(channel, 0x81C, eccP, 0, 172);
+ Array.Copy(channel, 0x8C8, eccQ, 0, 104);
- /* TODO: This is not working
+ bool failedEccP = CheckEcc(address, data, 86, 24, 2, 86, eccP);
+ bool failedEccQ = CheckEcc(address, data2, 52, 43, 86, 88, eccQ);
+
+ if(failedEccP)
+ 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(failedEccQ)
+ 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(failedEccP || failedEccQ) return false;
+
+ /* TODO: This is not working
byte[] SectorForCheck = new byte[0x810];
uint StoredEDC = BitConverter.ToUInt32(channel, 0x810);
byte[] CalculatedEDCBytes;
@@ -204,23 +204,23 @@ namespace DiscImageChef.Checksums
return false;
}*/
- return true;
- }
+ return true;
+ }
- if(channel[0x00F] == 0x02) // mode (1 byte)
+ 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
{
- DicConsole.DebugWriteLine("CD checksums", "Mode 2 sector at address {0:X2}:{1:X2}:{2:X2}",
- channel[0x00C], channel[0x00D], channel[0x00E]);
+ 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]);
- 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])
- 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]);
-
- /* TODO: This is not working
+ /* TODO: This is not working
byte[] SectorForCheck = new byte[0x91C];
uint StoredEDC = BitConverter.ToUInt32(channel, 0x92C);
byte[] CalculatedEDCBytes;
@@ -233,45 +233,45 @@ namespace DiscImageChef.Checksums
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;
}*/
- }
- else
- {
- 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]);
+ }
+ else
+ {
+ 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]);
- byte[] address = new byte[4];
- byte[] data = new byte[2060];
- byte[] data2 = new byte[2232];
- byte[] eccP = new byte[172];
- byte[] eccQ = new byte[104];
+ byte[] address = new byte[4];
+ byte[] data = new byte[2060];
+ byte[] data2 = new byte[2232];
+ byte[] eccP = new byte[172];
+ byte[] eccQ = new byte[104];
- address[0] = 0;
- address[1] = 0;
- address[2] = 0;
- address[3] = 0;
- Array.Copy(channel, 0x0C, data, 0, 2060);
- Array.Copy(channel, 0x0C, data2, 0, 2232);
- Array.Copy(channel, 0x80C, eccP, 0, 172);
- Array.Copy(channel, 0x8B8, eccQ, 0, 104);
+ address[0] = 0;
+ address[1] = 0;
+ address[2] = 0;
+ address[3] = 0;
+ Array.Copy(channel, 0x0C, data, 0, 2060);
+ Array.Copy(channel, 0x0C, data2, 0, 2232);
+ Array.Copy(channel, 0x80C, eccP, 0, 172);
+ Array.Copy(channel, 0x8B8, eccQ, 0, 104);
- bool failedEccP = CheckEcc(address, data, 86, 24, 2, 86, eccP);
- bool failedEccQ = CheckEcc(address, data2, 52, 43, 86, 88, eccQ);
+ bool failedEccP = CheckEcc(address, data, 86, 24, 2, 86, eccP);
+ bool failedEccQ = CheckEcc(address, data2, 52, 43, 86, 88, eccQ);
- if(failedEccP)
- 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(failedEccQ)
- 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(failedEccP)
+ 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(failedEccQ)
+ 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(failedEccP || failedEccQ) return false;
+ if(failedEccP || failedEccQ) return false;
- /* TODO: This is not working
+ /* TODO: This is not working
byte[] SectorForCheck = new byte[0x808];
uint StoredEDC = BitConverter.ToUInt32(channel, 0x818);
byte[] CalculatedEDCBytes;
@@ -284,17 +284,14 @@ namespace DiscImageChef.Checksums
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;
}*/
- }
-
- return true;
}
- DicConsole.DebugWriteLine("CD checksums",
- "Unknown mode {0} sector at address: {1:X2}:{2:X2}:{3:X2}",
- channel[0x00F], channel[0x00C], channel[0x00D], channel[0x00E]);
- return null;
+ return true;
}
+ DicConsole.DebugWriteLine("CD checksums",
+ "Unknown mode {0} sector at address: {1:X2}:{2:X2}:{3:X2}",
+ channel[0x00F], channel[0x00C], channel[0x00D], channel[0x00E]);
return null;
}
@@ -478,22 +475,20 @@ namespace DiscImageChef.Checksums
}
}
- if((cdTextPack4[0] & 0x80) == 0x80)
- {
- ushort cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16);
- byte[] cdTextPack4ForCrc = new byte[16];
- Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16);
- ushort calculatedCdtp4Crc = CalculateCCITT_CRC16(cdTextPack4ForCrc);
- DicConsole.DebugWriteLine("CD checksums", "Cyclic CDTP4 0x{0:X4}, Calc CDTP4 0x{1:X4}", cdTextPack4Crc,
- calculatedCdtp4Crc);
+ if((cdTextPack4[0] & 0x80) != 0x80) return status;
- 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;
- }
- }
+ ushort cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16);
+ byte[] cdTextPack4ForCrc = new byte[16];
+ Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16);
+ ushort 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) return status;
+
+ DicConsole.DebugWriteLine("CD checksums", "CD-Text Pack 4 CRC 0x{0:X4}, expected 0x{1:X4}",
+ cdTextPack4Crc, calculatedCdtp4Crc);
+ status = false;
return status;
}
diff --git a/DiscImageChef.Checksums/ReedSolomon.cs b/DiscImageChef.Checksums/ReedSolomon.cs
index 8eeda85c5..5dbdcd382 100644
--- a/DiscImageChef.Checksums/ReedSolomon.cs
+++ b/DiscImageChef.Checksums/ReedSolomon.cs
@@ -305,41 +305,38 @@ namespace DiscImageChef.Checksums
/// Outs parity symbols.
public int encode_rs(int[] data, out int[] bb)
{
- if(initialized)
+ if(!initialized) throw new UnauthorizedAccessException("Trying to calculate RS without initializing!");
+
+ int i, j;
+ int feedback;
+ bb = new int[nn - kk];
+
+ Clear(ref bb, nn - kk);
+ for(i = kk - 1; i >= 0; i--)
{
- int i, j;
- int feedback;
- bb = new int[nn - kk];
+ if(mm != 8) if(data[i] > nn) return -1; /* Illegal symbol */
- Clear(ref bb, nn - kk);
- for(i = kk - 1; i >= 0; i--)
+ feedback = index_of[data[i] ^ bb[nn - kk - 1]];
+ if(feedback != a0)
{
- if(mm != 8) if(data[i] > nn) return -1; /* Illegal symbol */
+ /* feedback term is non-zero */
+ for(j = nn - kk - 1; j > 0; j--)
+ if(gg[j] != a0) bb[j] = bb[j - 1] ^ alpha_to[Modnn(gg[j] + feedback)];
+ else bb[j] = bb[j - 1];
- feedback = index_of[data[i] ^ bb[nn - kk - 1]];
- if(feedback != a0)
- {
- /* feedback term is non-zero */
- for(j = nn - kk - 1; j > 0; j--)
- if(gg[j] != a0) bb[j] = bb[j - 1] ^ alpha_to[Modnn(gg[j] + feedback)];
- else bb[j] = bb[j - 1];
-
- bb[0] = alpha_to[Modnn(gg[0] + feedback)];
- }
- else
- {
- /* feedback term is zero. encoder becomes a
- * single-byte shifter */
- for(j = nn - kk - 1; j > 0; j--) bb[j] = bb[j - 1];
-
- bb[0] = 0;
- }
+ bb[0] = alpha_to[Modnn(gg[0] + feedback)];
}
+ else
+ {
+ /* feedback term is zero. encoder becomes a
+ * single-byte shifter */
+ for(j = nn - kk - 1; j > 0; j--) bb[j] = bb[j - 1];
- return 0;
+ bb[0] = 0;
+ }
}
- throw new UnauthorizedAccessException("Trying to calculate RS without initializing!");
+ return 0;
}
/*
@@ -364,243 +361,236 @@ namespace DiscImageChef.Checksums
/// Number of erasures.
public int eras_dec_rs(ref int[] data, out int[] erasPos, int noEras)
{
- if(initialized)
+ if(!initialized) throw new UnauthorizedAccessException("Trying to calculate RS without initializing!");
+
+ erasPos = new int[nn - kk];
+ int degLambda, el, degOmega;
+ int i, j, r;
+ int u, q, tmp, num1, num2, den, discrR;
+ int[] recd = new int[nn];
+ int[] lambda = new int[nn - kk + 1]; /* Err+Eras Locator poly */
+ int[] s = new int[nn - kk + 1]; /* syndrome poly */
+ int[] b = new int[nn - kk + 1];
+ int[] t = new int[nn - kk + 1];
+ int[] omega = new int[nn - kk + 1];
+ int[] root = new int[nn - kk];
+ int[] reg = new int[nn - kk + 1];
+ int[] loc = new int[nn - kk];
+ int synError, count;
+
+ /* data[] is in polynomial form, copy and convert to index form */
+ for(i = nn - 1; i >= 0; i--)
{
- erasPos = new int[nn - kk];
- int degLambda, el, degOmega;
- int i, j, r;
- int u, q, tmp, num1, num2, den, discrR;
- int[] recd = new int[nn];
- int[] lambda = new int[nn - kk + 1]; /* Err+Eras Locator poly */
- int[] s = new int[nn - kk + 1]; /* syndrome poly */
- int[] b = new int[nn - kk + 1];
- int[] t = new int[nn - kk + 1];
- int[] omega = new int[nn - kk + 1];
- int[] root = new int[nn - kk];
- int[] reg = new int[nn - kk + 1];
- int[] loc = new int[nn - kk];
- int synError, count;
+ if(mm != 8) if(data[i] > nn) return -1; /* Illegal symbol */
- /* data[] is in polynomial form, copy and convert to index form */
- for(i = nn - 1; i >= 0; i--)
- {
- if(mm != 8) if(data[i] > nn) return -1; /* Illegal symbol */
-
- recd[i] = index_of[data[i]];
- }
- /* first form the syndromes; i.e., evaluate recd(x) at roots of g(x)
+ recd[i] = index_of[data[i]];
+ }
+ /* first form the syndromes; i.e., evaluate recd(x) at roots of g(x)
* namely @**(B0+i), i = 0, ... ,(NN-KK-1)
*/
- synError = 0;
- for(i = 1; i <= nn - kk; i++)
- {
- tmp = 0;
- for(j = 0; j < nn; j++)
- if(recd[j] != a0) /* recd[j] in index form */
- tmp ^= alpha_to[Modnn(recd[j] + (B0 + i - 1) * j)];
+ synError = 0;
+ for(i = 1; i <= nn - kk; i++)
+ {
+ tmp = 0;
+ for(j = 0; j < nn; j++)
+ if(recd[j] != a0) /* recd[j] in index form */
+ tmp ^= alpha_to[Modnn(recd[j] + (B0 + i - 1) * j)];
- synError |= tmp; /* set flag if non-zero syndrome =>
+ synError |= tmp; /* set flag if non-zero syndrome =>
* error */
- /* store syndrome in index form */
- s[i] = index_of[tmp];
- }
+ /* store syndrome in index form */
+ s[i] = index_of[tmp];
+ }
- if(synError == 0) return 0;
+ if(synError == 0) return 0;
- Clear(ref lambda, nn - kk);
- lambda[0] = 1;
- if(noEras > 0)
+ Clear(ref lambda, nn - kk);
+ lambda[0] = 1;
+ if(noEras > 0)
+ {
+ /* Init lambda to be the erasure locator polynomial */
+ lambda[1] = alpha_to[erasPos[0]];
+ for(i = 1; i < noEras; i++)
{
- /* Init lambda to be the erasure locator polynomial */
- lambda[1] = alpha_to[erasPos[0]];
- for(i = 1; i < noEras; i++)
+ u = erasPos[i];
+ for(j = i + 1; j > 0; j--)
{
- u = erasPos[i];
- for(j = i + 1; j > 0; j--)
- {
- tmp = index_of[lambda[j - 1]];
- if(tmp != a0) lambda[j] ^= alpha_to[Modnn(u + tmp)];
- }
+ tmp = index_of[lambda[j - 1]];
+ if(tmp != a0) lambda[j] ^= alpha_to[Modnn(u + tmp)];
}
+ }
#if DEBUG
- /* find roots of the erasure location polynomial */
- for(i = 1; i <= noEras; i++) reg[i] = index_of[lambda[i]];
+ /* find roots of the erasure location polynomial */
+ for(i = 1; i <= noEras; i++) reg[i] = index_of[lambda[i]];
- count = 0;
- for(i = 1; i <= nn; i++)
- {
- q = 1;
- for(j = 1; j <= noEras; j++)
- if(reg[j] != a0)
- {
- reg[j] = Modnn(reg[j] + j);
- q ^= alpha_to[reg[j]];
- }
-
- if(q == 0)
- {
- /* store root and error location
- * number indices
- */
- root[count] = i;
- loc[count] = nn - i;
- count++;
- }
- }
-
- if(count != noEras)
- {
- DicConsole.DebugWriteLine("Reed Solomon", "\n lambda(x) is WRONG\n");
- return -1;
- }
-
- DicConsole.DebugWriteLine("Reed Solomon",
- "\n Erasure positions as determined by roots of Eras Loc Poly:\n");
- for(i = 0; i < count; i++) DicConsole.DebugWriteLine("Reed Solomon", "{0} ", loc[i]);
-
- DicConsole.DebugWriteLine("Reed Solomon", "\n");
-#endif
- }
-
- for(i = 0; i < nn - kk + 1; i++) b[i] = index_of[lambda[i]];
-
- /*
- * Begin Berlekamp-Massey algorithm to determine error+erasure
- * locator polynomial
- */
- r = noEras;
- el = noEras;
- while(++r <= nn - kk)
- {
- /* r is the step number */
- /* Compute discrepancy at the r-th step in poly-form */
- discrR = 0;
- for(i = 0; i < r; i++) if(lambda[i] != 0 && s[r - i] != a0) discrR ^= alpha_to[Modnn(index_of[lambda[i]] + s[r - i])];
-
- discrR = index_of[discrR]; /* Index form */
- if(discrR == a0)
- {
- /* 2 lines below: B(x) <-- x*B(x) */
- Copydown(ref b, ref b, nn - kk);
- b[0] = a0;
- }
- else
- {
- /* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */
- t[0] = lambda[0];
- for(i = 0; i < nn - kk; i++)
- if(b[i] != a0) t[i + 1] = lambda[i + 1] ^ alpha_to[Modnn(discrR + b[i])];
- else t[i + 1] = lambda[i + 1];
-
- if(2 * el <= r + noEras - 1)
- {
- el = r + noEras - el;
- /*
- * 2 lines below: B(x) <-- inv(discr_r) *
- * lambda(x)
- */
- for(i = 0; i <= nn - kk; i++)
- b[i] = lambda[i] == 0 ? a0 : Modnn(index_of[lambda[i]] - discrR + nn);
- }
- else
- {
- /* 2 lines below: B(x) <-- x*B(x) */
- Copydown(ref b, ref b, nn - kk);
- b[0] = a0;
- }
-
- Copy(ref lambda, ref t, nn - kk + 1);
- }
- }
-
- /* Convert lambda to index form and compute deg(lambda(x)) */
- degLambda = 0;
- for(i = 0; i < nn - kk + 1; i++)
- {
- lambda[i] = index_of[lambda[i]];
- if(lambda[i] != a0) degLambda = i;
- }
- /*
- * Find roots of the error+erasure locator polynomial. By Chien
- * Search
- */
- int temp = reg[0];
- Copy(ref reg, ref lambda, nn - kk);
- reg[0] = temp;
- count = 0; /* Number of roots of lambda(x) */
+ count = 0;
for(i = 1; i <= nn; i++)
{
q = 1;
- for(j = degLambda; j > 0; j--)
+ for(j = 1; j <= noEras; j++)
if(reg[j] != a0)
{
reg[j] = Modnn(reg[j] + j);
q ^= alpha_to[reg[j]];
}
- if(q == 0)
- {
- /* store root (index-form) and error location number */
- root[count] = i;
- loc[count] = nn - i;
- count++;
- }
+ if(q != 0) continue;
+ /* store root and error location
+ * number indices
+ */
+ root[count] = i;
+ loc[count] = nn - i;
+ count++;
}
-#if DEBUG
- DicConsole.DebugWriteLine("Reed Solomon", "\n Final error positions:\t");
+ if(count != noEras)
+ {
+ DicConsole.DebugWriteLine("Reed Solomon", "\n lambda(x) is WRONG\n");
+ return -1;
+ }
+
+ DicConsole.DebugWriteLine("Reed Solomon",
+ "\n Erasure positions as determined by roots of Eras Loc Poly:\n");
for(i = 0; i < count; i++) DicConsole.DebugWriteLine("Reed Solomon", "{0} ", loc[i]);
DicConsole.DebugWriteLine("Reed Solomon", "\n");
#endif
+ }
- if(degLambda != count) return -1;
- /*
+ for(i = 0; i < nn - kk + 1; i++) b[i] = index_of[lambda[i]];
+
+ /*
+ * Begin Berlekamp-Massey algorithm to determine error+erasure
+ * locator polynomial
+ */
+ r = noEras;
+ el = noEras;
+ while(++r <= nn - kk)
+ {
+ /* r is the step number */
+ /* Compute discrepancy at the r-th step in poly-form */
+ discrR = 0;
+ for(i = 0; i < r; i++) if(lambda[i] != 0 && s[r - i] != a0) discrR ^= alpha_to[Modnn(index_of[lambda[i]] + s[r - i])];
+
+ discrR = index_of[discrR]; /* Index form */
+ if(discrR == a0)
+ {
+ /* 2 lines below: B(x) <-- x*B(x) */
+ Copydown(ref b, ref b, nn - kk);
+ b[0] = a0;
+ }
+ else
+ {
+ /* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */
+ t[0] = lambda[0];
+ for(i = 0; i < nn - kk; i++)
+ if(b[i] != a0) t[i + 1] = lambda[i + 1] ^ alpha_to[Modnn(discrR + b[i])];
+ else t[i + 1] = lambda[i + 1];
+
+ if(2 * el <= r + noEras - 1)
+ {
+ el = r + noEras - el;
+ /*
+ * 2 lines below: B(x) <-- inv(discr_r) *
+ * lambda(x)
+ */
+ for(i = 0; i <= nn - kk; i++)
+ b[i] = lambda[i] == 0 ? a0 : Modnn(index_of[lambda[i]] - discrR + nn);
+ }
+ else
+ {
+ /* 2 lines below: B(x) <-- x*B(x) */
+ Copydown(ref b, ref b, nn - kk);
+ b[0] = a0;
+ }
+
+ Copy(ref lambda, ref t, nn - kk + 1);
+ }
+ }
+
+ /* Convert lambda to index form and compute deg(lambda(x)) */
+ degLambda = 0;
+ for(i = 0; i < nn - kk + 1; i++)
+ {
+ lambda[i] = index_of[lambda[i]];
+ if(lambda[i] != a0) degLambda = i;
+ }
+ /*
+ * Find roots of the error+erasure locator polynomial. By Chien
+ * Search
+ */
+ int temp = reg[0];
+ Copy(ref reg, ref lambda, nn - kk);
+ reg[0] = temp;
+ count = 0; /* Number of roots of lambda(x) */
+ for(i = 1; i <= nn; i++)
+ {
+ q = 1;
+ for(j = degLambda; j > 0; j--)
+ if(reg[j] != a0)
+ {
+ reg[j] = Modnn(reg[j] + j);
+ q ^= alpha_to[reg[j]];
+ }
+
+ if(q != 0) continue;
+ /* store root (index-form) and error location number */
+ root[count] = i;
+ loc[count] = nn - i;
+ count++;
+ }
+
+#if DEBUG
+ DicConsole.DebugWriteLine("Reed Solomon", "\n Final error positions:\t");
+ for(i = 0; i < count; i++) DicConsole.DebugWriteLine("Reed Solomon", "{0} ", loc[i]);
+
+ DicConsole.DebugWriteLine("Reed Solomon", "\n");
+#endif
+
+ if(degLambda != count) return -1;
+ /*
* Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
* x**(NN-KK)). in index form. Also find deg(omega).
*/
- degOmega = 0;
- for(i = 0; i < nn - kk; i++)
- {
- tmp = 0;
- j = degLambda < i ? degLambda : i;
- for(; j >= 0; j--) if(s[i + 1 - j] != a0 && lambda[j] != a0) tmp ^= alpha_to[Modnn(s[i + 1 - j] + lambda[j])];
+ degOmega = 0;
+ for(i = 0; i < nn - kk; i++)
+ {
+ tmp = 0;
+ j = degLambda < i ? degLambda : i;
+ for(; j >= 0; j--) if(s[i + 1 - j] != a0 && lambda[j] != a0) tmp ^= alpha_to[Modnn(s[i + 1 - j] + lambda[j])];
- if(tmp != 0) degOmega = i;
- omega[i] = index_of[tmp];
- }
+ if(tmp != 0) degOmega = i;
+ omega[i] = index_of[tmp];
+ }
- omega[nn - kk] = a0;
+ omega[nn - kk] = a0;
- /*
+ /*
* Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
* inv(X(l))**(B0-1) and den = lambda_pr(inv(X(l))) all in poly-form
*/
- for(j = count - 1; j >= 0; j--)
+ for(j = count - 1; j >= 0; j--)
+ {
+ num1 = 0;
+ for(i = degOmega; i >= 0; i--) if(omega[i] != a0) num1 ^= alpha_to[Modnn(omega[i] + i * root[j])];
+
+ num2 = alpha_to[Modnn(root[j] * (B0 - 1) + nn)];
+ den = 0;
+
+ /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
+ for(i = Min(degLambda, nn - kk - 1) & ~1; i >= 0; i -= 2) if(lambda[i + 1] != a0) den ^= alpha_to[Modnn(lambda[i + 1] + i * root[j])];
+
+ if(den == 0)
{
- num1 = 0;
- for(i = degOmega; i >= 0; i--) if(omega[i] != a0) num1 ^= alpha_to[Modnn(omega[i] + i * root[j])];
-
- num2 = alpha_to[Modnn(root[j] * (B0 - 1) + nn)];
- den = 0;
-
- /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
- for(i = Min(degLambda, nn - kk - 1) & ~1; i >= 0; i -= 2) if(lambda[i + 1] != a0) den ^= alpha_to[Modnn(lambda[i + 1] + i * root[j])];
-
- if(den == 0)
- {
- DicConsole.DebugWriteLine("Reed Solomon", "\n ERROR: denominator = 0\n");
- return -1;
- }
- /* Apply error to data */
- if(num1 != 0) data[loc[j]] ^= alpha_to[Modnn(index_of[num1] + index_of[num2] + nn - index_of[den])];
+ DicConsole.DebugWriteLine("Reed Solomon", "\n ERROR: denominator = 0\n");
+ return -1;
}
-
- return count;
+ /* Apply error to data */
+ if(num1 != 0) data[loc[j]] ^= alpha_to[Modnn(index_of[num1] + index_of[num2] + nn - index_of[den])];
}
- throw new UnauthorizedAccessException("Trying to calculate RS without initializing!");
+ return count;
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Checksums/SpamSumContext.cs b/DiscImageChef.Checksums/SpamSumContext.cs
index 8b18a6fa9..6e815e5b5 100644
--- a/DiscImageChef.Checksums/SpamSumContext.cs
+++ b/DiscImageChef.Checksums/SpamSumContext.cs
@@ -246,11 +246,10 @@ namespace DiscImageChef.Checksums
* */
self.Bh[i].Digest[++self.Bh[i].Dlen] = 0;
self.Bh[i].H = HASH_INIT;
- if(self.Bh[i].Dlen < SPAMSUM_LENGTH / 2)
- {
- self.Bh[i].Halfh = HASH_INIT;
- self.Bh[i].Halfdigest = 0;
- }
+ if(self.Bh[i].Dlen >= SPAMSUM_LENGTH / 2) continue;
+
+ self.Bh[i].Halfh = HASH_INIT;
+ self.Bh[i].Halfdigest = 0;
}
else fuzzy_try_reduce_blockhash();
}
diff --git a/DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs b/DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs
index 27d3c3540..f17c40943 100644
--- a/DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs
+++ b/DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs
@@ -51,15 +51,14 @@ namespace DiscImageChef.CommonTypes
{
if(blocks == 173400 && blockSize == 256) return MediaType.SQ400;
- if(blockSize == 512)
- {
- if(model.ToLowerInvariant().StartsWith("syjet")) return MediaType.SyJet;
+ if(blockSize != 512) return MediaType.Unknown;
- switch(blocks)
- {
- case 262144: return MediaType.EZ135;
- case 524288: return MediaType.SQ327;
- }
+ if(model.ToLowerInvariant().StartsWith("syjet")) return MediaType.SyJet;
+
+ switch(blocks)
+ {
+ case 262144: return MediaType.EZ135;
+ case 524288: return MediaType.SQ327;
}
return MediaType.Unknown;
@@ -72,24 +71,20 @@ namespace DiscImageChef.CommonTypes
if(model.ToLowerInvariant().StartsWith("zip"))
{
- if(blockSize == 512)
- {
- if(blocks == 196608) return MediaType.ZIP100;
- if(blocks == 489532) return MediaType.ZIP250;
+ if(blockSize != 512) return MediaType.Unknown;
- return MediaType.ZIP750;
- }
+ if(blocks == 196608) return MediaType.ZIP100;
+ if(blocks == 489532) return MediaType.ZIP250;
- return MediaType.Unknown;
+ return MediaType.ZIP750;
}
if(model.ToLowerInvariant().StartsWith("jaz"))
{
- if(blockSize == 512)
- {
- if(blocks == 2091050) return MediaType.Jaz;
- if(blocks == 3915600) return MediaType.Jaz2;
- }
+ if(blockSize != 512) return MediaType.Unknown;
+
+ if(blocks == 2091050) return MediaType.Jaz;
+ if(blocks == 3915600) return MediaType.Jaz2;
return MediaType.Unknown;
}
@@ -111,14 +106,11 @@ namespace DiscImageChef.CommonTypes
if(model.ToLowerInvariant().StartsWith("rdx"))
{
- if(blockSize == 512)
- {
- if(blocks == 625134256) return MediaType.RDX320;
+ if(blockSize != 512) return MediaType.Unknown;
- return MediaType.RDX;
- }
+ if(blocks == 625134256) return MediaType.RDX320;
- return MediaType.Unknown;
+ return MediaType.RDX;
}
switch(mediumType)
@@ -1318,79 +1310,80 @@ namespace DiscImageChef.CommonTypes
// Optical device
case 0x07:
{
- if(mediumType == 0x01 || mediumType == 0x02 || mediumType == 0x03 || mediumType == 0x05 ||
- mediumType == 0x07)
- switch(blockSize)
+ if(mediumType != 0x01 && mediumType != 0x02 && mediumType != 0x03 && mediumType != 0x05 &&
+ mediumType != 0x07) return MediaType.UnknownMO;
+
+ switch(blockSize)
+ {
+ case 512:
{
- case 512:
+ switch(blocks)
{
- switch(blocks)
- {
- case 249850: return MediaType.ECMA_154;
- case 429975: return MediaType.ECMA_201_ROM;
- case 446325: return MediaType.ECMA_201;
- case 694929: return MediaType.ECMA_223_512;
- case 904995: return MediaType.ECMA_183_512;
- case 1128772:
- case 1163337: return MediaType.ECMA_184_512;
- case 1281856: return MediaType.PD650_WORM;
- case 1298496: return MediaType.PD650;
- case 1644581:
- case 1647371: return MediaType.ECMA_195_512;
- default: return MediaType.UnknownMO;
- }
+ case 249850: return MediaType.ECMA_154;
+ case 429975: return MediaType.ECMA_201_ROM;
+ case 446325: return MediaType.ECMA_201;
+ case 694929: return MediaType.ECMA_223_512;
+ case 904995: return MediaType.ECMA_183_512;
+ case 1128772:
+ case 1163337: return MediaType.ECMA_184_512;
+ case 1281856: return MediaType.PD650_WORM;
+ case 1298496: return MediaType.PD650;
+ case 1644581:
+ case 1647371: return MediaType.ECMA_195_512;
+ default: return MediaType.UnknownMO;
}
- case 1024:
- {
- switch(blocks)
- {
- case 371371: return MediaType.ECMA_223;
- case 498526: return MediaType.ECMA_183;
- case 603466:
- case 637041: return MediaType.ECMA_184;
- case 936921:
- case 948770: return MediaType.ECMA_195;
- case 1244621: return MediaType.ECMA_238;
- case 14476734: return MediaType.ECMA_260;
- case 24445990: return MediaType.ECMA_260_Double;
- default: return MediaType.UnknownMO;
- }
- }
- case 2048:
- {
- switch(blocks)
- {
- case 318988:
- case 320332:
- case 321100: return MediaType.ECMA_239;
- case 605846: return MediaType.GigaMo;
- case 1063146: return MediaType.GigaMo2;
- case 1128134: return MediaType.ECMA_280;
- case 2043664: return MediaType.ECMA_322_2k;
- case 7355716: return MediaType.ECMA_317;
- default: return MediaType.UnknownMO;
- }
- }
- case 4096:
- {
- switch(blocks)
- {
- case 1095840: return MediaType.ECMA_322;
- default: return MediaType.UnknownMO;
- }
- }
- case 8192:
- {
- switch(blocks)
- {
- case 1834348: return MediaType.UDO;
- case 3668759: return MediaType.UDO2_WORM;
- case 3669724: return MediaType.UDO2;
- default: return MediaType.UnknownMO;
- }
- }
- default: return MediaType.UnknownMO;
}
+ case 1024:
+ {
+ switch(blocks)
+ {
+ case 371371: return MediaType.ECMA_223;
+ case 498526: return MediaType.ECMA_183;
+ case 603466:
+ case 637041: return MediaType.ECMA_184;
+ case 936921:
+ case 948770: return MediaType.ECMA_195;
+ case 1244621: return MediaType.ECMA_238;
+ case 14476734: return MediaType.ECMA_260;
+ case 24445990: return MediaType.ECMA_260_Double;
+ default: return MediaType.UnknownMO;
+ }
+ }
+ case 2048:
+ {
+ switch(blocks)
+ {
+ case 318988:
+ case 320332:
+ case 321100: return MediaType.ECMA_239;
+ case 605846: return MediaType.GigaMo;
+ case 1063146: return MediaType.GigaMo2;
+ case 1128134: return MediaType.ECMA_280;
+ case 2043664: return MediaType.ECMA_322_2k;
+ case 7355716: return MediaType.ECMA_317;
+ default: return MediaType.UnknownMO;
+ }
+ }
+ case 4096:
+ {
+ switch(blocks)
+ {
+ case 1095840: return MediaType.ECMA_322;
+ default: return MediaType.UnknownMO;
+ }
+ }
+ case 8192:
+ {
+ switch(blocks)
+ {
+ case 1834348: return MediaType.UDO;
+ case 3668759: return MediaType.UDO2_WORM;
+ case 3669724: return MediaType.UDO2;
+ default: return MediaType.UnknownMO;
+ }
+ }
+ default: return MediaType.UnknownMO;
+ }
return MediaType.UnknownMO;
}
diff --git a/DiscImageChef.Core/Checksum.cs b/DiscImageChef.Core/Checksum.cs
index ccf4595c9..bbb7e850b 100644
--- a/DiscImageChef.Core/Checksum.cs
+++ b/DiscImageChef.Core/Checksum.cs
@@ -370,13 +370,12 @@ namespace DiscImageChef.Core
chks.Add(chk);
}
- if(enabled.HasFlag(EnableChecksum.SpamSum))
- {
- chk = new ChecksumType();
- chk.type = ChecksumTypeType.spamsum;
- chk.Value = ssctx.End();
- chks.Add(chk);
- }
+ if(!enabled.HasFlag(EnableChecksum.SpamSum)) return chks;
+
+ chk = new ChecksumType();
+ chk.type = ChecksumTypeType.spamsum;
+ chk.Value = ssctx.End();
+ chks.Add(chk);
return chks;
}
@@ -617,13 +616,12 @@ namespace DiscImageChef.Core
dataChecksums.Add(chk);
}
- if(enabled.HasFlag(EnableChecksum.SpamSum))
- {
- chk = new ChecksumType();
- chk.type = ChecksumTypeType.spamsum;
- chk.Value = ssctxData.End();
- dataChecksums.Add(chk);
- }
+ if(!enabled.HasFlag(EnableChecksum.SpamSum)) return dataChecksums;
+
+ chk = new ChecksumType();
+ chk.type = ChecksumTypeType.spamsum;
+ chk.Value = ssctxData.End();
+ dataChecksums.Add(chk);
return dataChecksums;
}
diff --git a/DiscImageChef.Core/DataFile.cs b/DiscImageChef.Core/DataFile.cs
index f1e45fd86..8a626eb1d 100644
--- a/DiscImageChef.Core/DataFile.cs
+++ b/DiscImageChef.Core/DataFile.cs
@@ -104,25 +104,24 @@ namespace DiscImageChef.Core
public static void WriteTo(string who, string filename, byte[] data, string whatWriting = null,
bool overwrite = false)
{
- if(!string.IsNullOrEmpty(filename))
- {
- if(File.Exists(filename))
- if(overwrite) File.Delete(filename);
- else
- {
- DicConsole.ErrorWriteLine("Not overwriting file {0}", filename);
- return;
- }
+ if(string.IsNullOrEmpty(filename)) return;
- try
+ if(File.Exists(filename))
+ if(overwrite) File.Delete(filename);
+ else
{
- DicConsole.DebugWriteLine(who, "Writing " + whatWriting + " to {0}", filename);
- FileStream outputFs = new FileStream(filename, FileMode.CreateNew);
- outputFs.Write(data, 0, data.Length);
- outputFs.Close();
+ DicConsole.ErrorWriteLine("Not overwriting file {0}", filename);
+ return;
}
- catch { DicConsole.ErrorWriteLine("Unable to write file {0}", filename); }
+
+ try
+ {
+ DicConsole.DebugWriteLine(who, "Writing " + whatWriting + " to {0}", filename);
+ FileStream outputFs = new FileStream(filename, FileMode.CreateNew);
+ outputFs.Write(data, 0, data.Length);
+ outputFs.Close();
}
+ catch { DicConsole.ErrorWriteLine("Unable to write file {0}", filename); }
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Core/Devices/Dumping/ATA.cs b/DiscImageChef.Core/Devices/Dumping/ATA.cs
index a5e6c0ffb..b055bfb02 100644
--- a/DiscImageChef.Core/Devices/Dumping/ATA.cs
+++ b/DiscImageChef.Core/Devices/Dumping/ATA.cs
@@ -504,13 +504,12 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(imageFormat, partitions[i]))
- {
- plugin.GetInformation(imageFormat, partitions[i], out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
- dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
- }
+ if(!plugin.Identify(imageFormat, partitions[i])) continue;
+
+ plugin.GetInformation(imageFormat, partitions[i], out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
+ dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -540,13 +539,12 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(imageFormat, wholePart))
- {
- plugin.GetInformation(imageFormat, wholePart, out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
- dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
- }
+ if(!plugin.Identify(imageFormat, wholePart)) continue;
+
+ plugin.GetInformation(imageFormat, wholePart, out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
+ dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
diff --git a/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs b/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs
index 20acaf9a6..2d58d6a42 100644
--- a/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs
+++ b/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs
@@ -715,22 +715,21 @@ namespace DiscImageChef.Core.Devices.Dumping
totalDuration += cmdDuration;
}
- if(!sense && !dev.Error || runningPersistent)
- {
- if(!sense && !dev.Error)
- {
- resume.BadBlocks.Remove(badSector);
- extents.Add(badSector);
- dumpLog.WriteLine("Correctly retried sector {0} in pass {1}.", badSector, pass);
- }
+ if((sense || dev.Error) && !runningPersistent) continue;
- if(separateSubchannel)
- {
- dumpFile.WriteAt(readBuffer, badSector, (uint)sectorSize, 0, sectorSize);
- subFile.WriteAt(readBuffer, badSector, subSize, sectorSize, (int)subSize);
- }
- else dumpFile.WriteAt(readBuffer, badSector, blockSize);
+ if(!sense && !dev.Error)
+ {
+ resume.BadBlocks.Remove(badSector);
+ extents.Add(badSector);
+ dumpLog.WriteLine("Correctly retried sector {0} in pass {1}.", badSector, pass);
}
+
+ if(separateSubchannel)
+ {
+ dumpFile.WriteAt(readBuffer, badSector, (uint)sectorSize, 0, sectorSize);
+ subFile.WriteAt(readBuffer, badSector, subSize, sectorSize, (int)subSize);
+ }
+ else dumpFile.WriteAt(readBuffer, badSector, blockSize);
}
if(pass < retryPasses && !aborted && resume.BadBlocks.Count > 0)
diff --git a/DiscImageChef.Core/Devices/Dumping/ResumeSupport.cs b/DiscImageChef.Core/Devices/Dumping/ResumeSupport.cs
index 70898ef44..39de09ff5 100644
--- a/DiscImageChef.Core/Devices/Dumping/ResumeSupport.cs
+++ b/DiscImageChef.Core/Devices/Dumping/ResumeSupport.cs
@@ -78,31 +78,29 @@ namespace DiscImageChef.Core.Devices.Dumping
if(oldtry.Software == null) throw new Exception("Found corrupt resume file, cannot continue...");
- if(oldtry.Software.Name == "DiscImageChef" &&
- oldtry.Software.OperatingSystem == platform.ToString() &&
- oldtry.Software.Version == Version.GetVersion())
- {
- if(removable && (oldtry.Manufacturer != manufacturer || oldtry.Model != model ||
- oldtry.Serial != serial)) continue;
+ if(oldtry.Software.Name != "DiscImageChef" ||
+ oldtry.Software.OperatingSystem != platform.ToString() ||
+ oldtry.Software.Version != Version.GetVersion()) continue;
- currentTry = oldtry;
- extents = ExtentsConverter.FromMetadata(currentTry.Extents);
- break;
- }
+ if(removable && (oldtry.Manufacturer != manufacturer || oldtry.Model != model ||
+ oldtry.Serial != serial)) continue;
+
+ currentTry = oldtry;
+ extents = ExtentsConverter.FromMetadata(currentTry.Extents);
+ break;
}
- if(currentTry == null)
+ if(currentTry != null) return;
+
+ currentTry = new DumpHardwareType
{
- currentTry = new DumpHardwareType
- {
- Software = Version.GetSoftwareType(platform),
- Manufacturer = manufacturer,
- Model = model,
- Serial = serial
- };
- resume.Tries.Add(currentTry);
- extents = new ExtentsULong();
- }
+ Software = Version.GetSoftwareType(platform),
+ Manufacturer = manufacturer,
+ Model = model,
+ Serial = serial
+ };
+ resume.Tries.Add(currentTry);
+ extents = new ExtentsULong();
}
else
{
diff --git a/DiscImageChef.Core/Devices/Dumping/SBC.cs b/DiscImageChef.Core/Devices/Dumping/SBC.cs
index 7fef95faf..ac576fd00 100644
--- a/DiscImageChef.Core/Devices/Dumping/SBC.cs
+++ b/DiscImageChef.Core/Devices/Dumping/SBC.cs
@@ -211,18 +211,17 @@ namespace DiscImageChef.Core.Devices.Dumping
{
dumpLog.WriteLine("Requesting page {0:X2}h.", page);
sense = dev.ScsiInquiry(out cmdBuf, out senseBuf, page);
- if(!sense)
+ if(sense) continue;
+
+ EVPDType evpd = new EVPDType
{
- EVPDType evpd = new EVPDType
- {
- Image = string.Format("{0}.evpd_{1:X2}h.bin", outputPrefix, page),
- Checksums = Checksum.GetChecksums(cmdBuf).ToArray(),
- Size = cmdBuf.Length
- };
- evpd.Checksums = Checksum.GetChecksums(cmdBuf).ToArray();
- DataFile.WriteTo("SCSI Dump", evpd.Image, cmdBuf);
- evpds.Add(evpd);
- }
+ Image = string.Format("{0}.evpd_{1:X2}h.bin", outputPrefix, page),
+ Checksums = Checksum.GetChecksums(cmdBuf).ToArray(),
+ Size = cmdBuf.Length
+ };
+ evpd.Checksums = Checksum.GetChecksums(cmdBuf).ToArray();
+ DataFile.WriteTo("SCSI Dump", evpd.Image, cmdBuf);
+ evpds.Add(evpd);
}
if(evpds.Count > 0) sidecar.BlockMedia[0].SCSI.EVPD = evpds.ToArray();
@@ -651,23 +650,22 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(imageFormat, partitions[i]))
- {
- plugin.GetInformation(imageFormat, partitions[i], out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
- dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
+ if(!plugin.Identify(imageFormat, partitions[i])) continue;
- switch(plugin.XmlFSType.Type) {
- case "Opera": dskType = MediaType.ThreeDO;
- break;
- case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
- break;
- case "Nintendo Wii filesystem": dskType = MediaType.WOD;
- break;
- case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
- break;
- }
+ plugin.GetInformation(imageFormat, partitions[i], out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
+ dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
+
+ switch(plugin.XmlFSType.Type) {
+ case "Opera": dskType = MediaType.ThreeDO;
+ break;
+ case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
+ break;
+ case "Nintendo Wii filesystem": dskType = MediaType.WOD;
+ break;
+ case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
+ break;
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
@@ -693,23 +691,22 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(imageFormat, wholePart))
- {
- plugin.GetInformation(imageFormat, wholePart, out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
- dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
+ if(!plugin.Identify(imageFormat, wholePart)) continue;
- switch(plugin.XmlFSType.Type) {
- case "Opera": dskType = MediaType.ThreeDO;
- break;
- case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
- break;
- case "Nintendo Wii filesystem": dskType = MediaType.WOD;
- break;
- case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
- break;
- }
+ plugin.GetInformation(imageFormat, wholePart, out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
+ dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
+
+ switch(plugin.XmlFSType.Type) {
+ case "Opera": dskType = MediaType.ThreeDO;
+ break;
+ case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
+ break;
+ case "Nintendo Wii filesystem": dskType = MediaType.WOD;
+ break;
+ case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
+ break;
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
diff --git a/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs b/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs
index 9d2c1e274..0e7a9cad7 100644
--- a/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs
+++ b/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs
@@ -495,13 +495,12 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(imageFormat, partitions[i]))
- {
- plugin.GetInformation(imageFormat, partitions[i], out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
- dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
- }
+ if(!plugin.Identify(imageFormat, partitions[i])) continue;
+
+ plugin.GetInformation(imageFormat, partitions[i], out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
+ dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -527,13 +526,12 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(imageFormat, wholePart))
- {
- plugin.GetInformation(imageFormat, wholePart, out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
- dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
- }
+ if(!plugin.Identify(imageFormat, wholePart)) continue;
+
+ plugin.GetInformation(imageFormat, wholePart, out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
+ dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
diff --git a/DiscImageChef.Core/Devices/Dumping/XGD.cs b/DiscImageChef.Core/Devices/Dumping/XGD.cs
index caa37517f..4b18a778d 100644
--- a/DiscImageChef.Core/Devices/Dumping/XGD.cs
+++ b/DiscImageChef.Core/Devices/Dumping/XGD.cs
@@ -850,23 +850,22 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(imageFormat, partitions[i]))
- {
- plugin.GetInformation(imageFormat, partitions[i], out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
- dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
+ if(!plugin.Identify(imageFormat, partitions[i])) continue;
- switch(plugin.XmlFSType.Type) {
- case "Opera": dskType = MediaType.ThreeDO;
- break;
- case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
- break;
- case "Nintendo Wii filesystem": dskType = MediaType.WOD;
- break;
- case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
- break;
- }
+ plugin.GetInformation(imageFormat, partitions[i], out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
+ dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
+
+ switch(plugin.XmlFSType.Type) {
+ case "Opera": dskType = MediaType.ThreeDO;
+ break;
+ case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
+ break;
+ case "Nintendo Wii filesystem": dskType = MediaType.WOD;
+ break;
+ case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
+ break;
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
@@ -892,23 +891,22 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(imageFormat, wholePart))
- {
- plugin.GetInformation(imageFormat, wholePart, out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
- dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
+ if(!plugin.Identify(imageFormat, wholePart)) continue;
- switch(plugin.XmlFSType.Type) {
- case "Opera": dskType = MediaType.ThreeDO;
- break;
- case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
- break;
- case "Nintendo Wii filesystem": dskType = MediaType.WOD;
- break;
- case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
- break;
- }
+ plugin.GetInformation(imageFormat, wholePart, out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
+ dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
+
+ switch(plugin.XmlFSType.Type) {
+ case "Opera": dskType = MediaType.ThreeDO;
+ break;
+ case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
+ break;
+ case "Nintendo Wii filesystem": dskType = MediaType.WOD;
+ break;
+ case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
+ break;
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
diff --git a/DiscImageChef.Core/Devices/ReaderATA.cs b/DiscImageChef.Core/Devices/ReaderATA.cs
index e6e95e429..ebc850657 100644
--- a/DiscImageChef.Core/Devices/ReaderATA.cs
+++ b/DiscImageChef.Core/Devices/ReaderATA.cs
@@ -86,13 +86,14 @@ namespace DiscImageChef.Core.Devices
blocks = (ulong)(cylinders * heads * sectors);
}
- if((ataId.CurrentCylinders == 0 || ataId.CurrentHeads == 0 || ataId.CurrentSectorsPerTrack == 0) && ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0)
- {
- cylinders = ataId.Cylinders;
- heads = (byte)ataId.Heads;
- sectors = (byte)ataId.SectorsPerTrack;
- blocks = (ulong)(cylinders * heads * sectors);
- }
+ if((ataId.CurrentCylinders != 0 && ataId.CurrentHeads != 0 && ataId.CurrentSectorsPerTrack != 0) ||
+ ataId.Cylinders <= 0 || ataId.Heads <= 0 ||
+ ataId.SectorsPerTrack <= 0) return (cylinders, heads, sectors);
+
+ cylinders = ataId.Cylinders;
+ heads = (byte)ataId.Heads;
+ sectors = (byte)ataId.SectorsPerTrack;
+ blocks = (ulong)(cylinders * heads * sectors);
return (cylinders, heads, sectors);
}
@@ -107,11 +108,10 @@ namespace DiscImageChef.Core.Devices
lbaMode = true;
}
- if(ataId.CommandSet2.HasFlag(Identify.CommandSetBit2.LBA48))
- {
- blocks = ataId.LBA48Sectors;
- lbaMode = true;
- }
+ if(!ataId.CommandSet2.HasFlag(Identify.CommandSetBit2.LBA48)) return blocks;
+
+ blocks = ataId.LBA48Sectors;
+ lbaMode = true;
return blocks;
}
@@ -279,14 +279,11 @@ namespace DiscImageChef.Core.Devices
if(!error || blocksToRead == 1) break;
}
- if(error && lbaMode)
- {
- blocksToRead = 1;
- errorMessage = string.Format("Device error {0} trying to guess ideal transfer length.", dev.LastError);
- return true;
- }
+ if(!error || !lbaMode) return false;
- return false;
+ blocksToRead = 1;
+ errorMessage = string.Format("Device error {0} trying to guess ideal transfer length.", dev.LastError);
+ return true;
}
bool AtaReadBlocks(out byte[] buffer, ulong block, uint count, out double duration)
diff --git a/DiscImageChef.Core/Devices/ReaderSCSI.cs b/DiscImageChef.Core/Devices/ReaderSCSI.cs
index f8e37e82b..c1a507cc4 100644
--- a/DiscImageChef.Core/Devices/ReaderSCSI.cs
+++ b/DiscImageChef.Core/Devices/ReaderSCSI.cs
@@ -174,13 +174,12 @@ namespace DiscImageChef.Core.Devices
testSense = dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, testSize,
timeout, out duration);
- if(!testSense && !dev.Error)
- {
- readLong10 = true;
- longBlockSize = testSize;
- readRaw = true;
- break;
- }
+ if(testSense || dev.Error) continue;
+
+ readLong10 = true;
+ longBlockSize = testSize;
+ readRaw = true;
+ break;
}
else if(blockSize == 1024)
foreach(ushort testSize in new[]
@@ -203,13 +202,12 @@ namespace DiscImageChef.Core.Devices
testSense = dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, testSize,
timeout, out duration);
- if(!testSense && !dev.Error)
- {
- readLong10 = true;
- longBlockSize = testSize;
- readRaw = true;
- break;
- }
+ if(testSense || dev.Error) continue;
+
+ readLong10 = true;
+ longBlockSize = testSize;
+ readRaw = true;
+ break;
}
else if(blockSize == 2048)
{
@@ -468,14 +466,11 @@ namespace DiscImageChef.Core.Devices
if(!dev.Error || blocksToRead == 1) break;
}
- if(dev.Error)
- {
- blocksToRead = 1;
- errorMessage = string.Format("Device error {0} trying to guess ideal transfer length.", dev.LastError);
- return true;
- }
+ if(!dev.Error) return false;
- return false;
+ blocksToRead = 1;
+ errorMessage = string.Format("Device error {0} trying to guess ideal transfer length.", dev.LastError);
+ return true;
}
bool ScsiReadBlocks(out byte[] buffer, ulong block, uint count, out double duration)
@@ -522,14 +517,11 @@ namespace DiscImageChef.Core.Devices
else return true;
}
- if(sense || dev.Error)
- {
- DicConsole.DebugWriteLine("SCSI Reader", "READ error:\n{0}",
- Decoders.SCSI.Sense.PrettifySense(senseBuf));
- return true;
- }
+ if(!sense && !dev.Error) return false;
- return false;
+ DicConsole.DebugWriteLine("SCSI Reader", "READ error:\n{0}",
+ Decoders.SCSI.Sense.PrettifySense(senseBuf));
+ return true;
}
bool ScsiSeek(ulong block, out double duration)
diff --git a/DiscImageChef.Core/Devices/Report/ATA.cs b/DiscImageChef.Core/Devices/Report/ATA.cs
index 65832f288..3aad86474 100644
--- a/DiscImageChef.Core/Devices/Report/ATA.cs
+++ b/DiscImageChef.Core/Devices/Report/ATA.cs
@@ -60,1176 +60,1174 @@ namespace DiscImageChef.Core.Devices.Report
dev.AtaIdentify(out buffer, out errorRegs, timeout, out duration);
- if(Decoders.ATA.Identify.Decode(buffer).HasValue)
- {
- Decoders.ATA.Identify.IdentifyDevice ataId = Decoders.ATA.Identify.Decode(buffer).Value;
+ if(!Decoders.ATA.Identify.Decode(buffer).HasValue) return;
- if((ushort)ataId.GeneralConfiguration == 0x848A)
+ Decoders.ATA.Identify.IdentifyDevice ataId = Decoders.ATA.Identify.Decode(buffer).Value;
+
+ if((ushort)ataId.GeneralConfiguration == 0x848A)
+ {
+ report.CompactFlash = true;
+ report.CompactFlashSpecified = true;
+ removable = false;
+ }
+ else if(!removable &&
+ ataId.GeneralConfiguration.HasFlag(Decoders.ATA.Identify.GeneralConfigurationBit.Removable))
+ {
+ pressedKey = new ConsoleKeyInfo();
+ while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
- report.CompactFlash = true;
- report.CompactFlashSpecified = true;
- removable = false;
+ DicConsole.Write("Is the media removable from the reading/writing elements? (Y/N): ");
+ pressedKey = System.Console.ReadKey();
+ DicConsole.WriteLine();
}
- else if(!removable &&
- ataId.GeneralConfiguration.HasFlag(Decoders.ATA.Identify.GeneralConfigurationBit.Removable))
+
+ removable = pressedKey.Key == ConsoleKey.Y;
+ }
+
+ if(removable)
+ {
+ DicConsole.WriteLine("Please remove any media from the device and press any key when it is out.");
+ System.Console.ReadKey(true);
+ DicConsole.WriteLine("Querying ATA IDENTIFY...");
+ dev.AtaIdentify(out buffer, out errorRegs, timeout, out duration);
+ ataId = Decoders.ATA.Identify.Decode(buffer).Value;
+ }
+
+ report.ATA = new ataType();
+
+ if(!string.IsNullOrWhiteSpace(ataId.AdditionalPID))
+ {
+ report.ATA.AdditionalPID = ataId.AdditionalPID;
+ report.ATA.AdditionalPIDSpecified = true;
+ }
+ if(ataId.APIOSupported != 0)
+ {
+ report.ATA.APIOSupported = ataId.APIOSupported;
+ report.ATA.APIOSupportedSpecified = true;
+ }
+ if(ataId.BufferType != 0)
+ {
+ report.ATA.BufferType = ataId.BufferType;
+ report.ATA.BufferTypeSpecified = true;
+ }
+ if(ataId.BufferSize != 0)
+ {
+ report.ATA.BufferSize = ataId.BufferSize;
+ report.ATA.BufferSizeSpecified = true;
+ }
+ if(ataId.Capabilities != 0)
+ {
+ report.ATA.Capabilities = ataId.Capabilities;
+ report.ATA.CapabilitiesSpecified = true;
+ }
+ if(ataId.Capabilities2 != 0)
+ {
+ report.ATA.Capabilities2 = ataId.Capabilities2;
+ report.ATA.Capabilities2Specified = true;
+ }
+ if(ataId.Capabilities3 != 0)
+ {
+ report.ATA.Capabilities3 = ataId.Capabilities3;
+ report.ATA.Capabilities3Specified = true;
+ }
+ if(ataId.CFAPowerMode != 0)
+ {
+ report.ATA.CFAPowerMode = ataId.CFAPowerMode;
+ report.ATA.CFAPowerModeSpecified = true;
+ }
+ if(ataId.CommandSet != 0)
+ {
+ report.ATA.CommandSet = ataId.CommandSet;
+ report.ATA.CommandSetSpecified = true;
+ }
+ if(ataId.CommandSet2 != 0)
+ {
+ report.ATA.CommandSet2 = ataId.CommandSet2;
+ report.ATA.CommandSet2Specified = true;
+ }
+ if(ataId.CommandSet3 != 0)
+ {
+ report.ATA.CommandSet3 = ataId.CommandSet3;
+ report.ATA.CommandSet3Specified = true;
+ }
+ if(ataId.CommandSet4 != 0)
+ {
+ report.ATA.CommandSet4 = ataId.CommandSet4;
+ report.ATA.CommandSet4Specified = true;
+ }
+ if(ataId.CommandSet5 != 0)
+ {
+ report.ATA.CommandSet5 = ataId.CommandSet5;
+ report.ATA.CommandSet5Specified = true;
+ }
+ if(ataId.CurrentAAM != 0)
+ {
+ report.ATA.CurrentAAM = ataId.CurrentAAM;
+ report.ATA.CurrentAAMSpecified = true;
+ }
+ if(ataId.CurrentAPM != 0)
+ {
+ report.ATA.CurrentAPM = ataId.CurrentAPM;
+ report.ATA.CurrentAPMSpecified = true;
+ }
+ if(ataId.DataSetMgmt != 0)
+ {
+ report.ATA.DataSetMgmt = ataId.DataSetMgmt;
+ report.ATA.DataSetMgmtSpecified = true;
+ }
+ if(ataId.DataSetMgmtSize != 0)
+ {
+ report.ATA.DataSetMgmtSize = ataId.DataSetMgmtSize;
+ report.ATA.DataSetMgmtSizeSpecified = true;
+ }
+ if(ataId.DeviceFormFactor != 0)
+ {
+ report.ATA.DeviceFormFactor = ataId.DeviceFormFactor;
+ report.ATA.DeviceFormFactorSpecified = true;
+ }
+ if(ataId.DMAActive != 0)
+ {
+ report.ATA.DMAActive = ataId.DMAActive;
+ report.ATA.DMAActiveSpecified = true;
+ }
+ if(ataId.DMASupported != 0)
+ {
+ report.ATA.DMASupported = ataId.DMASupported;
+ report.ATA.DMASupportedSpecified = true;
+ }
+ if(ataId.DMATransferTimingMode != 0)
+ {
+ report.ATA.DMATransferTimingMode = ataId.DMATransferTimingMode;
+ report.ATA.DMATransferTimingModeSpecified = true;
+ }
+ if(ataId.EnhancedSecurityEraseTime != 0)
+ {
+ report.ATA.EnhancedSecurityEraseTime = ataId.EnhancedSecurityEraseTime;
+ report.ATA.EnhancedSecurityEraseTimeSpecified = true;
+ }
+ if(ataId.EnabledCommandSet != 0)
+ {
+ report.ATA.EnabledCommandSet = ataId.EnabledCommandSet;
+ report.ATA.EnabledCommandSetSpecified = true;
+ }
+ if(ataId.EnabledCommandSet2 != 0)
+ {
+ report.ATA.EnabledCommandSet2 = ataId.EnabledCommandSet2;
+ report.ATA.EnabledCommandSet2Specified = true;
+ }
+ if(ataId.EnabledCommandSet3 != 0)
+ {
+ report.ATA.EnabledCommandSet3 = ataId.EnabledCommandSet3;
+ report.ATA.EnabledCommandSet3Specified = true;
+ }
+ if(ataId.EnabledCommandSet4 != 0)
+ {
+ report.ATA.EnabledCommandSet4 = ataId.EnabledCommandSet4;
+ report.ATA.EnabledCommandSet4Specified = true;
+ }
+ if(ataId.EnabledSATAFeatures != 0)
+ {
+ report.ATA.EnabledSATAFeatures = ataId.EnabledSATAFeatures;
+ report.ATA.EnabledSATAFeaturesSpecified = true;
+ }
+ if(ataId.ExtendedUserSectors != 0)
+ {
+ report.ATA.ExtendedUserSectors = ataId.ExtendedUserSectors;
+ report.ATA.ExtendedUserSectorsSpecified = true;
+ }
+ if(ataId.FreeFallSensitivity != 0)
+ {
+ report.ATA.FreeFallSensitivity = ataId.FreeFallSensitivity;
+ report.ATA.FreeFallSensitivitySpecified = true;
+ }
+ if(!string.IsNullOrWhiteSpace(ataId.FirmwareRevision))
+ {
+ report.ATA.FirmwareRevision = ataId.FirmwareRevision;
+ report.ATA.FirmwareRevisionSpecified = true;
+ }
+ if(ataId.GeneralConfiguration != 0)
+ {
+ report.ATA.GeneralConfiguration = ataId.GeneralConfiguration;
+ report.ATA.GeneralConfigurationSpecified = true;
+ }
+ if(ataId.HardwareResetResult != 0)
+ {
+ report.ATA.HardwareResetResult = ataId.HardwareResetResult;
+ report.ATA.HardwareResetResultSpecified = true;
+ }
+ if(ataId.InterseekDelay != 0)
+ {
+ report.ATA.InterseekDelay = ataId.InterseekDelay;
+ report.ATA.InterseekDelaySpecified = true;
+ }
+ if(ataId.MajorVersion != 0)
+ {
+ report.ATA.MajorVersion = ataId.MajorVersion;
+ report.ATA.MajorVersionSpecified = true;
+ }
+ if(ataId.MasterPasswordRevisionCode != 0)
+ {
+ report.ATA.MasterPasswordRevisionCode = ataId.MasterPasswordRevisionCode;
+ report.ATA.MasterPasswordRevisionCodeSpecified = true;
+ }
+ if(ataId.MaxDownloadMicroMode3 != 0)
+ {
+ report.ATA.MaxDownloadMicroMode3 = ataId.MaxDownloadMicroMode3;
+ report.ATA.MaxDownloadMicroMode3Specified = true;
+ }
+ if(ataId.MaxQueueDepth != 0)
+ {
+ report.ATA.MaxQueueDepth = ataId.MaxQueueDepth;
+ report.ATA.MaxQueueDepthSpecified = true;
+ }
+ if(ataId.MDMAActive != 0)
+ {
+ report.ATA.MDMAActive = ataId.MDMAActive;
+ report.ATA.MDMAActiveSpecified = true;
+ }
+ if(ataId.MDMASupported != 0)
+ {
+ report.ATA.MDMASupported = ataId.MDMASupported;
+ report.ATA.MDMASupportedSpecified = true;
+ }
+ if(ataId.MinDownloadMicroMode3 != 0)
+ {
+ report.ATA.MinDownloadMicroMode3 = ataId.MinDownloadMicroMode3;
+ report.ATA.MinDownloadMicroMode3Specified = true;
+ }
+ if(ataId.MinMDMACycleTime != 0)
+ {
+ report.ATA.MinMDMACycleTime = ataId.MinMDMACycleTime;
+ report.ATA.MinMDMACycleTimeSpecified = true;
+ }
+ if(ataId.MinorVersion != 0)
+ {
+ report.ATA.MinorVersion = ataId.MinorVersion;
+ report.ATA.MinorVersionSpecified = true;
+ }
+ if(ataId.MinPIOCycleTimeNoFlow != 0)
+ {
+ report.ATA.MinPIOCycleTimeNoFlow = ataId.MinPIOCycleTimeNoFlow;
+ report.ATA.MinPIOCycleTimeNoFlowSpecified = true;
+ }
+ if(ataId.MinPIOCycleTimeFlow != 0)
+ {
+ report.ATA.MinPIOCycleTimeFlow = ataId.MinPIOCycleTimeFlow;
+ report.ATA.MinPIOCycleTimeFlowSpecified = true;
+ }
+ if(!string.IsNullOrWhiteSpace(ataId.Model))
+ {
+ report.ATA.Model = ataId.Model;
+ report.ATA.ModelSpecified = true;
+ }
+ if(ataId.MultipleMaxSectors != 0)
+ {
+ report.ATA.MultipleMaxSectors = ataId.MultipleMaxSectors;
+ report.ATA.MultipleMaxSectorsSpecified = true;
+ }
+ if(ataId.MultipleSectorNumber != 0)
+ {
+ report.ATA.MultipleSectorNumber = ataId.MultipleSectorNumber;
+ report.ATA.MultipleSectorNumberSpecified = true;
+ }
+ if(ataId.NVCacheCaps != 0)
+ {
+ report.ATA.NVCacheCaps = ataId.NVCacheCaps;
+ report.ATA.NVCacheCapsSpecified = true;
+ }
+ if(ataId.NVCacheSize != 0)
+ {
+ report.ATA.NVCacheSize = ataId.NVCacheSize;
+ report.ATA.NVCacheSizeSpecified = true;
+ }
+ if(ataId.NVCacheWriteSpeed != 0)
+ {
+ report.ATA.NVCacheWriteSpeed = ataId.NVCacheWriteSpeed;
+ report.ATA.NVCacheWriteSpeedSpecified = true;
+ }
+ if(ataId.NVEstimatedSpinUp != 0)
+ {
+ report.ATA.NVEstimatedSpinUp = ataId.NVEstimatedSpinUp;
+ report.ATA.NVEstimatedSpinUpSpecified = true;
+ }
+ if(ataId.PacketBusRelease != 0)
+ {
+ report.ATA.PacketBusRelease = ataId.PacketBusRelease;
+ report.ATA.PacketBusReleaseSpecified = true;
+ }
+ if(ataId.PIOTransferTimingMode != 0)
+ {
+ report.ATA.PIOTransferTimingMode = ataId.PIOTransferTimingMode;
+ report.ATA.PIOTransferTimingModeSpecified = true;
+ }
+ if(ataId.RecommendedAAM != 0)
+ {
+ report.ATA.RecommendedAAM = ataId.RecommendedAAM;
+ report.ATA.RecommendedAAMSpecified = true;
+ }
+ if(ataId.RecMDMACycleTime != 0)
+ {
+ report.ATA.RecommendedMDMACycleTime = ataId.RecMDMACycleTime;
+ report.ATA.RecommendedMDMACycleTimeSpecified = true;
+ }
+ if(ataId.RemovableStatusSet != 0)
+ {
+ report.ATA.RemovableStatusSet = ataId.RemovableStatusSet;
+ report.ATA.RemovableStatusSetSpecified = true;
+ }
+ if(ataId.SATACapabilities != 0)
+ {
+ report.ATA.SATACapabilities = ataId.SATACapabilities;
+ report.ATA.SATACapabilitiesSpecified = true;
+ }
+ if(ataId.SATACapabilities2 != 0)
+ {
+ report.ATA.SATACapabilities2 = ataId.SATACapabilities2;
+ report.ATA.SATACapabilities2Specified = true;
+ }
+ if(ataId.SATAFeatures != 0)
+ {
+ report.ATA.SATAFeatures = ataId.SATAFeatures;
+ report.ATA.SATAFeaturesSpecified = true;
+ }
+ if(ataId.SCTCommandTransport != 0)
+ {
+ report.ATA.SCTCommandTransport = ataId.SCTCommandTransport;
+ report.ATA.SCTCommandTransportSpecified = true;
+ }
+ if(ataId.SectorsPerCard != 0)
+ {
+ report.ATA.SectorsPerCard = ataId.SectorsPerCard;
+ report.ATA.SectorsPerCardSpecified = true;
+ }
+ if(ataId.SecurityEraseTime != 0)
+ {
+ report.ATA.SecurityEraseTime = ataId.SecurityEraseTime;
+ report.ATA.SecurityEraseTimeSpecified = true;
+ }
+ if(ataId.SecurityStatus != 0)
+ {
+ report.ATA.SecurityStatus = ataId.SecurityStatus;
+ report.ATA.SecurityStatusSpecified = true;
+ }
+ if(ataId.ServiceBusyClear != 0)
+ {
+ report.ATA.ServiceBusyClear = ataId.ServiceBusyClear;
+ report.ATA.ServiceBusyClearSpecified = true;
+ }
+ if(ataId.SpecificConfiguration != 0)
+ {
+ report.ATA.SpecificConfiguration = ataId.SpecificConfiguration;
+ report.ATA.SpecificConfigurationSpecified = true;
+ }
+ if(ataId.StreamAccessLatency != 0)
+ {
+ report.ATA.StreamAccessLatency = ataId.StreamAccessLatency;
+ report.ATA.StreamAccessLatencySpecified = true;
+ }
+ if(ataId.StreamMinReqSize != 0)
+ {
+ report.ATA.StreamMinReqSize = ataId.StreamMinReqSize;
+ report.ATA.StreamMinReqSizeSpecified = true;
+ }
+ if(ataId.StreamPerformanceGranularity != 0)
+ {
+ report.ATA.StreamPerformanceGranularity = ataId.StreamPerformanceGranularity;
+ report.ATA.StreamPerformanceGranularitySpecified = true;
+ }
+ if(ataId.StreamTransferTimeDMA != 0)
+ {
+ report.ATA.StreamTransferTimeDMA = ataId.StreamTransferTimeDMA;
+ report.ATA.StreamTransferTimeDMASpecified = true;
+ }
+ if(ataId.StreamTransferTimePIO != 0)
+ {
+ report.ATA.StreamTransferTimePIO = ataId.StreamTransferTimePIO;
+ report.ATA.StreamTransferTimePIOSpecified = true;
+ }
+ if(ataId.TransportMajorVersion != 0)
+ {
+ report.ATA.TransportMajorVersion = ataId.TransportMajorVersion;
+ report.ATA.TransportMajorVersionSpecified = true;
+ }
+ if(ataId.TransportMinorVersion != 0)
+ {
+ report.ATA.TransportMinorVersion = ataId.TransportMinorVersion;
+ report.ATA.TransportMinorVersionSpecified = true;
+ }
+ if(ataId.TrustedComputing != 0)
+ {
+ report.ATA.TrustedComputing = ataId.TrustedComputing;
+ report.ATA.TrustedComputingSpecified = true;
+ }
+ if(ataId.UDMAActive != 0)
+ {
+ report.ATA.UDMAActive = ataId.UDMAActive;
+ report.ATA.UDMAActiveSpecified = true;
+ }
+ if(ataId.UDMASupported != 0)
+ {
+ report.ATA.UDMASupported = ataId.UDMASupported;
+ report.ATA.UDMASupportedSpecified = true;
+ }
+ if(ataId.WRVMode != 0)
+ {
+ report.ATA.WRVMode = ataId.WRVMode;
+ report.ATA.WRVModeSpecified = true;
+ }
+ if(ataId.WRVSectorCountMode3 != 0)
+ {
+ report.ATA.WRVSectorCountMode3 = ataId.WRVSectorCountMode3;
+ report.ATA.WRVSectorCountMode3Specified = true;
+ }
+ if(ataId.WRVSectorCountMode2 != 0)
+ {
+ report.ATA.WRVSectorCountMode2 = ataId.WRVSectorCountMode2;
+ report.ATA.WRVSectorCountMode2Specified = true;
+ }
+ if(debug) report.ATA.Identify = buffer;
+
+ if(removable)
+ {
+ List mediaTests = new List();
+
+ pressedKey = new ConsoleKeyInfo();
+ while(pressedKey.Key != ConsoleKey.N)
{
pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
- DicConsole.Write("Is the media removable from the reading/writing elements? (Y/N): ");
+ DicConsole.Write("Do you have media that you can insert in the drive? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
- removable = pressedKey.Key == ConsoleKey.Y;
- }
+ if(pressedKey.Key != ConsoleKey.Y) continue;
- if(removable)
- {
- DicConsole.WriteLine("Please remove any media from the device and press any key when it is out.");
+ DicConsole.WriteLine("Please insert it in the drive and press any key when it is ready.");
System.Console.ReadKey(true);
+
+ testedMediaType mediaTest = new testedMediaType();
+ DicConsole.Write("Please write a description of the media type and press enter: ");
+ mediaTest.MediumTypeName = System.Console.ReadLine();
+ DicConsole.Write("Please write the media model and press enter: ");
+ mediaTest.Model = System.Console.ReadLine();
+
+ mediaTest.ManufacturerSpecified = true;
+ mediaTest.ModelSpecified = true;
+ mediaTest.MediaIsRecognized = true;
+
DicConsole.WriteLine("Querying ATA IDENTIFY...");
dev.AtaIdentify(out buffer, out errorRegs, timeout, out duration);
- ataId = Decoders.ATA.Identify.Decode(buffer).Value;
- }
- report.ATA = new ataType();
-
- if(!string.IsNullOrWhiteSpace(ataId.AdditionalPID))
- {
- report.ATA.AdditionalPID = ataId.AdditionalPID;
- report.ATA.AdditionalPIDSpecified = true;
- }
- if(ataId.APIOSupported != 0)
- {
- report.ATA.APIOSupported = ataId.APIOSupported;
- report.ATA.APIOSupportedSpecified = true;
- }
- if(ataId.BufferType != 0)
- {
- report.ATA.BufferType = ataId.BufferType;
- report.ATA.BufferTypeSpecified = true;
- }
- if(ataId.BufferSize != 0)
- {
- report.ATA.BufferSize = ataId.BufferSize;
- report.ATA.BufferSizeSpecified = true;
- }
- if(ataId.Capabilities != 0)
- {
- report.ATA.Capabilities = ataId.Capabilities;
- report.ATA.CapabilitiesSpecified = true;
- }
- if(ataId.Capabilities2 != 0)
- {
- report.ATA.Capabilities2 = ataId.Capabilities2;
- report.ATA.Capabilities2Specified = true;
- }
- if(ataId.Capabilities3 != 0)
- {
- report.ATA.Capabilities3 = ataId.Capabilities3;
- report.ATA.Capabilities3Specified = true;
- }
- if(ataId.CFAPowerMode != 0)
- {
- report.ATA.CFAPowerMode = ataId.CFAPowerMode;
- report.ATA.CFAPowerModeSpecified = true;
- }
- if(ataId.CommandSet != 0)
- {
- report.ATA.CommandSet = ataId.CommandSet;
- report.ATA.CommandSetSpecified = true;
- }
- if(ataId.CommandSet2 != 0)
- {
- report.ATA.CommandSet2 = ataId.CommandSet2;
- report.ATA.CommandSet2Specified = true;
- }
- if(ataId.CommandSet3 != 0)
- {
- report.ATA.CommandSet3 = ataId.CommandSet3;
- report.ATA.CommandSet3Specified = true;
- }
- if(ataId.CommandSet4 != 0)
- {
- report.ATA.CommandSet4 = ataId.CommandSet4;
- report.ATA.CommandSet4Specified = true;
- }
- if(ataId.CommandSet5 != 0)
- {
- report.ATA.CommandSet5 = ataId.CommandSet5;
- report.ATA.CommandSet5Specified = true;
- }
- if(ataId.CurrentAAM != 0)
- {
- report.ATA.CurrentAAM = ataId.CurrentAAM;
- report.ATA.CurrentAAMSpecified = true;
- }
- if(ataId.CurrentAPM != 0)
- {
- report.ATA.CurrentAPM = ataId.CurrentAPM;
- report.ATA.CurrentAPMSpecified = true;
- }
- if(ataId.DataSetMgmt != 0)
- {
- report.ATA.DataSetMgmt = ataId.DataSetMgmt;
- report.ATA.DataSetMgmtSpecified = true;
- }
- if(ataId.DataSetMgmtSize != 0)
- {
- report.ATA.DataSetMgmtSize = ataId.DataSetMgmtSize;
- report.ATA.DataSetMgmtSizeSpecified = true;
- }
- if(ataId.DeviceFormFactor != 0)
- {
- report.ATA.DeviceFormFactor = ataId.DeviceFormFactor;
- report.ATA.DeviceFormFactorSpecified = true;
- }
- if(ataId.DMAActive != 0)
- {
- report.ATA.DMAActive = ataId.DMAActive;
- report.ATA.DMAActiveSpecified = true;
- }
- if(ataId.DMASupported != 0)
- {
- report.ATA.DMASupported = ataId.DMASupported;
- report.ATA.DMASupportedSpecified = true;
- }
- if(ataId.DMATransferTimingMode != 0)
- {
- report.ATA.DMATransferTimingMode = ataId.DMATransferTimingMode;
- report.ATA.DMATransferTimingModeSpecified = true;
- }
- if(ataId.EnhancedSecurityEraseTime != 0)
- {
- report.ATA.EnhancedSecurityEraseTime = ataId.EnhancedSecurityEraseTime;
- report.ATA.EnhancedSecurityEraseTimeSpecified = true;
- }
- if(ataId.EnabledCommandSet != 0)
- {
- report.ATA.EnabledCommandSet = ataId.EnabledCommandSet;
- report.ATA.EnabledCommandSetSpecified = true;
- }
- if(ataId.EnabledCommandSet2 != 0)
- {
- report.ATA.EnabledCommandSet2 = ataId.EnabledCommandSet2;
- report.ATA.EnabledCommandSet2Specified = true;
- }
- if(ataId.EnabledCommandSet3 != 0)
- {
- report.ATA.EnabledCommandSet3 = ataId.EnabledCommandSet3;
- report.ATA.EnabledCommandSet3Specified = true;
- }
- if(ataId.EnabledCommandSet4 != 0)
- {
- report.ATA.EnabledCommandSet4 = ataId.EnabledCommandSet4;
- report.ATA.EnabledCommandSet4Specified = true;
- }
- if(ataId.EnabledSATAFeatures != 0)
- {
- report.ATA.EnabledSATAFeatures = ataId.EnabledSATAFeatures;
- report.ATA.EnabledSATAFeaturesSpecified = true;
- }
- if(ataId.ExtendedUserSectors != 0)
- {
- report.ATA.ExtendedUserSectors = ataId.ExtendedUserSectors;
- report.ATA.ExtendedUserSectorsSpecified = true;
- }
- if(ataId.FreeFallSensitivity != 0)
- {
- report.ATA.FreeFallSensitivity = ataId.FreeFallSensitivity;
- report.ATA.FreeFallSensitivitySpecified = true;
- }
- if(!string.IsNullOrWhiteSpace(ataId.FirmwareRevision))
- {
- report.ATA.FirmwareRevision = ataId.FirmwareRevision;
- report.ATA.FirmwareRevisionSpecified = true;
- }
- if(ataId.GeneralConfiguration != 0)
- {
- report.ATA.GeneralConfiguration = ataId.GeneralConfiguration;
- report.ATA.GeneralConfigurationSpecified = true;
- }
- if(ataId.HardwareResetResult != 0)
- {
- report.ATA.HardwareResetResult = ataId.HardwareResetResult;
- report.ATA.HardwareResetResultSpecified = true;
- }
- if(ataId.InterseekDelay != 0)
- {
- report.ATA.InterseekDelay = ataId.InterseekDelay;
- report.ATA.InterseekDelaySpecified = true;
- }
- if(ataId.MajorVersion != 0)
- {
- report.ATA.MajorVersion = ataId.MajorVersion;
- report.ATA.MajorVersionSpecified = true;
- }
- if(ataId.MasterPasswordRevisionCode != 0)
- {
- report.ATA.MasterPasswordRevisionCode = ataId.MasterPasswordRevisionCode;
- report.ATA.MasterPasswordRevisionCodeSpecified = true;
- }
- if(ataId.MaxDownloadMicroMode3 != 0)
- {
- report.ATA.MaxDownloadMicroMode3 = ataId.MaxDownloadMicroMode3;
- report.ATA.MaxDownloadMicroMode3Specified = true;
- }
- if(ataId.MaxQueueDepth != 0)
- {
- report.ATA.MaxQueueDepth = ataId.MaxQueueDepth;
- report.ATA.MaxQueueDepthSpecified = true;
- }
- if(ataId.MDMAActive != 0)
- {
- report.ATA.MDMAActive = ataId.MDMAActive;
- report.ATA.MDMAActiveSpecified = true;
- }
- if(ataId.MDMASupported != 0)
- {
- report.ATA.MDMASupported = ataId.MDMASupported;
- report.ATA.MDMASupportedSpecified = true;
- }
- if(ataId.MinDownloadMicroMode3 != 0)
- {
- report.ATA.MinDownloadMicroMode3 = ataId.MinDownloadMicroMode3;
- report.ATA.MinDownloadMicroMode3Specified = true;
- }
- if(ataId.MinMDMACycleTime != 0)
- {
- report.ATA.MinMDMACycleTime = ataId.MinMDMACycleTime;
- report.ATA.MinMDMACycleTimeSpecified = true;
- }
- if(ataId.MinorVersion != 0)
- {
- report.ATA.MinorVersion = ataId.MinorVersion;
- report.ATA.MinorVersionSpecified = true;
- }
- if(ataId.MinPIOCycleTimeNoFlow != 0)
- {
- report.ATA.MinPIOCycleTimeNoFlow = ataId.MinPIOCycleTimeNoFlow;
- report.ATA.MinPIOCycleTimeNoFlowSpecified = true;
- }
- if(ataId.MinPIOCycleTimeFlow != 0)
- {
- report.ATA.MinPIOCycleTimeFlow = ataId.MinPIOCycleTimeFlow;
- report.ATA.MinPIOCycleTimeFlowSpecified = true;
- }
- if(!string.IsNullOrWhiteSpace(ataId.Model))
- {
- report.ATA.Model = ataId.Model;
- report.ATA.ModelSpecified = true;
- }
- if(ataId.MultipleMaxSectors != 0)
- {
- report.ATA.MultipleMaxSectors = ataId.MultipleMaxSectors;
- report.ATA.MultipleMaxSectorsSpecified = true;
- }
- if(ataId.MultipleSectorNumber != 0)
- {
- report.ATA.MultipleSectorNumber = ataId.MultipleSectorNumber;
- report.ATA.MultipleSectorNumberSpecified = true;
- }
- if(ataId.NVCacheCaps != 0)
- {
- report.ATA.NVCacheCaps = ataId.NVCacheCaps;
- report.ATA.NVCacheCapsSpecified = true;
- }
- if(ataId.NVCacheSize != 0)
- {
- report.ATA.NVCacheSize = ataId.NVCacheSize;
- report.ATA.NVCacheSizeSpecified = true;
- }
- if(ataId.NVCacheWriteSpeed != 0)
- {
- report.ATA.NVCacheWriteSpeed = ataId.NVCacheWriteSpeed;
- report.ATA.NVCacheWriteSpeedSpecified = true;
- }
- if(ataId.NVEstimatedSpinUp != 0)
- {
- report.ATA.NVEstimatedSpinUp = ataId.NVEstimatedSpinUp;
- report.ATA.NVEstimatedSpinUpSpecified = true;
- }
- if(ataId.PacketBusRelease != 0)
- {
- report.ATA.PacketBusRelease = ataId.PacketBusRelease;
- report.ATA.PacketBusReleaseSpecified = true;
- }
- if(ataId.PIOTransferTimingMode != 0)
- {
- report.ATA.PIOTransferTimingMode = ataId.PIOTransferTimingMode;
- report.ATA.PIOTransferTimingModeSpecified = true;
- }
- if(ataId.RecommendedAAM != 0)
- {
- report.ATA.RecommendedAAM = ataId.RecommendedAAM;
- report.ATA.RecommendedAAMSpecified = true;
- }
- if(ataId.RecMDMACycleTime != 0)
- {
- report.ATA.RecommendedMDMACycleTime = ataId.RecMDMACycleTime;
- report.ATA.RecommendedMDMACycleTimeSpecified = true;
- }
- if(ataId.RemovableStatusSet != 0)
- {
- report.ATA.RemovableStatusSet = ataId.RemovableStatusSet;
- report.ATA.RemovableStatusSetSpecified = true;
- }
- if(ataId.SATACapabilities != 0)
- {
- report.ATA.SATACapabilities = ataId.SATACapabilities;
- report.ATA.SATACapabilitiesSpecified = true;
- }
- if(ataId.SATACapabilities2 != 0)
- {
- report.ATA.SATACapabilities2 = ataId.SATACapabilities2;
- report.ATA.SATACapabilities2Specified = true;
- }
- if(ataId.SATAFeatures != 0)
- {
- report.ATA.SATAFeatures = ataId.SATAFeatures;
- report.ATA.SATAFeaturesSpecified = true;
- }
- if(ataId.SCTCommandTransport != 0)
- {
- report.ATA.SCTCommandTransport = ataId.SCTCommandTransport;
- report.ATA.SCTCommandTransportSpecified = true;
- }
- if(ataId.SectorsPerCard != 0)
- {
- report.ATA.SectorsPerCard = ataId.SectorsPerCard;
- report.ATA.SectorsPerCardSpecified = true;
- }
- if(ataId.SecurityEraseTime != 0)
- {
- report.ATA.SecurityEraseTime = ataId.SecurityEraseTime;
- report.ATA.SecurityEraseTimeSpecified = true;
- }
- if(ataId.SecurityStatus != 0)
- {
- report.ATA.SecurityStatus = ataId.SecurityStatus;
- report.ATA.SecurityStatusSpecified = true;
- }
- if(ataId.ServiceBusyClear != 0)
- {
- report.ATA.ServiceBusyClear = ataId.ServiceBusyClear;
- report.ATA.ServiceBusyClearSpecified = true;
- }
- if(ataId.SpecificConfiguration != 0)
- {
- report.ATA.SpecificConfiguration = ataId.SpecificConfiguration;
- report.ATA.SpecificConfigurationSpecified = true;
- }
- if(ataId.StreamAccessLatency != 0)
- {
- report.ATA.StreamAccessLatency = ataId.StreamAccessLatency;
- report.ATA.StreamAccessLatencySpecified = true;
- }
- if(ataId.StreamMinReqSize != 0)
- {
- report.ATA.StreamMinReqSize = ataId.StreamMinReqSize;
- report.ATA.StreamMinReqSizeSpecified = true;
- }
- if(ataId.StreamPerformanceGranularity != 0)
- {
- report.ATA.StreamPerformanceGranularity = ataId.StreamPerformanceGranularity;
- report.ATA.StreamPerformanceGranularitySpecified = true;
- }
- if(ataId.StreamTransferTimeDMA != 0)
- {
- report.ATA.StreamTransferTimeDMA = ataId.StreamTransferTimeDMA;
- report.ATA.StreamTransferTimeDMASpecified = true;
- }
- if(ataId.StreamTransferTimePIO != 0)
- {
- report.ATA.StreamTransferTimePIO = ataId.StreamTransferTimePIO;
- report.ATA.StreamTransferTimePIOSpecified = true;
- }
- if(ataId.TransportMajorVersion != 0)
- {
- report.ATA.TransportMajorVersion = ataId.TransportMajorVersion;
- report.ATA.TransportMajorVersionSpecified = true;
- }
- if(ataId.TransportMinorVersion != 0)
- {
- report.ATA.TransportMinorVersion = ataId.TransportMinorVersion;
- report.ATA.TransportMinorVersionSpecified = true;
- }
- if(ataId.TrustedComputing != 0)
- {
- report.ATA.TrustedComputing = ataId.TrustedComputing;
- report.ATA.TrustedComputingSpecified = true;
- }
- if(ataId.UDMAActive != 0)
- {
- report.ATA.UDMAActive = ataId.UDMAActive;
- report.ATA.UDMAActiveSpecified = true;
- }
- if(ataId.UDMASupported != 0)
- {
- report.ATA.UDMASupported = ataId.UDMASupported;
- report.ATA.UDMASupportedSpecified = true;
- }
- if(ataId.WRVMode != 0)
- {
- report.ATA.WRVMode = ataId.WRVMode;
- report.ATA.WRVModeSpecified = true;
- }
- if(ataId.WRVSectorCountMode3 != 0)
- {
- report.ATA.WRVSectorCountMode3 = ataId.WRVSectorCountMode3;
- report.ATA.WRVSectorCountMode3Specified = true;
- }
- if(ataId.WRVSectorCountMode2 != 0)
- {
- report.ATA.WRVSectorCountMode2 = ataId.WRVSectorCountMode2;
- report.ATA.WRVSectorCountMode2Specified = true;
- }
- if(debug) report.ATA.Identify = buffer;
-
- if(removable)
- {
- List mediaTests = new List();
-
- pressedKey = new ConsoleKeyInfo();
- while(pressedKey.Key != ConsoleKey.N)
+ if(Decoders.ATA.Identify.Decode(buffer).HasValue)
{
- pressedKey = new ConsoleKeyInfo();
- while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
+ ataId = Decoders.ATA.Identify.Decode(buffer).Value;
+
+ if(ataId.UnformattedBPT != 0)
{
- DicConsole.Write("Do you have media that you can insert in the drive? (Y/N): ");
- pressedKey = System.Console.ReadKey();
- DicConsole.WriteLine();
+ mediaTest.UnformattedBPT = ataId.UnformattedBPT;
+ mediaTest.UnformattedBPTSpecified = true;
+ }
+ if(ataId.UnformattedBPS != 0)
+ {
+ mediaTest.UnformattedBPS = ataId.UnformattedBPS;
+ mediaTest.UnformattedBPSSpecified = true;
}
- if(pressedKey.Key == ConsoleKey.Y)
+ if(ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0)
{
- DicConsole.WriteLine("Please insert it in the drive and press any key when it is ready.");
- System.Console.ReadKey(true);
+ mediaTest.CHS = new chsType();
+ mediaTest.CHS.Cylinders = ataId.Cylinders;
+ mediaTest.CHS.Heads = ataId.Heads;
+ mediaTest.CHS.Sectors = ataId.SectorsPerTrack;
+ mediaTest.Blocks = (ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack);
+ mediaTest.BlocksSpecified = true;
+ }
- testedMediaType mediaTest = new testedMediaType();
- DicConsole.Write("Please write a description of the media type and press enter: ");
- mediaTest.MediumTypeName = System.Console.ReadLine();
- DicConsole.Write("Please write the media model and press enter: ");
- mediaTest.Model = System.Console.ReadLine();
+ if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 &&
+ ataId.CurrentSectorsPerTrack > 0)
+ {
+ mediaTest.CurrentCHS = new chsType();
+ mediaTest.CurrentCHS.Cylinders = ataId.CurrentCylinders;
+ mediaTest.CurrentCHS.Heads = ataId.CurrentHeads;
+ mediaTest.CurrentCHS.Sectors = ataId.CurrentSectorsPerTrack;
+ if(mediaTest.Blocks == 0)
+ mediaTest.Blocks =
+ (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads *
+ ataId.CurrentSectorsPerTrack);
+ mediaTest.BlocksSpecified = true;
+ }
- mediaTest.ManufacturerSpecified = true;
- mediaTest.ModelSpecified = true;
- mediaTest.MediaIsRecognized = true;
+ if(ataId.Capabilities.HasFlag(Decoders.ATA.Identify.CapabilitiesBit.LBASupport))
+ {
+ mediaTest.LBASectors = ataId.LBASectors;
+ mediaTest.LBASectorsSpecified = true;
+ mediaTest.Blocks = ataId.LBASectors;
+ mediaTest.BlocksSpecified = true;
+ }
- DicConsole.WriteLine("Querying ATA IDENTIFY...");
- dev.AtaIdentify(out buffer, out errorRegs, timeout, out duration);
+ if(ataId.CommandSet2.HasFlag(Decoders.ATA.Identify.CommandSetBit2.LBA48))
+ {
+ mediaTest.LBA48Sectors = ataId.LBA48Sectors;
+ mediaTest.LBA48SectorsSpecified = true;
+ mediaTest.Blocks = ataId.LBA48Sectors;
+ mediaTest.BlocksSpecified = true;
+ }
- if(Decoders.ATA.Identify.Decode(buffer).HasValue)
+ if(ataId.NominalRotationRate != 0x0000 && ataId.NominalRotationRate != 0xFFFF)
+ if(ataId.NominalRotationRate == 0x0001)
{
- ataId = Decoders.ATA.Identify.Decode(buffer).Value;
-
- if(ataId.UnformattedBPT != 0)
- {
- mediaTest.UnformattedBPT = ataId.UnformattedBPT;
- mediaTest.UnformattedBPTSpecified = true;
- }
- if(ataId.UnformattedBPS != 0)
- {
- mediaTest.UnformattedBPS = ataId.UnformattedBPS;
- mediaTest.UnformattedBPSSpecified = true;
- }
-
- if(ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0)
- {
- mediaTest.CHS = new chsType();
- mediaTest.CHS.Cylinders = ataId.Cylinders;
- mediaTest.CHS.Heads = ataId.Heads;
- mediaTest.CHS.Sectors = ataId.SectorsPerTrack;
- mediaTest.Blocks = (ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack);
- mediaTest.BlocksSpecified = true;
- }
-
- if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 &&
- ataId.CurrentSectorsPerTrack > 0)
- {
- mediaTest.CurrentCHS = new chsType();
- mediaTest.CurrentCHS.Cylinders = ataId.CurrentCylinders;
- mediaTest.CurrentCHS.Heads = ataId.CurrentHeads;
- mediaTest.CurrentCHS.Sectors = ataId.CurrentSectorsPerTrack;
- if(mediaTest.Blocks == 0)
- mediaTest.Blocks =
- (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads *
- ataId.CurrentSectorsPerTrack);
- mediaTest.BlocksSpecified = true;
- }
-
- if(ataId.Capabilities.HasFlag(Decoders.ATA.Identify.CapabilitiesBit.LBASupport))
- {
- mediaTest.LBASectors = ataId.LBASectors;
- mediaTest.LBASectorsSpecified = true;
- mediaTest.Blocks = ataId.LBASectors;
- mediaTest.BlocksSpecified = true;
- }
-
- if(ataId.CommandSet2.HasFlag(Decoders.ATA.Identify.CommandSetBit2.LBA48))
- {
- mediaTest.LBA48Sectors = ataId.LBA48Sectors;
- mediaTest.LBA48SectorsSpecified = true;
- mediaTest.Blocks = ataId.LBA48Sectors;
- mediaTest.BlocksSpecified = true;
- }
-
- if(ataId.NominalRotationRate != 0x0000 && ataId.NominalRotationRate != 0xFFFF)
- if(ataId.NominalRotationRate == 0x0001)
- {
- mediaTest.SolidStateDevice = true;
- mediaTest.SolidStateDeviceSpecified = true;
- }
- else
- {
- mediaTest.SolidStateDevice = false;
- mediaTest.SolidStateDeviceSpecified = true;
- mediaTest.NominalRotationRate = ataId.NominalRotationRate;
- mediaTest.NominalRotationRateSpecified = true;
- }
-
- uint logicalsectorsize = 0;
- uint physicalsectorsize;
- if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 &&
- (ataId.PhysLogSectorSize & 0x4000) == 0x4000)
- {
- if((ataId.PhysLogSectorSize & 0x1000) == 0x1000)
- if(ataId.LogicalSectorWords <= 255 || ataId.LogicalAlignment == 0xFFFF)
- logicalsectorsize = 512;
- else logicalsectorsize = ataId.LogicalSectorWords * 2;
- else logicalsectorsize = 512;
-
- if((ataId.PhysLogSectorSize & 0x2000) == 0x2000)
- {
-#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
- physicalsectorsize =
- (uint)(logicalsectorsize * ((1 << ataId.PhysLogSectorSize) & 0xF));
-#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
- }
- else physicalsectorsize = logicalsectorsize;
- }
- else
- {
- logicalsectorsize = 512;
- physicalsectorsize = 512;
- }
-
- mediaTest.BlockSize = logicalsectorsize;
- mediaTest.BlockSizeSpecified = true;
- if(physicalsectorsize != logicalsectorsize)
- {
- mediaTest.PhysicalBlockSize = physicalsectorsize;
- mediaTest.PhysicalBlockSizeSpecified = true;
-
- if((ataId.LogicalAlignment & 0x8000) == 0x0000 &&
- (ataId.LogicalAlignment & 0x4000) == 0x4000)
- {
- mediaTest.LogicalAlignment = (ushort)(ataId.LogicalAlignment & 0x3FFF);
- mediaTest.LogicalAlignmentSpecified = true;
- }
- }
-
- if(ataId.EccBytes != 0x0000 && ataId.EccBytes != 0xFFFF)
- {
- mediaTest.LongBlockSize = logicalsectorsize + ataId.EccBytes;
- mediaTest.LongBlockSizeSpecified = true;
- }
-
- if(ataId.UnformattedBPS > logicalsectorsize &&
- (!mediaTest.LongBlockSizeSpecified || mediaTest.LongBlockSize == 516))
- {
- mediaTest.LongBlockSize = ataId.UnformattedBPS;
- mediaTest.LongBlockSizeSpecified = true;
- }
-
- if(ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeSet) &&
- !ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeClear) &&
- ataId.EnabledCommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MediaSerial))
- {
- mediaTest.CanReadMediaSerial = true;
- mediaTest.CanReadMediaSerialSpecified = true;
- if(!string.IsNullOrWhiteSpace(ataId.MediaManufacturer))
- {
- mediaTest.Manufacturer = ataId.MediaManufacturer;
- mediaTest.ManufacturerSpecified = true;
- }
- }
-
- mediaTest.SupportsReadLbaSpecified = true;
- mediaTest.SupportsReadRetryLbaSpecified = true;
- mediaTest.SupportsReadDmaLbaSpecified = true;
- mediaTest.SupportsReadDmaRetryLbaSpecified = true;
- mediaTest.SupportsReadLongLbaSpecified = true;
- mediaTest.SupportsReadLongRetryLbaSpecified = true;
- mediaTest.SupportsSeekLbaSpecified = true;
-
- mediaTest.SupportsReadLba48Specified = true;
- mediaTest.SupportsReadDmaLba48Specified = true;
-
- mediaTest.SupportsReadSpecified = true;
- mediaTest.SupportsReadRetrySpecified = true;
- mediaTest.SupportsReadDmaSpecified = true;
- mediaTest.SupportsReadDmaRetrySpecified = true;
- mediaTest.SupportsReadLongSpecified = true;
- mediaTest.SupportsReadLongRetrySpecified = true;
- mediaTest.SupportsSeekSpecified = true;
-
- Decoders.ATA.AtaErrorRegistersCHS errorChs;
- Decoders.ATA.AtaErrorRegistersLBA28 errorLba;
- Decoders.ATA.AtaErrorRegistersLBA48 errorLba48;
-
- byte[] readBuf;
- ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
- bool sense = true;
-
- DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode...");
- sense = dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
- mediaTest.SupportsRead =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
- readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readsectorschs",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode...");
- sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
- mediaTest.SupportsReadRetry =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
- readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readsectorsretrychs",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ DMA in CHS mode...");
- sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout,
- out duration);
- mediaTest.SupportsReadDma =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
- readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readdmachs",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode...");
- sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
- mediaTest.SupportsReadDmaRetry =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
- readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readdmaretrychs",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying SEEK in CHS mode...");
- sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration);
- mediaTest.SupportsSeek =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
- errorChs.status, errorChs.error);
-
- DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode...");
- sense = dev.Read(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
- mediaTest.SupportsReadLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
- readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readsectors",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode...");
- sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
- mediaTest.SupportsReadRetryLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
- readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readsectorsretry",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ DMA in LBA mode...");
- sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
- mediaTest.SupportsReadDmaLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
- readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readdma",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode...");
- sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
- mediaTest.SupportsReadDmaRetryLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
- readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readdmaretry",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying SEEK in LBA mode...");
- sense = dev.Seek(out errorLba, 0, timeout, out duration);
- mediaTest.SupportsSeekLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
- errorChs.status, errorChs.error);
-
- DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode...");
- sense = dev.Read(out readBuf, out errorLba48, 0, 1, timeout, out duration);
- mediaTest.SupportsReadLba48 =
- !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 &&
- readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readsectors48",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ DMA in LBA48 mode...");
- sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration);
- mediaTest.SupportsReadDmaLba48 =
- !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 &&
- readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readdma48",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ LONG in CHS mode...");
- sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, mediaTest.LongBlockSize,
- timeout, out duration);
- mediaTest.SupportsReadLong =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
- readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readlongchs",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode...");
- sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, mediaTest.LongBlockSize,
- timeout, out duration);
- mediaTest.SupportsReadLongRetry =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
- readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readlongretrychs",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ LONG in LBA mode...");
- sense = dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize,
- timeout, out duration);
- mediaTest.SupportsReadLongLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
- readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readlong",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode...");
- sense = dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize,
- timeout, out duration);
- mediaTest.SupportsReadLongRetryLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
- readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
- sense, errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readlongretry",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- readBuf);
+ mediaTest.SolidStateDevice = true;
+ mediaTest.SolidStateDeviceSpecified = true;
+ }
+ else
+ {
+ mediaTest.SolidStateDevice = false;
+ mediaTest.SolidStateDeviceSpecified = true;
+ mediaTest.NominalRotationRate = ataId.NominalRotationRate;
+ mediaTest.NominalRotationRateSpecified = true;
}
- else mediaTest.MediaIsRecognized = false;
- mediaTests.Add(mediaTest);
- }
- }
-
- report.ATA.RemovableMedias = mediaTests.ToArray();
- }
- else
- {
- report.ATA.ReadCapabilities = new testedMediaType();
-
- if(ataId.UnformattedBPT != 0)
- {
- report.ATA.ReadCapabilities.UnformattedBPT = ataId.UnformattedBPT;
- report.ATA.ReadCapabilities.UnformattedBPTSpecified = true;
- }
- if(ataId.UnformattedBPS != 0)
- {
- report.ATA.ReadCapabilities.UnformattedBPS = ataId.UnformattedBPS;
- report.ATA.ReadCapabilities.UnformattedBPSSpecified = true;
- }
-
- if(ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0)
- {
- report.ATA.ReadCapabilities.CHS = new chsType();
- report.ATA.ReadCapabilities.CHS.Cylinders = ataId.Cylinders;
- report.ATA.ReadCapabilities.CHS.Heads = ataId.Heads;
- report.ATA.ReadCapabilities.CHS.Sectors = ataId.SectorsPerTrack;
- report.ATA.ReadCapabilities.Blocks =
- (ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack);
- report.ATA.ReadCapabilities.BlocksSpecified = true;
- }
-
- if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 && ataId.CurrentSectorsPerTrack > 0)
- {
- report.ATA.ReadCapabilities.CurrentCHS = new chsType();
- report.ATA.ReadCapabilities.CurrentCHS.Cylinders = ataId.CurrentCylinders;
- report.ATA.ReadCapabilities.CurrentCHS.Heads = ataId.CurrentHeads;
- report.ATA.ReadCapabilities.CurrentCHS.Sectors = ataId.CurrentSectorsPerTrack;
- report.ATA.ReadCapabilities.Blocks =
- (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack);
- report.ATA.ReadCapabilities.BlocksSpecified = true;
- }
-
- if(ataId.Capabilities.HasFlag(Decoders.ATA.Identify.CapabilitiesBit.LBASupport))
- {
- report.ATA.ReadCapabilities.LBASectors = ataId.LBASectors;
- report.ATA.ReadCapabilities.LBASectorsSpecified = true;
- report.ATA.ReadCapabilities.Blocks = ataId.LBASectors;
- report.ATA.ReadCapabilities.BlocksSpecified = true;
- }
-
- if(ataId.CommandSet2.HasFlag(Decoders.ATA.Identify.CommandSetBit2.LBA48))
- {
- report.ATA.ReadCapabilities.LBA48Sectors = ataId.LBA48Sectors;
- report.ATA.ReadCapabilities.LBA48SectorsSpecified = true;
- report.ATA.ReadCapabilities.Blocks = ataId.LBA48Sectors;
- report.ATA.ReadCapabilities.BlocksSpecified = true;
- }
-
- if(ataId.NominalRotationRate != 0x0000 && ataId.NominalRotationRate != 0xFFFF)
- if(ataId.NominalRotationRate == 0x0001)
+ uint logicalsectorsize = 0;
+ uint physicalsectorsize;
+ if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 &&
+ (ataId.PhysLogSectorSize & 0x4000) == 0x4000)
{
- report.ATA.ReadCapabilities.SolidStateDevice = true;
- report.ATA.ReadCapabilities.SolidStateDeviceSpecified = true;
+ if((ataId.PhysLogSectorSize & 0x1000) == 0x1000)
+ if(ataId.LogicalSectorWords <= 255 || ataId.LogicalAlignment == 0xFFFF)
+ logicalsectorsize = 512;
+ else logicalsectorsize = ataId.LogicalSectorWords * 2;
+ else logicalsectorsize = 512;
+
+ if((ataId.PhysLogSectorSize & 0x2000) == 0x2000)
+ {
+#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
+ physicalsectorsize =
+ (uint)(logicalsectorsize * ((1 << ataId.PhysLogSectorSize) & 0xF));
+#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
+ }
+ else physicalsectorsize = logicalsectorsize;
}
else
{
- report.ATA.ReadCapabilities.SolidStateDevice = false;
- report.ATA.ReadCapabilities.SolidStateDeviceSpecified = true;
- report.ATA.ReadCapabilities.NominalRotationRate = ataId.NominalRotationRate;
- report.ATA.ReadCapabilities.NominalRotationRateSpecified = true;
+ logicalsectorsize = 512;
+ physicalsectorsize = 512;
}
- uint logicalsectorsize = 0;
- uint physicalsectorsize;
- if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 && (ataId.PhysLogSectorSize & 0x4000) == 0x4000)
- {
- if((ataId.PhysLogSectorSize & 0x1000) == 0x1000)
- if(ataId.LogicalSectorWords <= 255 || ataId.LogicalAlignment == 0xFFFF)
- logicalsectorsize = 512;
- else logicalsectorsize = ataId.LogicalSectorWords * 2;
- else logicalsectorsize = 512;
-
- if((ataId.PhysLogSectorSize & 0x2000) == 0x2000)
+ mediaTest.BlockSize = logicalsectorsize;
+ mediaTest.BlockSizeSpecified = true;
+ if(physicalsectorsize != logicalsectorsize)
{
-#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
- physicalsectorsize = logicalsectorsize *
- (uint)Math.Pow(2, (double)(ataId.PhysLogSectorSize & 0xF));
-#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
+ mediaTest.PhysicalBlockSize = physicalsectorsize;
+ mediaTest.PhysicalBlockSizeSpecified = true;
+
+ if((ataId.LogicalAlignment & 0x8000) == 0x0000 &&
+ (ataId.LogicalAlignment & 0x4000) == 0x4000)
+ {
+ mediaTest.LogicalAlignment = (ushort)(ataId.LogicalAlignment & 0x3FFF);
+ mediaTest.LogicalAlignmentSpecified = true;
+ }
}
- else physicalsectorsize = logicalsectorsize;
+
+ if(ataId.EccBytes != 0x0000 && ataId.EccBytes != 0xFFFF)
+ {
+ mediaTest.LongBlockSize = logicalsectorsize + ataId.EccBytes;
+ mediaTest.LongBlockSizeSpecified = true;
+ }
+
+ if(ataId.UnformattedBPS > logicalsectorsize &&
+ (!mediaTest.LongBlockSizeSpecified || mediaTest.LongBlockSize == 516))
+ {
+ mediaTest.LongBlockSize = ataId.UnformattedBPS;
+ mediaTest.LongBlockSizeSpecified = true;
+ }
+
+ if(ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeSet) &&
+ !ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeClear) &&
+ ataId.EnabledCommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MediaSerial))
+ {
+ mediaTest.CanReadMediaSerial = true;
+ mediaTest.CanReadMediaSerialSpecified = true;
+ if(!string.IsNullOrWhiteSpace(ataId.MediaManufacturer))
+ {
+ mediaTest.Manufacturer = ataId.MediaManufacturer;
+ mediaTest.ManufacturerSpecified = true;
+ }
+ }
+
+ mediaTest.SupportsReadLbaSpecified = true;
+ mediaTest.SupportsReadRetryLbaSpecified = true;
+ mediaTest.SupportsReadDmaLbaSpecified = true;
+ mediaTest.SupportsReadDmaRetryLbaSpecified = true;
+ mediaTest.SupportsReadLongLbaSpecified = true;
+ mediaTest.SupportsReadLongRetryLbaSpecified = true;
+ mediaTest.SupportsSeekLbaSpecified = true;
+
+ mediaTest.SupportsReadLba48Specified = true;
+ mediaTest.SupportsReadDmaLba48Specified = true;
+
+ mediaTest.SupportsReadSpecified = true;
+ mediaTest.SupportsReadRetrySpecified = true;
+ mediaTest.SupportsReadDmaSpecified = true;
+ mediaTest.SupportsReadDmaRetrySpecified = true;
+ mediaTest.SupportsReadLongSpecified = true;
+ mediaTest.SupportsReadLongRetrySpecified = true;
+ mediaTest.SupportsSeekSpecified = true;
+
+ Decoders.ATA.AtaErrorRegistersCHS errorChs;
+ Decoders.ATA.AtaErrorRegistersLBA28 errorLba;
+ Decoders.ATA.AtaErrorRegistersLBA48 errorLba48;
+
+ byte[] readBuf;
+ ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
+ bool sense = true;
+
+ DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode...");
+ sense = dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
+ mediaTest.SupportsRead =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
+ readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readsectorschs",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode...");
+ sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
+ mediaTest.SupportsReadRetry =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
+ readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readsectorsretrychs",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ DMA in CHS mode...");
+ sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout,
+ out duration);
+ mediaTest.SupportsReadDma =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
+ readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readdmachs",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode...");
+ sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
+ mediaTest.SupportsReadDmaRetry =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
+ readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readdmaretrychs",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying SEEK in CHS mode...");
+ sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration);
+ mediaTest.SupportsSeek =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
+ errorChs.status, errorChs.error);
+
+ DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode...");
+ sense = dev.Read(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
+ mediaTest.SupportsReadLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
+ readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readsectors",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode...");
+ sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
+ mediaTest.SupportsReadRetryLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
+ readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readsectorsretry",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ DMA in LBA mode...");
+ sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
+ mediaTest.SupportsReadDmaLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
+ readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readdma",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode...");
+ sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
+ mediaTest.SupportsReadDmaRetryLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
+ readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readdmaretry",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying SEEK in LBA mode...");
+ sense = dev.Seek(out errorLba, 0, timeout, out duration);
+ mediaTest.SupportsSeekLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
+ errorChs.status, errorChs.error);
+
+ DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode...");
+ sense = dev.Read(out readBuf, out errorLba48, 0, 1, timeout, out duration);
+ mediaTest.SupportsReadLba48 =
+ !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 &&
+ readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readsectors48",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ DMA in LBA48 mode...");
+ sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration);
+ mediaTest.SupportsReadDmaLba48 =
+ !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 &&
+ readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readdma48",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ LONG in CHS mode...");
+ sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, mediaTest.LongBlockSize,
+ timeout, out duration);
+ mediaTest.SupportsReadLong =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
+ readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readlongchs",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode...");
+ sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, mediaTest.LongBlockSize,
+ timeout, out duration);
+ mediaTest.SupportsReadLongRetry =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
+ readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readlongretrychs",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ LONG in LBA mode...");
+ sense = dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize,
+ timeout, out duration);
+ mediaTest.SupportsReadLongLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
+ readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readlong",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode...");
+ sense = dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize,
+ timeout, out duration);
+ mediaTest.SupportsReadLongRetryLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
+ readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
+ sense, errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readlongretry",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ readBuf);
+ }
+ else mediaTest.MediaIsRecognized = false;
+
+ mediaTests.Add(mediaTest);
+ }
+
+ report.ATA.RemovableMedias = mediaTests.ToArray();
+ }
+ else
+ {
+ report.ATA.ReadCapabilities = new testedMediaType();
+
+ if(ataId.UnformattedBPT != 0)
+ {
+ report.ATA.ReadCapabilities.UnformattedBPT = ataId.UnformattedBPT;
+ report.ATA.ReadCapabilities.UnformattedBPTSpecified = true;
+ }
+ if(ataId.UnformattedBPS != 0)
+ {
+ report.ATA.ReadCapabilities.UnformattedBPS = ataId.UnformattedBPS;
+ report.ATA.ReadCapabilities.UnformattedBPSSpecified = true;
+ }
+
+ if(ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0)
+ {
+ report.ATA.ReadCapabilities.CHS = new chsType();
+ report.ATA.ReadCapabilities.CHS.Cylinders = ataId.Cylinders;
+ report.ATA.ReadCapabilities.CHS.Heads = ataId.Heads;
+ report.ATA.ReadCapabilities.CHS.Sectors = ataId.SectorsPerTrack;
+ report.ATA.ReadCapabilities.Blocks =
+ (ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack);
+ report.ATA.ReadCapabilities.BlocksSpecified = true;
+ }
+
+ if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 && ataId.CurrentSectorsPerTrack > 0)
+ {
+ report.ATA.ReadCapabilities.CurrentCHS = new chsType();
+ report.ATA.ReadCapabilities.CurrentCHS.Cylinders = ataId.CurrentCylinders;
+ report.ATA.ReadCapabilities.CurrentCHS.Heads = ataId.CurrentHeads;
+ report.ATA.ReadCapabilities.CurrentCHS.Sectors = ataId.CurrentSectorsPerTrack;
+ report.ATA.ReadCapabilities.Blocks =
+ (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack);
+ report.ATA.ReadCapabilities.BlocksSpecified = true;
+ }
+
+ if(ataId.Capabilities.HasFlag(Decoders.ATA.Identify.CapabilitiesBit.LBASupport))
+ {
+ report.ATA.ReadCapabilities.LBASectors = ataId.LBASectors;
+ report.ATA.ReadCapabilities.LBASectorsSpecified = true;
+ report.ATA.ReadCapabilities.Blocks = ataId.LBASectors;
+ report.ATA.ReadCapabilities.BlocksSpecified = true;
+ }
+
+ if(ataId.CommandSet2.HasFlag(Decoders.ATA.Identify.CommandSetBit2.LBA48))
+ {
+ report.ATA.ReadCapabilities.LBA48Sectors = ataId.LBA48Sectors;
+ report.ATA.ReadCapabilities.LBA48SectorsSpecified = true;
+ report.ATA.ReadCapabilities.Blocks = ataId.LBA48Sectors;
+ report.ATA.ReadCapabilities.BlocksSpecified = true;
+ }
+
+ if(ataId.NominalRotationRate != 0x0000 && ataId.NominalRotationRate != 0xFFFF)
+ if(ataId.NominalRotationRate == 0x0001)
+ {
+ report.ATA.ReadCapabilities.SolidStateDevice = true;
+ report.ATA.ReadCapabilities.SolidStateDeviceSpecified = true;
}
else
{
- logicalsectorsize = 512;
- physicalsectorsize = 512;
+ report.ATA.ReadCapabilities.SolidStateDevice = false;
+ report.ATA.ReadCapabilities.SolidStateDeviceSpecified = true;
+ report.ATA.ReadCapabilities.NominalRotationRate = ataId.NominalRotationRate;
+ report.ATA.ReadCapabilities.NominalRotationRateSpecified = true;
}
- report.ATA.ReadCapabilities.BlockSize = logicalsectorsize;
- report.ATA.ReadCapabilities.BlockSizeSpecified = true;
- if(physicalsectorsize != logicalsectorsize)
+ uint logicalsectorsize = 0;
+ uint physicalsectorsize;
+ if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 && (ataId.PhysLogSectorSize & 0x4000) == 0x4000)
+ {
+ if((ataId.PhysLogSectorSize & 0x1000) == 0x1000)
+ if(ataId.LogicalSectorWords <= 255 || ataId.LogicalAlignment == 0xFFFF)
+ logicalsectorsize = 512;
+ else logicalsectorsize = ataId.LogicalSectorWords * 2;
+ else logicalsectorsize = 512;
+
+ if((ataId.PhysLogSectorSize & 0x2000) == 0x2000)
{
- report.ATA.ReadCapabilities.PhysicalBlockSize = physicalsectorsize;
- report.ATA.ReadCapabilities.PhysicalBlockSizeSpecified = true;
-
- if((ataId.LogicalAlignment & 0x8000) == 0x0000 && (ataId.LogicalAlignment & 0x4000) == 0x4000)
- {
- report.ATA.ReadCapabilities.LogicalAlignment = (ushort)(ataId.LogicalAlignment & 0x3FFF);
- report.ATA.ReadCapabilities.LogicalAlignmentSpecified = true;
- }
+#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
+ physicalsectorsize = logicalsectorsize *
+ (uint)Math.Pow(2, (double)(ataId.PhysLogSectorSize & 0xF));
+#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
}
-
- if(ataId.EccBytes != 0x0000 && ataId.EccBytes != 0xFFFF)
- {
- report.ATA.ReadCapabilities.LongBlockSize = logicalsectorsize + ataId.EccBytes;
- report.ATA.ReadCapabilities.LongBlockSizeSpecified = true;
- }
-
- if(ataId.UnformattedBPS > logicalsectorsize &&
- (!report.ATA.ReadCapabilities.LongBlockSizeSpecified ||
- report.ATA.ReadCapabilities.LongBlockSize == 516))
- {
- report.ATA.ReadCapabilities.LongBlockSize = ataId.UnformattedBPS;
- report.ATA.ReadCapabilities.LongBlockSizeSpecified = true;
- }
-
- if(ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeSet) &&
- !ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeClear) &&
- ataId.EnabledCommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MediaSerial))
- {
- report.ATA.ReadCapabilities.CanReadMediaSerial = true;
- report.ATA.ReadCapabilities.CanReadMediaSerialSpecified = true;
- if(!string.IsNullOrWhiteSpace(ataId.MediaManufacturer))
- {
- report.ATA.ReadCapabilities.Manufacturer = ataId.MediaManufacturer;
- report.ATA.ReadCapabilities.ManufacturerSpecified = true;
- }
- }
-
- report.ATA.ReadCapabilities.SupportsReadLbaSpecified = true;
- report.ATA.ReadCapabilities.SupportsReadRetryLbaSpecified = true;
- report.ATA.ReadCapabilities.SupportsReadDmaLbaSpecified = true;
- report.ATA.ReadCapabilities.SupportsReadDmaRetryLbaSpecified = true;
- report.ATA.ReadCapabilities.SupportsReadLongLbaSpecified = true;
- report.ATA.ReadCapabilities.SupportsReadLongRetryLbaSpecified = true;
- report.ATA.ReadCapabilities.SupportsSeekLbaSpecified = true;
-
- report.ATA.ReadCapabilities.SupportsReadLba48Specified = true;
- report.ATA.ReadCapabilities.SupportsReadDmaLba48Specified = true;
-
- report.ATA.ReadCapabilities.SupportsReadSpecified = true;
- report.ATA.ReadCapabilities.SupportsReadRetrySpecified = true;
- report.ATA.ReadCapabilities.SupportsReadDmaSpecified = true;
- report.ATA.ReadCapabilities.SupportsReadDmaRetrySpecified = true;
- report.ATA.ReadCapabilities.SupportsReadLongSpecified = true;
- report.ATA.ReadCapabilities.SupportsReadLongRetrySpecified = true;
- report.ATA.ReadCapabilities.SupportsSeekSpecified = true;
-
- Decoders.ATA.AtaErrorRegistersCHS errorChs;
- Decoders.ATA.AtaErrorRegistersLBA28 errorLba;
- Decoders.ATA.AtaErrorRegistersLBA48 errorLba48;
-
- byte[] readBuf;
- ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
- bool sense = true;
-
- DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode...");
- sense = dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsRead =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readsectorschs", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode...");
- sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadRetry =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readsectorsretrychs", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying READ DMA in CHS mode...");
- sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadDma =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readdmachs", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode...");
- sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadDmaRetry =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readdmaretrychs", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying SEEK in CHS mode...");
- sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsSeek =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0;
- DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
- errorChs.status, errorChs.error);
-
- DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode...");
- sense = dev.Read(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorLba.status, errorLba.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readsectors", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode...");
- sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadRetryLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorLba.status, errorLba.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readsectorsretry", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying READ DMA in LBA mode...");
- sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadDmaLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorLba.status, errorLba.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readdma", "_debug_" + report.ATA.Model + ".bin", "read results",
- readBuf);
-
- DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode...");
- sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadDmaRetryLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorLba.status, errorLba.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readdmaretry", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying SEEK in LBA mode...");
- sense = dev.Seek(out errorLba, 0, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsSeekLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0;
- DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
- errorLba.status, errorLba.error);
-
- DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode...");
- sense = dev.Read(out readBuf, out errorLba48, 0, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadLba48 =
- !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorLba48.status, errorLba48.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readsectors48", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying READ DMA in LBA48 mode...");
- sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadDmaLba48 =
- !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorLba48.status, errorLba48.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readdma48", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying READ LONG in CHS mode...");
- sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1,
- report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadLong =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 &&
- BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readlongchs", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode...");
- sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1,
- report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadLongRetry =
- !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 &&
- BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorChs.status, errorChs.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readlongretrychs", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying READ LONG in LBA mode...");
- sense = dev.ReadLong(out readBuf, out errorLba, false, 0, report.ATA.ReadCapabilities.LongBlockSize,
- timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadLongLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 &&
- BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorLba.status, errorLba.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readlong", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
-
- DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode...");
- sense = dev.ReadLong(out readBuf, out errorLba, true, 0, report.ATA.ReadCapabilities.LongBlockSize,
- timeout, out duration);
- report.ATA.ReadCapabilities.SupportsReadLongRetryLba =
- !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 &&
- BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
- DicConsole.DebugWriteLine("ATA Report",
- "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
- errorLba.status, errorLba.error, readBuf.Length);
- if(debug)
- DataFile.WriteTo("ATA Report", "readlongretry", "_debug_" + report.ATA.Model + ".bin",
- "read results", readBuf);
+ else physicalsectorsize = logicalsectorsize;
}
+ else
+ {
+ logicalsectorsize = 512;
+ physicalsectorsize = 512;
+ }
+
+ report.ATA.ReadCapabilities.BlockSize = logicalsectorsize;
+ report.ATA.ReadCapabilities.BlockSizeSpecified = true;
+ if(physicalsectorsize != logicalsectorsize)
+ {
+ report.ATA.ReadCapabilities.PhysicalBlockSize = physicalsectorsize;
+ report.ATA.ReadCapabilities.PhysicalBlockSizeSpecified = true;
+
+ if((ataId.LogicalAlignment & 0x8000) == 0x0000 && (ataId.LogicalAlignment & 0x4000) == 0x4000)
+ {
+ report.ATA.ReadCapabilities.LogicalAlignment = (ushort)(ataId.LogicalAlignment & 0x3FFF);
+ report.ATA.ReadCapabilities.LogicalAlignmentSpecified = true;
+ }
+ }
+
+ if(ataId.EccBytes != 0x0000 && ataId.EccBytes != 0xFFFF)
+ {
+ report.ATA.ReadCapabilities.LongBlockSize = logicalsectorsize + ataId.EccBytes;
+ report.ATA.ReadCapabilities.LongBlockSizeSpecified = true;
+ }
+
+ if(ataId.UnformattedBPS > logicalsectorsize &&
+ (!report.ATA.ReadCapabilities.LongBlockSizeSpecified ||
+ report.ATA.ReadCapabilities.LongBlockSize == 516))
+ {
+ report.ATA.ReadCapabilities.LongBlockSize = ataId.UnformattedBPS;
+ report.ATA.ReadCapabilities.LongBlockSizeSpecified = true;
+ }
+
+ if(ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeSet) &&
+ !ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeClear) &&
+ ataId.EnabledCommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MediaSerial))
+ {
+ report.ATA.ReadCapabilities.CanReadMediaSerial = true;
+ report.ATA.ReadCapabilities.CanReadMediaSerialSpecified = true;
+ if(!string.IsNullOrWhiteSpace(ataId.MediaManufacturer))
+ {
+ report.ATA.ReadCapabilities.Manufacturer = ataId.MediaManufacturer;
+ report.ATA.ReadCapabilities.ManufacturerSpecified = true;
+ }
+ }
+
+ report.ATA.ReadCapabilities.SupportsReadLbaSpecified = true;
+ report.ATA.ReadCapabilities.SupportsReadRetryLbaSpecified = true;
+ report.ATA.ReadCapabilities.SupportsReadDmaLbaSpecified = true;
+ report.ATA.ReadCapabilities.SupportsReadDmaRetryLbaSpecified = true;
+ report.ATA.ReadCapabilities.SupportsReadLongLbaSpecified = true;
+ report.ATA.ReadCapabilities.SupportsReadLongRetryLbaSpecified = true;
+ report.ATA.ReadCapabilities.SupportsSeekLbaSpecified = true;
+
+ report.ATA.ReadCapabilities.SupportsReadLba48Specified = true;
+ report.ATA.ReadCapabilities.SupportsReadDmaLba48Specified = true;
+
+ report.ATA.ReadCapabilities.SupportsReadSpecified = true;
+ report.ATA.ReadCapabilities.SupportsReadRetrySpecified = true;
+ report.ATA.ReadCapabilities.SupportsReadDmaSpecified = true;
+ report.ATA.ReadCapabilities.SupportsReadDmaRetrySpecified = true;
+ report.ATA.ReadCapabilities.SupportsReadLongSpecified = true;
+ report.ATA.ReadCapabilities.SupportsReadLongRetrySpecified = true;
+ report.ATA.ReadCapabilities.SupportsSeekSpecified = true;
+
+ Decoders.ATA.AtaErrorRegistersCHS errorChs;
+ Decoders.ATA.AtaErrorRegistersLBA28 errorLba;
+ Decoders.ATA.AtaErrorRegistersLBA48 errorLba48;
+
+ byte[] readBuf;
+ ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
+ bool sense = true;
+
+ DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode...");
+ sense = dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsRead =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readsectorschs", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode...");
+ sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadRetry =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readsectorsretrychs", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying READ DMA in CHS mode...");
+ sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadDma =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readdmachs", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode...");
+ sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadDmaRetry =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readdmaretrychs", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying SEEK in CHS mode...");
+ sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsSeek =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0;
+ DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
+ errorChs.status, errorChs.error);
+
+ DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode...");
+ sense = dev.Read(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorLba.status, errorLba.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readsectors", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode...");
+ sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadRetryLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorLba.status, errorLba.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readsectorsretry", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying READ DMA in LBA mode...");
+ sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadDmaLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorLba.status, errorLba.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readdma", "_debug_" + report.ATA.Model + ".bin", "read results",
+ readBuf);
+
+ DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode...");
+ sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadDmaRetryLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorLba.status, errorLba.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readdmaretry", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying SEEK in LBA mode...");
+ sense = dev.Seek(out errorLba, 0, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsSeekLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0;
+ DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
+ errorLba.status, errorLba.error);
+
+ DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode...");
+ sense = dev.Read(out readBuf, out errorLba48, 0, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadLba48 =
+ !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorLba48.status, errorLba48.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readsectors48", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying READ DMA in LBA48 mode...");
+ sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadDmaLba48 =
+ !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorLba48.status, errorLba48.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readdma48", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying READ LONG in CHS mode...");
+ sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1,
+ report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadLong =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 &&
+ BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readlongchs", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode...");
+ sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1,
+ report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadLongRetry =
+ !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 &&
+ BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorChs.status, errorChs.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readlongretrychs", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying READ LONG in LBA mode...");
+ sense = dev.ReadLong(out readBuf, out errorLba, false, 0, report.ATA.ReadCapabilities.LongBlockSize,
+ timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadLongLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 &&
+ BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorLba.status, errorLba.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readlong", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
+
+ DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode...");
+ sense = dev.ReadLong(out readBuf, out errorLba, true, 0, report.ATA.ReadCapabilities.LongBlockSize,
+ timeout, out duration);
+ report.ATA.ReadCapabilities.SupportsReadLongRetryLba =
+ !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 &&
+ BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
+ DicConsole.DebugWriteLine("ATA Report",
+ "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
+ errorLba.status, errorLba.error, readBuf.Length);
+ if(debug)
+ DataFile.WriteTo("ATA Report", "readlongretry", "_debug_" + report.ATA.Model + ".bin",
+ "read results", readBuf);
}
}
}
diff --git a/DiscImageChef.Core/Devices/Report/ATAPI.cs b/DiscImageChef.Core/Devices/Report/ATAPI.cs
index bacad152f..8f1df5828 100644
--- a/DiscImageChef.Core/Devices/Report/ATAPI.cs
+++ b/DiscImageChef.Core/Devices/Report/ATAPI.cs
@@ -51,409 +51,408 @@ namespace DiscImageChef.Core.Devices.Report
Decoders.ATA.AtaErrorRegistersCHS errorRegs;
dev.AtapiIdentify(out buffer, out errorRegs, timeout, out duration);
- if(Decoders.ATA.Identify.Decode(buffer).HasValue)
+ if(!Decoders.ATA.Identify.Decode(buffer).HasValue) return;
+
+ Decoders.ATA.Identify.IdentifyDevice atapiId = Decoders.ATA.Identify.Decode(buffer).Value;
+
+ report.ATAPI = new ataType();
+
+ if(!string.IsNullOrWhiteSpace(atapiId.AdditionalPID))
{
- Decoders.ATA.Identify.IdentifyDevice atapiId = Decoders.ATA.Identify.Decode(buffer).Value;
-
- report.ATAPI = new ataType();
-
- if(!string.IsNullOrWhiteSpace(atapiId.AdditionalPID))
- {
- report.ATAPI.AdditionalPID = atapiId.AdditionalPID;
- report.ATAPI.AdditionalPIDSpecified = true;
- }
- if(atapiId.APIOSupported != 0)
- {
- report.ATAPI.APIOSupported = atapiId.APIOSupported;
- report.ATAPI.APIOSupportedSpecified = true;
- }
- if(atapiId.ATAPIByteCount != 0)
- {
- report.ATAPI.ATAPIByteCount = atapiId.ATAPIByteCount;
- report.ATAPI.ATAPIByteCountSpecified = true;
- }
- if(atapiId.BufferType != 0)
- {
- report.ATAPI.BufferType = atapiId.BufferType;
- report.ATAPI.BufferTypeSpecified = true;
- }
- if(atapiId.BufferSize != 0)
- {
- report.ATAPI.BufferSize = atapiId.BufferSize;
- report.ATAPI.BufferSizeSpecified = true;
- }
- if(atapiId.Capabilities != 0)
- {
- report.ATAPI.Capabilities = atapiId.Capabilities;
- report.ATAPI.CapabilitiesSpecified = true;
- }
- if(atapiId.Capabilities2 != 0)
- {
- report.ATAPI.Capabilities2 = atapiId.Capabilities2;
- report.ATAPI.Capabilities2Specified = true;
- }
- if(atapiId.Capabilities3 != 0)
- {
- report.ATAPI.Capabilities3 = atapiId.Capabilities3;
- report.ATAPI.Capabilities3Specified = true;
- }
- if(atapiId.CFAPowerMode != 0)
- {
- report.ATAPI.CFAPowerMode = atapiId.CFAPowerMode;
- report.ATAPI.CFAPowerModeSpecified = true;
- }
- if(atapiId.CommandSet != 0)
- {
- report.ATAPI.CommandSet = atapiId.CommandSet;
- report.ATAPI.CommandSetSpecified = true;
- }
- if(atapiId.CommandSet2 != 0)
- {
- report.ATAPI.CommandSet2 = atapiId.CommandSet2;
- report.ATAPI.CommandSet2Specified = true;
- }
- if(atapiId.CommandSet3 != 0)
- {
- report.ATAPI.CommandSet3 = atapiId.CommandSet3;
- report.ATAPI.CommandSet3Specified = true;
- }
- if(atapiId.CommandSet4 != 0)
- {
- report.ATAPI.CommandSet4 = atapiId.CommandSet4;
- report.ATAPI.CommandSet4Specified = true;
- }
- if(atapiId.CommandSet5 != 0)
- {
- report.ATAPI.CommandSet5 = atapiId.CommandSet5;
- report.ATAPI.CommandSet5Specified = true;
- }
- if(atapiId.CurrentAAM != 0)
- {
- report.ATAPI.CurrentAAM = atapiId.CurrentAAM;
- report.ATAPI.CurrentAAMSpecified = true;
- }
- if(atapiId.CurrentAPM != 0)
- {
- report.ATAPI.CurrentAPM = atapiId.CurrentAPM;
- report.ATAPI.CurrentAPMSpecified = true;
- }
- if(atapiId.DataSetMgmt != 0)
- {
- report.ATAPI.DataSetMgmt = atapiId.DataSetMgmt;
- report.ATAPI.DataSetMgmtSpecified = true;
- }
- if(atapiId.DataSetMgmtSize != 0)
- {
- report.ATAPI.DataSetMgmtSize = atapiId.DataSetMgmtSize;
- report.ATAPI.DataSetMgmtSizeSpecified = true;
- }
- if(atapiId.DeviceFormFactor != 0)
- {
- report.ATAPI.DeviceFormFactor = atapiId.DeviceFormFactor;
- report.ATAPI.DeviceFormFactorSpecified = true;
- }
- if(atapiId.DMAActive != 0)
- {
- report.ATAPI.DMAActive = atapiId.DMAActive;
- report.ATAPI.DMAActiveSpecified = true;
- }
- if(atapiId.DMASupported != 0)
- {
- report.ATAPI.DMASupported = atapiId.DMASupported;
- report.ATAPI.DMASupportedSpecified = true;
- }
- if(atapiId.DMATransferTimingMode != 0)
- {
- report.ATAPI.DMATransferTimingMode = atapiId.DMATransferTimingMode;
- report.ATAPI.DMATransferTimingModeSpecified = true;
- }
- if(atapiId.EnhancedSecurityEraseTime != 0)
- {
- report.ATAPI.EnhancedSecurityEraseTime = atapiId.EnhancedSecurityEraseTime;
- report.ATAPI.EnhancedSecurityEraseTimeSpecified = true;
- }
- if(atapiId.EnabledCommandSet != 0)
- {
- report.ATAPI.EnabledCommandSet = atapiId.EnabledCommandSet;
- report.ATAPI.EnabledCommandSetSpecified = true;
- }
- if(atapiId.EnabledCommandSet2 != 0)
- {
- report.ATAPI.EnabledCommandSet2 = atapiId.EnabledCommandSet2;
- report.ATAPI.EnabledCommandSet2Specified = true;
- }
- if(atapiId.EnabledCommandSet3 != 0)
- {
- report.ATAPI.EnabledCommandSet3 = atapiId.EnabledCommandSet3;
- report.ATAPI.EnabledCommandSet3Specified = true;
- }
- if(atapiId.EnabledCommandSet4 != 0)
- {
- report.ATAPI.EnabledCommandSet4 = atapiId.EnabledCommandSet4;
- report.ATAPI.EnabledCommandSet4Specified = true;
- }
- if(atapiId.EnabledSATAFeatures != 0)
- {
- report.ATAPI.EnabledSATAFeatures = atapiId.EnabledSATAFeatures;
- report.ATAPI.EnabledSATAFeaturesSpecified = true;
- }
- if(atapiId.ExtendedUserSectors != 0)
- {
- report.ATAPI.ExtendedUserSectors = atapiId.ExtendedUserSectors;
- report.ATAPI.ExtendedUserSectorsSpecified = true;
- }
- if(atapiId.FreeFallSensitivity != 0)
- {
- report.ATAPI.FreeFallSensitivity = atapiId.FreeFallSensitivity;
- report.ATAPI.FreeFallSensitivitySpecified = true;
- }
- if(!string.IsNullOrWhiteSpace(atapiId.FirmwareRevision))
- {
- report.ATAPI.FirmwareRevision = atapiId.FirmwareRevision;
- report.ATAPI.FirmwareRevisionSpecified = true;
- }
- if(atapiId.GeneralConfiguration != 0)
- {
- report.ATAPI.GeneralConfiguration = atapiId.GeneralConfiguration;
- report.ATAPI.GeneralConfigurationSpecified = true;
- }
- if(atapiId.HardwareResetResult != 0)
- {
- report.ATAPI.HardwareResetResult = atapiId.HardwareResetResult;
- report.ATAPI.HardwareResetResultSpecified = true;
- }
- if(atapiId.InterseekDelay != 0)
- {
- report.ATAPI.InterseekDelay = atapiId.InterseekDelay;
- report.ATAPI.InterseekDelaySpecified = true;
- }
- if(atapiId.MajorVersion != 0)
- {
- report.ATAPI.MajorVersion = atapiId.MajorVersion;
- report.ATAPI.MajorVersionSpecified = true;
- }
- if(atapiId.MasterPasswordRevisionCode != 0)
- {
- report.ATAPI.MasterPasswordRevisionCode = atapiId.MasterPasswordRevisionCode;
- report.ATAPI.MasterPasswordRevisionCodeSpecified = true;
- }
- if(atapiId.MaxDownloadMicroMode3 != 0)
- {
- report.ATAPI.MaxDownloadMicroMode3 = atapiId.MaxDownloadMicroMode3;
- report.ATAPI.MaxDownloadMicroMode3Specified = true;
- }
- if(atapiId.MaxQueueDepth != 0)
- {
- report.ATAPI.MaxQueueDepth = atapiId.MaxQueueDepth;
- report.ATAPI.MaxQueueDepthSpecified = true;
- }
- if(atapiId.MDMAActive != 0)
- {
- report.ATAPI.MDMAActive = atapiId.MDMAActive;
- report.ATAPI.MDMAActiveSpecified = true;
- }
- if(atapiId.MDMASupported != 0)
- {
- report.ATAPI.MDMASupported = atapiId.MDMASupported;
- report.ATAPI.MDMASupportedSpecified = true;
- }
- if(atapiId.MinDownloadMicroMode3 != 0)
- {
- report.ATAPI.MinDownloadMicroMode3 = atapiId.MinDownloadMicroMode3;
- report.ATAPI.MinDownloadMicroMode3Specified = true;
- }
- if(atapiId.MinMDMACycleTime != 0)
- {
- report.ATAPI.MinMDMACycleTime = atapiId.MinMDMACycleTime;
- report.ATAPI.MinMDMACycleTimeSpecified = true;
- }
- if(atapiId.MinorVersion != 0)
- {
- report.ATAPI.MinorVersion = atapiId.MinorVersion;
- report.ATAPI.MinorVersionSpecified = true;
- }
- if(atapiId.MinPIOCycleTimeNoFlow != 0)
- {
- report.ATAPI.MinPIOCycleTimeNoFlow = atapiId.MinPIOCycleTimeNoFlow;
- report.ATAPI.MinPIOCycleTimeNoFlowSpecified = true;
- }
- if(atapiId.MinPIOCycleTimeFlow != 0)
- {
- report.ATAPI.MinPIOCycleTimeFlow = atapiId.MinPIOCycleTimeFlow;
- report.ATAPI.MinPIOCycleTimeFlowSpecified = true;
- }
- if(!string.IsNullOrWhiteSpace(atapiId.Model))
- {
- report.ATAPI.Model = atapiId.Model;
- report.ATAPI.ModelSpecified = true;
- }
- if(atapiId.MultipleMaxSectors != 0)
- {
- report.ATAPI.MultipleMaxSectors = atapiId.MultipleMaxSectors;
- report.ATAPI.MultipleMaxSectorsSpecified = true;
- }
- if(atapiId.MultipleSectorNumber != 0)
- {
- report.ATAPI.MultipleSectorNumber = atapiId.MultipleSectorNumber;
- report.ATAPI.MultipleSectorNumberSpecified = true;
- }
- if(atapiId.NVCacheCaps != 0)
- {
- report.ATAPI.NVCacheCaps = atapiId.NVCacheCaps;
- report.ATAPI.NVCacheCapsSpecified = true;
- }
- if(atapiId.NVCacheSize != 0)
- {
- report.ATAPI.NVCacheSize = atapiId.NVCacheSize;
- report.ATAPI.NVCacheSizeSpecified = true;
- }
- if(atapiId.NVCacheWriteSpeed != 0)
- {
- report.ATAPI.NVCacheWriteSpeed = atapiId.NVCacheWriteSpeed;
- report.ATAPI.NVCacheWriteSpeedSpecified = true;
- }
- if(atapiId.NVEstimatedSpinUp != 0)
- {
- report.ATAPI.NVEstimatedSpinUp = atapiId.NVEstimatedSpinUp;
- report.ATAPI.NVEstimatedSpinUpSpecified = true;
- }
- if(atapiId.PacketBusRelease != 0)
- {
- report.ATAPI.PacketBusRelease = atapiId.PacketBusRelease;
- report.ATAPI.PacketBusReleaseSpecified = true;
- }
- if(atapiId.PIOTransferTimingMode != 0)
- {
- report.ATAPI.PIOTransferTimingMode = atapiId.PIOTransferTimingMode;
- report.ATAPI.PIOTransferTimingModeSpecified = true;
- }
- if(atapiId.RecommendedAAM != 0)
- {
- report.ATAPI.RecommendedAAM = atapiId.RecommendedAAM;
- report.ATAPI.RecommendedAAMSpecified = true;
- }
- if(atapiId.RecMDMACycleTime != 0)
- {
- report.ATAPI.RecommendedMDMACycleTime = atapiId.RecMDMACycleTime;
- report.ATAPI.RecommendedMDMACycleTimeSpecified = true;
- }
- if(atapiId.RemovableStatusSet != 0)
- {
- report.ATAPI.RemovableStatusSet = atapiId.RemovableStatusSet;
- report.ATAPI.RemovableStatusSetSpecified = true;
- }
- if(atapiId.SATACapabilities != 0)
- {
- report.ATAPI.SATACapabilities = atapiId.SATACapabilities;
- report.ATAPI.SATACapabilitiesSpecified = true;
- }
- if(atapiId.SATACapabilities2 != 0)
- {
- report.ATAPI.SATACapabilities2 = atapiId.SATACapabilities2;
- report.ATAPI.SATACapabilities2Specified = true;
- }
- if(atapiId.SATAFeatures != 0)
- {
- report.ATAPI.SATAFeatures = atapiId.SATAFeatures;
- report.ATAPI.SATAFeaturesSpecified = true;
- }
- if(atapiId.SCTCommandTransport != 0)
- {
- report.ATAPI.SCTCommandTransport = atapiId.SCTCommandTransport;
- report.ATAPI.SCTCommandTransportSpecified = true;
- }
- if(atapiId.SectorsPerCard != 0)
- {
- report.ATAPI.SectorsPerCard = atapiId.SectorsPerCard;
- report.ATAPI.SectorsPerCardSpecified = true;
- }
- if(atapiId.SecurityEraseTime != 0)
- {
- report.ATAPI.SecurityEraseTime = atapiId.SecurityEraseTime;
- report.ATAPI.SecurityEraseTimeSpecified = true;
- }
- if(atapiId.SecurityStatus != 0)
- {
- report.ATAPI.SecurityStatus = atapiId.SecurityStatus;
- report.ATAPI.SecurityStatusSpecified = true;
- }
- if(atapiId.ServiceBusyClear != 0)
- {
- report.ATAPI.ServiceBusyClear = atapiId.ServiceBusyClear;
- report.ATAPI.ServiceBusyClearSpecified = true;
- }
- if(atapiId.SpecificConfiguration != 0)
- {
- report.ATAPI.SpecificConfiguration = atapiId.SpecificConfiguration;
- report.ATAPI.SpecificConfigurationSpecified = true;
- }
- if(atapiId.StreamAccessLatency != 0)
- {
- report.ATAPI.StreamAccessLatency = atapiId.StreamAccessLatency;
- report.ATAPI.StreamAccessLatencySpecified = true;
- }
- if(atapiId.StreamMinReqSize != 0)
- {
- report.ATAPI.StreamMinReqSize = atapiId.StreamMinReqSize;
- report.ATAPI.StreamMinReqSizeSpecified = true;
- }
- if(atapiId.StreamPerformanceGranularity != 0)
- {
- report.ATAPI.StreamPerformanceGranularity = atapiId.StreamPerformanceGranularity;
- report.ATAPI.StreamPerformanceGranularitySpecified = true;
- }
- if(atapiId.StreamTransferTimeDMA != 0)
- {
- report.ATAPI.StreamTransferTimeDMA = atapiId.StreamTransferTimeDMA;
- report.ATAPI.StreamTransferTimeDMASpecified = true;
- }
- if(atapiId.StreamTransferTimePIO != 0)
- {
- report.ATAPI.StreamTransferTimePIO = atapiId.StreamTransferTimePIO;
- report.ATAPI.StreamTransferTimePIOSpecified = true;
- }
- if(atapiId.TransportMajorVersion != 0)
- {
- report.ATAPI.TransportMajorVersion = atapiId.TransportMajorVersion;
- report.ATAPI.TransportMajorVersionSpecified = true;
- }
- if(atapiId.TransportMinorVersion != 0)
- {
- report.ATAPI.TransportMinorVersion = atapiId.TransportMinorVersion;
- report.ATAPI.TransportMinorVersionSpecified = true;
- }
- if(atapiId.TrustedComputing != 0)
- {
- report.ATAPI.TrustedComputing = atapiId.TrustedComputing;
- report.ATAPI.TrustedComputingSpecified = true;
- }
- if(atapiId.UDMAActive != 0)
- {
- report.ATAPI.UDMAActive = atapiId.UDMAActive;
- report.ATAPI.UDMAActiveSpecified = true;
- }
- if(atapiId.UDMASupported != 0)
- {
- report.ATAPI.UDMASupported = atapiId.UDMASupported;
- report.ATAPI.UDMASupportedSpecified = true;
- }
- if(atapiId.WRVMode != 0)
- {
- report.ATAPI.WRVMode = atapiId.WRVMode;
- report.ATAPI.WRVModeSpecified = true;
- }
- if(atapiId.WRVSectorCountMode3 != 0)
- {
- report.ATAPI.WRVSectorCountMode3 = atapiId.WRVSectorCountMode3;
- report.ATAPI.WRVSectorCountMode3Specified = true;
- }
- if(atapiId.WRVSectorCountMode2 != 0)
- {
- report.ATAPI.WRVSectorCountMode2 = atapiId.WRVSectorCountMode2;
- report.ATAPI.WRVSectorCountMode2Specified = true;
- }
- if(debug) report.ATAPI.Identify = buffer;
+ report.ATAPI.AdditionalPID = atapiId.AdditionalPID;
+ report.ATAPI.AdditionalPIDSpecified = true;
}
+ if(atapiId.APIOSupported != 0)
+ {
+ report.ATAPI.APIOSupported = atapiId.APIOSupported;
+ report.ATAPI.APIOSupportedSpecified = true;
+ }
+ if(atapiId.ATAPIByteCount != 0)
+ {
+ report.ATAPI.ATAPIByteCount = atapiId.ATAPIByteCount;
+ report.ATAPI.ATAPIByteCountSpecified = true;
+ }
+ if(atapiId.BufferType != 0)
+ {
+ report.ATAPI.BufferType = atapiId.BufferType;
+ report.ATAPI.BufferTypeSpecified = true;
+ }
+ if(atapiId.BufferSize != 0)
+ {
+ report.ATAPI.BufferSize = atapiId.BufferSize;
+ report.ATAPI.BufferSizeSpecified = true;
+ }
+ if(atapiId.Capabilities != 0)
+ {
+ report.ATAPI.Capabilities = atapiId.Capabilities;
+ report.ATAPI.CapabilitiesSpecified = true;
+ }
+ if(atapiId.Capabilities2 != 0)
+ {
+ report.ATAPI.Capabilities2 = atapiId.Capabilities2;
+ report.ATAPI.Capabilities2Specified = true;
+ }
+ if(atapiId.Capabilities3 != 0)
+ {
+ report.ATAPI.Capabilities3 = atapiId.Capabilities3;
+ report.ATAPI.Capabilities3Specified = true;
+ }
+ if(atapiId.CFAPowerMode != 0)
+ {
+ report.ATAPI.CFAPowerMode = atapiId.CFAPowerMode;
+ report.ATAPI.CFAPowerModeSpecified = true;
+ }
+ if(atapiId.CommandSet != 0)
+ {
+ report.ATAPI.CommandSet = atapiId.CommandSet;
+ report.ATAPI.CommandSetSpecified = true;
+ }
+ if(atapiId.CommandSet2 != 0)
+ {
+ report.ATAPI.CommandSet2 = atapiId.CommandSet2;
+ report.ATAPI.CommandSet2Specified = true;
+ }
+ if(atapiId.CommandSet3 != 0)
+ {
+ report.ATAPI.CommandSet3 = atapiId.CommandSet3;
+ report.ATAPI.CommandSet3Specified = true;
+ }
+ if(atapiId.CommandSet4 != 0)
+ {
+ report.ATAPI.CommandSet4 = atapiId.CommandSet4;
+ report.ATAPI.CommandSet4Specified = true;
+ }
+ if(atapiId.CommandSet5 != 0)
+ {
+ report.ATAPI.CommandSet5 = atapiId.CommandSet5;
+ report.ATAPI.CommandSet5Specified = true;
+ }
+ if(atapiId.CurrentAAM != 0)
+ {
+ report.ATAPI.CurrentAAM = atapiId.CurrentAAM;
+ report.ATAPI.CurrentAAMSpecified = true;
+ }
+ if(atapiId.CurrentAPM != 0)
+ {
+ report.ATAPI.CurrentAPM = atapiId.CurrentAPM;
+ report.ATAPI.CurrentAPMSpecified = true;
+ }
+ if(atapiId.DataSetMgmt != 0)
+ {
+ report.ATAPI.DataSetMgmt = atapiId.DataSetMgmt;
+ report.ATAPI.DataSetMgmtSpecified = true;
+ }
+ if(atapiId.DataSetMgmtSize != 0)
+ {
+ report.ATAPI.DataSetMgmtSize = atapiId.DataSetMgmtSize;
+ report.ATAPI.DataSetMgmtSizeSpecified = true;
+ }
+ if(atapiId.DeviceFormFactor != 0)
+ {
+ report.ATAPI.DeviceFormFactor = atapiId.DeviceFormFactor;
+ report.ATAPI.DeviceFormFactorSpecified = true;
+ }
+ if(atapiId.DMAActive != 0)
+ {
+ report.ATAPI.DMAActive = atapiId.DMAActive;
+ report.ATAPI.DMAActiveSpecified = true;
+ }
+ if(atapiId.DMASupported != 0)
+ {
+ report.ATAPI.DMASupported = atapiId.DMASupported;
+ report.ATAPI.DMASupportedSpecified = true;
+ }
+ if(atapiId.DMATransferTimingMode != 0)
+ {
+ report.ATAPI.DMATransferTimingMode = atapiId.DMATransferTimingMode;
+ report.ATAPI.DMATransferTimingModeSpecified = true;
+ }
+ if(atapiId.EnhancedSecurityEraseTime != 0)
+ {
+ report.ATAPI.EnhancedSecurityEraseTime = atapiId.EnhancedSecurityEraseTime;
+ report.ATAPI.EnhancedSecurityEraseTimeSpecified = true;
+ }
+ if(atapiId.EnabledCommandSet != 0)
+ {
+ report.ATAPI.EnabledCommandSet = atapiId.EnabledCommandSet;
+ report.ATAPI.EnabledCommandSetSpecified = true;
+ }
+ if(atapiId.EnabledCommandSet2 != 0)
+ {
+ report.ATAPI.EnabledCommandSet2 = atapiId.EnabledCommandSet2;
+ report.ATAPI.EnabledCommandSet2Specified = true;
+ }
+ if(atapiId.EnabledCommandSet3 != 0)
+ {
+ report.ATAPI.EnabledCommandSet3 = atapiId.EnabledCommandSet3;
+ report.ATAPI.EnabledCommandSet3Specified = true;
+ }
+ if(atapiId.EnabledCommandSet4 != 0)
+ {
+ report.ATAPI.EnabledCommandSet4 = atapiId.EnabledCommandSet4;
+ report.ATAPI.EnabledCommandSet4Specified = true;
+ }
+ if(atapiId.EnabledSATAFeatures != 0)
+ {
+ report.ATAPI.EnabledSATAFeatures = atapiId.EnabledSATAFeatures;
+ report.ATAPI.EnabledSATAFeaturesSpecified = true;
+ }
+ if(atapiId.ExtendedUserSectors != 0)
+ {
+ report.ATAPI.ExtendedUserSectors = atapiId.ExtendedUserSectors;
+ report.ATAPI.ExtendedUserSectorsSpecified = true;
+ }
+ if(atapiId.FreeFallSensitivity != 0)
+ {
+ report.ATAPI.FreeFallSensitivity = atapiId.FreeFallSensitivity;
+ report.ATAPI.FreeFallSensitivitySpecified = true;
+ }
+ if(!string.IsNullOrWhiteSpace(atapiId.FirmwareRevision))
+ {
+ report.ATAPI.FirmwareRevision = atapiId.FirmwareRevision;
+ report.ATAPI.FirmwareRevisionSpecified = true;
+ }
+ if(atapiId.GeneralConfiguration != 0)
+ {
+ report.ATAPI.GeneralConfiguration = atapiId.GeneralConfiguration;
+ report.ATAPI.GeneralConfigurationSpecified = true;
+ }
+ if(atapiId.HardwareResetResult != 0)
+ {
+ report.ATAPI.HardwareResetResult = atapiId.HardwareResetResult;
+ report.ATAPI.HardwareResetResultSpecified = true;
+ }
+ if(atapiId.InterseekDelay != 0)
+ {
+ report.ATAPI.InterseekDelay = atapiId.InterseekDelay;
+ report.ATAPI.InterseekDelaySpecified = true;
+ }
+ if(atapiId.MajorVersion != 0)
+ {
+ report.ATAPI.MajorVersion = atapiId.MajorVersion;
+ report.ATAPI.MajorVersionSpecified = true;
+ }
+ if(atapiId.MasterPasswordRevisionCode != 0)
+ {
+ report.ATAPI.MasterPasswordRevisionCode = atapiId.MasterPasswordRevisionCode;
+ report.ATAPI.MasterPasswordRevisionCodeSpecified = true;
+ }
+ if(atapiId.MaxDownloadMicroMode3 != 0)
+ {
+ report.ATAPI.MaxDownloadMicroMode3 = atapiId.MaxDownloadMicroMode3;
+ report.ATAPI.MaxDownloadMicroMode3Specified = true;
+ }
+ if(atapiId.MaxQueueDepth != 0)
+ {
+ report.ATAPI.MaxQueueDepth = atapiId.MaxQueueDepth;
+ report.ATAPI.MaxQueueDepthSpecified = true;
+ }
+ if(atapiId.MDMAActive != 0)
+ {
+ report.ATAPI.MDMAActive = atapiId.MDMAActive;
+ report.ATAPI.MDMAActiveSpecified = true;
+ }
+ if(atapiId.MDMASupported != 0)
+ {
+ report.ATAPI.MDMASupported = atapiId.MDMASupported;
+ report.ATAPI.MDMASupportedSpecified = true;
+ }
+ if(atapiId.MinDownloadMicroMode3 != 0)
+ {
+ report.ATAPI.MinDownloadMicroMode3 = atapiId.MinDownloadMicroMode3;
+ report.ATAPI.MinDownloadMicroMode3Specified = true;
+ }
+ if(atapiId.MinMDMACycleTime != 0)
+ {
+ report.ATAPI.MinMDMACycleTime = atapiId.MinMDMACycleTime;
+ report.ATAPI.MinMDMACycleTimeSpecified = true;
+ }
+ if(atapiId.MinorVersion != 0)
+ {
+ report.ATAPI.MinorVersion = atapiId.MinorVersion;
+ report.ATAPI.MinorVersionSpecified = true;
+ }
+ if(atapiId.MinPIOCycleTimeNoFlow != 0)
+ {
+ report.ATAPI.MinPIOCycleTimeNoFlow = atapiId.MinPIOCycleTimeNoFlow;
+ report.ATAPI.MinPIOCycleTimeNoFlowSpecified = true;
+ }
+ if(atapiId.MinPIOCycleTimeFlow != 0)
+ {
+ report.ATAPI.MinPIOCycleTimeFlow = atapiId.MinPIOCycleTimeFlow;
+ report.ATAPI.MinPIOCycleTimeFlowSpecified = true;
+ }
+ if(!string.IsNullOrWhiteSpace(atapiId.Model))
+ {
+ report.ATAPI.Model = atapiId.Model;
+ report.ATAPI.ModelSpecified = true;
+ }
+ if(atapiId.MultipleMaxSectors != 0)
+ {
+ report.ATAPI.MultipleMaxSectors = atapiId.MultipleMaxSectors;
+ report.ATAPI.MultipleMaxSectorsSpecified = true;
+ }
+ if(atapiId.MultipleSectorNumber != 0)
+ {
+ report.ATAPI.MultipleSectorNumber = atapiId.MultipleSectorNumber;
+ report.ATAPI.MultipleSectorNumberSpecified = true;
+ }
+ if(atapiId.NVCacheCaps != 0)
+ {
+ report.ATAPI.NVCacheCaps = atapiId.NVCacheCaps;
+ report.ATAPI.NVCacheCapsSpecified = true;
+ }
+ if(atapiId.NVCacheSize != 0)
+ {
+ report.ATAPI.NVCacheSize = atapiId.NVCacheSize;
+ report.ATAPI.NVCacheSizeSpecified = true;
+ }
+ if(atapiId.NVCacheWriteSpeed != 0)
+ {
+ report.ATAPI.NVCacheWriteSpeed = atapiId.NVCacheWriteSpeed;
+ report.ATAPI.NVCacheWriteSpeedSpecified = true;
+ }
+ if(atapiId.NVEstimatedSpinUp != 0)
+ {
+ report.ATAPI.NVEstimatedSpinUp = atapiId.NVEstimatedSpinUp;
+ report.ATAPI.NVEstimatedSpinUpSpecified = true;
+ }
+ if(atapiId.PacketBusRelease != 0)
+ {
+ report.ATAPI.PacketBusRelease = atapiId.PacketBusRelease;
+ report.ATAPI.PacketBusReleaseSpecified = true;
+ }
+ if(atapiId.PIOTransferTimingMode != 0)
+ {
+ report.ATAPI.PIOTransferTimingMode = atapiId.PIOTransferTimingMode;
+ report.ATAPI.PIOTransferTimingModeSpecified = true;
+ }
+ if(atapiId.RecommendedAAM != 0)
+ {
+ report.ATAPI.RecommendedAAM = atapiId.RecommendedAAM;
+ report.ATAPI.RecommendedAAMSpecified = true;
+ }
+ if(atapiId.RecMDMACycleTime != 0)
+ {
+ report.ATAPI.RecommendedMDMACycleTime = atapiId.RecMDMACycleTime;
+ report.ATAPI.RecommendedMDMACycleTimeSpecified = true;
+ }
+ if(atapiId.RemovableStatusSet != 0)
+ {
+ report.ATAPI.RemovableStatusSet = atapiId.RemovableStatusSet;
+ report.ATAPI.RemovableStatusSetSpecified = true;
+ }
+ if(atapiId.SATACapabilities != 0)
+ {
+ report.ATAPI.SATACapabilities = atapiId.SATACapabilities;
+ report.ATAPI.SATACapabilitiesSpecified = true;
+ }
+ if(atapiId.SATACapabilities2 != 0)
+ {
+ report.ATAPI.SATACapabilities2 = atapiId.SATACapabilities2;
+ report.ATAPI.SATACapabilities2Specified = true;
+ }
+ if(atapiId.SATAFeatures != 0)
+ {
+ report.ATAPI.SATAFeatures = atapiId.SATAFeatures;
+ report.ATAPI.SATAFeaturesSpecified = true;
+ }
+ if(atapiId.SCTCommandTransport != 0)
+ {
+ report.ATAPI.SCTCommandTransport = atapiId.SCTCommandTransport;
+ report.ATAPI.SCTCommandTransportSpecified = true;
+ }
+ if(atapiId.SectorsPerCard != 0)
+ {
+ report.ATAPI.SectorsPerCard = atapiId.SectorsPerCard;
+ report.ATAPI.SectorsPerCardSpecified = true;
+ }
+ if(atapiId.SecurityEraseTime != 0)
+ {
+ report.ATAPI.SecurityEraseTime = atapiId.SecurityEraseTime;
+ report.ATAPI.SecurityEraseTimeSpecified = true;
+ }
+ if(atapiId.SecurityStatus != 0)
+ {
+ report.ATAPI.SecurityStatus = atapiId.SecurityStatus;
+ report.ATAPI.SecurityStatusSpecified = true;
+ }
+ if(atapiId.ServiceBusyClear != 0)
+ {
+ report.ATAPI.ServiceBusyClear = atapiId.ServiceBusyClear;
+ report.ATAPI.ServiceBusyClearSpecified = true;
+ }
+ if(atapiId.SpecificConfiguration != 0)
+ {
+ report.ATAPI.SpecificConfiguration = atapiId.SpecificConfiguration;
+ report.ATAPI.SpecificConfigurationSpecified = true;
+ }
+ if(atapiId.StreamAccessLatency != 0)
+ {
+ report.ATAPI.StreamAccessLatency = atapiId.StreamAccessLatency;
+ report.ATAPI.StreamAccessLatencySpecified = true;
+ }
+ if(atapiId.StreamMinReqSize != 0)
+ {
+ report.ATAPI.StreamMinReqSize = atapiId.StreamMinReqSize;
+ report.ATAPI.StreamMinReqSizeSpecified = true;
+ }
+ if(atapiId.StreamPerformanceGranularity != 0)
+ {
+ report.ATAPI.StreamPerformanceGranularity = atapiId.StreamPerformanceGranularity;
+ report.ATAPI.StreamPerformanceGranularitySpecified = true;
+ }
+ if(atapiId.StreamTransferTimeDMA != 0)
+ {
+ report.ATAPI.StreamTransferTimeDMA = atapiId.StreamTransferTimeDMA;
+ report.ATAPI.StreamTransferTimeDMASpecified = true;
+ }
+ if(atapiId.StreamTransferTimePIO != 0)
+ {
+ report.ATAPI.StreamTransferTimePIO = atapiId.StreamTransferTimePIO;
+ report.ATAPI.StreamTransferTimePIOSpecified = true;
+ }
+ if(atapiId.TransportMajorVersion != 0)
+ {
+ report.ATAPI.TransportMajorVersion = atapiId.TransportMajorVersion;
+ report.ATAPI.TransportMajorVersionSpecified = true;
+ }
+ if(atapiId.TransportMinorVersion != 0)
+ {
+ report.ATAPI.TransportMinorVersion = atapiId.TransportMinorVersion;
+ report.ATAPI.TransportMinorVersionSpecified = true;
+ }
+ if(atapiId.TrustedComputing != 0)
+ {
+ report.ATAPI.TrustedComputing = atapiId.TrustedComputing;
+ report.ATAPI.TrustedComputingSpecified = true;
+ }
+ if(atapiId.UDMAActive != 0)
+ {
+ report.ATAPI.UDMAActive = atapiId.UDMAActive;
+ report.ATAPI.UDMAActiveSpecified = true;
+ }
+ if(atapiId.UDMASupported != 0)
+ {
+ report.ATAPI.UDMASupported = atapiId.UDMASupported;
+ report.ATAPI.UDMASupportedSpecified = true;
+ }
+ if(atapiId.WRVMode != 0)
+ {
+ report.ATAPI.WRVMode = atapiId.WRVMode;
+ report.ATAPI.WRVModeSpecified = true;
+ }
+ if(atapiId.WRVSectorCountMode3 != 0)
+ {
+ report.ATAPI.WRVSectorCountMode3 = atapiId.WRVSectorCountMode3;
+ report.ATAPI.WRVSectorCountMode3Specified = true;
+ }
+ if(atapiId.WRVSectorCountMode2 != 0)
+ {
+ report.ATAPI.WRVSectorCountMode2 = atapiId.WRVSectorCountMode2;
+ report.ATAPI.WRVSectorCountMode2Specified = true;
+ }
+ if(debug) report.ATAPI.Identify = buffer;
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Core/Devices/Report/FireWire.cs b/DiscImageChef.Core/Devices/Report/FireWire.cs
index 468c048fe..3c5347b09 100644
--- a/DiscImageChef.Core/Devices/Report/FireWire.cs
+++ b/DiscImageChef.Core/Devices/Report/FireWire.cs
@@ -51,25 +51,24 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine();
}
- if(pressedKey.Key == ConsoleKey.Y)
+ if(pressedKey.Key != ConsoleKey.Y) return;
+
+ report.FireWire = new firewireType();
+ report.FireWire.Manufacturer = dev.FireWireVendorName;
+ report.FireWire.Product = dev.FireWireModelName;
+ report.FireWire.ProductID = dev.FireWireModel;
+ report.FireWire.VendorID = dev.FireWireVendor;
+
+ pressedKey = new ConsoleKeyInfo();
+ while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
- report.FireWire = new firewireType();
- report.FireWire.Manufacturer = dev.FireWireVendorName;
- report.FireWire.Product = dev.FireWireModelName;
- report.FireWire.ProductID = dev.FireWireModel;
- report.FireWire.VendorID = dev.FireWireVendor;
-
- pressedKey = new ConsoleKeyInfo();
- while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
- {
- DicConsole.Write("Is the media removable from the reading/writing elements? (Y/N): ");
- pressedKey = System.Console.ReadKey();
- DicConsole.WriteLine();
- }
-
- report.FireWire.RemovableMedia = pressedKey.Key == ConsoleKey.Y;
- removable = report.FireWire.RemovableMedia;
+ DicConsole.Write("Is the media removable from the reading/writing elements? (Y/N): ");
+ pressedKey = System.Console.ReadKey();
+ DicConsole.WriteLine();
}
+
+ report.FireWire.RemovableMedia = pressedKey.Key == ConsoleKey.Y;
+ removable = report.FireWire.RemovableMedia;
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Core/Devices/Report/PCMCIA.cs b/DiscImageChef.Core/Devices/Report/PCMCIA.cs
index 12c2455dd..cf1b7e0ed 100644
--- a/DiscImageChef.Core/Devices/Report/PCMCIA.cs
+++ b/DiscImageChef.Core/Devices/Report/PCMCIA.cs
@@ -43,32 +43,33 @@ namespace DiscImageChef.Core.Devices.Report
report.PCMCIA = new pcmciaType();
report.PCMCIA.CIS = dev.Cis;
Tuple[] tuples = CIS.GetTuples(dev.Cis);
- if(tuples != null)
- foreach(Tuple tuple in tuples)
- switch(tuple.Code) {
- case TupleCodes.CISTPL_MANFID:
- ManufacturerIdentificationTuple manfid = CIS.DecodeManufacturerIdentificationTuple(tuple);
+ if(tuples == null) return;
- if(manfid != null)
- {
- report.PCMCIA.ManufacturerCode = manfid.ManufacturerID;
- report.PCMCIA.CardCode = manfid.CardID;
- report.PCMCIA.ManufacturerCodeSpecified = true;
- report.PCMCIA.CardCodeSpecified = true;
- }
- break;
- case TupleCodes.CISTPL_VERS_1:
- Level1VersionTuple vers = CIS.DecodeLevel1VersionTuple(tuple);
+ foreach(Tuple tuple in tuples)
+ switch(tuple.Code) {
+ case TupleCodes.CISTPL_MANFID:
+ ManufacturerIdentificationTuple manfid = CIS.DecodeManufacturerIdentificationTuple(tuple);
- if(vers != null)
- {
- report.PCMCIA.Manufacturer = vers.Manufacturer;
- report.PCMCIA.ProductName = vers.Product;
- report.PCMCIA.Compliance = string.Format("{0}.{1}", vers.MajorVersion, vers.MinorVersion);
- report.PCMCIA.AdditionalInformation = vers.AdditionalInformation;
- }
- break;
- }
+ if(manfid != null)
+ {
+ report.PCMCIA.ManufacturerCode = manfid.ManufacturerID;
+ report.PCMCIA.CardCode = manfid.CardID;
+ report.PCMCIA.ManufacturerCodeSpecified = true;
+ report.PCMCIA.CardCodeSpecified = true;
+ }
+ break;
+ case TupleCodes.CISTPL_VERS_1:
+ Level1VersionTuple vers = CIS.DecodeLevel1VersionTuple(tuple);
+
+ if(vers != null)
+ {
+ report.PCMCIA.Manufacturer = vers.Manufacturer;
+ report.PCMCIA.ProductName = vers.Product;
+ report.PCMCIA.Compliance = string.Format("{0}.{1}", vers.MajorVersion, vers.MinorVersion);
+ report.PCMCIA.AdditionalInformation = vers.AdditionalInformation;
+ }
+ break;
+ }
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Core/Devices/Report/SCSI/General.cs b/DiscImageChef.Core/Devices/Report/SCSI/General.cs
index 0a8c9fcd6..db3eeec89 100644
--- a/DiscImageChef.Core/Devices/Report/SCSI/General.cs
+++ b/DiscImageChef.Core/Devices/Report/SCSI/General.cs
@@ -189,13 +189,12 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{
DicConsole.WriteLine("Querying SCSI EVPD {0:X2}h...", page);
sense = dev.ScsiInquiry(out buffer, out senseBuffer, page);
- if(!sense)
- {
- pageType evpd = new pageType();
- evpd.page = page;
- evpd.value = buffer;
- evpds.Add(evpd);
- }
+ if(sense) continue;
+
+ pageType evpd = new pageType();
+ evpd.page = page;
+ evpd.value = buffer;
+ evpds.Add(evpd);
}
if(evpds.Count > 0) report.SCSI.EVPDPages = evpds.ToArray();
@@ -330,324 +329,321 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine();
}
- if(pressedKey.Key == ConsoleKey.Y)
+ if(pressedKey.Key != ConsoleKey.Y) continue;
+
+ DicConsole.WriteLine("Please insert it in the drive and press any key when it is ready.");
+ System.Console.ReadKey(true);
+
+ testedMediaType mediaTest = new testedMediaType();
+ DicConsole.Write("Please write a description of the media type and press enter: ");
+ mediaTest.MediumTypeName = System.Console.ReadLine();
+ DicConsole.Write("Please write the media manufacturer and press enter: ");
+ mediaTest.Manufacturer = System.Console.ReadLine();
+ DicConsole.Write("Please write the media model and press enter: ");
+ mediaTest.Model = System.Console.ReadLine();
+
+ mediaTest.ManufacturerSpecified = true;
+ mediaTest.ModelSpecified = true;
+ mediaTest.MediaIsRecognized = true;
+
+ sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
+ if(sense)
{
- DicConsole.WriteLine("Please insert it in the drive and press any key when it is ready.");
- System.Console.ReadKey(true);
+ Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuffer);
+ if(decSense.HasValue)
+ if(decSense.Value.ASC == 0x3A)
+ {
+ int leftRetries = 20;
+ while(leftRetries > 0)
+ {
+ DicConsole.Write("\rWaiting for drive to become ready");
+ System.Threading.Thread.Sleep(2000);
+ sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
+ if(!sense) break;
- testedMediaType mediaTest = new testedMediaType();
- DicConsole.Write("Please write a description of the media type and press enter: ");
- mediaTest.MediumTypeName = System.Console.ReadLine();
- DicConsole.Write("Please write the media manufacturer and press enter: ");
- mediaTest.Manufacturer = System.Console.ReadLine();
- DicConsole.Write("Please write the media model and press enter: ");
- mediaTest.Model = System.Console.ReadLine();
+ leftRetries--;
+ }
- mediaTest.ManufacturerSpecified = true;
- mediaTest.ModelSpecified = true;
- mediaTest.MediaIsRecognized = true;
+ mediaTest.MediaIsRecognized &= !sense;
+ }
+ else if(decSense.Value.ASC == 0x04 && decSense.Value.ASCQ == 0x01)
+ {
+ int leftRetries = 20;
+ while(leftRetries > 0)
+ {
+ DicConsole.Write("\rWaiting for drive to become ready");
+ System.Threading.Thread.Sleep(2000);
+ sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
+ if(!sense) break;
- sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
- if(sense)
+ leftRetries--;
+ }
+
+ mediaTest.MediaIsRecognized &= !sense;
+ }
+ else mediaTest.MediaIsRecognized = false;
+ else mediaTest.MediaIsRecognized = false;
+ }
+
+ if(mediaTest.MediaIsRecognized)
+ {
+ mediaTest.SupportsReadCapacitySpecified = true;
+ mediaTest.SupportsReadCapacity16Specified = true;
+
+ DicConsole.WriteLine("Querying SCSI READ CAPACITY...");
+ sense = dev.ReadCapacity(out buffer, out senseBuffer, timeout, out duration);
+ if(!sense && !dev.Error)
+ {
+ mediaTest.SupportsReadCapacity = true;
+ mediaTest.Blocks =
+ (ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) +
+ buffer[3]) + 1;
+ mediaTest.BlockSize =
+ (uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + buffer[7]);
+ mediaTest.BlocksSpecified = true;
+ mediaTest.BlockSizeSpecified = true;
+ }
+
+ DicConsole.WriteLine("Querying SCSI READ CAPACITY (16)...");
+ sense = dev.ReadCapacity16(out buffer, out buffer, timeout, out duration);
+ if(!sense && !dev.Error)
+ {
+ mediaTest.SupportsReadCapacity16 = true;
+ byte[] temp = new byte[8];
+ Array.Copy(buffer, 0, temp, 0, 8);
+ Array.Reverse(temp);
+ mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1;
+ mediaTest.BlockSize =
+ (uint)((buffer[8] << 24) + (buffer[9] << 16) + (buffer[10] << 8) +
+ buffer[11]);
+ mediaTest.BlocksSpecified = true;
+ mediaTest.BlockSizeSpecified = true;
+ }
+
+ decMode = null;
+
+ DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
+ sense = dev.ModeSense10(out buffer, out senseBuffer, false, true,
+ ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout,
+ out duration);
+ if(!sense && !dev.Error)
+ {
+ report.SCSI.SupportsModeSense10 = true;
+ decMode = Decoders.SCSI.Modes.DecodeMode10(buffer, dev.ScsiType);
+ if(debug) mediaTest.ModeSense10Data = buffer;
+ }
+
+ DicConsole.WriteLine("Querying SCSI MODE SENSE...");
+ sense = dev.ModeSense(out buffer, out senseBuffer, timeout, out duration);
+ if(!sense && !dev.Error)
+ {
+ report.SCSI.SupportsModeSense6 = true;
+ if(!decMode.HasValue)
+ decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, dev.ScsiType);
+ if(debug) mediaTest.ModeSense6Data = buffer;
+ }
+
+ if(decMode.HasValue)
+ {
+ mediaTest.MediumType = (byte)decMode.Value.Header.MediumType;
+ mediaTest.MediumTypeSpecified = true;
+ if(decMode.Value.Header.BlockDescriptors != null &&
+ decMode.Value.Header.BlockDescriptors.Length > 0)
+ {
+ mediaTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
+ mediaTest.DensitySpecified = true;
+ }
+ }
+
+ mediaTest.SupportsReadSpecified = true;
+ mediaTest.SupportsRead10Specified = true;
+ mediaTest.SupportsRead12Specified = true;
+ mediaTest.SupportsRead16Specified = true;
+ mediaTest.SupportsReadLongSpecified = true;
+
+ DicConsole.WriteLine("Trying SCSI READ (6)...");
+ mediaTest.SupportsRead = !dev.Read6(out buffer, out senseBuffer, 0, mediaTest.BlockSize,
+ timeout, out duration);
+ DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead);
+ if(debug)
+ DataFile.WriteTo("SCSI Report", "read6",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ buffer);
+
+ DicConsole.WriteLine("Trying SCSI READ (10)...");
+ mediaTest.SupportsRead10 =
+ !dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0,
+ mediaTest.BlockSize, 0, 1, timeout, out duration);
+ DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10);
+ if(debug)
+ DataFile.WriteTo("SCSI Report", "read10",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ buffer);
+
+ DicConsole.WriteLine("Trying SCSI READ (12)...");
+ mediaTest.SupportsRead12 =
+ !dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0,
+ mediaTest.BlockSize, 0, 1, false, timeout, out duration);
+ DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12);
+ if(debug)
+ DataFile.WriteTo("SCSI Report", "read12",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ buffer);
+
+ DicConsole.WriteLine("Trying SCSI READ (16)...");
+ mediaTest.SupportsRead16 =
+ !dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0,
+ mediaTest.BlockSize, 0, 1, false, timeout, out duration);
+ DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16);
+ if(debug)
+ DataFile.WriteTo("SCSI Report", "read16",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ buffer);
+
+ mediaTest.LongBlockSize = mediaTest.BlockSize;
+ DicConsole.WriteLine("Trying SCSI READ LONG (10)...");
+ sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 0xFFFF, timeout,
+ out duration);
+ if(sense && !dev.Error)
{
Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuffer);
if(decSense.HasValue)
- if(decSense.Value.ASC == 0x3A)
+ if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest &&
+ decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00)
{
- int leftRetries = 20;
- while(leftRetries > 0)
+ mediaTest.SupportsReadLong = true;
+ if(decSense.Value.InformationValid && decSense.Value.ILI)
{
- DicConsole.Write("\rWaiting for drive to become ready");
- System.Threading.Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
- if(!sense) break;
-
- leftRetries--;
+ mediaTest.LongBlockSize =
+ 0xFFFF - (decSense.Value.Information & 0xFFFF);
+ mediaTest.LongBlockSizeSpecified = true;
}
-
- mediaTest.MediaIsRecognized &= !sense;
}
- else if(decSense.Value.ASC == 0x04 && decSense.Value.ASCQ == 0x01)
- {
- int leftRetries = 20;
- while(leftRetries > 0)
- {
- DicConsole.Write("\rWaiting for drive to become ready");
- System.Threading.Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
- if(!sense) break;
-
- leftRetries--;
- }
-
- mediaTest.MediaIsRecognized &= !sense;
- }
- else mediaTest.MediaIsRecognized = false;
- else mediaTest.MediaIsRecognized = false;
}
- if(mediaTest.MediaIsRecognized)
+ if(mediaTest.SupportsReadLong && mediaTest.LongBlockSize == mediaTest.BlockSize)
+ if(mediaTest.BlockSize == 512)
+ foreach(ushort testSize in new[]
+ {
+ // Long sector sizes for floppies
+ 514,
+ // Long sector sizes for SuperDisk
+ 536, 558,
+ // Long sector sizes for 512-byte magneto-opticals
+ 600, 610, 630
+ })
+ {
+ sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
+ testSize, timeout, out duration);
+ if(sense || dev.Error) continue;
+
+ mediaTest.SupportsReadLong = true;
+ mediaTest.LongBlockSize = testSize;
+ mediaTest.LongBlockSizeSpecified = true;
+ break;
+ }
+ else if(mediaTest.BlockSize == 1024)
+ foreach(ushort testSize in new[]
+ {
+ // Long sector sizes for floppies
+ 1026,
+ // Long sector sizes for 1024-byte magneto-opticals
+ 1200
+ })
+ {
+ sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
+ testSize, timeout, out duration);
+ if(sense || dev.Error) continue;
+
+ mediaTest.SupportsReadLong = true;
+ mediaTest.LongBlockSize = testSize;
+ mediaTest.LongBlockSizeSpecified = true;
+ break;
+ }
+ else if(mediaTest.BlockSize == 2048)
+ {
+ sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380,
+ timeout, out duration);
+ if(!sense && !dev.Error)
+ {
+ mediaTest.SupportsReadLong = true;
+ mediaTest.LongBlockSize = 2380;
+ mediaTest.LongBlockSizeSpecified = true;
+ }
+ }
+ else if(mediaTest.BlockSize == 4096)
+ {
+ sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760,
+ timeout, out duration);
+ if(!sense && !dev.Error)
+ {
+ mediaTest.SupportsReadLong = true;
+ mediaTest.LongBlockSize = 4760;
+ mediaTest.LongBlockSizeSpecified = true;
+ }
+ }
+ else if(mediaTest.BlockSize == 8192)
+ {
+ sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424,
+ timeout, out duration);
+ if(!sense && !dev.Error)
+ {
+ mediaTest.SupportsReadLong = true;
+ mediaTest.LongBlockSize = 9424;
+ mediaTest.LongBlockSizeSpecified = true;
+ }
+ }
+
+ if(mediaTest.SupportsReadLong && mediaTest.LongBlockSize == mediaTest.BlockSize)
{
- mediaTest.SupportsReadCapacitySpecified = true;
- mediaTest.SupportsReadCapacity16Specified = true;
-
- DicConsole.WriteLine("Querying SCSI READ CAPACITY...");
- sense = dev.ReadCapacity(out buffer, out senseBuffer, timeout, out duration);
- if(!sense && !dev.Error)
+ pressedKey = new ConsoleKeyInfo();
+ while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
- mediaTest.SupportsReadCapacity = true;
- mediaTest.Blocks =
- (ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) +
- buffer[3]) + 1;
- mediaTest.BlockSize =
- (uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + buffer[7]);
- mediaTest.BlocksSpecified = true;
- mediaTest.BlockSizeSpecified = true;
+ DicConsole
+ .Write("Drive supports SCSI READ LONG but I cannot find the correct size. Do you want me to try? (This can take hours) (Y/N): ");
+ pressedKey = System.Console.ReadKey();
+ DicConsole.WriteLine();
}
- DicConsole.WriteLine("Querying SCSI READ CAPACITY (16)...");
- sense = dev.ReadCapacity16(out buffer, out buffer, timeout, out duration);
- if(!sense && !dev.Error)
+ if(pressedKey.Key == ConsoleKey.Y)
{
- mediaTest.SupportsReadCapacity16 = true;
- byte[] temp = new byte[8];
- Array.Copy(buffer, 0, temp, 0, 8);
- Array.Reverse(temp);
- mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1;
- mediaTest.BlockSize =
- (uint)((buffer[8] << 24) + (buffer[9] << 16) + (buffer[10] << 8) +
- buffer[11]);
- mediaTest.BlocksSpecified = true;
- mediaTest.BlockSizeSpecified = true;
- }
-
- decMode = null;
-
- DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
- sense = dev.ModeSense10(out buffer, out senseBuffer, false, true,
- ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout,
- out duration);
- if(!sense && !dev.Error)
- {
- report.SCSI.SupportsModeSense10 = true;
- decMode = Decoders.SCSI.Modes.DecodeMode10(buffer, dev.ScsiType);
- if(debug) mediaTest.ModeSense10Data = buffer;
- }
-
- DicConsole.WriteLine("Querying SCSI MODE SENSE...");
- sense = dev.ModeSense(out buffer, out senseBuffer, timeout, out duration);
- if(!sense && !dev.Error)
- {
- report.SCSI.SupportsModeSense6 = true;
- if(!decMode.HasValue)
- decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, dev.ScsiType);
- if(debug) mediaTest.ModeSense6Data = buffer;
- }
-
- if(decMode.HasValue)
- {
- mediaTest.MediumType = (byte)decMode.Value.Header.MediumType;
- mediaTest.MediumTypeSpecified = true;
- if(decMode.Value.Header.BlockDescriptors != null &&
- decMode.Value.Header.BlockDescriptors.Length > 0)
+ for(ushort i = (ushort)mediaTest.BlockSize; i <= ushort.MaxValue; i++)
{
- mediaTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
- mediaTest.DensitySpecified = true;
- }
- }
-
- mediaTest.SupportsReadSpecified = true;
- mediaTest.SupportsRead10Specified = true;
- mediaTest.SupportsRead12Specified = true;
- mediaTest.SupportsRead16Specified = true;
- mediaTest.SupportsReadLongSpecified = true;
-
- DicConsole.WriteLine("Trying SCSI READ (6)...");
- mediaTest.SupportsRead = !dev.Read6(out buffer, out senseBuffer, 0, mediaTest.BlockSize,
- timeout, out duration);
- DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead);
- if(debug)
- DataFile.WriteTo("SCSI Report", "read6",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- buffer);
-
- DicConsole.WriteLine("Trying SCSI READ (10)...");
- mediaTest.SupportsRead10 =
- !dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0,
- mediaTest.BlockSize, 0, 1, timeout, out duration);
- DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10);
- if(debug)
- DataFile.WriteTo("SCSI Report", "read10",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- buffer);
-
- DicConsole.WriteLine("Trying SCSI READ (12)...");
- mediaTest.SupportsRead12 =
- !dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0,
- mediaTest.BlockSize, 0, 1, false, timeout, out duration);
- DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12);
- if(debug)
- DataFile.WriteTo("SCSI Report", "read12",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- buffer);
-
- DicConsole.WriteLine("Trying SCSI READ (16)...");
- mediaTest.SupportsRead16 =
- !dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0,
- mediaTest.BlockSize, 0, 1, false, timeout, out duration);
- DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16);
- if(debug)
- DataFile.WriteTo("SCSI Report", "read16",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- buffer);
-
- mediaTest.LongBlockSize = mediaTest.BlockSize;
- DicConsole.WriteLine("Trying SCSI READ LONG (10)...");
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 0xFFFF, timeout,
- out duration);
- if(sense && !dev.Error)
- {
- Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuffer);
- if(decSense.HasValue)
- if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest &&
- decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00)
- {
- mediaTest.SupportsReadLong = true;
- if(decSense.Value.InformationValid && decSense.Value.ILI)
- {
- mediaTest.LongBlockSize =
- 0xFFFF - (decSense.Value.Information & 0xFFFF);
- mediaTest.LongBlockSizeSpecified = true;
- }
- }
- }
-
- if(mediaTest.SupportsReadLong && mediaTest.LongBlockSize == mediaTest.BlockSize)
- if(mediaTest.BlockSize == 512)
- foreach(ushort testSize in new[]
- {
- // Long sector sizes for floppies
- 514,
- // Long sector sizes for SuperDisk
- 536, 558,
- // Long sector sizes for 512-byte magneto-opticals
- 600, 610, 630
- })
- {
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
- testSize, timeout, out duration);
- if(!sense && !dev.Error)
- {
- mediaTest.SupportsReadLong = true;
- mediaTest.LongBlockSize = testSize;
- mediaTest.LongBlockSizeSpecified = true;
- break;
- }
- }
- else if(mediaTest.BlockSize == 1024)
- foreach(ushort testSize in new[]
- {
- // Long sector sizes for floppies
- 1026,
- // Long sector sizes for 1024-byte magneto-opticals
- 1200
- })
- {
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
- testSize, timeout, out duration);
- if(!sense && !dev.Error)
- {
- mediaTest.SupportsReadLong = true;
- mediaTest.LongBlockSize = testSize;
- mediaTest.LongBlockSizeSpecified = true;
- break;
- }
- }
- else if(mediaTest.BlockSize == 2048)
- {
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380,
+ DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i);
+ sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i,
timeout, out duration);
- if(!sense && !dev.Error)
+ if(!sense)
{
- mediaTest.SupportsReadLong = true;
- mediaTest.LongBlockSize = 2380;
+ mediaTest.LongBlockSize = i;
mediaTest.LongBlockSizeSpecified = true;
- }
- }
- else if(mediaTest.BlockSize == 4096)
- {
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760,
- timeout, out duration);
- if(!sense && !dev.Error)
- {
- mediaTest.SupportsReadLong = true;
- mediaTest.LongBlockSize = 4760;
- mediaTest.LongBlockSizeSpecified = true;
- }
- }
- else if(mediaTest.BlockSize == 8192)
- {
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424,
- timeout, out duration);
- if(!sense && !dev.Error)
- {
- mediaTest.SupportsReadLong = true;
- mediaTest.LongBlockSize = 9424;
- mediaTest.LongBlockSizeSpecified = true;
- }
- }
-
- if(mediaTest.SupportsReadLong && mediaTest.LongBlockSize == mediaTest.BlockSize)
- {
- pressedKey = new ConsoleKeyInfo();
- while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
- {
- DicConsole
- .Write("Drive supports SCSI READ LONG but I cannot find the correct size. Do you want me to try? (This can take hours) (Y/N): ");
- pressedKey = System.Console.ReadKey();
- DicConsole.WriteLine();
- }
-
- if(pressedKey.Key == ConsoleKey.Y)
- {
- for(ushort i = (ushort)mediaTest.BlockSize; i <= ushort.MaxValue; i++)
- {
- DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i);
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i,
- timeout, out duration);
- if(!sense)
- {
- mediaTest.LongBlockSize = i;
- mediaTest.LongBlockSizeSpecified = true;
- break;
- }
-
- if(i == ushort.MaxValue) break;
+ break;
}
- DicConsole.WriteLine();
+ if(i == ushort.MaxValue) break;
}
+
+ DicConsole.WriteLine();
}
-
- if(debug && mediaTest.SupportsReadLong && mediaTest.LongBlockSizeSpecified &&
- mediaTest.LongBlockSize != mediaTest.BlockSize)
- {
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
- (ushort)mediaTest.LongBlockSize, timeout, out duration);
- if(!sense)
- DataFile.WriteTo("SCSI Report", "readlong10",
- "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
- buffer);
- }
-
- mediaTest.CanReadMediaSerialSpecified = true;
- DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER...");
- mediaTest.CanReadMediaSerial =
- !dev.ReadMediaSerialNumber(out buffer, out senseBuffer, timeout, out duration);
}
- mediaTests.Add(mediaTest);
+ if(debug && mediaTest.SupportsReadLong && mediaTest.LongBlockSizeSpecified &&
+ mediaTest.LongBlockSize != mediaTest.BlockSize)
+ {
+ sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
+ (ushort)mediaTest.LongBlockSize, timeout, out duration);
+ if(!sense)
+ DataFile.WriteTo("SCSI Report", "readlong10",
+ "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
+ buffer);
+ }
+
+ mediaTest.CanReadMediaSerialSpecified = true;
+ DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER...");
+ mediaTest.CanReadMediaSerial =
+ !dev.ReadMediaSerialNumber(out buffer, out senseBuffer, timeout, out duration);
}
+
+ mediaTests.Add(mediaTest);
}
report.SCSI.RemovableMedias = mediaTests.ToArray();
@@ -807,13 +803,12 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, timeout,
out duration);
- if(!sense && !dev.Error)
- {
- report.SCSI.ReadCapabilities.SupportsReadLong = true;
- report.SCSI.ReadCapabilities.LongBlockSize = testSize;
- report.SCSI.ReadCapabilities.LongBlockSizeSpecified = true;
- break;
- }
+ if(sense || dev.Error) continue;
+
+ report.SCSI.ReadCapabilities.SupportsReadLong = true;
+ report.SCSI.ReadCapabilities.LongBlockSize = testSize;
+ report.SCSI.ReadCapabilities.LongBlockSizeSpecified = true;
+ break;
}
else if(report.SCSI.ReadCapabilities.BlockSize == 1024)
foreach(ushort testSize in new[]
@@ -826,13 +821,12 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, timeout,
out duration);
- if(!sense && !dev.Error)
- {
- report.SCSI.ReadCapabilities.SupportsReadLong = true;
- report.SCSI.ReadCapabilities.LongBlockSize = testSize;
- report.SCSI.ReadCapabilities.LongBlockSizeSpecified = true;
- break;
- }
+ if(sense || dev.Error) continue;
+
+ report.SCSI.ReadCapabilities.SupportsReadLong = true;
+ report.SCSI.ReadCapabilities.LongBlockSize = testSize;
+ report.SCSI.ReadCapabilities.LongBlockSizeSpecified = true;
+ break;
}
else if(report.SCSI.ReadCapabilities.BlockSize == 2048)
{
diff --git a/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs b/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs
index df146b629..31e5f4cf2 100644
--- a/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs
+++ b/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs
@@ -1333,11 +1333,10 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DataFile.WriteTo("SCSI Report", "leadin",
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
mediaType + ".bin", "read results", buffer);
- if(!sense)
- {
- mediaTest.CanReadLeadIn = true;
- break;
- }
+ if(sense) continue;
+
+ mediaTest.CanReadLeadIn = true;
+ break;
}
DicConsole.WriteLine("Trying to read CD Lead-Out...");
diff --git a/DiscImageChef.Core/Devices/Report/SCSI/SSC.cs b/DiscImageChef.Core/Devices/Report/SCSI/SSC.cs
index 77e9b6511..87ddb2d2c 100644
--- a/DiscImageChef.Core/Devices/Report/SCSI/SSC.cs
+++ b/DiscImageChef.Core/Devices/Report/SCSI/SSC.cs
@@ -133,14 +133,13 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
report.SCSI.SequentialDevice.SupportedMediaTypes[i].Organization =
mtsh.Value.descriptors[i].organization;
report.SCSI.SequentialDevice.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
- if(mtsh.Value.descriptors[i].densityCodes != null)
- {
- report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes =
- new int[mtsh.Value.descriptors[i].densityCodes.Length];
- for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
- report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes[j] =
- mtsh.Value.descriptors[i].densityCodes[j];
- }
+ if(mtsh.Value.descriptors[i].densityCodes == null) continue;
+
+ report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes =
+ new int[mtsh.Value.descriptors[i].densityCodes.Length];
+ for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
+ report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes[j] =
+ mtsh.Value.descriptors[i].densityCodes[j];
}
}
}
@@ -158,159 +157,157 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine();
}
- if(pressedKey.Key == ConsoleKey.Y)
+ if(pressedKey.Key != ConsoleKey.Y) continue;
+
+ DicConsole.WriteLine("Please insert it in the drive and press any key when it is ready.");
+ System.Console.ReadKey(true);
+
+ SequentialMedia seqTest = new SequentialMedia();
+ DicConsole.Write("Please write a description of the media type and press enter: ");
+ seqTest.MediumTypeName = System.Console.ReadLine();
+ DicConsole.Write("Please write the media manufacturer and press enter: ");
+ seqTest.Manufacturer = System.Console.ReadLine();
+ DicConsole.Write("Please write the media model and press enter: ");
+ seqTest.Model = System.Console.ReadLine();
+
+ seqTest.MediaIsRecognized = true;
+
+ sense = dev.Load(out senseBuffer, timeout, out duration);
+ sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
+ if(sense)
{
- DicConsole.WriteLine("Please insert it in the drive and press any key when it is ready.");
- System.Console.ReadKey(true);
-
- SequentialMedia seqTest = new SequentialMedia();
- DicConsole.Write("Please write a description of the media type and press enter: ");
- seqTest.MediumTypeName = System.Console.ReadLine();
- DicConsole.Write("Please write the media manufacturer and press enter: ");
- seqTest.Manufacturer = System.Console.ReadLine();
- DicConsole.Write("Please write the media model and press enter: ");
- seqTest.Model = System.Console.ReadLine();
-
- seqTest.MediaIsRecognized = true;
-
- sense = dev.Load(out senseBuffer, timeout, out duration);
- sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
- if(sense)
- {
- Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuffer);
- if(decSense.HasValue)
- if(decSense.Value.ASC == 0x3A)
+ Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuffer);
+ if(decSense.HasValue)
+ if(decSense.Value.ASC == 0x3A)
+ {
+ int leftRetries = 20;
+ while(leftRetries > 0)
{
- int leftRetries = 20;
- while(leftRetries > 0)
- {
- DicConsole.Write("\rWaiting for drive to become ready");
- System.Threading.Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
- if(!sense) break;
+ DicConsole.Write("\rWaiting for drive to become ready");
+ System.Threading.Thread.Sleep(2000);
+ sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
+ if(!sense) break;
- leftRetries--;
- }
-
- seqTest.MediaIsRecognized &= !sense;
+ leftRetries--;
}
- else if(decSense.Value.ASC == 0x04 && decSense.Value.ASCQ == 0x01)
+
+ seqTest.MediaIsRecognized &= !sense;
+ }
+ else if(decSense.Value.ASC == 0x04 && decSense.Value.ASCQ == 0x01)
+ {
+ int leftRetries = 20;
+ while(leftRetries > 0)
{
- int leftRetries = 20;
- while(leftRetries > 0)
- {
- DicConsole.Write("\rWaiting for drive to become ready");
- System.Threading.Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
- if(!sense) break;
+ DicConsole.Write("\rWaiting for drive to become ready");
+ System.Threading.Thread.Sleep(2000);
+ sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
+ if(!sense) break;
- leftRetries--;
- }
-
- seqTest.MediaIsRecognized &= !sense;
+ leftRetries--;
}
- else seqTest.MediaIsRecognized = false;
+
+ seqTest.MediaIsRecognized &= !sense;
+ }
else seqTest.MediaIsRecognized = false;
- }
-
- if(seqTest.MediaIsRecognized)
- {
- decMode = null;
-
- DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
- sense = dev.ModeSense10(out buffer, out senseBuffer, false, true,
- ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout, out duration);
- if(!sense && !dev.Error)
- {
- report.SCSI.SupportsModeSense10 = true;
- decMode = Decoders.SCSI.Modes.DecodeMode10(buffer, dev.ScsiType);
- if(debug) seqTest.ModeSense10Data = buffer;
- }
-
- DicConsole.WriteLine("Querying SCSI MODE SENSE...");
- sense = dev.ModeSense(out buffer, out senseBuffer, timeout, out duration);
- if(!sense && !dev.Error)
- {
- report.SCSI.SupportsModeSense6 = true;
- if(!decMode.HasValue) decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, dev.ScsiType);
- if(debug) seqTest.ModeSense6Data = buffer;
- }
-
- if(decMode.HasValue)
- {
- seqTest.MediumType = (byte)decMode.Value.Header.MediumType;
- seqTest.MediumTypeSpecified = true;
- if(decMode.Value.Header.BlockDescriptors != null &&
- decMode.Value.Header.BlockDescriptors.Length > 0)
- {
- seqTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
- seqTest.DensitySpecified = true;
- }
- }
- }
-
- DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for current media...");
- sense = dev.ReportDensitySupport(out buffer, out senseBuffer, false, true, timeout, out duration);
- if(!sense)
- {
- Decoders.SCSI.SSC.DensitySupport.DensitySupportHeader? dsh =
- Decoders.SCSI.SSC.DensitySupport.DecodeDensity(buffer);
- if(dsh.HasValue)
- {
- seqTest.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length];
- for(int i = 0; i < dsh.Value.descriptors.Length; i++)
- {
- seqTest.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm;
- seqTest.SupportedDensities[i].Capacity = dsh.Value.descriptors[i].capacity;
- seqTest.SupportedDensities[i].DefaultDensity = dsh.Value.descriptors[i].defaultDensity;
- seqTest.SupportedDensities[i].Description = dsh.Value.descriptors[i].description;
- seqTest.SupportedDensities[i].Duplicate = dsh.Value.descriptors[i].duplicate;
- seqTest.SupportedDensities[i].Name = dsh.Value.descriptors[i].name;
- seqTest.SupportedDensities[i].Organization = dsh.Value.descriptors[i].organization;
- seqTest.SupportedDensities[i].PrimaryCode = dsh.Value.descriptors[i].primaryCode;
- seqTest.SupportedDensities[i].SecondaryCode = dsh.Value.descriptors[i].secondaryCode;
- seqTest.SupportedDensities[i].Tracks = dsh.Value.descriptors[i].tracks;
- seqTest.SupportedDensities[i].Width = dsh.Value.descriptors[i].width;
- seqTest.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable;
- }
- }
- }
-
- DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types for current media...");
- sense = dev.ReportDensitySupport(out buffer, out senseBuffer, true, true, timeout, out duration);
- if(!sense)
- {
- Decoders.SCSI.SSC.DensitySupport.MediaTypeSupportHeader? mtsh =
- Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(buffer);
- if(mtsh.HasValue)
- {
- seqTest.SupportedMediaTypes = new SupportedMedia[mtsh.Value.descriptors.Length];
- for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
- {
- seqTest.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description;
- seqTest.SupportedMediaTypes[i].Length = mtsh.Value.descriptors[i].length;
- seqTest.SupportedMediaTypes[i].MediumType = mtsh.Value.descriptors[i].mediumType;
- seqTest.SupportedMediaTypes[i].Name = mtsh.Value.descriptors[i].name;
- seqTest.SupportedMediaTypes[i].Organization = mtsh.Value.descriptors[i].organization;
- seqTest.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
- if(mtsh.Value.descriptors[i].densityCodes != null)
- {
- seqTest.SupportedMediaTypes[i].DensityCodes =
- new int[mtsh.Value.descriptors[i].densityCodes.Length];
- for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
- seqTest.SupportedMediaTypes[i].DensityCodes[j] =
- mtsh.Value.descriptors[i].densityCodes[j];
- }
- }
- }
- }
-
- seqTest.CanReadMediaSerialSpecified = true;
- DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER...");
- seqTest.CanReadMediaSerial =
- !dev.ReadMediaSerialNumber(out buffer, out senseBuffer, timeout, out duration);
- seqTests.Add(seqTest);
+ else seqTest.MediaIsRecognized = false;
}
+
+ if(seqTest.MediaIsRecognized)
+ {
+ decMode = null;
+
+ DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
+ sense = dev.ModeSense10(out buffer, out senseBuffer, false, true,
+ ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout, out duration);
+ if(!sense && !dev.Error)
+ {
+ report.SCSI.SupportsModeSense10 = true;
+ decMode = Decoders.SCSI.Modes.DecodeMode10(buffer, dev.ScsiType);
+ if(debug) seqTest.ModeSense10Data = buffer;
+ }
+
+ DicConsole.WriteLine("Querying SCSI MODE SENSE...");
+ sense = dev.ModeSense(out buffer, out senseBuffer, timeout, out duration);
+ if(!sense && !dev.Error)
+ {
+ report.SCSI.SupportsModeSense6 = true;
+ if(!decMode.HasValue) decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, dev.ScsiType);
+ if(debug) seqTest.ModeSense6Data = buffer;
+ }
+
+ if(decMode.HasValue)
+ {
+ seqTest.MediumType = (byte)decMode.Value.Header.MediumType;
+ seqTest.MediumTypeSpecified = true;
+ if(decMode.Value.Header.BlockDescriptors != null &&
+ decMode.Value.Header.BlockDescriptors.Length > 0)
+ {
+ seqTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
+ seqTest.DensitySpecified = true;
+ }
+ }
+ }
+
+ DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for current media...");
+ sense = dev.ReportDensitySupport(out buffer, out senseBuffer, false, true, timeout, out duration);
+ if(!sense)
+ {
+ Decoders.SCSI.SSC.DensitySupport.DensitySupportHeader? dsh =
+ Decoders.SCSI.SSC.DensitySupport.DecodeDensity(buffer);
+ if(dsh.HasValue)
+ {
+ seqTest.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length];
+ for(int i = 0; i < dsh.Value.descriptors.Length; i++)
+ {
+ seqTest.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm;
+ seqTest.SupportedDensities[i].Capacity = dsh.Value.descriptors[i].capacity;
+ seqTest.SupportedDensities[i].DefaultDensity = dsh.Value.descriptors[i].defaultDensity;
+ seqTest.SupportedDensities[i].Description = dsh.Value.descriptors[i].description;
+ seqTest.SupportedDensities[i].Duplicate = dsh.Value.descriptors[i].duplicate;
+ seqTest.SupportedDensities[i].Name = dsh.Value.descriptors[i].name;
+ seqTest.SupportedDensities[i].Organization = dsh.Value.descriptors[i].organization;
+ seqTest.SupportedDensities[i].PrimaryCode = dsh.Value.descriptors[i].primaryCode;
+ seqTest.SupportedDensities[i].SecondaryCode = dsh.Value.descriptors[i].secondaryCode;
+ seqTest.SupportedDensities[i].Tracks = dsh.Value.descriptors[i].tracks;
+ seqTest.SupportedDensities[i].Width = dsh.Value.descriptors[i].width;
+ seqTest.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable;
+ }
+ }
+ }
+
+ DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types for current media...");
+ sense = dev.ReportDensitySupport(out buffer, out senseBuffer, true, true, timeout, out duration);
+ if(!sense)
+ {
+ Decoders.SCSI.SSC.DensitySupport.MediaTypeSupportHeader? mtsh =
+ Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(buffer);
+ if(mtsh.HasValue)
+ {
+ seqTest.SupportedMediaTypes = new SupportedMedia[mtsh.Value.descriptors.Length];
+ for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
+ {
+ seqTest.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description;
+ seqTest.SupportedMediaTypes[i].Length = mtsh.Value.descriptors[i].length;
+ seqTest.SupportedMediaTypes[i].MediumType = mtsh.Value.descriptors[i].mediumType;
+ seqTest.SupportedMediaTypes[i].Name = mtsh.Value.descriptors[i].name;
+ seqTest.SupportedMediaTypes[i].Organization = mtsh.Value.descriptors[i].organization;
+ seqTest.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
+ if(mtsh.Value.descriptors[i].densityCodes == null) continue;
+
+ seqTest.SupportedMediaTypes[i].DensityCodes =
+ new int[mtsh.Value.descriptors[i].densityCodes.Length];
+ for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
+ seqTest.SupportedMediaTypes[i].DensityCodes[j] =
+ mtsh.Value.descriptors[i].densityCodes[j];
+ }
+ }
+ }
+
+ seqTest.CanReadMediaSerialSpecified = true;
+ DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER...");
+ seqTest.CanReadMediaSerial =
+ !dev.ReadMediaSerialNumber(out buffer, out senseBuffer, timeout, out duration);
+ seqTests.Add(seqTest);
}
report.SCSI.SequentialDevice.TestedMedia = seqTests.ToArray();
diff --git a/DiscImageChef.Core/Devices/Report/USB.cs b/DiscImageChef.Core/Devices/Report/USB.cs
index f8ea73109..5487ea12b 100644
--- a/DiscImageChef.Core/Devices/Report/USB.cs
+++ b/DiscImageChef.Core/Devices/Report/USB.cs
@@ -51,26 +51,25 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine();
}
- if(pressedKey.Key == ConsoleKey.Y)
+ if(pressedKey.Key != ConsoleKey.Y) return;
+
+ report.USB = new usbType();
+ report.USB.Manufacturer = dev.UsbManufacturerString;
+ report.USB.Product = dev.UsbProductString;
+ report.USB.ProductID = dev.UsbProductId;
+ report.USB.VendorID = dev.UsbVendorId;
+
+ pressedKey = new ConsoleKeyInfo();
+ while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
- report.USB = new usbType();
- report.USB.Manufacturer = dev.UsbManufacturerString;
- report.USB.Product = dev.UsbProductString;
- report.USB.ProductID = dev.UsbProductId;
- report.USB.VendorID = dev.UsbVendorId;
-
- pressedKey = new ConsoleKeyInfo();
- while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
- {
- DicConsole.Write("Is the media removable from the reading/writing elements? (Y/N): ");
- pressedKey = System.Console.ReadKey();
- DicConsole.WriteLine();
- }
-
- report.USB.RemovableMedia = pressedKey.Key == ConsoleKey.Y;
- removable = report.USB.RemovableMedia;
- if(debug) report.USB.Descriptors = dev.UsbDescriptors;
+ DicConsole.Write("Is the media removable from the reading/writing elements? (Y/N): ");
+ pressedKey = System.Console.ReadKey();
+ DicConsole.WriteLine();
}
+
+ report.USB.RemovableMedia = pressedKey.Key == ConsoleKey.Y;
+ removable = report.USB.RemovableMedia;
+ if(debug) report.USB.Descriptors = dev.UsbDescriptors;
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Core/ImageFormat.cs b/DiscImageChef.Core/ImageFormat.cs
index 5fccc6af2..03ec0e99e 100644
--- a/DiscImageChef.Core/ImageFormat.cs
+++ b/DiscImageChef.Core/ImageFormat.cs
@@ -56,11 +56,10 @@ namespace DiscImageChef.Core
try
{
DicConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imageplugin.Name);
- if(imageplugin.IdentifyImage(imageFilter))
- {
- imageFormat = imageplugin;
- break;
- }
+ if(!imageplugin.IdentifyImage(imageFilter)) continue;
+
+ imageFormat = imageplugin;
+ break;
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch { }
@@ -75,11 +74,10 @@ namespace DiscImageChef.Core
try
{
DicConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imageplugin.Name);
- if(imageplugin.IdentifyImage(imageFilter))
- {
- imageFormat = imageplugin;
- break;
- }
+ if(!imageplugin.IdentifyImage(imageFilter)) continue;
+
+ imageFormat = imageplugin;
+ break;
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch { }
diff --git a/DiscImageChef.Core/Logging/DumpLog.cs b/DiscImageChef.Core/Logging/DumpLog.cs
index eac4b52e8..78b378056 100644
--- a/DiscImageChef.Core/Logging/DumpLog.cs
+++ b/DiscImageChef.Core/Logging/DumpLog.cs
@@ -43,93 +43,90 @@ namespace DiscImageChef.Core.Logging
public DumpLog(string outputFile, Device dev)
{
- if(!string.IsNullOrEmpty(outputFile))
+ if(string.IsNullOrEmpty(outputFile)) return;
+
+ logSw = new StreamWriter(outputFile, true);
+
+ logSw.WriteLine("Start logging at {0}", DateTime.Now);
+
+ Interop.PlatformID platId = Interop.DetectOS.GetRealPlatformID();
+ string platVer = Interop.DetectOS.GetVersion();
+ Type monoRunType = Type.GetType("Mono.Runtime");
+
+ logSw.WriteLine("################# System information #################");
+ logSw.WriteLine("{0} {1} ({2}-bit)", Interop.DetectOS.GetPlatformName(platId, platVer), platVer,
+ Environment.Is64BitOperatingSystem ? 64 : 32);
+ if(monoRunType != null)
{
- logSw = new StreamWriter(outputFile, true);
-
- logSw.WriteLine("Start logging at {0}", DateTime.Now);
-
- Interop.PlatformID platId = Interop.DetectOS.GetRealPlatformID();
- string platVer = Interop.DetectOS.GetVersion();
- Type monoRunType = Type.GetType("Mono.Runtime");
-
- logSw.WriteLine("################# System information #################");
- logSw.WriteLine("{0} {1} ({2}-bit)", Interop.DetectOS.GetPlatformName(platId, platVer), platVer,
- Environment.Is64BitOperatingSystem ? 64 : 32);
- if(monoRunType != null)
- {
- string monoVer = "unknown version";
- MethodInfo monoDisplayName =
- monoRunType.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
- if(monoDisplayName != null) monoVer = (string)monoDisplayName.Invoke(null, null);
- logSw.WriteLine("Mono {0}", monoVer);
- }
- else logSw.WriteLine(".NET Framework {0}", Environment.Version);
- logSw.WriteLine();
-
- logSw.WriteLine("################# Program information ################");
- logSw.WriteLine("DiscImageChef {0} running in {1}-bit", Version.GetVersion(),
- Environment.Is64BitProcess ? 64 : 32);
-#if DEBUG
- logSw.WriteLine("DEBUG version");
-#endif
- logSw.WriteLine("Command line: {0}", Environment.CommandLine);
- logSw.WriteLine();
-
- logSw.WriteLine("################# Device information #################");
- logSw.WriteLine("Manufacturer: {0}", dev.Manufacturer);
- logSw.WriteLine("Model: {0}", dev.Model);
- logSw.WriteLine("Firmware revision: {0}", dev.Revision);
- logSw.WriteLine("Serial number: {0}", dev.Serial);
- logSw.WriteLine("Removable device: {0}", dev.IsRemovable);
- logSw.WriteLine("Device type: {0}", dev.Type);
- logSw.WriteLine("CompactFlash device: {0}", dev.IsCompactFlash);
- logSw.WriteLine("PCMCIA device: {0}", dev.IsPcmcia);
- logSw.WriteLine("USB device: {0}", dev.IsUsb);
- if(dev.IsUsb)
- {
- logSw.WriteLine("USB manufacturer: {0}", dev.UsbManufacturerString);
- logSw.WriteLine("USB product: {0}", dev.UsbProductString);
- logSw.WriteLine("USB serial: {0}", dev.UsbSerialString);
- logSw.WriteLine("USB vendor ID: {0:X4}h", dev.UsbVendorId);
- logSw.WriteLine("USB product ID: {0:X4}h", dev.UsbProductId);
- }
- logSw.WriteLine("FireWire device: {0}", dev.IsFireWire);
- if(dev.IsFireWire)
- {
- logSw.WriteLine("FireWire vendor: {0}", dev.FireWireVendorName);
- logSw.WriteLine("FireWire model: {0}", dev.FireWireModelName);
- logSw.WriteLine("FireWire GUID: 0x{0:X16}", dev.FireWireGuid);
- logSw.WriteLine("FireWire vendor ID: 0x{0:X8}", dev.FireWireVendor);
- logSw.WriteLine("FireWire product ID: 0x{0:X8}", dev.FireWireModel);
- }
- logSw.WriteLine();
- logSw.WriteLine("######################################################");
-
- logSw.WriteLine();
- logSw.WriteLine("################ Dumping progress log ################");
- logSw.Flush();
+ string monoVer = "unknown version";
+ MethodInfo monoDisplayName =
+ monoRunType.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
+ if(monoDisplayName != null) monoVer = (string)monoDisplayName.Invoke(null, null);
+ logSw.WriteLine("Mono {0}", monoVer);
}
+ else logSw.WriteLine(".NET Framework {0}", Environment.Version);
+ logSw.WriteLine();
+
+ logSw.WriteLine("################# Program information ################");
+ logSw.WriteLine("DiscImageChef {0} running in {1}-bit", Version.GetVersion(),
+ Environment.Is64BitProcess ? 64 : 32);
+#if DEBUG
+ logSw.WriteLine("DEBUG version");
+#endif
+ logSw.WriteLine("Command line: {0}", Environment.CommandLine);
+ logSw.WriteLine();
+
+ logSw.WriteLine("################# Device information #################");
+ logSw.WriteLine("Manufacturer: {0}", dev.Manufacturer);
+ logSw.WriteLine("Model: {0}", dev.Model);
+ logSw.WriteLine("Firmware revision: {0}", dev.Revision);
+ logSw.WriteLine("Serial number: {0}", dev.Serial);
+ logSw.WriteLine("Removable device: {0}", dev.IsRemovable);
+ logSw.WriteLine("Device type: {0}", dev.Type);
+ logSw.WriteLine("CompactFlash device: {0}", dev.IsCompactFlash);
+ logSw.WriteLine("PCMCIA device: {0}", dev.IsPcmcia);
+ logSw.WriteLine("USB device: {0}", dev.IsUsb);
+ if(dev.IsUsb)
+ {
+ logSw.WriteLine("USB manufacturer: {0}", dev.UsbManufacturerString);
+ logSw.WriteLine("USB product: {0}", dev.UsbProductString);
+ logSw.WriteLine("USB serial: {0}", dev.UsbSerialString);
+ logSw.WriteLine("USB vendor ID: {0:X4}h", dev.UsbVendorId);
+ logSw.WriteLine("USB product ID: {0:X4}h", dev.UsbProductId);
+ }
+ logSw.WriteLine("FireWire device: {0}", dev.IsFireWire);
+ if(dev.IsFireWire)
+ {
+ logSw.WriteLine("FireWire vendor: {0}", dev.FireWireVendorName);
+ logSw.WriteLine("FireWire model: {0}", dev.FireWireModelName);
+ logSw.WriteLine("FireWire GUID: 0x{0:X16}", dev.FireWireGuid);
+ logSw.WriteLine("FireWire vendor ID: 0x{0:X8}", dev.FireWireVendor);
+ logSw.WriteLine("FireWire product ID: 0x{0:X8}", dev.FireWireModel);
+ }
+ logSw.WriteLine();
+ logSw.WriteLine("######################################################");
+
+ logSw.WriteLine();
+ logSw.WriteLine("################ Dumping progress log ################");
+ logSw.Flush();
}
public void WriteLine(string format, params object[] args)
{
- if(logSw != null)
- {
- string text = string.Format(format, args);
- logSw.WriteLine("{0:s} {1}", DateTime.Now, text);
- logSw.Flush();
- }
+ if(logSw == null) return;
+
+ string text = string.Format(format, args);
+ logSw.WriteLine("{0:s} {1}", DateTime.Now, text);
+ logSw.Flush();
}
public void Close()
{
- if(logSw != null)
- {
- logSw.WriteLine("######################################################");
- logSw.WriteLine("End logging at {0}", DateTime.Now);
- logSw.Close();
- }
+ if(logSw == null) return;
+
+ logSw.WriteLine("######################################################");
+ logSw.WriteLine("End logging at {0}", DateTime.Now);
+ logSw.Close();
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Core/Logging/IBGLog.cs b/DiscImageChef.Core/Logging/IBGLog.cs
index fb4c0b5f8..52fe2bb71 100644
--- a/DiscImageChef.Core/Logging/IBGLog.cs
+++ b/DiscImageChef.Core/Logging/IBGLog.cs
@@ -56,237 +56,233 @@ namespace DiscImageChef.Core.Logging
internal IbgLog(string outputFile, ushort currentProfile)
{
- if(!string.IsNullOrEmpty(outputFile))
- {
- ibgFs = new FileStream(outputFile, FileMode.Create);
- ibgSb = new StringBuilder();
- ibgDatePoint = DateTime.Now;
- ibgCulture = new CultureInfo("en-US");
- ibgStartSet = false;
- ibgMaxSpeed = 0;
- ibgIntSpeed = 0;
- ibgSnaps = 0;
- ibgIntSector = 0;
+ if(string.IsNullOrEmpty(outputFile)) return;
- switch(currentProfile)
- {
- case 0x0001:
- ibgMediaType = "HDD";
- ibgDivider = 1353;
- break;
- case 0x0005:
- ibgMediaType = "CD-MO";
- ibgDivider = 150;
- break;
- case 0x0008:
- ibgMediaType = "CD-ROM";
- ibgDivider = 150;
- break;
- case 0x0009:
- ibgMediaType = "CD-R";
- ibgDivider = 150;
- break;
- case 0x000A:
- ibgMediaType = "CD-RW";
- ibgDivider = 150;
- break;
- case 0x0010:
- ibgMediaType = "DVD-ROM";
- ibgDivider = 1353;
- break;
- case 0x0011:
- ibgMediaType = "DVD-R";
- ibgDivider = 1353;
- break;
- case 0x0012:
- ibgMediaType = "DVD-RAM";
- ibgDivider = 1353;
- break;
- case 0x0013:
- case 0x0014:
- ibgMediaType = "DVD-RW";
- ibgDivider = 1353;
- break;
- case 0x0015:
- case 0x0016:
- ibgMediaType = "DVD-R DL";
- ibgDivider = 1353;
- break;
- case 0x0017:
- ibgMediaType = "DVD-RW DL";
- ibgDivider = 1353;
- break;
- case 0x0018:
- ibgMediaType = "DVD-Download";
- ibgDivider = 1353;
- break;
- case 0x001A:
- ibgMediaType = "DVD+RW";
- ibgDivider = 1353;
- break;
- case 0x001B:
- ibgMediaType = "DVD+R";
- ibgDivider = 1353;
- break;
- case 0x0020:
- ibgMediaType = "DDCD-ROM";
- ibgDivider = 150;
- break;
- case 0x0021:
- ibgMediaType = "DDCD-R";
- ibgDivider = 150;
- break;
- case 0x0022:
- ibgMediaType = "DDCD-RW";
- ibgDivider = 150;
- break;
- case 0x002A:
- ibgMediaType = "DVD+RW DL";
- ibgDivider = 1353;
- break;
- case 0x002B:
- ibgMediaType = "DVD+R DL";
- ibgDivider = 1353;
- break;
- case 0x0040:
- ibgMediaType = "BD-ROM";
- ibgDivider = 4500;
- break;
- case 0x0041:
- case 0x0042:
- ibgMediaType = "BD-R";
- ibgDivider = 4500;
- break;
- case 0x0043:
- ibgMediaType = "BD-RE";
- ibgDivider = 4500;
- break;
- case 0x0050:
- ibgMediaType = "HD DVD-ROM";
- ibgDivider = 4500;
- break;
- case 0x0051:
- ibgMediaType = "HD DVD-R";
- ibgDivider = 4500;
- break;
- case 0x0052:
- ibgMediaType = "HD DVD-RAM";
- ibgDivider = 4500;
- break;
- case 0x0053:
- ibgMediaType = "HD DVD-RW";
- ibgDivider = 4500;
- break;
- case 0x0058:
- ibgMediaType = "HD DVD-R DL";
- ibgDivider = 4500;
- break;
- case 0x005A:
- ibgMediaType = "HD DVD-RW DL";
- ibgDivider = 4500;
- break;
- default:
- ibgMediaType = "Unknown";
- ibgDivider = 1353;
- break;
- }
+ ibgFs = new FileStream(outputFile, FileMode.Create);
+ ibgSb = new StringBuilder();
+ ibgDatePoint = DateTime.Now;
+ ibgCulture = new CultureInfo("en-US");
+ ibgStartSet = false;
+ ibgMaxSpeed = 0;
+ ibgIntSpeed = 0;
+ ibgSnaps = 0;
+ ibgIntSector = 0;
+
+ switch(currentProfile)
+ {
+ case 0x0001:
+ ibgMediaType = "HDD";
+ ibgDivider = 1353;
+ break;
+ case 0x0005:
+ ibgMediaType = "CD-MO";
+ ibgDivider = 150;
+ break;
+ case 0x0008:
+ ibgMediaType = "CD-ROM";
+ ibgDivider = 150;
+ break;
+ case 0x0009:
+ ibgMediaType = "CD-R";
+ ibgDivider = 150;
+ break;
+ case 0x000A:
+ ibgMediaType = "CD-RW";
+ ibgDivider = 150;
+ break;
+ case 0x0010:
+ ibgMediaType = "DVD-ROM";
+ ibgDivider = 1353;
+ break;
+ case 0x0011:
+ ibgMediaType = "DVD-R";
+ ibgDivider = 1353;
+ break;
+ case 0x0012:
+ ibgMediaType = "DVD-RAM";
+ ibgDivider = 1353;
+ break;
+ case 0x0013:
+ case 0x0014:
+ ibgMediaType = "DVD-RW";
+ ibgDivider = 1353;
+ break;
+ case 0x0015:
+ case 0x0016:
+ ibgMediaType = "DVD-R DL";
+ ibgDivider = 1353;
+ break;
+ case 0x0017:
+ ibgMediaType = "DVD-RW DL";
+ ibgDivider = 1353;
+ break;
+ case 0x0018:
+ ibgMediaType = "DVD-Download";
+ ibgDivider = 1353;
+ break;
+ case 0x001A:
+ ibgMediaType = "DVD+RW";
+ ibgDivider = 1353;
+ break;
+ case 0x001B:
+ ibgMediaType = "DVD+R";
+ ibgDivider = 1353;
+ break;
+ case 0x0020:
+ ibgMediaType = "DDCD-ROM";
+ ibgDivider = 150;
+ break;
+ case 0x0021:
+ ibgMediaType = "DDCD-R";
+ ibgDivider = 150;
+ break;
+ case 0x0022:
+ ibgMediaType = "DDCD-RW";
+ ibgDivider = 150;
+ break;
+ case 0x002A:
+ ibgMediaType = "DVD+RW DL";
+ ibgDivider = 1353;
+ break;
+ case 0x002B:
+ ibgMediaType = "DVD+R DL";
+ ibgDivider = 1353;
+ break;
+ case 0x0040:
+ ibgMediaType = "BD-ROM";
+ ibgDivider = 4500;
+ break;
+ case 0x0041:
+ case 0x0042:
+ ibgMediaType = "BD-R";
+ ibgDivider = 4500;
+ break;
+ case 0x0043:
+ ibgMediaType = "BD-RE";
+ ibgDivider = 4500;
+ break;
+ case 0x0050:
+ ibgMediaType = "HD DVD-ROM";
+ ibgDivider = 4500;
+ break;
+ case 0x0051:
+ ibgMediaType = "HD DVD-R";
+ ibgDivider = 4500;
+ break;
+ case 0x0052:
+ ibgMediaType = "HD DVD-RAM";
+ ibgDivider = 4500;
+ break;
+ case 0x0053:
+ ibgMediaType = "HD DVD-RW";
+ ibgDivider = 4500;
+ break;
+ case 0x0058:
+ ibgMediaType = "HD DVD-R DL";
+ ibgDivider = 4500;
+ break;
+ case 0x005A:
+ ibgMediaType = "HD DVD-RW DL";
+ ibgDivider = 4500;
+ break;
+ default:
+ ibgMediaType = "Unknown";
+ ibgDivider = 1353;
+ break;
}
}
internal void Write(ulong sector, double currentSpeed)
{
- if(ibgFs != null)
+ if(ibgFs == null) return;
+
+ ibgIntSpeed += currentSpeed;
+ ibgSampleRate += (int)Math.Floor((DateTime.Now - ibgDatePoint).TotalMilliseconds);
+ ibgSnaps++;
+
+ if(ibgSampleRate < 100) return;
+
+ if(ibgIntSpeed > 0 && !ibgStartSet)
{
- ibgIntSpeed += currentSpeed;
- ibgSampleRate += (int)Math.Floor((DateTime.Now - ibgDatePoint).TotalMilliseconds);
- ibgSnaps++;
-
- if(ibgSampleRate >= 100)
- {
- if(ibgIntSpeed > 0 && !ibgStartSet)
- {
- ibgStartSpeed = ibgIntSpeed / ibgSnaps / ibgDivider;
- ibgStartSet = true;
- }
-
- ibgSb.AppendFormat("{0:0.00},{1},{2:0},0", ibgIntSpeed / ibgSnaps / ibgDivider, ibgIntSector,
- ibgSampleRate).AppendLine();
- if(ibgIntSpeed / ibgSnaps / ibgDivider > ibgMaxSpeed) ibgMaxSpeed = ibgIntSpeed / ibgDivider;
-
- ibgDatePoint = DateTime.Now;
- ibgIntSpeed = 0;
- ibgSampleRate = 0;
- ibgSnaps = 0;
- ibgIntSector = sector;
- }
+ ibgStartSpeed = ibgIntSpeed / ibgSnaps / ibgDivider;
+ ibgStartSet = true;
}
+
+ ibgSb.AppendFormat("{0:0.00},{1},{2:0},0", ibgIntSpeed / ibgSnaps / ibgDivider, ibgIntSector,
+ ibgSampleRate).AppendLine();
+ if(ibgIntSpeed / ibgSnaps / ibgDivider > ibgMaxSpeed) ibgMaxSpeed = ibgIntSpeed / ibgDivider;
+
+ ibgDatePoint = DateTime.Now;
+ ibgIntSpeed = 0;
+ ibgSampleRate = 0;
+ ibgSnaps = 0;
+ ibgIntSector = sector;
}
internal void Close(Device dev, ulong blocks, ulong blockSize, double totalSeconds, double currentSpeed,
double averageSpeed, string devicePath)
{
- if(ibgFs != null)
- {
- StringBuilder ibgHeader = new StringBuilder();
- string ibgBusType;
+ if(ibgFs == null) return;
- if(dev.IsUsb) ibgBusType = "USB";
- else if(dev.IsFireWire) ibgBusType = "FireWire";
- else ibgBusType = dev.Type.ToString();
+ StringBuilder ibgHeader = new StringBuilder();
+ string ibgBusType;
- ibgHeader.AppendLine("IBGD");
- ibgHeader.AppendLine();
- ibgHeader.AppendLine("[START_CONFIGURATION]");
- ibgHeader.AppendLine("IBGD_VERSION=2");
- ibgHeader.AppendLine();
- ibgHeader.AppendFormat("DATE={0}", DateTime.Now).AppendLine();
- ibgHeader.AppendLine();
- ibgHeader.AppendFormat("SAMPLE_RATE={0}", 100).AppendLine();
+ if(dev.IsUsb) ibgBusType = "USB";
+ else if(dev.IsFireWire) ibgBusType = "FireWire";
+ else ibgBusType = dev.Type.ToString();
- ibgHeader.AppendLine();
- ibgHeader.AppendFormat("DEVICE=[0:0:0] {0} {1} ({2}) ({3})", dev.Manufacturer, dev.Model, devicePath,
- ibgBusType).AppendLine();
- ibgHeader.AppendLine("DEVICE_ADDRESS=0:0:0");
- ibgHeader.AppendFormat("DEVICE_MAKEMODEL={0} {1}", dev.Manufacturer, dev.Model).AppendLine();
- ibgHeader.AppendFormat("DEVICE_FIRMWAREVERSION={0}", dev.Revision).AppendLine();
- ibgHeader.AppendFormat("DEVICE_DRIVELETTER={0}", devicePath).AppendLine();
- ibgHeader.AppendFormat("DEVICE_BUSTYPE={0}", ibgBusType).AppendLine();
- ibgHeader.AppendLine();
+ ibgHeader.AppendLine("IBGD");
+ ibgHeader.AppendLine();
+ ibgHeader.AppendLine("[START_CONFIGURATION]");
+ ibgHeader.AppendLine("IBGD_VERSION=2");
+ ibgHeader.AppendLine();
+ ibgHeader.AppendFormat("DATE={0}", DateTime.Now).AppendLine();
+ ibgHeader.AppendLine();
+ ibgHeader.AppendFormat("SAMPLE_RATE={0}", 100).AppendLine();
- ibgHeader.AppendFormat("MEDIA_TYPE={0}", ibgMediaType).AppendLine();
- ibgHeader.AppendLine("MEDIA_BOOKTYPE=Unknown");
- ibgHeader.AppendLine("MEDIA_ID=N/A");
- ibgHeader.AppendLine("MEDIA_TRACKPATH=PTP");
- ibgHeader.AppendLine("MEDIA_SPEEDS=N/A");
- ibgHeader.AppendFormat("MEDIA_CAPACITY={0}", blocks).AppendLine();
- ibgHeader.AppendLine("MEDIA_LAYER_BREAK=0");
- ibgHeader.AppendLine();
- ibgHeader.AppendLine("DATA_IMAGEFILE=/dev/null");
- ibgHeader.AppendFormat("DATA_SECTORS={0}", blocks).AppendLine();
- ibgHeader.AppendFormat("DATA_TYPE=MODE1/{0}", blockSize).AppendLine();
- ibgHeader.AppendLine("DATA_VOLUMEIDENTIFIER=");
- ibgHeader.AppendLine();
- ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_START={0:0.00}", ibgStartSpeed).AppendLine();
- ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_END={0:0.00}", currentSpeed / ibgDivider).AppendLine();
- ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_AVERAGE={0:0.00}", averageSpeed / ibgDivider)
- .AppendLine();
- ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_MAX={0:0.00}", ibgMaxSpeed).AppendLine();
- ibgHeader.AppendFormat(ibgCulture, "VERIFY_TIME_TAKEN={0:0}", Math.Floor(totalSeconds)).AppendLine();
- ibgHeader.AppendLine("[END_CONFIGURATION]");
- ibgHeader.AppendLine();
- ibgHeader.AppendLine("HRPC=True");
- ibgHeader.AppendLine();
- ibgHeader.AppendLine("[START_VERIFY_GRAPH_VALUES]");
- ibgHeader.Append(ibgSb.ToString());
- ibgHeader.AppendLine("[END_VERIFY_GRAPH_VALUES]");
- ibgHeader.AppendLine();
- ibgHeader.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n");
+ ibgHeader.AppendLine();
+ ibgHeader.AppendFormat("DEVICE=[0:0:0] {0} {1} ({2}) ({3})", dev.Manufacturer, dev.Model, devicePath,
+ ibgBusType).AppendLine();
+ ibgHeader.AppendLine("DEVICE_ADDRESS=0:0:0");
+ ibgHeader.AppendFormat("DEVICE_MAKEMODEL={0} {1}", dev.Manufacturer, dev.Model).AppendLine();
+ ibgHeader.AppendFormat("DEVICE_FIRMWAREVERSION={0}", dev.Revision).AppendLine();
+ ibgHeader.AppendFormat("DEVICE_DRIVELETTER={0}", devicePath).AppendLine();
+ ibgHeader.AppendFormat("DEVICE_BUSTYPE={0}", ibgBusType).AppendLine();
+ ibgHeader.AppendLine();
- StreamWriter sr = new StreamWriter(ibgFs);
- sr.Write(ibgHeader);
- sr.Close();
- ibgFs.Close();
- }
+ ibgHeader.AppendFormat("MEDIA_TYPE={0}", ibgMediaType).AppendLine();
+ ibgHeader.AppendLine("MEDIA_BOOKTYPE=Unknown");
+ ibgHeader.AppendLine("MEDIA_ID=N/A");
+ ibgHeader.AppendLine("MEDIA_TRACKPATH=PTP");
+ ibgHeader.AppendLine("MEDIA_SPEEDS=N/A");
+ ibgHeader.AppendFormat("MEDIA_CAPACITY={0}", blocks).AppendLine();
+ ibgHeader.AppendLine("MEDIA_LAYER_BREAK=0");
+ ibgHeader.AppendLine();
+ ibgHeader.AppendLine("DATA_IMAGEFILE=/dev/null");
+ ibgHeader.AppendFormat("DATA_SECTORS={0}", blocks).AppendLine();
+ ibgHeader.AppendFormat("DATA_TYPE=MODE1/{0}", blockSize).AppendLine();
+ ibgHeader.AppendLine("DATA_VOLUMEIDENTIFIER=");
+ ibgHeader.AppendLine();
+ ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_START={0:0.00}", ibgStartSpeed).AppendLine();
+ ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_END={0:0.00}", currentSpeed / ibgDivider).AppendLine();
+ ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_AVERAGE={0:0.00}", averageSpeed / ibgDivider)
+ .AppendLine();
+ ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_MAX={0:0.00}", ibgMaxSpeed).AppendLine();
+ ibgHeader.AppendFormat(ibgCulture, "VERIFY_TIME_TAKEN={0:0}", Math.Floor(totalSeconds)).AppendLine();
+ ibgHeader.AppendLine("[END_CONFIGURATION]");
+ ibgHeader.AppendLine();
+ ibgHeader.AppendLine("HRPC=True");
+ ibgHeader.AppendLine();
+ ibgHeader.AppendLine("[START_VERIFY_GRAPH_VALUES]");
+ ibgHeader.Append(ibgSb.ToString());
+ ibgHeader.AppendLine("[END_VERIFY_GRAPH_VALUES]");
+ ibgHeader.AppendLine();
+ ibgHeader.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n");
+
+ StreamWriter sr = new StreamWriter(ibgFs);
+ sr.Write(ibgHeader);
+ sr.Close();
+ ibgFs.Close();
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Core/Logging/MHDDLog.cs b/DiscImageChef.Core/Logging/MHDDLog.cs
index 6078b1fff..c7a8cfe53 100644
--- a/DiscImageChef.Core/Logging/MHDDLog.cs
+++ b/DiscImageChef.Core/Logging/MHDDLog.cs
@@ -43,101 +43,99 @@ namespace DiscImageChef.Core.Logging
internal MhddLog(string outputFile, Device dev, ulong blocks, ulong blockSize, ulong blocksToRead)
{
- if(dev != null && !string.IsNullOrEmpty(outputFile))
+ if(dev == null || string.IsNullOrEmpty(outputFile)) return;
+
+ mhddFs = new FileStream(outputFile, FileMode.Create);
+
+ string device;
+ string mode;
+ string fw;
+ string sn;
+ string sectors;
+ string sectorsize;
+ string scanblocksize;
+ string ver;
+
+ switch(dev.Type)
{
- mhddFs = new FileStream(outputFile, FileMode.Create);
-
- string device;
- string mode;
- string fw;
- string sn;
- string sectors;
- string sectorsize;
- string scanblocksize;
- string ver;
-
- switch(dev.Type)
- {
- case DeviceType.ATA:
- case DeviceType.ATAPI:
- mode = "MODE: IDE";
- break;
- case DeviceType.SCSI:
- mode = "MODE: SCSI";
- break;
- case DeviceType.MMC:
- mode = "MODE: MMC";
- break;
- case DeviceType.NVMe:
- mode = "MODE: NVMe";
- break;
- case DeviceType.SecureDigital:
- mode = "MODE: SD";
- break;
- default:
- mode = "MODE: IDE";
- break;
- }
-
- device = string.Format("DEVICE: {0} {1}", dev.Manufacturer, dev.Model);
- fw = string.Format("F/W: {0}", dev.Revision);
- sn = string.Format("S/N: {0}", dev.Serial);
- sectors = string.Format(new System.Globalization.CultureInfo("en-US"), "SECTORS: {0:n0}", blocks);
- sectorsize = string.Format(new System.Globalization.CultureInfo("en-US"), "SECTOR SIZE: {0:n0} bytes",
- blockSize);
- scanblocksize = string.Format(new System.Globalization.CultureInfo("en-US"),
- "SCAN BLOCK SIZE: {0:n0} sectors", blocksToRead);
- ver = "VER:2 ";
-
- byte[] deviceBytes = Encoding.ASCII.GetBytes(device);
- byte[] modeBytes = Encoding.ASCII.GetBytes(mode);
- byte[] fwBytes = Encoding.ASCII.GetBytes(fw);
- byte[] snBytes = Encoding.ASCII.GetBytes(sn);
- byte[] sectorsBytes = Encoding.ASCII.GetBytes(sectors);
- byte[] sectorsizeBytes = Encoding.ASCII.GetBytes(sectorsize);
- byte[] scanblocksizeBytes = Encoding.ASCII.GetBytes(scanblocksize);
- byte[] verBytes = Encoding.ASCII.GetBytes(ver);
-
- uint pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length + snBytes.Length +
- sectorsBytes.Length + sectorsizeBytes.Length + scanblocksizeBytes.Length +
- verBytes.Length + 2 * 9 + // New lines
- 4); // Pointer
-
- byte[] newLine = new byte[2];
- newLine[0] = 0x0D;
- newLine[1] = 0x0A;
-
- mhddFs.Write(BitConverter.GetBytes(pointer), 0, 4);
- mhddFs.Write(newLine, 0, 2);
- mhddFs.Write(verBytes, 0, verBytes.Length);
- mhddFs.Write(newLine, 0, 2);
- mhddFs.Write(modeBytes, 0, modeBytes.Length);
- mhddFs.Write(newLine, 0, 2);
- mhddFs.Write(deviceBytes, 0, deviceBytes.Length);
- mhddFs.Write(newLine, 0, 2);
- mhddFs.Write(fwBytes, 0, fwBytes.Length);
- mhddFs.Write(newLine, 0, 2);
- mhddFs.Write(snBytes, 0, snBytes.Length);
- mhddFs.Write(newLine, 0, 2);
- mhddFs.Write(sectorsBytes, 0, sectorsBytes.Length);
- mhddFs.Write(newLine, 0, 2);
- mhddFs.Write(sectorsizeBytes, 0, sectorsizeBytes.Length);
- mhddFs.Write(newLine, 0, 2);
- mhddFs.Write(scanblocksizeBytes, 0, scanblocksizeBytes.Length);
- mhddFs.Write(newLine, 0, 2);
+ case DeviceType.ATA:
+ case DeviceType.ATAPI:
+ mode = "MODE: IDE";
+ break;
+ case DeviceType.SCSI:
+ mode = "MODE: SCSI";
+ break;
+ case DeviceType.MMC:
+ mode = "MODE: MMC";
+ break;
+ case DeviceType.NVMe:
+ mode = "MODE: NVMe";
+ break;
+ case DeviceType.SecureDigital:
+ mode = "MODE: SD";
+ break;
+ default:
+ mode = "MODE: IDE";
+ break;
}
+
+ device = string.Format("DEVICE: {0} {1}", dev.Manufacturer, dev.Model);
+ fw = string.Format("F/W: {0}", dev.Revision);
+ sn = string.Format("S/N: {0}", dev.Serial);
+ sectors = string.Format(new System.Globalization.CultureInfo("en-US"), "SECTORS: {0:n0}", blocks);
+ sectorsize = string.Format(new System.Globalization.CultureInfo("en-US"), "SECTOR SIZE: {0:n0} bytes",
+ blockSize);
+ scanblocksize = string.Format(new System.Globalization.CultureInfo("en-US"),
+ "SCAN BLOCK SIZE: {0:n0} sectors", blocksToRead);
+ ver = "VER:2 ";
+
+ byte[] deviceBytes = Encoding.ASCII.GetBytes(device);
+ byte[] modeBytes = Encoding.ASCII.GetBytes(mode);
+ byte[] fwBytes = Encoding.ASCII.GetBytes(fw);
+ byte[] snBytes = Encoding.ASCII.GetBytes(sn);
+ byte[] sectorsBytes = Encoding.ASCII.GetBytes(sectors);
+ byte[] sectorsizeBytes = Encoding.ASCII.GetBytes(sectorsize);
+ byte[] scanblocksizeBytes = Encoding.ASCII.GetBytes(scanblocksize);
+ byte[] verBytes = Encoding.ASCII.GetBytes(ver);
+
+ uint pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length + snBytes.Length +
+ sectorsBytes.Length + sectorsizeBytes.Length + scanblocksizeBytes.Length +
+ verBytes.Length + 2 * 9 + // New lines
+ 4); // Pointer
+
+ byte[] newLine = new byte[2];
+ newLine[0] = 0x0D;
+ newLine[1] = 0x0A;
+
+ mhddFs.Write(BitConverter.GetBytes(pointer), 0, 4);
+ mhddFs.Write(newLine, 0, 2);
+ mhddFs.Write(verBytes, 0, verBytes.Length);
+ mhddFs.Write(newLine, 0, 2);
+ mhddFs.Write(modeBytes, 0, modeBytes.Length);
+ mhddFs.Write(newLine, 0, 2);
+ mhddFs.Write(deviceBytes, 0, deviceBytes.Length);
+ mhddFs.Write(newLine, 0, 2);
+ mhddFs.Write(fwBytes, 0, fwBytes.Length);
+ mhddFs.Write(newLine, 0, 2);
+ mhddFs.Write(snBytes, 0, snBytes.Length);
+ mhddFs.Write(newLine, 0, 2);
+ mhddFs.Write(sectorsBytes, 0, sectorsBytes.Length);
+ mhddFs.Write(newLine, 0, 2);
+ mhddFs.Write(sectorsizeBytes, 0, sectorsizeBytes.Length);
+ mhddFs.Write(newLine, 0, 2);
+ mhddFs.Write(scanblocksizeBytes, 0, scanblocksizeBytes.Length);
+ mhddFs.Write(newLine, 0, 2);
}
internal void Write(ulong sector, double duration)
{
- if(mhddFs != null)
- {
- byte[] sectorBytes = BitConverter.GetBytes(sector);
- byte[] durationBytes = BitConverter.GetBytes((ulong)(duration * 1000));
+ if(mhddFs == null) return;
- mhddFs.Write(sectorBytes, 0, 8);
- mhddFs.Write(durationBytes, 0, 8);
- }
+ byte[] sectorBytes = BitConverter.GetBytes(sector);
+ byte[] durationBytes = BitConverter.GetBytes((ulong)(duration * 1000));
+
+ mhddFs.Write(sectorBytes, 0, 8);
+ mhddFs.Write(durationBytes, 0, 8);
}
internal void Close()
diff --git a/DiscImageChef.Core/Partitions.cs b/DiscImageChef.Core/Partitions.cs
index d198a7262..ed42061e8 100644
--- a/DiscImageChef.Core/Partitions.cs
+++ b/DiscImageChef.Core/Partitions.cs
@@ -90,12 +90,12 @@ namespace DiscImageChef.Core
foreach(PartitionPlugin _partplugin in plugins.PartPluginsList.Values)
{
DicConsole.DebugWriteLine("Partitions", "Trying {0} @ {1}", _partplugin.Name, partitions[0].Start);
- if(_partplugin.GetInformation(image, out List _partitions, partitions[0].Start))
- {
- DicConsole.DebugWriteLine("Partitions", "Found {0} @ {1}", _partplugin.Name,
- partitions[0].Start);
- childs.AddRange(_partitions);
- }
+ if(!_partplugin.GetInformation(image, out List _partitions, partitions[0].Start))
+ continue;
+
+ DicConsole.DebugWriteLine("Partitions", "Found {0} @ {1}", _partplugin.Name,
+ partitions[0].Start);
+ childs.AddRange(_partitions);
}
checkedLocations.Add(partitions[0].Start);
diff --git a/DiscImageChef.Core/PluginBase.cs b/DiscImageChef.Core/PluginBase.cs
index 731463a1d..3228c1582 100644
--- a/DiscImageChef.Core/PluginBase.cs
+++ b/DiscImageChef.Core/PluginBase.cs
@@ -63,11 +63,10 @@ namespace DiscImageChef.Core
foreach(Type type in assembly.GetTypes())
try
{
- if(type.IsSubclassOf(typeof(ImagePlugin)))
- {
- ImagePlugin plugin = (ImagePlugin)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
- RegisterImagePlugin(plugin);
- }
+ if(!type.IsSubclassOf(typeof(ImagePlugin))) continue;
+
+ ImagePlugin plugin = (ImagePlugin)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
+ RegisterImagePlugin(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
@@ -76,11 +75,10 @@ namespace DiscImageChef.Core
foreach(Type type in assembly.GetTypes())
try
{
- if(type.IsSubclassOf(typeof(PartitionPlugin)))
- {
- PartitionPlugin plugin = (PartitionPlugin)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
- RegisterPartPlugin(plugin);
- }
+ if(!type.IsSubclassOf(typeof(PartitionPlugin))) continue;
+
+ PartitionPlugin plugin = (PartitionPlugin)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
+ RegisterPartPlugin(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
@@ -89,15 +87,14 @@ namespace DiscImageChef.Core
foreach(Type type in assembly.GetTypes())
try
{
- if(type.IsSubclassOf(typeof(Filesystem)))
- {
- Filesystem plugin;
- if(encoding != null)
- plugin = (Filesystem)type.GetConstructor(new Type[] {encoding.GetType()})
- .Invoke(new object[] {encoding});
- else plugin = (Filesystem)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
- RegisterPlugin(plugin);
- }
+ if(!type.IsSubclassOf(typeof(Filesystem))) continue;
+
+ Filesystem plugin;
+ if(encoding != null)
+ plugin = (Filesystem)type.GetConstructor(new Type[] {encoding.GetType()})
+ .Invoke(new object[] {encoding});
+ else plugin = (Filesystem)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
+ RegisterPlugin(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
}
diff --git a/DiscImageChef.Core/Sidecar/BlockMedia.cs b/DiscImageChef.Core/Sidecar/BlockMedia.cs
index f1a26dbc9..5c6c36749 100644
--- a/DiscImageChef.Core/Sidecar/BlockMedia.cs
+++ b/DiscImageChef.Core/Sidecar/BlockMedia.cs
@@ -308,12 +308,11 @@ namespace DiscImageChef.Core
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(image, partitions[i]))
- {
- plugin.GetInformation(image, partitions[i], out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
- }
+ if(!plugin.Identify(image, partitions[i])) continue;
+
+ plugin.GetInformation(image, partitions[i], out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -342,12 +341,11 @@ namespace DiscImageChef.Core
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(image, wholePart))
- {
- plugin.GetInformation(image, wholePart, out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
- }
+ if(!plugin.Identify(image, wholePart)) continue;
+
+ plugin.GetInformation(image, wholePart, out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -676,70 +674,68 @@ namespace DiscImageChef.Core
string dfiFilePath = Path.Combine(Path.GetDirectoryName(imagePath),
Path.GetFileNameWithoutExtension(imagePath) + ".dfi");
- if(File.Exists(dfiFilePath))
- {
- DiscImages.DiscFerret dfiImage = new DiscFerret();
- Filters.ZZZNoFilter dfiFilter = new ZZZNoFilter();
- dfiFilter.Open(dfiFilePath);
+ if(!File.Exists(dfiFilePath)) return;
- if(dfiImage.IdentifyImage(dfiFilter))
+ DiscImages.DiscFerret dfiImage = new DiscFerret();
+ Filters.ZZZNoFilter dfiFilter = new ZZZNoFilter();
+ dfiFilter.Open(dfiFilePath);
+
+ if(!dfiImage.IdentifyImage(dfiFilter)) return;
+
+ try { dfiImage.OpenImage(dfiFilter); }
+ catch(NotImplementedException) { }
+
+ if(image.ImageInfo.Heads == dfiImage.ImageInfo.Heads)
+ if(dfiImage.ImageInfo.Cylinders >= image.ImageInfo.Cylinders)
{
- try { dfiImage.OpenImage(dfiFilter); }
- catch(NotImplementedException) { }
+ List dfiBlockTrackTypes = new List();
+ long currentSector = 0;
+ Stream dfiStream = dfiFilter.GetDataForkStream();
- if(image.ImageInfo.Heads == dfiImage.ImageInfo.Heads)
- if(dfiImage.ImageInfo.Cylinders >= image.ImageInfo.Cylinders)
+ foreach(int t in dfiImage.TrackOffsets.Keys)
+ {
+ BlockTrackType dfiBlockTrackType = new BlockTrackType();
+ dfiBlockTrackType.Cylinder = t / image.ImageInfo.Heads;
+ dfiBlockTrackType.Head = t % image.ImageInfo.Heads;
+ dfiBlockTrackType.Image = new ImageType();
+ dfiBlockTrackType.Image.format = dfiImage.GetImageFormat();
+ dfiBlockTrackType.Image.Value = Path.GetFileName(dfiFilePath);
+
+ if(dfiBlockTrackType.Cylinder < image.ImageInfo.Cylinders)
{
- List dfiBlockTrackTypes = new List();
- long currentSector = 0;
- Stream dfiStream = dfiFilter.GetDataForkStream();
-
- foreach(int t in dfiImage.TrackOffsets.Keys)
- {
- BlockTrackType dfiBlockTrackType = new BlockTrackType();
- dfiBlockTrackType.Cylinder = t / image.ImageInfo.Heads;
- dfiBlockTrackType.Head = t % image.ImageInfo.Heads;
- dfiBlockTrackType.Image = new ImageType();
- dfiBlockTrackType.Image.format = dfiImage.GetImageFormat();
- dfiBlockTrackType.Image.Value = Path.GetFileName(dfiFilePath);
-
- if(dfiBlockTrackType.Cylinder < image.ImageInfo.Cylinders)
- {
- dfiBlockTrackType.StartSector = currentSector;
- currentSector += image.ImageInfo.SectorsPerTrack;
- dfiBlockTrackType.EndSector = currentSector - 1;
- dfiBlockTrackType.Sectors = image.ImageInfo.SectorsPerTrack;
- dfiBlockTrackType.BytesPerSector = (int)image.ImageInfo.SectorSize;
- dfiBlockTrackType.Format = trkFormat;
- }
-
- if(dfiImage.TrackOffsets.TryGetValue(t, out long offset) &&
- dfiImage.TrackLengths.TryGetValue(t, out long length))
- {
- dfiBlockTrackType.Image.offset = offset;
- byte[] trackContents = new byte[length];
- dfiStream.Position = offset;
- dfiStream.Read(trackContents, 0, trackContents.Length);
- dfiBlockTrackType.Size = trackContents.Length;
- dfiBlockTrackType.Checksums = Checksum.GetChecksums(trackContents).ToArray();
- }
-
- dfiBlockTrackTypes.Add(dfiBlockTrackType);
- }
-
- sidecar.BlockMedia[0].Track =
- dfiBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray();
+ dfiBlockTrackType.StartSector = currentSector;
+ currentSector += image.ImageInfo.SectorsPerTrack;
+ dfiBlockTrackType.EndSector = currentSector - 1;
+ dfiBlockTrackType.Sectors = image.ImageInfo.SectorsPerTrack;
+ dfiBlockTrackType.BytesPerSector = (int)image.ImageInfo.SectorSize;
+ dfiBlockTrackType.Format = trkFormat;
}
- else
- DicConsole
- .ErrorWriteLine("DiscFerret image do not contain same number of tracks ({0}) than disk image ({1}), ignoring...",
- dfiImage.ImageInfo.Cylinders, image.ImageInfo.Cylinders);
- else
- DicConsole
- .ErrorWriteLine("DiscFerret image do not contain same number of heads ({0}) than disk image ({1}), ignoring...",
- dfiImage.ImageInfo.Heads, image.ImageInfo.Heads);
+
+ if(dfiImage.TrackOffsets.TryGetValue(t, out long offset) &&
+ dfiImage.TrackLengths.TryGetValue(t, out long length))
+ {
+ dfiBlockTrackType.Image.offset = offset;
+ byte[] trackContents = new byte[length];
+ dfiStream.Position = offset;
+ dfiStream.Read(trackContents, 0, trackContents.Length);
+ dfiBlockTrackType.Size = trackContents.Length;
+ dfiBlockTrackType.Checksums = Checksum.GetChecksums(trackContents).ToArray();
+ }
+
+ dfiBlockTrackTypes.Add(dfiBlockTrackType);
+ }
+
+ sidecar.BlockMedia[0].Track =
+ dfiBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray();
}
- }
+ else
+ DicConsole
+ .ErrorWriteLine("DiscFerret image do not contain same number of tracks ({0}) than disk image ({1}), ignoring...",
+ dfiImage.ImageInfo.Cylinders, image.ImageInfo.Cylinders);
+ else
+ DicConsole
+ .ErrorWriteLine("DiscFerret image do not contain same number of heads ({0}) than disk image ({1}), ignoring...",
+ dfiImage.ImageInfo.Heads, image.ImageInfo.Heads);
#endregion
// TODO: Implement support for getting CHS from SCSI mode pages
diff --git a/DiscImageChef.Core/Sidecar/OpticalDisc.cs b/DiscImageChef.Core/Sidecar/OpticalDisc.cs
index 8940cb2ba..d53340f04 100644
--- a/DiscImageChef.Core/Sidecar/OpticalDisc.cs
+++ b/DiscImageChef.Core/Sidecar/OpticalDisc.cs
@@ -465,22 +465,21 @@ namespace DiscImageChef.Core
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(image, partitions[i]))
- {
- plugin.GetInformation(image, partitions[i], out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
+ if(!plugin.Identify(image, partitions[i])) continue;
- switch(plugin.XmlFSType.Type) {
- case "Opera": dskType = MediaType.ThreeDO;
- break;
- case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
- break;
- case "Nintendo Wii filesystem": dskType = MediaType.WOD;
- break;
- case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
- break;
- }
+ plugin.GetInformation(image, partitions[i], out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
+
+ switch(plugin.XmlFSType.Type) {
+ case "Opera": dskType = MediaType.ThreeDO;
+ break;
+ case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
+ break;
+ case "Nintendo Wii filesystem": dskType = MediaType.WOD;
+ break;
+ case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
+ break;
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
@@ -513,22 +512,21 @@ namespace DiscImageChef.Core
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
- if(plugin.Identify(image, xmlPart))
- {
- plugin.GetInformation(image, xmlPart, out string foo);
- lstFs.Add(plugin.XmlFSType);
- Statistics.AddFilesystem(plugin.XmlFSType.Type);
+ if(!plugin.Identify(image, xmlPart)) continue;
- switch(plugin.XmlFSType.Type) {
- case "Opera": dskType = MediaType.ThreeDO;
- break;
- case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
- break;
- case "Nintendo Wii filesystem": dskType = MediaType.WOD;
- break;
- case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
- break;
- }
+ plugin.GetInformation(image, xmlPart, out string foo);
+ lstFs.Add(plugin.XmlFSType);
+ Statistics.AddFilesystem(plugin.XmlFSType.Type);
+
+ switch(plugin.XmlFSType.Type) {
+ case "Opera": dskType = MediaType.ThreeDO;
+ break;
+ case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
+ break;
+ case "Nintendo Wii filesystem": dskType = MediaType.WOD;
+ break;
+ case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
+ break;
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
diff --git a/DiscImageChef.Core/Statistics.cs b/DiscImageChef.Core/Statistics.cs
index 405d26872..992b256fe 100644
--- a/DiscImageChef.Core/Statistics.cs
+++ b/DiscImageChef.Core/Statistics.cs
@@ -98,72 +98,71 @@ namespace DiscImageChef.Core
public static void SaveStats()
{
- if(AllStats != null)
+ if(AllStats == null) return;
+
+ if(AllStats.OperatingSystems != null)
{
- if(AllStats.OperatingSystems != null)
- {
- long count = 0;
+ long count = 0;
- OsStats old = null;
- foreach(OsStats nvs in AllStats.OperatingSystems)
- if(nvs.name == Interop.DetectOS.GetRealPlatformID().ToString() &&
- nvs.version == Interop.DetectOS.GetVersion())
- {
- count = nvs.Value + 1;
- old = nvs;
- break;
- }
-
- if(old != null) AllStats.OperatingSystems.Remove(old);
-
- count++;
- AllStats.OperatingSystems.Add(new OsStats
+ OsStats old = null;
+ foreach(OsStats nvs in AllStats.OperatingSystems)
+ if(nvs.name == Interop.DetectOS.GetRealPlatformID().ToString() &&
+ nvs.version == Interop.DetectOS.GetVersion())
{
- name = Interop.DetectOS.GetRealPlatformID().ToString(),
- Value = count,
- version = Interop.DetectOS.GetVersion()
- });
- }
- else if(CurrentStats != null) AllStats.OperatingSystems = CurrentStats.OperatingSystems;
+ count = nvs.Value + 1;
+ old = nvs;
+ break;
+ }
- if(AllStats.Versions != null)
+ if(old != null) AllStats.OperatingSystems.Remove(old);
+
+ count++;
+ AllStats.OperatingSystems.Add(new OsStats
{
- long count = 0;
-
- NameValueStats old = null;
- foreach(NameValueStats nvs in AllStats.Versions)
- if(nvs.name == Version.GetVersion())
- {
- count = nvs.Value + 1;
- old = nvs;
- break;
- }
-
- if(old != null) AllStats.Versions.Remove(old);
-
- count++;
- AllStats.Versions.Add(new NameValueStats {name = Version.GetVersion(), Value = count});
- }
- else if(CurrentStats != null) AllStats.Versions = CurrentStats.Versions;
-
- FileStream fs = new FileStream(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"),
- FileMode.Create);
- XmlSerializer xs = new XmlSerializer(AllStats.GetType());
- xs.Serialize(fs, AllStats);
- fs.Close();
-
- if(CurrentStats != null)
- {
- string partial = string.Format("PartialStats_{0:yyyyMMddHHmmssfff}.xml", DateTime.UtcNow);
-
- fs = new FileStream(Path.Combine(Settings.Settings.StatsPath, partial), FileMode.Create);
- xs = new XmlSerializer(CurrentStats.GetType());
- xs.Serialize(fs, CurrentStats);
- fs.Close();
- }
-
- if(Settings.Settings.Current.Stats.ShareStats) SubmitStats();
+ name = Interop.DetectOS.GetRealPlatformID().ToString(),
+ Value = count,
+ version = Interop.DetectOS.GetVersion()
+ });
}
+ else if(CurrentStats != null) AllStats.OperatingSystems = CurrentStats.OperatingSystems;
+
+ if(AllStats.Versions != null)
+ {
+ long count = 0;
+
+ NameValueStats old = null;
+ foreach(NameValueStats nvs in AllStats.Versions)
+ if(nvs.name == Version.GetVersion())
+ {
+ count = nvs.Value + 1;
+ old = nvs;
+ break;
+ }
+
+ if(old != null) AllStats.Versions.Remove(old);
+
+ count++;
+ AllStats.Versions.Add(new NameValueStats {name = Version.GetVersion(), Value = count});
+ }
+ else if(CurrentStats != null) AllStats.Versions = CurrentStats.Versions;
+
+ FileStream fs = new FileStream(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"),
+ FileMode.Create);
+ XmlSerializer xs = new XmlSerializer(AllStats.GetType());
+ xs.Serialize(fs, AllStats);
+ fs.Close();
+
+ if(CurrentStats != null)
+ {
+ string partial = string.Format("PartialStats_{0:yyyyMMddHHmmssfff}.xml", DateTime.UtcNow);
+
+ fs = new FileStream(Path.Combine(Settings.Settings.StatsPath, partial), FileMode.Create);
+ xs = new XmlSerializer(CurrentStats.GetType());
+ xs.Serialize(fs, CurrentStats);
+ fs.Close();
+ }
+
+ if(Settings.Settings.Current.Stats.ShareStats) SubmitStats();
}
public static void SubmitStats()
@@ -240,529 +239,519 @@ namespace DiscImageChef.Core
public static void AddCommand(string command)
{
- if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.DeviceStats)
+ if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.DeviceStats) return;
+
+ if(AllStats.Commands == null) AllStats.Commands = new CommandsStats();
+
+ if(CurrentStats.Commands == null) CurrentStats.Commands = new CommandsStats();
+
+ switch(command)
{
- if(AllStats.Commands == null) AllStats.Commands = new CommandsStats();
-
- if(CurrentStats.Commands == null) CurrentStats.Commands = new CommandsStats();
-
- switch(command)
- {
- case "analyze":
- AllStats.Commands.Analyze++;
- CurrentStats.Commands.Analyze++;
- break;
- case "benchmark":
- AllStats.Commands.Benchmark++;
- CurrentStats.Commands.Benchmark++;
- break;
- case "checksum":
- AllStats.Commands.Checksum++;
- CurrentStats.Commands.Checksum++;
- break;
- case "compare":
- AllStats.Commands.Compare++;
- CurrentStats.Commands.Compare++;
- break;
- case "create-sidecar":
- AllStats.Commands.CreateSidecar++;
- CurrentStats.Commands.CreateSidecar++;
- break;
- case "decode":
- AllStats.Commands.Decode++;
- CurrentStats.Commands.Decode++;
- break;
- case "device-info":
- AllStats.Commands.DeviceInfo++;
- CurrentStats.Commands.DeviceInfo++;
- break;
- case "device-report":
- AllStats.Commands.DeviceReport++;
- CurrentStats.Commands.DeviceReport++;
- break;
- case "dump-media":
- AllStats.Commands.DumpMedia++;
- CurrentStats.Commands.DumpMedia++;
- break;
- case "entropy":
- AllStats.Commands.Entropy++;
- CurrentStats.Commands.Entropy++;
- break;
- case "extract-files":
- AllStats.Commands.ExtractFiles++;
- CurrentStats.Commands.ExtractFiles++;
- break;
- case "formats":
- AllStats.Commands.Formats++;
- CurrentStats.Commands.Formats++;
- break;
- case "ls":
- AllStats.Commands.Ls++;
- CurrentStats.Commands.Ls++;
- break;
- case "media-info":
- AllStats.Commands.MediaInfo++;
- CurrentStats.Commands.MediaInfo++;
- break;
- case "media-scan":
- AllStats.Commands.MediaScan++;
- CurrentStats.Commands.MediaScan++;
- break;
- case "print-hex":
- AllStats.Commands.PrintHex++;
- CurrentStats.Commands.PrintHex++;
- break;
- case "verify":
- AllStats.Commands.Verify++;
- CurrentStats.Commands.Verify++;
- break;
- case "list-devices":
- AllStats.Commands.ListDevices++;
- CurrentStats.Commands.ListDevices++;
- break;
- case "list-encodings":
- AllStats.Commands.ListEncodings++;
- CurrentStats.Commands.ListEncodings++;
- break;
- }
+ case "analyze":
+ AllStats.Commands.Analyze++;
+ CurrentStats.Commands.Analyze++;
+ break;
+ case "benchmark":
+ AllStats.Commands.Benchmark++;
+ CurrentStats.Commands.Benchmark++;
+ break;
+ case "checksum":
+ AllStats.Commands.Checksum++;
+ CurrentStats.Commands.Checksum++;
+ break;
+ case "compare":
+ AllStats.Commands.Compare++;
+ CurrentStats.Commands.Compare++;
+ break;
+ case "create-sidecar":
+ AllStats.Commands.CreateSidecar++;
+ CurrentStats.Commands.CreateSidecar++;
+ break;
+ case "decode":
+ AllStats.Commands.Decode++;
+ CurrentStats.Commands.Decode++;
+ break;
+ case "device-info":
+ AllStats.Commands.DeviceInfo++;
+ CurrentStats.Commands.DeviceInfo++;
+ break;
+ case "device-report":
+ AllStats.Commands.DeviceReport++;
+ CurrentStats.Commands.DeviceReport++;
+ break;
+ case "dump-media":
+ AllStats.Commands.DumpMedia++;
+ CurrentStats.Commands.DumpMedia++;
+ break;
+ case "entropy":
+ AllStats.Commands.Entropy++;
+ CurrentStats.Commands.Entropy++;
+ break;
+ case "extract-files":
+ AllStats.Commands.ExtractFiles++;
+ CurrentStats.Commands.ExtractFiles++;
+ break;
+ case "formats":
+ AllStats.Commands.Formats++;
+ CurrentStats.Commands.Formats++;
+ break;
+ case "ls":
+ AllStats.Commands.Ls++;
+ CurrentStats.Commands.Ls++;
+ break;
+ case "media-info":
+ AllStats.Commands.MediaInfo++;
+ CurrentStats.Commands.MediaInfo++;
+ break;
+ case "media-scan":
+ AllStats.Commands.MediaScan++;
+ CurrentStats.Commands.MediaScan++;
+ break;
+ case "print-hex":
+ AllStats.Commands.PrintHex++;
+ CurrentStats.Commands.PrintHex++;
+ break;
+ case "verify":
+ AllStats.Commands.Verify++;
+ CurrentStats.Commands.Verify++;
+ break;
+ case "list-devices":
+ AllStats.Commands.ListDevices++;
+ CurrentStats.Commands.ListDevices++;
+ break;
+ case "list-encodings":
+ AllStats.Commands.ListEncodings++;
+ CurrentStats.Commands.ListEncodings++;
+ break;
}
}
public static void AddFilesystem(string filesystem)
{
- if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.FilesystemStats)
+ if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.FilesystemStats) return;
+
+ if(AllStats.Filesystems == null) AllStats.Filesystems = new List();
+ if(CurrentStats.Filesystems == null) CurrentStats.Filesystems = new List();
+
+ NameValueStats old = null;
+ foreach(NameValueStats nvs in AllStats.Filesystems)
+ if(nvs.name == filesystem)
+ {
+ old = nvs;
+ break;
+ }
+
+ NameValueStats nw = new NameValueStats();
+ if(old != null)
{
- if(AllStats.Filesystems == null) AllStats.Filesystems = new List();
- if(CurrentStats.Filesystems == null) CurrentStats.Filesystems = new List();
-
- NameValueStats old = null;
- foreach(NameValueStats nvs in AllStats.Filesystems)
- if(nvs.name == filesystem)
- {
- old = nvs;
- break;
- }
-
- NameValueStats nw = new NameValueStats();
- if(old != null)
- {
- nw.name = old.name;
- nw.Value = old.Value + 1;
- AllStats.Filesystems.Remove(old);
- }
- else
- {
- nw.name = filesystem;
- nw.Value = 1;
- }
- AllStats.Filesystems.Add(nw);
-
- old = null;
- foreach(NameValueStats nvs in CurrentStats.Filesystems)
- if(nvs.name == filesystem)
- {
- old = nvs;
- break;
- }
-
- nw = new NameValueStats();
- if(old != null)
- {
- nw.name = old.name;
- nw.Value = old.Value + 1;
- CurrentStats.Filesystems.Remove(old);
- }
- else
- {
- nw.name = filesystem;
- nw.Value = 1;
- }
- CurrentStats.Filesystems.Add(nw);
+ nw.name = old.name;
+ nw.Value = old.Value + 1;
+ AllStats.Filesystems.Remove(old);
}
+ else
+ {
+ nw.name = filesystem;
+ nw.Value = 1;
+ }
+ AllStats.Filesystems.Add(nw);
+
+ old = null;
+ foreach(NameValueStats nvs in CurrentStats.Filesystems)
+ if(nvs.name == filesystem)
+ {
+ old = nvs;
+ break;
+ }
+
+ nw = new NameValueStats();
+ if(old != null)
+ {
+ nw.name = old.name;
+ nw.Value = old.Value + 1;
+ CurrentStats.Filesystems.Remove(old);
+ }
+ else
+ {
+ nw.name = filesystem;
+ nw.Value = 1;
+ }
+ CurrentStats.Filesystems.Add(nw);
}
public static void AddPartition(string partition)
{
- if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.PartitionStats)
+ if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.PartitionStats) return;
+
+ if(AllStats.Partitions == null) AllStats.Partitions = new List();
+ if(CurrentStats.Partitions == null) CurrentStats.Partitions = new List();
+
+ NameValueStats old = null;
+ foreach(NameValueStats nvs in AllStats.Partitions)
+ if(nvs.name == partition)
+ {
+ old = nvs;
+ break;
+ }
+
+ NameValueStats nw = new NameValueStats();
+ if(old != null)
{
- if(AllStats.Partitions == null) AllStats.Partitions = new List();
- if(CurrentStats.Partitions == null) CurrentStats.Partitions = new List();
-
- NameValueStats old = null;
- foreach(NameValueStats nvs in AllStats.Partitions)
- if(nvs.name == partition)
- {
- old = nvs;
- break;
- }
-
- NameValueStats nw = new NameValueStats();
- if(old != null)
- {
- nw.name = old.name;
- nw.Value = old.Value + 1;
- AllStats.Partitions.Remove(old);
- }
- else
- {
- nw.name = partition;
- nw.Value = 1;
- }
- AllStats.Partitions.Add(nw);
-
- old = null;
- foreach(NameValueStats nvs in CurrentStats.Partitions)
- if(nvs.name == partition)
- {
- old = nvs;
- break;
- }
-
- nw = new NameValueStats();
- if(old != null)
- {
- nw.name = old.name;
- nw.Value = old.Value + 1;
- CurrentStats.Partitions.Remove(old);
- }
- else
- {
- nw.name = partition;
- nw.Value = 1;
- }
- CurrentStats.Partitions.Add(nw);
+ nw.name = old.name;
+ nw.Value = old.Value + 1;
+ AllStats.Partitions.Remove(old);
}
+ else
+ {
+ nw.name = partition;
+ nw.Value = 1;
+ }
+ AllStats.Partitions.Add(nw);
+
+ old = null;
+ foreach(NameValueStats nvs in CurrentStats.Partitions)
+ if(nvs.name == partition)
+ {
+ old = nvs;
+ break;
+ }
+
+ nw = new NameValueStats();
+ if(old != null)
+ {
+ nw.name = old.name;
+ nw.Value = old.Value + 1;
+ CurrentStats.Partitions.Remove(old);
+ }
+ else
+ {
+ nw.name = partition;
+ nw.Value = 1;
+ }
+ CurrentStats.Partitions.Add(nw);
}
public static void AddFilter(string format)
{
- if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.FilterStats)
+ if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.FilterStats) return;
+
+ if(AllStats.Filters == null) AllStats.Filters = new List();
+ if(CurrentStats.Filters == null) CurrentStats.Filters = new List();
+
+ NameValueStats old = null;
+ foreach(NameValueStats nvs in AllStats.Filters)
+ if(nvs.name == format)
+ {
+ old = nvs;
+ break;
+ }
+
+ NameValueStats nw = new NameValueStats();
+ if(old != null)
{
- if(AllStats.Filters == null) AllStats.Filters = new List();
- if(CurrentStats.Filters == null) CurrentStats.Filters = new List();
-
- NameValueStats old = null;
- foreach(NameValueStats nvs in AllStats.Filters)
- if(nvs.name == format)
- {
- old = nvs;
- break;
- }
-
- NameValueStats nw = new NameValueStats();
- if(old != null)
- {
- nw.name = old.name;
- nw.Value = old.Value + 1;
- AllStats.Filters.Remove(old);
- }
- else
- {
- nw.name = format;
- nw.Value = 1;
- }
- AllStats.Filters.Add(nw);
-
- old = null;
- foreach(NameValueStats nvs in CurrentStats.Filters)
- if(nvs.name == format)
- {
- old = nvs;
- break;
- }
-
- nw = new NameValueStats();
- if(old != null)
- {
- nw.name = old.name;
- nw.Value = old.Value + 1;
- CurrentStats.Filters.Remove(old);
- }
- else
- {
- nw.name = format;
- nw.Value = 1;
- }
- CurrentStats.Filters.Add(nw);
+ nw.name = old.name;
+ nw.Value = old.Value + 1;
+ AllStats.Filters.Remove(old);
}
+ else
+ {
+ nw.name = format;
+ nw.Value = 1;
+ }
+ AllStats.Filters.Add(nw);
+
+ old = null;
+ foreach(NameValueStats nvs in CurrentStats.Filters)
+ if(nvs.name == format)
+ {
+ old = nvs;
+ break;
+ }
+
+ nw = new NameValueStats();
+ if(old != null)
+ {
+ nw.name = old.name;
+ nw.Value = old.Value + 1;
+ CurrentStats.Filters.Remove(old);
+ }
+ else
+ {
+ nw.name = format;
+ nw.Value = 1;
+ }
+ CurrentStats.Filters.Add(nw);
}
public static void AddMediaFormat(string format)
{
- if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.MediaImageStats)
+ if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.MediaImageStats) return;
+
+ if(AllStats.MediaImages == null) AllStats.MediaImages = new List();
+ if(CurrentStats.MediaImages == null) CurrentStats.MediaImages = new List();
+
+ NameValueStats old = null;
+ foreach(NameValueStats nvs in AllStats.MediaImages)
+ if(nvs.name == format)
+ {
+ old = nvs;
+ break;
+ }
+
+ NameValueStats nw = new NameValueStats();
+ if(old != null)
{
- if(AllStats.MediaImages == null) AllStats.MediaImages = new List();
- if(CurrentStats.MediaImages == null) CurrentStats.MediaImages = new List();
-
- NameValueStats old = null;
- foreach(NameValueStats nvs in AllStats.MediaImages)
- if(nvs.name == format)
- {
- old = nvs;
- break;
- }
-
- NameValueStats nw = new NameValueStats();
- if(old != null)
- {
- nw.name = old.name;
- nw.Value = old.Value + 1;
- AllStats.MediaImages.Remove(old);
- }
- else
- {
- nw.name = format;
- nw.Value = 1;
- }
- AllStats.MediaImages.Add(nw);
-
- old = null;
- foreach(NameValueStats nvs in CurrentStats.MediaImages)
- if(nvs.name == format)
- {
- old = nvs;
- break;
- }
-
- nw = new NameValueStats();
- if(old != null)
- {
- nw.name = old.name;
- nw.Value = old.Value + 1;
- CurrentStats.MediaImages.Remove(old);
- }
- else
- {
- nw.name = format;
- nw.Value = 1;
- }
- CurrentStats.MediaImages.Add(nw);
+ nw.name = old.name;
+ nw.Value = old.Value + 1;
+ AllStats.MediaImages.Remove(old);
}
+ else
+ {
+ nw.name = format;
+ nw.Value = 1;
+ }
+ AllStats.MediaImages.Add(nw);
+
+ old = null;
+ foreach(NameValueStats nvs in CurrentStats.MediaImages)
+ if(nvs.name == format)
+ {
+ old = nvs;
+ break;
+ }
+
+ nw = new NameValueStats();
+ if(old != null)
+ {
+ nw.name = old.name;
+ nw.Value = old.Value + 1;
+ CurrentStats.MediaImages.Remove(old);
+ }
+ else
+ {
+ nw.name = format;
+ nw.Value = 1;
+ }
+ CurrentStats.MediaImages.Add(nw);
}
public static void AddDevice(DiscImageChef.Devices.Device dev)
{
- if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.DeviceStats)
- {
- if(AllStats.Devices == null) AllStats.Devices = new List();
- if(CurrentStats.Devices == null) CurrentStats.Devices = new List();
+ if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.DeviceStats) return;
- string deviceBus;
- if(dev.IsUsb) deviceBus = "USB";
- else if(dev.IsFireWire) deviceBus = "FireWire";
- else deviceBus = dev.Type.ToString();
+ if(AllStats.Devices == null) AllStats.Devices = new List();
+ if(CurrentStats.Devices == null) CurrentStats.Devices = new List();
- DeviceStats old = null;
- foreach(DeviceStats ds in AllStats.Devices)
- if(ds.Manufacturer == dev.Manufacturer && ds.Model == dev.Model && ds.Revision == dev.Revision &&
- ds.Bus == deviceBus)
- {
- old = ds;
- break;
- }
+ string deviceBus;
+ if(dev.IsUsb) deviceBus = "USB";
+ else if(dev.IsFireWire) deviceBus = "FireWire";
+ else deviceBus = dev.Type.ToString();
- if(old != null) AllStats.Devices.Remove(old);
+ DeviceStats old = null;
+ foreach(DeviceStats ds in AllStats.Devices)
+ if(ds.Manufacturer == dev.Manufacturer && ds.Model == dev.Model && ds.Revision == dev.Revision &&
+ ds.Bus == deviceBus)
+ {
+ old = ds;
+ break;
+ }
- DeviceStats nw = new DeviceStats();
- nw.Model = dev.Model;
- nw.Manufacturer = dev.Manufacturer;
- nw.Revision = dev.Revision;
- nw.Bus = deviceBus;
- nw.ManufacturerSpecified = true;
- AllStats.Devices.Add(nw);
+ if(old != null) AllStats.Devices.Remove(old);
- old = null;
- foreach(DeviceStats ds in CurrentStats.Devices)
- if(ds.Manufacturer == dev.Manufacturer && ds.Model == dev.Model && ds.Revision == dev.Revision &&
- ds.Bus == deviceBus)
- {
- old = ds;
- break;
- }
+ DeviceStats nw = new DeviceStats();
+ nw.Model = dev.Model;
+ nw.Manufacturer = dev.Manufacturer;
+ nw.Revision = dev.Revision;
+ nw.Bus = deviceBus;
+ nw.ManufacturerSpecified = true;
+ AllStats.Devices.Add(nw);
- if(old != null) CurrentStats.Devices.Remove(old);
+ old = null;
+ foreach(DeviceStats ds in CurrentStats.Devices)
+ if(ds.Manufacturer == dev.Manufacturer && ds.Model == dev.Model && ds.Revision == dev.Revision &&
+ ds.Bus == deviceBus)
+ {
+ old = ds;
+ break;
+ }
- nw = new DeviceStats();
- nw.Model = dev.Model;
- nw.Manufacturer = dev.Manufacturer;
- nw.Revision = dev.Revision;
- nw.Bus = deviceBus;
- nw.ManufacturerSpecified = true;
- CurrentStats.Devices.Add(nw);
- }
+ if(old != null) CurrentStats.Devices.Remove(old);
+
+ nw = new DeviceStats();
+ nw.Model = dev.Model;
+ nw.Manufacturer = dev.Manufacturer;
+ nw.Revision = dev.Revision;
+ nw.Bus = deviceBus;
+ nw.ManufacturerSpecified = true;
+ CurrentStats.Devices.Add(nw);
}
public static void AddMedia(CommonTypes.MediaType type, bool real)
{
- if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.MediaStats)
+ if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.MediaStats) return;
+
+ if(AllStats.Medias == null) AllStats.Medias = new List();
+ if(CurrentStats.Medias == null) CurrentStats.Medias = new List();
+
+ MediaStats old = null;
+ foreach(MediaStats ms in AllStats.Medias)
+ if(ms.real == real && ms.type == type.ToString())
+ {
+ old = ms;
+ break;
+ }
+
+ MediaStats nw = new MediaStats();
+ if(old != null)
{
- if(AllStats.Medias == null) AllStats.Medias = new List();
- if(CurrentStats.Medias == null) CurrentStats.Medias = new List();
-
- MediaStats old = null;
- foreach(MediaStats ms in AllStats.Medias)
- if(ms.real == real && ms.type == type.ToString())
- {
- old = ms;
- break;
- }
-
- MediaStats nw = new MediaStats();
- if(old != null)
- {
- nw.type = old.type;
- nw.real = old.real;
- nw.Value = old.Value + 1;
- AllStats.Medias.Remove(old);
- }
- else
- {
- nw.type = type.ToString();
- nw.real = real;
- nw.Value = 1;
- }
- AllStats.Medias.Add(nw);
-
- old = null;
- foreach(MediaStats ms in CurrentStats.Medias)
- if(ms.real == real && ms.type == type.ToString())
- {
- old = ms;
- break;
- }
-
- nw = new MediaStats();
- if(old != null)
- {
- nw.type = old.type;
- nw.real = old.real;
- nw.Value = old.Value + 1;
- CurrentStats.Medias.Remove(old);
- }
- else
- {
- nw.type = type.ToString();
- nw.real = real;
- nw.Value = 1;
- }
- CurrentStats.Medias.Add(nw);
+ nw.type = old.type;
+ nw.real = old.real;
+ nw.Value = old.Value + 1;
+ AllStats.Medias.Remove(old);
}
+ else
+ {
+ nw.type = type.ToString();
+ nw.real = real;
+ nw.Value = 1;
+ }
+ AllStats.Medias.Add(nw);
+
+ old = null;
+ foreach(MediaStats ms in CurrentStats.Medias)
+ if(ms.real == real && ms.type == type.ToString())
+ {
+ old = ms;
+ break;
+ }
+
+ nw = new MediaStats();
+ if(old != null)
+ {
+ nw.type = old.type;
+ nw.real = old.real;
+ nw.Value = old.Value + 1;
+ CurrentStats.Medias.Remove(old);
+ }
+ else
+ {
+ nw.type = type.ToString();
+ nw.real = real;
+ nw.Value = 1;
+ }
+ CurrentStats.Medias.Add(nw);
}
public static void AddBenchmark(Dictionary checksums, double entropy, double all,
double sequential, long maxMemory, long minMemory)
{
- if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.BenchmarkStats)
+ if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.BenchmarkStats) return;
+
+ CurrentStats.Benchmark = new BenchmarkStats();
+ CurrentStats.Benchmark.Checksum = new List();
+ AllStats.Benchmark = new BenchmarkStats();
+ AllStats.Benchmark.Checksum = new List();
+
+ foreach(KeyValuePair kvp in checksums)
{
- CurrentStats.Benchmark = new BenchmarkStats();
- CurrentStats.Benchmark.Checksum = new List();
- AllStats.Benchmark = new BenchmarkStats();
- AllStats.Benchmark.Checksum = new List();
-
- foreach(KeyValuePair kvp in checksums)
- {
- ChecksumStats st = new ChecksumStats();
- st.algorithm = kvp.Key;
- st.Value = kvp.Value;
- CurrentStats.Benchmark.Checksum.Add(st);
- AllStats.Benchmark.Checksum.Add(st);
- }
-
- CurrentStats.Benchmark.All = all;
- CurrentStats.Benchmark.Entropy = entropy;
- CurrentStats.Benchmark.MaxMemory = maxMemory;
- CurrentStats.Benchmark.MinMemory = minMemory;
- CurrentStats.Benchmark.Sequential = sequential;
-
- AllStats.Benchmark.All = all;
- AllStats.Benchmark.Entropy = entropy;
- AllStats.Benchmark.MaxMemory = maxMemory;
- AllStats.Benchmark.MinMemory = minMemory;
- AllStats.Benchmark.Sequential = sequential;
+ ChecksumStats st = new ChecksumStats();
+ st.algorithm = kvp.Key;
+ st.Value = kvp.Value;
+ CurrentStats.Benchmark.Checksum.Add(st);
+ AllStats.Benchmark.Checksum.Add(st);
}
+
+ CurrentStats.Benchmark.All = all;
+ CurrentStats.Benchmark.Entropy = entropy;
+ CurrentStats.Benchmark.MaxMemory = maxMemory;
+ CurrentStats.Benchmark.MinMemory = minMemory;
+ CurrentStats.Benchmark.Sequential = sequential;
+
+ AllStats.Benchmark.All = all;
+ AllStats.Benchmark.Entropy = entropy;
+ AllStats.Benchmark.MaxMemory = maxMemory;
+ AllStats.Benchmark.MinMemory = minMemory;
+ AllStats.Benchmark.Sequential = sequential;
}
public static void AddVerify(bool? mediaVerified, long correct, long failed, long unknown, long total)
{
- if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.VerifyStats)
+ if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.VerifyStats) return;
+
+ if(CurrentStats.Verify == null)
{
- if(CurrentStats.Verify == null)
- {
- CurrentStats.Verify = new VerifyStats();
- CurrentStats.Verify.MediaImages = new VerifiedItems();
- CurrentStats.Verify.Sectors = new ScannedSectors();
- }
-
- if(AllStats.Verify == null)
- {
- AllStats.Verify = new VerifyStats();
- AllStats.Verify.MediaImages = new VerifiedItems();
- AllStats.Verify.Sectors = new ScannedSectors();
- }
-
- if(mediaVerified.HasValue)
- if(mediaVerified.Value)
- {
- CurrentStats.Verify.MediaImages.Correct++;
- AllStats.Verify.MediaImages.Correct++;
- }
- else
- {
- CurrentStats.Verify.MediaImages.Failed++;
- AllStats.Verify.MediaImages.Failed++;
- }
-
- CurrentStats.Verify.Sectors.Correct += correct;
- CurrentStats.Verify.Sectors.Error += failed;
- CurrentStats.Verify.Sectors.Unverifiable += unknown;
- CurrentStats.Verify.Sectors.Total += total;
-
- AllStats.Verify.Sectors.Correct += correct;
- AllStats.Verify.Sectors.Error += failed;
- AllStats.Verify.Sectors.Unverifiable += unknown;
- AllStats.Verify.Sectors.Total += total;
+ CurrentStats.Verify = new VerifyStats();
+ CurrentStats.Verify.MediaImages = new VerifiedItems();
+ CurrentStats.Verify.Sectors = new ScannedSectors();
}
+
+ if(AllStats.Verify == null)
+ {
+ AllStats.Verify = new VerifyStats();
+ AllStats.Verify.MediaImages = new VerifiedItems();
+ AllStats.Verify.Sectors = new ScannedSectors();
+ }
+
+ if(mediaVerified.HasValue)
+ if(mediaVerified.Value)
+ {
+ CurrentStats.Verify.MediaImages.Correct++;
+ AllStats.Verify.MediaImages.Correct++;
+ }
+ else
+ {
+ CurrentStats.Verify.MediaImages.Failed++;
+ AllStats.Verify.MediaImages.Failed++;
+ }
+
+ CurrentStats.Verify.Sectors.Correct += correct;
+ CurrentStats.Verify.Sectors.Error += failed;
+ CurrentStats.Verify.Sectors.Unverifiable += unknown;
+ CurrentStats.Verify.Sectors.Total += total;
+
+ AllStats.Verify.Sectors.Correct += correct;
+ AllStats.Verify.Sectors.Error += failed;
+ AllStats.Verify.Sectors.Unverifiable += unknown;
+ AllStats.Verify.Sectors.Total += total;
}
public static void AddMediaScan(long lessThan3ms, long lessThan10ms, long lessThan50ms, long lessThan150ms,
long lessThan500ms, long moreThan500ms, long total, long error, long correct)
{
- if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.MediaScanStats)
+ if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.MediaScanStats) return;
+
+ if(CurrentStats.MediaScan == null)
{
- if(CurrentStats.MediaScan == null)
- {
- CurrentStats.MediaScan = new MediaScanStats();
- CurrentStats.MediaScan.Sectors = new ScannedSectors();
- CurrentStats.MediaScan.Times = new TimeStats();
- }
-
- if(AllStats.MediaScan == null)
- {
- AllStats.MediaScan = new MediaScanStats();
- AllStats.MediaScan.Sectors = new ScannedSectors();
- AllStats.MediaScan.Times = new TimeStats();
- }
-
- CurrentStats.MediaScan.Sectors.Correct += correct;
- CurrentStats.MediaScan.Sectors.Error += error;
- CurrentStats.MediaScan.Sectors.Total += total;
- CurrentStats.MediaScan.Times.LessThan3ms += lessThan3ms;
- CurrentStats.MediaScan.Times.LessThan10ms += lessThan10ms;
- CurrentStats.MediaScan.Times.LessThan50ms += lessThan50ms;
- CurrentStats.MediaScan.Times.LessThan150ms += lessThan150ms;
- CurrentStats.MediaScan.Times.LessThan500ms += lessThan500ms;
- CurrentStats.MediaScan.Times.MoreThan500ms += moreThan500ms;
-
- AllStats.MediaScan.Sectors.Correct += correct;
- AllStats.MediaScan.Sectors.Error += error;
- AllStats.MediaScan.Sectors.Total += total;
- AllStats.MediaScan.Times.LessThan3ms += lessThan3ms;
- AllStats.MediaScan.Times.LessThan10ms += lessThan10ms;
- AllStats.MediaScan.Times.LessThan50ms += lessThan50ms;
- AllStats.MediaScan.Times.LessThan150ms += lessThan150ms;
- AllStats.MediaScan.Times.LessThan500ms += lessThan500ms;
- AllStats.MediaScan.Times.MoreThan500ms += moreThan500ms;
+ CurrentStats.MediaScan = new MediaScanStats();
+ CurrentStats.MediaScan.Sectors = new ScannedSectors();
+ CurrentStats.MediaScan.Times = new TimeStats();
}
+
+ if(AllStats.MediaScan == null)
+ {
+ AllStats.MediaScan = new MediaScanStats();
+ AllStats.MediaScan.Sectors = new ScannedSectors();
+ AllStats.MediaScan.Times = new TimeStats();
+ }
+
+ CurrentStats.MediaScan.Sectors.Correct += correct;
+ CurrentStats.MediaScan.Sectors.Error += error;
+ CurrentStats.MediaScan.Sectors.Total += total;
+ CurrentStats.MediaScan.Times.LessThan3ms += lessThan3ms;
+ CurrentStats.MediaScan.Times.LessThan10ms += lessThan10ms;
+ CurrentStats.MediaScan.Times.LessThan50ms += lessThan50ms;
+ CurrentStats.MediaScan.Times.LessThan150ms += lessThan150ms;
+ CurrentStats.MediaScan.Times.LessThan500ms += lessThan500ms;
+ CurrentStats.MediaScan.Times.MoreThan500ms += moreThan500ms;
+
+ AllStats.MediaScan.Sectors.Correct += correct;
+ AllStats.MediaScan.Sectors.Error += error;
+ AllStats.MediaScan.Sectors.Total += total;
+ AllStats.MediaScan.Times.LessThan3ms += lessThan3ms;
+ AllStats.MediaScan.Times.LessThan10ms += lessThan10ms;
+ AllStats.MediaScan.Times.LessThan50ms += lessThan50ms;
+ AllStats.MediaScan.Times.LessThan150ms += lessThan150ms;
+ AllStats.MediaScan.Times.LessThan500ms += lessThan500ms;
+ AllStats.MediaScan.Times.MoreThan500ms += moreThan500ms;
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Decoders/Blu-ray/DI.cs b/DiscImageChef.Decoders/Blu-ray/DI.cs
index e7546df0d..24d5938c9 100644
--- a/DiscImageChef.Decoders/Blu-ray/DI.cs
+++ b/DiscImageChef.Decoders/Blu-ray/DI.cs
@@ -142,11 +142,10 @@ namespace DiscImageChef.Decoders.Bluray
offset += unit.Length;
}
- if(units.Count > 0)
- {
- decoded.Units = new DiscInformationUnits[units.Count];
- for(int i = 0; i < units.Count; i++) decoded.Units[i] = units[i];
- }
+ if(units.Count <= 0) return decoded;
+
+ decoded.Units = new DiscInformationUnits[units.Count];
+ for(int i = 0; i < units.Count; i++) decoded.Units[i] = units[i];
return decoded;
}
diff --git a/DiscImageChef.Decoders/CD/ATIP.cs b/DiscImageChef.Decoders/CD/ATIP.cs
index 816856b05..2867657ea 100644
--- a/DiscImageChef.Decoders/CD/ATIP.cs
+++ b/DiscImageChef.Decoders/CD/ATIP.cs
@@ -272,12 +272,11 @@ namespace DiscImageChef.Decoders.CD
decoded.Reserved8 = CDATIPResponse[23];
decoded.Reserved9 = CDATIPResponse[27];
- if(CDATIPResponse.Length >= 32)
- {
- decoded.S4Values = new byte[3];
- Array.Copy(CDATIPResponse, 28, decoded.S4Values, 0, 3);
- decoded.Reserved10 = CDATIPResponse[31];
- }
+ if(CDATIPResponse.Length < 32) return decoded;
+
+ decoded.S4Values = new byte[3];
+ Array.Copy(CDATIPResponse, 28, decoded.S4Values, 0, 3);
+ decoded.Reserved10 = CDATIPResponse[31];
return decoded;
}
@@ -425,24 +424,23 @@ namespace DiscImageChef.Decoders.CD
.AppendLine();
}
- if(response.LeadInStartMin == 97)
+ if(response.LeadInStartMin != 97) return sb.ToString();
+
+ int type = response.LeadInStartFrame % 10;
+ int frm = response.LeadInStartFrame - type;
+ string manufacturer = "";
+
+ if(response.DiscType) sb.AppendLine("Disc uses phase change");
+ else
{
- int type = response.LeadInStartFrame % 10;
- int frm = response.LeadInStartFrame - type;
- string manufacturer = "";
-
- if(response.DiscType) sb.AppendLine("Disc uses phase change");
- else
- {
- if(type < 5) sb.AppendLine("Disc uses long strategy type dye (Cyanine, AZO, etc...)");
- else sb.AppendLine("Disc uses short strategy type dye (Phthalocyanine, etc...)");
- }
-
- manufacturer = ManufacturerFromATIP(response.LeadInStartSec, frm);
-
- if(manufacturer != "") sb.AppendFormat("Disc manufactured by: {0}", manufacturer).AppendLine();
+ if(type < 5) sb.AppendLine("Disc uses long strategy type dye (Cyanine, AZO, etc...)");
+ else sb.AppendLine("Disc uses short strategy type dye (Phthalocyanine, etc...)");
}
+ manufacturer = ManufacturerFromATIP(response.LeadInStartSec, frm);
+
+ if(manufacturer != "") sb.AppendFormat("Disc manufactured by: {0}", manufacturer).AppendLine();
+
return sb.ToString();
}
diff --git a/DiscImageChef.Decoders/CD/Sector.cs b/DiscImageChef.Decoders/CD/Sector.cs
index d3637f2f2..c16b4b05a 100644
--- a/DiscImageChef.Decoders/CD/Sector.cs
+++ b/DiscImageChef.Decoders/CD/Sector.cs
@@ -187,7 +187,9 @@ namespace DiscImageChef.Decoders.CD
byte[] scrambled = new byte[sector.Length];
for(int i = 0; i < 2352; i++) scrambled[i] = (byte)(sector[i] ^ ScrambleTable[i]);
- if(sector.Length > 2352) for(int i = 2352; i < sector.Length; i++) scrambled[i] = sector[i];
+ if(sector.Length <= 2352) return scrambled;
+
+ for(int i = 2352; i < sector.Length; i++) scrambled[i] = sector[i];
return scrambled;
}
diff --git a/DiscImageChef.Decoders/DVD/Cartridge.cs b/DiscImageChef.Decoders/DVD/Cartridge.cs
index 64c09a390..e061ab9d9 100644
--- a/DiscImageChef.Decoders/DVD/Cartridge.cs
+++ b/DiscImageChef.Decoders/DVD/Cartridge.cs
@@ -174,21 +174,22 @@ namespace DiscImageChef.Decoders.DVD
break;
}
- if(decoded.MSWI)
- switch(decoded.RAMSWI)
- {
- case 0: break;
- case 1:
- sb.AppendLine("Disc is write inhibited because it has been extracted from the cartridge");
- break;
- case 0xFF:
- sb.AppendLine("Disc is write inhibited for an unspecified reason");
- break;
- default:
- sb.AppendFormat("Disc has unknown reason {0} for write inhibition", decoded.RAMSWI)
- .AppendLine();
- break;
- }
+ if(!decoded.MSWI) return sb.ToString();
+
+ switch(decoded.RAMSWI)
+ {
+ case 0: break;
+ case 1:
+ sb.AppendLine("Disc is write inhibited because it has been extracted from the cartridge");
+ break;
+ case 0xFF:
+ sb.AppendLine("Disc is write inhibited for an unspecified reason");
+ break;
+ default:
+ sb.AppendFormat("Disc has unknown reason {0} for write inhibition", decoded.RAMSWI)
+ .AppendLine();
+ break;
+ }
return sb.ToString();
}
diff --git a/DiscImageChef.Decoders/DVD/DDS.cs b/DiscImageChef.Decoders/DVD/DDS.cs
index 7b3fd4d9f..cf37e0c16 100644
--- a/DiscImageChef.Decoders/DVD/DDS.cs
+++ b/DiscImageChef.Decoders/DVD/DDS.cs
@@ -237,7 +237,8 @@ namespace DiscImageChef.Decoders.DVD
}
// ECMA-330
- if(dds.Groups == 1)
+ if(dds.Groups != 1) return dds;
+
{
dds.Reserved4 = (byte)((response[7] & 0x7C) >> 2);
dds.Reserved = new byte[68];
@@ -291,7 +292,8 @@ namespace DiscImageChef.Decoders.DVD
sb.AppendFormat("Group {0} has been certified by an user", i).AppendLine();
}
- if(decoded.Groups == 1)
+ if(decoded.Groups != 1) return sb.ToString();
+
{
sb.AppendFormat("Disc has {0} zones", decoded.Zones).AppendLine();
sb.AppendFormat("Primary Spare Area stats at PSN {0:X}h and ends at PSN {1:X}h, inclusively",
diff --git a/DiscImageChef.Decoders/Floppy/Apple2.cs b/DiscImageChef.Decoders/Floppy/Apple2.cs
index 554f78cce..6acf68108 100644
--- a/DiscImageChef.Decoders/Floppy/Apple2.cs
+++ b/DiscImageChef.Decoders/Floppy/Apple2.cs
@@ -290,18 +290,15 @@ namespace DiscImageChef.Decoders.Floppy
public static byte[] DecodeSector(RawSector sector)
{
- if(sector.addressField.prologue[0] == 0xD5 && sector.addressField.prologue[1] == 0xAA)
- {
- // Pre DOS 3.3
- if(sector.addressField.prologue[2] == 0xB5) return Decode5and3(sector.dataField.data);
- // DOS 3.3
- if(sector.addressField.prologue[2] == 0x96) return Decode6and2(sector.dataField.data);
- // Unknown
- return null;
- }
+ if(sector.addressField.prologue[0] != 0xD5 || sector.addressField.prologue[1] != 0xAA) return null;
+ // Pre DOS 3.3
+ if(sector.addressField.prologue[2] == 0xB5) return Decode5and3(sector.dataField.data);
+ // DOS 3.3
+ if(sector.addressField.prologue[2] == 0x96) return Decode6and2(sector.dataField.data);
+ // Unknown
+ return null;
// Not Apple ][ GCR?
- return null;
}
public static RawSector MarshalSector(byte[] data, int offset = 0)
diff --git a/DiscImageChef.Decoders/Floppy/AppleSony.cs b/DiscImageChef.Decoders/Floppy/AppleSony.cs
index ae3c59cf7..cb9d495be 100644
--- a/DiscImageChef.Decoders/Floppy/AppleSony.cs
+++ b/DiscImageChef.Decoders/Floppy/AppleSony.cs
@@ -144,78 +144,76 @@ namespace DiscImageChef.Decoders.Floppy
public static byte[] DecodeSector(RawSector sector)
{
- if(sector.addressField.prologue[0] == 0xD5 && sector.addressField.prologue[1] == 0xAA &&
- sector.addressField.prologue[2] == 0x96)
+ if(sector.addressField.prologue[0] != 0xD5 || sector.addressField.prologue[1] != 0xAA ||
+ sector.addressField.prologue[2] != 0x96) return null;
+
+ uint ck1, ck2, ck3;
+ byte carry;
+ byte w1, w2, w3, w4;
+ byte[] bf1 = new byte[175];
+ byte[] bf2 = new byte[175];
+ byte[] bf3 = new byte[175];
+ byte[] nib_data = sector.dataField.data;
+ MemoryStream ms = new MemoryStream();
+
+ int j = 0;
+ w3 = 0;
+ for(int i = 0; i <= 174; i++)
{
- uint ck1, ck2, ck3;
- byte carry;
- byte w1, w2, w3, w4;
- byte[] bf1 = new byte[175];
- byte[] bf2 = new byte[175];
- byte[] bf3 = new byte[175];
- byte[] nib_data = sector.dataField.data;
- MemoryStream ms = new MemoryStream();
+ w4 = nib_data[j++];
+ w1 = nib_data[j++];
+ w2 = nib_data[j++];
- int j = 0;
- w3 = 0;
- for(int i = 0; i <= 174; i++)
- {
- w4 = nib_data[j++];
- w1 = nib_data[j++];
- w2 = nib_data[j++];
+ if(i != 174) w3 = nib_data[j++];
- if(i != 174) w3 = nib_data[j++];
-
- bf1[i] = (byte)(((w1 & 0x3F) | ((w4 << 2) & 0xC0)) & 0x0F);
- bf2[i] = (byte)(((w2 & 0x3F) | ((w4 << 4) & 0xC0)) & 0x0F);
- bf3[i] = (byte)(((w3 & 0x3F) | ((w4 << 6) & 0xC0)) & 0x0F);
- }
-
- j = 0;
- ck1 = 0;
- ck2 = 0;
- ck3 = 0;
- while(true)
- {
- ck1 = (ck1 & 0xFF) << 1;
- if((ck1 & 0x0100) > 0) ck1++;
-
- carry = (byte)((bf1[j] ^ ck1) & 0xFF);
- ck3 += carry;
- if((ck1 & 0x0100) > 0)
- {
- ck3++;
- ck1 &= 0xFF;
- }
- ms.WriteByte(carry);
-
- carry = (byte)((bf2[j] ^ ck3) & 0xFF);
- ck2 += carry;
- if(ck3 > 0xFF)
- {
- ck2++;
- ck3 &= 0xFF;
- }
- ms.WriteByte(carry);
-
- if(ms.Length == 524) break;
-
- carry = (byte)((bf3[j] ^ ck2) & 0xFF);
- ck1 += carry;
- if(ck2 > 0xFF)
- {
- ck1++;
- ck2 &= 0xFF;
- }
- ms.WriteByte(carry);
- j++;
- }
-
- return ms.ToArray();
+ bf1[i] = (byte)(((w1 & 0x3F) | ((w4 << 2) & 0xC0)) & 0x0F);
+ bf2[i] = (byte)(((w2 & 0x3F) | ((w4 << 4) & 0xC0)) & 0x0F);
+ bf3[i] = (byte)(((w3 & 0x3F) | ((w4 << 6) & 0xC0)) & 0x0F);
}
+ j = 0;
+ ck1 = 0;
+ ck2 = 0;
+ ck3 = 0;
+ while(true)
+ {
+ ck1 = (ck1 & 0xFF) << 1;
+ if((ck1 & 0x0100) > 0) ck1++;
+
+ carry = (byte)((bf1[j] ^ ck1) & 0xFF);
+ ck3 += carry;
+ if((ck1 & 0x0100) > 0)
+ {
+ ck3++;
+ ck1 &= 0xFF;
+ }
+ ms.WriteByte(carry);
+
+ carry = (byte)((bf2[j] ^ ck3) & 0xFF);
+ ck2 += carry;
+ if(ck3 > 0xFF)
+ {
+ ck2++;
+ ck3 &= 0xFF;
+ }
+ ms.WriteByte(carry);
+
+ if(ms.Length == 524) break;
+
+ carry = (byte)((bf3[j] ^ ck2) & 0xFF);
+ ck1 += carry;
+ if(ck2 > 0xFF)
+ {
+ ck1++;
+ ck2 &= 0xFF;
+ }
+ ms.WriteByte(carry);
+ j++;
+ }
+
+ return ms.ToArray();
+
// Not Apple Sony GCR?
- return null;
}
public static RawSector MarshalSector(byte[] data, int offset = 0)
diff --git a/DiscImageChef.Decoders/PCMCIA/CIS.cs b/DiscImageChef.Decoders/PCMCIA/CIS.cs
index b69d8e961..db96994ca 100644
--- a/DiscImageChef.Decoders/PCMCIA/CIS.cs
+++ b/DiscImageChef.Decoders/PCMCIA/CIS.cs
@@ -226,29 +226,28 @@ namespace DiscImageChef.Decoders.PCMCIA
buffer.Add(data[position]);
- if(data[position] == 0x00)
+ if(data[position] != 0x00) continue;
+
+ if(!firstString)
{
- if(!firstString)
- {
- tuple.Manufacturer = StringHandlers.CToString(buffer.ToArray());
- buffer = new List();
- firstString = true;
- continue;
- }
-
- if(!secondString)
- {
- tuple.Product = StringHandlers.CToString(buffer.ToArray());
- buffer = new List();
- firstString = true;
- continue;
- }
-
- if(strings == null) strings = new List();
-
- strings.Add(StringHandlers.CToString(buffer.ToArray()));
+ tuple.Manufacturer = StringHandlers.CToString(buffer.ToArray());
buffer = new List();
+ firstString = true;
+ continue;
}
+
+ if(!secondString)
+ {
+ tuple.Product = StringHandlers.CToString(buffer.ToArray());
+ buffer = new List();
+ firstString = true;
+ continue;
+ }
+
+ if(strings == null) strings = new List();
+
+ strings.Add(StringHandlers.CToString(buffer.ToArray()));
+ buffer = new List();
}
if(strings != null) tuple.AdditionalInformation = strings.ToArray();
diff --git a/DiscImageChef.Decoders/SCSI/EVPD.cs b/DiscImageChef.Decoders/SCSI/EVPD.cs
index 9af225589..7ba2bf047 100644
--- a/DiscImageChef.Decoders/SCSI/EVPD.cs
+++ b/DiscImageChef.Decoders/SCSI/EVPD.cs
@@ -2301,52 +2301,49 @@ namespace DiscImageChef.Decoders.SCSI
return decoded;
}
- if(pageResponse[4] == pageResponse[3] - 1)
- {
- List array = new List();
- string fwRegExStr =
- "Firmware Rev\\s+=\\s+(?\\d+\\.\\d+)\\s+Build date\\s+=\\s+(?(\\w|\\d|\\s*.)*)\\s*$";
- string fwcRegExStr = "FW_CONF\\s+=\\s+(?0x[0-9A-Fa-f]{8})\\s*$";
- string servoRegExStr = "Servo\\s+Rev\\s+=\\s+(?\\d+\\.\\d+)\\s*$";
- Regex fwRegEx = new Regex(fwRegExStr);
- Regex fwcRegEx = new Regex(fwcRegExStr);
- Regex servoRegEx = new Regex(servoRegExStr);
- Match fwMatch;
- Match fwcMatch;
- Match servoMatch;
+ if(pageResponse[4] != pageResponse[3] - 1) return null;
- for(int pos = 5; pos < pageResponse.Length; pos++)
- if(pageResponse[pos] == 0x00)
+ List array = new List();
+ string fwRegExStr =
+ "Firmware Rev\\s+=\\s+(?\\d+\\.\\d+)\\s+Build date\\s+=\\s+(?(\\w|\\d|\\s*.)*)\\s*$";
+ string fwcRegExStr = "FW_CONF\\s+=\\s+(?0x[0-9A-Fa-f]{8})\\s*$";
+ string servoRegExStr = "Servo\\s+Rev\\s+=\\s+(?\\d+\\.\\d+)\\s*$";
+ Regex fwRegEx = new Regex(fwRegExStr);
+ Regex fwcRegEx = new Regex(fwcRegExStr);
+ Regex servoRegEx = new Regex(servoRegExStr);
+ Match fwMatch;
+ Match fwcMatch;
+ Match servoMatch;
+
+ for(int pos = 5; pos < pageResponse.Length; pos++)
+ if(pageResponse[pos] == 0x00)
+ {
+ string str = StringHandlers.CToString(array.ToArray());
+ fwMatch = fwRegEx.Match(str);
+ fwcMatch = fwcRegEx.Match(str);
+ servoMatch = servoRegEx.Match(str);
+
+ if(str.ToLowerInvariant().StartsWith("copyright", StringComparison.Ordinal))
+ decoded.Copyright = Encoding.ASCII.GetBytes(str);
+ else if(fwMatch.Success)
{
- string str = StringHandlers.CToString(array.ToArray());
- fwMatch = fwRegEx.Match(str);
- fwcMatch = fwcRegEx.Match(str);
- servoMatch = servoRegEx.Match(str);
-
- if(str.ToLowerInvariant().StartsWith("copyright", StringComparison.Ordinal))
- decoded.Copyright = Encoding.ASCII.GetBytes(str);
- else if(fwMatch.Success)
- {
- decoded.Component = Encoding.ASCII.GetBytes("Firmware");
- decoded.Version = Encoding.ASCII.GetBytes(fwMatch.Groups["fw"].Value);
- decoded.Date = Encoding.ASCII.GetBytes(fwMatch.Groups["date"].Value);
- }
- else if(fwcMatch.Success)
- decoded.Variant = Encoding.ASCII.GetBytes(fwMatch.Groups["value"].Value);
- else if(servoMatch.Success)
- {
- decoded.Component = Encoding.ASCII.GetBytes("Servo");
- decoded.Version = Encoding.ASCII.GetBytes(servoMatch.Groups["version"].Value);
- }
-
- array = new List();
+ decoded.Component = Encoding.ASCII.GetBytes("Firmware");
+ decoded.Version = Encoding.ASCII.GetBytes(fwMatch.Groups["fw"].Value);
+ decoded.Date = Encoding.ASCII.GetBytes(fwMatch.Groups["date"].Value);
+ }
+ else if(fwcMatch.Success)
+ decoded.Variant = Encoding.ASCII.GetBytes(fwMatch.Groups["value"].Value);
+ else if(servoMatch.Success)
+ {
+ decoded.Component = Encoding.ASCII.GetBytes("Servo");
+ decoded.Version = Encoding.ASCII.GetBytes(servoMatch.Groups["version"].Value);
}
- else array.Add(pageResponse[pos]);
- return decoded;
- }
+ array = new List();
+ }
+ else array.Add(pageResponse[pos]);
- return null;
+ return decoded;
}
public static string PrettifyPage_C0_to_C5_HP(byte[] pageResponse)
diff --git a/DiscImageChef.Decoders/SCSI/Inquiry.cs b/DiscImageChef.Decoders/SCSI/Inquiry.cs
index f828a51db..805a2a85a 100644
--- a/DiscImageChef.Decoders/SCSI/Inquiry.cs
+++ b/DiscImageChef.Decoders/SCSI/Inquiry.cs
@@ -248,13 +248,11 @@ namespace DiscImageChef.Decoders.SCSI
decoded.Seagate_Copyright = new byte[48];
Array.Copy(SCSIInquiryResponse, 96, decoded.Seagate_Copyright, 0, 48);
}
- if(SCSIInquiryResponse.Length >= 148)
- {
- // Seagate 2
- decoded.Seagate3Present = true;
- decoded.Seagate_ServoPROMPartNo = new byte[4];
- Array.Copy(SCSIInquiryResponse, 144, decoded.Seagate_ServoPROMPartNo, 0, 4);
- }
+ if(SCSIInquiryResponse.Length < 148) return decoded;
+ // Seagate 2
+ decoded.Seagate3Present = true;
+ decoded.Seagate_ServoPROMPartNo = new byte[4];
+ Array.Copy(SCSIInquiryResponse, 144, decoded.Seagate_ServoPROMPartNo, 0, 4);
return decoded;
}
@@ -2059,13 +2057,12 @@ namespace DiscImageChef.Decoders.SCSI
sb.AppendLine("============================================================");
}
- if(response.VendorSpecific2 != null)
- {
- sb.AppendFormat("Vendor-specific bytes 96 to {0}", response.AdditionalLength + 4).AppendLine();
- sb.AppendLine("============================================================");
- sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.VendorSpecific2, 60));
- sb.AppendLine("============================================================");
- }
+ if(response.VendorSpecific2 == null) return sb.ToString();
+
+ sb.AppendFormat("Vendor-specific bytes 96 to {0}", response.AdditionalLength + 4).AppendLine();
+ sb.AppendLine("============================================================");
+ sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.VendorSpecific2, 60));
+ sb.AppendLine("============================================================");
#endif
return sb.ToString();
diff --git a/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs b/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs
index 0a92f4003..2bcd1ec18 100644
--- a/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs
+++ b/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs
@@ -316,15 +316,14 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.DiscApplicationCode = response[32];
decoded.OPCTablesNumber = response[33];
- if(decoded.OPCTablesNumber > 0 && response.Length == decoded.OPCTablesNumber * 8 + 34)
+ if(decoded.OPCTablesNumber <= 0 || response.Length != decoded.OPCTablesNumber * 8 + 34) return decoded;
+
+ decoded.OPCTables = new OPCTable[decoded.OPCTablesNumber];
+ for(int i = 0; i < decoded.OPCTablesNumber; i++)
{
- decoded.OPCTables = new OPCTable[decoded.OPCTablesNumber];
- for(int i = 0; i < decoded.OPCTablesNumber; i++)
- {
- decoded.OPCTables[i].Speed = (ushort)((response[34 + i * 8 + 0] << 16) + response[34 + i * 8 + 1]);
- decoded.OPCTables[i].OPCValues = new byte[6];
- Array.Copy(response, 34 + i * 8 + 2, decoded.OPCTables[i].OPCValues, 0, 6);
- }
+ decoded.OPCTables[i].Speed = (ushort)((response[34 + i * 8 + 0] << 16) + response[34 + i * 8 + 1]);
+ decoded.OPCTables[i].OPCValues = new byte[6];
+ Array.Copy(response, 34 + i * 8 + 2, decoded.OPCTables[i].OPCValues, 0, 6);
}
return decoded;
@@ -425,11 +424,12 @@ namespace DiscImageChef.Decoders.SCSI.MMC
if(decoded.DBC_V) sb.AppendFormat("Disc barcode: {0:X16}", decoded.DiscBarcode).AppendLine();
if(decoded.DAC_V) sb.AppendFormat("Disc application code: {0}", decoded.DiscApplicationCode).AppendLine();
- if(decoded.OPCTables != null)
- foreach(OPCTable table in decoded.OPCTables)
- sb.AppendFormat("OPC values for {0}Kbit/sec.: {1}, {2}, {3}, {4}, {5}, {6}", table.Speed,
- table.OPCValues[0], table.OPCValues[1], table.OPCValues[2], table.OPCValues[3],
- table.OPCValues[4], table.OPCValues[5]).AppendLine();
+ if(decoded.OPCTables == null) return sb.ToString();
+
+ foreach(OPCTable table in decoded.OPCTables)
+ sb.AppendFormat("OPC values for {0}Kbit/sec.: {1}, {2}, {3}, {4}, {5}, {6}", table.Speed,
+ table.OPCValues[0], table.OPCValues[1], table.OPCValues[2], table.OPCValues[3],
+ table.OPCValues[4], table.OPCValues[5]).AppendLine();
return sb.ToString();
}
diff --git a/DiscImageChef.Decoders/SCSI/MMC/Features.cs b/DiscImageChef.Decoders/SCSI/MMC/Features.cs
index 46fc99f08..f4bebdd76 100644
--- a/DiscImageChef.Decoders/SCSI/MMC/Features.cs
+++ b/DiscImageChef.Decoders/SCSI/MMC/Features.cs
@@ -2274,11 +2274,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Lock |= (feature[4] & 0x01) == 0x01;
}
- if(decoded.Version >= 2)
- {
- decoded.Load |= (feature[4] & 0x10) == 0x10;
- decoded.DBML |= (feature[4] & 0x02) == 0x02;
- }
+ if(decoded.Version < 2) return decoded;
+
+ decoded.Load |= (feature[4] & 0x10) == 0x10;
+ decoded.DBML |= (feature[4] & 0x02) == 0x02;
return decoded;
}
@@ -2332,13 +2331,12 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.LogicalBlockSize =
- (uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]);
- decoded.Blocking = (ushort)((feature[8] << 8) + feature[9]);
- decoded.PP |= (feature[10] & 0x01) == 0x01;
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.LogicalBlockSize =
+ (uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]);
+ decoded.Blocking = (ushort)((feature[8] << 8) + feature[9]);
+ decoded.PP |= (feature[10] & 0x01) == 0x01;
return decoded;
}
@@ -2441,14 +2439,13 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 1)
- {
- decoded.LastLBA = (uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]);
- decoded.LogicalBlockSize =
- (uint)((feature[8] << 24) + (feature[9] << 16) + (feature[10] << 8) + feature[11]);
- decoded.Blocking = (ushort)((feature[12] << 8) + feature[13]);
- decoded.PP |= (feature[14] & 0x01) == 0x01;
- }
+ if(decoded.Version < 1) return decoded;
+
+ decoded.LastLBA = (uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]);
+ decoded.LogicalBlockSize =
+ (uint)((feature[8] << 24) + (feature[9] << 16) + (feature[10] << 8) + feature[11]);
+ decoded.Blocking = (ushort)((feature[12] << 8) + feature[13]);
+ decoded.PP |= (feature[14] & 0x01) == 0x01;
return decoded;
}
@@ -2479,11 +2476,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
if(feature.Length > feature[7] + 8) Array.Copy(feature, 8, decoded.LinkSizes, 0, feature[7]);
}
- if(decoded.Version >= 3)
- {
- decoded.TRIO |= (feature[6] & 0x04) == 0x04;
- decoded.ARSV |= (feature[6] & 0x02) == 0x02;
- }
+ if(decoded.Version < 3) return decoded;
+
+ decoded.TRIO |= (feature[6] & 0x04) == 0x04;
+ decoded.ARSV |= (feature[6] & 0x02) == 0x02;
return decoded;
}
@@ -2582,13 +2578,12 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.LogicalBlockSize =
- (uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]);
- decoded.Blocking = (ushort)((feature[8] << 8) + feature[9]);
- decoded.PP |= (feature[10] & 0x01) == 0x01;
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.LogicalBlockSize =
+ (uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]);
+ decoded.Blocking = (ushort)((feature[8] << 8) + feature[9]);
+ decoded.PP |= (feature[10] & 0x01) == 0x01;
return decoded;
}
@@ -2655,11 +2650,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
if(decoded.Version >= 0) decoded.Write |= (feature[4] & 0x01) == 0x01;
- if(decoded.Version >= 1)
- {
- decoded.DVDPWrite |= (feature[4] & 0x04) == 0x04;
- decoded.DVDPRead |= (feature[4] & 0x02) == 0x02;
- }
+ if(decoded.Version < 1) return decoded;
+
+ decoded.DVDPWrite |= (feature[4] & 0x04) == 0x04;
+ decoded.DVDPRead |= (feature[4] & 0x02) == 0x02;
return decoded;
}
@@ -2682,12 +2676,11 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.DRTDM |= (feature[4] & 0x01) == 0x01;
- decoded.DBICacheZones = feature[5];
- decoded.Entries = (ushort)((feature[6] << 8) + feature[7]);
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.DRTDM |= (feature[4] & 0x01) == 0x01;
+ decoded.DBICacheZones = feature[5];
+ decoded.Entries = (ushort)((feature[6] << 8) + feature[7]);
return decoded;
}
@@ -2762,13 +2755,12 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.DSDG |= (feature[4] & 0x08) == 0x08;
- decoded.DSDR |= (feature[4] & 0x04) == 0x04;
- decoded.Intermediate |= (feature[4] & 0x02) == 0x02;
- decoded.Blank |= (feature[4] & 0x01) == 0x01;
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.DSDG |= (feature[4] & 0x08) == 0x08;
+ decoded.DSDR |= (feature[4] & 0x04) == 0x04;
+ decoded.Intermediate |= (feature[4] & 0x02) == 0x02;
+ decoded.Blank |= (feature[4] & 0x01) == 0x01;
return decoded;
}
@@ -2799,12 +2791,11 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.DataTypeSupported = (ushort)((feature[6] << 8) + feature[7]);
}
- if(decoded.Version >= 2)
- {
- decoded.BUF |= (feature[4] & 0x40) == 0x40;
- decoded.RWRaw |= (feature[4] & 0x10) == 0x10;
- decoded.RWPack |= (feature[4] & 0x08) == 0x08;
- }
+ if(decoded.Version < 2) return decoded;
+
+ decoded.BUF |= (feature[4] & 0x40) == 0x40;
+ decoded.RWRaw |= (feature[4] & 0x10) == 0x10;
+ decoded.RWPack |= (feature[4] & 0x08) == 0x08;
return decoded;
}
@@ -2936,11 +2927,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.Intermediate |= (feature[4] & 0x02) == 0x02;
- decoded.Blank |= (feature[4] & 0x01) == 0x01;
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.Intermediate |= (feature[4] & 0x02) == 0x02;
+ decoded.Blank |= (feature[4] & 0x01) == 0x01;
return decoded;
}
@@ -2963,11 +2953,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(feature[7] > 0 && feature.Length > feature[7] + 8)
- {
- decoded.LinkSizes = new byte[feature[7]];
- Array.Copy(feature, 8, decoded.LinkSizes, 0, feature[7]);
- }
+ if(feature[7] <= 0 || feature.Length <= feature[7] + 8) return decoded;
+
+ decoded.LinkSizes = new byte[feature[7]];
+ Array.Copy(feature, 8, decoded.LinkSizes, 0, feature[7]);
return decoded;
}
@@ -3055,12 +3044,11 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.Write |= (feature[4] & 0x01) == 0x01;
- decoded.QuickStart |= (feature[5] & 0x02) == 0x02;
- decoded.CloseOnly |= (feature[5] & 0x01) == 0x01;
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.Write |= (feature[4] & 0x01) == 0x01;
+ decoded.QuickStart |= (feature[5] & 0x02) == 0x02;
+ decoded.CloseOnly |= (feature[5] & 0x01) == 0x01;
return decoded;
}
@@ -3113,14 +3101,13 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.OldROM |= (feature[25] & 0x01) == 0x01;
}
- if(decoded.Version >= 1)
- {
- decoded.BCA |= (feature[4] & 0x01) == 0x01;
- decoded.RE2 |= (feature[9] & 0x04) == 0x04;
- decoded.RE1 |= (feature[9] & 0x02) == 0x02;
- decoded.R |= (feature[17] & 0x02) == 0x02;
- decoded.ROM |= (feature[25] & 0x02) == 0x02;
- }
+ if(decoded.Version < 1) return decoded;
+
+ decoded.BCA |= (feature[4] & 0x01) == 0x01;
+ decoded.RE2 |= (feature[9] & 0x04) == 0x04;
+ decoded.RE1 |= (feature[9] & 0x02) == 0x02;
+ decoded.R |= (feature[17] & 0x02) == 0x02;
+ decoded.ROM |= (feature[25] & 0x02) == 0x02;
return decoded;
}
@@ -3150,12 +3137,11 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.OldR |= (feature[17] & 0x01) == 0x01;
}
- if(decoded.Version >= 1)
- {
- decoded.RE2 |= (feature[9] & 0x04) == 0x04;
- decoded.RE1 |= (feature[9] & 0x02) == 0x02;
- decoded.R |= (feature[17] & 0x02) == 0x02;
- }
+ if(decoded.Version < 1) return decoded;
+
+ decoded.RE2 |= (feature[9] & 0x04) == 0x04;
+ decoded.RE1 |= (feature[9] & 0x02) == 0x02;
+ decoded.R |= (feature[17] & 0x02) == 0x02;
return decoded;
}
@@ -3199,11 +3185,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.HDDVDR |= (feature[4] & 0x01) == 0x01;
- decoded.HDDVDRAM |= (feature[6] & 0x01) == 0x01;
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.HDDVDR |= (feature[4] & 0x01) == 0x01;
+ decoded.HDDVDRAM |= (feature[6] & 0x01) == 0x01;
return decoded;
}
@@ -3226,11 +3211,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.HDDVDR |= (feature[4] & 0x01) == 0x01;
- decoded.HDDVDRAM |= (feature[6] & 0x01) == 0x01;
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.HDDVDR |= (feature[4] & 0x01) == 0x01;
+ decoded.HDDVDRAM |= (feature[6] & 0x01) == 0x01;
return decoded;
}
@@ -3320,12 +3304,11 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.SCC |= (feature[4] & 0x10) == 0x10;
- decoded.SDP |= (feature[4] & 0x04) == 0x04;
- decoded.HighestSlotNumber = (byte)(feature[7] & 0x1F);
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.SCC |= (feature[4] & 0x10) == 0x10;
+ decoded.SDP |= (feature[4] & 0x04) == 0x04;
+ decoded.HighestSlotNumber = (byte)(feature[7] & 0x1F);
return decoded;
}
@@ -3348,13 +3331,12 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.Scan |= (feature[4] & 0x04) == 0x04;
- decoded.SCM |= (feature[4] & 0x02) == 0x02;
- decoded.SV |= (feature[4] & 0x01) == 0x01;
- decoded.VolumeLevels = (ushort)((feature[6] << 8) + feature[7]);
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.Scan |= (feature[4] & 0x04) == 0x04;
+ decoded.SCM |= (feature[4] & 0x02) == 0x02;
+ decoded.SV |= (feature[4] & 0x01) == 0x01;
+ decoded.VolumeLevels = (ushort)((feature[6] << 8) + feature[7]);
return decoded;
}
@@ -3400,11 +3382,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 1 && feature.Length >= 8)
- {
- decoded.Group3 |= (feature[4] & 0x01) == 0x01;
- decoded.UnitLength = (ushort)((feature[6] << 8) + feature[7]);
- }
+ if(decoded.Version < 1 || feature.Length < 8) return decoded;
+
+ decoded.Group3 |= (feature[4] & 0x01) == 0x01;
+ decoded.UnitLength = (ushort)((feature[6] << 8) + feature[7]);
return decoded;
}
@@ -3459,11 +3440,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.SW |= (feature[4] & 0x01) == 0x01;
}
- if(decoded.Version >= 5 && feature.Length >= 8)
- {
- decoded.SMP |= (feature[4] & 0x20) == 0x20;
- decoded.RBCB |= (feature[4] & 0x10) == 0x10;
- }
+ if(decoded.Version < 5 || feature.Length < 8) return decoded;
+
+ decoded.SMP |= (feature[4] & 0x20) == 0x20;
+ decoded.RBCB |= (feature[4] & 0x10) == 0x10;
return decoded;
}
@@ -3486,12 +3466,11 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- byte[] serial = new byte[feature.Length];
- Array.Copy(feature, 4, serial, 0, feature.Length - 4);
- decoded.Serial = StringHandlers.CToString(serial).Trim();
- }
+ if(decoded.Version < 0) return decoded;
+
+ byte[] serial = new byte[feature.Length];
+ Array.Copy(feature, 4, serial, 0, feature.Length - 4);
+ decoded.Serial = StringHandlers.CToString(serial).Trim();
return decoded;
}
@@ -3535,13 +3514,12 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.DCBs = new uint[feature[3] / 4];
- for(int i = 0; i < decoded.DCBs.Length; i++)
- decoded.DCBs[i] = (uint)((feature[0 + 4 + i * 4] << 24) + (feature[1 + 4 + i * 4] << 16) +
- (feature[2 + 4 + i * 4] << 8) + feature[3 + 4 + i * 4]);
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.DCBs = new uint[feature[3] / 4];
+ for(int i = 0; i < decoded.DCBs.Length; i++)
+ decoded.DCBs[i] = (uint)((feature[0 + 4 + i * 4] << 24) + (feature[1 + 4 + i * 4] << 16) +
+ (feature[2 + 4 + i * 4] << 8) + feature[3 + 4 + i * 4]);
return decoded;
}
@@ -3587,16 +3565,15 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.Century = (ushort)((feature[4] << 8) + feature[5]);
- decoded.Year = (ushort)((feature[6] << 8) + feature[7]);
- decoded.Month = (ushort)((feature[8] << 8) + feature[9]);
- decoded.Day = (ushort)((feature[10] << 8) + feature[11]);
- decoded.Hour = (ushort)((feature[12] << 8) + feature[13]);
- decoded.Minute = (ushort)((feature[14] << 8) + feature[15]);
- decoded.Second = (ushort)((feature[16] << 8) + feature[17]);
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.Century = (ushort)((feature[4] << 8) + feature[5]);
+ decoded.Year = (ushort)((feature[6] << 8) + feature[7]);
+ decoded.Month = (ushort)((feature[8] << 8) + feature[9]);
+ decoded.Day = (ushort)((feature[10] << 8) + feature[11]);
+ decoded.Hour = (ushort)((feature[12] << 8) + feature[13]);
+ decoded.Minute = (ushort)((feature[14] << 8) + feature[15]);
+ decoded.Second = (ushort)((feature[16] << 8) + feature[17]);
return decoded;
}
@@ -3627,13 +3604,12 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.AACSVersion = feature[7];
}
- if(decoded.Version >= 2)
- {
- decoded.RDC |= (feature[4] & 0x10) == 0x10;
- decoded.RMC |= (feature[4] & 0x08) == 0x08;
- decoded.WBE |= (feature[4] & 0x04) == 0x04;
- decoded.BEC |= (feature[4] & 0x02) == 0x02;
- }
+ if(decoded.Version < 2) return decoded;
+
+ decoded.RDC |= (feature[4] & 0x10) == 0x10;
+ decoded.RMC |= (feature[4] & 0x08) == 0x08;
+ decoded.WBE |= (feature[4] & 0x04) == 0x04;
+ decoded.BEC |= (feature[4] & 0x02) == 0x02;
return decoded;
}
@@ -3721,16 +3697,16 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
- if(decoded.Version >= 0)
- {
- decoded.PSAU |= (feature[4] & 0x80) == 0x80;
- decoded.LOSPB |= (feature[4] & 0x40) == 0x40;
- decoded.ME |= (feature[4] & 0x01) == 0x01;
- decoded.Profiles = new ushort[feature[5]];
- if(feature[5] * 2 + 6 == feature.Length)
- for(int i = 0; i < feature[5]; i++)
- decoded.Profiles[i] = (ushort)((feature[0 + 6 + 2 * i] << 8) + feature[1 + 6 + 2 * i]);
- }
+ if(decoded.Version < 0) return decoded;
+
+ decoded.PSAU |= (feature[4] & 0x80) == 0x80;
+ decoded.LOSPB |= (feature[4] & 0x40) == 0x40;
+ decoded.ME |= (feature[4] & 0x01) == 0x01;
+ decoded.Profiles = new ushort[feature[5]];
+ if(feature[5] * 2 + 6 != feature.Length) return decoded;
+
+ for(int i = 0; i < feature[5]; i++)
+ decoded.Profiles[i] = (ushort)((feature[0 + 6 + 2 * i] << 8) + feature[1 + 6 + 2 * i]);
return decoded;
}
@@ -3743,137 +3719,138 @@ namespace DiscImageChef.Decoders.SCSI.MMC
StringBuilder sb = new StringBuilder();
sb.AppendLine("MMC Supported Profiles:");
- if(ftr.Profiles != null)
- foreach(Profile prof in ftr.Profiles)
- {
- switch(prof.Number)
- {
- case ProfileNumber.Reserved:
- sb.Append("\tDrive reported a reserved profile number");
- break;
- case ProfileNumber.NonRemovable:
- sb.Append("\tDrive supports non-removable changeable media");
- break;
- case ProfileNumber.Removable:
- sb.Append("\tDrive supports rewritable and removable media");
- break;
- case ProfileNumber.MOErasable:
- sb.Append("\tDrive supports Magnet-Optical media");
- break;
- case ProfileNumber.OpticalWORM:
- sb.Append("\tDrive supports optical write-once media");
- break;
- case ProfileNumber.ASMO:
- sb.Append("\tDrive supports Advanced Storage - Magneto-Optical");
- break;
- case ProfileNumber.CDROM:
- sb.Append("\tDrive supports CD-ROM");
- break;
- case ProfileNumber.CDR:
- sb.Append("\tDrive supports CD-R");
- break;
- case ProfileNumber.CDRW:
- sb.Append("\tDrive supports CD-RW");
- break;
- case ProfileNumber.DVDROM:
- sb.Append("\tDrive supports DVD-ROM");
- break;
- case ProfileNumber.DVDRSeq:
- sb.Append("\tDrive supports DVD-R");
- break;
- case ProfileNumber.DVDRAM:
- sb.Append("\tDrive supports DVD-RAM");
- break;
- case ProfileNumber.DVDRWRes:
- sb.Append("\tDrive supports restricted overwrite DVD-RW");
- break;
- case ProfileNumber.DVDRWSeq:
- sb.Append("\tDrive supports sequentially recorded DVD-RW");
- break;
- case ProfileNumber.DVDRDLSeq:
- sb.Append("\tDrive supports sequentially recorded DVD-R DL");
- break;
- case ProfileNumber.DVDRDLJump:
- sb.Append("\tDrive supports layer jump recorded DVD-R DL");
- break;
- case ProfileNumber.DVDRWDL:
- sb.Append("\tDrive supports DVD-RW DL");
- break;
- case ProfileNumber.DVDDownload:
- sb.Append("\tDrive supports DVD-Download");
- break;
- case ProfileNumber.DVDRWPlus:
- sb.Append("\tDrive supports DVD+RW");
- break;
- case ProfileNumber.DVDRPlus:
- sb.Append("\tDrive supports DVD+R");
- break;
- case ProfileNumber.DDCDROM:
- sb.Append("\tDrive supports DDCD-ROM");
- break;
- case ProfileNumber.DDCDR:
- sb.Append("\tDrive supports DDCD-R");
- break;
- case ProfileNumber.DDCDRW:
- sb.Append("\tDrive supports DDCD-RW");
- break;
- case ProfileNumber.DVDRWDLPlus:
- sb.Append("\tDrive supports DVD+RW DL");
- break;
- case ProfileNumber.DVDRDLPlus:
- sb.Append("\tDrive supports DVD+R DL");
- break;
- case ProfileNumber.BDROM:
- sb.Append("\tDrive supports BD-ROM");
- break;
- case ProfileNumber.BDRSeq:
- sb.Append("\tDrive supports BD-R SRM");
- break;
- case ProfileNumber.BDRRdm:
- sb.Append("\tDrive supports BD-R RRM");
- break;
- case ProfileNumber.BDRE:
- sb.Append("\tDrive supports BD-RE");
- break;
- case ProfileNumber.HDDVDROM:
- sb.Append("\tDrive supports HD DVD-ROM");
- break;
- case ProfileNumber.HDDVDR:
- sb.Append("\tDrive supports HD DVD-R");
- break;
- case ProfileNumber.HDDVDRAM:
- sb.Append("\tDrive supports HD DVD-RAM");
- break;
- case ProfileNumber.HDDVDRW:
- sb.Append("\tDrive supports HD DVD-RW");
- break;
- case ProfileNumber.HDDVDRDL:
- sb.Append("\tDrive supports HD DVD-R DL");
- break;
- case ProfileNumber.HDDVDRWDL:
- sb.Append("\tDrive supports HD DVD-RW DL");
- break;
- case ProfileNumber.HDBURNROM:
- sb.Append("\tDrive supports HDBurn CD-ROM");
- break;
- case ProfileNumber.HDBURNR:
- sb.Append("\tDrive supports HDBurn CD-R");
- break;
- case ProfileNumber.HDBURNRW:
- sb.Append("\tDrive supports HDBurn CD-RW");
- break;
- case ProfileNumber.Unconforming:
- sb.Append("\tDrive is not conforming to any profile");
- break;
- default:
- sb.AppendFormat("\tDrive informs of unknown profile 0x{0:X4}", (ushort)prof.Number);
- break;
- }
+ if(ftr.Profiles == null) return sb.ToString();
- if(prof.Current) sb.AppendLine(" (current)");
- else sb.AppendLine();
+ foreach(Profile prof in ftr.Profiles)
+ {
+ switch(prof.Number)
+ {
+ case ProfileNumber.Reserved:
+ sb.Append("\tDrive reported a reserved profile number");
+ break;
+ case ProfileNumber.NonRemovable:
+ sb.Append("\tDrive supports non-removable changeable media");
+ break;
+ case ProfileNumber.Removable:
+ sb.Append("\tDrive supports rewritable and removable media");
+ break;
+ case ProfileNumber.MOErasable:
+ sb.Append("\tDrive supports Magnet-Optical media");
+ break;
+ case ProfileNumber.OpticalWORM:
+ sb.Append("\tDrive supports optical write-once media");
+ break;
+ case ProfileNumber.ASMO:
+ sb.Append("\tDrive supports Advanced Storage - Magneto-Optical");
+ break;
+ case ProfileNumber.CDROM:
+ sb.Append("\tDrive supports CD-ROM");
+ break;
+ case ProfileNumber.CDR:
+ sb.Append("\tDrive supports CD-R");
+ break;
+ case ProfileNumber.CDRW:
+ sb.Append("\tDrive supports CD-RW");
+ break;
+ case ProfileNumber.DVDROM:
+ sb.Append("\tDrive supports DVD-ROM");
+ break;
+ case ProfileNumber.DVDRSeq:
+ sb.Append("\tDrive supports DVD-R");
+ break;
+ case ProfileNumber.DVDRAM:
+ sb.Append("\tDrive supports DVD-RAM");
+ break;
+ case ProfileNumber.DVDRWRes:
+ sb.Append("\tDrive supports restricted overwrite DVD-RW");
+ break;
+ case ProfileNumber.DVDRWSeq:
+ sb.Append("\tDrive supports sequentially recorded DVD-RW");
+ break;
+ case ProfileNumber.DVDRDLSeq:
+ sb.Append("\tDrive supports sequentially recorded DVD-R DL");
+ break;
+ case ProfileNumber.DVDRDLJump:
+ sb.Append("\tDrive supports layer jump recorded DVD-R DL");
+ break;
+ case ProfileNumber.DVDRWDL:
+ sb.Append("\tDrive supports DVD-RW DL");
+ break;
+ case ProfileNumber.DVDDownload:
+ sb.Append("\tDrive supports DVD-Download");
+ break;
+ case ProfileNumber.DVDRWPlus:
+ sb.Append("\tDrive supports DVD+RW");
+ break;
+ case ProfileNumber.DVDRPlus:
+ sb.Append("\tDrive supports DVD+R");
+ break;
+ case ProfileNumber.DDCDROM:
+ sb.Append("\tDrive supports DDCD-ROM");
+ break;
+ case ProfileNumber.DDCDR:
+ sb.Append("\tDrive supports DDCD-R");
+ break;
+ case ProfileNumber.DDCDRW:
+ sb.Append("\tDrive supports DDCD-RW");
+ break;
+ case ProfileNumber.DVDRWDLPlus:
+ sb.Append("\tDrive supports DVD+RW DL");
+ break;
+ case ProfileNumber.DVDRDLPlus:
+ sb.Append("\tDrive supports DVD+R DL");
+ break;
+ case ProfileNumber.BDROM:
+ sb.Append("\tDrive supports BD-ROM");
+ break;
+ case ProfileNumber.BDRSeq:
+ sb.Append("\tDrive supports BD-R SRM");
+ break;
+ case ProfileNumber.BDRRdm:
+ sb.Append("\tDrive supports BD-R RRM");
+ break;
+ case ProfileNumber.BDRE:
+ sb.Append("\tDrive supports BD-RE");
+ break;
+ case ProfileNumber.HDDVDROM:
+ sb.Append("\tDrive supports HD DVD-ROM");
+ break;
+ case ProfileNumber.HDDVDR:
+ sb.Append("\tDrive supports HD DVD-R");
+ break;
+ case ProfileNumber.HDDVDRAM:
+ sb.Append("\tDrive supports HD DVD-RAM");
+ break;
+ case ProfileNumber.HDDVDRW:
+ sb.Append("\tDrive supports HD DVD-RW");
+ break;
+ case ProfileNumber.HDDVDRDL:
+ sb.Append("\tDrive supports HD DVD-R DL");
+ break;
+ case ProfileNumber.HDDVDRWDL:
+ sb.Append("\tDrive supports HD DVD-RW DL");
+ break;
+ case ProfileNumber.HDBURNROM:
+ sb.Append("\tDrive supports HDBurn CD-ROM");
+ break;
+ case ProfileNumber.HDBURNR:
+ sb.Append("\tDrive supports HDBurn CD-R");
+ break;
+ case ProfileNumber.HDBURNRW:
+ sb.Append("\tDrive supports HDBurn CD-RW");
+ break;
+ case ProfileNumber.Unconforming:
+ sb.Append("\tDrive is not conforming to any profile");
+ break;
+ default:
+ sb.AppendFormat("\tDrive informs of unknown profile 0x{0:X4}", (ushort)prof.Number);
+ break;
}
+ if(prof.Current) sb.AppendLine(" (current)");
+ else sb.AppendLine();
+ }
+
return sb.ToString();
}
@@ -4337,27 +4314,26 @@ namespace DiscImageChef.Decoders.SCSI.MMC
if(ftr.TestWrite) sb.AppendLine("\tDrive can do a test writing");
if(ftr.BUF) sb.AppendLine("\tDrive supports zero loss linking");
- if(ftr.DataTypeSupported > 0)
- {
- sb.Append("\tDrive supports data block types:");
- if((ftr.DataTypeSupported & 0x0001) == 0x0001) sb.Append(" 0");
- if((ftr.DataTypeSupported & 0x0002) == 0x0002) sb.Append(" 1");
- if((ftr.DataTypeSupported & 0x0004) == 0x0004) sb.Append(" 2");
- if((ftr.DataTypeSupported & 0x0008) == 0x0008) sb.Append(" 3");
- if((ftr.DataTypeSupported & 0x0010) == 0x0010) sb.Append(" 4");
- if((ftr.DataTypeSupported & 0x0020) == 0x0020) sb.Append(" 5");
- if((ftr.DataTypeSupported & 0x0040) == 0x0040) sb.Append(" 6");
- if((ftr.DataTypeSupported & 0x0080) == 0x0080) sb.Append(" 7");
- if((ftr.DataTypeSupported & 0x0100) == 0x0100) sb.Append(" 8");
- if((ftr.DataTypeSupported & 0x0200) == 0x0200) sb.Append(" 9");
- if((ftr.DataTypeSupported & 0x0400) == 0x0400) sb.Append(" 10");
- if((ftr.DataTypeSupported & 0x0800) == 0x0800) sb.Append(" 11");
- if((ftr.DataTypeSupported & 0x1000) == 0x1000) sb.Append(" 12");
- if((ftr.DataTypeSupported & 0x2000) == 0x2000) sb.Append(" 13");
- if((ftr.DataTypeSupported & 0x4000) == 0x4000) sb.Append(" 14");
- if((ftr.DataTypeSupported & 0x8000) == 0x8000) sb.Append(" 15");
- sb.AppendLine();
- }
+ if(ftr.DataTypeSupported <= 0) return sb.ToString();
+
+ sb.Append("\tDrive supports data block types:");
+ if((ftr.DataTypeSupported & 0x0001) == 0x0001) sb.Append(" 0");
+ if((ftr.DataTypeSupported & 0x0002) == 0x0002) sb.Append(" 1");
+ if((ftr.DataTypeSupported & 0x0004) == 0x0004) sb.Append(" 2");
+ if((ftr.DataTypeSupported & 0x0008) == 0x0008) sb.Append(" 3");
+ if((ftr.DataTypeSupported & 0x0010) == 0x0010) sb.Append(" 4");
+ if((ftr.DataTypeSupported & 0x0020) == 0x0020) sb.Append(" 5");
+ if((ftr.DataTypeSupported & 0x0040) == 0x0040) sb.Append(" 6");
+ if((ftr.DataTypeSupported & 0x0080) == 0x0080) sb.Append(" 7");
+ if((ftr.DataTypeSupported & 0x0100) == 0x0100) sb.Append(" 8");
+ if((ftr.DataTypeSupported & 0x0200) == 0x0200) sb.Append(" 9");
+ if((ftr.DataTypeSupported & 0x0400) == 0x0400) sb.Append(" 10");
+ if((ftr.DataTypeSupported & 0x0800) == 0x0800) sb.Append(" 11");
+ if((ftr.DataTypeSupported & 0x1000) == 0x1000) sb.Append(" 12");
+ if((ftr.DataTypeSupported & 0x2000) == 0x2000) sb.Append(" 13");
+ if((ftr.DataTypeSupported & 0x4000) == 0x4000) sb.Append(" 14");
+ if((ftr.DataTypeSupported & 0x8000) == 0x8000) sb.Append(" 15");
+ sb.AppendLine();
return sb.ToString();
}
@@ -4449,9 +4425,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
sb.AppendLine("MMC Layer Jump Recording:");
- if(ftr.LinkSizes != null)
- foreach(byte link in ftr.LinkSizes)
- sb.AppendFormat("\tCurrent media has a {0} bytes link available", link).AppendLine();
+ if(ftr.LinkSizes == null) return sb.ToString();
+
+ foreach(byte link in ftr.LinkSizes)
+ sb.AppendFormat("\tCurrent media has a {0} bytes link available", link).AppendLine();
return sb.ToString();
}
@@ -4469,19 +4446,18 @@ namespace DiscImageChef.Decoders.SCSI.MMC
StringBuilder sb = new StringBuilder();
sb.AppendLine("Drive can write CD-RW");
- if(ftr.SubtypeSupport > 0)
- {
- sb.Append("\tDrive supports CD-RW subtypes");
- if((ftr.SubtypeSupport & 0x01) == 0x01) sb.Append(" 0");
- if((ftr.SubtypeSupport & 0x02) == 0x02) sb.Append(" 1");
- if((ftr.SubtypeSupport & 0x04) == 0x04) sb.Append(" 2");
- if((ftr.SubtypeSupport & 0x08) == 0x08) sb.Append(" 3");
- if((ftr.SubtypeSupport & 0x10) == 0x10) sb.Append(" 4");
- if((ftr.SubtypeSupport & 0x20) == 0x20) sb.Append(" 5");
- if((ftr.SubtypeSupport & 0x40) == 0x40) sb.Append(" 6");
- if((ftr.SubtypeSupport & 0x80) == 0x80) sb.Append(" 7");
- sb.AppendLine();
- }
+ if(ftr.SubtypeSupport <= 0) return sb.ToString();
+
+ sb.Append("\tDrive supports CD-RW subtypes");
+ if((ftr.SubtypeSupport & 0x01) == 0x01) sb.Append(" 0");
+ if((ftr.SubtypeSupport & 0x02) == 0x02) sb.Append(" 1");
+ if((ftr.SubtypeSupport & 0x04) == 0x04) sb.Append(" 2");
+ if((ftr.SubtypeSupport & 0x08) == 0x08) sb.Append(" 3");
+ if((ftr.SubtypeSupport & 0x10) == 0x10) sb.Append(" 4");
+ if((ftr.SubtypeSupport & 0x20) == 0x20) sb.Append(" 5");
+ if((ftr.SubtypeSupport & 0x40) == 0x40) sb.Append(" 6");
+ if((ftr.SubtypeSupport & 0x80) == 0x80) sb.Append(" 7");
+ sb.AppendLine();
return sb.ToString();
}
@@ -4722,12 +4698,11 @@ namespace DiscImageChef.Decoders.SCSI.MMC
sb.AppendLine("Drive supports Timeout & Protect mode page 1Dh");
- if(ftr.Group3)
- {
- sb.AppendLine("\tDrive supports the Group3 in Timeout & Protect mode page 1Dh");
- if(ftr.UnitLength > 0)
- sb.AppendFormat("\tDrive has {0} increase of Group 3 time unit", ftr.UnitLength).AppendLine();
- }
+ if(!ftr.Group3) return sb.ToString();
+
+ sb.AppendLine("\tDrive supports the Group3 in Timeout & Protect mode page 1Dh");
+ if(ftr.UnitLength > 0)
+ sb.AppendFormat("\tDrive has {0} increase of Group 3 time unit", ftr.UnitLength).AppendLine();
return sb.ToString();
}
@@ -4791,7 +4766,9 @@ namespace DiscImageChef.Decoders.SCSI.MMC
Feature_010A ftr = feature.Value;
StringBuilder sb = new StringBuilder();
- if(ftr.DCBs != null) foreach(uint DCB in ftr.DCBs) sb.AppendFormat("Drive supports DCB {0:X8}h", DCB).AppendLine();
+ if(ftr.DCBs == null) return sb.ToString();
+
+ foreach(uint DCB in ftr.DCBs) sb.AppendFormat("Drive supports DCB {0:X8}h", DCB).AppendLine();
return sb.ToString();
}
@@ -4946,9 +4923,10 @@ namespace DiscImageChef.Decoders.SCSI.MMC
if(ftr.LOSPB) sb.AppendLine("\tDrive supports linked OSPBs");
if(ftr.ME) sb.AppendLine("\tDrive will only record on the OSSC Disc Format");
- if(ftr.Profiles != null)
- for(int i = 0; i < ftr.Profiles.Length; i++)
- sb.AppendFormat("\tProfile {0}: {1}", i, ftr.Profiles[i]).AppendLine();
+ if(ftr.Profiles == null) return sb.ToString();
+
+ for(int i = 0; i < ftr.Profiles.Length; i++)
+ sb.AppendFormat("\tProfile {0}: {1}", i, ftr.Profiles[i]).AppendLine();
return sb.ToString();
}
diff --git a/DiscImageChef.Decoders/SCSI/Modes/00_SFF.cs b/DiscImageChef.Decoders/SCSI/Modes/00_SFF.cs
index 586708e52..70fa358c5 100644
--- a/DiscImageChef.Decoders/SCSI/Modes/00_SFF.cs
+++ b/DiscImageChef.Decoders/SCSI/Modes/00_SFF.cs
@@ -110,12 +110,11 @@ namespace DiscImageChef.Decoders.SCSI
if(page.DVW) sb.AppendLine("\tVerifying after writing is disabled");
if(page.DDE) sb.AppendLine("\tDrive will abort when a writing error is detected");
- if(page.SLM)
- {
- sb.Append("\tDrive has two LUNs with rewritable being ");
- if(page.SLM) sb.AppendLine("LUN 1");
- else sb.AppendLine("LUN 0");
- }
+ if(!page.SLM) return sb.ToString();
+
+ sb.Append("\tDrive has two LUNs with rewritable being ");
+ if(page.SLM) sb.AppendLine("LUN 1");
+ else sb.AppendLine("LUN 0");
return sb.ToString();
}
diff --git a/DiscImageChef.Decoders/SCSI/Modes/0E.cs b/DiscImageChef.Decoders/SCSI/Modes/0E.cs
index 4533bfdab..1a217234d 100644
--- a/DiscImageChef.Decoders/SCSI/Modes/0E.cs
+++ b/DiscImageChef.Decoders/SCSI/Modes/0E.cs
@@ -228,26 +228,25 @@ namespace DiscImageChef.Decoders.SCSI
}
}
- if(page.OutputPort3ChannelSelection > 0)
- {
- sb.Append("\tOutput port 3 has channels ");
- if((page.OutputPort3ChannelSelection & 0x01) == 0x01) sb.Append("0 ");
- if((page.OutputPort3ChannelSelection & 0x02) == 0x02) sb.Append("1 ");
- if((page.OutputPort3ChannelSelection & 0x04) == 0x04) sb.Append("2 ");
- if((page.OutputPort3ChannelSelection & 0x08) == 0x08) sb.Append("3 ");
+ if(page.OutputPort3ChannelSelection <= 0) return sb.ToString();
- switch(page.OutputPort3Volume)
- {
- case 0:
- sb.AppendLine("muted");
- break;
- case 0xFF:
- sb.AppendLine("at maximum volume");
- break;
- default:
- sb.AppendFormat("at volume {0}", page.OutputPort3Volume).AppendLine();
- break;
- }
+ sb.Append("\tOutput port 3 has channels ");
+ if((page.OutputPort3ChannelSelection & 0x01) == 0x01) sb.Append("0 ");
+ if((page.OutputPort3ChannelSelection & 0x02) == 0x02) sb.Append("1 ");
+ if((page.OutputPort3ChannelSelection & 0x04) == 0x04) sb.Append("2 ");
+ if((page.OutputPort3ChannelSelection & 0x08) == 0x08) sb.Append("3 ");
+
+ switch(page.OutputPort3Volume)
+ {
+ case 0:
+ sb.AppendLine("muted");
+ break;
+ case 0xFF:
+ sb.AppendLine("at maximum volume");
+ break;
+ default:
+ sb.AppendFormat("at volume {0}", page.OutputPort3Volume).AppendLine();
+ break;
}
return sb.ToString();
diff --git a/DiscImageChef.Decoders/SCSI/Modes/24_IBM.cs b/DiscImageChef.Decoders/SCSI/Modes/24_IBM.cs
index d87d66297..3a11d61df 100644
--- a/DiscImageChef.Decoders/SCSI/Modes/24_IBM.cs
+++ b/DiscImageChef.Decoders/SCSI/Modes/24_IBM.cs
@@ -91,11 +91,10 @@ namespace DiscImageChef.Decoders.SCSI
sb.AppendFormat("\tVendor-specific mode control: {0}", page.ModeControl);
sb.AppendFormat("\tVendor-specific velocity setting: {0}", page.VelocitySetting);
- if(page.EncryptionCapable)
- {
- sb.AppendLine("\tDrive supports encryption");
- if(page.EncryptionEnabled) sb.AppendLine("\tDrive has encryption enabled");
- }
+ if(!page.EncryptionCapable) return sb.ToString();
+
+ sb.AppendLine("\tDrive supports encryption");
+ if(page.EncryptionEnabled) sb.AppendLine("\tDrive has encryption enabled");
return sb.ToString();
}
diff --git a/DiscImageChef.Decoders/SCSI/Modes/Mode10.cs b/DiscImageChef.Decoders/SCSI/Modes/Mode10.cs
index 194b6f056..7202acd49 100644
--- a/DiscImageChef.Decoders/SCSI/Modes/Mode10.cs
+++ b/DiscImageChef.Decoders/SCSI/Modes/Mode10.cs
@@ -236,37 +236,38 @@ namespace DiscImageChef.Decoders.SCSI
if(longLBA) hdr[4] += 0x01;
- if(header.BlockDescriptors != null)
- if(longLBA)
- for(int i = 0; i < header.BlockDescriptors.Length; i++)
- {
- byte[] temp = BitConverter.GetBytes(header.BlockDescriptors[i].Blocks);
- hdr[7 + i * 16 + 8] = temp[0];
- hdr[6 + i * 16 + 8] = temp[1];
- hdr[5 + i * 16 + 8] = temp[2];
- hdr[4 + i * 16 + 8] = temp[3];
- hdr[3 + i * 16 + 8] = temp[4];
- hdr[2 + i * 16 + 8] = temp[5];
- hdr[1 + i * 16 + 8] = temp[6];
- hdr[0 + i * 16 + 8] = temp[7];
- hdr[12 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF000000) >> 24);
- hdr[13 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
- hdr[14 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
- hdr[15 + i * 16 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
- }
- else
- for(int i = 0; i < header.BlockDescriptors.Length; i++)
- {
- if(deviceType != PeripheralDeviceTypes.DirectAccess)
- hdr[0 + i * 8 + 8] = (byte)header.BlockDescriptors[i].Density;
- else hdr[0 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF000000) >> 24);
- hdr[1 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
- hdr[2 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
- hdr[3 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
- hdr[5 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
- hdr[6 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
- hdr[7 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
- }
+ if(header.BlockDescriptors == null) return hdr;
+
+ if(longLBA)
+ for(int i = 0; i < header.BlockDescriptors.Length; i++)
+ {
+ byte[] temp = BitConverter.GetBytes(header.BlockDescriptors[i].Blocks);
+ hdr[7 + i * 16 + 8] = temp[0];
+ hdr[6 + i * 16 + 8] = temp[1];
+ hdr[5 + i * 16 + 8] = temp[2];
+ hdr[4 + i * 16 + 8] = temp[3];
+ hdr[3 + i * 16 + 8] = temp[4];
+ hdr[2 + i * 16 + 8] = temp[5];
+ hdr[1 + i * 16 + 8] = temp[6];
+ hdr[0 + i * 16 + 8] = temp[7];
+ hdr[12 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF000000) >> 24);
+ hdr[13 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
+ hdr[14 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
+ hdr[15 + i * 16 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
+ }
+ else
+ for(int i = 0; i < header.BlockDescriptors.Length; i++)
+ {
+ if(deviceType != PeripheralDeviceTypes.DirectAccess)
+ hdr[0 + i * 8 + 8] = (byte)header.BlockDescriptors[i].Density;
+ else hdr[0 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF000000) >> 24);
+ hdr[1 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
+ hdr[2 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
+ hdr[3 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
+ hdr[5 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
+ hdr[6 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
+ hdr[7 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
+ }
return hdr;
}
@@ -282,7 +283,8 @@ namespace DiscImageChef.Decoders.SCSI
Array.Copy(hdr, 0, md, 0, hdr.Length);
- if(mode.Pages != null)
+ if(mode.Pages == null) return md;
+
{
int offset = hdr.Length;
foreach(ModePage page in mode.Pages)
diff --git a/DiscImageChef.Decoders/SCSI/Modes/Mode6.cs b/DiscImageChef.Decoders/SCSI/Modes/Mode6.cs
index 95a166f68..fc691e0c2 100644
--- a/DiscImageChef.Decoders/SCSI/Modes/Mode6.cs
+++ b/DiscImageChef.Decoders/SCSI/Modes/Mode6.cs
@@ -184,20 +184,19 @@ namespace DiscImageChef.Decoders.SCSI
break;
}
- if(header.BlockDescriptors != null)
- {
- hdr[3] = (byte)(header.BlockDescriptors.Length * 8);
+ if(header.BlockDescriptors == null) return hdr;
- for(int i = 0; i < header.BlockDescriptors.Length; i++)
- {
- hdr[0 + i * 8 + 4] = (byte)header.BlockDescriptors[i].Density;
- hdr[1 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
- hdr[2 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
- hdr[3 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
- hdr[5 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
- hdr[6 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
- hdr[7 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
- }
+ hdr[3] = (byte)(header.BlockDescriptors.Length * 8);
+
+ for(int i = 0; i < header.BlockDescriptors.Length; i++)
+ {
+ hdr[0 + i * 8 + 4] = (byte)header.BlockDescriptors[i].Density;
+ hdr[1 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
+ hdr[2 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
+ hdr[3 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
+ hdr[5 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
+ hdr[6 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
+ hdr[7 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
}
return hdr;
@@ -214,7 +213,8 @@ namespace DiscImageChef.Decoders.SCSI
Array.Copy(hdr, 0, md, 0, hdr.Length);
- if(mode.Pages != null)
+ if(mode.Pages == null) return md;
+
{
int offset = hdr.Length;
foreach(ModePage page in mode.Pages)
diff --git a/DiscImageChef.Decoders/SCSI/Sense.cs b/DiscImageChef.Decoders/SCSI/Sense.cs
index d898bda58..fbe505322 100644
--- a/DiscImageChef.Decoders/SCSI/Sense.cs
+++ b/DiscImageChef.Decoders/SCSI/Sense.cs
@@ -301,11 +301,10 @@ namespace DiscImageChef.Decoders.SCSI
if(sense.Length >= 18) decoded.SenseKeySpecific = (uint)((sense[15] << 16) + (sense[16] << 8) + sense[17]);
- if(sense.Length > 18)
- {
- decoded.AdditionalSense = new byte[sense.Length - 18];
- Array.Copy(sense, 18, decoded.AdditionalSense, 0, decoded.AdditionalSense.Length);
- }
+ if(sense.Length <= 18) return decoded;
+
+ decoded.AdditionalSense = new byte[sense.Length - 18];
+ Array.Copy(sense, 18, decoded.AdditionalSense, 0, decoded.AdditionalSense.Length);
return decoded;
}
@@ -398,33 +397,34 @@ namespace DiscImageChef.Decoders.SCSI
if(decoded.AdditionalLength < 10) return sb.ToString();
- if(decoded.SKSV)
- switch(decoded.SenseKey)
- {
- case SenseKeys.IllegalRequest:
- {
- if((decoded.SenseKeySpecific & 0x400000) == 0x400000) sb.AppendLine("Illegal field in CDB");
- else sb.AppendLine("Illegal field in data parameters");
+ if(!decoded.SKSV) return sb.ToString();
- if((decoded.SenseKeySpecific & 0x200000) == 0x200000)
- sb.AppendFormat("Invalid value in bit {0} in field {1} of CDB",
- (decoded.SenseKeySpecific & 0x70000) >> 16,
- decoded.SenseKeySpecific & 0xFFFF).AppendLine();
- else
- sb.AppendFormat("Invalid value in field {0} of CDB", decoded.SenseKeySpecific & 0xFFFF)
- .AppendLine();
- }
- break;
- case SenseKeys.NotReady:
- sb.AppendFormat("Format progress {0:P}", (double)(decoded.SenseKeySpecific & 0xFFFF) / 65536)
+ switch(decoded.SenseKey)
+ {
+ case SenseKeys.IllegalRequest:
+ {
+ if((decoded.SenseKeySpecific & 0x400000) == 0x400000) sb.AppendLine("Illegal field in CDB");
+ else sb.AppendLine("Illegal field in data parameters");
+
+ if((decoded.SenseKeySpecific & 0x200000) == 0x200000)
+ sb.AppendFormat("Invalid value in bit {0} in field {1} of CDB",
+ (decoded.SenseKeySpecific & 0x70000) >> 16,
+ decoded.SenseKeySpecific & 0xFFFF).AppendLine();
+ else
+ sb.AppendFormat("Invalid value in field {0} of CDB", decoded.SenseKeySpecific & 0xFFFF)
.AppendLine();
- break;
- case SenseKeys.RecoveredError:
- case SenseKeys.HardwareError:
- case SenseKeys.MediumError:
- sb.AppendFormat("Actual retry count is {0}", decoded.SenseKeySpecific & 0xFFFF).AppendLine();
- break;
}
+ break;
+ case SenseKeys.NotReady:
+ sb.AppendFormat("Format progress {0:P}", (double)(decoded.SenseKeySpecific & 0xFFFF) / 65536)
+ .AppendLine();
+ break;
+ case SenseKeys.RecoveredError:
+ case SenseKeys.HardwareError:
+ case SenseKeys.MediumError:
+ sb.AppendFormat("Actual retry count is {0}", decoded.SenseKeySpecific & 0xFFFF).AppendLine();
+ break;
+ }
return sb.ToString();
}
diff --git a/DiscImageChef.Devices/Device/Commands.cs b/DiscImageChef.Devices/Device/Commands.cs
index e8092b0a6..78233a279 100644
--- a/DiscImageChef.Devices/Device/Commands.cs
+++ b/DiscImageChef.Devices/Device/Commands.cs
@@ -173,8 +173,11 @@ namespace DiscImageChef.Devices
}
}
- if((command == (MmcCommands)SecureDigitalCommands.SendOperatingCondition ||
- command == MmcCommands.SendOpCond) && cachedOcr != null)
+ if((command != (MmcCommands)SecureDigitalCommands.SendOperatingCondition &&
+ command != MmcCommands.SendOpCond) || cachedOcr == null)
+ return Command.SendMmcCommand(platformId, fd, command, write, isApplication, flags, argument, blockSize,
+ blocks, ref buffer, out response, out duration, out sense, timeout);
+
{
System.DateTime start = System.DateTime.Now;
buffer = new byte[cachedOcr.Length];
@@ -185,9 +188,6 @@ namespace DiscImageChef.Devices
duration = (end - start).TotalMilliseconds;
return 0;
}
-
- return Command.SendMmcCommand(platformId, fd, command, write, isApplication, flags, argument, blockSize,
- blocks, ref buffer, out response, out duration, out sense, timeout);
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Devices/Device/Constructor.cs b/DiscImageChef.Devices/Device/Constructor.cs
index 8dac57150..fbeaed039 100644
--- a/DiscImageChef.Devices/Device/Constructor.cs
+++ b/DiscImageChef.Devices/Device/Constructor.cs
@@ -383,59 +383,58 @@ namespace DiscImageChef.Devices
while(resolvedLink.Contains("usb"))
{
resolvedLink = System.IO.Path.GetDirectoryName(resolvedLink);
- if(System.IO.File.Exists(resolvedLink + "/descriptors") &&
- System.IO.File.Exists(resolvedLink + "/idProduct") &&
- System.IO.File.Exists(resolvedLink + "/idVendor"))
+ if(!System.IO.File.Exists(resolvedLink + "/descriptors") ||
+ !System.IO.File.Exists(resolvedLink + "/idProduct") ||
+ !System.IO.File.Exists(resolvedLink + "/idVendor")) continue;
+
+ System.IO.FileStream usbFs;
+ System.IO.StreamReader usbSr;
+ string usbTemp;
+
+ usbFs = new System.IO.FileStream(resolvedLink + "/descriptors",
+ System.IO.FileMode.Open,
+ System.IO.FileAccess.Read);
+ byte[] usbBuf = new byte[65536];
+ int usbCount = usbFs.Read(usbBuf, 0, 65536);
+ usbDescriptors = new byte[usbCount];
+ Array.Copy(usbBuf, 0, usbDescriptors, 0, usbCount);
+ usbFs.Close();
+
+ usbSr = new System.IO.StreamReader(resolvedLink + "/idProduct");
+ usbTemp = usbSr.ReadToEnd();
+ ushort.TryParse(usbTemp, System.Globalization.NumberStyles.HexNumber,
+ System.Globalization.CultureInfo.InvariantCulture, out usbProduct);
+ usbSr.Close();
+
+ usbSr = new System.IO.StreamReader(resolvedLink + "/idVendor");
+ usbTemp = usbSr.ReadToEnd();
+ ushort.TryParse(usbTemp, System.Globalization.NumberStyles.HexNumber,
+ System.Globalization.CultureInfo.InvariantCulture, out usbVendor);
+ usbSr.Close();
+
+ if(System.IO.File.Exists(resolvedLink + "/manufacturer"))
{
- System.IO.FileStream usbFs;
- System.IO.StreamReader usbSr;
- string usbTemp;
-
- usbFs = new System.IO.FileStream(resolvedLink + "/descriptors",
- System.IO.FileMode.Open,
- System.IO.FileAccess.Read);
- byte[] usbBuf = new byte[65536];
- int usbCount = usbFs.Read(usbBuf, 0, 65536);
- usbDescriptors = new byte[usbCount];
- Array.Copy(usbBuf, 0, usbDescriptors, 0, usbCount);
- usbFs.Close();
-
- usbSr = new System.IO.StreamReader(resolvedLink + "/idProduct");
- usbTemp = usbSr.ReadToEnd();
- ushort.TryParse(usbTemp, System.Globalization.NumberStyles.HexNumber,
- System.Globalization.CultureInfo.InvariantCulture, out usbProduct);
+ usbSr = new System.IO.StreamReader(resolvedLink + "/manufacturer");
+ usbManufacturerString = usbSr.ReadToEnd().Trim();
usbSr.Close();
-
- usbSr = new System.IO.StreamReader(resolvedLink + "/idVendor");
- usbTemp = usbSr.ReadToEnd();
- ushort.TryParse(usbTemp, System.Globalization.NumberStyles.HexNumber,
- System.Globalization.CultureInfo.InvariantCulture, out usbVendor);
- usbSr.Close();
-
- if(System.IO.File.Exists(resolvedLink + "/manufacturer"))
- {
- usbSr = new System.IO.StreamReader(resolvedLink + "/manufacturer");
- usbManufacturerString = usbSr.ReadToEnd().Trim();
- usbSr.Close();
- }
-
- if(System.IO.File.Exists(resolvedLink + "/product"))
- {
- usbSr = new System.IO.StreamReader(resolvedLink + "/product");
- usbProductString = usbSr.ReadToEnd().Trim();
- usbSr.Close();
- }
-
- if(System.IO.File.Exists(resolvedLink + "/serial"))
- {
- usbSr = new System.IO.StreamReader(resolvedLink + "/serial");
- usbSerialString = usbSr.ReadToEnd().Trim();
- usbSr.Close();
- }
-
- usb = true;
- break;
}
+
+ if(System.IO.File.Exists(resolvedLink + "/product"))
+ {
+ usbSr = new System.IO.StreamReader(resolvedLink + "/product");
+ usbProductString = usbSr.ReadToEnd().Trim();
+ usbSr.Close();
+ }
+
+ if(System.IO.File.Exists(resolvedLink + "/serial"))
+ {
+ usbSr = new System.IO.StreamReader(resolvedLink + "/serial");
+ usbSerialString = usbSr.ReadToEnd().Trim();
+ usbSr.Close();
+ }
+
+ usb = true;
+ break;
}
}
}
@@ -487,49 +486,48 @@ namespace DiscImageChef.Devices
while(resolvedLink.Contains("firewire"))
{
resolvedLink = System.IO.Path.GetDirectoryName(resolvedLink);
- if(System.IO.File.Exists(resolvedLink + "/model") &&
- System.IO.File.Exists(resolvedLink + "/vendor") &&
- System.IO.File.Exists(resolvedLink + "/guid"))
+ if(!System.IO.File.Exists(resolvedLink + "/model") ||
+ !System.IO.File.Exists(resolvedLink + "/vendor") ||
+ !System.IO.File.Exists(resolvedLink + "/guid")) continue;
+
+ System.IO.StreamReader fwSr;
+ string fwTemp;
+
+ fwSr = new System.IO.StreamReader(resolvedLink + "/model");
+ fwTemp = fwSr.ReadToEnd();
+ uint.TryParse(fwTemp, System.Globalization.NumberStyles.HexNumber,
+ System.Globalization.CultureInfo.InvariantCulture, out firewireModel);
+ fwSr.Close();
+
+ fwSr = new System.IO.StreamReader(resolvedLink + "/vendor");
+ fwTemp = fwSr.ReadToEnd();
+ uint.TryParse(fwTemp, System.Globalization.NumberStyles.HexNumber,
+ System.Globalization.CultureInfo.InvariantCulture,
+ out firewireVendor);
+ fwSr.Close();
+
+ fwSr = new System.IO.StreamReader(resolvedLink + "/guid");
+ fwTemp = fwSr.ReadToEnd();
+ ulong.TryParse(fwTemp, System.Globalization.NumberStyles.HexNumber,
+ System.Globalization.CultureInfo.InvariantCulture, out firewireGuid);
+ fwSr.Close();
+
+ if(System.IO.File.Exists(resolvedLink + "/model_name"))
{
- System.IO.StreamReader fwSr;
- string fwTemp;
-
- fwSr = new System.IO.StreamReader(resolvedLink + "/model");
- fwTemp = fwSr.ReadToEnd();
- uint.TryParse(fwTemp, System.Globalization.NumberStyles.HexNumber,
- System.Globalization.CultureInfo.InvariantCulture, out firewireModel);
+ fwSr = new System.IO.StreamReader(resolvedLink + "/model_name");
+ firewireModelName = fwSr.ReadToEnd().Trim();
fwSr.Close();
-
- fwSr = new System.IO.StreamReader(resolvedLink + "/vendor");
- fwTemp = fwSr.ReadToEnd();
- uint.TryParse(fwTemp, System.Globalization.NumberStyles.HexNumber,
- System.Globalization.CultureInfo.InvariantCulture,
- out firewireVendor);
- fwSr.Close();
-
- fwSr = new System.IO.StreamReader(resolvedLink + "/guid");
- fwTemp = fwSr.ReadToEnd();
- ulong.TryParse(fwTemp, System.Globalization.NumberStyles.HexNumber,
- System.Globalization.CultureInfo.InvariantCulture, out firewireGuid);
- fwSr.Close();
-
- if(System.IO.File.Exists(resolvedLink + "/model_name"))
- {
- fwSr = new System.IO.StreamReader(resolvedLink + "/model_name");
- firewireModelName = fwSr.ReadToEnd().Trim();
- fwSr.Close();
- }
-
- if(System.IO.File.Exists(resolvedLink + "/vendor_name"))
- {
- fwSr = new System.IO.StreamReader(resolvedLink + "/vendor_name");
- firewireVendorName = fwSr.ReadToEnd().Trim();
- fwSr.Close();
- }
-
- firewire = true;
- break;
}
+
+ if(System.IO.File.Exists(resolvedLink + "/vendor_name"))
+ {
+ fwSr = new System.IO.StreamReader(resolvedLink + "/vendor_name");
+ firewireVendorName = fwSr.ReadToEnd().Trim();
+ fwSr.Close();
+ }
+
+ firewire = true;
+ break;
}
}
}
@@ -554,36 +552,33 @@ namespace DiscImageChef.Devices
while(resolvedLink.Contains("/sys/devices"))
{
resolvedLink = System.IO.Path.GetDirectoryName(resolvedLink);
- if(System.IO.Directory.Exists(resolvedLink + "/pcmcia_socket"))
- {
- string[] subdirs =
- System.IO.Directory.GetDirectories(resolvedLink + "/pcmcia_socket",
- "pcmcia_socket*",
- System.IO.SearchOption.TopDirectoryOnly);
+ if(!System.IO.Directory.Exists(resolvedLink + "/pcmcia_socket")) continue;
- if(subdirs.Length > 0)
- {
- string possibleDir =
- System.IO.Path.Combine(resolvedLink, "pcmcia_socket", subdirs[0]);
- if(System.IO.File.Exists(possibleDir + "/card_type") &&
- System.IO.File.Exists(possibleDir + "/cis"))
- {
- System.IO.FileStream cisFs;
+ string[] subdirs =
+ System.IO.Directory.GetDirectories(resolvedLink + "/pcmcia_socket",
+ "pcmcia_socket*",
+ System.IO.SearchOption.TopDirectoryOnly);
- cisFs = new System.IO.FileStream(possibleDir + "/cis",
- System.IO.FileMode.Open,
- System.IO.FileAccess.Read);
- byte[] cisBuf = new byte[65536];
- int cisCount = cisFs.Read(cisBuf, 0, 65536);
- cis = new byte[cisCount];
- Array.Copy(cisBuf, 0, cis, 0, cisCount);
- cisFs.Close();
+ if(subdirs.Length <= 0) continue;
- pcmcia = true;
- break;
- }
- }
- }
+ string possibleDir =
+ System.IO.Path.Combine(resolvedLink, "pcmcia_socket", subdirs[0]);
+ if(!System.IO.File.Exists(possibleDir + "/card_type") ||
+ !System.IO.File.Exists(possibleDir + "/cis")) continue;
+
+ System.IO.FileStream cisFs;
+
+ cisFs = new System.IO.FileStream(possibleDir + "/cis",
+ System.IO.FileMode.Open,
+ System.IO.FileAccess.Read);
+ byte[] cisBuf = new byte[65536];
+ int cisCount = cisFs.Read(cisBuf, 0, 65536);
+ cis = new byte[cisCount];
+ Array.Copy(cisBuf, 0, cis, 0, cisCount);
+ cisFs.Close();
+
+ pcmcia = true;
+ break;
}
}
}
@@ -678,13 +673,12 @@ namespace DiscImageChef.Devices
else foreach(char c in serial) if(char.IsControl(c)) serial = usbSerialString;
}
- if(firewire)
- {
- if(string.IsNullOrEmpty(manufacturer)) manufacturer = firewireVendorName;
- if(string.IsNullOrEmpty(model)) model = firewireModelName;
- if(string.IsNullOrEmpty(serial)) serial = string.Format("{0:X16}", firewireGuid);
- else foreach(char c in serial) if(char.IsControl(c)) serial = string.Format("{0:X16}", firewireGuid);
- }
+ if(!firewire) return;
+
+ if(string.IsNullOrEmpty(manufacturer)) manufacturer = firewireVendorName;
+ if(string.IsNullOrEmpty(model)) model = firewireModelName;
+ if(string.IsNullOrEmpty(serial)) serial = string.Format("{0:X16}", firewireGuid);
+ else foreach(char c in serial) if(char.IsControl(c)) serial = string.Format("{0:X16}", firewireGuid);
}
static int ConvertFromHexAscii(string file, out byte[] outBuf)
diff --git a/DiscImageChef.Devices/Device/Destructor.cs b/DiscImageChef.Devices/Device/Destructor.cs
index 34ecd47b5..69295e1b3 100644
--- a/DiscImageChef.Devices/Device/Destructor.cs
+++ b/DiscImageChef.Devices/Device/Destructor.cs
@@ -43,19 +43,20 @@ namespace DiscImageChef.Devices
///
~Device()
{
- if(fd != null)
- switch(platformId)
- {
- case Interop.PlatformID.Win32NT:
- Windows.Extern.CloseHandle((SafeFileHandle)fd);
- break;
- case Interop.PlatformID.Linux:
- Linux.Extern.close((int)fd);
- break;
- case Interop.PlatformID.FreeBSD:
- FreeBSD.Extern.cam_close_device((IntPtr)fd);
- break;
- }
+ if(fd == null) return;
+
+ switch(platformId)
+ {
+ case Interop.PlatformID.Win32NT:
+ Windows.Extern.CloseHandle((SafeFileHandle)fd);
+ break;
+ case Interop.PlatformID.Linux:
+ Linux.Extern.close((int)fd);
+ break;
+ case Interop.PlatformID.FreeBSD:
+ FreeBSD.Extern.cam_close_device((IntPtr)fd);
+ break;
+ }
}
}
}
\ No newline at end of file
diff --git a/DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs b/DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs
index 63765b26c..6c7a7da50 100644
--- a/DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs
+++ b/DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs
@@ -233,13 +233,12 @@ namespace DiscImageChef.Devices
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR POWEREC GET SPEEDS took {0} ms.", duration);
- if(!sense && !error)
- {
- BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- selected = BigEndianBitConverter.ToUInt16(buf, 4);
- max = BigEndianBitConverter.ToUInt16(buf, 6);
- last = BigEndianBitConverter.ToUInt16(buf, 8);
- }
+ if(sense || error) return sense;
+
+ BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
+ selected = BigEndianBitConverter.ToUInt16(buf, 4);
+ max = BigEndianBitConverter.ToUInt16(buf, 6);
+ last = BigEndianBitConverter.ToUInt16(buf, 8);
return sense;
}
@@ -274,12 +273,11 @@ namespace DiscImageChef.Devices
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR POWEREC GET SPEEDS took {0} ms.", duration);
- if(!sense && !error)
- {
- BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- enabled = buf[2] != 0;
- speed = BigEndianBitConverter.ToUInt16(buf, 4);
- }
+ if(sense || error) return sense;
+
+ BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
+ enabled = buf[2] != 0;
+ speed = BigEndianBitConverter.ToUInt16(buf, 4);
return sense;
}
diff --git a/DiscImageChef.Devices/Windows/Usb.cs b/DiscImageChef.Devices/Windows/Usb.cs
index f93155ed9..ea20b1e3a 100644
--- a/DiscImageChef.Devices/Windows/Usb.cs
+++ b/DiscImageChef.Devices/Windows/Usb.cs
@@ -494,57 +494,57 @@ namespace DiscImageChef.Devices.Windows
// We start at the "root" of the device tree and look for all
// devices that match the interface GUID of a Hub Controller
IntPtr h = SetupDiGetClassDevs(ref hostGuid, 0, IntPtr.Zero, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
- if(h.ToInt32() != INVALID_HANDLE_VALUE)
+ if(h.ToInt32() == INVALID_HANDLE_VALUE)
+ return new System.Collections.ObjectModel.ReadOnlyCollection(hostList);
+
+ IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
+ bool success;
+ int i = 0;
+ do
{
- IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
- bool success;
- int i = 0;
- do
+ UsbController host = new UsbController();
+ host.ControllerIndex = i;
+
+ // create a Device Interface Data structure
+ SpDeviceInterfaceData dia = new SpDeviceInterfaceData();
+ dia.cbSize = Marshal.SizeOf(dia);
+
+ // start the enumeration
+ success = SetupDiEnumDeviceInterfaces(h, IntPtr.Zero, ref hostGuid, i, ref dia);
+ if(success)
{
- UsbController host = new UsbController();
- host.ControllerIndex = i;
+ // build a DevInfo Data structure
+ SpDevinfoData da = new SpDevinfoData();
+ da.cbSize = Marshal.SizeOf(da);
- // create a Device Interface Data structure
- SpDeviceInterfaceData dia = new SpDeviceInterfaceData();
- dia.cbSize = Marshal.SizeOf(dia);
+ // build a Device Interface Detail Data structure
+ SpDeviceInterfaceDetailData didd = new SpDeviceInterfaceDetailData();
+ didd.cbSize = 4 + Marshal.SystemDefaultCharSize; // trust me :)
- // start the enumeration
- success = SetupDiEnumDeviceInterfaces(h, IntPtr.Zero, ref hostGuid, i, ref dia);
- if(success)
+ // now we can get some more detailed information
+ int nRequiredSize = 0;
+ int nBytes = BUFFER_SIZE;
+ if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, nBytes, ref nRequiredSize, ref da))
{
- // build a DevInfo Data structure
- SpDevinfoData da = new SpDevinfoData();
- da.cbSize = Marshal.SizeOf(da);
+ host.ControllerDevicePath = didd.DevicePath;
- // build a Device Interface Detail Data structure
- SpDeviceInterfaceDetailData didd = new SpDeviceInterfaceDetailData();
- didd.cbSize = 4 + Marshal.SystemDefaultCharSize; // trust me :)
+ // get the Device Description and DriverKeyName
+ int requiredSize = 0;
+ int regType = REG_SZ;
- // now we can get some more detailed information
- int nRequiredSize = 0;
- int nBytes = BUFFER_SIZE;
- if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, nBytes, ref nRequiredSize, ref da))
- {
- host.ControllerDevicePath = didd.DevicePath;
-
- // get the Device Description and DriverKeyName
- int requiredSize = 0;
- int regType = REG_SZ;
-
- if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref regType, ptrBuf,
- BUFFER_SIZE, ref requiredSize)) host.ControllerDeviceDesc = Marshal.PtrToStringAuto(ptrBuf);
- if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf,
- BUFFER_SIZE, ref requiredSize)) host.ControllerDriverKeyName = Marshal.PtrToStringAuto(ptrBuf);
- }
- hostList.Add(host);
+ if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref regType, ptrBuf,
+ BUFFER_SIZE, ref requiredSize)) host.ControllerDeviceDesc = Marshal.PtrToStringAuto(ptrBuf);
+ if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf,
+ BUFFER_SIZE, ref requiredSize)) host.ControllerDriverKeyName = Marshal.PtrToStringAuto(ptrBuf);
}
- i++;
+ hostList.Add(host);
}
- while(success);
-
- Marshal.FreeHGlobal(ptrBuf);
- SetupDiDestroyDeviceInfoList(h);
+ i++;
}
+ while(success);
+
+ Marshal.FreeHGlobal(ptrBuf);
+ SetupDiDestroyDeviceInfoList(h);
// convert it into a Collection
return new System.Collections.ObjectModel.ReadOnlyCollection(hostList);
@@ -602,50 +602,49 @@ namespace DiscImageChef.Devices.Windows
// Open a handle to the Host Controller
h = CreateFile(ControllerDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr.Zero);
- if(h.ToInt32() != INVALID_HANDLE_VALUE)
- {
- int nBytesReturned;
- UsbRootHubName hubName = new UsbRootHubName();
- int nBytes = Marshal.SizeOf(hubName);
- IntPtr ptrHubName = Marshal.AllocHGlobal(nBytes);
+ if(h.ToInt32() == INVALID_HANDLE_VALUE) return root;
- // get the Hub Name
- if(DeviceIoControl(h, IOCTL_USB_GET_ROOT_HUB_NAME, ptrHubName, nBytes, ptrHubName, nBytes,
+ int nBytesReturned;
+ UsbRootHubName hubName = new UsbRootHubName();
+ int nBytes = Marshal.SizeOf(hubName);
+ IntPtr ptrHubName = Marshal.AllocHGlobal(nBytes);
+
+ // get the Hub Name
+ if(DeviceIoControl(h, IOCTL_USB_GET_ROOT_HUB_NAME, ptrHubName, nBytes, ptrHubName, nBytes,
+ out nBytesReturned, IntPtr.Zero))
+ {
+ hubName = (UsbRootHubName)Marshal.PtrToStructure(ptrHubName, typeof(UsbRootHubName));
+ root.HubDevicePath = @"\\.\" + hubName.RootHubName;
+ }
+
+ // TODO: Get DriverKeyName for Root Hub
+
+ // Now let's open the Hub (based upon the HubName we got above)
+ h2 = CreateFile(root.HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
+ IntPtr.Zero);
+ if(h2.ToInt32() != INVALID_HANDLE_VALUE)
+ {
+ UsbNodeInformation nodeInfo = new UsbNodeInformation();
+ nodeInfo.NodeType = (int)UsbHubNode.UsbHub;
+ nBytes = Marshal.SizeOf(nodeInfo);
+ IntPtr ptrNodeInfo = Marshal.AllocHGlobal(nBytes);
+ Marshal.StructureToPtr(nodeInfo, ptrNodeInfo, true);
+
+ // get the Hub Information
+ if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes,
out nBytesReturned, IntPtr.Zero))
{
- hubName = (UsbRootHubName)Marshal.PtrToStructure(ptrHubName, typeof(UsbRootHubName));
- root.HubDevicePath = @"\\.\" + hubName.RootHubName;
+ nodeInfo = (UsbNodeInformation)Marshal.PtrToStructure(ptrNodeInfo,
+ typeof(UsbNodeInformation));
+ root.HubIsBusPowered = Convert.ToBoolean(nodeInfo.HubInformation.HubIsBusPowered);
+ root.HubPortCount = nodeInfo.HubInformation.HubDescriptor.bNumberOfPorts;
}
-
- // TODO: Get DriverKeyName for Root Hub
-
- // Now let's open the Hub (based upon the HubName we got above)
- h2 = CreateFile(root.HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
- IntPtr.Zero);
- if(h2.ToInt32() != INVALID_HANDLE_VALUE)
- {
- UsbNodeInformation nodeInfo = new UsbNodeInformation();
- nodeInfo.NodeType = (int)UsbHubNode.UsbHub;
- nBytes = Marshal.SizeOf(nodeInfo);
- IntPtr ptrNodeInfo = Marshal.AllocHGlobal(nBytes);
- Marshal.StructureToPtr(nodeInfo, ptrNodeInfo, true);
-
- // get the Hub Information
- if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes,
- out nBytesReturned, IntPtr.Zero))
- {
- nodeInfo = (UsbNodeInformation)Marshal.PtrToStructure(ptrNodeInfo,
- typeof(UsbNodeInformation));
- root.HubIsBusPowered = Convert.ToBoolean(nodeInfo.HubInformation.HubIsBusPowered);
- root.HubPortCount = nodeInfo.HubInformation.HubDescriptor.bNumberOfPorts;
- }
- Marshal.FreeHGlobal(ptrNodeInfo);
- CloseHandle(h2);
- }
-
- Marshal.FreeHGlobal(ptrHubName);
- CloseHandle(h);
+ Marshal.FreeHGlobal(ptrNodeInfo);
+ CloseHandle(h2);
}
+
+ Marshal.FreeHGlobal(ptrHubName);
+ CloseHandle(h);
return root;
}
}
@@ -740,50 +739,49 @@ namespace DiscImageChef.Devices.Windows
// Open a handle to the Hub device
IntPtr h = CreateFile(HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr.Zero);
- if(h.ToInt32() != INVALID_HANDLE_VALUE)
+ if(h.ToInt32() == INVALID_HANDLE_VALUE)
+ return new System.Collections.ObjectModel.ReadOnlyCollection(portList);
+
+ int nBytes = Marshal.SizeOf(typeof(UsbNodeConnectionInformationEx));
+ IntPtr ptrNodeConnection = Marshal.AllocHGlobal(nBytes);
+
+ // loop thru all of the ports on the hub
+ // BTW: Ports are numbered starting at 1
+ for(int i = 1; i <= HubPortCount; i++)
{
- int nBytes = Marshal.SizeOf(typeof(UsbNodeConnectionInformationEx));
- IntPtr ptrNodeConnection = Marshal.AllocHGlobal(nBytes);
+ int nBytesReturned;
+ UsbNodeConnectionInformationEx nodeConnection = new UsbNodeConnectionInformationEx();
+ nodeConnection.ConnectionIndex = i;
+ Marshal.StructureToPtr(nodeConnection, ptrNodeConnection, true);
- // loop thru all of the ports on the hub
- // BTW: Ports are numbered starting at 1
- for(int i = 1; i <= HubPortCount; i++)
- {
- int nBytesReturned;
- UsbNodeConnectionInformationEx nodeConnection = new UsbNodeConnectionInformationEx();
- nodeConnection.ConnectionIndex = i;
- Marshal.StructureToPtr(nodeConnection, ptrNodeConnection, true);
+ if(!DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptrNodeConnection, nBytes,
+ ptrNodeConnection, nBytes, out nBytesReturned, IntPtr.Zero)) continue;
- if(DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptrNodeConnection, nBytes,
- ptrNodeConnection, nBytes, out nBytesReturned, IntPtr.Zero))
- {
- nodeConnection =
- (UsbNodeConnectionInformationEx)Marshal.PtrToStructure(ptrNodeConnection,
- typeof(
- UsbNodeConnectionInformationEx
- ));
+ nodeConnection =
+ (UsbNodeConnectionInformationEx)Marshal.PtrToStructure(ptrNodeConnection,
+ typeof(
+ UsbNodeConnectionInformationEx
+ ));
- // load up the USBPort class
- UsbPort port = new UsbPort();
- port.PortPortNumber = i;
- port.PortHubDevicePath = HubDevicePath;
- UsbConnectionStatus status = (UsbConnectionStatus)nodeConnection.ConnectionStatus;
- port.PortStatus = status.ToString();
- UsbDeviceSpeed speed = (UsbDeviceSpeed)nodeConnection.Speed;
- port.PortSpeed = speed.ToString();
- port.PortIsDeviceConnected =
- nodeConnection.ConnectionStatus == (int)UsbConnectionStatus.DeviceConnected;
- port.PortIsHub = Convert.ToBoolean(nodeConnection.DeviceIsHub);
- port.PortDeviceDescriptor = nodeConnection.DeviceDescriptor;
+ // load up the USBPort class
+ UsbPort port = new UsbPort();
+ port.PortPortNumber = i;
+ port.PortHubDevicePath = HubDevicePath;
+ UsbConnectionStatus status = (UsbConnectionStatus)nodeConnection.ConnectionStatus;
+ port.PortStatus = status.ToString();
+ UsbDeviceSpeed speed = (UsbDeviceSpeed)nodeConnection.Speed;
+ port.PortSpeed = speed.ToString();
+ port.PortIsDeviceConnected =
+ nodeConnection.ConnectionStatus == (int)UsbConnectionStatus.DeviceConnected;
+ port.PortIsHub = Convert.ToBoolean(nodeConnection.DeviceIsHub);
+ port.PortDeviceDescriptor = nodeConnection.DeviceDescriptor;
- // add it to the list
- portList.Add(port);
- }
- }
-
- Marshal.FreeHGlobal(ptrNodeConnection);
- CloseHandle(h);
+ // add it to the list
+ portList.Add(port);
}
+
+ Marshal.FreeHGlobal(ptrNodeConnection);
+ CloseHandle(h);
// convert it into a Collection
return new System.Collections.ObjectModel.ReadOnlyCollection(portList);
}
@@ -862,143 +860,142 @@ namespace DiscImageChef.Devices.Windows
// Open a handle to the Hub device
IntPtr h = CreateFile(PortHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr.Zero);
- if(h.ToInt32() != INVALID_HANDLE_VALUE)
+ if(h.ToInt32() == INVALID_HANDLE_VALUE) return device;
+
+ int nBytesReturned;
+ int nBytes = BUFFER_SIZE;
+ // We use this to zero fill a buffer
+ string nullString = new string((char)0, BUFFER_SIZE / Marshal.SystemDefaultCharSize);
+
+ // The iManufacturer, iProduct and iSerialNumber entries in the
+ // Device Descriptor are really just indexes. So, we have to
+ // request a String Descriptor to get the values for those strings.
+
+ if(PortDeviceDescriptor.iManufacturer > 0)
{
- int nBytesReturned;
- int nBytes = BUFFER_SIZE;
- // We use this to zero fill a buffer
- string nullString = new string((char)0, BUFFER_SIZE / Marshal.SystemDefaultCharSize);
-
- // The iManufacturer, iProduct and iSerialNumber entries in the
- // Device Descriptor are really just indexes. So, we have to
- // request a String Descriptor to get the values for those strings.
-
- if(PortDeviceDescriptor.iManufacturer > 0)
- {
- // build a request for string descriptor
- UsbDescriptorRequest request = new UsbDescriptorRequest();
- request.ConnectionIndex = PortPortNumber;
- request.SetupPacket.wValue =
- (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iManufacturer);
- request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
- request.SetupPacket.wIndex = 0x409; // Language Code
- // Geez, I wish C# had a Marshal.MemSet() method
- IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
- Marshal.StructureToPtr(request, ptrRequest, true);
-
- // Use an IOCTL call to request the String Descriptor
- if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes,
- ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
- {
- // The location of the string descriptor is immediately after
- // the Request structure. Because this location is not "covered"
- // by the structure allocation, we're forced to zero out this
- // chunk of memory by using the StringToHGlobalAuto() hack above
- IntPtr ptrStringDesc = new IntPtr(ptrRequest.ToInt32() + Marshal.SizeOf(request));
- UsbStringDescriptor stringDesc =
- (UsbStringDescriptor)Marshal.PtrToStructure(ptrStringDesc,
- typeof(UsbStringDescriptor));
- device.DeviceManufacturer = stringDesc.bString;
- }
- Marshal.FreeHGlobal(ptrRequest);
- }
- if(PortDeviceDescriptor.iProduct > 0)
- {
- // build a request for string descriptor
- UsbDescriptorRequest request = new UsbDescriptorRequest();
- request.ConnectionIndex = PortPortNumber;
- request.SetupPacket.wValue =
- (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iProduct);
- request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
- request.SetupPacket.wIndex = 0x409; // Language Code
- // Geez, I wish C# had a Marshal.MemSet() method
- IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
- Marshal.StructureToPtr(request, ptrRequest, true);
-
- // Use an IOCTL call to request the String Descriptor
- if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes,
- ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
- {
- // the location of the string descriptor is immediately after the Request structure
- IntPtr ptrStringDesc = new IntPtr(ptrRequest.ToInt32() + Marshal.SizeOf(request));
- UsbStringDescriptor stringDesc =
- (UsbStringDescriptor)Marshal.PtrToStructure(ptrStringDesc,
- typeof(UsbStringDescriptor));
- device.DeviceProduct = stringDesc.bString;
- }
- Marshal.FreeHGlobal(ptrRequest);
- }
- if(PortDeviceDescriptor.iSerialNumber > 0)
- {
- // build a request for string descriptor
- UsbDescriptorRequest request = new UsbDescriptorRequest();
- request.ConnectionIndex = PortPortNumber;
- request.SetupPacket.wValue =
- (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iSerialNumber);
- request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
- request.SetupPacket.wIndex = 0x409; // Language Code
- // Geez, I wish C# had a Marshal.MemSet() method
- IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
- Marshal.StructureToPtr(request, ptrRequest, true);
-
- // Use an IOCTL call to request the String Descriptor
- if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes,
- ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
- {
- // the location of the string descriptor is immediately after the Request structure
- IntPtr ptrStringDesc = new IntPtr(ptrRequest.ToInt32() + Marshal.SizeOf(request));
- UsbStringDescriptor stringDesc =
- (UsbStringDescriptor)Marshal.PtrToStructure(ptrStringDesc,
- typeof(UsbStringDescriptor));
- device.DeviceSerialNumber = stringDesc.bString;
- }
- Marshal.FreeHGlobal(ptrRequest);
- }
-
- // build a request for configuration descriptor
- UsbDescriptorRequest dcrRequest = new UsbDescriptorRequest();
- dcrRequest.ConnectionIndex = PortPortNumber;
- dcrRequest.SetupPacket.wValue = (short)(USB_CONFIGURATION_DESCRIPTOR_TYPE << 8);
- dcrRequest.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(dcrRequest));
- dcrRequest.SetupPacket.wIndex = 0;
+ // build a request for string descriptor
+ UsbDescriptorRequest request = new UsbDescriptorRequest();
+ request.ConnectionIndex = PortPortNumber;
+ request.SetupPacket.wValue =
+ (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iManufacturer);
+ request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
+ request.SetupPacket.wIndex = 0x409; // Language Code
// Geez, I wish C# had a Marshal.MemSet() method
- IntPtr dcrPtrRequest = Marshal.StringToHGlobalAuto(nullString);
- Marshal.StructureToPtr(dcrRequest, dcrPtrRequest, true);
+ IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
+ Marshal.StructureToPtr(request, ptrRequest, true);
// Use an IOCTL call to request the String Descriptor
- if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, dcrPtrRequest, nBytes,
- dcrPtrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
+ if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes,
+ ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
{
- IntPtr ptrStringDesc = new IntPtr(dcrPtrRequest.ToInt32() + Marshal.SizeOf(dcrRequest));
- device.BinaryDeviceDescriptors = new byte[nBytesReturned];
- Marshal.Copy(ptrStringDesc, device.BinaryDeviceDescriptors, 0, nBytesReturned);
+ // The location of the string descriptor is immediately after
+ // the Request structure. Because this location is not "covered"
+ // by the structure allocation, we're forced to zero out this
+ // chunk of memory by using the StringToHGlobalAuto() hack above
+ IntPtr ptrStringDesc = new IntPtr(ptrRequest.ToInt32() + Marshal.SizeOf(request));
+ UsbStringDescriptor stringDesc =
+ (UsbStringDescriptor)Marshal.PtrToStructure(ptrStringDesc,
+ typeof(UsbStringDescriptor));
+ device.DeviceManufacturer = stringDesc.bString;
}
- Marshal.FreeHGlobal(dcrPtrRequest);
-
- // Get the Driver Key Name (usefull in locating a device)
- UsbNodeConnectionDriverkeyName driverKey = new UsbNodeConnectionDriverkeyName();
- driverKey.ConnectionIndex = PortPortNumber;
- nBytes = Marshal.SizeOf(driverKey);
- IntPtr ptrDriverKey = Marshal.AllocHGlobal(nBytes);
- Marshal.StructureToPtr(driverKey, ptrDriverKey, true);
-
- // Use an IOCTL call to request the Driver Key Name
- if(DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, ptrDriverKey, nBytes,
- ptrDriverKey, nBytes, out nBytesReturned, IntPtr.Zero))
- {
- driverKey = (UsbNodeConnectionDriverkeyName)Marshal.PtrToStructure(ptrDriverKey,
- typeof(
- UsbNodeConnectionDriverkeyName
- ));
- device.DeviceDriverKey = driverKey.DriverKeyName;
-
- // use the DriverKeyName to get the Device Description and Instance ID
- device.DeviceName = GetDescriptionByKeyName(device.DeviceDriverKey);
- device.DeviceInstanceId = GetInstanceIdByKeyName(device.DeviceDriverKey);
- }
- Marshal.FreeHGlobal(ptrDriverKey);
- CloseHandle(h);
+ Marshal.FreeHGlobal(ptrRequest);
}
+ if(PortDeviceDescriptor.iProduct > 0)
+ {
+ // build a request for string descriptor
+ UsbDescriptorRequest request = new UsbDescriptorRequest();
+ request.ConnectionIndex = PortPortNumber;
+ request.SetupPacket.wValue =
+ (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iProduct);
+ request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
+ request.SetupPacket.wIndex = 0x409; // Language Code
+ // Geez, I wish C# had a Marshal.MemSet() method
+ IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
+ Marshal.StructureToPtr(request, ptrRequest, true);
+
+ // Use an IOCTL call to request the String Descriptor
+ if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes,
+ ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
+ {
+ // the location of the string descriptor is immediately after the Request structure
+ IntPtr ptrStringDesc = new IntPtr(ptrRequest.ToInt32() + Marshal.SizeOf(request));
+ UsbStringDescriptor stringDesc =
+ (UsbStringDescriptor)Marshal.PtrToStructure(ptrStringDesc,
+ typeof(UsbStringDescriptor));
+ device.DeviceProduct = stringDesc.bString;
+ }
+ Marshal.FreeHGlobal(ptrRequest);
+ }
+ if(PortDeviceDescriptor.iSerialNumber > 0)
+ {
+ // build a request for string descriptor
+ UsbDescriptorRequest request = new UsbDescriptorRequest();
+ request.ConnectionIndex = PortPortNumber;
+ request.SetupPacket.wValue =
+ (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iSerialNumber);
+ request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
+ request.SetupPacket.wIndex = 0x409; // Language Code
+ // Geez, I wish C# had a Marshal.MemSet() method
+ IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
+ Marshal.StructureToPtr(request, ptrRequest, true);
+
+ // Use an IOCTL call to request the String Descriptor
+ if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes,
+ ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
+ {
+ // the location of the string descriptor is immediately after the Request structure
+ IntPtr ptrStringDesc = new IntPtr(ptrRequest.ToInt32() + Marshal.SizeOf(request));
+ UsbStringDescriptor stringDesc =
+ (UsbStringDescriptor)Marshal.PtrToStructure(ptrStringDesc,
+ typeof(UsbStringDescriptor));
+ device.DeviceSerialNumber = stringDesc.bString;
+ }
+ Marshal.FreeHGlobal(ptrRequest);
+ }
+
+ // build a request for configuration descriptor
+ UsbDescriptorRequest dcrRequest = new UsbDescriptorRequest();
+ dcrRequest.ConnectionIndex = PortPortNumber;
+ dcrRequest.SetupPacket.wValue = (short)(USB_CONFIGURATION_DESCRIPTOR_TYPE << 8);
+ dcrRequest.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(dcrRequest));
+ dcrRequest.SetupPacket.wIndex = 0;
+ // Geez, I wish C# had a Marshal.MemSet() method
+ IntPtr dcrPtrRequest = Marshal.StringToHGlobalAuto(nullString);
+ Marshal.StructureToPtr(dcrRequest, dcrPtrRequest, true);
+
+ // Use an IOCTL call to request the String Descriptor
+ if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, dcrPtrRequest, nBytes,
+ dcrPtrRequest, nBytes, out nBytesReturned, IntPtr.Zero))
+ {
+ IntPtr ptrStringDesc = new IntPtr(dcrPtrRequest.ToInt32() + Marshal.SizeOf(dcrRequest));
+ device.BinaryDeviceDescriptors = new byte[nBytesReturned];
+ Marshal.Copy(ptrStringDesc, device.BinaryDeviceDescriptors, 0, nBytesReturned);
+ }
+ Marshal.FreeHGlobal(dcrPtrRequest);
+
+ // Get the Driver Key Name (usefull in locating a device)
+ UsbNodeConnectionDriverkeyName driverKey = new UsbNodeConnectionDriverkeyName();
+ driverKey.ConnectionIndex = PortPortNumber;
+ nBytes = Marshal.SizeOf(driverKey);
+ IntPtr ptrDriverKey = Marshal.AllocHGlobal(nBytes);
+ Marshal.StructureToPtr(driverKey, ptrDriverKey, true);
+
+ // Use an IOCTL call to request the Driver Key Name
+ if(DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, ptrDriverKey, nBytes,
+ ptrDriverKey, nBytes, out nBytesReturned, IntPtr.Zero))
+ {
+ driverKey = (UsbNodeConnectionDriverkeyName)Marshal.PtrToStructure(ptrDriverKey,
+ typeof(
+ UsbNodeConnectionDriverkeyName
+ ));
+ device.DeviceDriverKey = driverKey.DriverKeyName;
+
+ // use the DriverKeyName to get the Device Description and Instance ID
+ device.DeviceName = GetDescriptionByKeyName(device.DeviceDriverKey);
+ device.DeviceInstanceId = GetInstanceIdByKeyName(device.DeviceDriverKey);
+ }
+ Marshal.FreeHGlobal(ptrDriverKey);
+ CloseHandle(h);
return device;
}
@@ -1015,61 +1012,59 @@ namespace DiscImageChef.Devices.Windows
// Open a handle to the Host Controller
h = CreateFile(PortHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr.Zero);
- if(h.ToInt32() != INVALID_HANDLE_VALUE)
- {
- // Get the DevicePath for downstream hub
- int nBytesReturned;
- UsbNodeConnectionName nodeName = new UsbNodeConnectionName();
- nodeName.ConnectionIndex = PortPortNumber;
- int nBytes = Marshal.SizeOf(nodeName);
- IntPtr ptrNodeName = Marshal.AllocHGlobal(nBytes);
- Marshal.StructureToPtr(nodeName, ptrNodeName, true);
+ if(h.ToInt32() == INVALID_HANDLE_VALUE) return hub;
+ // Get the DevicePath for downstream hub
+ int nBytesReturned;
+ UsbNodeConnectionName nodeName = new UsbNodeConnectionName();
+ nodeName.ConnectionIndex = PortPortNumber;
+ int nBytes = Marshal.SizeOf(nodeName);
+ IntPtr ptrNodeName = Marshal.AllocHGlobal(nBytes);
+ Marshal.StructureToPtr(nodeName, ptrNodeName, true);
- // Use an IOCTL call to request the Node Name
- if(DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_NAME, ptrNodeName, nBytes, ptrNodeName, nBytes,
+ // Use an IOCTL call to request the Node Name
+ if(DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_NAME, ptrNodeName, nBytes, ptrNodeName, nBytes,
+ out nBytesReturned, IntPtr.Zero))
+ {
+ nodeName = (UsbNodeConnectionName)Marshal.PtrToStructure(ptrNodeName,
+ typeof(UsbNodeConnectionName));
+ hub.HubDevicePath = @"\\.\" + nodeName.NodeName;
+ }
+
+ // Now let's open the Hub (based upon the HubName we got above)
+ h2 = CreateFile(hub.HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
+ IntPtr.Zero);
+ if(h2.ToInt32() != INVALID_HANDLE_VALUE)
+ {
+ UsbNodeInformation nodeInfo = new UsbNodeInformation();
+ nodeInfo.NodeType = (int)UsbHubNode.UsbHub;
+ nBytes = Marshal.SizeOf(nodeInfo);
+ IntPtr ptrNodeInfo = Marshal.AllocHGlobal(nBytes);
+ Marshal.StructureToPtr(nodeInfo, ptrNodeInfo, true);
+
+ // get the Hub Information
+ if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes,
out nBytesReturned, IntPtr.Zero))
{
- nodeName = (UsbNodeConnectionName)Marshal.PtrToStructure(ptrNodeName,
- typeof(UsbNodeConnectionName));
- hub.HubDevicePath = @"\\.\" + nodeName.NodeName;
+ nodeInfo = (UsbNodeInformation)Marshal.PtrToStructure(ptrNodeInfo,
+ typeof(UsbNodeInformation));
+ hub.HubIsBusPowered = Convert.ToBoolean(nodeInfo.HubInformation.HubIsBusPowered);
+ hub.HubPortCount = nodeInfo.HubInformation.HubDescriptor.bNumberOfPorts;
}
-
- // Now let's open the Hub (based upon the HubName we got above)
- h2 = CreateFile(hub.HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
- IntPtr.Zero);
- if(h2.ToInt32() != INVALID_HANDLE_VALUE)
- {
- UsbNodeInformation nodeInfo = new UsbNodeInformation();
- nodeInfo.NodeType = (int)UsbHubNode.UsbHub;
- nBytes = Marshal.SizeOf(nodeInfo);
- IntPtr ptrNodeInfo = Marshal.AllocHGlobal(nBytes);
- Marshal.StructureToPtr(nodeInfo, ptrNodeInfo, true);
-
- // get the Hub Information
- if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes,
- out nBytesReturned, IntPtr.Zero))
- {
- nodeInfo = (UsbNodeInformation)Marshal.PtrToStructure(ptrNodeInfo,
- typeof(UsbNodeInformation));
- hub.HubIsBusPowered = Convert.ToBoolean(nodeInfo.HubInformation.HubIsBusPowered);
- hub.HubPortCount = nodeInfo.HubInformation.HubDescriptor.bNumberOfPorts;
- }
- Marshal.FreeHGlobal(ptrNodeInfo);
- CloseHandle(h2);
- }
-
- // Fill in the missing Manufacture, Product, and SerialNumber values
- // values by just creating a Device instance and copying the values
- UsbDevice device = GetDevice();
- hub.HubInstanceId = device.DeviceInstanceId;
- hub.HubManufacturer = device.Manufacturer;
- hub.HubProduct = device.Product;
- hub.HubSerialNumber = device.SerialNumber;
- hub.HubDriverKey = device.DriverKey;
-
- Marshal.FreeHGlobal(ptrNodeName);
- CloseHandle(h);
+ Marshal.FreeHGlobal(ptrNodeInfo);
+ CloseHandle(h2);
}
+
+ // Fill in the missing Manufacture, Product, and SerialNumber values
+ // values by just creating a Device instance and copying the values
+ UsbDevice device = GetDevice();
+ hub.HubInstanceId = device.DeviceInstanceId;
+ hub.HubManufacturer = device.Manufacturer;
+ hub.HubProduct = device.Product;
+ hub.HubSerialNumber = device.SerialNumber;
+ hub.HubDriverKey = device.DriverKey;
+
+ Marshal.FreeHGlobal(ptrNodeName);
+ CloseHandle(h);
return hub;
}
}
@@ -1161,46 +1156,45 @@ namespace DiscImageChef.Devices.Windows
// Use the "enumerator form" of the SetupDiGetClassDevs API
// to generate a list of all USB devices
IntPtr h = SetupDiGetClassDevs(0, devEnum, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES);
- if(h.ToInt32() != INVALID_HANDLE_VALUE)
+ if(h.ToInt32() == INVALID_HANDLE_VALUE) return ans;
+
+ IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
+ string keyName;
+
+ bool success;
+ int i = 0;
+ do
{
- IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
- string keyName;
+ // create a Device Interface Data structure
+ SpDevinfoData da = new SpDevinfoData();
+ da.cbSize = Marshal.SizeOf(da);
- bool success;
- int i = 0;
- do
+ // start the enumeration
+ success = SetupDiEnumDeviceInfo(h, i, ref da);
+ if(success)
{
- // create a Device Interface Data structure
- SpDevinfoData da = new SpDevinfoData();
- da.cbSize = Marshal.SizeOf(da);
+ int requiredSize = 0;
+ int regType = REG_SZ;
+ keyName = "";
- // start the enumeration
- success = SetupDiEnumDeviceInfo(h, i, ref da);
- if(success)
+ if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE,
+ ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf);
+
+ // is it a match?
+ if(keyName == driverKeyName)
{
- int requiredSize = 0;
- int regType = REG_SZ;
- keyName = "";
-
- if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE,
- ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf);
-
- // is it a match?
- if(keyName == driverKeyName)
- {
- if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref regType, ptrBuf,
- BUFFER_SIZE, ref requiredSize)) ans = Marshal.PtrToStringAuto(ptrBuf);
- break;
- }
+ if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref regType, ptrBuf,
+ BUFFER_SIZE, ref requiredSize)) ans = Marshal.PtrToStringAuto(ptrBuf);
+ break;
}
-
- i++;
}
- while(success);
- Marshal.FreeHGlobal(ptrBuf);
- SetupDiDestroyDeviceInfoList(h);
+ i++;
}
+ while(success);
+
+ Marshal.FreeHGlobal(ptrBuf);
+ SetupDiDestroyDeviceInfoList(h);
return ans;
}
@@ -1216,48 +1210,47 @@ namespace DiscImageChef.Devices.Windows
// Use the "enumerator form" of the SetupDiGetClassDevs API
// to generate a list of all USB devices
IntPtr h = SetupDiGetClassDevs(0, devEnum, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES);
- if(h.ToInt32() != INVALID_HANDLE_VALUE)
+ if(h.ToInt32() == INVALID_HANDLE_VALUE) return ans;
+
+ IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
+ string keyName;
+
+ bool success;
+ int i = 0;
+ do
{
- IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
- string keyName;
+ // create a Device Interface Data structure
+ SpDevinfoData da = new SpDevinfoData();
+ da.cbSize = Marshal.SizeOf(da);
- bool success;
- int i = 0;
- do
+ // start the enumeration
+ success = SetupDiEnumDeviceInfo(h, i, ref da);
+ if(success)
{
- // create a Device Interface Data structure
- SpDevinfoData da = new SpDevinfoData();
- da.cbSize = Marshal.SizeOf(da);
+ int requiredSize = 0;
+ int regType = REG_SZ;
- // start the enumeration
- success = SetupDiEnumDeviceInfo(h, i, ref da);
- if(success)
+ keyName = "";
+ if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE,
+ ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf);
+
+ // is it a match?
+ if(keyName == driverKeyName)
{
- int requiredSize = 0;
- int regType = REG_SZ;
-
- keyName = "";
- if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE,
- ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf);
-
- // is it a match?
- if(keyName == driverKeyName)
- {
- int nBytes = BUFFER_SIZE;
- StringBuilder sb = new StringBuilder(nBytes);
- SetupDiGetDeviceInstanceId(h, ref da, sb, nBytes, out requiredSize);
- ans = sb.ToString();
- break;
- }
+ int nBytes = BUFFER_SIZE;
+ StringBuilder sb = new StringBuilder(nBytes);
+ SetupDiGetDeviceInstanceId(h, ref da, sb, nBytes, out requiredSize);
+ ans = sb.ToString();
+ break;
}
-
- i++;
}
- while(success);
- Marshal.FreeHGlobal(ptrBuf);
- SetupDiDestroyDeviceInfoList(h);
+ i++;
}
+ while(success);
+
+ Marshal.FreeHGlobal(ptrBuf);
+ SetupDiDestroyDeviceInfoList(h);
return ans;
}
diff --git a/DiscImageChef.Devices/Windows/UsbFunctions.cs b/DiscImageChef.Devices/Windows/UsbFunctions.cs
index 87d211b35..f63b9efaa 100644
--- a/DiscImageChef.Devices/Windows/UsbFunctions.cs
+++ b/DiscImageChef.Devices/Windows/UsbFunctions.cs
@@ -86,15 +86,13 @@ namespace DiscImageChef.Devices.Windows
if(port.IsHub) SearchHubDriverKeyName(port.GetHub(), ref foundDevice, driverKeyName);
else
{
- if(port.IsDeviceConnected)
- {
- UsbDevice device = port.GetDevice();
- if(device.DeviceDriverKey == driverKeyName)
- {
- foundDevice = device;
- break;
- }
- }
+ if(!port.IsDeviceConnected) continue;
+
+ UsbDevice device = port.GetDevice();
+ if(device.DeviceDriverKey != driverKeyName) continue;
+
+ foundDevice = device;
+ break;
}
}
@@ -121,15 +119,13 @@ namespace DiscImageChef.Devices.Windows
if(port.IsHub) SearchHubInstanceId(port.GetHub(), ref foundDevice, instanceId);
else
{
- if(port.IsDeviceConnected)
- {
- UsbDevice device = port.GetDevice();
- if(device.InstanceId == instanceId)
- {
- foundDevice = device;
- break;
- }
- }
+ if(!port.IsDeviceConnected) continue;
+
+ UsbDevice device = port.GetDevice();
+ if(device.InstanceId != instanceId) continue;
+
+ foundDevice = device;
+ break;
}
}
@@ -273,24 +269,23 @@ namespace DiscImageChef.Devices.Windows
int ans = -1;
IntPtr h = CreateFile(devicePath.TrimEnd('\\'), 0, 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);
- if(h.ToInt32() != INVALID_HANDLE_VALUE)
- {
- int requiredSize;
- StorageDeviceNumber sdn = new StorageDeviceNumber();
- int nBytes = Marshal.SizeOf(sdn);
- IntPtr ptrSdn = Marshal.AllocHGlobal(nBytes);
+ if(h.ToInt32() == INVALID_HANDLE_VALUE) return ans;
- if(DeviceIoControl(h, IOCTL_STORAGE_GET_DEVICE_NUMBER, IntPtr.Zero, 0, ptrSdn, nBytes, out requiredSize,
- IntPtr.Zero))
- {
- sdn = (StorageDeviceNumber)Marshal.PtrToStructure(ptrSdn, typeof(StorageDeviceNumber));
- // just my way of combining the relevant parts of the
- // STORAGE_DEVICE_NUMBER into a single number
- ans = (sdn.DeviceType << 8) + sdn.DeviceNumber;
- }
- Marshal.FreeHGlobal(ptrSdn);
- CloseHandle(h);
+ int requiredSize;
+ StorageDeviceNumber sdn = new StorageDeviceNumber();
+ int nBytes = Marshal.SizeOf(sdn);
+ IntPtr ptrSdn = Marshal.AllocHGlobal(nBytes);
+
+ if(DeviceIoControl(h, IOCTL_STORAGE_GET_DEVICE_NUMBER, IntPtr.Zero, 0, ptrSdn, nBytes, out requiredSize,
+ IntPtr.Zero))
+ {
+ sdn = (StorageDeviceNumber)Marshal.PtrToStructure(ptrSdn, typeof(StorageDeviceNumber));
+ // just my way of combining the relevant parts of the
+ // STORAGE_DEVICE_NUMBER into a single number
+ ans = (sdn.DeviceType << 8) + sdn.DeviceNumber;
}
+ Marshal.FreeHGlobal(ptrSdn);
+ CloseHandle(h);
return ans;
}
}
diff --git a/DiscImageChef.DiscImages/Alcohol120.cs b/DiscImageChef.DiscImages/Alcohol120.cs
index cab796d73..5a893d8c6 100644
--- a/DiscImageChef.DiscImages/Alcohol120.cs
+++ b/DiscImageChef.DiscImages/Alcohol120.cs
@@ -828,9 +828,10 @@ namespace DiscImageChef.DiscImages
{
AlcoholTrackExtra extra;
- if(track.point == kvp.Key && alcTrackExtras.TryGetValue(track.point, out extra))
- if(sectorAddress - kvp.Value < extra.sectors)
- return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key);
+ if(track.point != kvp.Key || !alcTrackExtras.TryGetValue(track.point, out extra)) continue;
+
+ if(sectorAddress - kvp.Value < extra.sectors)
+ return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key);
}
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
@@ -844,9 +845,10 @@ namespace DiscImageChef.DiscImages
{
AlcoholTrackExtra extra;
- if(track.point == kvp.Key && alcTrackExtras.TryGetValue(track.point, out extra))
- if(sectorAddress - kvp.Value < extra.sectors)
- return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
+ if(track.point != kvp.Key || !alcTrackExtras.TryGetValue(track.point, out extra)) continue;
+
+ if(sectorAddress - kvp.Value < extra.sectors)
+ return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
}
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
@@ -1296,9 +1298,10 @@ namespace DiscImageChef.DiscImages
{
AlcoholTrackExtra extra;
- if(track.point == kvp.Key && alcTrackExtras.TryGetValue(track.point, out extra))
- if(sectorAddress - kvp.Value < extra.sectors)
- return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key);
+ if(track.point != kvp.Key || !alcTrackExtras.TryGetValue(track.point, out extra)) continue;
+
+ if(sectorAddress - kvp.Value < extra.sectors)
+ return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key);
}
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
@@ -1393,40 +1396,39 @@ namespace DiscImageChef.DiscImages
}
AlcoholTrackExtra extra;
- if(alcTrackExtras.TryGetValue(track.point, out extra))
+ if(!alcTrackExtras.TryGetValue(track.point, out extra)) continue;
+
+ Track _track = new Track();
+
+ _track.Indexes = new Dictionary();
+ _track.Indexes.Add(1, track.startLba);
+ _track.TrackStartSector = track.startLba;
+ _track.TrackEndSector = extra.sectors - 1;
+ _track.TrackPregap = extra.pregap;
+ _track.TrackSession = sessionNo;
+ _track.TrackSequence = track.point;
+ _track.TrackType = AlcoholTrackTypeToTrackType(track.mode);
+ _track.TrackFilter = alcImage;
+ _track.TrackFile = alcImage.GetFilename();
+ _track.TrackFileOffset = track.startOffset;
+ _track.TrackFileType = "BINARY";
+ _track.TrackRawBytesPerSector = track.sectorSize;
+ _track.TrackBytesPerSector = AlcoholTrackModeToCookedBytesPerSector(track.mode);
+ switch(track.subMode)
{
- Track _track = new Track();
-
- _track.Indexes = new Dictionary();
- _track.Indexes.Add(1, track.startLba);
- _track.TrackStartSector = track.startLba;
- _track.TrackEndSector = extra.sectors - 1;
- _track.TrackPregap = extra.pregap;
- _track.TrackSession = sessionNo;
- _track.TrackSequence = track.point;
- _track.TrackType = AlcoholTrackTypeToTrackType(track.mode);
- _track.TrackFilter = alcImage;
- _track.TrackFile = alcImage.GetFilename();
- _track.TrackFileOffset = track.startOffset;
- _track.TrackFileType = "BINARY";
- _track.TrackRawBytesPerSector = track.sectorSize;
- _track.TrackBytesPerSector = AlcoholTrackModeToCookedBytesPerSector(track.mode);
- switch(track.subMode)
- {
- case AlcoholSubchannelMode.Interleaved:
- _track.TrackSubchannelFilter = alcImage;
- _track.TrackSubchannelFile = alcImage.GetFilename();
- _track.TrackSubchannelOffset = track.startOffset;
- _track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
- _track.TrackRawBytesPerSector += 96;
- break;
- case AlcoholSubchannelMode.None:
- _track.TrackSubchannelType = TrackSubchannelType.None;
- break;
- }
-
- tracks.Add(_track);
+ case AlcoholSubchannelMode.Interleaved:
+ _track.TrackSubchannelFilter = alcImage;
+ _track.TrackSubchannelFile = alcImage.GetFilename();
+ _track.TrackSubchannelOffset = track.startOffset;
+ _track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
+ _track.TrackRawBytesPerSector += 96;
+ break;
+ case AlcoholSubchannelMode.None:
+ _track.TrackSubchannelType = TrackSubchannelType.None;
+ break;
}
+
+ tracks.Add(_track);
}
return tracks;
@@ -1455,40 +1457,39 @@ namespace DiscImageChef.DiscImages
}
AlcoholTrackExtra extra;
- if(alcTrackExtras.TryGetValue(track.point, out extra) && session == sessionNo)
+ if(!alcTrackExtras.TryGetValue(track.point, out extra) || session != sessionNo) continue;
+
+ Track _track = new Track();
+
+ _track.Indexes = new Dictionary();
+ _track.Indexes.Add(1, track.startLba);
+ _track.TrackStartSector = track.startLba;
+ _track.TrackEndSector = extra.sectors - 1;
+ _track.TrackPregap = extra.pregap;
+ _track.TrackSession = sessionNo;
+ _track.TrackSequence = track.point;
+ _track.TrackType = AlcoholTrackTypeToTrackType(track.mode);
+ _track.TrackFilter = alcImage;
+ _track.TrackFile = alcImage.GetFilename();
+ _track.TrackFileOffset = track.startOffset;
+ _track.TrackFileType = "BINARY";
+ _track.TrackRawBytesPerSector = track.sectorSize;
+ _track.TrackBytesPerSector = AlcoholTrackModeToCookedBytesPerSector(track.mode);
+ switch(track.subMode)
{
- Track _track = new Track();
-
- _track.Indexes = new Dictionary();
- _track.Indexes.Add(1, track.startLba);
- _track.TrackStartSector = track.startLba;
- _track.TrackEndSector = extra.sectors - 1;
- _track.TrackPregap = extra.pregap;
- _track.TrackSession = sessionNo;
- _track.TrackSequence = track.point;
- _track.TrackType = AlcoholTrackTypeToTrackType(track.mode);
- _track.TrackFilter = alcImage;
- _track.TrackFile = alcImage.GetFilename();
- _track.TrackFileOffset = track.startOffset;
- _track.TrackFileType = "BINARY";
- _track.TrackRawBytesPerSector = track.sectorSize;
- _track.TrackBytesPerSector = AlcoholTrackModeToCookedBytesPerSector(track.mode);
- switch(track.subMode)
- {
- case AlcoholSubchannelMode.Interleaved:
- _track.TrackSubchannelFilter = alcImage;
- _track.TrackSubchannelFile = alcImage.GetFilename();
- _track.TrackSubchannelOffset = track.startOffset;
- _track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
- _track.TrackRawBytesPerSector += 96;
- break;
- case AlcoholSubchannelMode.None:
- _track.TrackSubchannelType = TrackSubchannelType.None;
- break;
- }
-
- tracks.Add(_track);
+ case AlcoholSubchannelMode.Interleaved:
+ _track.TrackSubchannelFilter = alcImage;
+ _track.TrackSubchannelFile = alcImage.GetFilename();
+ _track.TrackSubchannelOffset = track.startOffset;
+ _track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
+ _track.TrackRawBytesPerSector += 96;
+ break;
+ case AlcoholSubchannelMode.None:
+ _track.TrackSubchannelType = TrackSubchannelType.None;
+ break;
}
+
+ tracks.Add(_track);
}
return tracks;
diff --git a/DiscImageChef.DiscImages/BlindWrite5.cs b/DiscImageChef.DiscImages/BlindWrite5.cs
index c65a75415..6d2782384 100644
--- a/DiscImageChef.DiscImages/BlindWrite5.cs
+++ b/DiscImageChef.DiscImages/BlindWrite5.cs
@@ -593,12 +593,15 @@ namespace DiscImageChef.DiscImages
session.Tracks[tSeq].session);
DicConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].unknown8 = 0x{2:X4}", ses,
tSeq, session.Tracks[tSeq].unknown8);
- if(session.Tracks[tSeq].type != Bw5TrackType.Dvd &&
- session.Tracks[tSeq].type != Bw5TrackType.NotData)
+ if(session.Tracks[tSeq].type == Bw5TrackType.Dvd ||
+ session.Tracks[tSeq].type == Bw5TrackType.NotData) continue;
+
+ {
for(int i = 0; i < session.Tracks[tSeq].unknown9.Length; i++)
DicConsole.DebugWriteLine("BlindWrite5 plugin",
"session[{0}].track[{1}].unknown9[{2}] = 0x{3:X8}", ses, tSeq, i,
session.Tracks[tSeq].unknown9[i]);
+ }
}
bwSessions.Add(session);
@@ -795,121 +798,120 @@ namespace DiscImageChef.DiscImages
fullTocStream.WriteByte(trk.psec);
fullTocStream.WriteByte(trk.pframe);
- if(trk.point < 0xA0)
+ if(trk.point >= 0xA0) continue;
+
+ Track track = new Track();
+ Partition partition = new Partition();
+
+ trackFlags.Add(trk.point, trk.ctl);
+
+ switch(trk.type)
{
- Track track = new Track();
- Partition partition = new Partition();
+ case Bw5TrackType.Audio:
+ track.TrackBytesPerSector = 2352;
+ track.TrackRawBytesPerSector = 2352;
+ if(ImageInfo.SectorSize < 2352) ImageInfo.SectorSize = 2352;
+ break;
+ case Bw5TrackType.Mode1:
+ case Bw5TrackType.Mode2F1:
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader);
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc);
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP);
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ);
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
+ track.TrackBytesPerSector = 2048;
+ track.TrackRawBytesPerSector = 2352;
+ if(ImageInfo.SectorSize < 2048) ImageInfo.SectorSize = 2048;
+ break;
+ case Bw5TrackType.Mode2:
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
+ track.TrackBytesPerSector = 2336;
+ track.TrackRawBytesPerSector = 2352;
+ if(ImageInfo.SectorSize < 2336) ImageInfo.SectorSize = 2336;
+ break;
+ case Bw5TrackType.Mode2F2:
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader);
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
+ track.TrackBytesPerSector = 2336;
+ track.TrackRawBytesPerSector = 2352;
+ if(ImageInfo.SectorSize < 2324) ImageInfo.SectorSize = 2324;
+ break;
+ case Bw5TrackType.Dvd:
+ track.TrackBytesPerSector = 2048;
+ track.TrackRawBytesPerSector = 2048;
+ if(ImageInfo.SectorSize < 2048) ImageInfo.SectorSize = 2048;
+ isDvd = true;
+ break;
+ }
- trackFlags.Add(trk.point, trk.ctl);
+ track.TrackDescription = string.Format("Track {0}", trk.point);
+ track.TrackStartSector = (ulong)(trk.startLba + trk.pregap);
+ track.TrackEndSector = (ulong)(trk.sectors + trk.startLba);
- switch(trk.type)
+ foreach(DataFileCharacteristics chars in filePaths)
+ if(trk.startLba >= chars.StartLba &&
+ trk.startLba + trk.sectors <= chars.StartLba + chars.Sectors)
{
- case Bw5TrackType.Audio:
- track.TrackBytesPerSector = 2352;
- track.TrackRawBytesPerSector = 2352;
- if(ImageInfo.SectorSize < 2352) ImageInfo.SectorSize = 2352;
- break;
- case Bw5TrackType.Mode1:
- case Bw5TrackType.Mode2F1:
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader);
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc);
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP);
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ);
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
- track.TrackBytesPerSector = 2048;
- track.TrackRawBytesPerSector = 2352;
- if(ImageInfo.SectorSize < 2048) ImageInfo.SectorSize = 2048;
- break;
- case Bw5TrackType.Mode2:
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
- track.TrackBytesPerSector = 2336;
- track.TrackRawBytesPerSector = 2352;
- if(ImageInfo.SectorSize < 2336) ImageInfo.SectorSize = 2336;
- break;
- case Bw5TrackType.Mode2F2:
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader);
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
- track.TrackBytesPerSector = 2336;
- track.TrackRawBytesPerSector = 2352;
- if(ImageInfo.SectorSize < 2324) ImageInfo.SectorSize = 2324;
- break;
- case Bw5TrackType.Dvd:
- track.TrackBytesPerSector = 2048;
- track.TrackRawBytesPerSector = 2048;
- if(ImageInfo.SectorSize < 2048) ImageInfo.SectorSize = 2048;
- isDvd = true;
- break;
- }
-
- track.TrackDescription = string.Format("Track {0}", trk.point);
- track.TrackStartSector = (ulong)(trk.startLba + trk.pregap);
- track.TrackEndSector = (ulong)(trk.sectors + trk.startLba);
-
- foreach(DataFileCharacteristics chars in filePaths)
- if(trk.startLba >= chars.StartLba &&
- trk.startLba + trk.sectors <= chars.StartLba + chars.Sectors)
+ track.TrackFilter = chars.FileFilter;
+ track.TrackFile = chars.FileFilter.GetFilename();
+ if(trk.startLba >= 0)
+ track.TrackFileOffset = (ulong)((trk.startLba - chars.StartLba) * chars.SectorSize);
+ else track.TrackFileOffset = (ulong)(trk.startLba * -1 * chars.SectorSize);
+ track.TrackFileType = "BINARY";
+ if(chars.Subchannel != TrackSubchannelType.None)
{
- track.TrackFilter = chars.FileFilter;
- track.TrackFile = chars.FileFilter.GetFilename();
- if(trk.startLba >= 0)
- track.TrackFileOffset = (ulong)((trk.startLba - chars.StartLba) * chars.SectorSize);
- else track.TrackFileOffset = (ulong)(trk.startLba * -1 * chars.SectorSize);
- track.TrackFileType = "BINARY";
- if(chars.Subchannel != TrackSubchannelType.None)
- {
- track.TrackSubchannelFilter = track.TrackFilter;
- track.TrackSubchannelFile = track.TrackFile;
- track.TrackSubchannelType = chars.Subchannel;
- track.TrackSubchannelOffset = track.TrackFileOffset;
+ track.TrackSubchannelFilter = track.TrackFilter;
+ track.TrackSubchannelFile = track.TrackFile;
+ track.TrackSubchannelType = chars.Subchannel;
+ track.TrackSubchannelOffset = track.TrackFileOffset;
- if(chars.Subchannel == TrackSubchannelType.PackedInterleaved)
- if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel))
- ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel);
- }
-
- break;
+ if(chars.Subchannel == TrackSubchannelType.PackedInterleaved)
+ if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel))
+ ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel);
}
- track.TrackPregap = trk.pregap;
- track.TrackSequence = trk.point;
- track.TrackType = BlindWriteTrackTypeToTrackType(trk.type);
- track.Indexes = new Dictionary();
- track.Indexes.Add(1, track.TrackStartSector);
+ break;
+ }
- partition.Description = track.TrackDescription;
- partition.Size = (track.TrackEndSector - track.TrackStartSector) *
- (ulong)track.TrackRawBytesPerSector;
- partition.Length = track.TrackEndSector - track.TrackStartSector;
- partition.Sequence = track.TrackSequence;
- partition.Offset = offsetBytes;
- partition.Start = track.TrackStartSector;
- partition.Type = track.TrackType.ToString();
+ track.TrackPregap = trk.pregap;
+ track.TrackSequence = trk.point;
+ track.TrackType = BlindWriteTrackTypeToTrackType(trk.type);
+ track.Indexes = new Dictionary();
+ track.Indexes.Add(1, track.TrackStartSector);
- offsetBytes += partition.Size;
+ partition.Description = track.TrackDescription;
+ partition.Size = (track.TrackEndSector - track.TrackStartSector) *
+ (ulong)track.TrackRawBytesPerSector;
+ partition.Length = track.TrackEndSector - track.TrackStartSector;
+ partition.Sequence = track.TrackSequence;
+ partition.Offset = offsetBytes;
+ partition.Start = track.TrackStartSector;
+ partition.Type = track.TrackType.ToString();
- tracks.Add(track);
- partitions.Add(partition);
- offsetmap.Add(track.TrackSequence, track.TrackStartSector);
- ImageInfo.Sectors += partition.Length;
- }
+ offsetBytes += partition.Size;
+
+ tracks.Add(track);
+ partitions.Add(partition);
+ offsetmap.Add(track.TrackSequence, track.TrackStartSector);
+ ImageInfo.Sectors += partition.Length;
}
}
diff --git a/DiscImageChef.DiscImages/CDRDAO.cs b/DiscImageChef.DiscImages/CDRDAO.cs
index 6904eac5e..10e3fc35d 100644
--- a/DiscImageChef.DiscImages/CDRDAO.cs
+++ b/DiscImageChef.DiscImages/CDRDAO.cs
@@ -446,12 +446,12 @@ namespace DiscImageChef.DiscImages
if(matchComment.Success)
{
// Ignore "// Track X" comments
- if(!matchComment.Groups["comment"].Value.StartsWith(" Track ", StringComparison.Ordinal))
- {
- DicConsole.DebugWriteLine("CDRDAO plugin", "Found comment \"{1}\" at line {0}", line,
- matchComment.Groups["comment"].Value.Trim());
- commentBuilder.AppendLine(matchComment.Groups["comment"].Value.Trim());
- }
+ if(matchComment.Groups["comment"].Value.StartsWith(" Track ", StringComparison.Ordinal))
+ continue;
+
+ DicConsole.DebugWriteLine("CDRDAO plugin", "Found comment \"{1}\" at line {0}", line,
+ matchComment.Groups["comment"].Value.Trim());
+ commentBuilder.AppendLine(matchComment.Groups["comment"].Value.Trim());
}
else if(matchDiskType.Success)
{
@@ -1241,31 +1241,31 @@ namespace DiscImageChef.DiscImages
{
case CDRDAO_TRACK_TYPE_MODE1:
case CDRDAO_TRACK_TYPE_MODE2_FORM1:
- if(tag == SectorTagType.CdSectorSubchannel)
- {
- sectorOffset = 2048;
- sectorSize = 96;
- break;
- }
+ if(tag != SectorTagType.CdSectorSubchannel)
+ throw new ArgumentException("No tags in image for requested track", nameof(tag));
+
+ sectorOffset = 2048;
+ sectorSize = 96;
+ break;
throw new ArgumentException("No tags in image for requested track", nameof(tag));
case CDRDAO_TRACK_TYPE_MODE2_FORM2:
case CDRDAO_TRACK_TYPE_MODE2_MIX:
- if(tag == SectorTagType.CdSectorSubchannel)
- {
- sectorOffset = 2336;
- sectorSize = 96;
- break;
- }
+ if(tag != SectorTagType.CdSectorSubchannel)
+ throw new ArgumentException("No tags in image for requested track", nameof(tag));
+
+ sectorOffset = 2336;
+ sectorSize = 96;
+ break;
throw new ArgumentException("No tags in image for requested track", nameof(tag));
case CDRDAO_TRACK_TYPE_AUDIO:
- if(tag == SectorTagType.CdSectorSubchannel)
- {
- sectorOffset = 2352;
- sectorSize = 96;
- break;
- }
+ if(tag != SectorTagType.CdSectorSubchannel)
+ throw new ArgumentException("No tags in image for requested track", nameof(tag));
+
+ sectorOffset = 2352;
+ sectorSize = 96;
+ break;
throw new ArgumentException("No tags in image for requested track", nameof(tag));
case CDRDAO_TRACK_TYPE_MODE1_RAW:
@@ -1328,12 +1328,12 @@ namespace DiscImageChef.DiscImages
break;
}
case CDRDAO_TRACK_TYPE_MODE2_RAW: // Requires reading sector
- if(tag == SectorTagType.CdSectorSubchannel)
- {
- sectorOffset = 2352;
- sectorSize = 96;
- break;
- }
+ if(tag != SectorTagType.CdSectorSubchannel)
+ throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
+
+ sectorOffset = 2352;
+ sectorSize = 96;
+ break;
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
diff --git a/DiscImageChef.DiscImages/CDRWin.cs b/DiscImageChef.DiscImages/CDRWin.cs
index 18e98c61d..3f4247022 100644
--- a/DiscImageChef.DiscImages/CDRWin.cs
+++ b/DiscImageChef.DiscImages/CDRWin.cs
@@ -453,17 +453,16 @@ namespace DiscImageChef.DiscImages
string _line = cueStream.ReadLine();
matchTrack = regexTrack.Match(_line);
- if(matchTrack.Success)
- {
- uint trackSeq = uint.Parse(matchTrack.Groups[1].Value);
- if(trackCount + 1 != trackSeq)
- throw new
- FeatureUnsupportedImageException(string
- .Format("Found TRACK {0} out of order in line {1}",
- trackSeq, line));
+ if(!matchTrack.Success) continue;
- trackCount++;
- }
+ uint trackSeq = uint.Parse(matchTrack.Groups[1].Value);
+ if(trackCount + 1 != trackSeq)
+ throw new
+ FeatureUnsupportedImageException(string
+ .Format("Found TRACK {0} out of order in line {1}",
+ trackSeq, line));
+
+ trackCount++;
}
if(trackCount == 0) throw new FeatureUnsupportedImageException("No tracks found");
diff --git a/DiscImageChef.DiscImages/CHD.cs b/DiscImageChef.DiscImages/CHD.cs
index 3b7646839..bc364f87c 100644
--- a/DiscImageChef.DiscImages/CHD.cs
+++ b/DiscImageChef.DiscImages/CHD.cs
@@ -1647,127 +1647,126 @@ namespace DiscImageChef.DiscImages
{
byte[] hunk;
- if(!hunkCache.TryGetValue(hunkNo, out hunk))
+ if(hunkCache.TryGetValue(hunkNo, out hunk)) return hunk;
+
+ switch(mapVersion)
{
- switch(mapVersion)
- {
- case 1:
- ulong offset = hunkTable[hunkNo] & 0x00000FFFFFFFFFFF;
- ulong length = hunkTable[hunkNo] >> 44;
+ case 1:
+ ulong offset = hunkTable[hunkNo] & 0x00000FFFFFFFFFFF;
+ ulong length = hunkTable[hunkNo] >> 44;
- byte[] compHunk = new byte[length];
- imageStream.Seek((long)offset, SeekOrigin.Begin);
- imageStream.Read(compHunk, 0, compHunk.Length);
+ byte[] compHunk = new byte[length];
+ imageStream.Seek((long)offset, SeekOrigin.Begin);
+ imageStream.Read(compHunk, 0, compHunk.Length);
- if(length == sectorsPerHunk * ImageInfo.SectorSize) hunk = compHunk;
- else if((ChdCompression)hdrCompression > ChdCompression.Zlib)
- throw new ImageNotSupportedException(string.Format("Unsupported compression {0}",
- (ChdCompression)hdrCompression));
- else
- {
- DeflateStream zStream =
- new DeflateStream(new MemoryStream(compHunk), CompressionMode.Decompress);
- hunk = new byte[sectorsPerHunk * ImageInfo.SectorSize];
- int read = zStream.Read(hunk, 0, (int)(sectorsPerHunk * ImageInfo.SectorSize));
- if(read != sectorsPerHunk * ImageInfo.SectorSize)
- throw new
- IOException(string
- .Format("Unable to decompress hunk correctly, got {0} bytes, expected {1}",
- read, sectorsPerHunk * ImageInfo.SectorSize));
+ if(length == sectorsPerHunk * ImageInfo.SectorSize) hunk = compHunk;
+ else if((ChdCompression)hdrCompression > ChdCompression.Zlib)
+ throw new ImageNotSupportedException(string.Format("Unsupported compression {0}",
+ (ChdCompression)hdrCompression));
+ else
+ {
+ DeflateStream zStream =
+ new DeflateStream(new MemoryStream(compHunk), CompressionMode.Decompress);
+ hunk = new byte[sectorsPerHunk * ImageInfo.SectorSize];
+ int read = zStream.Read(hunk, 0, (int)(sectorsPerHunk * ImageInfo.SectorSize));
+ if(read != sectorsPerHunk * ImageInfo.SectorSize)
+ throw new
+ IOException(string
+ .Format("Unable to decompress hunk correctly, got {0} bytes, expected {1}",
+ read, sectorsPerHunk * ImageInfo.SectorSize));
- zStream.Close();
- zStream = null;
- }
+ zStream.Close();
+ zStream = null;
+ }
- break;
- case 3:
- byte[] entryBytes = new byte[16];
- Array.Copy(hunkMap, (int)(hunkNo * 16), entryBytes, 0, 16);
- ChdMapV3Entry entry = BigEndianMarshal.ByteArrayToStructureBigEndian(entryBytes);
- switch((Chdv3EntryFlags)(entry.flags & 0x0F))
- {
- case Chdv3EntryFlags.Invalid: throw new ArgumentException("Invalid hunk found.");
- case Chdv3EntryFlags.Compressed:
- switch((ChdCompression)hdrCompression)
- {
- case ChdCompression.None: goto uncompressedV3;
- case ChdCompression.Zlib:
- case ChdCompression.ZlibPlus:
- if(isHdd)
- {
- byte[] zHunk = new byte[(entry.lengthLsb << 16) + entry.lengthLsb];
- imageStream.Seek((long)entry.offset, SeekOrigin.Begin);
- imageStream.Read(zHunk, 0, zHunk.Length);
- DeflateStream zStream =
- new DeflateStream(new MemoryStream(zHunk), CompressionMode.Decompress);
- hunk = new byte[bytesPerHunk];
- int read = zStream.Read(hunk, 0, (int)bytesPerHunk);
- if(read != bytesPerHunk)
- throw new
- IOException(string
- .Format("Unable to decompress hunk correctly, got {0} bytes, expected {1}",
- read, bytesPerHunk));
-
- zStream.Close();
- zStream = null;
- }
- // TODO: Guess wth is MAME doing with these hunks
- else
+ break;
+ case 3:
+ byte[] entryBytes = new byte[16];
+ Array.Copy(hunkMap, (int)(hunkNo * 16), entryBytes, 0, 16);
+ ChdMapV3Entry entry = BigEndianMarshal.ByteArrayToStructureBigEndian(entryBytes);
+ switch((Chdv3EntryFlags)(entry.flags & 0x0F))
+ {
+ case Chdv3EntryFlags.Invalid: throw new ArgumentException("Invalid hunk found.");
+ case Chdv3EntryFlags.Compressed:
+ switch((ChdCompression)hdrCompression)
+ {
+ case ChdCompression.None: goto uncompressedV3;
+ case ChdCompression.Zlib:
+ case ChdCompression.ZlibPlus:
+ if(isHdd)
+ {
+ byte[] zHunk = new byte[(entry.lengthLsb << 16) + entry.lengthLsb];
+ imageStream.Seek((long)entry.offset, SeekOrigin.Begin);
+ imageStream.Read(zHunk, 0, zHunk.Length);
+ DeflateStream zStream =
+ new DeflateStream(new MemoryStream(zHunk), CompressionMode.Decompress);
+ hunk = new byte[bytesPerHunk];
+ int read = zStream.Read(hunk, 0, (int)bytesPerHunk);
+ if(read != bytesPerHunk)
throw new
- ImageNotSupportedException("Compressed CD/GD-ROM hunks are not yet supported");
+ IOException(string
+ .Format("Unable to decompress hunk correctly, got {0} bytes, expected {1}",
+ read, bytesPerHunk));
- break;
- case ChdCompression.Av:
+ zStream.Close();
+ zStream = null;
+ }
+ // TODO: Guess wth is MAME doing with these hunks
+ else
throw new
- ImageNotSupportedException(string.Format("Unsupported compression {0}",
- (ChdCompression)hdrCompression));
- }
+ ImageNotSupportedException("Compressed CD/GD-ROM hunks are not yet supported");
- break;
- case Chdv3EntryFlags.Uncompressed:
- uncompressedV3:
- hunk = new byte[bytesPerHunk];
- imageStream.Seek((long)entry.offset, SeekOrigin.Begin);
- imageStream.Read(hunk, 0, hunk.Length);
- break;
- case Chdv3EntryFlags.Mini:
- hunk = new byte[bytesPerHunk];
- byte[] mini = new byte[8];
- mini = BigEndianBitConverter.GetBytes(entry.offset);
- for(int i = 0; i < bytesPerHunk; i++) hunk[i] = mini[i % 8];
+ break;
+ case ChdCompression.Av:
+ throw new
+ ImageNotSupportedException(string.Format("Unsupported compression {0}",
+ (ChdCompression)hdrCompression));
+ }
- break;
- case Chdv3EntryFlags.SelfHunk: return GetHunk(entry.offset);
- case Chdv3EntryFlags.ParentHunk:
- throw new ImageNotSupportedException("Parent images are not supported");
- case Chdv3EntryFlags.SecondCompressed:
- throw new ImageNotSupportedException("FLAC is not supported");
- default:
- throw new ImageNotSupportedException(string.Format("Hunk type {0} is not supported",
- entry.flags & 0xF));
- }
-
- break;
- case 5:
- if(hdrCompression == 0)
- {
+ break;
+ case Chdv3EntryFlags.Uncompressed:
+ uncompressedV3:
hunk = new byte[bytesPerHunk];
- imageStream.Seek(hunkTableSmall[hunkNo] * bytesPerHunk, SeekOrigin.Begin);
+ imageStream.Seek((long)entry.offset, SeekOrigin.Begin);
imageStream.Read(hunk, 0, hunk.Length);
- }
- else throw new ImageNotSupportedException("Compressed v5 hunks not yet supported");
+ break;
+ case Chdv3EntryFlags.Mini:
+ hunk = new byte[bytesPerHunk];
+ byte[] mini = new byte[8];
+ mini = BigEndianBitConverter.GetBytes(entry.offset);
+ for(int i = 0; i < bytesPerHunk; i++) hunk[i] = mini[i % 8];
- break;
- default:
- throw new ImageNotSupportedException(string.Format("Unsupported hunk map version {0}",
- mapVersion));
- }
+ break;
+ case Chdv3EntryFlags.SelfHunk: return GetHunk(entry.offset);
+ case Chdv3EntryFlags.ParentHunk:
+ throw new ImageNotSupportedException("Parent images are not supported");
+ case Chdv3EntryFlags.SecondCompressed:
+ throw new ImageNotSupportedException("FLAC is not supported");
+ default:
+ throw new ImageNotSupportedException(string.Format("Hunk type {0} is not supported",
+ entry.flags & 0xF));
+ }
- if(hunkCache.Count >= maxBlockCache) hunkCache.Clear();
+ break;
+ case 5:
+ if(hdrCompression == 0)
+ {
+ hunk = new byte[bytesPerHunk];
+ imageStream.Seek(hunkTableSmall[hunkNo] * bytesPerHunk, SeekOrigin.Begin);
+ imageStream.Read(hunk, 0, hunk.Length);
+ }
+ else throw new ImageNotSupportedException("Compressed v5 hunks not yet supported");
- hunkCache.Add(hunkNo, hunk);
+ break;
+ default:
+ throw new ImageNotSupportedException(string.Format("Unsupported hunk map version {0}",
+ mapVersion));
}
+ if(hunkCache.Count >= maxBlockCache) hunkCache.Clear();
+
+ hunkCache.Add(hunkNo, hunk);
+
return hunk;
}
diff --git a/DiscImageChef.DiscImages/CloneCD.cs b/DiscImageChef.DiscImages/CloneCD.cs
index 4061225f3..02aa00cfb 100644
--- a/DiscImageChef.DiscImages/CloneCD.cs
+++ b/DiscImageChef.DiscImages/CloneCD.cs
@@ -304,16 +304,15 @@ namespace DiscImageChef.DiscImages
{
ccdVerMatch = ccdVerRegex.Match(_line);
- if(ccdVerMatch.Success)
- {
- DicConsole.DebugWriteLine("CloneCD plugin", "Found Version at line {0}", line);
+ if(!ccdVerMatch.Success) continue;
- ImageInfo.ImageVersion = ccdVerMatch.Groups["value"].Value;
- if(ImageInfo.ImageVersion != "2" && ImageInfo.ImageVersion != "3")
- DicConsole
- .ErrorWriteLine("(CloneCD plugin): Warning! Unknown CCD image version {0}, may not work!",
- ImageInfo.ImageVersion);
- }
+ DicConsole.DebugWriteLine("CloneCD plugin", "Found Version at line {0}", line);
+
+ ImageInfo.ImageVersion = ccdVerMatch.Groups["value"].Value;
+ if(ImageInfo.ImageVersion != "2" && ImageInfo.ImageVersion != "3")
+ DicConsole
+ .ErrorWriteLine("(CloneCD plugin): Warning! Unknown CCD image version {0}, may not work!",
+ ImageInfo.ImageVersion);
}
else if(inDisk)
{
diff --git a/DiscImageChef.DiscImages/D88.cs b/DiscImageChef.DiscImages/D88.cs
index 3464a220a..1734c95e1 100644
--- a/DiscImageChef.DiscImages/D88.cs
+++ b/DiscImageChef.DiscImages/D88.cs
@@ -376,13 +376,12 @@ namespace DiscImageChef.DiscImages
sechdr = (SectorHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SectorHeader));
handle.Free();
- if(sechdr.spt != spt || sechdr.n != bps)
- {
- DicConsole.DebugWriteLine("D88 plugin",
- "Disk tracks are not same size. spt = {0} (expected {1}), bps = {2} (expected {3}) at track {4} sector {5}",
- sechdr.spt, spt, sechdr.n, bps, i, j, sechdr.deleted_mark);
- allEqual = false;
- }
+ if(sechdr.spt == spt && sechdr.n == bps) continue;
+
+ DicConsole.DebugWriteLine("D88 plugin",
+ "Disk tracks are not same size. spt = {0} (expected {1}), bps = {2} (expected {3}) at track {4} sector {5}",
+ sechdr.spt, spt, sechdr.n, bps, i, j, sechdr.deleted_mark);
+ allEqual = false;
}
secB = new byte[sechdr.size_of_data];
diff --git a/DiscImageChef.DiscImages/DiscJuggler.cs b/DiscImageChef.DiscImages/DiscJuggler.cs
index 1fe6e1382..4fb01cf09 100644
--- a/DiscImageChef.DiscImages/DiscJuggler.cs
+++ b/DiscImageChef.DiscImages/DiscJuggler.cs
@@ -218,19 +218,17 @@ namespace DiscImageChef.DiscImages
int bLen = descriptor[position];
position++;
DicConsole.DebugWriteLine("DiscJuggler plugin", "\tc[{1}][{2}].Length = {0}", bLen, c, cb);
- if(bLen > 0)
- {
- byte[] textBlk = new byte[bLen];
- Array.Copy(descriptor, position, textBlk, 0, bLen);
- position += bLen;
- // Track title
- if(cb == 10)
- {
- track.TrackDescription = Encoding.Default.GetString(textBlk, 0, bLen);
- DicConsole.DebugWriteLine("DiscJuggler plugin", "\tTrack title = {0}",
- track.TrackDescription);
- }
- }
+ if(bLen <= 0) continue;
+
+ byte[] textBlk = new byte[bLen];
+ Array.Copy(descriptor, position, textBlk, 0, bLen);
+ position += bLen;
+ // Track title
+ if(cb != 10) continue;
+
+ track.TrackDescription = Encoding.Default.GetString(textBlk, 0, bLen);
+ DicConsole.DebugWriteLine("DiscJuggler plugin", "\tTrack title = {0}",
+ track.TrackDescription);
}
}
@@ -519,17 +517,16 @@ namespace DiscImageChef.DiscImages
addedATrack = true;
}
- if(addedATrack)
- {
- lastSessionTrack = session.EndTrack;
- sessions.Add(session);
- DicConsole.DebugWriteLine("DiscJuggler plugin", "session.StartTrack = {0}", session.StartTrack);
- DicConsole.DebugWriteLine("DiscJuggler plugin", "session.StartSector = {0}", session.StartSector);
- DicConsole.DebugWriteLine("DiscJuggler plugin", "session.EndTrack = {0}", session.EndTrack);
- DicConsole.DebugWriteLine("DiscJuggler plugin", "session.EndSector = {0}", session.EndSector);
- DicConsole.DebugWriteLine("DiscJuggler plugin", "session.SessionSequence = {0}",
- session.SessionSequence);
- }
+ if(!addedATrack) continue;
+
+ lastSessionTrack = session.EndTrack;
+ sessions.Add(session);
+ DicConsole.DebugWriteLine("DiscJuggler plugin", "session.StartTrack = {0}", session.StartTrack);
+ DicConsole.DebugWriteLine("DiscJuggler plugin", "session.StartSector = {0}", session.StartSector);
+ DicConsole.DebugWriteLine("DiscJuggler plugin", "session.EndTrack = {0}", session.EndTrack);
+ DicConsole.DebugWriteLine("DiscJuggler plugin", "session.EndSector = {0}", session.EndSector);
+ DicConsole.DebugWriteLine("DiscJuggler plugin", "session.SessionSequence = {0}",
+ session.SessionSequence);
}
// Skip unknown
diff --git a/DiscImageChef.DiscImages/DiskCopy42.cs b/DiscImageChef.DiscImages/DiskCopy42.cs
index 7d197fe8b..16a5ebeb5 100644
--- a/DiscImageChef.DiscImages/DiskCopy42.cs
+++ b/DiscImageChef.DiscImages/DiskCopy42.cs
@@ -231,14 +231,11 @@ namespace DiscImageChef.DiscImages
return false;
}
- if(tmpHeader.FmtByte == kInvalidFmtByte)
- {
- DicConsole.DebugWriteLine("DC42 plugin", "Image says it's unformatted");
+ if(tmpHeader.FmtByte != kInvalidFmtByte) return true;
- return false;
- }
+ DicConsole.DebugWriteLine("DC42 plugin", "Image says it's unformatted");
- return true;
+ return false;
}
public override bool OpenImage(Filter imageFilter)
@@ -646,18 +643,17 @@ namespace DiscImageChef.DiscImages
DicConsole.DebugWriteLine("DC42 plugin", "Calculated data checksum = 0x{0:X8}", dataChk);
DicConsole.DebugWriteLine("DC42 plugin", "Stored data checksum = 0x{0:X8}", header.DataChecksum);
- if(header.TagSize > 0)
- {
- DicConsole.DebugWriteLine("DC42 plugin", "Reading tags");
- Stream tagstream = dc42ImageFilter.GetDataForkStream();
- tagstream.Seek(tagOffset, SeekOrigin.Begin);
- tagstream.Read(tags, 0, (int)header.TagSize);
+ if(header.TagSize <= 0) return dataChk == header.DataChecksum && tagsChk == header.TagChecksum;
- DicConsole.DebugWriteLine("DC42 plugin", "Calculating tag checksum");
- tagsChk = DC42CheckSum(tags);
- DicConsole.DebugWriteLine("DC42 plugin", "Calculated tag checksum = 0x{0:X8}", tagsChk);
- DicConsole.DebugWriteLine("DC42 plugin", "Stored tag checksum = 0x{0:X8}", header.TagChecksum);
- }
+ DicConsole.DebugWriteLine("DC42 plugin", "Reading tags");
+ Stream tagstream = dc42ImageFilter.GetDataForkStream();
+ tagstream.Seek(tagOffset, SeekOrigin.Begin);
+ tagstream.Read(tags, 0, (int)header.TagSize);
+
+ DicConsole.DebugWriteLine("DC42 plugin", "Calculating tag checksum");
+ tagsChk = DC42CheckSum(tags);
+ DicConsole.DebugWriteLine("DC42 plugin", "Calculated tag checksum = 0x{0:X8}", tagsChk);
+ DicConsole.DebugWriteLine("DC42 plugin", "Stored tag checksum = 0x{0:X8}", header.TagChecksum);
return dataChk == header.DataChecksum && tagsChk == header.TagChecksum;
}
diff --git a/DiscImageChef.DiscImages/Nero.cs b/DiscImageChef.DiscImages/Nero.cs
index 8c1047c91..585f9f0fc 100644
--- a/DiscImageChef.DiscImages/Nero.cs
+++ b/DiscImageChef.DiscImages/Nero.cs
@@ -1572,128 +1572,128 @@ namespace DiscImageChef.DiscImages
for(uint i = 1; i <= neroTracks.Count; i++)
{
NeroTrack neroTrack;
- if(neroTracks.TryGetValue(i, out neroTrack))
+ if(!neroTracks.TryGetValue(i, out neroTrack)) continue;
+
+ DicConsole.DebugWriteLine("Nero plugin", "\tcurrentsession = {0}", currentsession);
+ DicConsole.DebugWriteLine("Nero plugin", "\tcurrentsessionmaxtrack = {0}",
+ currentsessionmaxtrack);
+ DicConsole.DebugWriteLine("Nero plugin", "\tcurrentsessioncurrenttrack = {0}",
+ currentsessioncurrenttrack);
+
+ Track _track = new Track();
+ if(neroTrack.Sequence == 1) neroTrack.Index0 = neroTrack.Index1;
+
+ _track.Indexes = new Dictionary();
+ if(neroTrack.Index0 < neroTrack.Index1)
+ _track.Indexes.Add(0, neroTrack.Index0 / neroTrack.SectorSize);
+ _track.Indexes.Add(1, neroTrack.Index1 / neroTrack.SectorSize);
+ _track.TrackDescription = StringHandlers.CToString(neroTrack.Isrc);
+ _track.TrackEndSector = neroTrack.Length / neroTrack.SectorSize + neroTrack.StartLba - 1;
+ _track.TrackPregap = (neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize;
+ _track.TrackSequence = neroTrack.Sequence;
+ _track.TrackSession = currentsession;
+ _track.TrackStartSector = neroTrack.StartLba;
+ _track.TrackType = NeroTrackModeToTrackType((DaoMode)neroTrack.Mode);
+ _track.TrackFile = imageFilter.GetFilename();
+ _track.TrackFilter = imageFilter;
+ _track.TrackFileOffset = neroTrack.Offset;
+ _track.TrackFileType = "BINARY";
+ _track.TrackSubchannelType = TrackSubchannelType.None;
+ switch((DaoMode)neroTrack.Mode)
{
- DicConsole.DebugWriteLine("Nero plugin", "\tcurrentsession = {0}", currentsession);
- DicConsole.DebugWriteLine("Nero plugin", "\tcurrentsessionmaxtrack = {0}",
- currentsessionmaxtrack);
- DicConsole.DebugWriteLine("Nero plugin", "\tcurrentsessioncurrenttrack = {0}",
- currentsessioncurrenttrack);
+ case DaoMode.Audio:
+ _track.TrackBytesPerSector = 2352;
+ _track.TrackRawBytesPerSector = 2352;
+ break;
+ case DaoMode.AudioSub:
+ _track.TrackBytesPerSector = 2352;
+ _track.TrackRawBytesPerSector = 2448;
+ _track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
+ break;
+ case DaoMode.Data:
+ case DaoMode.DataM2F1:
+ _track.TrackBytesPerSector = 2048;
+ _track.TrackRawBytesPerSector = 2048;
+ break;
+ case DaoMode.DataM2F2:
+ _track.TrackBytesPerSector = 2336;
+ _track.TrackRawBytesPerSector = 2336;
+ break;
+ case DaoMode.DataM2Raw:
+ _track.TrackBytesPerSector = 2352;
+ _track.TrackRawBytesPerSector = 2352;
+ break;
+ case DaoMode.DataM2RawSub:
+ _track.TrackBytesPerSector = 2352;
+ _track.TrackRawBytesPerSector = 2448;
+ _track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
+ break;
+ case DaoMode.DataRaw:
+ _track.TrackBytesPerSector = 2048;
+ _track.TrackRawBytesPerSector = 2352;
+ break;
+ case DaoMode.DataRawSub:
+ _track.TrackBytesPerSector = 2048;
+ _track.TrackRawBytesPerSector = 2448;
+ _track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
+ break;
+ }
- Track _track = new Track();
- if(neroTrack.Sequence == 1) neroTrack.Index0 = neroTrack.Index1;
+ if(_track.TrackSubchannelType == TrackSubchannelType.RawInterleaved)
+ {
+ _track.TrackSubchannelFilter = imageFilter;
+ _track.TrackSubchannelFile = imageFilter.GetFilename();
+ _track.TrackSubchannelOffset = neroTrack.Offset;
+ }
- _track.Indexes = new Dictionary();
- if(neroTrack.Index0 < neroTrack.Index1)
- _track.Indexes.Add(0, neroTrack.Index0 / neroTrack.SectorSize);
- _track.Indexes.Add(1, neroTrack.Index1 / neroTrack.SectorSize);
- _track.TrackDescription = StringHandlers.CToString(neroTrack.Isrc);
- _track.TrackEndSector = neroTrack.Length / neroTrack.SectorSize + neroTrack.StartLba - 1;
- _track.TrackPregap = (neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize;
- _track.TrackSequence = neroTrack.Sequence;
- _track.TrackSession = currentsession;
- _track.TrackStartSector = neroTrack.StartLba;
- _track.TrackType = NeroTrackModeToTrackType((DaoMode)neroTrack.Mode);
- _track.TrackFile = imageFilter.GetFilename();
- _track.TrackFilter = imageFilter;
- _track.TrackFileOffset = neroTrack.Offset;
- _track.TrackFileType = "BINARY";
- _track.TrackSubchannelType = TrackSubchannelType.None;
- switch((DaoMode)neroTrack.Mode)
- {
- case DaoMode.Audio:
- _track.TrackBytesPerSector = 2352;
- _track.TrackRawBytesPerSector = 2352;
- break;
- case DaoMode.AudioSub:
- _track.TrackBytesPerSector = 2352;
- _track.TrackRawBytesPerSector = 2448;
- _track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
- break;
- case DaoMode.Data:
- case DaoMode.DataM2F1:
- _track.TrackBytesPerSector = 2048;
- _track.TrackRawBytesPerSector = 2048;
- break;
- case DaoMode.DataM2F2:
- _track.TrackBytesPerSector = 2336;
- _track.TrackRawBytesPerSector = 2336;
- break;
- case DaoMode.DataM2Raw:
- _track.TrackBytesPerSector = 2352;
- _track.TrackRawBytesPerSector = 2352;
- break;
- case DaoMode.DataM2RawSub:
- _track.TrackBytesPerSector = 2352;
- _track.TrackRawBytesPerSector = 2448;
- _track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
- break;
- case DaoMode.DataRaw:
- _track.TrackBytesPerSector = 2048;
- _track.TrackRawBytesPerSector = 2352;
- break;
- case DaoMode.DataRawSub:
- _track.TrackBytesPerSector = 2048;
- _track.TrackRawBytesPerSector = 2448;
- _track.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
- break;
- }
+ imageTracks.Add(_track);
- if(_track.TrackSubchannelType == TrackSubchannelType.RawInterleaved)
- {
- _track.TrackSubchannelFilter = imageFilter;
- _track.TrackSubchannelFile = imageFilter.GetFilename();
- _track.TrackSubchannelOffset = neroTrack.Offset;
- }
+ DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackDescription = {0}",
+ _track.TrackDescription);
+ DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackEndSector = {0}",
+ _track.TrackEndSector);
+ DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackPregap = {0}", _track.TrackPregap);
+ DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackSequence = {0}",
+ _track.TrackSequence);
+ DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackSession = {0}", _track.TrackSession);
+ DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackStartSector = {0}",
+ _track.TrackStartSector);
+ DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackType = {0}", _track.TrackType);
- imageTracks.Add(_track);
+ if(currentsessioncurrenttrack == 1)
+ {
+ currentsessionstruct = new Session();
+ currentsessionstruct.SessionSequence = currentsession;
+ currentsessionstruct.StartSector = _track.TrackStartSector;
+ currentsessionstruct.StartTrack = _track.TrackSequence;
+ }
+ currentsessioncurrenttrack++;
+ if(currentsessioncurrenttrack > currentsessionmaxtrack)
+ {
+ currentsession++;
+ neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack);
+ currentsessioncurrenttrack = 1;
+ currentsessionstruct.EndTrack = _track.TrackSequence;
+ currentsessionstruct.EndSector = _track.TrackEndSector;
+ imageSessions.Add(currentsessionstruct);
+ }
- DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackDescription = {0}",
- _track.TrackDescription);
- DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackEndSector = {0}",
- _track.TrackEndSector);
- DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackPregap = {0}", _track.TrackPregap);
- DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackSequence = {0}",
- _track.TrackSequence);
- DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackSession = {0}", _track.TrackSession);
- DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackStartSector = {0}",
- _track.TrackStartSector);
- DicConsole.DebugWriteLine("Nero plugin", "\t\t _track.TrackType = {0}", _track.TrackType);
+ if(i == neroTracks.Count)
+ {
+ neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack);
+ currentsessioncurrenttrack = 1;
+ currentsessionstruct.EndTrack = _track.TrackSequence;
+ currentsessionstruct.EndSector = _track.TrackEndSector;
+ imageSessions.Add(currentsessionstruct);
+ }
- if(currentsessioncurrenttrack == 1)
- {
- currentsessionstruct = new Session();
- currentsessionstruct.SessionSequence = currentsession;
- currentsessionstruct.StartSector = _track.TrackStartSector;
- currentsessionstruct.StartTrack = _track.TrackSequence;
- }
- currentsessioncurrenttrack++;
- if(currentsessioncurrenttrack > currentsessionmaxtrack)
- {
- currentsession++;
- neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack);
- currentsessioncurrenttrack = 1;
- currentsessionstruct.EndTrack = _track.TrackSequence;
- currentsessionstruct.EndSector = _track.TrackEndSector;
- imageSessions.Add(currentsessionstruct);
- }
+ offsetmap.Add(_track.TrackSequence, _track.TrackStartSector);
+ DicConsole.DebugWriteLine("Nero plugin", "\t\t Offset[{0}]: {1}", _track.TrackSequence,
+ _track.TrackStartSector);
- if(i == neroTracks.Count)
- {
- neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack);
- currentsessioncurrenttrack = 1;
- currentsessionstruct.EndTrack = _track.TrackSequence;
- currentsessionstruct.EndSector = _track.TrackEndSector;
- imageSessions.Add(currentsessionstruct);
- }
+ Partition partition;
- offsetmap.Add(_track.TrackSequence, _track.TrackStartSector);
- DicConsole.DebugWriteLine("Nero plugin", "\t\t Offset[{0}]: {1}", _track.TrackSequence,
- _track.TrackStartSector);
-
- Partition partition;
-
- /*if(_neroTrack.Index0 < _neroTrack.Index1)
+ /*if(_neroTrack.Index0 < _neroTrack.Index1)
{
partition = new Partition();
partition.PartitionDescription = string.Format("Track {0} Index 0", _track.TrackSequence);
@@ -1708,20 +1708,19 @@ namespace DiscImageChef.DiscImages
PartitionSequence++;
}*/
- partition = new Partition();
- partition.Description = string.Format("Track {0} Index 1", _track.TrackSequence);
- partition.Size = neroTrack.EndOfTrack - neroTrack.Index1;
- partition.Name = StringHandlers.CToString(neroTrack.Isrc);
- partition.Length = partition.Size / neroTrack.SectorSize;
- partition.Sequence = partitionSequence;
- partition.Offset = partitionStartByte;
- partition.Start = neroTrack.StartLba +
- (neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize;
- partition.Type = NeroTrackModeToTrackType((DaoMode)neroTrack.Mode).ToString();
- imagePartitions.Add(partition);
- partitionSequence++;
- partitionStartByte += partition.Size;
- }
+ partition = new Partition();
+ partition.Description = string.Format("Track {0} Index 1", _track.TrackSequence);
+ partition.Size = neroTrack.EndOfTrack - neroTrack.Index1;
+ partition.Name = StringHandlers.CToString(neroTrack.Isrc);
+ partition.Length = partition.Size / neroTrack.SectorSize;
+ partition.Sequence = partitionSequence;
+ partition.Offset = partitionStartByte;
+ partition.Start = neroTrack.StartLba +
+ (neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize;
+ partition.Type = NeroTrackModeToTrackType((DaoMode)neroTrack.Mode).ToString();
+ imagePartitions.Add(partition);
+ partitionSequence++;
+ partitionStartByte += partition.Size;
}
this.imageFilter = imageFilter;
diff --git a/DiscImageChef.DiscImages/QCOW.cs b/DiscImageChef.DiscImages/QCOW.cs
index e2bbdcc55..56502282c 100644
--- a/DiscImageChef.DiscImages/QCOW.cs
+++ b/DiscImageChef.DiscImages/QCOW.cs
@@ -250,11 +250,10 @@ namespace DiscImageChef.DiscImages
{
l1Mask <<= 1;
- if(c < 64 - l1Shift)
- {
- l1Mask += 1;
- c++;
- }
+ if(c >= 64 - l1Shift) continue;
+
+ l1Mask += 1;
+ c++;
}
l2Mask = 0;
diff --git a/DiscImageChef.DiscImages/QCOW2.cs b/DiscImageChef.DiscImages/QCOW2.cs
index 146e5742a..465ca18a8 100644
--- a/DiscImageChef.DiscImages/QCOW2.cs
+++ b/DiscImageChef.DiscImages/QCOW2.cs
@@ -297,11 +297,10 @@ namespace DiscImageChef.DiscImages
{
l1Mask <<= 1;
- if(c < 64 - l1Shift)
- {
- l1Mask += 1;
- c++;
- }
+ if(c >= 64 - l1Shift) continue;
+
+ l1Mask += 1;
+ c++;
}
l2Mask = 0;
diff --git a/DiscImageChef.DiscImages/QED.cs b/DiscImageChef.DiscImages/QED.cs
index 82aeca90f..137b75894 100644
--- a/DiscImageChef.DiscImages/QED.cs
+++ b/DiscImageChef.DiscImages/QED.cs
@@ -264,11 +264,10 @@ namespace DiscImageChef.DiscImages
{
l1Mask <<= 1;
- if(c < 64 - l1Shift)
- {
- l1Mask += 1;
- c++;
- }
+ if(c >= 64 - l1Shift) continue;
+
+ l1Mask += 1;
+ c++;
}
sectorMask = 0;
diff --git a/DiscImageChef.DiscImages/RsIde.cs b/DiscImageChef.DiscImages/RsIde.cs
index 1f33f0480..9caa89823 100644
--- a/DiscImageChef.DiscImages/RsIde.cs
+++ b/DiscImageChef.DiscImages/RsIde.cs
@@ -261,14 +261,12 @@ namespace DiscImageChef.DiscImages
#region Unsupported features
public override byte[] ReadDiskTag(MediaTagType tag)
{
- if(ImageInfo.ReadableMediaTags.Contains(tag) && tag == MediaTagType.ATA_IDENTIFY)
- {
- byte[] buffer = new byte[512];
- Array.Copy(identify, 0, buffer, 0, 512);
- return buffer;
- }
+ if(!ImageInfo.ReadableMediaTags.Contains(tag) || tag != MediaTagType.ATA_IDENTIFY)
+ throw new FeatureUnsupportedImageException("Feature not supported by image format");
- throw new FeatureUnsupportedImageException("Feature not supported by image format");
+ byte[] buffer = new byte[512];
+ Array.Copy(identify, 0, buffer, 0, 512);
+ return buffer;
}
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
diff --git a/DiscImageChef.DiscImages/TeleDisk.cs b/DiscImageChef.DiscImages/TeleDisk.cs
index dbdaf03eb..faf579d0f 100644
--- a/DiscImageChef.DiscImages/TeleDisk.cs
+++ b/DiscImageChef.DiscImages/TeleDisk.cs
@@ -546,16 +546,15 @@ namespace DiscImageChef.DiscImages
teleDiskSector.Flags = (byte)stream.ReadByte();
teleDiskSector.Crc = (byte)stream.ReadByte();
- if((teleDiskSector.Flags & FLAGS_SECTOR_DATALESS) != FLAGS_SECTOR_DATALESS &&
- (teleDiskSector.Flags & FLAGS_SECTOR_SKIPPED) != FLAGS_SECTOR_SKIPPED)
- {
- stream.Read(dataSizeBytes, 0, 2);
- teleDiskData.DataSize = BitConverter.ToUInt16(dataSizeBytes, 0);
- teleDiskData.DataSize--; // Sydex decided to including dataEncoding byte as part of it
- teleDiskData.DataEncoding = (byte)stream.ReadByte();
- data = new byte[teleDiskData.DataSize];
- stream.Read(data, 0, teleDiskData.DataSize);
- }
+ if((teleDiskSector.Flags & FLAGS_SECTOR_DATALESS) == FLAGS_SECTOR_DATALESS ||
+ (teleDiskSector.Flags & FLAGS_SECTOR_SKIPPED) == FLAGS_SECTOR_SKIPPED) continue;
+
+ stream.Read(dataSizeBytes, 0, 2);
+ teleDiskData.DataSize = BitConverter.ToUInt16(dataSizeBytes, 0);
+ teleDiskData.DataSize--; // Sydex decided to including dataEncoding byte as part of it
+ teleDiskData.DataEncoding = (byte)stream.ReadByte();
+ data = new byte[teleDiskData.DataSize];
+ stream.Read(data, 0, teleDiskData.DataSize);
}
}
@@ -671,21 +670,22 @@ namespace DiscImageChef.DiscImages
DicConsole.DebugWriteLine("TeleDisk plugin", "\t\tLBA: {0}", lba);
- if((teleDiskSector.Flags & FLAGS_SECTOR_NO_ID) != FLAGS_SECTOR_NO_ID)
- if(sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] != null)
- if((teleDiskSector.Flags & FLAGS_SECTOR_DUPLICATE) == FLAGS_SECTOR_DUPLICATE)
- DicConsole.DebugWriteLine("TeleDisk plugin",
- "\t\tSector {0} on cylinder {1} head {2} is duplicate, and marked so",
- teleDiskSector.SectorNumber, teleDiskSector.Cylinder, teleDiskSector.Head);
- else
- DicConsole.DebugWriteLine("TeleDisk plugin",
- "\t\tSector {0} on cylinder {1} head {2} is duplicate, but is not marked so",
- teleDiskSector.SectorNumber, teleDiskSector.Cylinder, teleDiskSector.Head);
+ if((teleDiskSector.Flags & FLAGS_SECTOR_NO_ID) == FLAGS_SECTOR_NO_ID) continue;
+
+ if(sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] != null)
+ if((teleDiskSector.Flags & FLAGS_SECTOR_DUPLICATE) == FLAGS_SECTOR_DUPLICATE)
+ DicConsole.DebugWriteLine("TeleDisk plugin",
+ "\t\tSector {0} on cylinder {1} head {2} is duplicate, and marked so",
+ teleDiskSector.SectorNumber, teleDiskSector.Cylinder, teleDiskSector.Head);
else
- {
- sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] = decodedData;
- totalDiskSize += (uint)decodedData.Length;
- }
+ DicConsole.DebugWriteLine("TeleDisk plugin",
+ "\t\tSector {0} on cylinder {1} head {2} is duplicate, but is not marked so",
+ teleDiskSector.SectorNumber, teleDiskSector.Cylinder, teleDiskSector.Head);
+ else
+ {
+ sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] = decodedData;
+ totalDiskSize += (uint)decodedData.Length;
+ }
}
}
@@ -1147,14 +1147,12 @@ namespace DiscImageChef.DiscImages
public override byte[] ReadDiskTag(MediaTagType tag)
{
- if(tag == MediaTagType.Floppy_LeadOut)
- {
- if(leadOut != null) return leadOut;
+ if(tag != MediaTagType.Floppy_LeadOut)
+ throw new FeatureUnsupportedImageException("Feature not supported by image format");
- throw new FeatureNotPresentImageException("Lead-out not present in disk image");
- }
+ if(leadOut != null) return leadOut;
- throw new FeatureUnsupportedImageException("Feature not supported by image format");
+ throw new FeatureNotPresentImageException("Lead-out not present in disk image");
}
#endregion
@@ -1538,28 +1536,26 @@ namespace DiscImageChef.DiscImages
k = ++freq[c];
/* swap nodes to keep the tree freq-ordered */
- if(k > freq[l = c + 1])
- {
- while(k > freq[++l]) { }
+ if(k <= freq[l = c + 1]) continue;
- ;
- l--;
- freq[c] = freq[l];
- freq[l] = (ushort)k;
+ while(k > freq[++l]) { }
- i = son[c];
- prnt[i] = (short)l;
- if(i < T) prnt[i + 1] = (short)l;
+ l--;
+ freq[c] = freq[l];
+ freq[l] = (ushort)k;
- j = son[l];
- son[l] = (short)i;
+ i = son[c];
+ prnt[i] = (short)l;
+ if(i < T) prnt[i + 1] = (short)l;
- prnt[j] = (short)c;
- if(j < T) prnt[j + 1] = (short)c;
- son[c] = (short)j;
+ j = son[l];
+ son[l] = (short)i;
- c = l;
- }
+ prnt[j] = (short)c;
+ if(j < T) prnt[j + 1] = (short)c;
+ son[c] = (short)j;
+
+ c = l;
}
while((c = prnt[c]) != 0); /* do it until reaching the root */
}
diff --git a/DiscImageChef.DiscImages/UkvFdi.cs b/DiscImageChef.DiscImages/UkvFdi.cs
index 6b7e08ba7..8ba2157e9 100644
--- a/DiscImageChef.DiscImages/UkvFdi.cs
+++ b/DiscImageChef.DiscImages/UkvFdi.cs
@@ -237,16 +237,17 @@ namespace DiscImageChef.DiscImages
}
// For empty cylinders
- if(sectorsOff[cyl][head].Length == 0)
- if(cyl + 1 == hdr.cylinders ||
- // Next cylinder is also empty
- sectorsOff[cyl + 1][head].Length == 0) emptyCyl = true;
- // Create empty sectors
- else
- {
- sectorsData[cyl][head] = new byte[spt][];
- for(int i = 0; i < spt; i++) sectorsData[cyl][head][i] = new byte[ImageInfo.SectorSize];
- }
+ if(sectorsOff[cyl][head].Length != 0) continue;
+
+ if(cyl + 1 == hdr.cylinders ||
+ // Next cylinder is also empty
+ sectorsOff[cyl + 1][head].Length == 0) emptyCyl = true;
+ // Create empty sectors
+ else
+ {
+ sectorsData[cyl][head] = new byte[spt][];
+ for(int i = 0; i < spt; i++) sectorsData[cyl][head][i] = new byte[ImageInfo.SectorSize];
+ }
}
if(emptyCyl) ImageInfo.Cylinders--;
diff --git a/DiscImageChef.DiscImages/VHD.cs b/DiscImageChef.DiscImages/VHD.cs
index 67ec5dbb5..fa5531417 100644
--- a/DiscImageChef.DiscImages/VHD.cs
+++ b/DiscImageChef.DiscImages/VHD.cs
@@ -1081,28 +1081,25 @@ namespace DiscImageChef.DiscImages
*/
// Sector has been written, read from child image
- if(dirty)
- {
- /* Too noisy
+ if(!dirty) return parentImage.ReadSector(sectorAddress);
+ /* Too noisy
DicConsole.DebugWriteLine("VirtualPC plugin", "Sector {0} is dirty", sectorAddress);
*/
- byte[] data = new byte[512];
- uint sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock;
- thisStream = thisFilter.GetDataForkStream();
+ byte[] data = new byte[512];
+ uint sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock;
+ thisStream = thisFilter.GetDataForkStream();
- thisStream.Seek(sectorOffset * 512, SeekOrigin.Begin);
- thisStream.Read(data, 0, 512);
+ thisStream.Seek(sectorOffset * 512, SeekOrigin.Begin);
+ thisStream.Read(data, 0, 512);
- return data;
- }
+ return data;
/* Too noisy
DicConsole.DebugWriteLine("VirtualPC plugin", "Sector {0} is clean", sectorAddress);
*/
// Read sector from parent image
- return parentImage.ReadSector(sectorAddress);
}
default: return ReadSectors(sectorAddress, 1);
}
@@ -1170,15 +1167,12 @@ namespace DiscImageChef.DiscImages
else Array.Clear(prefix, 0, prefix.Length);
// If we needed to read from another block, join all the data
- if(suffix != null)
- {
- byte[] data = new byte[512 * length];
- Array.Copy(prefix, 0, data, 0, prefix.Length);
- Array.Copy(suffix, 0, data, prefix.Length, suffix.Length);
- return data;
- }
+ if(suffix == null) return prefix;
- return prefix;
+ byte[] data = new byte[512 * length];
+ Array.Copy(prefix, 0, data, 0, prefix.Length);
+ Array.Copy(suffix, 0, data, prefix.Length, suffix.Length);
+ return data;
}
case TYPE_DIFFERENCING:
{
diff --git a/DiscImageChef.DiscImages/VHDX.cs b/DiscImageChef.DiscImages/VHDX.cs
index 36777bf0e..73bf1a6ee 100644
--- a/DiscImageChef.DiscImages/VHDX.cs
+++ b/DiscImageChef.DiscImages/VHDX.cs
@@ -614,11 +614,10 @@ namespace DiscImageChef.DiscImages
{
parentFilter =
new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), relEntry));
- if(parentFilter != null && parentImage.OpenImage(parentFilter))
- {
- parentWorks = true;
- break;
- }
+ if(parentFilter == null || !parentImage.OpenImage(parentFilter)) continue;
+
+ parentWorks = true;
+ break;
}
catch { continue; }
}
@@ -634,11 +633,10 @@ namespace DiscImageChef.DiscImages
{
parentFilter =
new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), entryValue));
- if(parentFilter != null && parentImage.OpenImage(parentFilter))
- {
- parentWorks = true;
- break;
- }
+ if(parentFilter == null || !parentImage.OpenImage(parentFilter)) continue;
+
+ parentWorks = true;
+ break;
}
catch { continue; }
}
diff --git a/DiscImageChef.DiscImages/VMware.cs b/DiscImageChef.DiscImages/VMware.cs
index 95b32f812..b72a026e4 100644
--- a/DiscImageChef.DiscImages/VMware.cs
+++ b/DiscImageChef.DiscImages/VMware.cs
@@ -234,16 +234,17 @@ namespace DiscImageChef.DiscImages
stream.Read(ddfMagic, 0, 0x15);
vmCHdr = new VMwareCowHeader();
- if(stream.Length > Marshal.SizeOf(vmCHdr))
- {
- stream.Seek(0, SeekOrigin.Begin);
- byte[] vmCHdrB = new byte[Marshal.SizeOf(vmCHdr)];
- stream.Read(vmCHdrB, 0, Marshal.SizeOf(vmCHdr));
- headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vmCHdr));
- Marshal.Copy(vmCHdrB, 0, headerPtr, Marshal.SizeOf(vmCHdr));
- vmCHdr = (VMwareCowHeader)Marshal.PtrToStructure(headerPtr, typeof(VMwareCowHeader));
- Marshal.FreeHGlobal(headerPtr);
- }
+ if(stream.Length <= Marshal.SizeOf(vmCHdr))
+ return ddfMagicBytes.SequenceEqual(ddfMagic) || vmEHdr.magic == VMWARE_EXTENT_MAGIC ||
+ vmCHdr.magic == VMWARE_COW_MAGIC;
+
+ stream.Seek(0, SeekOrigin.Begin);
+ byte[] vmCHdrB = new byte[Marshal.SizeOf(vmCHdr)];
+ stream.Read(vmCHdrB, 0, Marshal.SizeOf(vmCHdr));
+ headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vmCHdr));
+ Marshal.Copy(vmCHdrB, 0, headerPtr, Marshal.SizeOf(vmCHdr));
+ vmCHdr = (VMwareCowHeader)Marshal.PtrToStructure(headerPtr, typeof(VMwareCowHeader));
+ Marshal.FreeHGlobal(headerPtr);
return ddfMagicBytes.SequenceEqual(ddfMagic) || vmEHdr.magic == VMWARE_EXTENT_MAGIC ||
vmCHdr.magic == VMWARE_COW_MAGIC;
@@ -522,43 +523,42 @@ namespace DiscImageChef.DiscImages
if(extent.Access == "NOACCESS") throw new Exception("Cannot access NOACCESS extents ;).");
- if(extent.Type != "FLAT" && extent.Type != "ZERO" && extent.Type != "VMFS" && !cowD)
+ if(extent.Type == "FLAT" || extent.Type == "ZERO" || extent.Type == "VMFS" || cowD) continue;
+
+ Stream extentStream = extent.Filter.GetDataForkStream();
+ extentStream.Seek(0, SeekOrigin.Begin);
+
+ if(extentStream.Length < SECTOR_SIZE)
+ throw new Exception(string.Format("Extent {0} is too small.", extent.Filename));
+
+ VMwareExtentHeader extentHdr = new VMwareExtentHeader();
+ byte[] extentHdrB = new byte[Marshal.SizeOf(extentHdr)];
+ extentStream.Read(extentHdrB, 0, Marshal.SizeOf(extentHdr));
+ IntPtr extentHdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(extentHdr));
+ Marshal.Copy(extentHdrB, 0, extentHdrPtr, Marshal.SizeOf(extentHdr));
+ extentHdr = (VMwareExtentHeader)Marshal.PtrToStructure(extentHdrPtr, typeof(VMwareExtentHeader));
+ Marshal.FreeHGlobal(extentHdrPtr);
+
+ if(extentHdr.magic != VMWARE_EXTENT_MAGIC)
+ throw new Exception(string.Format("{0} is not an VMware extent.", extent.Filter));
+
+ if(extentHdr.capacity < extent.Sectors)
+ throw new
+ Exception(string.Format("Extent contains incorrect number of sectors, {0}. {1} were expected",
+ extentHdr.capacity, extent.Sectors));
+
+ // TODO: Support compressed extents
+ if(extentHdr.compression != COMPRESSION_NONE)
+ throw new ImageNotSupportedException("Compressed extents are not yet supported.");
+
+ if(!vmEHdrSet)
{
- Stream extentStream = extent.Filter.GetDataForkStream();
- extentStream.Seek(0, SeekOrigin.Begin);
-
- if(extentStream.Length < SECTOR_SIZE)
- throw new Exception(string.Format("Extent {0} is too small.", extent.Filename));
-
- VMwareExtentHeader extentHdr = new VMwareExtentHeader();
- byte[] extentHdrB = new byte[Marshal.SizeOf(extentHdr)];
- extentStream.Read(extentHdrB, 0, Marshal.SizeOf(extentHdr));
- IntPtr extentHdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(extentHdr));
- Marshal.Copy(extentHdrB, 0, extentHdrPtr, Marshal.SizeOf(extentHdr));
- extentHdr = (VMwareExtentHeader)Marshal.PtrToStructure(extentHdrPtr, typeof(VMwareExtentHeader));
- Marshal.FreeHGlobal(extentHdrPtr);
-
- if(extentHdr.magic != VMWARE_EXTENT_MAGIC)
- throw new Exception(string.Format("{0} is not an VMware extent.", extent.Filter));
-
- if(extentHdr.capacity < extent.Sectors)
- throw new
- Exception(string.Format("Extent contains incorrect number of sectors, {0}. {1} were expected",
- extentHdr.capacity, extent.Sectors));
-
- // TODO: Support compressed extents
- if(extentHdr.compression != COMPRESSION_NONE)
- throw new ImageNotSupportedException("Compressed extents are not yet supported.");
-
- if(!vmEHdrSet)
- {
- vmEHdr = extentHdr;
- gdFilter = extent.Filter;
- vmEHdrSet = true;
- }
-
- oneNoFlat = true;
+ vmEHdr = extentHdr;
+ gdFilter = extent.Filter;
+ vmEHdrSet = true;
}
+
+ oneNoFlat = true;
}
if(oneNoFlat && !vmEHdrSet && !cowD)
diff --git a/DiscImageChef.DiscImages/ZZZRawImage.cs b/DiscImageChef.DiscImages/ZZZRawImage.cs
index 3349284b8..1924a9ca4 100644
--- a/DiscImageChef.DiscImages/ZZZRawImage.cs
+++ b/DiscImageChef.DiscImages/ZZZRawImage.cs
@@ -78,40 +78,39 @@ namespace DiscImageChef.DiscImages
public override bool IdentifyImage(Filter imageFilter)
{
// Check if file is not multiple of 512
- if(imageFilter.GetDataForkLength() % 512 != 0)
+ if(imageFilter.GetDataForkLength() % 512 == 0) return true;
+
+ extension = Path.GetExtension(imageFilter.GetFilename()).ToLower();
+
+ if(extension == ".hdf" && ImageInfo.ImageSize % 256 == 0) return true;
+
+ // Check known disk sizes with sectors smaller than 512
+ switch(imageFilter.GetDataForkLength())
{
- extension = Path.GetExtension(imageFilter.GetFilename()).ToLower();
+ #region Commodore
+ case 174848:
+ case 175531:
+ case 197376:
+ case 351062:
+ case 822400:
+ #endregion Commodore
- if(extension == ".hdf" && ImageInfo.ImageSize % 256 == 0) return true;
-
- // Check known disk sizes with sectors smaller than 512
- switch(imageFilter.GetDataForkLength())
- {
- #region Commodore
- case 174848:
- case 175531:
- case 197376:
- case 351062:
- case 822400:
- #endregion Commodore
-
- case 81664:
- case 116480:
- case 242944:
- case 256256:
- case 287488:
- case 306432:
- case 495872:
- case 988416:
- case 995072:
- case 1021696:
- case 1146624:
- case 1177344:
- case 1222400:
- case 1304320:
- case 1255168: return true;
- default: return false;
- }
+ case 81664:
+ case 116480:
+ case 242944:
+ case 256256:
+ case 287488:
+ case 306432:
+ case 495872:
+ case 988416:
+ case 995072:
+ case 1021696:
+ case 1146624:
+ case 1177344:
+ case 1222400:
+ case 1304320:
+ case 1255168: return true;
+ default: return false;
}
return true;
@@ -761,148 +760,132 @@ namespace DiscImageChef.DiscImages
public override List