diff --git a/DiscImageChef.Core/Devices/Reader.cs b/DiscImageChef.Core/Devices/Reader.cs index 1b8f91d8..7c3c5cfe 100644 --- a/DiscImageChef.Core/Devices/Reader.cs +++ b/DiscImageChef.Core/Devices/Reader.cs @@ -40,42 +40,14 @@ namespace DiscImageChef.Core.Devices { Device dev; uint timeout; - ulong blocks; - uint blocksToRead; - string errorMessage; - bool readRaw; - uint blockSize; - uint physicalsectorsize; - uint longBlockSize; - internal string ErrorMessage - { - get { return errorMessage; } - } - internal ulong Blocks - { - get { return blocks; } - } - internal uint BlocksToRead - { - get { return blocksToRead; } - } - internal uint LogicalBlockSize - { - get { return blockSize; } - } - internal uint PhysicalBlockSize - { - get { return physicalsectorsize; } - } - internal uint LongBlockSize - { - get { return longBlockSize; } - } - internal bool CanReadRaw - { - get { return readRaw; } - } + internal string ErrorMessage { get; private set; } + internal ulong Blocks { get; set; } + internal uint BlocksToRead { get; private set; } + internal uint LogicalBlockSize { get; private set; } + internal uint PhysicalBlockSize { get; private set; } + internal uint LongBlockSize { get; private set; } + internal bool CanReadRaw { get; private set; } internal bool CanSeek { get { return ataSeek || seek6 || seek10; } @@ -89,8 +61,8 @@ namespace DiscImageChef.Core.Devices { this.dev = dev; this.timeout = timeout; - blocksToRead = 64; - readRaw = raw; + BlocksToRead = 64; + CanReadRaw = raw; switch(dev.Type) { @@ -109,7 +81,7 @@ namespace DiscImageChef.Core.Devices case DeviceType.ATAPI: case DeviceType.SCSI: return ScsiGetBlocks(); default: - errorMessage = string.Format("Unknown device type {0}.", dev.Type); + ErrorMessage = string.Format("Unknown device type {0}.", dev.Type); return 0; } } @@ -122,7 +94,7 @@ namespace DiscImageChef.Core.Devices case DeviceType.ATAPI: case DeviceType.SCSI: return ScsiFindReadCommand(); default: - errorMessage = string.Format("Unknown device type {0}.", dev.Type); + ErrorMessage = string.Format("Unknown device type {0}.", dev.Type); return true; } } @@ -135,7 +107,7 @@ namespace DiscImageChef.Core.Devices case DeviceType.ATAPI: case DeviceType.SCSI: return ScsiGetBlockSize(); default: - errorMessage = string.Format("Unknown device type {0}.", dev.Type); + ErrorMessage = string.Format("Unknown device type {0}.", dev.Type); return true; } } @@ -148,7 +120,7 @@ namespace DiscImageChef.Core.Devices case DeviceType.ATAPI: case DeviceType.SCSI: return ScsiGetBlocksToRead(startWithBlocks); default: - errorMessage = string.Format("Unknown device type {0}.", dev.Type); + ErrorMessage = string.Format("Unknown device type {0}.", dev.Type); return true; } } @@ -160,7 +132,7 @@ namespace DiscImageChef.Core.Devices internal bool ReadBlocks(out byte[] buffer, ulong block, out double duration) { - return ReadBlocks(out buffer, block, blocksToRead, out duration); + return ReadBlocks(out buffer, block, BlocksToRead, out duration); } internal bool ReadBlocks(out byte[] buffer, ulong block, uint count, out double duration) diff --git a/DiscImageChef.Core/Devices/ReaderATA.cs b/DiscImageChef.Core/Devices/ReaderATA.cs index ebc85065..2a8e7350 100644 --- a/DiscImageChef.Core/Devices/ReaderATA.cs +++ b/DiscImageChef.Core/Devices/ReaderATA.cs @@ -49,30 +49,15 @@ namespace DiscImageChef.Core.Devices bool ataReadRetry; bool ataReadDma; bool ataReadDmaRetry; - bool lbaMode; - ushort cylinders; - byte heads, sectors; bool ataSeek; bool ataSeekLba; Identify.IdentifyDevice ataId; - internal bool IsLba - { - get { return lbaMode; } - } - internal ushort Cylinders - { - get { return cylinders; } - } - internal byte Heads - { - get { return heads; } - } - internal byte Sectors - { - get { return sectors; } - } + internal bool IsLba { get; private set; } + internal ushort Cylinders { get; private set; } + internal byte Heads { get; private set; } + internal byte Sectors { get; private set; } (uint, byte, byte) GetDeviceChs() { @@ -80,22 +65,22 @@ namespace DiscImageChef.Core.Devices if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 && ataId.CurrentSectorsPerTrack > 0) { - cylinders = ataId.CurrentCylinders; - heads = (byte)ataId.CurrentHeads; - sectors = (byte)ataId.CurrentSectorsPerTrack; - blocks = (ulong)(cylinders * heads * sectors); + Cylinders = ataId.CurrentCylinders; + Heads = (byte)ataId.CurrentHeads; + Sectors = (byte)ataId.CurrentSectorsPerTrack; + 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); + ataId.SectorsPerTrack <= 0) return (Cylinders, Heads, Sectors); - cylinders = ataId.Cylinders; - heads = (byte)ataId.Heads; - sectors = (byte)ataId.SectorsPerTrack; - blocks = (ulong)(cylinders * heads * sectors); + Cylinders = ataId.Cylinders; + Heads = (byte)ataId.Heads; + Sectors = (byte)ataId.SectorsPerTrack; + Blocks = (ulong)(Cylinders * Heads * Sectors); - return (cylinders, heads, sectors); + return (Cylinders, Heads, Sectors); } ulong AtaGetBlocks() @@ -104,16 +89,16 @@ namespace DiscImageChef.Core.Devices if(ataId.Capabilities.HasFlag(Identify.CapabilitiesBit.LBASupport)) { - blocks = ataId.LBASectors; - lbaMode = true; + Blocks = ataId.LBASectors; + IsLba = true; } - if(!ataId.CommandSet2.HasFlag(Identify.CommandSetBit2.LBA48)) return blocks; + if(!ataId.CommandSet2.HasFlag(Identify.CommandSetBit2.LBA48)) return Blocks; - blocks = ataId.LBA48Sectors; - lbaMode = true; + Blocks = ataId.LBA48Sectors; + IsLba = true; - return blocks; + return Blocks; } bool AtaFindReadCommand() @@ -153,17 +138,17 @@ namespace DiscImageChef.Core.Devices sense = dev.Seek(out errorLba, 0, timeout, out duration); ataSeekLba = !sense && (errorLba.status & 0x27) == 0 && errorChs.error == 0; - if(lbaMode) + if(IsLba) { - if(blocks > 0xFFFFFFF && !ataReadLba48 && !ataReadDmaLba48) + if(Blocks > 0xFFFFFFF && !ataReadLba48 && !ataReadDmaLba48) { - errorMessage = "Device needs 48-bit LBA commands but I can't issue them... Aborting."; + ErrorMessage = "Device needs 48-bit LBA commands but I can't issue them... Aborting."; return true; } if(!ataReadLba && !ataReadRetryLba && !ataReadDmaLba && !ataReadDmaRetryLba) { - errorMessage = "Device needs 28-bit LBA commands but I can't issue them... Aborting."; + ErrorMessage = "Device needs 28-bit LBA commands but I can't issue them... Aborting."; return true; } } @@ -171,7 +156,7 @@ namespace DiscImageChef.Core.Devices { if(!ataRead && !ataReadRetry && !ataReadDma && !ataReadDmaRetry) { - errorMessage = "Device needs CHS commands but I can't issue them... Aborting."; + ErrorMessage = "Device needs CHS commands but I can't issue them... Aborting."; return true; } } @@ -188,7 +173,7 @@ namespace DiscImageChef.Core.Devices else if(ataRead) DicConsole.WriteLine("Using ATA READ command (CHS)."); else { - errorMessage = "Could not get a working read command!"; + ErrorMessage = "Could not get a working read command!"; return true; } @@ -200,37 +185,37 @@ namespace DiscImageChef.Core.Devices if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 && (ataId.PhysLogSectorSize & 0x4000) == 0x4000) { if((ataId.PhysLogSectorSize & 0x1000) == 0x1000) - if(ataId.LogicalSectorWords <= 255 || ataId.LogicalAlignment == 0xFFFF) blockSize = 512; - else blockSize = ataId.LogicalSectorWords * 2; - else blockSize = 512; + if(ataId.LogicalSectorWords <= 255 || ataId.LogicalAlignment == 0xFFFF) LogicalBlockSize = 512; + else LogicalBlockSize = ataId.LogicalSectorWords * 2; + else LogicalBlockSize = 512; if((ataId.PhysLogSectorSize & 0x2000) == 0x2000) { #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created - physicalsectorsize = blockSize * (uint)Math.Pow(2, (double)(ataId.PhysLogSectorSize & 0xF)); + PhysicalBlockSize = LogicalBlockSize * (uint)Math.Pow(2, (double)(ataId.PhysLogSectorSize & 0xF)); #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created } - else physicalsectorsize = blockSize; + else PhysicalBlockSize = LogicalBlockSize; } else { - blockSize = 512; - physicalsectorsize = 512; + LogicalBlockSize = 512; + PhysicalBlockSize = 512; } // TODO: ATA READ LONG - longBlockSize = 0; + LongBlockSize = 0; return false; } bool AtaGetBlocksToRead(uint startWithBlocks) { - blocksToRead = startWithBlocks; + BlocksToRead = startWithBlocks; - if(!lbaMode) + if(!IsLba) { - blocksToRead = 1; + BlocksToRead = 1; return false; } @@ -241,48 +226,48 @@ namespace DiscImageChef.Core.Devices double duration; bool error = true; - while(lbaMode) + while(IsLba) { if(ataReadDmaLba48) { - sense = dev.ReadDma(out cmdBuf, out errorLba48, 0, (byte)blocksToRead, timeout, out duration); + sense = dev.ReadDma(out cmdBuf, out errorLba48, 0, (byte)BlocksToRead, timeout, out duration); error = !(!sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0); } else if(ataReadLba48) { - sense = dev.Read(out cmdBuf, out errorLba48, 0, (byte)blocksToRead, timeout, out duration); + sense = dev.Read(out cmdBuf, out errorLba48, 0, (byte)BlocksToRead, timeout, out duration); error = !(!sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0); } else if(ataReadDmaRetryLba) { - sense = dev.ReadDma(out cmdBuf, out errorLba, true, 0, (byte)blocksToRead, timeout, out duration); + sense = dev.ReadDma(out cmdBuf, out errorLba, true, 0, (byte)BlocksToRead, timeout, out duration); error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); } else if(ataReadDmaLba) { - sense = dev.ReadDma(out cmdBuf, out errorLba, false, 0, (byte)blocksToRead, timeout, out duration); + sense = dev.ReadDma(out cmdBuf, out errorLba, false, 0, (byte)BlocksToRead, timeout, out duration); error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); } else if(ataReadRetryLba) { - sense = dev.Read(out cmdBuf, out errorLba, true, 0, (byte)blocksToRead, timeout, out duration); + sense = dev.Read(out cmdBuf, out errorLba, true, 0, (byte)BlocksToRead, timeout, out duration); error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); } else if(ataReadLba) { - sense = dev.Read(out cmdBuf, out errorLba, false, 0, (byte)blocksToRead, timeout, out duration); + sense = dev.Read(out cmdBuf, out errorLba, false, 0, (byte)BlocksToRead, timeout, out duration); error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); } - if(error) blocksToRead /= 2; + if(error) BlocksToRead /= 2; - if(!error || blocksToRead == 1) break; + if(!error || BlocksToRead == 1) break; } - if(!error || !lbaMode) return false; + if(!error || !IsLba) return false; - blocksToRead = 1; - errorMessage = string.Format("Device error {0} trying to guess ideal transfer length.", dev.LastError); + BlocksToRead = 1; + ErrorMessage = string.Format("Device error {0} trying to guess ideal transfer length.", dev.LastError); return true; } diff --git a/DiscImageChef.Core/Devices/ReaderSCSI.cs b/DiscImageChef.Core/Devices/ReaderSCSI.cs index c1a507cc..becfd432 100644 --- a/DiscImageChef.Core/Devices/ReaderSCSI.cs +++ b/DiscImageChef.Core/Devices/ReaderSCSI.cs @@ -54,7 +54,7 @@ namespace DiscImageChef.Core.Devices ulong ScsiGetBlocks() { - return ScsiGetBlockSize() ? 0 : blocks; + return ScsiGetBlockSize() ? 0 : Blocks; } bool ScsiFindReadCommand() @@ -63,15 +63,15 @@ namespace DiscImageChef.Core.Devices byte[] senseBuf; double duration; - read6 = !dev.Read6(out readBuffer, out senseBuf, 0, blockSize, timeout, out duration); + read6 = !dev.Read6(out readBuffer, out senseBuf, 0, LogicalBlockSize, timeout, out duration); - read10 = !dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, 1, + read10 = !dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, 0, LogicalBlockSize, 0, 1, timeout, out duration); - read12 = !dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, 1, false, + read12 = !dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, LogicalBlockSize, 0, 1, false, timeout, out duration); - read16 = !dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, 0, blockSize, 0, 1, false, + read16 = !dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, 0, LogicalBlockSize, 0, 1, false, timeout, out duration); seek6 = !dev.Seek6(out senseBuf, 0, timeout, out duration); @@ -80,35 +80,35 @@ namespace DiscImageChef.Core.Devices if(!read6 && !read10 && !read12 && !read16) { - errorMessage = "Cannot read medium, aborting scan..."; + ErrorMessage = "Cannot read medium, aborting scan..."; return true; } - if(read6 && !read10 && !read12 && !read16 && blocks > 0x001FFFFF + 1) + if(read6 && !read10 && !read12 && !read16 && Blocks > 0x001FFFFF + 1) { - errorMessage = + ErrorMessage = string.Format("Device only supports SCSI READ (6) but has more than {0} blocks ({1} blocks total)", - 0x001FFFFF + 1, blocks); + 0x001FFFFF + 1, Blocks); return true; } #pragma warning disable IDE0004 // Remove Unnecessary Cast - if(!read16 && blocks > (long)0xFFFFFFFF + (long)1) + if(!read16 && Blocks > (long)0xFFFFFFFF + (long)1) #pragma warning restore IDE0004 // Remove Unnecessary Cast { #pragma warning disable IDE0004 // Remove Unnecessary Cast - errorMessage = + ErrorMessage = string.Format("Device only supports SCSI READ (10) but has more than {0} blocks ({1} blocks total)", - (long)0xFFFFFFFF + (long)1, blocks); + (long)0xFFFFFFFF + (long)1, Blocks); #pragma warning restore IDE0004 // Remove Unnecessary Cast return true; } - if(readRaw) + if(CanReadRaw) { bool testSense; Decoders.SCSI.FixedSense? decSense; - readRaw = false; + CanReadRaw = false; if(dev.ScsiType != Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { @@ -140,18 +140,18 @@ namespace DiscImageChef.Core.Devices if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest && decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00) { - readRaw = true; + CanReadRaw = true; if(decSense.Value.InformationValid && decSense.Value.ILI) { - longBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); + LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); readLong10 = !dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, - (ushort)longBlockSize, timeout, out duration); + (ushort)LongBlockSize, timeout, out duration); } } } - if(readRaw && longBlockSize == blockSize) - if(blockSize == 512) + if(CanReadRaw && LongBlockSize == LogicalBlockSize) + if(LogicalBlockSize == 512) foreach(ushort testSize in new[] { // Long sector sizes for floppies @@ -167,8 +167,8 @@ namespace DiscImageChef.Core.Devices if(!testSense && !dev.Error) { readLong16 = true; - longBlockSize = testSize; - readRaw = true; + LongBlockSize = testSize; + CanReadRaw = true; break; } @@ -177,11 +177,11 @@ namespace DiscImageChef.Core.Devices if(testSense || dev.Error) continue; readLong10 = true; - longBlockSize = testSize; - readRaw = true; + LongBlockSize = testSize; + CanReadRaw = true; break; } - else if(blockSize == 1024) + else if(LogicalBlockSize == 1024) foreach(ushort testSize in new[] { // Long sector sizes for floppies @@ -195,8 +195,8 @@ namespace DiscImageChef.Core.Devices if(!testSense && !dev.Error) { readLong16 = true; - longBlockSize = testSize; - readRaw = true; + LongBlockSize = testSize; + CanReadRaw = true; break; } @@ -205,19 +205,19 @@ namespace DiscImageChef.Core.Devices if(testSense || dev.Error) continue; readLong10 = true; - longBlockSize = testSize; - readRaw = true; + LongBlockSize = testSize; + CanReadRaw = true; break; } - else if(blockSize == 2048) + else if(LogicalBlockSize == 2048) { testSense = dev.ReadLong16(out readBuffer, out senseBuf, false, 0, 2380, timeout, out duration); if(!testSense && !dev.Error) { readLong16 = true; - longBlockSize = 2380; - readRaw = true; + LongBlockSize = 2380; + CanReadRaw = true; } else { @@ -226,20 +226,20 @@ namespace DiscImageChef.Core.Devices if(!testSense && !dev.Error) { readLong10 = true; - longBlockSize = 2380; - readRaw = true; + LongBlockSize = 2380; + CanReadRaw = true; } } } - else if(blockSize == 4096) + else if(LogicalBlockSize == 4096) { testSense = dev.ReadLong16(out readBuffer, out senseBuf, false, 0, 4760, timeout, out duration); if(!testSense && !dev.Error) { readLong16 = true; - longBlockSize = 4760; - readRaw = true; + LongBlockSize = 4760; + CanReadRaw = true; } else { @@ -248,20 +248,20 @@ namespace DiscImageChef.Core.Devices if(!testSense && !dev.Error) { readLong10 = true; - longBlockSize = 4760; - readRaw = true; + LongBlockSize = 4760; + CanReadRaw = true; } } } - else if(blockSize == 8192) + else if(LogicalBlockSize == 8192) { testSense = dev.ReadLong16(out readBuffer, out senseBuf, false, 0, 9424, timeout, out duration); if(!testSense && !dev.Error) { readLong16 = true; - longBlockSize = 9424; - readRaw = true; + LongBlockSize = 9424; + CanReadRaw = true; } else { @@ -270,13 +270,13 @@ namespace DiscImageChef.Core.Devices if(!testSense && !dev.Error) { readLong10 = true; - longBlockSize = 9424; - readRaw = true; + LongBlockSize = 9424; + CanReadRaw = true; } } } - if(!readRaw && dev.Manufacturer == "SYQUEST") + if(!CanReadRaw && dev.Manufacturer == "SYQUEST") { testSense = dev.SyQuestReadLong10(out readBuffer, out senseBuf, 0, 0xFFFF, timeout, out duration); @@ -287,12 +287,12 @@ namespace DiscImageChef.Core.Devices if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest && decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00) { - readRaw = true; + CanReadRaw = true; if(decSense.Value.InformationValid && decSense.Value.ILI) { - longBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); + LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); syqReadLong10 = - !dev.SyQuestReadLong10(out readBuffer, out senseBuf, 0, longBlockSize, + !dev.SyQuestReadLong10(out readBuffer, out senseBuf, 0, LongBlockSize, timeout, out duration); } } @@ -307,28 +307,28 @@ namespace DiscImageChef.Core.Devices if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest && decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00) { - readRaw = true; + CanReadRaw = true; if(decSense.Value.InformationValid && decSense.Value.ILI) { - longBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); + LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); syqReadLong6 = !dev.SyQuestReadLong6(out readBuffer, out senseBuf, 0, - longBlockSize, timeout, out duration); + LongBlockSize, timeout, out duration); } } } } } - if(!readRaw && blockSize == 256) + if(!CanReadRaw && LogicalBlockSize == 256) { testSense = dev.SyQuestReadLong6(out readBuffer, out senseBuf, 0, 262, timeout, out duration); if(!testSense && !dev.Error) { syqReadLong6 = true; - longBlockSize = 262; - readRaw = true; + LongBlockSize = 262; + CanReadRaw = true; } } } @@ -348,26 +348,26 @@ namespace DiscImageChef.Core.Devices if(hldtstReadRaw || plextorReadRaw) { - readRaw = true; - longBlockSize = 2064; + CanReadRaw = true; + LongBlockSize = 2064; } // READ LONG (10) for some DVD drives - if(!readRaw && dev.Manufacturer == "MATSHITA") + if(!CanReadRaw && dev.Manufacturer == "MATSHITA") { testSense = dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, 37856, timeout, out duration); if(!testSense && !dev.Error) { readLongDvd = true; - longBlockSize = 37856; - readRaw = true; + LongBlockSize = 37856; + CanReadRaw = true; } } } } - if(readRaw) + if(CanReadRaw) { if(readLong16) DicConsole.WriteLine("Using SCSI READ LONG (16) command."); else if(readLong10 || readLongDvd) DicConsole.WriteLine("Using SCSI READ LONG (10) command."); @@ -390,23 +390,23 @@ namespace DiscImageChef.Core.Devices byte[] cmdBuf; byte[] senseBuf; double duration; - blocks = 0; + Blocks = 0; sense = dev.ReadCapacity(out cmdBuf, out senseBuf, timeout, out duration); if(!sense) { - blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]); - blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); + Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]); + LogicalBlockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); } - if(sense || blocks == 0xFFFFFFFF) + if(sense || Blocks == 0xFFFFFFFF) { sense = dev.ReadCapacity16(out cmdBuf, out senseBuf, timeout, out duration); - if(sense && blocks == 0) + if(sense && Blocks == 0) if(dev.ScsiType != Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { - errorMessage = string.Format("Unable to get media capacity\n" + "{0}", + ErrorMessage = string.Format("Unable to get media capacity\n" + "{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); return true; @@ -418,13 +418,13 @@ namespace DiscImageChef.Core.Devices Array.Copy(cmdBuf, 0, temp, 0, 8); Array.Reverse(temp); - blocks = BitConverter.ToUInt64(temp, 0); - blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); + Blocks = BitConverter.ToUInt64(temp, 0); + LogicalBlockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); } } - physicalsectorsize = blockSize; - longBlockSize = blockSize; + PhysicalBlockSize = LogicalBlockSize; + LongBlockSize = LogicalBlockSize; return false; } @@ -434,42 +434,42 @@ namespace DiscImageChef.Core.Devices byte[] readBuffer; byte[] senseBuf; double duration; - blocksToRead = startWithBlocks; + BlocksToRead = startWithBlocks; while(true) { if(read16) { - sense = dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, 0, blockSize, 0, - blocksToRead, false, timeout, out duration); - if(dev.Error) blocksToRead /= 2; + sense = dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, 0, LogicalBlockSize, 0, + BlocksToRead, false, timeout, out duration); + if(dev.Error) BlocksToRead /= 2; } else if(read12) { - sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, 0, blockSize, 0, - blocksToRead, false, timeout, out duration); - if(dev.Error) blocksToRead /= 2; + sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, 0, LogicalBlockSize, 0, + BlocksToRead, false, timeout, out duration); + if(dev.Error) BlocksToRead /= 2; } else if(read10) { - sense = dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, - (ushort)blocksToRead, timeout, out duration); - if(dev.Error) blocksToRead /= 2; + sense = dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, 0, LogicalBlockSize, 0, + (ushort)BlocksToRead, timeout, out duration); + if(dev.Error) BlocksToRead /= 2; } else if(read6) { - sense = dev.Read6(out readBuffer, out senseBuf, 0, blockSize, (byte)blocksToRead, timeout, + sense = dev.Read6(out readBuffer, out senseBuf, 0, LogicalBlockSize, (byte)BlocksToRead, timeout, out duration); - if(dev.Error) blocksToRead /= 2; + if(dev.Error) BlocksToRead /= 2; } - if(!dev.Error || blocksToRead == 1) break; + if(!dev.Error || BlocksToRead == 1) break; } if(!dev.Error) return false; - blocksToRead = 1; - errorMessage = string.Format("Device error {0} trying to guess ideal transfer length.", dev.LastError); + BlocksToRead = 1; + ErrorMessage = string.Format("Device error {0} trying to guess ideal transfer length.", dev.LastError); return true; } @@ -480,39 +480,39 @@ namespace DiscImageChef.Core.Devices buffer = null; duration = 0; - if(readRaw) + if(CanReadRaw) if(readLong16) - sense = dev.ReadLong16(out buffer, out senseBuf, false, block, longBlockSize, timeout, + sense = dev.ReadLong16(out buffer, out senseBuf, false, block, LongBlockSize, timeout, out duration); else if(readLong10) - sense = dev.ReadLong10(out buffer, out senseBuf, false, false, (uint)block, (ushort)longBlockSize, + sense = dev.ReadLong10(out buffer, out senseBuf, false, false, (uint)block, (ushort)LongBlockSize, timeout, out duration); else if(syqReadLong10) - sense = dev.SyQuestReadLong10(out buffer, out senseBuf, (uint)block, longBlockSize, timeout, + sense = dev.SyQuestReadLong10(out buffer, out senseBuf, (uint)block, LongBlockSize, timeout, out duration); else if(syqReadLong6) - sense = dev.SyQuestReadLong6(out buffer, out senseBuf, (uint)block, longBlockSize, timeout, + sense = dev.SyQuestReadLong6(out buffer, out senseBuf, (uint)block, LongBlockSize, timeout, out duration); else if(hldtstReadRaw) - sense = dev.HlDtStReadRawDvd(out buffer, out senseBuf, (uint)block, longBlockSize, timeout, + sense = dev.HlDtStReadRawDvd(out buffer, out senseBuf, (uint)block, LongBlockSize, timeout, out duration); else if(plextorReadRaw) - sense = dev.PlextorReadRawDvd(out buffer, out senseBuf, (uint)block, longBlockSize, timeout, + sense = dev.PlextorReadRawDvd(out buffer, out senseBuf, (uint)block, LongBlockSize, timeout, out duration); else return true; else { if(read16) - sense = dev.Read16(out buffer, out senseBuf, 0, false, true, false, block, blockSize, 0, count, + sense = dev.Read16(out buffer, out senseBuf, 0, false, true, false, block, LogicalBlockSize, 0, count, false, timeout, out duration); else if(read12) - sense = dev.Read12(out buffer, out senseBuf, 0, false, false, false, false, (uint)block, blockSize, + sense = dev.Read12(out buffer, out senseBuf, 0, false, false, false, false, (uint)block, LogicalBlockSize, 0, count, false, timeout, out duration); else if(read10) - sense = dev.Read10(out buffer, out senseBuf, 0, false, true, false, false, (uint)block, blockSize, + sense = dev.Read10(out buffer, out senseBuf, 0, false, true, false, false, (uint)block, LogicalBlockSize, 0, (ushort)count, timeout, out duration); else if(read6) - sense = dev.Read6(out buffer, out senseBuf, (uint)block, blockSize, (byte)count, timeout, + sense = dev.Read6(out buffer, out senseBuf, (uint)block, LogicalBlockSize, (byte)count, timeout, out duration); else return true; } diff --git a/DiscImageChef.Devices/Device/AtaCommands/Ata28.cs b/DiscImageChef.Devices/Device/AtaCommands/Ata28.cs index d471929c..af8c12a7 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/Ata28.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/Ata28.cs @@ -46,10 +46,10 @@ namespace DiscImageChef.Devices registers.command = (byte)AtaCommands.ReadBuffer; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ BUFFER took {0} ms.", duration); @@ -65,9 +65,9 @@ namespace DiscImageChef.Devices registers.command = (byte)AtaCommands.ReadBufferDma; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ BUFFER DMA took {0} ms.", duration); @@ -97,9 +97,9 @@ namespace DiscImageChef.Devices registers.lbaLow = (byte)((lba & 0xFF) / 0x1); registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration); @@ -122,10 +122,10 @@ namespace DiscImageChef.Devices registers.lbaLow = (byte)((lba & 0xFF) / 0x1); registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration); @@ -143,10 +143,10 @@ namespace DiscImageChef.Devices registers.command = (byte)AtaCommands.ReadNativeMaxAddress; registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if((statusRegisters.status & 0x23) == 0) { @@ -185,10 +185,10 @@ namespace DiscImageChef.Devices registers.lbaLow = (byte)((lba & 0xFF) / 0x1); registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration); @@ -217,10 +217,10 @@ namespace DiscImageChef.Devices registers.lbaLow = (byte)((lba & 0xFF) / 0x1); registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration); @@ -240,10 +240,10 @@ namespace DiscImageChef.Devices registers.lbaLow = (byte)((lba & 0xFF) / 0x1); registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/AtaCommands/Ata48.cs b/DiscImageChef.Devices/Device/AtaCommands/Ata48.cs index 1a4a749c..ea0287e7 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/Ata48.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/Ata48.cs @@ -48,10 +48,10 @@ namespace DiscImageChef.Devices registers.command = (byte)AtaCommands.NativeMaxAddress; registers.feature = 0x0000; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if((statusRegisters.status & 0x23) == 0) { @@ -81,9 +81,9 @@ namespace DiscImageChef.Devices registers.lbaLow = (ushort)((lba & 0xFFFF) / 0x1); registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ DMA EXT took {0} ms.", duration); @@ -103,10 +103,10 @@ namespace DiscImageChef.Devices registers.lbaLow += logAddress; registers.lbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100); - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ LOG EXT took {0} ms.", duration); @@ -126,9 +126,9 @@ namespace DiscImageChef.Devices registers.lbaLow += logAddress; registers.lbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100); - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ LOG DMA EXT took {0} ms.", duration); @@ -150,10 +150,10 @@ namespace DiscImageChef.Devices registers.lbaLow = (ushort)((lba & 0xFFFF) / 0x1); registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE EXT took {0} ms.", duration); @@ -171,10 +171,10 @@ namespace DiscImageChef.Devices registers.command = (byte)AtaCommands.ReadNativeMaxAddressExt; registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if((statusRegisters.status & 0x23) == 0) { @@ -204,10 +204,10 @@ namespace DiscImageChef.Devices registers.lbaLow = (ushort)((lba & 0xFFFF) / 0x1); registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ SECTORS EXT took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs b/DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs index d739245d..d01e00cf 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs @@ -90,10 +90,10 @@ namespace DiscImageChef.Devices registers.command = (byte)AtaCommands.IdentifyDevice; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "IDENTIFY DEVICE took {0} ms.", duration); @@ -122,9 +122,9 @@ namespace DiscImageChef.Devices registers.deviceHead = (byte)(head & 0x0F); registers.sector = sector; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration); @@ -146,10 +146,10 @@ namespace DiscImageChef.Devices registers.deviceHead = (byte)(head & 0x0F); registers.sector = sector; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration); @@ -178,10 +178,10 @@ namespace DiscImageChef.Devices registers.deviceHead = (byte)(head & 0x0F); registers.sector = sector; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration); @@ -210,10 +210,10 @@ namespace DiscImageChef.Devices registers.deviceHead = (byte)(head & 0x0F); registers.sector = sector; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration); @@ -233,10 +233,10 @@ namespace DiscImageChef.Devices registers.deviceHead = (byte)(head & 0x0F); registers.sector = sector; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/AtaCommands/Atapi.cs b/DiscImageChef.Devices/Device/AtaCommands/Atapi.cs index 984984dc..463b7056 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/Atapi.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/Atapi.cs @@ -90,10 +90,10 @@ namespace DiscImageChef.Devices registers.command = (byte)AtaCommands.IdentifyPacketDevice; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "IDENTIFY PACKET DEVICE took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/AtaCommands/Cfa.cs b/DiscImageChef.Devices/Device/AtaCommands/Cfa.cs index 43833990..bf0b5ca3 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/Cfa.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/Cfa.cs @@ -51,10 +51,10 @@ namespace DiscImageChef.Devices registers.lbaLow = (byte)((lba & 0xFF) / 0x1); registers.deviceHead += 0x40; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration); @@ -74,10 +74,10 @@ namespace DiscImageChef.Devices registers.sector = sector; registers.deviceHead = (byte)(head & 0x0F); - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration); @@ -93,10 +93,10 @@ namespace DiscImageChef.Devices registers.command = (byte)AtaCommands.RequestSense; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; errorCode = statusRegisters.error; diff --git a/DiscImageChef.Devices/Device/AtaCommands/MCPT.cs b/DiscImageChef.Devices/Device/AtaCommands/MCPT.cs index af4cbdd3..ebc0c803 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/MCPT.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/MCPT.cs @@ -59,10 +59,10 @@ namespace DiscImageChef.Devices registers.command = (byte)AtaCommands.CheckMediaCardType; registers.feature = feature; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "CHECK MEDIA CARD TYPE took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/AtaCommands/Smart.cs b/DiscImageChef.Devices/Device/AtaCommands/Smart.cs index 186f8f13..9fcd6b0f 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/Smart.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/Smart.cs @@ -48,10 +48,10 @@ namespace DiscImageChef.Devices registers.lbaHigh = 0xC2; registers.lbaMid = 0x4F; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "SMART DISABLE OPERATIONS took {0} ms.", duration); @@ -71,10 +71,10 @@ namespace DiscImageChef.Devices registers.lbaMid = 0x4F; registers.sectorCount = 0xF1; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "SMART ENABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration); @@ -93,10 +93,10 @@ namespace DiscImageChef.Devices registers.lbaHigh = 0xC2; registers.lbaMid = 0x4F; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "SMART DISABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration); @@ -114,10 +114,10 @@ namespace DiscImageChef.Devices registers.lbaHigh = 0xC2; registers.lbaMid = 0x4F; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "SMART ENABLE OPERATIONS took {0} ms.", duration); @@ -137,10 +137,10 @@ namespace DiscImageChef.Devices registers.lbaMid = 0x4F; registers.lbaLow = subcommand; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "SMART EXECUTE OFF-LINE IMMEDIATE took {0} ms.", duration); @@ -159,10 +159,10 @@ namespace DiscImageChef.Devices registers.lbaHigh = 0xC2; registers.lbaMid = 0x4F; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "SMART READ DATA took {0} ms.", duration); @@ -182,10 +182,10 @@ namespace DiscImageChef.Devices registers.lbaMid = 0x4F; registers.lbaLow = logAddress; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "SMART READ LOG took {0} ms.", duration); @@ -203,10 +203,10 @@ namespace DiscImageChef.Devices registers.lbaHigh = 0xC2; registers.lbaMid = 0x4F; - lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, + LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("ATA Device", "SMART RETURN STATUS took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/Commands.cs b/DiscImageChef.Devices/Device/Commands.cs index 78233a27..9fb65798 100644 --- a/DiscImageChef.Devices/Device/Commands.cs +++ b/DiscImageChef.Devices/Device/Commands.cs @@ -50,7 +50,7 @@ namespace DiscImageChef.Devices public int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout, ScsiDirection direction, out double duration, out bool sense) { - return Command.SendScsiCommand(platformId, fd, cdb, ref buffer, out senseBuffer, timeout, direction, + return Command.SendScsiCommand(PlatformId, FileHandle, cdb, ref buffer, out senseBuffer, timeout, direction, out duration, out sense); } @@ -71,7 +71,7 @@ namespace DiscImageChef.Devices AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout, bool transferBlocks, out double duration, out bool sense) { - return Command.SendAtaCommand(platformId, fd, registers, out errorRegisters, protocol, transferRegister, + return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense); } @@ -92,7 +92,7 @@ namespace DiscImageChef.Devices AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout, bool transferBlocks, out double duration, out bool sense) { - return Command.SendAtaCommand(platformId, fd, registers, out errorRegisters, protocol, transferRegister, + return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense); } @@ -113,7 +113,7 @@ namespace DiscImageChef.Devices AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout, bool transferBlocks, out double duration, out bool sense) { - return Command.SendAtaCommand(platformId, fd, registers, out errorRegisters, protocol, transferRegister, + return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense); } @@ -175,7 +175,7 @@ namespace DiscImageChef.Devices if((command != (MmcCommands)SecureDigitalCommands.SendOperatingCondition && command != MmcCommands.SendOpCond) || cachedOcr == null) - return Command.SendMmcCommand(platformId, fd, command, write, isApplication, flags, argument, blockSize, + return Command.SendMmcCommand(PlatformId, FileHandle, command, write, isApplication, flags, argument, blockSize, blocks, ref buffer, out response, out duration, out sense, timeout); { diff --git a/DiscImageChef.Devices/Device/Constructor.cs b/DiscImageChef.Devices/Device/Constructor.cs index cbfc94ec..4dbf5cdf 100644 --- a/DiscImageChef.Devices/Device/Constructor.cs +++ b/DiscImageChef.Devices/Device/Constructor.cs @@ -47,53 +47,53 @@ namespace DiscImageChef.Devices /// Device path public Device(string devicePath) { - platformId = Interop.DetectOS.GetRealPlatformID(); + PlatformId = Interop.DetectOS.GetRealPlatformID(); Timeout = 15; - error = false; - removable = false; + Error = false; + IsRemovable = false; - switch(platformId) + switch(PlatformId) { case Interop.PlatformID.Win32NT: { - fd = Windows.Extern.CreateFile(devicePath, + FileHandle = Windows.Extern.CreateFile(devicePath, Windows.FileAccess.GenericRead | Windows.FileAccess.GenericWrite, Windows.FileShare.Read | Windows.FileShare.Write, IntPtr.Zero, Windows.FileMode.OpenExisting, Windows.FileAttributes.Normal, IntPtr.Zero); - if(((SafeFileHandle)fd).IsInvalid) + if(((SafeFileHandle)FileHandle).IsInvalid) { - error = true; - lastError = Marshal.GetLastWin32Error(); + Error = true; + LastError = Marshal.GetLastWin32Error(); } break; } case Interop.PlatformID.Linux: { - fd = Linux.Extern.open(devicePath, Linux.FileFlags.Readonly | Linux.FileFlags.NonBlocking); + FileHandle = Linux.Extern.open(devicePath, Linux.FileFlags.Readonly | Linux.FileFlags.NonBlocking); - if((int)fd < 0) + if((int)FileHandle < 0) { - error = true; - lastError = Marshal.GetLastWin32Error(); + Error = true; + LastError = Marshal.GetLastWin32Error(); } break; } case Interop.PlatformID.FreeBSD: { - fd = FreeBSD.Extern.cam_open_device(devicePath, FreeBSD.FileFlags.ReadWrite); + FileHandle = FreeBSD.Extern.cam_open_device(devicePath, FreeBSD.FileFlags.ReadWrite); - if(((IntPtr)fd).ToInt64() == 0) + if(((IntPtr)FileHandle).ToInt64() == 0) { - error = true; - lastError = Marshal.GetLastWin32Error(); + Error = true; + LastError = Marshal.GetLastWin32Error(); } FreeBSD.CamDevice camDevice = - (FreeBSD.CamDevice)Marshal.PtrToStructure((IntPtr)fd, typeof(FreeBSD.CamDevice)); + (FreeBSD.CamDevice)Marshal.PtrToStructure((IntPtr)FileHandle, typeof(FreeBSD.CamDevice)); if(StringHandlers.CToString(camDevice.SimName) == "ata") throw new @@ -102,13 +102,13 @@ namespace DiscImageChef.Devices break; } default: - throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", platformId)); + throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", PlatformId)); } - if(error) throw new SystemException(string.Format("Error {0} opening device.", lastError)); + if(Error) throw new SystemException(string.Format("Error {0} opening device.", LastError)); - type = DeviceType.Unknown; - scsiType = Decoders.SCSI.PeripheralDeviceTypes.UnknownDevice; + Type = DeviceType.Unknown; + ScsiType = Decoders.SCSI.PeripheralDeviceTypes.UnknownDevice; AtaErrorRegistersCHS errorRegisters; @@ -116,13 +116,13 @@ namespace DiscImageChef.Devices byte[] senseBuf; byte[] inqBuf = null; - if(error) throw new SystemException(string.Format("Error {0} trying device.", lastError)); + if(Error) throw new SystemException(string.Format("Error {0} trying device.", LastError)); bool scsiSense = true; string ntDevicePath = null; // Windows is answering SCSI INQUIRY for all device types so it needs to be detected first - switch(platformId) { + switch(PlatformId) { case Interop.PlatformID.Win32NT: Windows.StoragePropertyQuery query = new Windows.StoragePropertyQuery(); query.PropertyId = Windows.StoragePropertyId.Device; @@ -135,7 +135,7 @@ namespace DiscImageChef.Devices uint returned = 0; int error = 0; - bool hasError = !Windows.Extern.DeviceIoControlStorageQuery((SafeFileHandle)fd, + bool hasError = !Windows.Extern.DeviceIoControlStorageQuery((SafeFileHandle)FileHandle, Windows.WindowsIoctl .IoctlStorageQueryProperty, ref query, (uint)Marshal.SizeOf(query), @@ -171,35 +171,35 @@ namespace DiscImageChef.Devices case Windows.StorageBusType.Fibre: case Windows.StorageBusType.iSCSI: case Windows.StorageBusType.SAS: - type = DeviceType.SCSI; + Type = DeviceType.SCSI; break; case Windows.StorageBusType.FireWire: - firewire = true; - type = DeviceType.SCSI; + IsFireWire = true; + Type = DeviceType.SCSI; break; case Windows.StorageBusType.USB: - usb = true; - type = DeviceType.SCSI; + IsUsb = true; + Type = DeviceType.SCSI; break; case Windows.StorageBusType.ATAPI: - type = DeviceType.ATAPI; + Type = DeviceType.ATAPI; break; case Windows.StorageBusType.ATA: case Windows.StorageBusType.SATA: - type = DeviceType.ATA; + Type = DeviceType.ATA; break; case Windows.StorageBusType.MultiMediaCard: - type = DeviceType.MMC; + Type = DeviceType.MMC; break; case Windows.StorageBusType.SecureDigital: - type = DeviceType.SecureDigital; + Type = DeviceType.SecureDigital; break; case Windows.StorageBusType.NVMe: - type = DeviceType.NVMe; + Type = DeviceType.NVMe; break; } - switch(type) { + switch(Type) { case DeviceType.SCSI: case DeviceType.ATAPI: scsiSense = ScsiInquiry(out inqBuf, out senseBuf); break; @@ -208,26 +208,26 @@ namespace DiscImageChef.Devices if(!atapiSense) { - type = DeviceType.ATAPI; + Type = DeviceType.ATAPI; Identify.IdentifyDevice? ataid = Identify.Decode(ataBuf); if(ataid.HasValue) scsiSense = ScsiInquiry(out inqBuf, out senseBuf); } - else manufacturer = "ATA"; + else Manufacturer = "ATA"; break; } } - ntDevicePath = Windows.Command.GetDevicePath((SafeFileHandle)fd); + ntDevicePath = Windows.Command.GetDevicePath((SafeFileHandle)FileHandle); DicConsole.DebugWriteLine("Windows devices", "NT device path: {0}", ntDevicePath); Marshal.FreeHGlobal(descriptorPtr); - if(Windows.Command.IsSdhci((SafeFileHandle)fd)) + if(Windows.Command.IsSdhci((SafeFileHandle)FileHandle)) { byte[] sdBuffer = new byte[16]; bool sense = false; - lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd, MmcCommands.SendCsd, false, false, + LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCsd, false, false, MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out uint[] response, out double duration, out sense, 0); @@ -241,7 +241,7 @@ namespace DiscImageChef.Devices sdBuffer = new byte[16]; sense = false; - lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd, MmcCommands.SendCid, false, false, + LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCid, false, false, MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out response, out duration, out sense, 0); @@ -255,7 +255,7 @@ namespace DiscImageChef.Devices sdBuffer = new byte[8]; sense = false; - lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd, + LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, (MmcCommands)SecureDigitalCommands.SendScr, false, true, MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 8, 1, ref sdBuffer, @@ -272,7 +272,7 @@ namespace DiscImageChef.Devices sdBuffer = new byte[4]; sense = false; - lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd, + LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, (MmcCommands)SecureDigitalCommands .SendOperatingCondition, false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | @@ -290,7 +290,7 @@ namespace DiscImageChef.Devices sdBuffer = new byte[4]; sense = false; - lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd, MmcCommands.SendOpCond, false, + LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendOpCond, false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer, @@ -342,34 +342,34 @@ namespace DiscImageChef.Devices #region SecureDigital / MultiMediaCard if(cachedCid != null) { - scsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess; - removable = false; + ScsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess; + IsRemovable = false; if(cachedScr != null) { - type = DeviceType.SecureDigital; + Type = DeviceType.SecureDigital; Decoders.SecureDigital.CID decoded = Decoders.SecureDigital.Decoders.DecodeCID(cachedCid); - manufacturer = Decoders.SecureDigital.VendorString.Prettify(decoded.Manufacturer); - model = decoded.ProductName; - revision = string.Format("{0:X2}.{1:X2}", (decoded.ProductRevision & 0xF0) >> 4, + Manufacturer = Decoders.SecureDigital.VendorString.Prettify(decoded.Manufacturer); + Model = decoded.ProductName; + Revision = string.Format("{0:X2}.{1:X2}", (decoded.ProductRevision & 0xF0) >> 4, decoded.ProductRevision & 0x0F); - serial = string.Format("{0}", decoded.ProductSerialNumber); + Serial = string.Format("{0}", decoded.ProductSerialNumber); } else { - type = DeviceType.MMC; + Type = DeviceType.MMC; Decoders.MMC.CID decoded = Decoders.MMC.Decoders.DecodeCID(cachedCid); - manufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); - model = decoded.ProductName; - revision = string.Format("{0:X2}.{1:X2}", (decoded.ProductRevision & 0xF0) >> 4, + Manufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); + Model = decoded.ProductName; + Revision = string.Format("{0:X2}.{1:X2}", (decoded.ProductRevision & 0xF0) >> 4, decoded.ProductRevision & 0x0F); - serial = string.Format("{0}", decoded.ProductSerialNumber); + Serial = string.Format("{0}", decoded.ProductSerialNumber); } } #endregion SecureDigital / MultiMediaCard #region USB - switch(platformId) { + switch(PlatformId) { case Interop.PlatformID.Linux: if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || @@ -397,8 +397,8 @@ namespace DiscImageChef.Devices 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); + UsbDescriptors = new byte[usbCount]; + Array.Copy(usbBuf, 0, UsbDescriptors, 0, usbCount); usbFs.Close(); usbSr = new System.IO.StreamReader(resolvedLink + "/idProduct"); @@ -416,25 +416,25 @@ namespace DiscImageChef.Devices if(System.IO.File.Exists(resolvedLink + "/manufacturer")) { usbSr = new System.IO.StreamReader(resolvedLink + "/manufacturer"); - usbManufacturerString = usbSr.ReadToEnd().Trim(); + UsbManufacturerString = usbSr.ReadToEnd().Trim(); usbSr.Close(); } if(System.IO.File.Exists(resolvedLink + "/product")) { usbSr = new System.IO.StreamReader(resolvedLink + "/product"); - usbProductString = usbSr.ReadToEnd().Trim(); + UsbProductString = usbSr.ReadToEnd().Trim(); usbSr.Close(); } if(System.IO.File.Exists(resolvedLink + "/serial")) { usbSr = new System.IO.StreamReader(resolvedLink + "/serial"); - usbSerialString = usbSr.ReadToEnd().Trim(); + UsbSerialString = usbSr.ReadToEnd().Trim(); usbSr.Close(); } - usb = true; + IsUsb = true; break; } } @@ -457,22 +457,22 @@ namespace DiscImageChef.Devices if(usbDevice != null) { - usbDescriptors = usbDevice.BinaryDescriptors; + UsbDescriptors = usbDevice.BinaryDescriptors; usbVendor = (ushort)usbDevice.DeviceDescriptor.idVendor; usbProduct = (ushort)usbDevice.DeviceDescriptor.idProduct; - usbManufacturerString = usbDevice.Manufacturer; - usbProductString = usbDevice.Product; - usbSerialString = + UsbManufacturerString = usbDevice.Manufacturer; + UsbProductString = usbDevice.Product; + UsbSerialString = usbDevice.SerialNumber; // This is incorrect filled by Windows with SCSI/ATA serial number } break; - default: usb = false; + default: IsUsb = false; break; } #endregion USB #region FireWire - if(platformId == Interop.PlatformID.Linux) + if(PlatformId == Interop.PlatformID.Linux) { if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || @@ -516,29 +516,29 @@ namespace DiscImageChef.Devices if(System.IO.File.Exists(resolvedLink + "/model_name")) { fwSr = new System.IO.StreamReader(resolvedLink + "/model_name"); - firewireModelName = fwSr.ReadToEnd().Trim(); + 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(); + FireWireVendorName = fwSr.ReadToEnd().Trim(); fwSr.Close(); } - firewire = true; + IsFireWire = true; break; } } } } // TODO: Implement for other operating systems - else firewire = false; + else IsFireWire = false; #endregion FireWire #region PCMCIA - if(platformId == Interop.PlatformID.Linux) + if(PlatformId == Interop.PlatformID.Linux) { if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || @@ -574,112 +574,112 @@ namespace DiscImageChef.Devices 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); + Cis = new byte[cisCount]; + Array.Copy(cisBuf, 0, Cis, 0, cisCount); cisFs.Close(); - pcmcia = true; + IsPcmcia = true; break; } } } } // TODO: Implement for other operating systems - else pcmcia = false; + else IsPcmcia = false; #endregion PCMCIA if(!scsiSense) { Decoders.SCSI.Inquiry.SCSIInquiry? inquiry = Decoders.SCSI.Inquiry.Decode(inqBuf); - type = DeviceType.SCSI; + Type = DeviceType.SCSI; bool serialSense = ScsiInquiry(out inqBuf, out senseBuf, 0x80); - if(!serialSense) serial = Decoders.SCSI.EVPD.DecodePage80(inqBuf); + if(!serialSense) Serial = Decoders.SCSI.EVPD.DecodePage80(inqBuf); if(inquiry.HasValue) { string tmp = StringHandlers.CToString(inquiry.Value.ProductRevisionLevel); - if(tmp != null) revision = tmp.Trim(); + if(tmp != null) Revision = tmp.Trim(); tmp = StringHandlers.CToString(inquiry.Value.ProductIdentification); - if(tmp != null) model = tmp.Trim(); + if(tmp != null) Model = tmp.Trim(); tmp = StringHandlers.CToString(inquiry.Value.VendorIdentification); - if(tmp != null) manufacturer = tmp.Trim(); - removable = inquiry.Value.RMB; + if(tmp != null) Manufacturer = tmp.Trim(); + IsRemovable = inquiry.Value.RMB; - scsiType = (Decoders.SCSI.PeripheralDeviceTypes)inquiry.Value.PeripheralDeviceType; + ScsiType = (Decoders.SCSI.PeripheralDeviceTypes)inquiry.Value.PeripheralDeviceType; } bool atapiSense = AtapiIdentify(out ataBuf, out errorRegisters); if(!atapiSense) { - type = DeviceType.ATAPI; + Type = DeviceType.ATAPI; Identify.IdentifyDevice? ataId = Identify.Decode(ataBuf); - if(ataId.HasValue) serial = ataId.Value.SerialNumber; + if(ataId.HasValue) Serial = ataId.Value.SerialNumber; } else { - lastError = 0; - error = false; + LastError = 0; + Error = false; } } - if(scsiSense && (usb || firewire) || manufacturer == "ATA") + if(scsiSense && (IsUsb || IsFireWire) || Manufacturer == "ATA") { bool ataSense = AtaIdentify(out ataBuf, out errorRegisters); if(!ataSense) { - type = DeviceType.ATA; + Type = DeviceType.ATA; Identify.IdentifyDevice? ataid = Identify.Decode(ataBuf); if(ataid.HasValue) { string[] separated = ataid.Value.Model.Split(' '); - if(separated.Length == 1) model = separated[0]; + if(separated.Length == 1) Model = separated[0]; else { - manufacturer = separated[0]; - model = separated[separated.Length - 1]; + Manufacturer = separated[0]; + Model = separated[separated.Length - 1]; } - revision = ataid.Value.FirmwareRevision; - serial = ataid.Value.SerialNumber; + Revision = ataid.Value.FirmwareRevision; + Serial = ataid.Value.SerialNumber; - scsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess; + ScsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess; if((ushort)ataid.Value.GeneralConfiguration != 0x848A) - removable |= + IsRemovable |= (ataid.Value.GeneralConfiguration & Identify.GeneralConfigurationBit.Removable) == Identify.GeneralConfigurationBit.Removable; - else compactFlash = true; + else IsCompactFlash = true; } } } - if(type == DeviceType.Unknown) + if(Type == DeviceType.Unknown) { - manufacturer = null; - model = null; - revision = null; - serial = null; + Manufacturer = null; + Model = null; + Revision = null; + Serial = null; } - if(usb) + if(IsUsb) { - if(string.IsNullOrEmpty(manufacturer)) manufacturer = usbManufacturerString; - if(string.IsNullOrEmpty(model)) model = usbProductString; - if(string.IsNullOrEmpty(serial)) serial = usbSerialString; - else foreach(char c in serial.Where(c => char.IsControl(c))) serial = usbSerialString; + if(string.IsNullOrEmpty(Manufacturer)) Manufacturer = UsbManufacturerString; + if(string.IsNullOrEmpty(Model)) Model = UsbProductString; + if(string.IsNullOrEmpty(Serial)) Serial = UsbSerialString; + else foreach(char c in Serial.Where(c => char.IsControl(c))) Serial = UsbSerialString; } - if(!firewire) return; + if(!IsFireWire) 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.Where(c => char.IsControl(c))) serial = string.Format("{0:X16}", firewireGuid); + 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.Where(c => 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 69295e1b..519ab3b2 100644 --- a/DiscImageChef.Devices/Device/Destructor.cs +++ b/DiscImageChef.Devices/Device/Destructor.cs @@ -43,18 +43,18 @@ namespace DiscImageChef.Devices /// ~Device() { - if(fd == null) return; + if(FileHandle == null) return; - switch(platformId) + switch(PlatformId) { case Interop.PlatformID.Win32NT: - Windows.Extern.CloseHandle((SafeFileHandle)fd); + Windows.Extern.CloseHandle((SafeFileHandle)FileHandle); break; case Interop.PlatformID.Linux: - Linux.Extern.close((int)fd); + Linux.Extern.close((int)FileHandle); break; case Interop.PlatformID.FreeBSD: - FreeBSD.Extern.cam_close_device((IntPtr)fd); + FreeBSD.Extern.cam_close_device((IntPtr)FileHandle); break; } } diff --git a/DiscImageChef.Devices/Device/MmcCommands/MMC.cs b/DiscImageChef.Devices/Device/MmcCommands/MMC.cs index f73ef6e9..32c6bc0a 100644 --- a/DiscImageChef.Devices/Device/MmcCommands/MMC.cs +++ b/DiscImageChef.Devices/Device/MmcCommands/MMC.cs @@ -41,10 +41,10 @@ namespace DiscImageChef.Devices buffer = new byte[16]; bool sense = false; - lastError = SendMmcCommand(MmcCommands.SendCsd, false, false, + LastError = SendMmcCommand(MmcCommands.SendCsd, false, false, MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1, ref buffer, out response, out duration, out sense, timeout); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("MMC Device", "SEND_CSD took {0} ms.", duration); @@ -56,10 +56,10 @@ namespace DiscImageChef.Devices buffer = new byte[16]; bool sense = false; - lastError = SendMmcCommand(MmcCommands.SendCid, false, false, + LastError = SendMmcCommand(MmcCommands.SendCid, false, false, MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1, ref buffer, out response, out duration, out sense, timeout); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("MMC Device", "SEND_CID took {0} ms.", duration); @@ -71,10 +71,10 @@ namespace DiscImageChef.Devices buffer = new byte[4]; bool sense = false; - lastError = SendMmcCommand(MmcCommands.SendOpCond, false, true, + LastError = SendMmcCommand(MmcCommands.SendOpCond, false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1, ref buffer, out response, out duration, out sense, timeout); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SecureDigital Device", "SEND_OP_COND took {0} ms.", duration); @@ -86,10 +86,10 @@ namespace DiscImageChef.Devices buffer = new byte[512]; bool sense = false; - lastError = SendMmcCommand(MmcCommands.SendExtCsd, false, false, + LastError = SendMmcCommand(MmcCommands.SendExtCsd, false, false, MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 512, 1, ref buffer, out response, out duration, out sense, timeout); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("MMC Device", "SEND_EXT_CSD took {0} ms.", duration); @@ -101,10 +101,10 @@ namespace DiscImageChef.Devices byte[] buffer = new byte[0]; bool sense = false; - lastError = SendMmcCommand(MmcCommands.SetBlocklen, false, false, + LastError = SendMmcCommand(MmcCommands.SetBlocklen, false, false, MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, length, 0, 0, ref buffer, out response, out duration, out sense, timeout); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("MMC Device", "SET_BLOCKLEN took {0} ms.", duration); @@ -124,11 +124,11 @@ namespace DiscImageChef.Devices if(transferLength > 1) command = MmcCommands.ReadMultipleBlock; else command = MmcCommands.ReadSingleBlock; - lastError = SendMmcCommand(command, false, false, + LastError = SendMmcCommand(command, false, false, MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, address, blockSize, transferLength, ref buffer, out response, out duration, out sense, timeout); - error = lastError != 0; + Error = LastError != 0; if(transferLength > 1) { @@ -149,10 +149,10 @@ namespace DiscImageChef.Devices buffer = new byte[4]; bool sense = false; - lastError = SendMmcCommand(MmcCommands.SendStatus, false, true, + LastError = SendMmcCommand(MmcCommands.SendStatus, false, true, MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, 0, 4, 1, ref buffer, out response, out duration, out sense, timeout); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SecureDigital Device", "SEND_STATUS took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/MmcCommands/SecureDigital.cs b/DiscImageChef.Devices/Device/MmcCommands/SecureDigital.cs index 37752212..74fe270e 100644 --- a/DiscImageChef.Devices/Device/MmcCommands/SecureDigital.cs +++ b/DiscImageChef.Devices/Device/MmcCommands/SecureDigital.cs @@ -41,10 +41,10 @@ namespace DiscImageChef.Devices buffer = new byte[64]; bool sense = false; - lastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendStatus, false, true, + LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendStatus, false, true, MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 64, 1, ref buffer, out response, out duration, out sense, timeout); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SecureDigital Device", "SD_STATUS took {0} ms.", duration); @@ -56,10 +56,10 @@ namespace DiscImageChef.Devices buffer = new byte[4]; bool sense = false; - lastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendOperatingCondition, false, true, + LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendOperatingCondition, false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1, ref buffer, out response, out duration, out sense, timeout); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SecureDigital Device", "SD_SEND_OP_COND took {0} ms.", duration); @@ -71,10 +71,10 @@ namespace DiscImageChef.Devices buffer = new byte[8]; bool sense = false; - lastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, false, true, + LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, false, true, MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 8, 1, ref buffer, out response, out duration, out sense, timeout); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SecureDigital Device", "SEND_SCR took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs b/DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs index 10278f88..70413bc8 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs @@ -75,9 +75,9 @@ namespace DiscImageChef.Devices cdb[3] = (byte)(lba & 0xFF); if(drive1) cdb[1] += 0x20; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC TRANSLATE took {0} ms.", duration); @@ -119,9 +119,9 @@ namespace DiscImageChef.Devices if(drive1) cdb[1] += 0x20; cdb[4] = 1; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC SET ERROR THRESHOLD took {0} ms.", duration); @@ -161,9 +161,9 @@ namespace DiscImageChef.Devices if(drive1) cdb[1] += 0x20; cdb[4] = (byte)buffer.Length; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC READ/RESET USAGE COUNTER took {0} ms.", duration); @@ -189,9 +189,9 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.AdaptecWriteBuffer; - lastError = SendScsiCommand(cdb, ref oneKBuffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, ref oneKBuffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC WRITE DATA BUFFER took {0} ms.", duration); @@ -214,9 +214,9 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.AdaptecReadBuffer; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC READ DATA BUFFER took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs b/DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs index 09e08cd6..f613a3d7 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs @@ -57,9 +57,9 @@ namespace DiscImageChef.Devices cdb[3] = (byte)(lba & 0xFF); cdb[4] = 3; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "ARCHIVE CORP. REQUEST BLOCK ADDRESS took {0} ms.", duration); @@ -100,9 +100,9 @@ namespace DiscImageChef.Devices cdb[3] = (byte)(lba & 0xFF); if(immediate) cdb[1] += 0x01; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "ARCHIVE CORP. SEEK BLOCK took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/Certance.cs b/DiscImageChef.Devices/Device/ScsiCommands/Certance.cs index 1e059224..b6ea062c 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/Certance.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/Certance.cs @@ -75,9 +75,9 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.CertanceParkUnpark; if(park) cdb[4] = 1; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "CERTANCE PARK UNPARK took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs b/DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs index 44f76e3a..7d14b2a3 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs @@ -97,9 +97,9 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.FujitsuDisplay; cdb[6] = (byte)buffer.Length; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "FUJITSU DISPLAY took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs b/DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs index 071addb1..e75f7903 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs @@ -66,9 +66,9 @@ namespace DiscImageChef.Devices cdb[10] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[11] = (byte)(buffer.Length & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "HL-DT-ST READ DVD (RAW) took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/HP.cs b/DiscImageChef.Devices/Device/ScsiCommands/HP.cs index 2861d14f..50b051b9 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/HP.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/HP.cs @@ -91,9 +91,9 @@ namespace DiscImageChef.Devices if(sectorCount) buffer = new byte[blockBytes * transferLen]; else buffer = new byte[transferLen]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "HP READ LONG took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/Kreon.cs b/DiscImageChef.Devices/Device/ScsiCommands/Kreon.cs index 6a961cc1..3d1491d6 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/Kreon.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/Kreon.cs @@ -56,9 +56,9 @@ namespace DiscImageChef.Devices cdb[2] = 0x01; cdb[3] = 0x01; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "KREON DEPRECATED UNLOCK took {0} ms.", duration); @@ -122,9 +122,9 @@ namespace DiscImageChef.Devices cdb[3] = 0x11; cdb[4] = (byte)state; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "KREON SET LOCK STATE took {0} ms.", duration); @@ -153,9 +153,9 @@ namespace DiscImageChef.Devices cdb[2] = 0x01; cdb[3] = 0x10; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "KREON GET FEATURE LIST took {0} ms.", duration); @@ -236,9 +236,9 @@ namespace DiscImageChef.Devices cdb[10] = requestNumber; cdb[11] = 0xC0; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "KREON EXTRACT SS took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/MMC.cs b/DiscImageChef.Devices/Device/ScsiCommands/MMC.cs index aa2ab6ea..dc368a69 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/MMC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/MMC.cs @@ -93,9 +93,9 @@ namespace DiscImageChef.Devices cdb[8] = (byte)(buffer.Length & 0xFF); cdb[9] = 0; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if(sense) return true; @@ -107,9 +107,9 @@ namespace DiscImageChef.Devices cdb[8] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[32]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "GET CONFIGURATION took {0} ms.", duration); @@ -150,9 +150,9 @@ namespace DiscImageChef.Devices cdb[9] = (byte)(buffer.Length & 0xFF); cdb[10] = (byte)((agid & 0x03) << 6); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if(sense) return true; @@ -164,9 +164,9 @@ namespace DiscImageChef.Devices cdb[9] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[32]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ DISC STRUCTURE took {0} ms.", duration); @@ -314,9 +314,9 @@ namespace DiscImageChef.Devices cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(tmpBuffer.Length & 0xFF); - lastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; #pragma warning disable IDE0004 // Cast is necessary or an invalid bitshift happens uint strctLength = (uint)(((int)tmpBuffer[0] << 8) + tmpBuffer[1] + 2); @@ -332,9 +332,9 @@ namespace DiscImageChef.Devices double tmpDuration = duration; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; duration += tmpDuration; DicConsole.DebugWriteLine("SCSI Device", "READ TOC/PMA/ATIP took {0} ms.", duration); @@ -377,9 +377,9 @@ namespace DiscImageChef.Devices cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(tmpBuffer.Length & 0xFF); - lastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; #pragma warning disable IDE0004 // Cast is necessary or an invalid bitshift happens uint strctLength = (uint)(((int)tmpBuffer[0] << 8) + tmpBuffer[1] + 2); @@ -441,9 +441,9 @@ namespace DiscImageChef.Devices buffer = new byte[blockSize * transferLength]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ CD took {0} ms.", duration); @@ -498,9 +498,9 @@ namespace DiscImageChef.Devices buffer = new byte[blockSize * transferLength]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ CD MSF took {0} ms.", duration); @@ -529,9 +529,9 @@ namespace DiscImageChef.Devices if(prevent) cdb[4] += 0x01; if(persistent) cdb[4] += 0x02; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PREVENT ALLOW MEDIUM REMOVAL took {0} ms.", duration); @@ -580,9 +580,9 @@ namespace DiscImageChef.Devices } cdb[4] += (byte)((powerConditions & 0x0F) << 4); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "START STOP UNIT took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/NEC.cs b/DiscImageChef.Devices/Device/ScsiCommands/NEC.cs index 2d650bd5..4660267d 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/NEC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/NEC.cs @@ -63,9 +63,9 @@ namespace DiscImageChef.Devices buffer = new byte[2352 * transferLength]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ CD-DA took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs b/DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs index 45e9c433..7808360c 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs @@ -68,9 +68,9 @@ namespace DiscImageChef.Devices buffer = new byte[blockSize * transferLength]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-DA took {0} ms.", duration); @@ -108,9 +108,9 @@ namespace DiscImageChef.Devices uint transferLength = (uint)((cdb[7] - cdb[3]) * 60 * 75 + (cdb[8] - cdb[4]) * 75 + (cdb[9] - cdb[5])); buffer = new byte[blockSize * transferLength]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-DA MSF took {0} ms.", duration); @@ -161,9 +161,9 @@ namespace DiscImageChef.Devices cdb[6] = 0x00; } - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-XA took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs b/DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs index 68791e23..ea5872d8 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs @@ -103,9 +103,9 @@ namespace DiscImageChef.Devices buffer = new byte[8]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLASMON READ SECTOR LOCATION took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs b/DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs index 6c7a7da5..7167794a 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs @@ -70,9 +70,9 @@ namespace DiscImageChef.Devices buffer = new byte[blockSize * transferLength]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ CD-DA took {0} ms.", duration); @@ -106,9 +106,9 @@ namespace DiscImageChef.Devices cdb[4] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[5] = (byte)(buffer.Length & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "Plextor READ DVD (RAW) took {0} ms.", duration); @@ -133,9 +133,9 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.PlextorReadEeprom; cdb[8] = 1; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration); @@ -160,9 +160,9 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.PlextorReadEeprom; cdb[8] = 2; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration); @@ -193,9 +193,9 @@ namespace DiscImageChef.Devices cdb[8] = (byte)((blockSize & 0xFF00) >> 8); cdb[9] = (byte)(blockSize & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration); @@ -227,13 +227,13 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.PlextorPoweRec; cdb[9] = (byte)buf.Length; - lastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR POWEREC GET SPEEDS took {0} ms.", duration); - if(sense || error) return sense; + if(sense || Error) return sense; BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; selected = BigEndianBitConverter.ToUInt16(buf, 4); @@ -267,13 +267,13 @@ namespace DiscImageChef.Devices cdb[1] = (byte)PlextorSubCommands.GetMode; cdb[9] = (byte)buf.Length; - lastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR POWEREC GET SPEEDS took {0} ms.", duration); - if(sense || error) return sense; + if(sense || Error) return sense; BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; enabled = buf[2] != 0; @@ -303,9 +303,9 @@ namespace DiscImageChef.Devices cdb[3] = 4; cdb[10] = (byte)buffer.Length; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SILENT MODE took {0} ms.", duration); @@ -332,9 +332,9 @@ namespace DiscImageChef.Devices cdb[2] = (byte)PlextorSubCommands.GigaRec; cdb[10] = (byte)buffer.Length; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET GIGAREC took {0} ms.", duration); @@ -365,9 +365,9 @@ namespace DiscImageChef.Devices if(dvd) cdb[3] = 0x12; else cdb[3] = 0x02; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET VARIREC took {0} ms.", duration); @@ -393,9 +393,9 @@ namespace DiscImageChef.Devices cdb[2] = (byte)PlextorSubCommands.SecuRec; cdb[10] = (byte)buffer.Length; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SECUREC took {0} ms.", duration); @@ -422,9 +422,9 @@ namespace DiscImageChef.Devices cdb[2] = (byte)PlextorSubCommands.SpeedRead; cdb[10] = (byte)buffer.Length; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SPEEDREAD took {0} ms.", duration); @@ -451,9 +451,9 @@ namespace DiscImageChef.Devices cdb[2] = (byte)PlextorSubCommands.SessionHide; cdb[9] = (byte)buffer.Length; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SINGLE-SESSION / HIDE CD-R took {0} ms.", duration); @@ -484,9 +484,9 @@ namespace DiscImageChef.Devices if(dualLayer) cdb[3] = (byte)PlextorSubCommands.BitSetRdl; else cdb[3] = (byte)PlextorSubCommands.BitSetR; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET BOOK BITSETTING took {0} ms.", duration); @@ -514,9 +514,9 @@ namespace DiscImageChef.Devices cdb[2] = (byte)PlextorSubCommands.TestWriteDvdPlus; cdb[10] = (byte)buffer.Length; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET TEST WRITE DVD+ took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/SBC.cs b/DiscImageChef.Devices/Device/ScsiCommands/SBC.cs index 4aef6863..1f07ed62 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/SBC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/SBC.cs @@ -80,9 +80,9 @@ namespace DiscImageChef.Devices if(transferLength == 0) buffer = new byte[256 * blockSize]; else buffer = new byte[transferLength * blockSize]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ (6) took {0} ms.", duration); @@ -130,9 +130,9 @@ namespace DiscImageChef.Devices buffer = new byte[transferLength * blockSize]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ (10) took {0} ms.", duration); @@ -184,9 +184,9 @@ namespace DiscImageChef.Devices buffer = new byte[transferLength * blockSize]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ (12) took {0} ms.", duration); @@ -241,9 +241,9 @@ namespace DiscImageChef.Devices buffer = new byte[transferLength * blockSize]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ (16) took {0} ms.", duration); @@ -281,9 +281,9 @@ namespace DiscImageChef.Devices buffer = new byte[transferBytes]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ LONG (10) took {0} ms.", duration); @@ -325,9 +325,9 @@ namespace DiscImageChef.Devices buffer = new byte[transferBytes]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ LONG (16) took {0} ms.", duration); @@ -353,9 +353,9 @@ namespace DiscImageChef.Devices cdb[2] = (byte)((lba & 0xFF00) >> 8); cdb[3] = (byte)(lba & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "SEEK (6) took {0} ms.", duration); @@ -382,9 +382,9 @@ namespace DiscImageChef.Devices cdb[4] = (byte)((lba & 0xFF00) >> 8); cdb[5] = (byte)(lba & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "SEEK (10) took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/SMC.cs b/DiscImageChef.Devices/Device/ScsiCommands/SMC.cs index b0317095..f7b42a2b 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/SMC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/SMC.cs @@ -74,9 +74,9 @@ namespace DiscImageChef.Devices cdb[13] = (byte)(buffer.Length & 0xFF); if(cache) cdb[14] += 0x01; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if(sense) return true; @@ -91,9 +91,9 @@ namespace DiscImageChef.Devices cdb[13] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[32]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ ATTRIBUTE took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/SPC.cs b/DiscImageChef.Devices/Device/ScsiCommands/SPC.cs index 16cae51c..e1e4fdbb 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/SPC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/SPC.cs @@ -88,9 +88,9 @@ namespace DiscImageChef.Devices byte[] cdb = {(byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0}; bool sense; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if(sense) return true; @@ -100,9 +100,9 @@ namespace DiscImageChef.Devices buffer = new byte[pagesLength]; senseBuffer = new byte[32]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "INQUIRY took {0} ms.", duration); @@ -164,9 +164,9 @@ namespace DiscImageChef.Devices byte[] cdb = {(byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0}; bool sense; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if(sense) return true; @@ -179,9 +179,9 @@ namespace DiscImageChef.Devices buffer = new byte[pagesLength]; senseBuffer = new byte[32]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "INQUIRY took {0} ms.", duration); @@ -202,9 +202,9 @@ namespace DiscImageChef.Devices bool sense; byte[] buffer = new byte[0]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "TEST UNIT READY took {0} ms.", duration); @@ -271,9 +271,9 @@ namespace DiscImageChef.Devices cdb[4] = (byte)buffer.Length; cdb[5] = 0; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if(sense) return true; @@ -282,9 +282,9 @@ namespace DiscImageChef.Devices cdb[4] = (byte)buffer.Length; senseBuffer = new byte[32]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "MODE SENSE(6) took {0} ms.", duration); @@ -360,9 +360,9 @@ namespace DiscImageChef.Devices cdb[8] = (byte)(buffer.Length & 0xFF); cdb[9] = 0; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if(sense) return true; @@ -374,9 +374,9 @@ namespace DiscImageChef.Devices cdb[8] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[32]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "MODE SENSE(10) took {0} ms.", duration); @@ -444,9 +444,9 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval; cdb[4] = (byte)((byte)preventMode & 0x03); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "PREVENT ALLOW MEDIUM REMOVAL took {0} ms.", duration); @@ -498,9 +498,9 @@ namespace DiscImageChef.Devices cdb[5] = (byte)(address & 0xFF); } - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ CAPACITY took {0} ms.", duration); @@ -560,9 +560,9 @@ namespace DiscImageChef.Devices cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[13] = (byte)(buffer.Length & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ CAPACITY(16) took {0} ms.", duration); @@ -591,9 +591,9 @@ namespace DiscImageChef.Devices cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[9] = (byte)(buffer.Length & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if(sense) return true; @@ -608,9 +608,9 @@ namespace DiscImageChef.Devices cdb[9] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[32]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ MEDIA SERIAL NUMBER took {0} ms.", duration); @@ -738,12 +738,12 @@ namespace DiscImageChef.Devices // Prevent overflows if(buffer.Length > 255) { - if(platformId != Interop.PlatformID.Win32NT && platformId != Interop.PlatformID.Win32S && - platformId != Interop.PlatformID.Win32Windows && platformId != Interop.PlatformID.WinCE && - platformId != Interop.PlatformID.WindowsPhone && - platformId != Interop.PlatformID.Xbox) lastError = 75; - else lastError = 111; - error = true; + if(PlatformId != Interop.PlatformID.Win32NT && PlatformId != Interop.PlatformID.Win32S && + PlatformId != Interop.PlatformID.Win32Windows && PlatformId != Interop.PlatformID.WinCE && + PlatformId != Interop.PlatformID.WindowsPhone && + PlatformId != Interop.PlatformID.Xbox) LastError = 75; + else LastError = 111; + Error = true; duration = 0; return true; } @@ -756,9 +756,9 @@ namespace DiscImageChef.Devices if(savePages) cdb[1] += 0x01; cdb[4] = (byte)buffer.Length; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "MODE SELECT(6) took {0} ms.", duration); @@ -781,12 +781,12 @@ namespace DiscImageChef.Devices // Prevent overflows if(buffer.Length > 65535) { - if(platformId != Interop.PlatformID.Win32NT && platformId != Interop.PlatformID.Win32S && - platformId != Interop.PlatformID.Win32Windows && platformId != Interop.PlatformID.WinCE && - platformId != Interop.PlatformID.WindowsPhone && - platformId != Interop.PlatformID.Xbox) lastError = 75; - else lastError = 111; - error = true; + if(PlatformId != Interop.PlatformID.Win32NT && PlatformId != Interop.PlatformID.Win32S && + PlatformId != Interop.PlatformID.Win32Windows && PlatformId != Interop.PlatformID.WinCE && + PlatformId != Interop.PlatformID.WindowsPhone && + PlatformId != Interop.PlatformID.Xbox) LastError = 75; + else LastError = 111; + Error = true; duration = 0; return true; } @@ -800,9 +800,9 @@ namespace DiscImageChef.Devices cdb[7] = (byte)((buffer.Length & 0xFF00) << 8); cdb[8] = (byte)(buffer.Length & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "MODE SELECT(10) took {0} ms.", duration); @@ -828,9 +828,9 @@ namespace DiscImageChef.Devices cdb[4] = (byte)buffer.Length; cdb[5] = 0; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "REQUEST SENSE took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/SSC.cs b/DiscImageChef.Devices/Device/ScsiCommands/SSC.cs index cc547a64..567c9a74 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/SSC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/SSC.cs @@ -88,9 +88,9 @@ namespace DiscImageChef.Devices if(endOfTape) cdb[4] += 0x04; if(hold) cdb[4] += 0x08; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "LOAD UNLOAD (6) took {0} ms.", duration); @@ -179,9 +179,9 @@ namespace DiscImageChef.Devices cdb[6] = (byte)(objectId & 0xFF); cdb[8] = partition; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "LOCATE (10) took {0} ms.", duration); @@ -282,9 +282,9 @@ namespace DiscImageChef.Devices cdb[10] = idBytes[1]; cdb[11] = idBytes[0]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "LOCATE (16) took {0} ms.", duration); @@ -348,9 +348,9 @@ namespace DiscImageChef.Devices cdb[3] = (byte)((transferLen & 0xFF00) >> 8); cdb[4] = (byte)(transferLen & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ (6) took {0} ms.", duration); @@ -468,9 +468,9 @@ namespace DiscImageChef.Devices cdb[13] = (byte)((transferLen & 0xFF00) >> 8); cdb[14] = (byte)(transferLen & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ (16) took {0} ms.", duration); @@ -493,9 +493,9 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.ReadBlockLimits; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ BLOCK LIMITS took {0} ms.", duration); @@ -590,9 +590,9 @@ namespace DiscImageChef.Devices cdb[8] = (byte)(buffer.Length & 0xFF); } - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ POSITION took {0} ms.", duration); @@ -661,9 +661,9 @@ namespace DiscImageChef.Devices cdb[3] = (byte)((transferLen & 0xFF00) >> 8); cdb[4] = (byte)(transferLen & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ REVERSE (6) took {0} ms.", duration); @@ -784,9 +784,9 @@ namespace DiscImageChef.Devices cdb[13] = (byte)((transferLen & 0xFF00) >> 8); cdb[14] = (byte)(transferLen & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "READ REVERSE (16) took {0} ms.", duration); @@ -853,9 +853,9 @@ namespace DiscImageChef.Devices cdb[3] = (byte)((transferLen & 0xFF00) >> 8); cdb[4] = (byte)(transferLen & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "RECOVER BUFFERED DATA took {0} ms.", duration); @@ -911,9 +911,9 @@ namespace DiscImageChef.Devices cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; if(sense) return true; @@ -925,9 +925,9 @@ namespace DiscImageChef.Devices cdb[8] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[32]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "REPORT DENSITY SUPPORT took {0} ms.", duration); @@ -962,9 +962,9 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.Rewind; if(immediate) cdb[1] += 0x01; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "REWIND took {0} ms.", duration); @@ -989,9 +989,9 @@ namespace DiscImageChef.Devices cdb[0] = (byte)ScsiCommands.TrackSelect; cdb[5] = track; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "TRACK SELECT took {0} ms.", duration); @@ -1012,9 +1012,9 @@ namespace DiscImageChef.Devices cdb[3] = countB[1]; cdb[4] = countB[0]; - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "SPACE took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs b/DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs index 16217b49..17c807bb 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs @@ -107,13 +107,13 @@ namespace DiscImageChef.Devices else buffer = new byte[0]; if(!inhibitDma) - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); else - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "SYQUEST READ (6) took {0} ms.", duration); @@ -189,12 +189,12 @@ namespace DiscImageChef.Devices else buffer = new byte[0]; if(!inhibitDma) - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); else - lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); - error = lastError != 0; + Error = LastError != 0; DicConsole.DebugWriteLine("SCSI Device", "SYQUEST READ (10) took {0} ms.", duration); diff --git a/DiscImageChef.Devices/Device/Variables.cs b/DiscImageChef.Devices/Device/Variables.cs index d913a1cc..7a7eee05 100644 --- a/DiscImageChef.Devices/Device/Variables.cs +++ b/DiscImageChef.Devices/Device/Variables.cs @@ -34,33 +34,11 @@ namespace DiscImageChef.Devices { public partial class Device { - Interop.PlatformID platformId; - object fd; - bool error; - int lastError; - readonly DeviceType type; - readonly string manufacturer; - readonly string model; - readonly string revision; - readonly string serial; - readonly Decoders.SCSI.PeripheralDeviceTypes scsiType; - readonly bool removable; - readonly bool usb; readonly ushort usbVendor; readonly ushort usbProduct; - readonly byte[] usbDescriptors; - readonly string usbManufacturerString; - readonly string usbProductString; - readonly string usbSerialString; - readonly bool firewire; readonly ulong firewireGuid; readonly uint firewireModel; - readonly string firewireModelName; readonly uint firewireVendor; - readonly string firewireVendorName; - readonly bool compactFlash; - readonly bool pcmcia; - readonly byte[] cis; // MMC and SecureDigital, values that need to be get with card idle, something that may // not be possible to do but usually is already done by the SDHCI driver. @@ -73,115 +51,79 @@ namespace DiscImageChef.Devices /// Gets the Platform ID for this device /// /// The Platform ID - public Interop.PlatformID PlatformId - { - get { return platformId; } - } + public Interop.PlatformID PlatformId { get; } /// /// Gets the file handle representing this device /// /// The file handle - public object FileHandle - { - get { return fd; } - } + public object FileHandle { get; } /// /// Gets or sets the standard timeout for commands sent to this device /// /// The timeout in seconds - public uint Timeout { get; set; } + public uint Timeout { get; } /// /// Gets a value indicating whether this is in error. /// /// true if error; otherwise, false. - public bool Error - { - get { return error; } - } + public bool Error { get; } /// /// Gets the last error number. /// /// The last error. - public int LastError - { - get { return lastError; } - } + public int LastError { get; } /// /// Gets the device type. /// /// The device type. - public DeviceType Type - { - get { return type; } - } + public DeviceType Type { get; } /// /// Gets the device's manufacturer /// /// The manufacturer. - public string Manufacturer - { - get { return manufacturer; } - } + public string Manufacturer { get; } /// /// Gets the device model /// /// The model. - public string Model - { - get { return model; } - } + public string Model { get; } /// /// Gets the device's revision. /// /// The revision. - public string Revision - { - get { return revision; } - } + public string Revision { get; } /// /// Gets the device's serial number. /// /// The serial number. - public string Serial - { - get { return serial; } - } + public string Serial { get; } /// /// Gets the device's SCSI peripheral device type /// /// The SCSI peripheral device type. - public Decoders.SCSI.PeripheralDeviceTypes ScsiType - { - get { return scsiType; } - } + public Decoders.SCSI.PeripheralDeviceTypes ScsiType { get; } /// /// Gets a value indicating whether this device's media is removable. /// /// true if this device's media is removable; otherwise, false. - public bool IsRemovable - { - get { return removable; } - } + public bool IsRemovable { get; } /// /// Gets a value indicating whether this device is attached via USB. /// /// true if this device is attached via USB; otherwise, false. - public bool IsUsb - { - get { return usb; } - } + public bool IsUsb { get; } /// /// Gets the USB vendor ID. @@ -189,7 +131,7 @@ namespace DiscImageChef.Devices /// The USB vendor ID. public ushort UsbVendorId { - get { return usbVendor; } + get => usbVendor; } /// @@ -198,53 +140,38 @@ namespace DiscImageChef.Devices /// The USB product ID. public ushort UsbProductId { - get { return usbProduct; } + get => usbProduct; } /// /// Gets the USB descriptors. /// /// The USB descriptors. - public byte[] UsbDescriptors - { - get { return usbDescriptors; } - } + public byte[] UsbDescriptors { get; } /// /// Gets the USB manufacturer string. /// /// The USB manufacturer string. - public string UsbManufacturerString - { - get { return usbManufacturerString; } - } + public string UsbManufacturerString { get; } /// /// Gets the USB product string. /// /// The USB product string. - public string UsbProductString - { - get { return usbProductString; } - } + public string UsbProductString { get; } /// /// Gets the USB serial string. /// /// The USB serial string. - public string UsbSerialString - { - get { return usbSerialString; } - } + public string UsbSerialString { get; } /// /// Gets a value indicating whether this device is attached via FireWire. /// /// true if this device is attached via FireWire; otherwise, false. - public bool IsFireWire - { - get { return firewire; } - } + public bool IsFireWire { get; } /// /// Gets the FireWire GUID @@ -252,7 +179,7 @@ namespace DiscImageChef.Devices /// The FireWire GUID. public ulong FireWireGuid { - get { return firewireGuid; } + get => firewireGuid; } /// @@ -261,17 +188,14 @@ namespace DiscImageChef.Devices /// The FireWire model. public uint FireWireModel { - get { return firewireModel; } + get => firewireModel; } /// /// Gets the FireWire model name. /// /// The FireWire model name. - public string FireWireModelName - { - get { return firewireModelName; } - } + public string FireWireModelName { get; } /// /// Gets the FireWire vendor number. @@ -279,42 +203,30 @@ namespace DiscImageChef.Devices /// The FireWire vendor number. public uint FireWireVendor { - get { return firewireVendor; } + get => firewireVendor; } /// /// Gets the FireWire vendor name. /// /// The FireWire vendor name. - public string FireWireVendorName - { - get { return firewireVendorName; } - } + public string FireWireVendorName { get; } /// /// Gets a value indicating whether this device is a CompactFlash device. /// /// true if this device is a CompactFlash device; otherwise, false. - public bool IsCompactFlash - { - get { return compactFlash; } - } + public bool IsCompactFlash { get; } /// /// Gets a value indicating whether this device is a PCMCIA device. /// /// true if this device is a PCMCIA device; otherwise, false. - public bool IsPcmcia - { - get { return pcmcia; } - } + public bool IsPcmcia { get; } /// /// Contains the PCMCIA CIS if applicable /// - public byte[] Cis - { - get { return cis; } - } + public byte[] Cis { get; } } } \ No newline at end of file diff --git a/DiscImageChef.Filesystems/Structs.cs b/DiscImageChef.Filesystems/Structs.cs index 76ff2c1c..1527134a 100644 --- a/DiscImageChef.Filesystems/Structs.cs +++ b/DiscImageChef.Filesystems/Structs.cs @@ -147,75 +147,49 @@ namespace DiscImageChef.Filesystems /// public class FileEntryInfo { - DateTime crtimeUtc; - DateTime atimeUtc; - DateTime ctimeUtc; - DateTime btimeUtc; - DateTime mtimeUtc; - /// File attributes public FileAttributes Attributes; /// File creation date in UTC - public DateTime CreationTimeUtc - { - get { return crtimeUtc; } - set { crtimeUtc = value; } - } + public DateTime CreationTimeUtc { get; set; } /// File last access date in UTC - public DateTime AccessTimeUtc - { - get { return atimeUtc; } - set { atimeUtc = value; } - } + public DateTime AccessTimeUtc { get; set; } /// File attributes change date in UTC - public DateTime StatusChangeTimeUtc - { - get { return ctimeUtc; } - set { ctimeUtc = value; } - } + public DateTime StatusChangeTimeUtc { get; set; } /// File last backup date in UTC - public DateTime BackupTimeUtc - { - get { return btimeUtc; } - set { btimeUtc = value; } - } + public DateTime BackupTimeUtc { get; set; } /// File last modification date in UTC - public DateTime LastWriteTimeUtc - { - get { return mtimeUtc; } - set { mtimeUtc = value; } - } + public DateTime LastWriteTimeUtc { get; set; } /// File creation date public DateTime CreationTime { - get { return crtimeUtc.ToLocalTime(); } - set { crtimeUtc = value.ToUniversalTime(); } + get { return CreationTimeUtc.ToLocalTime(); } + set { CreationTimeUtc = value.ToUniversalTime(); } } /// File last access date public DateTime AccessTime { - get { return atimeUtc.ToLocalTime(); } - set { atimeUtc = value.ToUniversalTime(); } + get { return AccessTimeUtc.ToLocalTime(); } + set { AccessTimeUtc = value.ToUniversalTime(); } } /// File attributes change date public DateTime StatusChangeTime { - get { return ctimeUtc.ToLocalTime(); } - set { ctimeUtc = value.ToUniversalTime(); } + get { return StatusChangeTimeUtc.ToLocalTime(); } + set { StatusChangeTimeUtc = value.ToUniversalTime(); } } /// File last backup date public DateTime BackupTime { - get { return btimeUtc.ToLocalTime(); } - set { btimeUtc = value.ToUniversalTime(); } + get { return BackupTimeUtc.ToLocalTime(); } + set { BackupTimeUtc = value.ToUniversalTime(); } } /// File last modification date public DateTime LastWriteTime { - get { return mtimeUtc.ToLocalTime(); } - set { mtimeUtc = value.ToUniversalTime(); } + get { return LastWriteTimeUtc.ToLocalTime(); } + set { LastWriteTimeUtc = value.ToUniversalTime(); } } /// inode number for this file diff --git a/DiscImageChef.Helpers/EndianAwareBinaryReader.cs b/DiscImageChef.Helpers/EndianAwareBinaryReader.cs index 496f667a..b4731690 100644 --- a/DiscImageChef.Helpers/EndianAwareBinaryReader.cs +++ b/DiscImageChef.Helpers/EndianAwareBinaryReader.cs @@ -49,7 +49,7 @@ namespace DiscImageChef public EndianAwareBinaryReader(Stream input, bool isLittleEndian) : this(input, Encoding.UTF8, isLittleEndian) { } - public bool IsLittleEndian { get; set; } + public bool IsLittleEndian { get; set; } public override double ReadDouble() { diff --git a/DiscImageChef.Settings/Settings.cs b/DiscImageChef.Settings/Settings.cs index 4ebb279b..8daa664b 100644 --- a/DiscImageChef.Settings/Settings.cs +++ b/DiscImageChef.Settings/Settings.cs @@ -70,18 +70,10 @@ namespace DiscImageChef.Settings public static class Settings { public static DicSettings Current; - static string reportsPath; - static string statsPath; - public static string ReportsPath - { - get { return reportsPath; } - } + static string ReportsPath { get; set; } - public static string StatsPath - { - get { return statsPath; } - } + public static string StatsPath { get; private set; } public static void LoadSettings() { @@ -103,11 +95,11 @@ namespace DiscImageChef.Settings string dicPath = Path.Combine(appSupportPath, "DiscImageChef"); if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath); - reportsPath = Path.Combine(dicPath, "Reports"); - if(!Directory.Exists(reportsPath)) Directory.CreateDirectory(reportsPath); + ReportsPath = Path.Combine(dicPath, "Reports"); + if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath); - statsPath = Path.Combine(dicPath, "Statistics"); - if(!Directory.Exists(statsPath)) Directory.CreateDirectory(statsPath); + StatsPath = Path.Combine(dicPath, "Statistics"); + if(!Directory.Exists(StatsPath)) Directory.CreateDirectory(StatsPath); } break; case Interop.PlatformID.Win32NT: @@ -124,11 +116,11 @@ namespace DiscImageChef.Settings string dicPath = Path.Combine(appSupportPath, "DiscImageChef"); if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath); - reportsPath = Path.Combine(dicPath, "Reports"); - if(!Directory.Exists(reportsPath)) Directory.CreateDirectory(reportsPath); + ReportsPath = Path.Combine(dicPath, "Reports"); + if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath); - statsPath = Path.Combine(dicPath, "Statistics"); - if(!Directory.Exists(statsPath)) Directory.CreateDirectory(statsPath); + StatsPath = Path.Combine(dicPath, "Statistics"); + if(!Directory.Exists(StatsPath)) Directory.CreateDirectory(StatsPath); } break; default: @@ -141,16 +133,16 @@ namespace DiscImageChef.Settings string dicPath = Path.Combine(appSupportPath, "DiscImageChef"); if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath); - reportsPath = Path.Combine(dicPath, "Reports"); - if(!Directory.Exists(reportsPath)) Directory.CreateDirectory(reportsPath); + ReportsPath = Path.Combine(dicPath, "Reports"); + if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath); - statsPath = Path.Combine(dicPath, "Statistics"); - if(!Directory.Exists(statsPath)) Directory.CreateDirectory(statsPath); + StatsPath = Path.Combine(dicPath, "Statistics"); + if(!Directory.Exists(StatsPath)) Directory.CreateDirectory(StatsPath); } break; } } - catch { reportsPath = null; } + catch { ReportsPath = null; } FileStream prefsFs = null; StreamReader prefsSr = null;