diff --git a/DiscImageChef.Checksums/CDChecksums.cs b/DiscImageChef.Checksums/CDChecksums.cs index 2ee8206a..29bf911c 100644 --- a/DiscImageChef.Checksums/CDChecksums.cs +++ b/DiscImageChef.Checksums/CDChecksums.cs @@ -32,6 +32,7 @@ // ****************************************************************************/ using System; +using System.Collections.Generic; using System.Linq; using DiscImageChef.Console; @@ -292,8 +293,6 @@ namespace DiscImageChef.Checksums channel[0x00C], channel[0x00D], channel[0x00E], calculatedEdc, storedEdc); return false; } - - return true; } DicConsole.DebugWriteLine("CD checksums", "Unknown mode {0} sector at address: {1:X2}:{2:X2}:{3:X2}", @@ -301,7 +300,7 @@ namespace DiscImageChef.Checksums return null; } - static uint ComputeEdc(uint edc, byte[] src, int size) + static uint ComputeEdc(uint edc, IReadOnlyList src, int size) { int pos = 0; for(; size > 0; size--) edc = (edc >> 8) ^ edcTable[(edc ^ src[pos++]) & 0xFF]; @@ -309,7 +308,7 @@ namespace DiscImageChef.Checksums return edc; } - static bool? CheckCdSectorSubChannel(byte[] subchannel) + static bool? CheckCdSectorSubChannel(IReadOnlyList subchannel) { bool? status = true; byte[] qSubChannel = new byte[12]; diff --git a/DiscImageChef.Checksums/ReedSolomon.cs b/DiscImageChef.Checksums/ReedSolomon.cs index d80ac8f1..ca53d866 100644 --- a/DiscImageChef.Checksums/ReedSolomon.cs +++ b/DiscImageChef.Checksums/ReedSolomon.cs @@ -231,9 +231,9 @@ namespace DiscImageChef.Checksums */ void generate_gf() { - int i, mask; + int i; - mask = 1; + int mask = 1; alpha_to[mm] = 0; for(i = 0; i < mm; i++) { @@ -372,8 +372,7 @@ namespace DiscImageChef.Checksums if(!initialized) throw new UnauthorizedAccessException("Trying to calculate RS without initializing!"); erasPos = new int[nn - kk]; - int degLambda, el, degOmega; - int i, j, r; + int i, j; int q, tmp; int[] recd = new int[nn]; int[] lambda = new int[nn - kk + 1]; /* Err+Eras Locator poly */ @@ -384,7 +383,7 @@ namespace DiscImageChef.Checksums int[] root = new int[nn - kk]; int[] reg = new int[nn - kk + 1]; int[] loc = new int[nn - kk]; - int synError, count; + int count; /* data[] is in polynomial form, copy and convert to index form */ for(i = nn - 1; i >= 0; i--) @@ -396,7 +395,7 @@ namespace DiscImageChef.Checksums /* first form the syndromes; i.e., evaluate recd(x) at roots of g(x) * namely @**(B0+i), i = 0, ... ,(NN-KK-1) */ - synError = 0; + int synError = 0; for(i = 1; i <= nn - kk; i++) { tmp = 0; @@ -471,8 +470,8 @@ namespace DiscImageChef.Checksums * Begin Berlekamp-Massey algorithm to determine error+erasure * locator polynomial */ - r = noEras; - el = noEras; + int r = noEras; + int el = noEras; while(++r <= nn - kk) { /* r is the step number */ @@ -518,7 +517,7 @@ namespace DiscImageChef.Checksums } /* Convert lambda to index form and compute deg(lambda(x)) */ - degLambda = 0; + int degLambda = 0; for(i = 0; i < nn - kk + 1; i++) { lambda[i] = index_of[lambda[i]]; @@ -561,7 +560,7 @@ namespace DiscImageChef.Checksums * Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo * x**(NN-KK)). in index form. Also find deg(omega). */ - degOmega = 0; + int degOmega = 0; for(i = 0; i < nn - kk; i++) { tmp = 0; diff --git a/DiscImageChef.Checksums/SpamSumContext.cs b/DiscImageChef.Checksums/SpamSumContext.cs index b36a1376..2ea280ba 100644 --- a/DiscImageChef.Checksums/SpamSumContext.cs +++ b/DiscImageChef.Checksums/SpamSumContext.cs @@ -177,15 +177,13 @@ namespace DiscImageChef.Checksums void fuzzy_try_fork_blockhash() { - uint obh, nbh; - if(self.Bhend >= NUM_BLOCKHASHES) return; if(self.Bhend == 0) // assert throw new Exception("Assertion failed"); - obh = self.Bhend - 1; - nbh = self.Bhend; + uint obh = self.Bhend - 1; + uint nbh = self.Bhend; self.Bh[nbh].H = self.Bh[obh].H; self.Bh[nbh].Halfh = self.Bh[obh].Halfh; self.Bh[nbh].Digest[0] = 0; @@ -213,13 +211,12 @@ namespace DiscImageChef.Checksums void fuzzy_engine_step(byte c) { - ulong h; uint i; /* At each character we update the rolling hash and the normal hashes. * When the rolling hash hits a reset value then we emit a normal hash * as a element of the signature and reset the normal hash. */ roll_hash(c); - h = roll_sum(); + ulong h = roll_sum(); for(i = self.Bhstart; i < self.Bhend; ++i) { @@ -266,14 +263,13 @@ namespace DiscImageChef.Checksums StringBuilder sb = new StringBuilder(); uint bi = self.Bhstart; uint h = roll_sum(); - int i, resultOff; int remain = (int)(FUZZY_MAX_RESULT - 1); /* Exclude terminating '\0'. */ result = new byte[FUZZY_MAX_RESULT]; /* Verify that our elimination was not overeager. */ if(!(bi == 0 || (ulong)SSDEEP_BS(bi) / 2 * SPAMSUM_LENGTH < self.TotalSize)) throw new Exception("Assertion failed"); - resultOff = 0; + int resultOff = 0; /* Initial blocksize guess. */ while((ulong)SSDEEP_BS(bi) * SPAMSUM_LENGTH < self.TotalSize) @@ -289,7 +285,7 @@ namespace DiscImageChef.Checksums if(bi > 0 && self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2) throw new Exception("Assertion failed"); sb.AppendFormat("{0}:", SSDEEP_BS(bi)); - i = Encoding.ASCII.GetBytes(sb.ToString()).Length; + int i = Encoding.ASCII.GetBytes(sb.ToString()).Length; if(i <= 0) /* Maybe snprintf has set errno here? */ throw new OverflowException("The input exceeds data types."); if(i >= remain) throw new Exception("Assertion failed"); diff --git a/DiscImageChef.CommonTypes/Partition.cs b/DiscImageChef.CommonTypes/Partition.cs index 10689f68..e876ba1e 100644 --- a/DiscImageChef.CommonTypes/Partition.cs +++ b/DiscImageChef.CommonTypes/Partition.cs @@ -72,9 +72,7 @@ namespace DiscImageChef.CommonTypes public override bool Equals(object obj) { - if(!(obj is Partition)) return false; - - return Equals((Partition)obj); + return obj is Partition partition && Equals(partition); } public override int GetHashCode() diff --git a/DiscImageChef.Core/Benchmark.cs b/DiscImageChef.Core/Benchmark.cs index 29a9ffad..78103a4b 100644 --- a/DiscImageChef.Core/Benchmark.cs +++ b/DiscImageChef.Core/Benchmark.cs @@ -97,7 +97,6 @@ namespace DiscImageChef.Core Random rnd = new Random(); DateTime start; DateTime end; - long mem; start = DateTime.Now; InitProgress(); @@ -116,7 +115,7 @@ namespace DiscImageChef.Core results.FillSpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds; ms.Seek(0, SeekOrigin.Begin); - mem = GC.GetTotalMemory(false); + long mem = GC.GetTotalMemory(false); if(mem > results.MaxMemory) results.MaxMemory = mem; if(mem < results.MinMemory) results.MinMemory = mem; start = DateTime.Now; diff --git a/DiscImageChef.Core/Checksum.cs b/DiscImageChef.Core/Checksum.cs index f5677529..e6f5f8ea 100644 --- a/DiscImageChef.Core/Checksum.cs +++ b/DiscImageChef.Core/Checksum.cs @@ -398,8 +398,8 @@ namespace DiscImageChef.Core IChecksum sha384CtxData = null; IChecksum sha512CtxData = null; IChecksum ssctxData = null; - IChecksum f16ctxData = null; - IChecksum f32ctxData = null; + IChecksum f16CtxData = null; + IChecksum f32CtxData = null; Thread adlerThreadData = new Thread(UpdateHash); Thread crc16ThreadData = new Thread(UpdateHash); @@ -494,15 +494,15 @@ namespace DiscImageChef.Core if(enabled.HasFlag(EnableChecksum.Fletcher16)) { - f16ctxData = new Fletcher16Context(); - HashPacket f16PktData = new HashPacket {Context = f16ctxData, Data = data}; + f16CtxData = new Fletcher16Context(); + HashPacket f16PktData = new HashPacket {Context = f16CtxData, Data = data}; f16ThreadData.Start(f16PktData); } if(enabled.HasFlag(EnableChecksum.Fletcher32)) { - f32ctxData = new Fletcher32Context(); - HashPacket f32PktData = new HashPacket {Context = f32ctxData, Data = data}; + f32CtxData = new Fletcher32Context(); + HashPacket f32PktData = new HashPacket {Context = f32CtxData, Data = data}; f32ThreadData.Start(f32PktData); } @@ -582,13 +582,13 @@ namespace DiscImageChef.Core if(enabled.HasFlag(EnableChecksum.Fletcher16)) { - chk = new ChecksumType {type = ChecksumTypeType.fletcher16, Value = f16ctxData.End()}; + chk = new ChecksumType {type = ChecksumTypeType.fletcher16, Value = f16CtxData.End()}; dataChecksums.Add(chk); } if(enabled.HasFlag(EnableChecksum.Fletcher32)) { - chk = new ChecksumType {type = ChecksumTypeType.fletcher32, Value = f32ctxData.End()}; + chk = new ChecksumType {type = ChecksumTypeType.fletcher32, Value = f32CtxData.End()}; dataChecksums.Add(chk); } diff --git a/DiscImageChef.Core/Devices/Dumping/ATA.cs b/DiscImageChef.Core/Devices/Dumping/ATA.cs index d13cae15..a786fb8f 100644 --- a/DiscImageChef.Core/Devices/Dumping/ATA.cs +++ b/DiscImageChef.Core/Devices/Dumping/ATA.cs @@ -54,7 +54,7 @@ namespace DiscImageChef.Core.Devices.Dumping /// /// Implements dumping ATA devices /// - public class Ata + public static class Ata { /// /// Dumps an ATA device diff --git a/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs b/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs index aea3943e..4050266d 100644 --- a/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs +++ b/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs @@ -97,7 +97,7 @@ namespace DiscImageChef.Core.Devices.Dumping DateTime start; DateTime end; bool readcd; - bool read6 = false, read10 = false, read12 = false, read16 = false; + bool read6 = false, read10 = false, read12 = false, read16 = false; bool sense = false; const uint SECTOR_SIZE = 2352; FullTOC.CDFullTOC? toc = null; @@ -289,8 +289,8 @@ namespace DiscImageChef.Core.Devices.Dumping dev.Timeout, out _); dumpLog.WriteLine("Checking if drive supports READ(12)..."); DicConsole.WriteLine("Checking if drive supports READ(12)..."); - read12 = !dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, 2048, 0, - 1, false, dev.Timeout, out _); + read12 = !dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, 2048, 0, 1, + false, dev.Timeout, out _); dumpLog.WriteLine("Checking if drive supports READ(16)..."); DicConsole.WriteLine("Checking if drive supports READ(16)..."); read16 = !dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, 0, 2048, 0, 1, false, @@ -308,16 +308,19 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Drive supports READ(6)..."); DicConsole.WriteLine("Drive supports READ(6)..."); } + if(read10) { dumpLog.WriteLine("Drive supports READ(10)..."); DicConsole.WriteLine("Drive supports READ(10)..."); } + if(read12) { dumpLog.WriteLine("Drive supports READ(12)..."); DicConsole.WriteLine("Drive supports READ(12)..."); } + if(read16) { dumpLog.WriteLine("Drive supports READ(16)..."); @@ -535,15 +538,15 @@ namespace DiscImageChef.Core.Devices.Dumping Array.Copy(cmdBuf, 0, temp, 0, 8); Array.Reverse(temp); lastSector = (long)BitConverter.ToUInt64(temp, 0); - blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); + blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); } else { sense = dev.ReadCapacity(out cmdBuf, out senseBuf, dev.Timeout, out _); if(!sense) { - lastSector = (long)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]); - blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); + lastSector = (cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]; + blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); } } @@ -736,25 +739,26 @@ namespace DiscImageChef.Core.Devices.Dumping } else if(read16) { - sense = dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, 0, blockSize, 0, blocksToRead, false, - dev.Timeout, out _); + sense = dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, 0, blockSize, 0, + blocksToRead, false, dev.Timeout, out _); if(dev.Error || sense) blocksToRead /= 2; } else if(read12) { - sense = dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, blocksToRead, false, - dev.Timeout, out _); + sense = dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, + blocksToRead, false, dev.Timeout, out _); if(dev.Error || sense) blocksToRead /= 2; } else if(read10) { - sense = dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, (ushort)blocksToRead, - dev.Timeout, out _); + sense = dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, + (ushort)blocksToRead, dev.Timeout, out _); if(dev.Error || sense) blocksToRead /= 2; } else if(read6) { - sense = dev.Read6(out readBuffer, out senseBuf, 0, blockSize, (byte)blocksToRead, dev.Timeout, out _); + sense = dev.Read6(out readBuffer, out senseBuf, 0, blockSize, (byte)blocksToRead, dev.Timeout, + out _); if(dev.Error || sense) blocksToRead /= 2; } @@ -810,7 +814,7 @@ namespace DiscImageChef.Core.Devices.Dumping // If a subchannel is supported, check if output plugin allows us to write it. if(supportedSubchannel != MmcSubchannel.None) { - sense = dev.ReadCd(out readBuffer, out senseBuf, 0, blockSize, 1, MmcSectorTypes.AllTypes, false, false, + dev.ReadCd(out readBuffer, out senseBuf, 0, blockSize, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, supportedSubchannel, dev.Timeout, out _); @@ -871,12 +875,11 @@ namespace DiscImageChef.Core.Devices.Dumping sense = dev.ReadIsrc((byte)trk.TrackSequence, out string isrc, out _, out _, dev.Timeout, out _); if(sense || isrc == null || isrc == "000000000000") continue; - if(outputPlugin.WriteSectorTag(Encoding.ASCII.GetBytes(isrc), trk.TrackStartSector, - SectorTagType.CdTrackIsrc)) - { - DicConsole.WriteLine("Setting ISRC for track {0} to {1}", trk.TrackSequence, isrc); - dumpLog.WriteLine("Setting ISRC for track {0} to {1}", trk.TrackSequence, isrc); - } + if(!outputPlugin.WriteSectorTag(Encoding.ASCII.GetBytes(isrc), trk.TrackStartSector, + SectorTagType.CdTrackIsrc)) continue; + + DicConsole.WriteLine("Setting ISRC for track {0} to {1}", trk.TrackSequence, isrc); + dumpLog.WriteLine("Setting ISRC for track {0} to {1}", trk.TrackSequence, isrc); } if(resume.NextBlock > 0) dumpLog.WriteLine("Resuming from block {0}.", resume.NextBlock); @@ -922,24 +925,17 @@ namespace DiscImageChef.Core.Devices.Dumping totalDuration += cmdDuration; } else if(read16) - { - sense = dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, i, blockSize, 0, blocksToRead, false, - dev.Timeout, out cmdDuration); - } + sense = dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, i, blockSize, 0, + blocksToRead, false, dev.Timeout, out cmdDuration); else if(read12) - { - sense = dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0, blocksToRead, false, - dev.Timeout, out cmdDuration); - } + sense = dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)i, + blockSize, 0, blocksToRead, false, dev.Timeout, out cmdDuration); else if(read10) - { - sense = dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0, (ushort)blocksToRead, - dev.Timeout, out cmdDuration); - } + sense = dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)i, + blockSize, 0, (ushort)blocksToRead, dev.Timeout, out cmdDuration); else if(read6) - { - sense = dev.Read6(out readBuffer, out senseBuf, (uint)i, blockSize, (byte)blocksToRead, dev.Timeout, out cmdDuration); - } + sense = dev.Read6(out readBuffer, out senseBuf, (uint)i, blockSize, (byte)blocksToRead, + dev.Timeout, out cmdDuration); if(!sense && !dev.Error) { @@ -1034,34 +1030,29 @@ namespace DiscImageChef.Core.Devices.Dumping DicConsole.Write("\rTrimming sector {0}", badSector); + double cmdDuration = 0; + if(readcd) { - sense = true; sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)badSector, blockSize, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, supportedSubchannel, dev.Timeout, - out double cmdDuration); - totalDuration += cmdDuration; + out cmdDuration); } else if(read16) - { - sense = dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, badSector, blockSize, 0, blocksToRead, false, - dev.Timeout, out double cmdDuration); - } + sense = dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, badSector, blockSize, 0, + blocksToRead, false, dev.Timeout, out cmdDuration); else if(read12) - { - sense = dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)badSector, blockSize, 0, blocksToRead, false, - dev.Timeout, out double cmdDuration); - } + sense = dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)badSector, + blockSize, 0, blocksToRead, false, dev.Timeout, out cmdDuration); else if(read10) - { - sense = dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)badSector, blockSize, 0, (ushort)blocksToRead, - dev.Timeout, out double cmdDuration); - } + sense = dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)badSector, + blockSize, 0, (ushort)blocksToRead, dev.Timeout, out cmdDuration); else if(read6) - { - sense = dev.Read6(out readBuffer, out senseBuf, (uint)badSector, blockSize, (byte)blocksToRead, dev.Timeout, out double cmdDuration); - } + sense = dev.Read6(out readBuffer, out senseBuf, (uint)badSector, blockSize, (byte)blocksToRead, + dev.Timeout, out cmdDuration); + + totalDuration += cmdDuration; if(sense || dev.Error) continue; @@ -1103,24 +1094,23 @@ namespace DiscImageChef.Core.Devices.Dumping if(persistent) { Modes.ModePage_01_MMC pgMmc; - + sense = dev.ModeSense6(out readBuffer, out _, false, ScsiModeSensePageControl.Current, 0x01, dev.Timeout, out _); if(sense) { - sense = dev.ModeSense10(out readBuffer, out _, false, ScsiModeSensePageControl.Current, - 0x01, dev.Timeout, out _); + sense = dev.ModeSense10(out readBuffer, out _, false, ScsiModeSensePageControl.Current, 0x01, + dev.Timeout, out _); if(!sense) { Modes.DecodedMode? dcMode10 = Modes.DecodeMode10(readBuffer, PeripheralDeviceTypes.MultiMediaDevice); - + if(dcMode10.HasValue) - { foreach(Modes.ModePage modePage in dcMode10.Value.Pages) - if(modePage.Page == 0x01 && modePage.Subpage == 0x00) currentModePage = modePage; - } + if(modePage.Page == 0x01 && modePage.Subpage == 0x00) + currentModePage = modePage; } } else @@ -1129,18 +1119,14 @@ namespace DiscImageChef.Core.Devices.Dumping Modes.DecodeMode6(readBuffer, PeripheralDeviceTypes.MultiMediaDevice); if(dcMode6.HasValue) - { foreach(Modes.ModePage modePage in dcMode6.Value.Pages) if(modePage.Page == 0x01 && modePage.Subpage == 0x00) currentModePage = modePage; - } } if(currentModePage == null) { - - pgMmc = - new Modes.ModePage_01_MMC {PS = false, ReadRetryCount = 32, Parameter = 0x00}; + pgMmc = new Modes.ModePage_01_MMC {PS = false, ReadRetryCount = 32, Parameter = 0x00}; currentModePage = new Modes.ModePage { Page = 0x01, @@ -1148,9 +1134,8 @@ namespace DiscImageChef.Core.Devices.Dumping PageResponse = Modes.EncodeModePage_01_MMC(pgMmc) }; } - - pgMmc = - new Modes.ModePage_01_MMC {PS = false, ReadRetryCount = 255, Parameter = 0x20}; + + pgMmc = new Modes.ModePage_01_MMC {PS = false, ReadRetryCount = 255, Parameter = 0x20}; Modes.DecodedMode md = new Modes.DecodedMode { Header = new Modes.ModeHeader(), @@ -1199,7 +1184,6 @@ namespace DiscImageChef.Core.Devices.Dumping if(readcd) { - sense = true; sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)badSector, blockSize, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, supportedSubchannel, dev.Timeout, @@ -1278,7 +1262,6 @@ namespace DiscImageChef.Core.Devices.Dumping runningPersistent = true; DicConsole.WriteLine(); - tmpArray = resume.BadBlocks.ToArray(); foreach(ulong badSector in sectorsNotEvenPartial) { if(aborted) @@ -1299,21 +1282,20 @@ namespace DiscImageChef.Core.Devices.Dumping totalDuration += cmdDuration; } - if(!sense && !dev.Error) - { - dumpLog.WriteLine("Got partial data for sector {0} in pass {1}.", badSector, pass); + if(sense || dev.Error) continue; - if(supportedSubchannel != MmcSubchannel.None) - { - byte[] data = new byte[SECTOR_SIZE]; - byte[] sub = new byte[subSize]; - Array.Copy(readBuffer, 0, data, 0, SECTOR_SIZE); - Array.Copy(readBuffer, SECTOR_SIZE, sub, 0, subSize); - outputPlugin.WriteSectorLong(data, badSector); - outputPlugin.WriteSectorTag(sub, badSector, SectorTagType.CdSectorSubchannel); - } - else outputPlugin.WriteSectorLong(readBuffer, badSector); + dumpLog.WriteLine("Got partial data for sector {0} in pass {1}.", badSector, pass); + + if(supportedSubchannel != MmcSubchannel.None) + { + byte[] data = new byte[SECTOR_SIZE]; + byte[] sub = new byte[subSize]; + Array.Copy(readBuffer, 0, data, 0, SECTOR_SIZE); + Array.Copy(readBuffer, SECTOR_SIZE, sub, 0, subSize); + outputPlugin.WriteSectorLong(data, badSector); + outputPlugin.WriteSectorTag(sub, badSector, SectorTagType.CdSectorSubchannel); } + else outputPlugin.WriteSectorLong(readBuffer, badSector); } } } diff --git a/DiscImageChef.Core/Devices/Dumping/MMC.cs b/DiscImageChef.Core/Devices/Dumping/MMC.cs index 702e8582..25b03bc4 100644 --- a/DiscImageChef.Core/Devices/Dumping/MMC.cs +++ b/DiscImageChef.Core/Devices/Dumping/MMC.cs @@ -87,13 +87,11 @@ namespace DiscImageChef.Core.Devices.Dumping bool nometadata, bool notrim) { bool sense; - ulong blocks; byte[] tmpBuf; bool compactDisc = true; bool isXbox = false; // TODO: Log not only what is it reading, but if it was read correctly or not. - sense = dev.GetConfiguration(out byte[] cmdBuf, out _, 0, MmcGetConfigurationRt.Current, dev.Timeout, out _); if(!sense) @@ -205,7 +203,7 @@ namespace DiscImageChef.Core.Devices.Dumping } Reader scsiReader = new Reader(dev, dev.Timeout, null, dumpRaw); - blocks = scsiReader.GetDeviceBlocks(); + ulong blocks = scsiReader.GetDeviceBlocks(); dumpLog.WriteLine("Device reports disc has {0} blocks", blocks); Dictionary mediaTags = new Dictionary(); diff --git a/DiscImageChef.Core/Devices/Dumping/SBC.cs b/DiscImageChef.Core/Devices/Dumping/SBC.cs index 7d5f0971..89e3b132 100644 --- a/DiscImageChef.Core/Devices/Dumping/SBC.cs +++ b/DiscImageChef.Core/Devices/Dumping/SBC.cs @@ -90,10 +90,6 @@ namespace DiscImageChef.Core.Devices.Dumping bool nometadata, bool notrim) { bool sense; - ulong blocks; - uint blockSize; - uint logicalBlockSize; - uint physicalBlockSize; byte scsiMediumType = 0; byte scsiDensityCode = 0; bool containsFloppyPage = false; @@ -105,15 +101,14 @@ namespace DiscImageChef.Core.Devices.Dumping double maxSpeed = double.MinValue; double minSpeed = double.MaxValue; byte[] readBuffer; - uint blocksToRead; bool aborted = false; System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true; Modes.DecodedMode? decMode = null; dumpLog.WriteLine("Initializing reader."); Reader scsiReader = new Reader(dev, dev.Timeout, null, dumpRaw); - blocks = scsiReader.GetDeviceBlocks(); - blockSize = scsiReader.LogicalBlockSize; + ulong blocks = scsiReader.GetDeviceBlocks(); + uint blockSize = scsiReader.LogicalBlockSize; if(scsiReader.FindReadCommand()) { dumpLog.WriteLine("ERROR: Cannot find correct read command: {0}.", scsiReader.ErrorMessage); @@ -136,9 +131,9 @@ namespace DiscImageChef.Core.Devices.Dumping return; } - blocksToRead = scsiReader.BlocksToRead; - logicalBlockSize = blockSize; - physicalBlockSize = scsiReader.PhysicalBlockSize; + uint blocksToRead = scsiReader.BlocksToRead; + uint logicalBlockSize = blockSize; + uint physicalBlockSize = scsiReader.PhysicalBlockSize; if(blocks == 0) { @@ -238,7 +233,6 @@ namespace DiscImageChef.Core.Devices.Dumping } DicConsole.ErrorWriteLine("Continuing dumping cooked data."); - dumpRaw = false; } else { diff --git a/DiscImageChef.Core/Devices/Dumping/SCSI.cs b/DiscImageChef.Core/Devices/Dumping/SCSI.cs index c52be83d..d364f24f 100644 --- a/DiscImageChef.Core/Devices/Dumping/SCSI.cs +++ b/DiscImageChef.Core/Devices/Dumping/SCSI.cs @@ -48,7 +48,7 @@ namespace DiscImageChef.Core.Devices.Dumping /// /// Implements dumping SCSI and ATAPI devices /// - public class Scsi + public static class Scsi { // TODO: Get cartridge serial number from Certance vendor EVPD /// diff --git a/DiscImageChef.Core/Devices/Dumping/XGD.cs b/DiscImageChef.Core/Devices/Dumping/XGD.cs index 27531f9a..972f717a 100644 --- a/DiscImageChef.Core/Devices/Dumping/XGD.cs +++ b/DiscImageChef.Core/Devices/Dumping/XGD.cs @@ -93,7 +93,6 @@ namespace DiscImageChef.Core.Devices.Dumping bool nometadata, bool notrim) { bool sense; - ulong blocks; const uint BLOCK_SIZE = 2048; uint blocksToRead = 64; DateTime start; @@ -130,8 +129,6 @@ namespace DiscImageChef.Core.Devices.Dumping Array.Copy(ssBuf, 4, tmpBuf, 0, ssBuf.Length - 4); mediaTags.Add(MediaTagType.Xbox_SecuritySector, tmpBuf); - ulong l0Video, l1Video, middleZone, gameSize, totalSize, layerBreak; - // Get video partition size DicConsole.DebugWriteLine("Dump-media command", "Getting video partition size"); dumpLog.WriteLine("Locking drive."); @@ -152,7 +149,7 @@ namespace DiscImageChef.Core.Devices.Dumping return; } - totalSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); + ulong totalSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); dumpLog.WriteLine("Reading Physical Format Information."); sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _); @@ -167,8 +164,8 @@ namespace DiscImageChef.Core.Devices.Dumping Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.Length - 4); mediaTags.Add(MediaTagType.DVD_PFI, tmpBuf); DicConsole.DebugWriteLine("Dump-media command", "Video partition total size: {0} sectors", totalSize); - l0Video = PFI.Decode(readBuffer).Value.Layer0EndPSN - PFI.Decode(readBuffer).Value.DataAreaStartPSN + 1; - l1Video = totalSize - l0Video + 1; + ulong l0Video = PFI.Decode(readBuffer).Value.Layer0EndPSN - PFI.Decode(readBuffer).Value.DataAreaStartPSN + 1; + ulong l1Video = totalSize - l0Video + 1; dumpLog.WriteLine("Reading Disc Manufacturing Information."); sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out _); @@ -203,8 +200,8 @@ namespace DiscImageChef.Core.Devices.Dumping return; } - gameSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]) + - 1; + ulong gameSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]) + + 1; DicConsole.DebugWriteLine("Dump-media command", "Game partition total size: {0} sectors", gameSize); // Get middle zone size @@ -239,11 +236,10 @@ namespace DiscImageChef.Core.Devices.Dumping } DicConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors", totalSize); - blocks = totalSize + 1; - middleZone = - totalSize - (PFI.Decode(readBuffer).Value.Layer0EndPSN - - PFI.Decode(readBuffer).Value.DataAreaStartPSN + - 1) - gameSize + 1; + ulong blocks = totalSize + 1; + ulong middleZone = totalSize - (PFI.Decode(readBuffer).Value.Layer0EndPSN - + PFI.Decode(readBuffer).Value.DataAreaStartPSN + + 1) - gameSize + 1; tmpBuf = new byte[readBuffer.Length - 4]; Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.Length - 4); @@ -264,7 +260,7 @@ namespace DiscImageChef.Core.Devices.Dumping mediaTags.Add(MediaTagType.Xbox_DMI, tmpBuf); totalSize = l0Video + l1Video + middleZone * 2 + gameSize; - layerBreak = l0Video + middleZone + gameSize / 2; + ulong layerBreak = l0Video + middleZone + gameSize / 2; DicConsole.WriteLine("Video layer 0 size: {0} sectors", l0Video); DicConsole.WriteLine("Video layer 1 size: {0} sectors", l1Video); diff --git a/DiscImageChef.Core/Devices/ReaderSCSI.cs b/DiscImageChef.Core/Devices/ReaderSCSI.cs index ce77d92f..260deb14 100644 --- a/DiscImageChef.Core/Devices/ReaderSCSI.cs +++ b/DiscImageChef.Core/Devices/ReaderSCSI.cs @@ -142,7 +142,7 @@ namespace DiscImageChef.Core.Devices if(CanReadRaw && LongBlockSize == LogicalBlockSize) if(LogicalBlockSize == 512) - foreach(ushort testSize in new[] + foreach(int i in new[] { // Long sector sizes for floppies 514, @@ -152,6 +152,7 @@ namespace DiscImageChef.Core.Devices 600, 610, 630 }) { + ushort testSize = (ushort)i; testSense = dev.ReadLong16(out _, out senseBuf, false, 0, testSize, timeout, out _); if(!testSense && !dev.Error) { @@ -171,7 +172,7 @@ namespace DiscImageChef.Core.Devices break; } else if(LogicalBlockSize == 1024) - foreach(ushort testSize in new[] + foreach(int i in new[] { // Long sector sizes for floppies 1026, @@ -179,6 +180,7 @@ namespace DiscImageChef.Core.Devices 1200 }) { + ushort testSize = (ushort)i; testSense = dev.ReadLong16(out _, out senseBuf, false, 0, testSize, timeout, out _); if(!testSense && !dev.Error) { diff --git a/DiscImageChef.Core/Devices/Report/SCSI/General.cs b/DiscImageChef.Core/Devices/Report/SCSI/General.cs index fac72baf..4d0394ba 100644 --- a/DiscImageChef.Core/Devices/Report/SCSI/General.cs +++ b/DiscImageChef.Core/Devices/Report/SCSI/General.cs @@ -534,7 +534,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI if(mediaTest.SupportsReadLong && mediaTest.LongBlockSize == mediaTest.BlockSize) if(mediaTest.BlockSize == 512) - foreach(ushort testSize in new[] + foreach(int i in new[] { // Long sector sizes for floppies 514, @@ -544,6 +544,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI 600, 610, 630 }) { + ushort testSize = (ushort)i; sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, TIMEOUT, out _); if(sense || dev.Error) continue; @@ -554,7 +555,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI break; } else if(mediaTest.BlockSize == 1024) - foreach(ushort testSize in new[] + foreach(int i in new[] { // Long sector sizes for floppies 1026, @@ -562,8 +563,9 @@ namespace DiscImageChef.Core.Devices.Report.SCSI 1200 }) { + ushort testSize = (ushort)i; sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, - testSize, TIMEOUT, out _); + (ushort)i, TIMEOUT, out _); if(sense || dev.Error) continue; mediaTest.SupportsReadLong = true; @@ -803,7 +805,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI if(report.SCSI.ReadCapabilities.SupportsReadLong && report.SCSI.ReadCapabilities.LongBlockSize == report.SCSI.ReadCapabilities.BlockSize) if(report.SCSI.ReadCapabilities.BlockSize == 512) - foreach(ushort testSize in new[] + foreach(int i in new[] { // Long sector sizes for floppies 514, @@ -813,7 +815,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI 600, 610, 630 }) { - sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, + ushort testSize = (ushort)i; + sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, (ushort)i, TIMEOUT, out _); if(sense || dev.Error) continue; @@ -823,7 +826,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI break; } else if(report.SCSI.ReadCapabilities.BlockSize == 1024) - foreach(ushort testSize in new[] + foreach(int i in new[] { // Long sector sizes for floppies 1026, @@ -831,7 +834,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI 1200 }) { - sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, + ushort testSize = (ushort)i; + sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, (ushort)i, TIMEOUT, out _); if(sense || dev.Error) continue; diff --git a/DiscImageChef.Core/Options.cs b/DiscImageChef.Core/Options.cs index e47a552a..499008f7 100644 --- a/DiscImageChef.Core/Options.cs +++ b/DiscImageChef.Core/Options.cs @@ -45,7 +45,7 @@ namespace DiscImageChef.Core bool quoted = false; bool inValue = false; string name = null; - string value = null; + string value; StringBuilder sb = new StringBuilder(); if(options == null) return parsed; diff --git a/DiscImageChef.Core/Statistics.cs b/DiscImageChef.Core/Statistics.cs index 3eee5171..efeae07b 100644 --- a/DiscImageChef.Core/Statistics.cs +++ b/DiscImageChef.Core/Statistics.cs @@ -740,19 +740,21 @@ namespace DiscImageChef.Core /// /// Adds a new media scan to statistics /// - /// Sectors <3ms - /// Sectors >3ms and <10ms - /// Sectors >10ms and <50ms - /// Sectors >50ms and <150ms - /// Sectors >150ms and <500ms - /// Sectors >500ms + /// Sectors <3ms + /// Sectors >3ms and <10ms + /// Sectors >10ms and <50ms + /// Sectors >50ms and <150ms + /// Sectors >150ms and <500ms + /// Sectors >500ms /// Total sectors /// Errored sectors /// Correct sectors - public static void AddMediaScan(long lessThan3ms, long lessThan10ms, long lessThan50ms, long lessThan150ms, - long lessThan500ms, long moreThan500ms, long total, long error, + public static void AddMediaScan(long lessThan3Ms, long lessThan10Ms, long lessThan50Ms, long lessThan150Ms, + long lessThan500Ms, long moreThan500Ms, long total, long error, long correct) { + if(lessThan500Ms <= 0) throw new ArgumentOutOfRangeException(nameof(lessThan500Ms)); + if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.MediaScanStats) return; if(CurrentStats.MediaScan == null) @@ -764,22 +766,22 @@ namespace DiscImageChef.Core CurrentStats.MediaScan.Sectors.Correct += correct; CurrentStats.MediaScan.Sectors.Error += error; CurrentStats.MediaScan.Sectors.Total += total; - CurrentStats.MediaScan.Times.LessThan3ms += lessThan3ms; - CurrentStats.MediaScan.Times.LessThan10ms += lessThan10ms; - CurrentStats.MediaScan.Times.LessThan50ms += lessThan50ms; - CurrentStats.MediaScan.Times.LessThan150ms += lessThan150ms; - CurrentStats.MediaScan.Times.LessThan500ms += lessThan500ms; - CurrentStats.MediaScan.Times.MoreThan500ms += moreThan500ms; + CurrentStats.MediaScan.Times.LessThan3ms += lessThan3Ms; + CurrentStats.MediaScan.Times.LessThan10ms += lessThan10Ms; + CurrentStats.MediaScan.Times.LessThan50ms += lessThan50Ms; + CurrentStats.MediaScan.Times.LessThan150ms += lessThan150Ms; + CurrentStats.MediaScan.Times.LessThan500ms += lessThan500Ms; + CurrentStats.MediaScan.Times.MoreThan500ms += moreThan500Ms; AllStats.MediaScan.Sectors.Correct += correct; AllStats.MediaScan.Sectors.Error += error; AllStats.MediaScan.Sectors.Total += total; - AllStats.MediaScan.Times.LessThan3ms += lessThan3ms; - AllStats.MediaScan.Times.LessThan10ms += lessThan10ms; - AllStats.MediaScan.Times.LessThan50ms += lessThan50ms; - AllStats.MediaScan.Times.LessThan150ms += lessThan150ms; - AllStats.MediaScan.Times.LessThan500ms += lessThan500ms; - AllStats.MediaScan.Times.MoreThan500ms += moreThan500ms; + AllStats.MediaScan.Times.LessThan3ms += lessThan3Ms; + AllStats.MediaScan.Times.LessThan10ms += lessThan10Ms; + AllStats.MediaScan.Times.LessThan50ms += lessThan50Ms; + AllStats.MediaScan.Times.LessThan150ms += lessThan150Ms; + AllStats.MediaScan.Times.LessThan500ms += lessThan500Ms; + AllStats.MediaScan.Times.MoreThan500ms += moreThan500Ms; } } } \ No newline at end of file diff --git a/DiscImageChef.Decoders/Floppy/AppleSony.cs b/DiscImageChef.Decoders/Floppy/AppleSony.cs index 2fc370c5..a463a306 100644 --- a/DiscImageChef.Decoders/Floppy/AppleSony.cs +++ b/DiscImageChef.Decoders/Floppy/AppleSony.cs @@ -153,8 +153,6 @@ namespace DiscImageChef.Decoders.Floppy if(sector.addressField.prologue[0] != 0xD5 || sector.addressField.prologue[1] != 0xAA || sector.addressField.prologue[2] != 0x96) return null; - uint ck1, ck2, ck3; - byte w3; byte[] bf1 = new byte[175]; byte[] bf2 = new byte[175]; byte[] bf3 = new byte[175]; @@ -162,7 +160,7 @@ namespace DiscImageChef.Decoders.Floppy MemoryStream ms = new MemoryStream(); int j = 0; - w3 = 0; + byte w3 = 0; for(int i = 0; i <= 174; i++) { byte w4 = nib_data[j++]; @@ -177,9 +175,9 @@ namespace DiscImageChef.Decoders.Floppy } j = 0; - ck1 = 0; - ck2 = 0; - ck3 = 0; + uint ck1 = 0; + uint ck2 = 0; + uint ck3 = 0; while(true) { ck1 = (ck1 & 0xFF) << 1; diff --git a/DiscImageChef.Decoders/MMC/CSD.cs b/DiscImageChef.Decoders/MMC/CSD.cs index d9a5a997..dffe3928 100644 --- a/DiscImageChef.Decoders/MMC/CSD.cs +++ b/DiscImageChef.Decoders/MMC/CSD.cs @@ -148,7 +148,6 @@ namespace DiscImageChef.Decoders.MMC double unitFactor = 0; double multiplier = 0; - double result; string unit = ""; StringBuilder sb = new StringBuilder(); @@ -257,7 +256,7 @@ namespace DiscImageChef.Decoders.MMC break; } - result = unitFactor * multiplier; + double result = unitFactor * multiplier; sb.AppendFormat("\tAsynchronous data access time is {0}{1}", result, unit).AppendLine(); sb.AppendFormat("\tClock dependent part of data access is {0} clock cycles", csd.NSAC * 100).AppendLine(); diff --git a/DiscImageChef.Decoders/MMC/ExtendedCSD.cs b/DiscImageChef.Decoders/MMC/ExtendedCSD.cs index 02f7a39a..260c81e7 100644 --- a/DiscImageChef.Decoders/MMC/ExtendedCSD.cs +++ b/DiscImageChef.Decoders/MMC/ExtendedCSD.cs @@ -213,9 +213,8 @@ namespace DiscImageChef.Decoders.MMC if(response.Length != 512) return null; - ExtendedCSD csd; GCHandle handle = GCHandle.Alloc(response, GCHandleType.Pinned); - csd = (ExtendedCSD)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ExtendedCSD)); + ExtendedCSD csd = (ExtendedCSD)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ExtendedCSD)); handle.Free(); return csd; @@ -231,8 +230,9 @@ namespace DiscImageChef.Decoders.MMC double unit; if((csd.HPIFeatures & 0x01) == 0x01) - if((csd.HPIFeatures & 0x02) == 0x02) sb.AppendLine("\tDevice implements HPI using CMD12"); - else sb.AppendLine("\tDevice implements HPI using CMD13"); + sb.AppendLine((csd.HPIFeatures & 0x02) == 0x02 + ? "\tDevice implements HPI using CMD12" + : "\tDevice implements HPI using CMD13"); if((csd.BackgroundOperationsSupport & 0x01) == 0x01) sb.AppendLine("\tDevice supports background operations"); @@ -574,9 +574,9 @@ namespace DiscImageChef.Decoders.MMC if((csd.StrobeSupport & 0x01) == 0x01) { sb.AppendLine("\tDevice supports enhanced strobe mode"); - if((csd.BusWidth & 0x80) == 0x80) - sb.AppendLine("\tDevice uses strobe during Data Out, CRC and CMD responses"); - else sb.AppendLine("\tDevice uses strobe during Data Out and CRC responses"); + sb.AppendLine((csd.BusWidth & 0x80) == 0x80 + ? "\tDevice uses strobe during Data Out, CRC and CMD responses" + : "\tDevice uses strobe during Data Out and CRC responses"); } switch(csd.BusWidth & 0x0F) diff --git a/DiscImageChef.Decoders/SCSI/Modes/03.cs b/DiscImageChef.Decoders/SCSI/Modes/03.cs index 3e1636a7..f6e0549a 100644 --- a/DiscImageChef.Decoders/SCSI/Modes/03.cs +++ b/DiscImageChef.Decoders/SCSI/Modes/03.cs @@ -172,10 +172,9 @@ namespace DiscImageChef.Decoders.SCSI if(page.SSEC) sb.AppendLine("\tDrive supports soft-sectoring format"); if(page.HSEC) sb.AppendLine("\tDrive supports hard-sectoring format"); if(page.RMB) sb.AppendLine("\tDrive media is removable"); - if(page.SURF) - sb.AppendLine("\tSector addressing is progressively incremented in one surface before going to the next"); - else - sb.AppendLine("\tSector addressing is progressively incremented in one cylinder before going to the next"); + sb.AppendLine(page.SURF + ? "\tSector addressing is progressively incremented in one surface before going to the next" + : "\tSector addressing is progressively incremented in one cylinder before going to the next"); return sb.ToString(); } diff --git a/DiscImageChef.Decoders/SCSI/Modes/Mode10.cs b/DiscImageChef.Decoders/SCSI/Modes/Mode10.cs index 8538dc83..59641ddb 100644 --- a/DiscImageChef.Decoders/SCSI/Modes/Mode10.cs +++ b/DiscImageChef.Decoders/SCSI/Modes/Mode10.cs @@ -46,11 +46,8 @@ namespace DiscImageChef.Decoders.SCSI { if(modeResponse == null || modeResponse.Length < 8) return null; - ushort modeLength; - ushort blockDescLength; - - modeLength = (ushort)((modeResponse[0] << 8) + modeResponse[1]); - blockDescLength = (ushort)((modeResponse[6] << 8) + modeResponse[7]); + ushort modeLength = (ushort)((modeResponse[0] << 8) + modeResponse[1]); + ushort blockDescLength = (ushort)((modeResponse[6] << 8) + modeResponse[7]); if(modeResponse.Length < modeLength) return null; diff --git a/DiscImageChef.Decoders/SecureDigital/CSD.cs b/DiscImageChef.Decoders/SecureDigital/CSD.cs index e4f9e004..2f76c0e3 100644 --- a/DiscImageChef.Decoders/SecureDigital/CSD.cs +++ b/DiscImageChef.Decoders/SecureDigital/CSD.cs @@ -145,7 +145,6 @@ namespace DiscImageChef.Decoders.SecureDigital double unitFactor = 0; double multiplier = 0; - double result; string unit = ""; StringBuilder sb = new StringBuilder(); @@ -248,7 +247,7 @@ namespace DiscImageChef.Decoders.SecureDigital break; } - result = unitFactor * multiplier; + double result = unitFactor * multiplier; sb.AppendFormat("\tAsynchronous data access time is {0}{1}", result, unit).AppendLine(); sb.AppendFormat("\tClock dependent part of data access is {0} clock cycles", csd.NSAC * 100).AppendLine(); diff --git a/DiscImageChef.DiscImages/BlindWrite5.cs b/DiscImageChef.DiscImages/BlindWrite5.cs index 3332ef4d..3e4e60f0 100644 --- a/DiscImageChef.DiscImages/BlindWrite5.cs +++ b/DiscImageChef.DiscImages/BlindWrite5.cs @@ -112,11 +112,11 @@ namespace DiscImageChef.DiscImages public string Format => "BlindWrite 5 TOC file"; - public List Partitions { get; set; } + public List Partitions { get; private set; } - public List Tracks { get; set; } + public List Tracks { get; private set; } - public List Sessions { get; set; } + public List Sessions { get; private set; } public bool Identify(IFilter imageFilter) { @@ -1175,12 +1175,12 @@ namespace DiscImageChef.DiscImages throw new ArgumentOutOfRangeException(nameof(length), $"Requested more sectors ({length + sectorAddress}) than present in track ({dicTrack.TrackEndSector}), won't cross tracks"); - foreach(DataFileCharacteristics _chars in filePaths.Where(_chars => - (long)sectorAddress >= _chars.StartLba && - length < (ulong)_chars.Sectors - + foreach(DataFileCharacteristics characteristics in filePaths.Where(characteristics => + (long)sectorAddress >= characteristics.StartLba && + length < (ulong)characteristics.Sectors - sectorAddress)) { - chars = _chars; + chars = characteristics; break; } @@ -1294,12 +1294,12 @@ namespace DiscImageChef.DiscImages throw new ArgumentOutOfRangeException(nameof(length), $"Requested more sectors ({length + sectorAddress}) than present in track ({dicTrack.TrackEndSector}), won't cross tracks"); - foreach(DataFileCharacteristics _chars in filePaths.Where(_chars => - (long)sectorAddress >= _chars.StartLba && - length < (ulong)_chars.Sectors - + foreach(DataFileCharacteristics characteristics in filePaths.Where(characteristics => + (long)sectorAddress >= characteristics.StartLba && + length < (ulong)characteristics.Sectors - sectorAddress)) { - chars = _chars; + chars = characteristics; break; } @@ -1602,12 +1602,12 @@ namespace DiscImageChef.DiscImages throw new ArgumentOutOfRangeException(nameof(length), $"Requested more sectors ({length + sectorAddress}) than present in track ({dicTrack.TrackEndSector}), won't cross tracks"); - foreach(DataFileCharacteristics _chars in filePaths.Where(_chars => - (long)sectorAddress >= _chars.StartLba && - length < (ulong)_chars.Sectors - + foreach(DataFileCharacteristics characteristics in filePaths.Where(characteristics => + (long)sectorAddress >= characteristics.StartLba && + length < (ulong)characteristics.Sectors - sectorAddress)) { - chars = _chars; + chars = characteristics; break; } diff --git a/DiscImageChef.DiscImages/CDRDAO.cs b/DiscImageChef.DiscImages/CDRDAO.cs index 80f24df5..5ce00130 100644 --- a/DiscImageChef.DiscImages/CDRDAO.cs +++ b/DiscImageChef.DiscImages/CDRDAO.cs @@ -148,7 +148,7 @@ namespace DiscImageChef.DiscImages public string Format => "CDRDAO tocfile"; - public List Partitions { get; set; } + public List Partitions { get; private set; } public List Tracks { diff --git a/DiscImageChef.DiscImages/CloneCD.cs b/DiscImageChef.DiscImages/CloneCD.cs index 8f9adc09..51e041cc 100644 --- a/DiscImageChef.DiscImages/CloneCD.cs +++ b/DiscImageChef.DiscImages/CloneCD.cs @@ -126,11 +126,11 @@ namespace DiscImageChef.DiscImages public string Format => "CloneCD"; - public List Partitions { get; set; } + public List Partitions { get; private set; } - public List Tracks { get; set; } + public List Tracks { get; private set; } - public List Sessions { get; set; } + public List Sessions { get; private set; } public bool Identify(IFilter imageFilter) { @@ -1605,8 +1605,7 @@ namespace DiscImageChef.DiscImages subStream?.Close(); FullTOC.CDFullTOC? nullableToc = null; - FullTOC.CDFullTOC toc = - new FullTOC.CDFullTOC {TrackDescriptors = new FullTOC.TrackDataDescriptor[0]}; + FullTOC.CDFullTOC toc; // Easy, just decode the real toc if(fulltoc != null) nullableToc = FullTOC.Decode(fulltoc); @@ -1641,7 +1640,6 @@ namespace DiscImageChef.DiscImages foreach(Track track in Tracks.OrderBy(t => t.TrackSession).ThenBy(t => t.TrackSequence)) { - FullTOC.TrackDataDescriptor trackDescriptor; trackFlags.TryGetValue((byte)track.TrackSequence, out byte trackControl); if(trackControl == 0 && track.TrackType != TrackType.Audio) trackControl = (byte)CdFlags.DataTrack; diff --git a/DiscImageChef.DiscImages/DiscJuggler.cs b/DiscImageChef.DiscImages/DiscJuggler.cs index 54b537d4..77f14f13 100644 --- a/DiscImageChef.DiscImages/DiscJuggler.cs +++ b/DiscImageChef.DiscImages/DiscJuggler.cs @@ -83,11 +83,11 @@ namespace DiscImageChef.DiscImages public string Format => "DiscJuggler"; - public List Partitions { get; set; } + public List Partitions { get; private set; } - public List Tracks { get; set; } + public List Tracks { get; private set; } - public List Sessions { get; set; } + public List Sessions { get; private set; } public bool Identify(IFilter imageFilter) { diff --git a/DiscImageChef.DiscImages/DiskCopy42.cs b/DiscImageChef.DiscImages/DiskCopy42.cs index feb537d1..69cfdca6 100644 --- a/DiscImageChef.DiscImages/DiskCopy42.cs +++ b/DiscImageChef.DiscImages/DiskCopy42.cs @@ -109,8 +109,6 @@ namespace DiscImageChef.DiscImages bool twiggy; byte[] twiggyCache; byte[] twiggyCacheTags; - MemoryStream twiggyDataCache; - MemoryStream twiggyTagCache; FileStream writingStream; @@ -818,10 +816,6 @@ namespace DiscImageChef.DiscImages header.FmtByte = kSigmaFmtByteTwiggy; header.Format = kSigmaFormatTwiggy; twiggy = true; - tags = true; - twiggyDataCache = new MemoryStream(); - twiggyTagCache = new MemoryStream(); - // TODO ErrorMessage = "Twiggy write support not yet implemented"; return false; diff --git a/DiscImageChef.DiscImages/GDI.cs b/DiscImageChef.DiscImages/GDI.cs index 643c5025..78f56623 100644 --- a/DiscImageChef.DiscImages/GDI.cs +++ b/DiscImageChef.DiscImages/GDI.cs @@ -88,7 +88,7 @@ namespace DiscImageChef.DiscImages public string Format => "Dreamcast GDI image"; - public List Partitions { get; set; } + public List Partitions { get; private set; } public List Tracks { diff --git a/DiscImageChef.DiscImages/Nero.cs b/DiscImageChef.DiscImages/Nero.cs index d3d4d06f..05443f96 100644 --- a/DiscImageChef.DiscImages/Nero.cs +++ b/DiscImageChef.DiscImages/Nero.cs @@ -226,12 +226,10 @@ namespace DiscImageChef.DiscImages while(parsing) { byte[] chunkHeaderBuffer = new byte[8]; - uint chunkId; - uint chunkLength; imageStream.Read(chunkHeaderBuffer, 0, 8); - chunkId = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 0); - chunkLength = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 4); + uint chunkId = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 0); + uint chunkLength = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 4); DicConsole.DebugWriteLine("Nero plugin", "ChunkID = 0x{0:X8} (\"{1}\")", chunkId, Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(chunkId))); @@ -705,10 +703,9 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("Nero plugin", "Found \"SINF\" chunk, parsing {0} bytes", chunkLength); - uint sessionTracks; byte[] tmpbuffer = new byte[4]; imageStream.Read(tmpbuffer, 0, 4); - sessionTracks = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); + uint sessionTracks = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); neroSessions.Add(currentsession, sessionTracks); DicConsole.DebugWriteLine("Nero plugin", "\tSession {0} has {1} tracks", currentsession, @@ -1534,7 +1531,7 @@ namespace DiscImageChef.DiscImages public List Partitions { get; } - public List Tracks { get; set; } + public List Tracks { get; private set; } public List GetSessionTracks(Session session) { diff --git a/DiscImageChef.DiscImages/UDIF.cs b/DiscImageChef.DiscImages/UDIF.cs index b66372a8..7438fdc0 100644 --- a/DiscImageChef.DiscImages/UDIF.cs +++ b/DiscImageChef.DiscImages/UDIF.cs @@ -478,13 +478,13 @@ namespace DiscImageChef.DiscImages if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; - BlockChunk currentChunk = new BlockChunk(); + BlockChunk readChunk = new BlockChunk(); bool chunkFound = false; ulong chunkStartSector = 0; foreach(KeyValuePair kvp in chunks.Where(kvp => sectorAddress >= kvp.Key)) { - currentChunk = kvp.Value; + readChunk = kvp.Value; chunkFound = true; chunkStartSector = kvp.Key; } @@ -499,17 +499,17 @@ namespace DiscImageChef.DiscImages throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if((currentChunk.type & CHUNK_TYPE_COMPRESSED_MASK) == CHUNK_TYPE_COMPRESSED_MASK) + if((readChunk.type & CHUNK_TYPE_COMPRESSED_MASK) == CHUNK_TYPE_COMPRESSED_MASK) { if(!chunkCache.TryGetValue(chunkStartSector, out byte[] buffer)) { - byte[] cmpBuffer = new byte[currentChunk.length]; - imageStream.Seek((long)currentChunk.offset, SeekOrigin.Begin); + byte[] cmpBuffer = new byte[readChunk.length]; + imageStream.Seek((long)readChunk.offset, SeekOrigin.Begin); imageStream.Read(cmpBuffer, 0, cmpBuffer.Length); MemoryStream cmpMs = new MemoryStream(cmpBuffer); Stream decStream = null; - switch(currentChunk.type) + switch(readChunk.type) { case CHUNK_TYPE_ADC: decStream = new ADCStream(cmpMs); @@ -523,7 +523,7 @@ namespace DiscImageChef.DiscImages case CHUNK_TYPE_RLE: break; default: throw new - ImageNotSupportedException($"Unsupported chunk type 0x{currentChunk.type:X8} found"); + ImageNotSupportedException($"Unsupported chunk type 0x{readChunk.type:X8} found"); } #if DEBUG @@ -532,7 +532,7 @@ namespace DiscImageChef.DiscImages #endif byte[] tmpBuffer; int realSize; - switch(currentChunk.type) + switch(readChunk.type) { case CHUNK_TYPE_ADC: case CHUNK_TYPE_ZLIB: @@ -572,7 +572,7 @@ namespace DiscImageChef.DiscImages } catch(ZlibException) { - DicConsole.WriteLine("zlib exception on chunk starting at sector {0}", currentChunk.sector); + DicConsole.WriteLine("zlib exception on chunk starting at sector {0}", readChunk.sector); throw; } #endif @@ -588,7 +588,7 @@ namespace DiscImageChef.DiscImages return sector; } - switch(currentChunk.type) + switch(readChunk.type) { case CHUNK_TYPE_NOCOPY: case CHUNK_TYPE_ZERO: @@ -599,7 +599,7 @@ namespace DiscImageChef.DiscImages sectorCache.Add(sectorAddress, sector); return sector; case CHUNK_TYPE_COPY: - imageStream.Seek((long)currentChunk.offset + relOff, SeekOrigin.Begin); + imageStream.Seek((long)readChunk.offset + relOff, SeekOrigin.Begin); sector = new byte[SECTOR_SIZE]; imageStream.Read(sector, 0, sector.Length); @@ -609,7 +609,7 @@ namespace DiscImageChef.DiscImages return sector; } - throw new ImageNotSupportedException($"Unsupported chunk type 0x{currentChunk.type:X8} found"); + throw new ImageNotSupportedException($"Unsupported chunk type 0x{readChunk.type:X8} found"); } public byte[] ReadSectors(ulong sectorAddress, uint length) diff --git a/DiscImageChef.DiscImages/VHD.cs b/DiscImageChef.DiscImages/VHD.cs index 14382f36..084a6625 100644 --- a/DiscImageChef.DiscImages/VHD.cs +++ b/DiscImageChef.DiscImages/VHD.cs @@ -262,8 +262,6 @@ namespace DiscImageChef.DiscImages public bool Identify(IFilter imageFilter) { Stream imageStream = imageFilter.GetDataForkStream(); - ulong headerCookie; - ulong footerCookie; byte[] headerCookieBytes = new byte[8]; byte[] footerCookieBytes = new byte[8]; @@ -276,8 +274,8 @@ namespace DiscImageChef.DiscImages imageStream.Read(headerCookieBytes, 0, 8); BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - headerCookie = BigEndianBitConverter.ToUInt64(headerCookieBytes, 0); - footerCookie = BigEndianBitConverter.ToUInt64(footerCookieBytes, 0); + ulong headerCookie = BigEndianBitConverter.ToUInt64(headerCookieBytes, 0); + ulong footerCookie = BigEndianBitConverter.ToUInt64(footerCookieBytes, 0); return headerCookie == IMAGE_COOKIE || footerCookie == IMAGE_COOKIE; } diff --git a/DiscImageChef.DiscImages/ZZZRawImage.cs b/DiscImageChef.DiscImages/ZZZRawImage.cs index 52d826a1..bd727654 100644 --- a/DiscImageChef.DiscImages/ZZZRawImage.cs +++ b/DiscImageChef.DiscImages/ZZZRawImage.cs @@ -50,7 +50,7 @@ namespace DiscImageChef.DiscImages { public class ZZZRawImage : IWritableImage { - readonly byte[] CdSync = + readonly byte[] cdSync = {0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00}; readonly (MediaTagType tag, string name)[] readWriteSidecars = { @@ -213,7 +213,7 @@ namespace DiscImageChef.DiscImages Stream stream = imageFilter.GetDataForkStream(); stream.Position = 0; stream.Read(sync, 0, 12); - return CdSync.SequenceEqual(sync); + return cdSync.SequenceEqual(sync); } // Check known disk sizes with sectors smaller than 512 @@ -436,7 +436,7 @@ namespace DiscImageChef.DiscImages stream.Seek(0, SeekOrigin.Begin); stream.Read(sync, 0, 12); stream.Read(header, 0, 4); - if(CdSync.SequenceEqual(sync)) + if(cdSync.SequenceEqual(sync)) { rawCompactDisc = true; hasSubchannel = imageInfo.ImageSize % 2448 == 0; @@ -473,7 +473,7 @@ namespace DiscImageChef.DiscImages filter.GetDataForkStream().Read(data, 0, data.Length); mediaTags.Add(sidecar.tag, data); } - catch(IOException e) { } + catch(IOException) { } // If there are INQUIRY and IDENTIFY tags, it's ATAPI if(mediaTags.ContainsKey(MediaTagType.SCSI_INQUIRY)) diff --git a/DiscImageChef.Filesystems/AmigaDOS.cs b/DiscImageChef.Filesystems/AmigaDOS.cs index 4f62411c..c65fe0a8 100644 --- a/DiscImageChef.Filesystems/AmigaDOS.cs +++ b/DiscImageChef.Filesystems/AmigaDOS.cs @@ -357,9 +357,7 @@ namespace DiscImageChef.Filesystems static uint AmigaBootChecksum(byte[] data) { - uint sum; - - sum = 0; + uint sum = 0; for(int i = 0; i < data.Length; i += 4) { uint psum = sum; diff --git a/DiscImageChef.Filesystems/AppleDOS/Info.cs b/DiscImageChef.Filesystems/AppleDOS/Info.cs index ee19978f..a1212065 100644 --- a/DiscImageChef.Filesystems/AppleDOS/Info.cs +++ b/DiscImageChef.Filesystems/AppleDOS/Info.cs @@ -49,8 +49,7 @@ namespace DiscImageChef.Filesystems.AppleDOS if(partition.Start > 0 || imagePlugin.Info.SectorSize != 256) return false; - int spt; - spt = imagePlugin.Info.Sectors == 455 ? 13 : 16; + int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16; byte[] vtocB = imagePlugin.ReadSector((ulong)(17 * spt)); vtoc = new Vtoc(); diff --git a/DiscImageChef.Filesystems/AppleHFS.cs b/DiscImageChef.Filesystems/AppleHFS.cs index 55cf6d8a..14ca5838 100644 --- a/DiscImageChef.Filesystems/AppleHFS.cs +++ b/DiscImageChef.Filesystems/AppleHFS.cs @@ -111,7 +111,7 @@ namespace DiscImageChef.Filesystems byte[] mdbSector = null; ushort drSigWord; - bool APMFromHDDOnCD = false; + bool apmFromHddOnCd = false; if(imagePlugin.Info.SectorSize == 2352 || imagePlugin.Info.SectorSize == 2448 || imagePlugin.Info.SectorSize == 2048) @@ -127,11 +127,11 @@ namespace DiscImageChef.Filesystems mdbSector = new byte[512]; if(offset >= 0x400) Array.Copy(tmpSector, offset - 0x400, bbSector, 0, 1024); Array.Copy(tmpSector, offset, mdbSector, 0, 512); - APMFromHDDOnCD = true; + apmFromHddOnCd = true; break; } - if(!APMFromHDDOnCD) return; + if(!apmFromHddOnCd) return; } else { @@ -142,146 +142,146 @@ namespace DiscImageChef.Filesystems else return; } - HFS_MasterDirectoryBlock MDB = - BigEndianMarshal.ByteArrayToStructureBigEndian(mdbSector); - HFS_BootBlock BB = BigEndianMarshal.ByteArrayToStructureBigEndian(bbSector); + HfsMasterDirectoryBlock mdb = + BigEndianMarshal.ByteArrayToStructureBigEndian(mdbSector); + HfsBootBlock bb = BigEndianMarshal.ByteArrayToStructureBigEndian(bbSector); sb.AppendLine("Apple Hierarchical File System"); sb.AppendLine(); - if(APMFromHDDOnCD) + if(apmFromHddOnCd) sb.AppendLine("HFS uses 512 bytes/sector while device uses 2048 bytes/sector.").AppendLine(); sb.AppendLine("Master Directory Block:"); - sb.AppendFormat("Creation date: {0}", DateHandlers.MacToDateTime(MDB.drCrDate)).AppendLine(); - sb.AppendFormat("Last modification date: {0}", DateHandlers.MacToDateTime(MDB.drLsMod)).AppendLine(); - if(MDB.drVolBkUp > 0) + sb.AppendFormat("Creation date: {0}", DateHandlers.MacToDateTime(mdb.drCrDate)).AppendLine(); + sb.AppendFormat("Last modification date: {0}", DateHandlers.MacToDateTime(mdb.drLsMod)).AppendLine(); + if(mdb.drVolBkUp > 0) { - sb.AppendFormat("Last backup date: {0}", DateHandlers.MacToDateTime(MDB.drVolBkUp)).AppendLine(); - sb.AppendFormat("Backup sequence number: {0}", MDB.drVSeqNum).AppendLine(); + sb.AppendFormat("Last backup date: {0}", DateHandlers.MacToDateTime(mdb.drVolBkUp)).AppendLine(); + sb.AppendFormat("Backup sequence number: {0}", mdb.drVSeqNum).AppendLine(); } else sb.AppendLine("Volume has never been backed up"); - if((MDB.drAtrb & 0x80) == 0x80) sb.AppendLine("Volume is locked by hardware."); - sb.AppendLine((MDB.drAtrb & 0x100) == 0x100 ? "Volume was unmonted." : "Volume is mounted."); - if((MDB.drAtrb & 0x200) == 0x200) sb.AppendLine("Volume has spared bad blocks."); - if((MDB.drAtrb & 0x400) == 0x400) sb.AppendLine("Volume does not need cache."); - if((MDB.drAtrb & 0x800) == 0x800) sb.AppendLine("Boot volume is inconsistent."); - if((MDB.drAtrb & 0x1000) == 0x1000) sb.AppendLine("There are reused CNIDs."); - if((MDB.drAtrb & 0x2000) == 0x2000) sb.AppendLine("Volume is journaled."); - if((MDB.drAtrb & 0x4000) == 0x4000) sb.AppendLine("Volume is seriously inconsistent."); - if((MDB.drAtrb & 0x8000) == 0x8000) sb.AppendLine("Volume is locked by software."); + if((mdb.drAtrb & 0x80) == 0x80) sb.AppendLine("Volume is locked by hardware."); + sb.AppendLine((mdb.drAtrb & 0x100) == 0x100 ? "Volume was unmonted." : "Volume is mounted."); + if((mdb.drAtrb & 0x200) == 0x200) sb.AppendLine("Volume has spared bad blocks."); + if((mdb.drAtrb & 0x400) == 0x400) sb.AppendLine("Volume does not need cache."); + if((mdb.drAtrb & 0x800) == 0x800) sb.AppendLine("Boot volume is inconsistent."); + if((mdb.drAtrb & 0x1000) == 0x1000) sb.AppendLine("There are reused CNIDs."); + if((mdb.drAtrb & 0x2000) == 0x2000) sb.AppendLine("Volume is journaled."); + if((mdb.drAtrb & 0x4000) == 0x4000) sb.AppendLine("Volume is seriously inconsistent."); + if((mdb.drAtrb & 0x8000) == 0x8000) sb.AppendLine("Volume is locked by software."); - sb.AppendFormat("{0} files on root directory", MDB.drNmFls).AppendLine(); - sb.AppendFormat("{0} directories on root directory", MDB.drNmRtDirs).AppendLine(); - sb.AppendFormat("{0} files on volume", MDB.drFilCnt).AppendLine(); - sb.AppendFormat("{0} directories on volume", MDB.drDirCnt).AppendLine(); - sb.AppendFormat("Volume write count: {0}", MDB.drWrCnt).AppendLine(); + sb.AppendFormat("{0} files on root directory", mdb.drNmFls).AppendLine(); + sb.AppendFormat("{0} directories on root directory", mdb.drNmRtDirs).AppendLine(); + sb.AppendFormat("{0} files on volume", mdb.drFilCnt).AppendLine(); + sb.AppendFormat("{0} directories on volume", mdb.drDirCnt).AppendLine(); + sb.AppendFormat("Volume write count: {0}", mdb.drWrCnt).AppendLine(); - sb.AppendFormat("Volume bitmap starting sector (in 512-bytes): {0}", MDB.drVBMSt).AppendLine(); - sb.AppendFormat("Next allocation block: {0}.", MDB.drAllocPtr).AppendLine(); - sb.AppendFormat("{0} volume allocation blocks.", MDB.drNmAlBlks).AppendLine(); - sb.AppendFormat("{0} bytes per allocation block.", MDB.drAlBlkSiz).AppendLine(); - sb.AppendFormat("{0} bytes to allocate when extending a file.", MDB.drClpSiz).AppendLine(); - sb.AppendFormat("{0} bytes to allocate when extending a Extents B-Tree.", MDB.drXTClpSiz).AppendLine(); - sb.AppendFormat("{0} bytes to allocate when extending a Catalog B-Tree.", MDB.drCTClpSiz).AppendLine(); - sb.AppendFormat("Sector of first allocation block: {0}", MDB.drAlBlSt).AppendLine(); - sb.AppendFormat("Next unused CNID: {0}", MDB.drNxtCNID).AppendLine(); - sb.AppendFormat("{0} unused allocation blocks.", MDB.drFreeBks).AppendLine(); + sb.AppendFormat("Volume bitmap starting sector (in 512-bytes): {0}", mdb.drVBMSt).AppendLine(); + sb.AppendFormat("Next allocation block: {0}.", mdb.drAllocPtr).AppendLine(); + sb.AppendFormat("{0} volume allocation blocks.", mdb.drNmAlBlks).AppendLine(); + sb.AppendFormat("{0} bytes per allocation block.", mdb.drAlBlkSiz).AppendLine(); + sb.AppendFormat("{0} bytes to allocate when extending a file.", mdb.drClpSiz).AppendLine(); + sb.AppendFormat("{0} bytes to allocate when extending a Extents B-Tree.", mdb.drXTClpSiz).AppendLine(); + sb.AppendFormat("{0} bytes to allocate when extending a Catalog B-Tree.", mdb.drCTClpSiz).AppendLine(); + sb.AppendFormat("Sector of first allocation block: {0}", mdb.drAlBlSt).AppendLine(); + sb.AppendFormat("Next unused CNID: {0}", mdb.drNxtCNID).AppendLine(); + sb.AppendFormat("{0} unused allocation blocks.", mdb.drFreeBks).AppendLine(); - sb.AppendFormat("{0} bytes in the Extents B-Tree", MDB.drXTFlSize).AppendLine(); - sb.AppendFormat("{0} bytes in the Catalog B-Tree", MDB.drCTFlSize).AppendLine(); + sb.AppendFormat("{0} bytes in the Extents B-Tree", mdb.drXTFlSize).AppendLine(); + sb.AppendFormat("{0} bytes in the Catalog B-Tree", mdb.drCTFlSize).AppendLine(); - sb.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(MDB.drVN, Encoding)).AppendLine(); + sb.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(mdb.drVN, Encoding)).AppendLine(); sb.AppendLine("Finder info:"); - sb.AppendFormat("CNID of bootable system's directory: {0}", MDB.drFndrInfo0).AppendLine(); - sb.AppendFormat("CNID of first-run application's directory: {0}", MDB.drFndrInfo1).AppendLine(); - sb.AppendFormat("CNID of previously opened directory: {0}", MDB.drFndrInfo2).AppendLine(); - sb.AppendFormat("CNID of bootable Mac OS 8 or 9 directory: {0}", MDB.drFndrInfo3).AppendLine(); - sb.AppendFormat("CNID of bootable Mac OS X directory: {0}", MDB.drFndrInfo5).AppendLine(); - if(MDB.drFndrInfo6 != 0 && MDB.drFndrInfo7 != 0) - sb.AppendFormat("Mac OS X Volume ID: {0:X8}{1:X8}", MDB.drFndrInfo6, MDB.drFndrInfo7).AppendLine(); + sb.AppendFormat("CNID of bootable system's directory: {0}", mdb.drFndrInfo0).AppendLine(); + sb.AppendFormat("CNID of first-run application's directory: {0}", mdb.drFndrInfo1).AppendLine(); + sb.AppendFormat("CNID of previously opened directory: {0}", mdb.drFndrInfo2).AppendLine(); + sb.AppendFormat("CNID of bootable Mac OS 8 or 9 directory: {0}", mdb.drFndrInfo3).AppendLine(); + sb.AppendFormat("CNID of bootable Mac OS X directory: {0}", mdb.drFndrInfo5).AppendLine(); + if(mdb.drFndrInfo6 != 0 && mdb.drFndrInfo7 != 0) + sb.AppendFormat("Mac OS X Volume ID: {0:X8}{1:X8}", mdb.drFndrInfo6, mdb.drFndrInfo7).AppendLine(); - if(MDB.drEmbedSigWord == HFSP_MAGIC) + if(mdb.drEmbedSigWord == HFSP_MAGIC) { sb.AppendLine("Volume wraps a HFS+ volume."); - sb.AppendFormat("Starting block of the HFS+ volume: {0}", MDB.xdrStABNt).AppendLine(); - sb.AppendFormat("Allocations blocks of the HFS+ volume: {0}", MDB.xdrNumABlks).AppendLine(); + sb.AppendFormat("Starting block of the HFS+ volume: {0}", mdb.xdrStABNt).AppendLine(); + sb.AppendFormat("Allocations blocks of the HFS+ volume: {0}", mdb.xdrNumABlks).AppendLine(); } else { - sb.AppendFormat("{0} blocks in volume cache", MDB.drVCSize).AppendLine(); - sb.AppendFormat("{0} blocks in volume bitmap cache", MDB.drVBMCSize).AppendLine(); - sb.AppendFormat("{0} blocks in volume common cache", MDB.drCtlCSize).AppendLine(); + sb.AppendFormat("{0} blocks in volume cache", mdb.drVCSize).AppendLine(); + sb.AppendFormat("{0} blocks in volume bitmap cache", mdb.drVBMCSize).AppendLine(); + sb.AppendFormat("{0} blocks in volume common cache", mdb.drCtlCSize).AppendLine(); } - if(BB.signature == HFSBB_MAGIC) + if(bb.signature == HFSBB_MAGIC) { sb.AppendLine("Volume is bootable."); sb.AppendLine(); sb.AppendLine("Boot Block:"); - if((BB.boot_flags & 0x40) == 0x40) sb.AppendLine("Boot block should be executed."); - if((BB.boot_flags & 0x80) == 0x80) sb.AppendLine("Boot block is in new unknown format."); + if((bb.boot_flags & 0x40) == 0x40) sb.AppendLine("Boot block should be executed."); + if((bb.boot_flags & 0x80) == 0x80) sb.AppendLine("Boot block is in new unknown format."); else { - if(BB.boot_flags > 0) sb.AppendLine("Allocate secondary sound buffer at boot."); - else if(BB.boot_flags < 0) sb.AppendLine("Allocate secondary sound and video buffers at boot."); + if(bb.boot_flags > 0) sb.AppendLine("Allocate secondary sound buffer at boot."); + else if(bb.boot_flags < 0) sb.AppendLine("Allocate secondary sound and video buffers at boot."); - sb.AppendFormat("System filename: {0}", StringHandlers.PascalToString(BB.system_name, Encoding)) + sb.AppendFormat("System filename: {0}", StringHandlers.PascalToString(bb.system_name, Encoding)) .AppendLine(); - sb.AppendFormat("Finder filename: {0}", StringHandlers.PascalToString(BB.finder_name, Encoding)) + sb.AppendFormat("Finder filename: {0}", StringHandlers.PascalToString(bb.finder_name, Encoding)) .AppendLine(); - sb.AppendFormat("Debugger filename: {0}", StringHandlers.PascalToString(BB.debug_name, Encoding)) + sb.AppendFormat("Debugger filename: {0}", StringHandlers.PascalToString(bb.debug_name, Encoding)) .AppendLine(); sb.AppendFormat("Disassembler filename: {0}", - StringHandlers.PascalToString(BB.disasm_name, Encoding)).AppendLine(); + StringHandlers.PascalToString(bb.disasm_name, Encoding)).AppendLine(); sb.AppendFormat("Startup screen filename: {0}", - StringHandlers.PascalToString(BB.stupscr_name, Encoding)).AppendLine(); + StringHandlers.PascalToString(bb.stupscr_name, Encoding)).AppendLine(); sb.AppendFormat("First program to execute at boot: {0}", - StringHandlers.PascalToString(BB.bootup_name, Encoding)).AppendLine(); - sb.AppendFormat("Clipboard filename: {0}", StringHandlers.PascalToString(BB.clipbrd_name, Encoding)) + StringHandlers.PascalToString(bb.bootup_name, Encoding)).AppendLine(); + sb.AppendFormat("Clipboard filename: {0}", StringHandlers.PascalToString(bb.clipbrd_name, Encoding)) .AppendLine(); - sb.AppendFormat("Maximum opened files: {0}", BB.max_files * 4).AppendLine(); - sb.AppendFormat("Event queue size: {0}", BB.queue_size).AppendLine(); - sb.AppendFormat("Heap size with 128KiB of RAM: {0} bytes", BB.heap_128k).AppendLine(); - sb.AppendFormat("Heap size with 256KiB of RAM: {0} bytes", BB.heap_256k).AppendLine(); - sb.AppendFormat("Heap size with 512KiB of RAM or more: {0} bytes", BB.heap_512k).AppendLine(); + sb.AppendFormat("Maximum opened files: {0}", bb.max_files * 4).AppendLine(); + sb.AppendFormat("Event queue size: {0}", bb.queue_size).AppendLine(); + sb.AppendFormat("Heap size with 128KiB of RAM: {0} bytes", bb.heap_128k).AppendLine(); + sb.AppendFormat("Heap size with 256KiB of RAM: {0} bytes", bb.heap_256k).AppendLine(); + sb.AppendFormat("Heap size with 512KiB of RAM or more: {0} bytes", bb.heap_512k).AppendLine(); } } - else if(MDB.drFndrInfo0 != 0 || MDB.drFndrInfo3 != 0 || MDB.drFndrInfo5 != 0) + else if(mdb.drFndrInfo0 != 0 || mdb.drFndrInfo3 != 0 || mdb.drFndrInfo5 != 0) sb.AppendLine("Volume is bootable."); else sb.AppendLine("Volume is not bootable."); information = sb.ToString(); XmlFsType = new FileSystemType(); - if(MDB.drVolBkUp > 0) + if(mdb.drVolBkUp > 0) { - XmlFsType.BackupDate = DateHandlers.MacToDateTime(MDB.drVolBkUp); + XmlFsType.BackupDate = DateHandlers.MacToDateTime(mdb.drVolBkUp); XmlFsType.BackupDateSpecified = true; } - XmlFsType.Bootable = BB.signature == HFSBB_MAGIC || MDB.drFndrInfo0 != 0 || MDB.drFndrInfo3 != 0 || - MDB.drFndrInfo5 != 0; - XmlFsType.Clusters = MDB.drNmAlBlks; - XmlFsType.ClusterSize = (int)MDB.drAlBlkSiz; - if(MDB.drCrDate > 0) + XmlFsType.Bootable = bb.signature == HFSBB_MAGIC || mdb.drFndrInfo0 != 0 || mdb.drFndrInfo3 != 0 || + mdb.drFndrInfo5 != 0; + XmlFsType.Clusters = mdb.drNmAlBlks; + XmlFsType.ClusterSize = (int)mdb.drAlBlkSiz; + if(mdb.drCrDate > 0) { - XmlFsType.CreationDate = DateHandlers.MacToDateTime(MDB.drCrDate); + XmlFsType.CreationDate = DateHandlers.MacToDateTime(mdb.drCrDate); XmlFsType.CreationDateSpecified = true; } - XmlFsType.Dirty = (MDB.drAtrb & 0x100) != 0x100; - XmlFsType.Files = MDB.drFilCnt; + XmlFsType.Dirty = (mdb.drAtrb & 0x100) != 0x100; + XmlFsType.Files = mdb.drFilCnt; XmlFsType.FilesSpecified = true; - XmlFsType.FreeClusters = MDB.drFreeBks; + XmlFsType.FreeClusters = mdb.drFreeBks; XmlFsType.FreeClustersSpecified = true; - if(MDB.drLsMod > 0) + if(mdb.drLsMod > 0) { - XmlFsType.ModificationDate = DateHandlers.MacToDateTime(MDB.drLsMod); + XmlFsType.ModificationDate = DateHandlers.MacToDateTime(mdb.drLsMod); XmlFsType.ModificationDateSpecified = true; } XmlFsType.Type = "HFS"; - XmlFsType.VolumeName = StringHandlers.PascalToString(MDB.drVN, Encoding); - if(MDB.drFndrInfo6 != 0 && MDB.drFndrInfo7 != 0) - XmlFsType.VolumeSerial = $"{MDB.drFndrInfo6:X8}{MDB.drFndrInfo7:X8}"; + XmlFsType.VolumeName = StringHandlers.PascalToString(mdb.drVN, Encoding); + if(mdb.drFndrInfo6 != 0 && mdb.drFndrInfo7 != 0) + XmlFsType.VolumeSerial = $"{mdb.drFndrInfo6:X8}{mdb.drFndrInfo7:X8}"; } static byte[] Read2048SectorAs512(IMediaImage imagePlugin, ulong lba) @@ -301,7 +301,7 @@ namespace DiscImageChef.Filesystems /// Master Directory Block, should be sector 2 in volume /// [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HFS_MasterDirectoryBlock // Should be sector 2 in volume + struct HfsMasterDirectoryBlock // Should be sector 2 in volume { /// 0x000, Signature, 0x4244 public ushort drSigWord; @@ -394,7 +394,7 @@ namespace DiscImageChef.Filesystems /// Should be sectors 0 and 1 in volume, followed by boot code /// [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HFS_BootBlock // Should be sectors 0 and 1 in volume + struct HfsBootBlock // Should be sectors 0 and 1 in volume { /// 0x000, Signature, 0x4C4B if bootable public ushort signature; diff --git a/DiscImageChef.Filesystems/AppleHFSPlus.cs b/DiscImageChef.Filesystems/AppleHFSPlus.cs index b94f94ac..ae9b649c 100644 --- a/DiscImageChef.Filesystems/AppleHFSPlus.cs +++ b/DiscImageChef.Filesystems/AppleHFSPlus.cs @@ -64,8 +64,6 @@ namespace DiscImageChef.Filesystems { if(2 + partition.Start >= partition.End) return false; - ushort drSigWord; - ulong hfspOffset; uint sectorsToRead = 0x800 / imagePlugin.Info.SectorSize; @@ -73,7 +71,7 @@ namespace DiscImageChef.Filesystems byte[] vhSector = imagePlugin.ReadSectors(partition.Start, sectorsToRead); - drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); // Check for HFS Wrapper MDB + ushort drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); if(drSigWord == HFS_MAGIC) // "BD" { @@ -105,8 +103,7 @@ namespace DiscImageChef.Filesystems Encoding = Encoding.BigEndianUnicode; information = ""; - ushort drSigWord; - HFSPlusVolumeHeader HPVH = new HFSPlusVolumeHeader(); + HfsPlusVolumeHeader vh = new HfsPlusVolumeHeader(); ulong hfspOffset; bool wrapped; @@ -116,7 +113,7 @@ namespace DiscImageChef.Filesystems byte[] vhSector = imagePlugin.ReadSectors(partition.Start, sectorsToRead); - drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); // Check for HFS Wrapper MDB + ushort drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); if(drSigWord == HFS_MAGIC) // "BD" { @@ -147,120 +144,119 @@ namespace DiscImageChef.Filesystems vhSector = imagePlugin.ReadSectors(partition.Start + hfspOffset, sectorsToRead); // Read volume header - HPVH.signature = BigEndianBitConverter.ToUInt16(vhSector, 0x400); - if(HPVH.signature == HFSP_MAGIC || HPVH.signature == HFSX_MAGIC) + vh.signature = BigEndianBitConverter.ToUInt16(vhSector, 0x400); + + if(vh.signature != HFSP_MAGIC && vh.signature != HFSX_MAGIC) return; + + StringBuilder sb = new StringBuilder(); + + if(vh.signature == 0x482B) sb.AppendLine("HFS+ filesystem."); + if(vh.signature == 0x4858) sb.AppendLine("HFSX filesystem."); + if(wrapped) sb.AppendLine("Volume is wrapped inside an HFS volume."); + + byte[] tmp = new byte[0x400]; + Array.Copy(vhSector, 0x400, tmp, 0, 0x400); + vhSector = tmp; + + vh = BigEndianMarshal.ByteArrayToStructureBigEndian(vhSector); + + if(vh.version == 4 || vh.version == 5) { - StringBuilder sb = new StringBuilder(); + sb.AppendFormat("Filesystem version is {0}.", vh.version).AppendLine(); - if(HPVH.signature == 0x482B) sb.AppendLine("HFS+ filesystem."); - if(HPVH.signature == 0x4858) sb.AppendLine("HFSX filesystem."); - if(wrapped) sb.AppendLine("Volume is wrapped inside an HFS volume."); + if((vh.attributes & 0x80) == 0x80) sb.AppendLine("Volume is locked on hardware."); + if((vh.attributes & 0x100) == 0x100) sb.AppendLine("Volume is unmounted."); + if((vh.attributes & 0x200) == 0x200) sb.AppendLine("There are bad blocks in the extents file."); + if((vh.attributes & 0x400) == 0x400) sb.AppendLine("Volume does not require cache."); + if((vh.attributes & 0x800) == 0x800) sb.AppendLine("Volume state is inconsistent."); + if((vh.attributes & 0x1000) == 0x1000) sb.AppendLine("CNIDs are reused."); + if((vh.attributes & 0x2000) == 0x2000) sb.AppendLine("Volume is journaled."); + if((vh.attributes & 0x8000) == 0x8000) sb.AppendLine("Volume is locked on software."); - byte[] tmp = new byte[0x400]; - Array.Copy(vhSector, 0x400, tmp, 0, 0x400); - vhSector = tmp; - - HPVH = BigEndianMarshal.ByteArrayToStructureBigEndian(vhSector); - - if(HPVH.version == 4 || HPVH.version == 5) - { - sb.AppendFormat("Filesystem version is {0}.", HPVH.version).AppendLine(); - - if((HPVH.attributes & 0x80) == 0x80) sb.AppendLine("Volume is locked on hardware."); - if((HPVH.attributes & 0x100) == 0x100) sb.AppendLine("Volume is unmounted."); - if((HPVH.attributes & 0x200) == 0x200) sb.AppendLine("There are bad blocks in the extents file."); - if((HPVH.attributes & 0x400) == 0x400) sb.AppendLine("Volume does not require cache."); - if((HPVH.attributes & 0x800) == 0x800) sb.AppendLine("Volume state is inconsistent."); - if((HPVH.attributes & 0x1000) == 0x1000) sb.AppendLine("CNIDs are reused."); - if((HPVH.attributes & 0x2000) == 0x2000) sb.AppendLine("Volume is journaled."); - if((HPVH.attributes & 0x8000) == 0x8000) sb.AppendLine("Volume is locked on software."); - - sb.AppendFormat("Implementation that last mounted the volume: \"{0}\".", - Encoding.ASCII.GetString(HPVH.lastMountedVersion)).AppendLine(); - if((HPVH.attributes & 0x2000) == 0x2000) - sb.AppendFormat("Journal starts at allocation block {0}.", HPVH.journalInfoBlock).AppendLine(); - sb.AppendFormat("Creation date: {0}", DateHandlers.MacToDateTime(HPVH.createDate)).AppendLine(); - sb.AppendFormat("Last modification date: {0}", DateHandlers.MacToDateTime(HPVH.modifyDate)) + sb.AppendFormat("Implementation that last mounted the volume: \"{0}\".", + Encoding.ASCII.GetString(vh.lastMountedVersion)).AppendLine(); + if((vh.attributes & 0x2000) == 0x2000) + sb.AppendFormat("Journal starts at allocation block {0}.", vh.journalInfoBlock).AppendLine(); + sb.AppendFormat("Creation date: {0}", DateHandlers.MacToDateTime(vh.createDate)).AppendLine(); + sb.AppendFormat("Last modification date: {0}", DateHandlers.MacToDateTime(vh.modifyDate)) + .AppendLine(); + if(vh.backupDate > 0) + sb.AppendFormat("Last backup date: {0}", DateHandlers.MacToDateTime(vh.backupDate)) + .AppendLine(); + else sb.AppendLine("Volume has never been backed up"); + if(vh.backupDate > 0) + sb.AppendFormat("Last check date: {0}", DateHandlers.MacToDateTime(vh.checkedDate)) + .AppendLine(); + else sb.AppendLine("Volume has never been checked up"); + sb.AppendFormat("{0} files on volume.", vh.fileCount).AppendLine(); + sb.AppendFormat("{0} folders on volume.", vh.folderCount).AppendLine(); + sb.AppendFormat("{0} bytes per allocation block.", vh.blockSize).AppendLine(); + sb.AppendFormat("{0} allocation blocks.", vh.totalBlocks).AppendLine(); + sb.AppendFormat("{0} free blocks.", vh.freeBlocks).AppendLine(); + sb.AppendFormat("Next allocation block: {0}.", vh.nextAllocation).AppendLine(); + sb.AppendFormat("Resource fork clump size: {0} bytes.", vh.rsrcClumpSize).AppendLine(); + sb.AppendFormat("Data fork clump size: {0} bytes.", vh.dataClumpSize).AppendLine(); + sb.AppendFormat("Next unused CNID: {0}.", vh.nextCatalogID).AppendLine(); + sb.AppendFormat("Volume has been mounted writable {0} times.", vh.writeCount).AppendLine(); + sb.AppendFormat("Allocation File is {0} bytes.", vh.allocationFile_logicalSize).AppendLine(); + sb.AppendFormat("Extents File is {0} bytes.", vh.extentsFile_logicalSize).AppendLine(); + sb.AppendFormat("Catalog File is {0} bytes.", vh.catalogFile_logicalSize).AppendLine(); + sb.AppendFormat("Attributes File is {0} bytes.", vh.attributesFile_logicalSize).AppendLine(); + sb.AppendFormat("Startup File is {0} bytes.", vh.startupFile_logicalSize).AppendLine(); + sb.AppendLine("Finder info:"); + sb.AppendFormat("CNID of bootable system's directory: {0}", vh.drFndrInfo0).AppendLine(); + sb.AppendFormat("CNID of first-run application's directory: {0}", vh.drFndrInfo1).AppendLine(); + sb.AppendFormat("CNID of previously opened directory: {0}", vh.drFndrInfo2).AppendLine(); + sb.AppendFormat("CNID of bootable Mac OS 8 or 9 directory: {0}", vh.drFndrInfo3).AppendLine(); + sb.AppendFormat("CNID of bootable Mac OS X directory: {0}", vh.drFndrInfo5).AppendLine(); + if(vh.drFndrInfo6 != 0 && vh.drFndrInfo7 != 0) + sb.AppendFormat("Mac OS X Volume ID: {0:X8}{1:X8}", vh.drFndrInfo6, vh.drFndrInfo7) .AppendLine(); - if(HPVH.backupDate > 0) - sb.AppendFormat("Last backup date: {0}", DateHandlers.MacToDateTime(HPVH.backupDate)) - .AppendLine(); - else sb.AppendLine("Volume has never been backed up"); - if(HPVH.backupDate > 0) - sb.AppendFormat("Last check date: {0}", DateHandlers.MacToDateTime(HPVH.checkedDate)) - .AppendLine(); - else sb.AppendLine("Volume has never been checked up"); - sb.AppendFormat("{0} files on volume.", HPVH.fileCount).AppendLine(); - sb.AppendFormat("{0} folders on volume.", HPVH.folderCount).AppendLine(); - sb.AppendFormat("{0} bytes per allocation block.", HPVH.blockSize).AppendLine(); - sb.AppendFormat("{0} allocation blocks.", HPVH.totalBlocks).AppendLine(); - sb.AppendFormat("{0} free blocks.", HPVH.freeBlocks).AppendLine(); - sb.AppendFormat("Next allocation block: {0}.", HPVH.nextAllocation).AppendLine(); - sb.AppendFormat("Resource fork clump size: {0} bytes.", HPVH.rsrcClumpSize).AppendLine(); - sb.AppendFormat("Data fork clump size: {0} bytes.", HPVH.dataClumpSize).AppendLine(); - sb.AppendFormat("Next unused CNID: {0}.", HPVH.nextCatalogID).AppendLine(); - sb.AppendFormat("Volume has been mounted writable {0} times.", HPVH.writeCount).AppendLine(); - sb.AppendFormat("Allocation File is {0} bytes.", HPVH.allocationFile_logicalSize).AppendLine(); - sb.AppendFormat("Extents File is {0} bytes.", HPVH.extentsFile_logicalSize).AppendLine(); - sb.AppendFormat("Catalog File is {0} bytes.", HPVH.catalogFile_logicalSize).AppendLine(); - sb.AppendFormat("Attributes File is {0} bytes.", HPVH.attributesFile_logicalSize).AppendLine(); - sb.AppendFormat("Startup File is {0} bytes.", HPVH.startupFile_logicalSize).AppendLine(); - sb.AppendLine("Finder info:"); - sb.AppendFormat("CNID of bootable system's directory: {0}", HPVH.drFndrInfo0).AppendLine(); - sb.AppendFormat("CNID of first-run application's directory: {0}", HPVH.drFndrInfo1).AppendLine(); - sb.AppendFormat("CNID of previously opened directory: {0}", HPVH.drFndrInfo2).AppendLine(); - sb.AppendFormat("CNID of bootable Mac OS 8 or 9 directory: {0}", HPVH.drFndrInfo3).AppendLine(); - sb.AppendFormat("CNID of bootable Mac OS X directory: {0}", HPVH.drFndrInfo5).AppendLine(); - if(HPVH.drFndrInfo6 != 0 && HPVH.drFndrInfo7 != 0) - sb.AppendFormat("Mac OS X Volume ID: {0:X8}{1:X8}", HPVH.drFndrInfo6, HPVH.drFndrInfo7) - .AppendLine(); - XmlFsType = new FileSystemType(); - if(HPVH.backupDate > 0) - { - XmlFsType.BackupDate = DateHandlers.MacToDateTime(HPVH.backupDate); - XmlFsType.BackupDateSpecified = true; - } - XmlFsType.Bootable |= HPVH.drFndrInfo0 != 0 || HPVH.drFndrInfo3 != 0 || HPVH.drFndrInfo5 != 0; - XmlFsType.Clusters = HPVH.totalBlocks; - XmlFsType.ClusterSize = (int)HPVH.blockSize; - if(HPVH.createDate > 0) - { - XmlFsType.CreationDate = DateHandlers.MacToDateTime(HPVH.createDate); - XmlFsType.CreationDateSpecified = true; - } - XmlFsType.Dirty = (HPVH.attributes & 0x100) != 0x100; - XmlFsType.Files = HPVH.fileCount; - XmlFsType.FilesSpecified = true; - XmlFsType.FreeClusters = HPVH.freeBlocks; - XmlFsType.FreeClustersSpecified = true; - if(HPVH.modifyDate > 0) - { - XmlFsType.ModificationDate = DateHandlers.MacToDateTime(HPVH.modifyDate); - XmlFsType.ModificationDateSpecified = true; - } - if(HPVH.signature == 0x482B) XmlFsType.Type = "HFS+"; - if(HPVH.signature == 0x4858) XmlFsType.Type = "HFSX"; - if(HPVH.drFndrInfo6 != 0 && HPVH.drFndrInfo7 != 0) - XmlFsType.VolumeSerial = $"{HPVH.drFndrInfo6:X8}{HPVH.drFndrInfo7:X8}"; - XmlFsType.SystemIdentifier = Encoding.ASCII.GetString(HPVH.lastMountedVersion); - } - else + XmlFsType = new FileSystemType(); + if(vh.backupDate > 0) { - sb.AppendFormat("Filesystem version is {0}.", HPVH.version).AppendLine(); - sb.AppendLine("This version is not supported yet."); + XmlFsType.BackupDate = DateHandlers.MacToDateTime(vh.backupDate); + XmlFsType.BackupDateSpecified = true; } - - information = sb.ToString(); + XmlFsType.Bootable |= vh.drFndrInfo0 != 0 || vh.drFndrInfo3 != 0 || vh.drFndrInfo5 != 0; + XmlFsType.Clusters = vh.totalBlocks; + XmlFsType.ClusterSize = (int)vh.blockSize; + if(vh.createDate > 0) + { + XmlFsType.CreationDate = DateHandlers.MacToDateTime(vh.createDate); + XmlFsType.CreationDateSpecified = true; + } + XmlFsType.Dirty = (vh.attributes & 0x100) != 0x100; + XmlFsType.Files = vh.fileCount; + XmlFsType.FilesSpecified = true; + XmlFsType.FreeClusters = vh.freeBlocks; + XmlFsType.FreeClustersSpecified = true; + if(vh.modifyDate > 0) + { + XmlFsType.ModificationDate = DateHandlers.MacToDateTime(vh.modifyDate); + XmlFsType.ModificationDateSpecified = true; + } + if(vh.signature == 0x482B) XmlFsType.Type = "HFS+"; + if(vh.signature == 0x4858) XmlFsType.Type = "HFSX"; + if(vh.drFndrInfo6 != 0 && vh.drFndrInfo7 != 0) + XmlFsType.VolumeSerial = $"{vh.drFndrInfo6:X8}{vh.drFndrInfo7:X8}"; + XmlFsType.SystemIdentifier = Encoding.ASCII.GetString(vh.lastMountedVersion); } - else return; + else + { + sb.AppendFormat("Filesystem version is {0}.", vh.version).AppendLine(); + sb.AppendLine("This version is not supported yet."); + } + + information = sb.ToString(); } /// /// HFS+ Volume Header, should be at offset 0x0400 bytes in volume with a size of 532 bytes /// [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HFSPlusVolumeHeader + struct HfsPlusVolumeHeader { /// 0x000, "H+" for HFS+, "HX" for HFSX public ushort signature; diff --git a/DiscImageChef.Filesystems/AppleMFS/Info.cs b/DiscImageChef.Filesystems/AppleMFS/Info.cs index 8d7b2ec7..c5e03bfb 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Info.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Info.cs @@ -45,15 +45,13 @@ namespace DiscImageChef.Filesystems.AppleMFS { public bool Identify(IMediaImage imagePlugin, Partition partition) { - ushort drSigWord; - if(2 + partition.Start >= partition.End) return false; byte[] mdbSector = imagePlugin.ReadSector(2 + partition.Start); BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000); + ushort drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000); return drSigWord == MFS_MAGIC; } @@ -66,8 +64,8 @@ namespace DiscImageChef.Filesystems.AppleMFS StringBuilder sb = new StringBuilder(); - MFS_MasterDirectoryBlock MDB = new MFS_MasterDirectoryBlock(); - MFS_BootBlock BB = new MFS_BootBlock(); + MFS_MasterDirectoryBlock mdb = new MFS_MasterDirectoryBlock(); + MFS_BootBlock bb = new MFS_BootBlock(); byte[] pString = new byte[16]; @@ -76,101 +74,101 @@ namespace DiscImageChef.Filesystems.AppleMFS BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - MDB.drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000); - if(MDB.drSigWord != MFS_MAGIC) return; + mdb.drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000); + if(mdb.drSigWord != MFS_MAGIC) return; - MDB.drCrDate = BigEndianBitConverter.ToUInt32(mdbSector, 0x002); - MDB.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbSector, 0x006); - MDB.drAtrb = BigEndianBitConverter.ToUInt16(mdbSector, 0x00A); - MDB.drNmFls = BigEndianBitConverter.ToUInt16(mdbSector, 0x00C); - MDB.drDirSt = BigEndianBitConverter.ToUInt16(mdbSector, 0x00E); - MDB.drBlLen = BigEndianBitConverter.ToUInt16(mdbSector, 0x010); - MDB.drNmAlBlks = BigEndianBitConverter.ToUInt16(mdbSector, 0x012); - MDB.drAlBlkSiz = BigEndianBitConverter.ToUInt32(mdbSector, 0x014); - MDB.drClpSiz = BigEndianBitConverter.ToUInt32(mdbSector, 0x018); - MDB.drAlBlSt = BigEndianBitConverter.ToUInt16(mdbSector, 0x01C); - MDB.drNxtFNum = BigEndianBitConverter.ToUInt32(mdbSector, 0x01E); - MDB.drFreeBks = BigEndianBitConverter.ToUInt16(mdbSector, 0x022); - MDB.drVNSiz = mdbSector[0x024]; - byte[] variableSize = new byte[MDB.drVNSiz + 1]; - Array.Copy(mdbSector, 0x024, variableSize, 0, MDB.drVNSiz + 1); - MDB.drVN = StringHandlers.PascalToString(variableSize, Encoding); + mdb.drCrDate = BigEndianBitConverter.ToUInt32(mdbSector, 0x002); + mdb.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbSector, 0x006); + mdb.drAtrb = BigEndianBitConverter.ToUInt16(mdbSector, 0x00A); + mdb.drNmFls = BigEndianBitConverter.ToUInt16(mdbSector, 0x00C); + mdb.drDirSt = BigEndianBitConverter.ToUInt16(mdbSector, 0x00E); + mdb.drBlLen = BigEndianBitConverter.ToUInt16(mdbSector, 0x010); + mdb.drNmAlBlks = BigEndianBitConverter.ToUInt16(mdbSector, 0x012); + mdb.drAlBlkSiz = BigEndianBitConverter.ToUInt32(mdbSector, 0x014); + mdb.drClpSiz = BigEndianBitConverter.ToUInt32(mdbSector, 0x018); + mdb.drAlBlSt = BigEndianBitConverter.ToUInt16(mdbSector, 0x01C); + mdb.drNxtFNum = BigEndianBitConverter.ToUInt32(mdbSector, 0x01E); + mdb.drFreeBks = BigEndianBitConverter.ToUInt16(mdbSector, 0x022); + mdb.drVNSiz = mdbSector[0x024]; + byte[] variableSize = new byte[mdb.drVNSiz + 1]; + Array.Copy(mdbSector, 0x024, variableSize, 0, mdb.drVNSiz + 1); + mdb.drVN = StringHandlers.PascalToString(variableSize, Encoding); - BB.signature = BigEndianBitConverter.ToUInt16(bbSector, 0x000); + bb.signature = BigEndianBitConverter.ToUInt16(bbSector, 0x000); - if(BB.signature == MFSBB_MAGIC) + if(bb.signature == MFSBB_MAGIC) { - BB.branch = BigEndianBitConverter.ToUInt32(bbSector, 0x002); - BB.boot_flags = bbSector[0x006]; - BB.boot_version = bbSector[0x007]; + bb.branch = BigEndianBitConverter.ToUInt32(bbSector, 0x002); + bb.boot_flags = bbSector[0x006]; + bb.boot_version = bbSector[0x007]; - BB.sec_sv_pages = BigEndianBitConverter.ToInt16(bbSector, 0x008); + bb.sec_sv_pages = BigEndianBitConverter.ToInt16(bbSector, 0x008); Array.Copy(mdbSector, 0x00A, pString, 0, 16); - BB.system_name = StringHandlers.PascalToString(pString, Encoding); + bb.system_name = StringHandlers.PascalToString(pString, Encoding); Array.Copy(mdbSector, 0x01A, pString, 0, 16); - BB.finder_name = StringHandlers.PascalToString(pString, Encoding); + bb.finder_name = StringHandlers.PascalToString(pString, Encoding); Array.Copy(mdbSector, 0x02A, pString, 0, 16); - BB.debug_name = StringHandlers.PascalToString(pString, Encoding); + bb.debug_name = StringHandlers.PascalToString(pString, Encoding); Array.Copy(mdbSector, 0x03A, pString, 0, 16); - BB.disasm_name = StringHandlers.PascalToString(pString, Encoding); + bb.disasm_name = StringHandlers.PascalToString(pString, Encoding); Array.Copy(mdbSector, 0x04A, pString, 0, 16); - BB.stupscr_name = StringHandlers.PascalToString(pString, Encoding); + bb.stupscr_name = StringHandlers.PascalToString(pString, Encoding); Array.Copy(mdbSector, 0x05A, pString, 0, 16); - BB.bootup_name = StringHandlers.PascalToString(pString, Encoding); + bb.bootup_name = StringHandlers.PascalToString(pString, Encoding); Array.Copy(mdbSector, 0x06A, pString, 0, 16); - BB.clipbrd_name = StringHandlers.PascalToString(pString, Encoding); + bb.clipbrd_name = StringHandlers.PascalToString(pString, Encoding); - BB.max_files = BigEndianBitConverter.ToUInt16(bbSector, 0x07A); - BB.queue_size = BigEndianBitConverter.ToUInt16(bbSector, 0x07C); - BB.heap_128k = BigEndianBitConverter.ToUInt32(bbSector, 0x07E); - BB.heap_256k = BigEndianBitConverter.ToUInt32(bbSector, 0x082); - BB.heap_512k = BigEndianBitConverter.ToUInt32(bbSector, 0x086); + bb.max_files = BigEndianBitConverter.ToUInt16(bbSector, 0x07A); + bb.queue_size = BigEndianBitConverter.ToUInt16(bbSector, 0x07C); + bb.heap_128k = BigEndianBitConverter.ToUInt32(bbSector, 0x07E); + bb.heap_256k = BigEndianBitConverter.ToUInt32(bbSector, 0x082); + bb.heap_512k = BigEndianBitConverter.ToUInt32(bbSector, 0x086); } - else BB.signature = 0x0000; + else bb.signature = 0x0000; sb.AppendLine("Apple Macintosh File System"); sb.AppendLine(); sb.AppendLine("Master Directory Block:"); - sb.AppendFormat("Creation date: {0}", DateHandlers.MacToDateTime(MDB.drCrDate)).AppendLine(); - sb.AppendFormat("Last backup date: {0}", DateHandlers.MacToDateTime(MDB.drLsBkUp)).AppendLine(); - if((MDB.drAtrb & 0x80) == 0x80) sb.AppendLine("Volume is locked by hardware."); - if((MDB.drAtrb & 0x8000) == 0x8000) sb.AppendLine("Volume is locked by software."); - sb.AppendFormat("{0} files on volume", MDB.drNmFls).AppendLine(); - sb.AppendFormat("First directory sector: {0}", MDB.drDirSt).AppendLine(); - sb.AppendFormat("{0} sectors in directory.", MDB.drBlLen).AppendLine(); - sb.AppendFormat("{0} volume allocation blocks.", MDB.drNmAlBlks + 1).AppendLine(); - sb.AppendFormat("Size of allocation blocks: {0} bytes", MDB.drAlBlkSiz).AppendLine(); - sb.AppendFormat("{0} bytes to allocate.", MDB.drClpSiz).AppendLine(); - sb.AppendFormat("First allocation block (#2) starts in sector {0}.", MDB.drAlBlSt).AppendLine(); - sb.AppendFormat("Next unused file number: {0}", MDB.drNxtFNum).AppendLine(); - sb.AppendFormat("{0} unused allocation blocks.", MDB.drFreeBks).AppendLine(); - sb.AppendFormat("Volume name: {0}", MDB.drVN).AppendLine(); + sb.AppendFormat("Creation date: {0}", DateHandlers.MacToDateTime(mdb.drCrDate)).AppendLine(); + sb.AppendFormat("Last backup date: {0}", DateHandlers.MacToDateTime(mdb.drLsBkUp)).AppendLine(); + if((mdb.drAtrb & 0x80) == 0x80) sb.AppendLine("Volume is locked by hardware."); + if((mdb.drAtrb & 0x8000) == 0x8000) sb.AppendLine("Volume is locked by software."); + sb.AppendFormat("{0} files on volume", mdb.drNmFls).AppendLine(); + sb.AppendFormat("First directory sector: {0}", mdb.drDirSt).AppendLine(); + sb.AppendFormat("{0} sectors in directory.", mdb.drBlLen).AppendLine(); + sb.AppendFormat("{0} volume allocation blocks.", mdb.drNmAlBlks + 1).AppendLine(); + sb.AppendFormat("Size of allocation blocks: {0} bytes", mdb.drAlBlkSiz).AppendLine(); + sb.AppendFormat("{0} bytes to allocate.", mdb.drClpSiz).AppendLine(); + sb.AppendFormat("First allocation block (#2) starts in sector {0}.", mdb.drAlBlSt).AppendLine(); + sb.AppendFormat("Next unused file number: {0}", mdb.drNxtFNum).AppendLine(); + sb.AppendFormat("{0} unused allocation blocks.", mdb.drFreeBks).AppendLine(); + sb.AppendFormat("Volume name: {0}", mdb.drVN).AppendLine(); - if(BB.signature == MFSBB_MAGIC) + if(bb.signature == MFSBB_MAGIC) { sb.AppendLine("Volume is bootable."); sb.AppendLine(); sb.AppendLine("Boot Block:"); - if((BB.boot_flags & 0x40) == 0x40) sb.AppendLine("Boot block should be executed."); - if((BB.boot_flags & 0x80) == 0x80) sb.AppendLine("Boot block is in new unknown format."); + if((bb.boot_flags & 0x40) == 0x40) sb.AppendLine("Boot block should be executed."); + if((bb.boot_flags & 0x80) == 0x80) sb.AppendLine("Boot block is in new unknown format."); else { - if(BB.sec_sv_pages > 0) sb.AppendLine("Allocate secondary sound buffer at boot."); - else if(BB.sec_sv_pages < 0) sb.AppendLine("Allocate secondary sound and video buffers at boot."); + if(bb.sec_sv_pages > 0) sb.AppendLine("Allocate secondary sound buffer at boot."); + else if(bb.sec_sv_pages < 0) sb.AppendLine("Allocate secondary sound and video buffers at boot."); - sb.AppendFormat("System filename: {0}", BB.system_name).AppendLine(); - sb.AppendFormat("Finder filename: {0}", BB.finder_name).AppendLine(); - sb.AppendFormat("Debugger filename: {0}", BB.debug_name).AppendLine(); - sb.AppendFormat("Disassembler filename: {0}", BB.disasm_name).AppendLine(); - sb.AppendFormat("Startup screen filename: {0}", BB.stupscr_name).AppendLine(); - sb.AppendFormat("First program to execute at boot: {0}", BB.bootup_name).AppendLine(); - sb.AppendFormat("Clipboard filename: {0}", BB.clipbrd_name).AppendLine(); - sb.AppendFormat("Maximum opened files: {0}", BB.max_files * 4).AppendLine(); - sb.AppendFormat("Event queue size: {0}", BB.queue_size).AppendLine(); - sb.AppendFormat("Heap size with 128KiB of RAM: {0} bytes", BB.heap_128k).AppendLine(); - sb.AppendFormat("Heap size with 256KiB of RAM: {0} bytes", BB.heap_256k).AppendLine(); - sb.AppendFormat("Heap size with 512KiB of RAM or more: {0} bytes", BB.heap_512k).AppendLine(); + sb.AppendFormat("System filename: {0}", bb.system_name).AppendLine(); + sb.AppendFormat("Finder filename: {0}", bb.finder_name).AppendLine(); + sb.AppendFormat("Debugger filename: {0}", bb.debug_name).AppendLine(); + sb.AppendFormat("Disassembler filename: {0}", bb.disasm_name).AppendLine(); + sb.AppendFormat("Startup screen filename: {0}", bb.stupscr_name).AppendLine(); + sb.AppendFormat("First program to execute at boot: {0}", bb.bootup_name).AppendLine(); + sb.AppendFormat("Clipboard filename: {0}", bb.clipbrd_name).AppendLine(); + sb.AppendFormat("Maximum opened files: {0}", bb.max_files * 4).AppendLine(); + sb.AppendFormat("Event queue size: {0}", bb.queue_size).AppendLine(); + sb.AppendFormat("Heap size with 128KiB of RAM: {0} bytes", bb.heap_128k).AppendLine(); + sb.AppendFormat("Heap size with 256KiB of RAM: {0} bytes", bb.heap_256k).AppendLine(); + sb.AppendFormat("Heap size with 512KiB of RAM or more: {0} bytes", bb.heap_512k).AppendLine(); } } else sb.AppendLine("Volume is not bootable."); @@ -178,25 +176,25 @@ namespace DiscImageChef.Filesystems.AppleMFS information = sb.ToString(); XmlFsType = new FileSystemType(); - if(MDB.drLsBkUp > 0) + if(mdb.drLsBkUp > 0) { - XmlFsType.BackupDate = DateHandlers.MacToDateTime(MDB.drLsBkUp); + XmlFsType.BackupDate = DateHandlers.MacToDateTime(mdb.drLsBkUp); XmlFsType.BackupDateSpecified = true; } - XmlFsType.Bootable = BB.signature == MFSBB_MAGIC; - XmlFsType.Clusters = MDB.drNmAlBlks; - XmlFsType.ClusterSize = (int)MDB.drAlBlkSiz; - if(MDB.drCrDate > 0) + XmlFsType.Bootable = bb.signature == MFSBB_MAGIC; + XmlFsType.Clusters = mdb.drNmAlBlks; + XmlFsType.ClusterSize = (int)mdb.drAlBlkSiz; + if(mdb.drCrDate > 0) { - XmlFsType.CreationDate = DateHandlers.MacToDateTime(MDB.drCrDate); + XmlFsType.CreationDate = DateHandlers.MacToDateTime(mdb.drCrDate); XmlFsType.CreationDateSpecified = true; } - XmlFsType.Files = MDB.drNmFls; + XmlFsType.Files = mdb.drNmFls; XmlFsType.FilesSpecified = true; - XmlFsType.FreeClusters = MDB.drFreeBks; + XmlFsType.FreeClusters = mdb.drFreeBks; XmlFsType.FreeClustersSpecified = true; XmlFsType.Type = "MFS"; - XmlFsType.VolumeName = MDB.drVN; + XmlFsType.VolumeName = mdb.drVN; } } } \ No newline at end of file diff --git a/DiscImageChef.Filesystems/AtheOS.cs b/DiscImageChef.Filesystems/AtheOS.cs index bc1f2340..47a37428 100644 --- a/DiscImageChef.Filesystems/AtheOS.cs +++ b/DiscImageChef.Filesystems/AtheOS.cs @@ -65,13 +65,11 @@ namespace DiscImageChef.Filesystems if(sector + partition.Start >= partition.End) return false; - uint magic; - byte[] tmp = imagePlugin.ReadSectors(sector + partition.Start, run); byte[] sbSector = new byte[AFS_SUPERBLOCK_SIZE]; Array.Copy(tmp, offset, sbSector, 0, AFS_SUPERBLOCK_SIZE); - magic = BitConverter.ToUInt32(sbSector, 0x20); + uint magic = BitConverter.ToUInt32(sbSector, 0x20); return magic == AFS_MAGIC1; } diff --git a/DiscImageChef.Filesystems/BFS.cs b/DiscImageChef.Filesystems/BFS.cs index 0ed706d0..5022882b 100644 --- a/DiscImageChef.Filesystems/BFS.cs +++ b/DiscImageChef.Filesystems/BFS.cs @@ -63,13 +63,10 @@ namespace DiscImageChef.Filesystems { if(2 + partition.Start >= partition.End) return false; - uint magic; - uint magicBe; - byte[] sbSector = imagePlugin.ReadSector(0 + partition.Start); - magic = BitConverter.ToUInt32(sbSector, 0x20); - magicBe = BigEndianBitConverter.ToUInt32(sbSector, 0x20); + uint magic = BitConverter.ToUInt32(sbSector, 0x20); + uint magicBe = BigEndianBitConverter.ToUInt32(sbSector, 0x20); if(magic == BEFS_MAGIC1 || magicBe == BEFS_MAGIC1) return true; diff --git a/DiscImageChef.Filesystems/BTRFS.cs b/DiscImageChef.Filesystems/BTRFS.cs index a68982f8..8cb38069 100644 --- a/DiscImageChef.Filesystems/BTRFS.cs +++ b/DiscImageChef.Filesystems/BTRFS.cs @@ -45,7 +45,7 @@ namespace DiscImageChef.Filesystems /// /// BTRFS magic "_BHRfS_M" /// - const ulong btrfsMagic = 0x4D5F53665248425F; + const ulong BTRFS_MAGIC = 0x4D5F53665248425F; public FileSystemType XmlFsType { get; private set; } public Encoding Encoding { get; private set; } @@ -77,7 +77,7 @@ namespace DiscImageChef.Filesystems DicConsole.DebugWriteLine("BTRFS Plugin", "partition.PartitionStartSector = {0}", partition.Start); DicConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.magic = 0x{0:X16}", btrfsSb.magic); - return btrfsSb.magic == btrfsMagic; + return btrfsSb.magic == BTRFS_MAGIC; } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, diff --git a/DiscImageChef.Filesystems/CBM.cs b/DiscImageChef.Filesystems/CBM.cs index 109911ab..cd442b68 100644 --- a/DiscImageChef.Filesystems/CBM.cs +++ b/DiscImageChef.Filesystems/CBM.cs @@ -74,10 +74,10 @@ namespace DiscImageChef.Filesystems else { sector = imagePlugin.ReadSector(357); - CommodoreBAM cbmBam = new CommodoreBAM(); + CommodoreBam cbmBam = new CommodoreBam(); IntPtr cbmBamPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cbmBam)); Marshal.Copy(sector, 0, cbmBamPtr, Marshal.SizeOf(cbmBam)); - cbmBam = (CommodoreBAM)Marshal.PtrToStructure(cbmBamPtr, typeof(CommodoreBAM)); + cbmBam = (CommodoreBam)Marshal.PtrToStructure(cbmBamPtr, typeof(CommodoreBam)); Marshal.FreeHGlobal(cbmBamPtr); if(cbmBam.dosVersion == 0x41 && (cbmBam.doubleSided == 0x00 || cbmBam.doubleSided == 0x80) && @@ -132,10 +132,10 @@ namespace DiscImageChef.Filesystems else { sector = imagePlugin.ReadSector(357); - CommodoreBAM cbmBam = new CommodoreBAM(); + CommodoreBam cbmBam = new CommodoreBam(); IntPtr cbmBamPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cbmBam)); Marshal.Copy(sector, 0, cbmBamPtr, Marshal.SizeOf(cbmBam)); - cbmBam = (CommodoreBAM)Marshal.PtrToStructure(cbmBamPtr, typeof(CommodoreBAM)); + cbmBam = (CommodoreBam)Marshal.PtrToStructure(cbmBamPtr, typeof(CommodoreBam)); Marshal.FreeHGlobal(cbmBamPtr); sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmBam.directoryTrack, @@ -157,7 +157,7 @@ namespace DiscImageChef.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CommodoreBAM + struct CommodoreBam { /// /// Track where directory starts diff --git a/DiscImageChef.Filesystems/CPM/Info.cs b/DiscImageChef.Filesystems/CPM/Info.cs index 7e2342ae..61728e76 100644 --- a/DiscImageChef.Filesystems/CPM/Info.cs +++ b/DiscImageChef.Filesystems/CPM/Info.cs @@ -172,19 +172,17 @@ namespace DiscImageChef.Filesystems.CPM sector = imagePlugin.ReadSector(0 + partition.Start); int amsSbOffset = 0; - uint sig1, sig2, sig3; - sig1 = BitConverter.ToUInt32(sector, 0x2B); - sig2 = BitConverter.ToUInt32(sector, 0x33) & 0x00FFFFFF; - sig3 = BitConverter.ToUInt32(sector, 0x7C); + uint sig1 = BitConverter.ToUInt32(sector, 0x2B); + uint sig2 = BitConverter.ToUInt32(sector, 0x33) & 0x00FFFFFF; + uint sig3 = BitConverter.ToUInt32(sector, 0x7C); // PCW16 extended boot record if(sig1 == 0x4D2F5043 && sig2 == 0x004B5344 && sig3 == sig1) amsSbOffset = 0x80; // Read the superblock - AmstradSuperBlock amsSb; IntPtr amsPtr = Marshal.AllocHGlobal(16); Marshal.Copy(sector, amsSbOffset, amsPtr, 16); - amsSb = (AmstradSuperBlock)Marshal.PtrToStructure(amsPtr, typeof(AmstradSuperBlock)); + AmstradSuperBlock amsSb = (AmstradSuperBlock)Marshal.PtrToStructure(amsPtr, typeof(AmstradSuperBlock)); Marshal.FreeHGlobal(amsPtr); // Check that format byte and sidedness indicate the same number of sizes diff --git a/DiscImageChef.Filesystems/ECMA67.cs b/DiscImageChef.Filesystems/ECMA67.cs index f493d3ea..ad990893 100644 --- a/DiscImageChef.Filesystems/ECMA67.cs +++ b/DiscImageChef.Filesystems/ECMA67.cs @@ -42,7 +42,7 @@ namespace DiscImageChef.Filesystems { public class ECMA67 : IFilesystem { - readonly byte[] ECMA67_Magic = {0x56, 0x4F, 0x4C}; + readonly byte[] ecma67_magic = {0x56, 0x4F, 0x4C}; public Encoding Encoding { get; private set; } public string Name => "ECMA-67"; @@ -65,7 +65,7 @@ namespace DiscImageChef.Filesystems vol = (VolumeLabel)Marshal.PtrToStructure(volPtr, typeof(VolumeLabel)); Marshal.FreeHGlobal(volPtr); - return ECMA67_Magic.SequenceEqual(vol.labelIdentifier) && vol.labelNumber == 1 && vol.recordLength == 0x31; + return ecma67_magic.SequenceEqual(vol.labelIdentifier) && vol.labelNumber == 1 && vol.recordLength == 0x31; } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, diff --git a/DiscImageChef.Filesystems/FAT.cs b/DiscImageChef.Filesystems/FAT.cs index 8ea7cd3c..58e902a4 100644 --- a/DiscImageChef.Filesystems/FAT.cs +++ b/DiscImageChef.Filesystems/FAT.cs @@ -307,12 +307,10 @@ namespace DiscImageChef.Filesystems // HPFS if(16 + partition.Start <= partition.End) { - uint hpfsMagic1, hpfsMagic2; - byte[] hpfsSbSector = imagePlugin.ReadSector(16 + partition.Start); // Seek to superblock, on logical sector 16 - hpfsMagic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000); - hpfsMagic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004); + uint hpfsMagic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000); + uint hpfsMagic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004); if(hpfsMagic1 == 0xF995E849 && hpfsMagic2 == 0xFA53E9C5) return false; } diff --git a/DiscImageChef.Filesystems/FATX.cs b/DiscImageChef.Filesystems/FATX.cs index e0b4e47c..a1f442b7 100644 --- a/DiscImageChef.Filesystems/FATX.cs +++ b/DiscImageChef.Filesystems/FATX.cs @@ -52,10 +52,9 @@ namespace DiscImageChef.Filesystems { if(imagePlugin.Info.SectorSize < 512) return false; - FATX_Superblock fatxSb; byte[] sector = imagePlugin.ReadSector(partition.Start); - fatxSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); + FATX_Superblock fatxSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); return fatxSb.magic == FATX_MAGIC; } @@ -67,11 +66,9 @@ namespace DiscImageChef.Filesystems information = ""; if(imagePlugin.Info.SectorSize < 512) return; - FATX_Superblock fatxSb; - byte[] sector = imagePlugin.ReadSector(partition.Start); - fatxSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); + FATX_Superblock fatxSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); if(fatxSb.magic != FATX_MAGIC) return; diff --git a/DiscImageChef.Filesystems/Fossil.cs b/DiscImageChef.Filesystems/Fossil.cs index 27290ca0..722c0b69 100644 --- a/DiscImageChef.Filesystems/Fossil.cs +++ b/DiscImageChef.Filesystems/Fossil.cs @@ -56,12 +56,10 @@ namespace DiscImageChef.Filesystems { ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize; - FossilHeader hdr; - if(partition.Start + hdrSector > imagePlugin.Info.Sectors) return false; byte[] sector = imagePlugin.ReadSector(partition.Start + hdrSector); - hdr = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); + FossilHeader hdr = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); DicConsole.DebugWriteLine("Fossil plugin", "magic at 0x{0:X8} (expected 0x{1:X8})", hdr.magic, FOSSIL_HDR_MAGIC); @@ -79,10 +77,8 @@ namespace DiscImageChef.Filesystems ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize; - FossilHeader hdr; - byte[] sector = imagePlugin.ReadSector(partition.Start + hdrSector); - hdr = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); + FossilHeader hdr = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); DicConsole.DebugWriteLine("Fossil plugin", "magic at 0x{0:X8} (expected 0x{1:X8})", hdr.magic, FOSSIL_HDR_MAGIC); diff --git a/DiscImageChef.Filesystems/HAMMER.cs b/DiscImageChef.Filesystems/HAMMER.cs index a832d4e7..9acba33c 100644 --- a/DiscImageChef.Filesystems/HAMMER.cs +++ b/DiscImageChef.Filesystems/HAMMER.cs @@ -65,11 +65,9 @@ namespace DiscImageChef.Filesystems if(run + partition.Start >= partition.End) return false; - ulong magic; - byte[] sbSector = imagePlugin.ReadSectors(partition.Start, run); - magic = BitConverter.ToUInt64(sbSector, 0); + ulong magic = BitConverter.ToUInt64(sbSector, 0); return magic == HAMMER_FSBUF_VOLUME || magic == HAMMER_FSBUF_VOLUME_REV; } @@ -88,11 +86,9 @@ namespace DiscImageChef.Filesystems if(HAMMER_VOLHDR_SIZE % imagePlugin.Info.SectorSize > 0) run++; - ulong magic; - byte[] sbSector = imagePlugin.ReadSectors(partition.Start, run); - magic = BitConverter.ToUInt64(sbSector, 0); + ulong magic = BitConverter.ToUInt64(sbSector, 0); if(magic == HAMMER_FSBUF_VOLUME) { diff --git a/DiscImageChef.Filesystems/HPFS.cs b/DiscImageChef.Filesystems/HPFS.cs index c2322f25..fabfd2ed 100644 --- a/DiscImageChef.Filesystems/HPFS.cs +++ b/DiscImageChef.Filesystems/HPFS.cs @@ -77,18 +77,18 @@ namespace DiscImageChef.Filesystems IntPtr bpbPtr = Marshal.AllocHGlobal(512); Marshal.Copy(hpfsBpbSector, 0, bpbPtr, 512); - HPFS_BIOSParameterBlock hpfsBpb = - (HPFS_BIOSParameterBlock)Marshal.PtrToStructure(bpbPtr, typeof(HPFS_BIOSParameterBlock)); + HpfsBiosParameterBlock hpfsBpb = + (HpfsBiosParameterBlock)Marshal.PtrToStructure(bpbPtr, typeof(HpfsBiosParameterBlock)); Marshal.FreeHGlobal(bpbPtr); IntPtr sbPtr = Marshal.AllocHGlobal(512); Marshal.Copy(hpfsSbSector, 0, sbPtr, 512); - HPFS_SuperBlock hpfsSb = (HPFS_SuperBlock)Marshal.PtrToStructure(sbPtr, typeof(HPFS_SuperBlock)); + HpfsSuperBlock hpfsSb = (HpfsSuperBlock)Marshal.PtrToStructure(sbPtr, typeof(HpfsSuperBlock)); Marshal.FreeHGlobal(sbPtr); IntPtr spPtr = Marshal.AllocHGlobal(512); Marshal.Copy(hpfsSpSector, 0, spPtr, 512); - HPFS_SpareBlock hpfsSp = (HPFS_SpareBlock)Marshal.PtrToStructure(spPtr, typeof(HPFS_SpareBlock)); + HpfsSpareBlock hpfsSp = (HpfsSpareBlock)Marshal.PtrToStructure(spPtr, typeof(HpfsSpareBlock)); Marshal.FreeHGlobal(spPtr); if(StringHandlers.CToString(hpfsBpb.fs_type) != "HPFS " || hpfsSb.magic1 != 0xF995E849 || @@ -206,7 +206,7 @@ namespace DiscImageChef.Filesystems /// BIOS Parameter Block, at sector 0 /// [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HPFS_BIOSParameterBlock + struct HpfsBiosParameterBlock { /// 0x000, Jump to boot code [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] @@ -263,7 +263,7 @@ namespace DiscImageChef.Filesystems /// HPFS superblock at sector 16 /// [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HPFS_SuperBlock + struct HpfsSuperBlock { /// 0x000, 0xF995E849 public uint magic1; @@ -317,7 +317,7 @@ namespace DiscImageChef.Filesystems /// HPFS spareblock at sector 17 /// [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HPFS_SpareBlock + struct HpfsSpareBlock { /// 0x000, 0xF9911849 public uint magic1; diff --git a/DiscImageChef.Filesystems/JFS.cs b/DiscImageChef.Filesystems/JFS.cs index 73b35c07..072a2d3c 100644 --- a/DiscImageChef.Filesystems/JFS.cs +++ b/DiscImageChef.Filesystems/JFS.cs @@ -57,10 +57,10 @@ namespace DiscImageChef.Filesystems byte[] sector = imagePlugin.ReadSector(partition.Start + bootSectors); if(sector.Length < 512) return false; - JFS_SuperBlock jfsSb = new JFS_SuperBlock(); + JfsSuperBlock jfsSb = new JfsSuperBlock(); IntPtr sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(jfsSb)); Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(jfsSb)); - jfsSb = (JFS_SuperBlock)Marshal.PtrToStructure(sbPtr, typeof(JFS_SuperBlock)); + jfsSb = (JfsSuperBlock)Marshal.PtrToStructure(sbPtr, typeof(JfsSuperBlock)); Marshal.FreeHGlobal(sbPtr); return jfsSb.s_magic == JFS_MAGIC; @@ -76,10 +76,10 @@ namespace DiscImageChef.Filesystems byte[] sector = imagePlugin.ReadSector(partition.Start + bootSectors); if(sector.Length < 512) return; - JFS_SuperBlock jfsSb = new JFS_SuperBlock(); + JfsSuperBlock jfsSb = new JfsSuperBlock(); IntPtr sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(jfsSb)); Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(jfsSb)); - jfsSb = (JFS_SuperBlock)Marshal.PtrToStructure(sbPtr, typeof(JFS_SuperBlock)); + jfsSb = (JfsSuperBlock)Marshal.PtrToStructure(sbPtr, typeof(JfsSuperBlock)); Marshal.FreeHGlobal(sbPtr); sb.AppendLine("JFS filesystem"); @@ -87,31 +87,31 @@ namespace DiscImageChef.Filesystems sb.AppendFormat("{0} blocks of {1} bytes", jfsSb.s_size, jfsSb.s_bsize).AppendLine(); sb.AppendFormat("{0} blocks per allocation group", jfsSb.s_agsize).AppendLine(); - if(jfsSb.s_flags.HasFlag(JFS_Flags.Unicode)) sb.AppendLine("Volume uses Unicode for directory entries"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.RemountRO)) sb.AppendLine("Volume remounts read-only on error"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.Continue)) sb.AppendLine("Volume continues on error"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.Panic)) sb.AppendLine("Volume panics on error"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.UserQuota)) sb.AppendLine("Volume has user quotas enabled"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.GroupQuota)) sb.AppendLine("Volume has group quotas enabled"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.NoJournal)) sb.AppendLine("Volume is not using any journal"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.Discard)) + if(jfsSb.s_flags.HasFlag(JfsFlags.Unicode)) sb.AppendLine("Volume uses Unicode for directory entries"); + if(jfsSb.s_flags.HasFlag(JfsFlags.RemountRO)) sb.AppendLine("Volume remounts read-only on error"); + if(jfsSb.s_flags.HasFlag(JfsFlags.Continue)) sb.AppendLine("Volume continues on error"); + if(jfsSb.s_flags.HasFlag(JfsFlags.Panic)) sb.AppendLine("Volume panics on error"); + if(jfsSb.s_flags.HasFlag(JfsFlags.UserQuota)) sb.AppendLine("Volume has user quotas enabled"); + if(jfsSb.s_flags.HasFlag(JfsFlags.GroupQuota)) sb.AppendLine("Volume has group quotas enabled"); + if(jfsSb.s_flags.HasFlag(JfsFlags.NoJournal)) sb.AppendLine("Volume is not using any journal"); + if(jfsSb.s_flags.HasFlag(JfsFlags.Discard)) sb.AppendLine("Volume sends TRIM/UNMAP commands to underlying device"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.GroupCommit)) sb.AppendLine("Volume commits in groups of 1"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.LazyCommit)) sb.AppendLine("Volume commits lazy"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.Temporary)) sb.AppendLine("Volume does not commit to log"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.InlineLog)) sb.AppendLine("Volume has log withing itself"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.InlineMoving)) + if(jfsSb.s_flags.HasFlag(JfsFlags.GroupCommit)) sb.AppendLine("Volume commits in groups of 1"); + if(jfsSb.s_flags.HasFlag(JfsFlags.LazyCommit)) sb.AppendLine("Volume commits lazy"); + if(jfsSb.s_flags.HasFlag(JfsFlags.Temporary)) sb.AppendLine("Volume does not commit to log"); + if(jfsSb.s_flags.HasFlag(JfsFlags.InlineLog)) sb.AppendLine("Volume has log withing itself"); + if(jfsSb.s_flags.HasFlag(JfsFlags.InlineMoving)) sb.AppendLine("Volume has log withing itself and is moving it out"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.BadSAIT)) sb.AppendLine("Volume has bad current secondary ait"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.Sparse)) sb.AppendLine("Volume supports sparse files"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.DASDEnabled)) sb.AppendLine("Volume has DASD limits enabled"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.DASDPrime)) sb.AppendLine("Volume primes DASD on boot"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.SwapBytes)) sb.AppendLine("Volume is in a big-endian system"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.DirIndex)) sb.AppendLine("Volume has presistent indexes"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.Linux)) sb.AppendLine("Volume supports Linux"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.DFS)) sb.AppendLine("Volume supports DCE DFS LFS"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.OS2)) sb.AppendLine("Volume supports OS/2, and is case insensitive"); - if(jfsSb.s_flags.HasFlag(JFS_Flags.AIX)) sb.AppendLine("Volume supports AIX"); + if(jfsSb.s_flags.HasFlag(JfsFlags.BadSAIT)) sb.AppendLine("Volume has bad current secondary ait"); + if(jfsSb.s_flags.HasFlag(JfsFlags.Sparse)) sb.AppendLine("Volume supports sparse files"); + if(jfsSb.s_flags.HasFlag(JfsFlags.DASDEnabled)) sb.AppendLine("Volume has DASD limits enabled"); + if(jfsSb.s_flags.HasFlag(JfsFlags.DASDPrime)) sb.AppendLine("Volume primes DASD on boot"); + if(jfsSb.s_flags.HasFlag(JfsFlags.SwapBytes)) sb.AppendLine("Volume is in a big-endian system"); + if(jfsSb.s_flags.HasFlag(JfsFlags.DirIndex)) sb.AppendLine("Volume has presistent indexes"); + if(jfsSb.s_flags.HasFlag(JfsFlags.Linux)) sb.AppendLine("Volume supports Linux"); + if(jfsSb.s_flags.HasFlag(JfsFlags.DFS)) sb.AppendLine("Volume supports DCE DFS LFS"); + if(jfsSb.s_flags.HasFlag(JfsFlags.OS2)) sb.AppendLine("Volume supports OS/2, and is case insensitive"); + if(jfsSb.s_flags.HasFlag(JfsFlags.AIX)) sb.AppendLine("Volume supports AIX"); if(jfsSb.s_state != 0) sb.AppendLine("Volume is dirty"); sb.AppendFormat("Volume was last updated on {0}", DateHandlers.UnixUnsignedToDateTime(jfsSb.s_time.tv_sec, jfsSb.s_time.tv_nsec)) @@ -138,7 +138,7 @@ namespace DiscImageChef.Filesystems } [Flags] - enum JFS_Flags : uint + enum JfsFlags : uint { Unicode = 0x00000001, RemountRO = 0x00000002, @@ -166,7 +166,7 @@ namespace DiscImageChef.Filesystems } [Flags] - enum JFS_State : uint + enum JfsState : uint { Clean = 0, Mounted = 1, @@ -176,7 +176,7 @@ namespace DiscImageChef.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct JFS_Extent + struct JfsExtent { /// /// Leftmost 24 bits are extent length, rest 8 bits are most significant for @@ -186,14 +186,14 @@ namespace DiscImageChef.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct JFS_TimeStruct + struct JfsTimeStruct { public uint tv_sec; public uint tv_nsec; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct JFS_SuperBlock + struct JfsSuperBlock { public uint s_magic; public uint s_version; @@ -205,22 +205,22 @@ namespace DiscImageChef.Filesystems public ushort s_l1pbsize; public ushort pad; public uint s_agsize; - public JFS_Flags s_flags; - public JFS_State s_state; + public JfsFlags s_flags; + public JfsState s_state; public uint s_compress; - public JFS_Extent s_ait2; - public JFS_Extent s_aim2; + public JfsExtent s_ait2; + public JfsExtent s_aim2; public uint s_logdev; public uint s_logserial; - public JFS_Extent s_logpxd; - public JFS_Extent s_fsckpxd; - public JFS_TimeStruct s_time; + public JfsExtent s_logpxd; + public JfsExtent s_fsckpxd; + public JfsTimeStruct s_time; public uint s_fsckloglen; public sbyte s_fscklog; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] public byte[] s_fpack; public ulong s_xsize; - public JFS_Extent s_xfsckpxd; - public JFS_Extent s_xlogpxd; + public JfsExtent s_xfsckpxd; + public JfsExtent s_xlogpxd; public Guid s_uuid; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] s_label; public Guid s_loguuid; diff --git a/DiscImageChef.Filesystems/LIF.cs b/DiscImageChef.Filesystems/LIF.cs index a0b7fb07..5b5a9718 100644 --- a/DiscImageChef.Filesystems/LIF.cs +++ b/DiscImageChef.Filesystems/LIF.cs @@ -55,7 +55,7 @@ namespace DiscImageChef.Filesystems if(imagePlugin.Info.SectorSize < 256) return false; byte[] sector = imagePlugin.ReadSector(partition.Start); - LIF_SystemBlock lifSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); + LifSystemBlock lifSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); DicConsole.DebugWriteLine("LIF plugin", "magic 0x{0:X8} (expected 0x{1:X8})", lifSb.magic, LIF_MAGIC); return lifSb.magic == LIF_MAGIC; @@ -70,7 +70,7 @@ namespace DiscImageChef.Filesystems if(imagePlugin.Info.SectorSize < 256) return; byte[] sector = imagePlugin.ReadSector(partition.Start); - LIF_SystemBlock lifSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); + LifSystemBlock lifSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); if(lifSb.magic != LIF_MAGIC) return; @@ -102,7 +102,7 @@ namespace DiscImageChef.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct LIF_SystemBlock + struct LifSystemBlock { public ushort magic; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] volumeLabel; diff --git a/DiscImageChef.Filesystems/LisaFS/Info.cs b/DiscImageChef.Filesystems/LisaFS/Info.cs index 155de6a4..f2fceead 100644 --- a/DiscImageChef.Filesystems/LisaFS/Info.cs +++ b/DiscImageChef.Filesystems/LisaFS/Info.cs @@ -154,7 +154,6 @@ namespace DiscImageChef.Filesystems.LisaFS byte[] sector = imagePlugin.ReadSector((ulong)i); MDDF infoMddf = new MDDF(); byte[] pString = new byte[33]; - uint lisaTime; infoMddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00); infoMddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); @@ -168,7 +167,7 @@ namespace DiscImageChef.Filesystems.LisaFS infoMddf.unknown2 = sector[0x4F]; infoMddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50); infoMddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54); - lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58); + uint lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58); infoMddf.dtvc = DateHandlers.LisaToDateTime(lisaTime); lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x5C); infoMddf.dtcc = DateHandlers.LisaToDateTime(lisaTime); diff --git a/DiscImageChef.Filesystems/LisaFS/Super.cs b/DiscImageChef.Filesystems/LisaFS/Super.cs index 7ed7fea2..659ea5f5 100644 --- a/DiscImageChef.Filesystems/LisaFS/Super.cs +++ b/DiscImageChef.Filesystems/LisaFS/Super.cs @@ -95,7 +95,6 @@ namespace DiscImageChef.Filesystems.LisaFS byte[] sector = device.ReadSector(i); mddf = new MDDF(); byte[] pString = new byte[33]; - uint lisaTime; mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00); mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); @@ -110,7 +109,7 @@ namespace DiscImageChef.Filesystems.LisaFS mddf.unknown2 = sector[0x4F]; mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50); mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54); - lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58); + uint lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58); mddf.dtvc = DateHandlers.LisaToDateTime(lisaTime); lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x5C); mddf.dtcc = DateHandlers.LisaToDateTime(lisaTime); diff --git a/DiscImageChef.Filesystems/Locus.cs b/DiscImageChef.Filesystems/Locus.cs index 654960dc..6c5d0361 100644 --- a/DiscImageChef.Filesystems/Locus.cs +++ b/DiscImageChef.Filesystems/Locus.cs @@ -62,10 +62,10 @@ namespace DiscImageChef.Filesystems const int OLDNICINOD = 700; const int OLDNICFREE = 500; - const uint Locus_Magic = 0xFFEEDDCD; - const uint Locus_Cigam = 0xCDDDEEFF; - const uint Locus_OldMagic = 0xFFEEDDCC; - const uint Locus_OldCigam = 0xCCDDEEFF; + const uint LOCUS_MAGIC = 0xFFEEDDCD; + const uint LOCUS_CIGAM = 0xCDDDEEFF; + const uint LOCUS_MAGIC_OLD = 0xFFEEDDCC; + const uint LOCUS_CIGAM_OLD = 0xCCDDEEFF; public FileSystemType XmlFsType { get; private set; } public Encoding Encoding { get; private set; } @@ -78,25 +78,25 @@ namespace DiscImageChef.Filesystems for(ulong location = 0; location <= 8; location++) { - Locus_Superblock LocusSb = new Locus_Superblock(); + Locus_Superblock locusSb = new Locus_Superblock(); - uint sbSize = (uint)(Marshal.SizeOf(LocusSb) / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf(LocusSb) % imagePlugin.Info.SectorSize != 0) sbSize++; + uint sbSize = (uint)(Marshal.SizeOf(locusSb) / imagePlugin.Info.SectorSize); + if(Marshal.SizeOf(locusSb) % imagePlugin.Info.SectorSize != 0) sbSize++; if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) break; byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); - if(sector.Length < Marshal.SizeOf(LocusSb)) return false; + if(sector.Length < Marshal.SizeOf(locusSb)) return false; - IntPtr sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(LocusSb)); - Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(LocusSb)); - LocusSb = (Locus_Superblock)Marshal.PtrToStructure(sbPtr, typeof(Locus_Superblock)); + IntPtr sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(locusSb)); + Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(locusSb)); + locusSb = (Locus_Superblock)Marshal.PtrToStructure(sbPtr, typeof(Locus_Superblock)); Marshal.FreeHGlobal(sbPtr); - DicConsole.DebugWriteLine("Locus plugin", "magic at {1} = 0x{0:X8}", LocusSb.s_magic, location); + DicConsole.DebugWriteLine("Locus plugin", "magic at {1} = 0x{0:X8}", locusSb.s_magic, location); - if(LocusSb.s_magic == Locus_Magic || LocusSb.s_magic == Locus_Cigam || - LocusSb.s_magic == Locus_OldMagic || LocusSb.s_magic == Locus_OldCigam) return true; + if(locusSb.s_magic == LOCUS_MAGIC || locusSb.s_magic == LOCUS_CIGAM || + locusSb.s_magic == LOCUS_MAGIC_OLD || locusSb.s_magic == LOCUS_CIGAM_OLD) return true; } return false; @@ -109,94 +109,94 @@ namespace DiscImageChef.Filesystems information = ""; if(imagePlugin.Info.SectorSize < 512) return; - Locus_Superblock LocusSb = new Locus_Superblock(); + Locus_Superblock locusSb = new Locus_Superblock(); byte[] sector = null; for(ulong location = 0; location <= 8; location++) { - uint sbSize = (uint)(Marshal.SizeOf(LocusSb) / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf(LocusSb) % imagePlugin.Info.SectorSize != 0) sbSize++; + uint sbSize = (uint)(Marshal.SizeOf(locusSb) / imagePlugin.Info.SectorSize); + if(Marshal.SizeOf(locusSb) % imagePlugin.Info.SectorSize != 0) sbSize++; sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); - if(sector.Length < Marshal.SizeOf(LocusSb)) return; + if(sector.Length < Marshal.SizeOf(locusSb)) return; - IntPtr sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(LocusSb)); - Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(LocusSb)); - LocusSb = (Locus_Superblock)Marshal.PtrToStructure(sbPtr, typeof(Locus_Superblock)); + IntPtr sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(locusSb)); + Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(locusSb)); + locusSb = (Locus_Superblock)Marshal.PtrToStructure(sbPtr, typeof(Locus_Superblock)); Marshal.FreeHGlobal(sbPtr); - if(LocusSb.s_magic == Locus_Magic || LocusSb.s_magic == Locus_Cigam || - LocusSb.s_magic == Locus_OldMagic || LocusSb.s_magic == Locus_OldCigam) break; + if(locusSb.s_magic == LOCUS_MAGIC || locusSb.s_magic == LOCUS_CIGAM || + locusSb.s_magic == LOCUS_MAGIC_OLD || locusSb.s_magic == LOCUS_CIGAM_OLD) break; } // We don't care about old version for information - if(LocusSb.s_magic != Locus_Magic && LocusSb.s_magic != Locus_Cigam && LocusSb.s_magic != Locus_OldMagic && - LocusSb.s_magic != Locus_OldCigam) return; + if(locusSb.s_magic != LOCUS_MAGIC && locusSb.s_magic != LOCUS_CIGAM && locusSb.s_magic != LOCUS_MAGIC_OLD && + locusSb.s_magic != LOCUS_CIGAM_OLD) return; // Numerical arrays are not important for information so no need to swap them - if(LocusSb.s_magic == Locus_Cigam || LocusSb.s_magic == Locus_OldCigam) + if(locusSb.s_magic == LOCUS_CIGAM || locusSb.s_magic == LOCUS_CIGAM_OLD) { - LocusSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); - LocusSb.s_flags = (LocusFlags)Swapping.Swap((ushort)LocusSb.s_flags); + locusSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); + locusSb.s_flags = (LocusFlags)Swapping.Swap((ushort)locusSb.s_flags); } StringBuilder sb = new StringBuilder(); - sb.AppendLine(LocusSb.s_magic == Locus_OldMagic ? "Locus filesystem (old)" : "Locus filesystem"); + sb.AppendLine(locusSb.s_magic == LOCUS_MAGIC_OLD ? "Locus filesystem (old)" : "Locus filesystem"); - int blockSize = LocusSb.s_version == LocusVersion.SB_SB4096 ? 4096 : 1024; + int blockSize = locusSb.s_version == LocusVersion.SB_SB4096 ? 4096 : 1024; - string s_fsmnt = StringHandlers.CToString(LocusSb.s_fsmnt, Encoding); - string s_fpack = StringHandlers.CToString(LocusSb.s_fpack, Encoding); + string s_fsmnt = StringHandlers.CToString(locusSb.s_fsmnt, Encoding); + string s_fpack = StringHandlers.CToString(locusSb.s_fpack, Encoding); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_magic = 0x{0:X8}", LocusSb.s_magic); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_gfs = {0}", LocusSb.s_gfs); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_fsize = {0}", LocusSb.s_fsize); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_lwm = {0}", LocusSb.s_lwm); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_hwm = {0}", LocusSb.s_hwm); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_llst = {0}", LocusSb.s_llst); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_fstore = {0}", LocusSb.s_fstore); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_time = {0}", LocusSb.s_time); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_tfree = {0}", LocusSb.s_tfree); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_isize = {0}", LocusSb.s_isize); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_nfree = {0}", LocusSb.s_nfree); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_flags = {0}", LocusSb.s_flags); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_tinode = {0}", LocusSb.s_tinode); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_lasti = {0}", LocusSb.s_lasti); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_nbehind = {0}", LocusSb.s_nbehind); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_gfspack = {0}", LocusSb.s_gfspack); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_ninode = {0}", LocusSb.s_ninode); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_flock = {0}", LocusSb.s_flock); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_ilock = {0}", LocusSb.s_ilock); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_fmod = {0}", LocusSb.s_fmod); - DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_version = {0}", LocusSb.s_version); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_magic = 0x{0:X8}", locusSb.s_magic); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_gfs = {0}", locusSb.s_gfs); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_fsize = {0}", locusSb.s_fsize); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_lwm = {0}", locusSb.s_lwm); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_hwm = {0}", locusSb.s_hwm); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_llst = {0}", locusSb.s_llst); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_fstore = {0}", locusSb.s_fstore); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_time = {0}", locusSb.s_time); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_tfree = {0}", locusSb.s_tfree); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_isize = {0}", locusSb.s_isize); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_nfree = {0}", locusSb.s_nfree); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_flags = {0}", locusSb.s_flags); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_tinode = {0}", locusSb.s_tinode); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_lasti = {0}", locusSb.s_lasti); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_nbehind = {0}", locusSb.s_nbehind); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_gfspack = {0}", locusSb.s_gfspack); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_ninode = {0}", locusSb.s_ninode); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_flock = {0}", locusSb.s_flock); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_ilock = {0}", locusSb.s_ilock); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_fmod = {0}", locusSb.s_fmod); + DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_version = {0}", locusSb.s_version); - sb.AppendFormat("Superblock last modified on {0}", DateHandlers.UnixToDateTime(LocusSb.s_time)) + sb.AppendFormat("Superblock last modified on {0}", DateHandlers.UnixToDateTime(locusSb.s_time)) .AppendLine(); - sb.AppendFormat("Volume has {0} blocks of {1} bytes each (total {2} bytes)", LocusSb.s_fsize, blockSize, - LocusSb.s_fsize * blockSize).AppendLine(); - sb.AppendFormat("{0} blocks free ({1} bytes)", LocusSb.s_tfree, LocusSb.s_tfree * blockSize).AppendLine(); - sb.AppendFormat("I-node list uses {0} blocks", LocusSb.s_isize).AppendLine(); - sb.AppendFormat("{0} free inodes", LocusSb.s_tinode).AppendLine(); - sb.AppendFormat("Next free inode search will start at inode {0}", LocusSb.s_lasti).AppendLine(); - sb.AppendFormat("There are an estimate of {0} free inodes before next search start", LocusSb.s_nbehind) + sb.AppendFormat("Volume has {0} blocks of {1} bytes each (total {2} bytes)", locusSb.s_fsize, blockSize, + locusSb.s_fsize * blockSize).AppendLine(); + sb.AppendFormat("{0} blocks free ({1} bytes)", locusSb.s_tfree, locusSb.s_tfree * blockSize).AppendLine(); + sb.AppendFormat("I-node list uses {0} blocks", locusSb.s_isize).AppendLine(); + sb.AppendFormat("{0} free inodes", locusSb.s_tinode).AppendLine(); + sb.AppendFormat("Next free inode search will start at inode {0}", locusSb.s_lasti).AppendLine(); + sb.AppendFormat("There are an estimate of {0} free inodes before next search start", locusSb.s_nbehind) .AppendLine(); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_RDONLY)) sb.AppendLine("Read-only volume"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_CLEAN)) sb.AppendLine("Clean volume"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_DIRTY)) sb.AppendLine("Dirty volume"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_RMV)) sb.AppendLine("Removable volume"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_PRIMPACK)) sb.AppendLine("This is the primary pack"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_REPLTYPE)) sb.AppendLine("Replicated volume"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_USER)) sb.AppendLine("User replicated volume"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_BACKBONE)) sb.AppendLine("Backbone volume"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_NFS)) sb.AppendLine("NFS volume"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_BYHAND)) sb.AppendLine("Volume inhibits automatic fsck"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_NOSUID)) sb.AppendLine("Set-uid/set-gid is disabled"); - if(LocusSb.s_flags.HasFlag(LocusFlags.SB_SYNCW)) sb.AppendLine("Volume uses synchronous writes"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_RDONLY)) sb.AppendLine("Read-only volume"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_CLEAN)) sb.AppendLine("Clean volume"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_DIRTY)) sb.AppendLine("Dirty volume"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_RMV)) sb.AppendLine("Removable volume"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_PRIMPACK)) sb.AppendLine("This is the primary pack"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_REPLTYPE)) sb.AppendLine("Replicated volume"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_USER)) sb.AppendLine("User replicated volume"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_BACKBONE)) sb.AppendLine("Backbone volume"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_NFS)) sb.AppendLine("NFS volume"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_BYHAND)) sb.AppendLine("Volume inhibits automatic fsck"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_NOSUID)) sb.AppendLine("Set-uid/set-gid is disabled"); + if(locusSb.s_flags.HasFlag(LocusFlags.SB_SYNCW)) sb.AppendLine("Volume uses synchronous writes"); sb.AppendFormat("Volume label: {0}", s_fsmnt).AppendLine(); sb.AppendFormat("Physical volume name: {0}", s_fpack).AppendLine(); - sb.AppendFormat("Global File System number: {0}", LocusSb.s_gfs).AppendLine(); - sb.AppendFormat("Global File System pack number {0}", LocusSb.s_gfspack).AppendLine(); + sb.AppendFormat("Global File System number: {0}", locusSb.s_gfs).AppendLine(); + sb.AppendFormat("Global File System pack number {0}", locusSb.s_gfspack).AppendLine(); information = sb.ToString(); @@ -204,13 +204,13 @@ namespace DiscImageChef.Filesystems { Type = "Locus filesystem", ClusterSize = blockSize, - Clusters = LocusSb.s_fsize, + Clusters = locusSb.s_fsize, // Sometimes it uses one, or the other. Use the bigger VolumeName = string.IsNullOrEmpty(s_fsmnt) ? s_fpack : s_fsmnt, - ModificationDate = DateHandlers.UnixToDateTime(LocusSb.s_time), + ModificationDate = DateHandlers.UnixToDateTime(locusSb.s_time), ModificationDateSpecified = true, - Dirty = !LocusSb.s_flags.HasFlag(LocusFlags.SB_CLEAN) || LocusSb.s_flags.HasFlag(LocusFlags.SB_DIRTY), - FreeClusters = LocusSb.s_tfree, + Dirty = !locusSb.s_flags.HasFlag(LocusFlags.SB_CLEAN) || locusSb.s_flags.HasFlag(LocusFlags.SB_DIRTY), + FreeClusters = locusSb.s_tfree, FreeClustersSpecified = true }; } diff --git a/DiscImageChef.Filesystems/MicroDOS.cs b/DiscImageChef.Filesystems/MicroDOS.cs index 080c886a..83b10423 100644 --- a/DiscImageChef.Filesystems/MicroDOS.cs +++ b/DiscImageChef.Filesystems/MicroDOS.cs @@ -60,8 +60,8 @@ namespace DiscImageChef.Filesystems byte[] bk0 = imagePlugin.ReadSector(0 + partition.Start); GCHandle handle = GCHandle.Alloc(bk0, GCHandleType.Pinned); - MicroDOSBlock0 block0 = - (MicroDOSBlock0)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(MicroDOSBlock0)); + MicroDosBlock0 block0 = + (MicroDosBlock0)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(MicroDosBlock0)); handle.Free(); return block0.label == MAGIC && block0.mklabel == MAGIC2; @@ -78,8 +78,8 @@ namespace DiscImageChef.Filesystems byte[] bk0 = imagePlugin.ReadSector(0 + partition.Start); GCHandle handle = GCHandle.Alloc(bk0, GCHandleType.Pinned); - MicroDOSBlock0 block0 = - (MicroDOSBlock0)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(MicroDOSBlock0)); + MicroDosBlock0 block0 = + (MicroDosBlock0)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(MicroDosBlock0)); handle.Free(); sb.AppendLine("MicroDOS filesystem"); @@ -105,7 +105,7 @@ namespace DiscImageChef.Filesystems // Followed by directory entries [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct MicroDOSBlock0 + struct MicroDosBlock0 { /// BK starts booting here [MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] bootCode; diff --git a/DiscImageChef.Filesystems/MinixFS.cs b/DiscImageChef.Filesystems/MinixFS.cs index 147b4ff5..56efcaea 100644 --- a/DiscImageChef.Filesystems/MinixFS.cs +++ b/DiscImageChef.Filesystems/MinixFS.cs @@ -82,7 +82,6 @@ namespace DiscImageChef.Filesystems if(sector + partition.Start >= partition.End) return false; - ushort magic; byte[] minixSbSector = imagePlugin.ReadSector(sector + partition.Start); // Optical media @@ -93,7 +92,7 @@ namespace DiscImageChef.Filesystems minixSbSector = tmp; } - magic = BitConverter.ToUInt16(minixSbSector, 0x010); // Here should reside magic number on Minix v1 & V2 + ushort magic = BitConverter.ToUInt16(minixSbSector, 0x010); if(magic == MINIX_MAGIC || magic == MINIX_MAGIC2 || magic == MINIX2_MAGIC || magic == MINIX2_MAGIC2 || magic == MINIX_CIGAM || magic == MINIX_CIGAM2 || magic == MINIX2_CIGAM || @@ -101,10 +100,8 @@ namespace DiscImageChef.Filesystems magic = BitConverter.ToUInt16(minixSbSector, 0x018); // Here should reside magic number on Minix v3 - if(magic == MINIX_MAGIC || magic == MINIX2_MAGIC || magic == MINIX3_MAGIC || magic == MINIX_CIGAM || - magic == MINIX2_CIGAM || magic == MINIX3_CIGAM) return true; - - return false; + return magic == MINIX_MAGIC || magic == MINIX2_MAGIC || magic == MINIX3_MAGIC || magic == MINIX_CIGAM || + magic == MINIX2_CIGAM || magic == MINIX3_CIGAM; } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -127,7 +124,6 @@ namespace DiscImageChef.Filesystems bool minix3 = false; int filenamesize; string minixVersion; - ushort magic; byte[] minixSbSector = imagePlugin.ReadSector(sector + partition.Start); // Optical media @@ -138,7 +134,7 @@ namespace DiscImageChef.Filesystems minixSbSector = tmp; } - magic = BitConverter.ToUInt16(minixSbSector, 0x018); + ushort magic = BitConverter.ToUInt16(minixSbSector, 0x018); XmlFsType = new FileSystemType(); diff --git a/DiscImageChef.Filesystems/Nintendo.cs b/DiscImageChef.Filesystems/Nintendo.cs index 89622cb5..7f60609f 100644 --- a/DiscImageChef.Filesystems/Nintendo.cs +++ b/DiscImageChef.Filesystems/Nintendo.cs @@ -108,11 +108,10 @@ namespace DiscImageChef.Filesystems if(wii) { - uint offset1, offset2, offset3, offset4; - offset1 = BigEndianBitConverter.ToUInt32(header, 0x40004) << 2; - offset2 = BigEndianBitConverter.ToUInt32(header, 0x4000C) << 2; - offset3 = BigEndianBitConverter.ToUInt32(header, 0x40014) << 2; - offset4 = BigEndianBitConverter.ToUInt32(header, 0x4001C) << 2; + uint offset1 = BigEndianBitConverter.ToUInt32(header, 0x40004) << 2; + uint offset2 = BigEndianBitConverter.ToUInt32(header, 0x4000C) << 2; + uint offset3 = BigEndianBitConverter.ToUInt32(header, 0x40014) << 2; + uint offset4 = BigEndianBitConverter.ToUInt32(header, 0x4001C) << 2; fields.FirstPartitions = new NintendoPartition[BigEndianBitConverter.ToUInt32(header, 0x40000)]; fields.SecondPartitions = new NintendoPartition[BigEndianBitConverter.ToUInt32(header, 0x40008)]; diff --git a/DiscImageChef.Filesystems/ProDOS.cs b/DiscImageChef.Filesystems/ProDOS.cs index 5ecb53e8..055aec46 100644 --- a/DiscImageChef.Filesystems/ProDOS.cs +++ b/DiscImageChef.Filesystems/ProDOS.cs @@ -96,7 +96,7 @@ namespace DiscImageChef.Filesystems // Blocks 0 and 1 are boot code byte[] rootDirectoryKeyBlock = imagePlugin.ReadSectors(2 * multiplier + partition.Start, multiplier); - bool APMFromHDDOnCD = false; + bool apmFromHddOnCd = false; if(imagePlugin.Info.SectorSize == 2352 || imagePlugin.Info.SectorSize == 2448 || imagePlugin.Info.SectorSize == 2048) @@ -119,7 +119,7 @@ namespace DiscImageChef.Filesystems ENTRIES_PER_BLOCK)) { Array.Copy(tmp, offset, rootDirectoryKeyBlock, 0, 0x200); - APMFromHDDOnCD = true; + apmFromHddOnCd = true; break; } } @@ -145,7 +145,7 @@ namespace DiscImageChef.Filesystems if(bitMapPointer > partition.End) return false; ushort totalBlocks = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x29); - if(APMFromHDDOnCD) totalBlocks /= 4; + if(apmFromHddOnCd) totalBlocks /= 4; DicConsole.DebugWriteLine("ProDOS plugin", "{0} <= ({1} - {2} + 1)? {3}", totalBlocks, partition.End, partition.Start, totalBlocks <= partition.End - partition.Start + 1); @@ -162,7 +162,7 @@ namespace DiscImageChef.Filesystems // Blocks 0 and 1 are boot code byte[] rootDirectoryKeyBlockBytes = imagePlugin.ReadSectors(2 * multiplier + partition.Start, multiplier); - bool APMFromHDDOnCD = false; + bool apmFromHddOnCd = false; if(imagePlugin.Info.SectorSize == 2352 || imagePlugin.Info.SectorSize == 2448 || imagePlugin.Info.SectorSize == 2048) @@ -185,7 +185,7 @@ namespace DiscImageChef.Filesystems ENTRIES_PER_BLOCK)) { Array.Copy(tmp, offset, rootDirectoryKeyBlockBytes, 0, 0x200); - APMFromHDDOnCD = true; + apmFromHddOnCd = true; break; } } @@ -243,7 +243,7 @@ namespace DiscImageChef.Filesystems rootDirectoryKeyBlock.header.bit_map_pointer = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x27); rootDirectoryKeyBlock.header.total_blocks = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x29); - if(APMFromHDDOnCD) + if(apmFromHddOnCd) sbInformation.AppendLine("ProDOS uses 512 bytes/sector while devices uses 2048 bytes/sector.") .AppendLine(); @@ -299,20 +299,21 @@ namespace DiscImageChef.Filesystems information = sbInformation.ToString(); - XmlFsType = new FileSystemType(); - XmlFsType.VolumeName = rootDirectoryKeyBlock.header.volume_name; - if(dateCorrect) + XmlFsType = new FileSystemType { - XmlFsType.CreationDate = rootDirectoryKeyBlock.header.creation_time; - XmlFsType.CreationDateSpecified = true; - } + VolumeName = rootDirectoryKeyBlock.header.volume_name, + Files = rootDirectoryKeyBlock.header.file_count, + FilesSpecified = true, + Clusters = rootDirectoryKeyBlock.header.total_blocks, + Type = "ProDOS" + }; - XmlFsType.Files = rootDirectoryKeyBlock.header.file_count; - XmlFsType.FilesSpecified = true; - XmlFsType.Clusters = rootDirectoryKeyBlock.header.total_blocks; - XmlFsType.ClusterSize = (int)((partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize / - (ulong)XmlFsType.Clusters); - XmlFsType.Type = "ProDOS"; + XmlFsType.ClusterSize = (int)((partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize / + (ulong)XmlFsType.Clusters); + if(!dateCorrect) return; + + XmlFsType.CreationDate = rootDirectoryKeyBlock.header.creation_time; + XmlFsType.CreationDateSpecified = true; } /// diff --git a/DiscImageChef.Filesystems/QNX4.cs b/DiscImageChef.Filesystems/QNX4.cs index 72898c8b..f6ba733a 100644 --- a/DiscImageChef.Filesystems/QNX4.cs +++ b/DiscImageChef.Filesystems/QNX4.cs @@ -42,7 +42,7 @@ namespace DiscImageChef.Filesystems { public class QNX4 : IFilesystem { - readonly byte[] QNX4_RootDir_Fname = + readonly byte[] qnx4_rootDir_fname = {0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; public FileSystemType XmlFsType { get; private set; } @@ -63,7 +63,7 @@ namespace DiscImageChef.Filesystems Marshal.FreeHGlobal(sbPtr); // Check root directory name - if(!QNX4_RootDir_Fname.SequenceEqual(qnxSb.rootDir.di_fname)) return false; + if(!qnx4_rootDir_fname.SequenceEqual(qnxSb.rootDir.di_fname)) return false; // Check sizes are multiple of blocks if(qnxSb.rootDir.di_size % 512 != 0 || qnxSb.inode.di_size % 512 != 0 || qnxSb.boot.di_size % 512 != 0 || diff --git a/DiscImageChef.Filesystems/RBF.cs b/DiscImageChef.Filesystems/RBF.cs index 3b66dec2..0c5daef0 100644 --- a/DiscImageChef.Filesystems/RBF.cs +++ b/DiscImageChef.Filesystems/RBF.cs @@ -58,8 +58,9 @@ namespace DiscImageChef.Filesystems // Documentation says ID should be sector 0 // I've found that OS-9/X68000 has it on sector 4 // I've read OS-9/Apple2 has it on sector 15 - foreach(ulong location in new[] {0, 4, 15}) + foreach(int i in new[] {0, 4, 15}) { + ulong location = (ulong)i; RBF_IdSector rbfSb = new RBF_IdSector(); uint sbSize = (uint)(Marshal.SizeOf(rbfSb) / imagePlugin.Info.SectorSize); @@ -94,8 +95,9 @@ namespace DiscImageChef.Filesystems RBF_IdSector rbfSb = new RBF_IdSector(); RBF_NewIdSector rbf9000Sb = new RBF_NewIdSector(); - foreach(ulong location in new[] {0, 4, 15}) + foreach(int i in new[] {0, 4, 15}) { + ulong location = (ulong)i; uint sbSize = (uint)(Marshal.SizeOf(rbfSb) / imagePlugin.Info.SectorSize); if(Marshal.SizeOf(rbfSb) % imagePlugin.Info.SectorSize != 0) sbSize++; diff --git a/DiscImageChef.Filesystems/Reiser.cs b/DiscImageChef.Filesystems/Reiser.cs index 31ca3f44..c6478e1d 100644 --- a/DiscImageChef.Filesystems/Reiser.cs +++ b/DiscImageChef.Filesystems/Reiser.cs @@ -44,9 +44,9 @@ namespace DiscImageChef.Filesystems { const uint REISER_SUPER_OFFSET = 0x10000; - readonly byte[] Reiser35_Magic = {0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x46, 0x73, 0x00, 0x00}; - readonly byte[] Reiser36_Magic = {0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x32, 0x46, 0x73, 0x00}; - readonly byte[] ReiserJr_Magic = {0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x33, 0x46, 0x73, 0x00}; + readonly byte[] reiser35_magic = {0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x46, 0x73, 0x00, 0x00}; + readonly byte[] reiser36_magic = {0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x32, 0x46, 0x73, 0x00}; + readonly byte[] reiserJr_magic = {0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x33, 0x46, 0x73, 0x00}; public FileSystemType XmlFsType { get; private set; } public Encoding Encoding { get; private set; } @@ -75,8 +75,8 @@ namespace DiscImageChef.Filesystems reiserSb = (Reiser_Superblock)Marshal.PtrToStructure(sbPtr, typeof(Reiser_Superblock)); Marshal.FreeHGlobal(sbPtr); - return Reiser35_Magic.SequenceEqual(reiserSb.magic) || Reiser36_Magic.SequenceEqual(reiserSb.magic) || - ReiserJr_Magic.SequenceEqual(reiserSb.magic); + return reiser35_magic.SequenceEqual(reiserSb.magic) || reiser36_magic.SequenceEqual(reiserSb.magic) || + reiserJr_magic.SequenceEqual(reiserSb.magic); } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -102,14 +102,14 @@ namespace DiscImageChef.Filesystems reiserSb = (Reiser_Superblock)Marshal.PtrToStructure(sbPtr, typeof(Reiser_Superblock)); Marshal.FreeHGlobal(sbPtr); - if(!Reiser35_Magic.SequenceEqual(reiserSb.magic) && !Reiser36_Magic.SequenceEqual(reiserSb.magic) && - !ReiserJr_Magic.SequenceEqual(reiserSb.magic)) return; + if(!reiser35_magic.SequenceEqual(reiserSb.magic) && !reiser36_magic.SequenceEqual(reiserSb.magic) && + !reiserJr_magic.SequenceEqual(reiserSb.magic)) return; StringBuilder sb = new StringBuilder(); - if(Reiser35_Magic.SequenceEqual(reiserSb.magic)) sb.AppendLine("Reiser 3.5 filesystem"); - else if(Reiser36_Magic.SequenceEqual(reiserSb.magic)) sb.AppendLine("Reiser 3.6 filesystem"); - else if(ReiserJr_Magic.SequenceEqual(reiserSb.magic)) sb.AppendLine("Reiser Jr. filesystem"); + if(reiser35_magic.SequenceEqual(reiserSb.magic)) sb.AppendLine("Reiser 3.5 filesystem"); + else if(reiser36_magic.SequenceEqual(reiserSb.magic)) sb.AppendLine("Reiser 3.6 filesystem"); + else if(reiserJr_magic.SequenceEqual(reiserSb.magic)) sb.AppendLine("Reiser Jr. filesystem"); sb.AppendFormat("Volume has {0} blocks with {1} blocks free", reiserSb.block_count, reiserSb.free_blocks) .AppendLine(); sb.AppendFormat("{0} bytes per block", reiserSb.blocksize).AppendLine(); @@ -126,9 +126,9 @@ namespace DiscImageChef.Filesystems information = sb.ToString(); XmlFsType = new FileSystemType(); - if(Reiser35_Magic.SequenceEqual(reiserSb.magic)) XmlFsType.Type = "Reiser 3.5 filesystem"; - else if(Reiser36_Magic.SequenceEqual(reiserSb.magic)) XmlFsType.Type = "Reiser 3.6 filesystem"; - else if(ReiserJr_Magic.SequenceEqual(reiserSb.magic)) XmlFsType.Type = "Reiser Jr. filesystem"; + if(reiser35_magic.SequenceEqual(reiserSb.magic)) XmlFsType.Type = "Reiser 3.5 filesystem"; + else if(reiser36_magic.SequenceEqual(reiserSb.magic)) XmlFsType.Type = "Reiser 3.6 filesystem"; + else if(reiserJr_magic.SequenceEqual(reiserSb.magic)) XmlFsType.Type = "Reiser Jr. filesystem"; XmlFsType.ClusterSize = reiserSb.blocksize; XmlFsType.Clusters = reiserSb.block_count; XmlFsType.FreeClusters = reiserSb.free_blocks; diff --git a/DiscImageChef.Filesystems/Reiser4.cs b/DiscImageChef.Filesystems/Reiser4.cs index f859d7cc..d9cf0a77 100644 --- a/DiscImageChef.Filesystems/Reiser4.cs +++ b/DiscImageChef.Filesystems/Reiser4.cs @@ -44,7 +44,7 @@ namespace DiscImageChef.Filesystems { const uint REISER4_SUPER_OFFSET = 0x10000; - readonly byte[] Reiser4_Magic = + readonly byte[] reiser4_magic = {0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; public FileSystemType XmlFsType { get; private set; } @@ -74,7 +74,7 @@ namespace DiscImageChef.Filesystems reiserSb = (Reiser4_Superblock)Marshal.PtrToStructure(sbPtr, typeof(Reiser4_Superblock)); Marshal.FreeHGlobal(sbPtr); - return Reiser4_Magic.SequenceEqual(reiserSb.magic); + return reiser4_magic.SequenceEqual(reiserSb.magic); } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -100,7 +100,7 @@ namespace DiscImageChef.Filesystems reiserSb = (Reiser4_Superblock)Marshal.PtrToStructure(sbPtr, typeof(Reiser4_Superblock)); Marshal.FreeHGlobal(sbPtr); - if(!Reiser4_Magic.SequenceEqual(reiserSb.magic)) return; + if(!reiser4_magic.SequenceEqual(reiserSb.magic)) return; StringBuilder sb = new StringBuilder(); diff --git a/DiscImageChef.Filesystems/SolarFS.cs b/DiscImageChef.Filesystems/SolarFS.cs index dcc21b40..fe335701 100644 --- a/DiscImageChef.Filesystems/SolarFS.cs +++ b/DiscImageChef.Filesystems/SolarFS.cs @@ -51,13 +51,11 @@ namespace DiscImageChef.Filesystems { if(2 + partition.Start >= partition.End) return false; - byte signature; // 0x29 - byte[] bpb = imagePlugin.ReadSector(0 + partition.Start); byte[] fsTypeB = new byte[8]; - signature = bpb[0x25]; + byte signature = bpb[0x25]; Array.Copy(bpb, 0x35, fsTypeB, 0, 8); string fsType = StringHandlers.CToString(fsTypeB); diff --git a/DiscImageChef.Filesystems/UNICOS.cs b/DiscImageChef.Filesystems/UNICOS.cs index c75e36f0..8fee2cee 100644 --- a/DiscImageChef.Filesystems/UNICOS.cs +++ b/DiscImageChef.Filesystems/UNICOS.cs @@ -50,11 +50,11 @@ namespace DiscImageChef.Filesystems { public class UNICOS : IFilesystem { - const int NC1MAXPART = 64; - const int NC1MAXIREG = 4; + const int NC1_MAXPART = 64; + const int NC1_MAXIREG = 4; - const ulong UNICOS_Magic = 0x6e6331667331636e; - const ulong UNICOS_Secure = 0xcd076d1771d670cd; + const ulong UNICOS_MAGIC = 0x6e6331667331636e; + const ulong UNICOS_SECURE = 0xcd076d1771d670cd; public FileSystemType XmlFsType { get; private set; } public Encoding Encoding { get; private set; } @@ -76,9 +76,9 @@ namespace DiscImageChef.Filesystems unicosSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); DicConsole.DebugWriteLine("UNICOS plugin", "magic = 0x{0:X16} (expected 0x{1:X16})", unicosSb.s_magic, - UNICOS_Magic); + UNICOS_MAGIC); - return unicosSb.s_magic == UNICOS_Magic; + return unicosSb.s_magic == UNICOS_MAGIC; } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -98,12 +98,12 @@ namespace DiscImageChef.Filesystems unicosSb = BigEndianMarshal.ByteArrayToStructureBigEndian(sector); - if(unicosSb.s_magic != UNICOS_Magic) return; + if(unicosSb.s_magic != UNICOS_MAGIC) return; StringBuilder sb = new StringBuilder(); sb.AppendLine("UNICOS filesystem"); - if(unicosSb.s_secure == UNICOS_Secure) sb.AppendLine("Volume is secure"); + if(unicosSb.s_secure == UNICOS_SECURE) sb.AppendLine("Volume is secure"); sb.AppendFormat("Volume contains {0} partitions", unicosSb.s_npart).AppendLine(); sb.AppendFormat("{0} bytes per sector", unicosSb.s_iounit).AppendLine(); sb.AppendLine("4096 bytes per block"); @@ -145,7 +145,7 @@ namespace DiscImageChef.Filesystems public long fd_name; /* Physical device name */ public uint fd_sblk; /* Start block number */ public uint fd_nblk; /* Number of blocks */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NC1MAXIREG)] + [MarshalAs(UnmanagedType.ByValArray, SizeConst = NC1_MAXIREG)] public nc1ireg_sb[] fd_ireg; /* Inode regions */ } @@ -178,7 +178,7 @@ namespace DiscImageChef.Filesystems public long s_ifract; /* Ratio of inodes to blocks */ public extent_t s_sfs; /* SFS only blocks */ public long s_flag; /* Flag word */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NC1MAXPART)] + [MarshalAs(UnmanagedType.ByValArray, SizeConst = NC1_MAXPART)] public nc1fdev_sb[] s_part; /* Partition descriptors */ public long s_iounit; /* Physical block size */ public long s_numiresblks; /* number of inode reservation blocks */ diff --git a/DiscImageChef.Filesystems/UNIXBFS.cs b/DiscImageChef.Filesystems/UNIXBFS.cs index 1db6b004..b6363630 100644 --- a/DiscImageChef.Filesystems/UNIXBFS.cs +++ b/DiscImageChef.Filesystems/UNIXBFS.cs @@ -53,9 +53,7 @@ namespace DiscImageChef.Filesystems { if(2 + partition.Start >= partition.End) return false; - uint magic; - - magic = BitConverter.ToUInt32(imagePlugin.ReadSector(0 + partition.Start), 0); + uint magic = BitConverter.ToUInt32(imagePlugin.ReadSector(0 + partition.Start), 0); return magic == BFS_MAGIC; } diff --git a/DiscImageChef.Filesystems/XFS.cs b/DiscImageChef.Filesystems/XFS.cs index ad48e312..4ef005fe 100644 --- a/DiscImageChef.Filesystems/XFS.cs +++ b/DiscImageChef.Filesystems/XFS.cs @@ -79,8 +79,9 @@ namespace DiscImageChef.Filesystems } } else - foreach(ulong location in new[] {0, 1, 2}) + foreach(int i in new[] {0, 1, 2}) { + ulong location = (ulong)i; XFS_Superblock xfsSb = new XFS_Superblock(); uint sbSize = (uint)(Marshal.SizeOf(xfsSb) / imagePlugin.Info.SectorSize); @@ -133,8 +134,9 @@ namespace DiscImageChef.Filesystems } } else - foreach(ulong location in new[] {0, 1, 2}) + foreach(int i in new[] {0, 1, 2}) { + ulong location = (ulong)i; uint sbSize = (uint)(Marshal.SizeOf(xfsSb) / imagePlugin.Info.SectorSize); if(Marshal.SizeOf(xfsSb) % imagePlugin.Info.SectorSize != 0) sbSize++; diff --git a/DiscImageChef.Filesystems/ZFS.cs b/DiscImageChef.Filesystems/ZFS.cs index 4483edcf..3dcba136 100644 --- a/DiscImageChef.Filesystems/ZFS.cs +++ b/DiscImageChef.Filesystems/ZFS.cs @@ -166,15 +166,13 @@ namespace DiscImageChef.Filesystems if(nvlist == null || nvlist.Length < 16) return false; - int offset; if(!xdr) return false; BigEndianBitConverter.IsLittleEndian = littleEndian; - offset = 8; + int offset = 8; while(offset < nvlist.Length) { - uint nameLength; NVS_Item item = new NVS_Item(); int currOff = offset; @@ -186,7 +184,7 @@ namespace DiscImageChef.Filesystems offset += 4; item.decodedSize = BigEndianBitConverter.ToUInt32(nvlist, offset); offset += 4; - nameLength = BigEndianBitConverter.ToUInt32(nvlist, offset); + uint nameLength = BigEndianBitConverter.ToUInt32(nvlist, offset); offset += 4; if(nameLength % 4 > 0) nameLength += 4 - nameLength % 4; byte[] nameBytes = new byte[nameLength]; diff --git a/DiscImageChef.Filesystems/exFAT.cs b/DiscImageChef.Filesystems/exFAT.cs index 9ec641a1..d9735df9 100644 --- a/DiscImageChef.Filesystems/exFAT.cs +++ b/DiscImageChef.Filesystems/exFAT.cs @@ -45,7 +45,7 @@ namespace DiscImageChef.Filesystems { readonly Guid OEM_FLASH_PARAMETER_GUID = new Guid("0A0C7E46-3399-4021-90C8-FA6D389C4BA2"); - readonly byte[] Signature = {0x45, 0x58, 0x46, 0x41, 0x54, 0x20, 0x20, 0x20}; + readonly byte[] signature = {0x45, 0x58, 0x46, 0x41, 0x54, 0x20, 0x20, 0x20}; public FileSystemType XmlFsType { get; private set; } public Encoding Encoding { get; private set; } @@ -64,7 +64,7 @@ namespace DiscImageChef.Filesystems VolumeBootRecord vbr = (VolumeBootRecord)Marshal.PtrToStructure(vbrPtr, typeof(VolumeBootRecord)); Marshal.FreeHGlobal(vbrPtr); - return Signature.SequenceEqual(vbr.signature); + return signature.SequenceEqual(vbr.signature); } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -111,7 +111,7 @@ namespace DiscImageChef.Filesystems .AppendLine(); sb.AppendFormat("Volume serial number: {0:X8}", vbr.volumeSerial).AppendLine(); sb.AppendFormat("BIOS drive is {0:X2}h", vbr.drive).AppendLine(); - if(vbr.flags.HasFlag(VolumeFlags.SecondFATActive)) sb.AppendLine("2nd FAT is in use"); + if(vbr.flags.HasFlag(VolumeFlags.SecondFatActive)) sb.AppendLine("2nd FAT is in use"); if(vbr.flags.HasFlag(VolumeFlags.VolumeDirty)) sb.AppendLine("Volume is dirty"); if(vbr.flags.HasFlag(VolumeFlags.MediaFailure)) sb.AppendLine("Underlying media presented errors"); @@ -148,7 +148,7 @@ namespace DiscImageChef.Filesystems [Flags] enum VolumeFlags : ushort { - SecondFATActive = 1, + SecondFatActive = 1, VolumeDirty = 2, MediaFailure = 4, ClearToZero = 8 diff --git a/DiscImageChef.Filters/AppleDouble.cs b/DiscImageChef.Filters/AppleDouble.cs index a4531c1b..8c07f1b7 100644 --- a/DiscImageChef.Filters/AppleDouble.cs +++ b/DiscImageChef.Filters/AppleDouble.cs @@ -153,36 +153,27 @@ namespace DiscImageChef.Filters public bool Identify(string path) { - // Prepend data fork name with "R." - string ProDosAppleDouble; - // Prepend data fork name with '%' - string UNIXAppleDouble; - // Change file extension to ADF - string DOSAppleDouble; - // Change file extension to adf - string DOSAppleDoubleLower; - // Store AppleDouble header file in ".AppleDouble" folder with same name - string NetatalkAppleDouble; - // Store AppleDouble header file in "resource.frk" folder with same name - string DAVEAppleDouble; - // Prepend data fork name with "._" - string OSXAppleDouble; - // Adds ".rsrc" extension - string UnArAppleDouble; - string filename = Path.GetFileName(path); string filenameNoExt = Path.GetFileNameWithoutExtension(path); string parentFolder = Path.GetDirectoryName(path); - ProDosAppleDouble = Path.Combine(parentFolder ?? throw new InvalidOperationException(), "R." + filename); - UNIXAppleDouble = Path.Combine(parentFolder, "%" + filename); - DOSAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF"); - DOSAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf"); - NetatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", - filename ?? throw new InvalidOperationException()); - DAVEAppleDouble = Path.Combine(parentFolder, "resource.frk", filename); - OSXAppleDouble = Path.Combine(parentFolder, "._" + filename); - UnArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc"); + // Prepend data fork name with "R." + string ProDosAppleDouble = Path.Combine(parentFolder ?? throw new InvalidOperationException(), "R." + filename); + // Prepend data fork name with '%' + string UNIXAppleDouble = Path.Combine(parentFolder, "%" + filename); + // Change file extension to ADF + string DOSAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF"); + // Change file extension to adf + string DOSAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf"); + // Store AppleDouble header file in ".AppleDouble" folder with same name + string NetatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", + filename ?? throw new InvalidOperationException()); + // Store AppleDouble header file in "resource.frk" folder with same name + string DAVEAppleDouble = Path.Combine(parentFolder, "resource.frk", filename); + // Prepend data fork name with "._" + string OSXAppleDouble = Path.Combine(parentFolder, "._" + filename); + // Adds ".rsrc" extension + string UnArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc"); // Check AppleDouble created by A/UX in ProDOS filesystem if(File.Exists(ProDosAppleDouble)) @@ -322,36 +313,27 @@ namespace DiscImageChef.Filters public void Open(string path) { - // Prepend data fork name with "R." - string ProDosAppleDouble; - // Prepend data fork name with '%' - string UNIXAppleDouble; - // Change file extension to ADF - string DOSAppleDouble; - // Change file extension to adf - string DOSAppleDoubleLower; - // Store AppleDouble header file in ".AppleDouble" folder with same name - string NetatalkAppleDouble; - // Store AppleDouble header file in "resource.frk" folder with same name - string DAVEAppleDouble; - // Prepend data fork name with "._" - string OSXAppleDouble; - // Adds ".rsrc" extension - string UnArAppleDouble; - string filename = Path.GetFileName(path); string filenameNoExt = Path.GetFileNameWithoutExtension(path); string parentFolder = Path.GetDirectoryName(path); - ProDosAppleDouble = Path.Combine(parentFolder ?? throw new InvalidOperationException(), "R." + filename); - UNIXAppleDouble = Path.Combine(parentFolder, "%" + filename); - DOSAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF"); - DOSAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf"); - NetatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", - filename ?? throw new InvalidOperationException()); - DAVEAppleDouble = Path.Combine(parentFolder, "resource.frk", filename); - OSXAppleDouble = Path.Combine(parentFolder, "._" + filename); - UnArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc"); + // Prepend data fork name with "R." + string ProDosAppleDouble = Path.Combine(parentFolder ?? throw new InvalidOperationException(), "R." + filename); + // Prepend data fork name with '%' + string UNIXAppleDouble = Path.Combine(parentFolder, "%" + filename); + // Change file extension to ADF + string DOSAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF"); + // Change file extension to adf + string DOSAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf"); + // Store AppleDouble header file in ".AppleDouble" folder with same name + string NetatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", + filename ?? throw new InvalidOperationException()); + // Store AppleDouble header file in "resource.frk" folder with same name + string DAVEAppleDouble = Path.Combine(parentFolder, "resource.frk", filename); + // Prepend data fork name with "._" + string OSXAppleDouble = Path.Combine(parentFolder, "._" + filename); + // Adds ".rsrc" extension + string UnArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc"); // Check AppleDouble created by A/UX in ProDOS filesystem if(File.Exists(ProDosAppleDouble)) diff --git a/DiscImageChef.Filters/BZip2.cs b/DiscImageChef.Filters/BZip2.cs index d9dea72b..b8a93984 100644 --- a/DiscImageChef.Filters/BZip2.cs +++ b/DiscImageChef.Filters/BZip2.cs @@ -137,9 +137,7 @@ namespace DiscImageChef.Filters stream.Read(buffer, 0, 4); stream.Seek(0, SeekOrigin.Begin); // Check it is not an UDIF - if(buffer[0] == 0x6B && buffer[1] == 0x6F && buffer[2] == 0x6C && buffer[3] == 0x79) return false; - - return true; + return buffer[0] != 0x6B || buffer[1] != 0x6F || buffer[2] != 0x6C || buffer[3] != 0x79; } public void Open(byte[] buffer) @@ -169,9 +167,6 @@ namespace DiscImageChef.Filters dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); basePath = Path.GetFullPath(path); - DateTime start = DateTime.UtcNow; - DateTime end = DateTime.UtcNow; - FileInfo fi = new FileInfo(path); creationTime = fi.CreationTimeUtc; lastWriteTime = fi.LastWriteTimeUtc; @@ -209,10 +204,10 @@ namespace DiscImageChef.Filters { if(basePath?.EndsWith(".bz2", StringComparison.InvariantCultureIgnoreCase) == true) return basePath.Substring(0, basePath.Length - 4); - if(basePath?.EndsWith(".bzip2", StringComparison.InvariantCultureIgnoreCase) == true) - return basePath.Substring(0, basePath.Length - 6); - return basePath; + return basePath?.EndsWith(".bzip2", StringComparison.InvariantCultureIgnoreCase) == true + ? basePath.Substring(0, basePath.Length - 6) + : basePath; } public string GetParentFolder() diff --git a/DiscImageChef.Filters/GZip.cs b/DiscImageChef.Filters/GZip.cs index 2e37d547..5c6c59b9 100644 --- a/DiscImageChef.Filters/GZip.cs +++ b/DiscImageChef.Filters/GZip.cs @@ -119,8 +119,6 @@ namespace DiscImageChef.Filters { byte[] mtime_b = new byte[4]; byte[] isize_b = new byte[4]; - uint mtime; - uint isize; dataStream = new MemoryStream(buffer); basePath = null; @@ -131,8 +129,8 @@ namespace DiscImageChef.Filters dataStream.Read(isize_b, 0, 4); dataStream.Seek(0, SeekOrigin.Begin); - mtime = BitConverter.ToUInt32(mtime_b, 0); - isize = BitConverter.ToUInt32(isize_b, 0); + uint mtime = BitConverter.ToUInt32(mtime_b, 0); + uint isize = BitConverter.ToUInt32(isize_b, 0); decompressedSize = isize; creationTime = DateHandlers.UnixUnsignedToDateTime(mtime); @@ -145,8 +143,6 @@ namespace DiscImageChef.Filters { byte[] mtime_b = new byte[4]; byte[] isize_b = new byte[4]; - uint mtime; - uint isize; dataStream = stream; basePath = null; @@ -157,8 +153,8 @@ namespace DiscImageChef.Filters dataStream.Read(isize_b, 0, 4); dataStream.Seek(0, SeekOrigin.Begin); - mtime = BitConverter.ToUInt32(mtime_b, 0); - isize = BitConverter.ToUInt32(isize_b, 0); + uint mtime = BitConverter.ToUInt32(mtime_b, 0); + uint isize = BitConverter.ToUInt32(isize_b, 0); decompressedSize = isize; creationTime = DateHandlers.UnixUnsignedToDateTime(mtime); @@ -171,8 +167,6 @@ namespace DiscImageChef.Filters { byte[] mtime_b = new byte[4]; byte[] isize_b = new byte[4]; - uint mtime; - uint isize; dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); basePath = Path.GetFullPath(path); @@ -183,8 +177,8 @@ namespace DiscImageChef.Filters dataStream.Read(isize_b, 0, 4); dataStream.Seek(0, SeekOrigin.Begin); - mtime = BitConverter.ToUInt32(mtime_b, 0); - isize = BitConverter.ToUInt32(isize_b, 0); + uint mtime = BitConverter.ToUInt32(mtime_b, 0); + uint isize = BitConverter.ToUInt32(isize_b, 0); decompressedSize = isize; FileInfo fi = new FileInfo(path); @@ -223,10 +217,10 @@ namespace DiscImageChef.Filters { if(basePath?.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase) == true) return basePath.Substring(0, basePath.Length - 3); - if(basePath?.EndsWith(".gzip", StringComparison.InvariantCultureIgnoreCase) == true) - return basePath.Substring(0, basePath.Length - 5); - return basePath; + return basePath?.EndsWith(".gzip", StringComparison.InvariantCultureIgnoreCase) == true + ? basePath.Substring(0, basePath.Length - 5) + : basePath; } public string GetParentFolder() diff --git a/DiscImageChef.Filters/LZip.cs b/DiscImageChef.Filters/LZip.cs index 5d6479ac..c0b8053d 100644 --- a/DiscImageChef.Filters/LZip.cs +++ b/DiscImageChef.Filters/LZip.cs @@ -152,9 +152,6 @@ namespace DiscImageChef.Filters dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); basePath = Path.GetFullPath(path); - DateTime start = DateTime.UtcNow; - DateTime end = DateTime.UtcNow; - FileInfo fi = new FileInfo(path); creationTime = fi.CreationTimeUtc; lastWriteTime = fi.LastWriteTimeUtc; @@ -197,10 +194,10 @@ namespace DiscImageChef.Filters { if(basePath?.EndsWith(".lz", StringComparison.InvariantCultureIgnoreCase) == true) return basePath.Substring(0, basePath.Length - 3); - if(basePath?.EndsWith(".lzip", StringComparison.InvariantCultureIgnoreCase) == true) - return basePath.Substring(0, basePath.Length - 5); - return basePath; + return basePath?.EndsWith(".lzip", StringComparison.InvariantCultureIgnoreCase) == true + ? basePath.Substring(0, basePath.Length - 5) + : basePath; } public string GetParentFolder() diff --git a/DiscImageChef.Filters/XZ.cs b/DiscImageChef.Filters/XZ.cs index 4840d662..8c795b9b 100644 --- a/DiscImageChef.Filters/XZ.cs +++ b/DiscImageChef.Filters/XZ.cs @@ -199,9 +199,6 @@ namespace DiscImageChef.Filters dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); basePath = Path.GetFullPath(path); - DateTime start = DateTime.UtcNow; - DateTime end = DateTime.UtcNow; - FileInfo fi = new FileInfo(path); creationTime = fi.CreationTimeUtc; lastWriteTime = fi.LastWriteTimeUtc; diff --git a/DiscImageChef.Interop/DetectOS.cs b/DiscImageChef.Interop/DetectOS.cs index c775412b..599ded26 100644 --- a/DiscImageChef.Interop/DetectOS.cs +++ b/DiscImageChef.Interop/DetectOS.cs @@ -89,10 +89,8 @@ namespace DiscImageChef.Interop } case "Darwin": { - int osxError; - IntPtr pLen = Marshal.AllocHGlobal(sizeof(int)); - osxError = OSX_sysctlbyname("hw.machine", IntPtr.Zero, pLen, IntPtr.Zero, 0); + int osxError = OSX_sysctlbyname("hw.machine", IntPtr.Zero, pLen, IntPtr.Zero, 0); if(osxError != 0) { Marshal.FreeHGlobal(pLen); diff --git a/DiscImageChef.Partitions/AppleMap.cs b/DiscImageChef.Partitions/AppleMap.cs index 4f324195..ab9e8739 100644 --- a/DiscImageChef.Partitions/AppleMap.cs +++ b/DiscImageChef.Partitions/AppleMap.cs @@ -276,7 +276,7 @@ namespace DiscImageChef.Partitions StringBuilder sb = new StringBuilder(); - Partition _partition = new Partition + Partition partition = new Partition { Sequence = sequence, Type = StringHandlers.CToString(entry.type), @@ -309,25 +309,25 @@ namespace DiscImageChef.Partitions sb.AppendLine("Partition's boot code is position independent."); } - _partition.Description = sb.ToString(); - if(_partition.Start < imagePlugin.Info.Sectors && _partition.End < imagePlugin.Info.Sectors) + partition.Description = sb.ToString(); + if(partition.Start < imagePlugin.Info.Sectors && partition.End < imagePlugin.Info.Sectors) { - partitions.Add(_partition); + partitions.Add(partition); sequence++; } // Some CD and DVDs end with an Apple_Free that expands beyond the disc size... - else if(_partition.Start < imagePlugin.Info.Sectors) + else if(partition.Start < imagePlugin.Info.Sectors) { DicConsole.DebugWriteLine("AppleMap Plugin", "Cutting last partition end ({0}) to media size ({1})", - _partition.End, imagePlugin.Info.Sectors - 1); - _partition.Length = imagePlugin.Info.Sectors - _partition.Start; - partitions.Add(_partition); + partition.End, imagePlugin.Info.Sectors - 1); + partition.Length = imagePlugin.Info.Sectors - partition.Start; + partitions.Add(partition); sequence++; } else DicConsole.DebugWriteLine("AppleMap Plugin", "Not adding partition becaus start ({0}) is outside media size ({1})", - _partition.Start, imagePlugin.Info.Sectors - 1); + partition.Start, imagePlugin.Info.Sectors - 1); } return partitions.Count > 0; diff --git a/DiscImageChef.Partitions/RDB.cs b/DiscImageChef.Partitions/RDB.cs index a1c65f24..31e131a3 100644 --- a/DiscImageChef.Partitions/RDB.cs +++ b/DiscImageChef.Partitions/RDB.cs @@ -444,11 +444,9 @@ namespace DiscImageChef.Partitions DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved24 = 0x{0:X8}", rdb.Reserved24); DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved25 = 0x{0:X8}", rdb.Reserved25); - ulong nextBlock; - // Reading BadBlock list List badBlockChain = new List(); - nextBlock = rdb.BadblockPtr; + ulong nextBlock = rdb.BadblockPtr; while(nextBlock != 0xFFFFFFFF) { DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a BadBlock block", diff --git a/DiscImageChef.Partitions/RioKarma.cs b/DiscImageChef.Partitions/RioKarma.cs index 9b1dcbfd..8b7423aa 100644 --- a/DiscImageChef.Partitions/RioKarma.cs +++ b/DiscImageChef.Partitions/RioKarma.cs @@ -49,8 +49,7 @@ namespace DiscImageChef.Partitions public bool GetInformation(IMediaImage imagePlugin, out List partitions, ulong sectorOffset) { - partitions = new List(); - + partitions = null; byte[] sector = imagePlugin.ReadSector(sectorOffset); if(sector.Length < 512) return false; @@ -63,23 +62,19 @@ namespace DiscImageChef.Partitions ulong counter = 0; - foreach(Partition part in from entry in table.entries - let part = new Partition - { - Start = entry.offset, - Offset = (ulong)(entry.offset * sector.Length), - Size = entry.size, - Length = (ulong)(entry.size * sector.Length), - Type = "Rio Karma", - Sequence = counter, - Scheme = Name - } - where entry.type == ENTRY_MAGIC - select part) - { - partitions.Add(part); - counter++; - } + partitions = (from entry in table.entries + let part = new Partition + { + Start = entry.offset, + Offset = (ulong)(entry.offset * sector.Length), + Size = entry.size, + Length = (ulong)(entry.size * sector.Length), + Type = "Rio Karma", + Sequence = counter++, + Scheme = Name + } + where entry.type == ENTRY_MAGIC + select part).ToList(); return true; } diff --git a/DiscImageChef.Partitions/XENIX.cs b/DiscImageChef.Partitions/XENIX.cs index 8f0408f7..b63578ab 100644 --- a/DiscImageChef.Partitions/XENIX.cs +++ b/DiscImageChef.Partitions/XENIX.cs @@ -51,16 +51,16 @@ namespace DiscImageChef.Partitions public string Name => "XENIX"; public Guid Id => new Guid("53BE01DE-E68B-469F-A17F-EC2E4BD61CD9"); - public bool GetInformation(IMediaImage imagePlugin, out List partitions, ulong sectorOffset) + public bool GetInformation(IMediaImage imagePlugin, out List partitions, ulong sectorOffset) { - partitions = new List(); + partitions = new List(); if(42 + sectorOffset >= imagePlugin.Info.Sectors) return false; byte[] tblsector = imagePlugin.ReadSector(42 + sectorOffset); GCHandle handle = GCHandle.Alloc(tblsector, GCHandleType.Pinned); - partable xnxtbl = (partable)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(partable)); + Partable xnxtbl = (Partable)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Partable)); handle.Free(); DicConsole.DebugWriteLine("XENIX plugin", "xnxtbl.p_magic = 0x{0:X4} (should be 0x{1:X4})", xnxtbl.p_magic, @@ -74,7 +74,7 @@ namespace DiscImageChef.Partitions DicConsole.DebugWriteLine("XENIX plugin", "xnxtbl.p[{0}].p_size = {1}", i, xnxtbl.p[i].p_size); if(xnxtbl.p[i].p_size <= 0) continue; - Partition part = new Partition + CommonTypes.Partition part = new CommonTypes.Partition { Start = (ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) / imagePlugin.Info.SectorSize + @@ -96,14 +96,14 @@ namespace DiscImageChef.Partitions } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct partable + struct Partable { public ushort p_magic; /* magic number validity indicator */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXPARTS)] public partition[] p; /*partition headers*/ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXPARTS)] public Partition[] p; /*partition headers*/ } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct partition + struct Partition { public int p_off; /*start 1K block no of partition*/ public int p_size; /*# of 1K blocks in partition*/ diff --git a/DiscImageChef.Tests.Devices/ATA.cs b/DiscImageChef.Tests.Devices/ATA.cs index 98d807e6..00840fce 100644 --- a/DiscImageChef.Tests.Devices/ATA.cs +++ b/DiscImageChef.Tests.Devices/ATA.cs @@ -32,7 +32,7 @@ using DiscImageChef.Tests.Devices.ATA; namespace DiscImageChef.Tests.Devices { - partial class MainClass + static partial class MainClass { public static void Ata(string devPath, Device dev) { diff --git a/DiscImageChef.Tests.Devices/Command.cs b/DiscImageChef.Tests.Devices/Command.cs index aef23ce8..70f84a2a 100644 --- a/DiscImageChef.Tests.Devices/Command.cs +++ b/DiscImageChef.Tests.Devices/Command.cs @@ -31,7 +31,7 @@ using DiscImageChef.Devices; namespace DiscImageChef.Tests.Devices { - partial class MainClass + static partial class MainClass { public static void Command(string devPath, Device dev) { diff --git a/DiscImageChef.Tests.Devices/DecodeATARegisters.cs b/DiscImageChef.Tests.Devices/DecodeATARegisters.cs index d84016e9..f3b8d947 100644 --- a/DiscImageChef.Tests.Devices/DecodeATARegisters.cs +++ b/DiscImageChef.Tests.Devices/DecodeATARegisters.cs @@ -32,7 +32,7 @@ using DiscImageChef.Decoders.ATA; namespace DiscImageChef.Tests.Devices { - partial class MainClass + static partial class MainClass { static string DecodeAtaStatus(byte status) { diff --git a/DiscImageChef.Tests.Devices/Device.cs b/DiscImageChef.Tests.Devices/Device.cs index 3ffdb28e..7ff7056f 100644 --- a/DiscImageChef.Tests.Devices/Device.cs +++ b/DiscImageChef.Tests.Devices/Device.cs @@ -31,7 +31,7 @@ using DiscImageChef.Devices; namespace DiscImageChef.Tests.Devices { - partial class MainClass + static partial class MainClass { public static void Device(string devPath) { diff --git a/DiscImageChef.Tests.Devices/Main.cs b/DiscImageChef.Tests.Devices/Main.cs index 8d561eaa..237f7071 100644 --- a/DiscImageChef.Tests.Devices/Main.cs +++ b/DiscImageChef.Tests.Devices/Main.cs @@ -32,9 +32,9 @@ using DiscImageChef.Devices; namespace DiscImageChef.Tests.Devices { - partial class MainClass + static partial class MainClass { - public static void Main(string[] args) + public static void Main() { DicConsole.WriteLineEvent += System.Console.WriteLine; DicConsole.WriteEvent += System.Console.Write; diff --git a/DiscImageChef.Tests.Devices/NVMe.cs b/DiscImageChef.Tests.Devices/NVMe.cs index d89efca6..baf9df27 100644 --- a/DiscImageChef.Tests.Devices/NVMe.cs +++ b/DiscImageChef.Tests.Devices/NVMe.cs @@ -31,7 +31,7 @@ using DiscImageChef.Devices; namespace DiscImageChef.Tests.Devices { - partial class MainClass + static partial class MainClass { public static void NVMe(string devPath, Device dev) { diff --git a/DiscImageChef.Tests.Devices/SCSI.cs b/DiscImageChef.Tests.Devices/SCSI.cs index 94ffd5ed..dd78dcb0 100644 --- a/DiscImageChef.Tests.Devices/SCSI.cs +++ b/DiscImageChef.Tests.Devices/SCSI.cs @@ -32,7 +32,7 @@ using DiscImageChef.Tests.Devices.SCSI; namespace DiscImageChef.Tests.Devices { - partial class MainClass + static partial class MainClass { public static void Scsi(string devPath, Device dev) { diff --git a/DiscImageChef.Tests.Devices/SecureDigital.cs b/DiscImageChef.Tests.Devices/SecureDigital.cs index b066af07..066047fa 100644 --- a/DiscImageChef.Tests.Devices/SecureDigital.cs +++ b/DiscImageChef.Tests.Devices/SecureDigital.cs @@ -32,7 +32,7 @@ using DiscImageChef.Tests.Devices.SecureDigital; namespace DiscImageChef.Tests.Devices { - partial class MainClass + static partial class MainClass { public static void SecureDigital(string devPath, Device dev) { diff --git a/DiscImageChef.Tests/Program.cs b/DiscImageChef.Tests/Program.cs index 9bdae4ad..2cfd0727 100644 --- a/DiscImageChef.Tests/Program.cs +++ b/DiscImageChef.Tests/Program.cs @@ -23,7 +23,7 @@ namespace NUnitLite.Tests { - public class Program + public static class Program { /// /// The main program executes the tests. Output may be routed to diff --git a/DiscImageChef/Commands/Configure.cs b/DiscImageChef/Commands/Configure.cs index cb073793..7d13ce67 100644 --- a/DiscImageChef/Commands/Configure.cs +++ b/DiscImageChef/Commands/Configure.cs @@ -224,7 +224,7 @@ namespace DiscImageChef.Commands else Settings.Settings.Current.Stats = null; #endregion Statistics - Settings.Settings.Current.GdprCompliance = Settings.DicSettings.GdprLevel; + Settings.Settings.Current.GdprCompliance = DicSettings.GdprLevel; Settings.Settings.SaveSettings(); } } diff --git a/DiscImageChef/Commands/Decode.cs b/DiscImageChef/Commands/Decode.cs index a2086825..0356f046 100644 --- a/DiscImageChef/Commands/Decode.cs +++ b/DiscImageChef/Commands/Decode.cs @@ -230,12 +230,10 @@ namespace DiscImageChef.Commands if(options.SectorTags) { - ulong length; - - if(options.Length.ToLowerInvariant() == "all") length = inputFormat.Info.Sectors - 1; + if(options.Length.ToLowerInvariant() == "all") { } else { - if(!ulong.TryParse(options.Length, out length)) + if(!ulong.TryParse(options.Length, out ulong _)) { DicConsole.WriteLine("Value \"{0}\" is not a valid number for length.", options.Length); DicConsole.WriteLine("Not decoding sectors tags"); diff --git a/DiscImageChef/Commands/DumpMedia.cs b/DiscImageChef/Commands/DumpMedia.cs index 5def5fa8..350a6ed8 100644 --- a/DiscImageChef/Commands/DumpMedia.cs +++ b/DiscImageChef/Commands/DumpMedia.cs @@ -63,7 +63,8 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Dump-Media command", "--debug={0}", options.Debug); DicConsole.DebugWriteLine("Dump-Media command", "--verbose={0}", options.Verbose); DicConsole.DebugWriteLine("Dump-Media command", "--device={0}", options.DevicePath); - DicConsole.DebugWriteLine("Dump-Media command", "--raw={0}", options.Raw); + // TODO: Disabled temporarily + //DicConsole.DebugWriteLine("Dump-Media command", "--raw={0}", options.Raw); DicConsole.DebugWriteLine("Dump-Media command", "--stop-on-error={0}", options.StopOnError); DicConsole.DebugWriteLine("Dump-Media command", "--force={0}", options.Force); DicConsole.DebugWriteLine("Dump-Media command", "--retry-passes={0}", options.RetryPasses); @@ -205,7 +206,7 @@ namespace DiscImageChef.Commands switch(dev.Type) { case DeviceType.ATA: - Ata.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, options.Raw, + Ata.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, false, /*options.Raw,*/ options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar, (uint)options.Skip, options.NoMetadata, options.NoTrim); @@ -213,19 +214,19 @@ namespace DiscImageChef.Commands case DeviceType.MMC: case DeviceType.SecureDigital: SecureDigital.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, - options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog, + false, /*options.Raw,*/ options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar, (uint)options.Skip, options.NoMetadata, options.NoTrim); break; case DeviceType.NVMe: - NvMe.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, options.Raw, + NvMe.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, false, /*options.Raw,*/ options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar, (uint)options.Skip, options.NoMetadata, options.NoTrim); break; case DeviceType.ATAPI: case DeviceType.SCSI: - Scsi.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, options.Raw, + Scsi.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, false, /*options.Raw,*/ options.Persistent, options.StopOnError, ref resume, ref dumpLog, options.LeadIn, encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar, (uint)options.Skip, options.NoMetadata, options.NoTrim); diff --git a/DiscImageChef/Commands/ExtractFiles.cs b/DiscImageChef/Commands/ExtractFiles.cs index 55d90723..b7a561a1 100644 --- a/DiscImageChef/Commands/ExtractFiles.cs +++ b/DiscImageChef/Commands/ExtractFiles.cs @@ -172,28 +172,23 @@ namespace DiscImageChef.Commands error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions); if(error == Errno.NoError) { - List rootDir = new List(); - error = fs.ReadDir("/", out rootDir); + error = fs.ReadDir("/", out List rootDir); if(error == Errno.NoError) foreach(string entry in rootDir) { - FileEntryInfo stat = new FileEntryInfo(); - string volumeName = string.IsNullOrEmpty(fs.XmlFsType.VolumeName) ? "NO NAME" : fs.XmlFsType.VolumeName; - error = fs.Stat(entry, out stat); + error = fs.Stat(entry, out FileEntryInfo stat); if(error == Errno.NoError) { string outputPath; FileStream outputFile; if(options.Xattrs) { - List xattrs = new List(); - - error = fs.ListXAttr(entry, out xattrs); + error = fs.ListXAttr(entry, out List xattrs); if(error == Errno.NoError) foreach(string xattr in xattrs) { @@ -328,28 +323,23 @@ namespace DiscImageChef.Commands error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions); if(error == Errno.NoError) { - List rootDir = new List(); - error = fs.ReadDir("/", out rootDir); + error = fs.ReadDir("/", out List rootDir); if(error == Errno.NoError) foreach(string entry in rootDir) { - FileEntryInfo stat = new FileEntryInfo(); - string volumeName = string.IsNullOrEmpty(fs.XmlFsType.VolumeName) ? "NO NAME" : fs.XmlFsType.VolumeName; - error = fs.Stat(entry, out stat); + error = fs.Stat(entry, out FileEntryInfo stat); if(error == Errno.NoError) { FileStream outputFile; string outputPath; if(options.Xattrs) { - List xattrs = new List(); - - error = fs.ListXAttr(entry, out xattrs); + error = fs.ListXAttr(entry, out List xattrs); if(error == Errno.NoError) foreach(string xattr in xattrs) { @@ -489,28 +479,23 @@ namespace DiscImageChef.Commands error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions); if(error == Errno.NoError) { - List rootDir = new List(); - error = fs.ReadDir("/", out rootDir); + error = fs.ReadDir("/", out List rootDir); if(error == Errno.NoError) foreach(string entry in rootDir) { - FileEntryInfo stat = new FileEntryInfo(); - string volumeName = string.IsNullOrEmpty(fs.XmlFsType.VolumeName) ? "NO NAME" : fs.XmlFsType.VolumeName; - error = fs.Stat(entry, out stat); + error = fs.Stat(entry, out FileEntryInfo stat); if(error == Errno.NoError) { FileStream outputFile; string outputPath; if(options.Xattrs) { - List xattrs = new List(); - - error = fs.ListXAttr(entry, out xattrs); + error = fs.ListXAttr(entry, out List xattrs); if(error == Errno.NoError) foreach(string xattr in xattrs) { @@ -634,27 +619,22 @@ namespace DiscImageChef.Commands error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions); if(error == Errno.NoError) { - List rootDir = new List(); - error = fs.ReadDir("/", out rootDir); + error = fs.ReadDir("/", out List rootDir); if(error == Errno.NoError) foreach(string entry in rootDir) { - FileEntryInfo stat = new FileEntryInfo(); - string volumeName = string.IsNullOrEmpty(fs.XmlFsType.VolumeName) ? "NO NAME" : fs.XmlFsType.VolumeName; - error = fs.Stat(entry, out stat); + error = fs.Stat(entry, out FileEntryInfo stat); if(error == Errno.NoError) { string outputPath; FileStream outputFile; if(options.Xattrs) { - List xattrs = new List(); - - error = fs.ListXAttr(entry, out xattrs); + error = fs.ListXAttr(entry, out List xattrs); if(error == Errno.NoError) foreach(string xattr in xattrs) { diff --git a/DiscImageChef/Commands/Ls.cs b/DiscImageChef/Commands/Ls.cs index 1326d5c4..07d56849 100644 --- a/DiscImageChef/Commands/Ls.cs +++ b/DiscImageChef/Commands/Ls.cs @@ -161,8 +161,7 @@ namespace DiscImageChef.Commands error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions); if(error == Errno.NoError) { - List rootDir = new List(); - error = fs.ReadDir("/", out rootDir); + error = fs.ReadDir("/", out List rootDir); if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); @@ -191,8 +190,7 @@ namespace DiscImageChef.Commands error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions); if(error == Errno.NoError) { - List rootDir = new List(); - error = fs.ReadDir("/", out rootDir); + error = fs.ReadDir("/", out List rootDir); if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); @@ -231,8 +229,7 @@ namespace DiscImageChef.Commands error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions); if(error == Errno.NoError) { - List rootDir = new List(); - error = fs.ReadDir("/", out rootDir); + error = fs.ReadDir("/", out List rootDir); if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); @@ -258,22 +255,18 @@ namespace DiscImageChef.Commands error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions); if(error == Errno.NoError) { - List rootDir = new List(); - error = fs.ReadDir("/", out rootDir); + error = fs.ReadDir("/", out List rootDir); if(error == Errno.NoError) foreach(string entry in rootDir) if(options.Long) { - FileEntryInfo stat = new FileEntryInfo(); - List xattrs = new List(); - - error = fs.Stat(entry, out stat); + error = fs.Stat(entry, out FileEntryInfo stat); if(error == Errno.NoError) { DicConsole.WriteLine("{0}\t{1}\t{2} bytes\t{3}", stat.CreationTimeUtc, stat.Inode, stat.Length, entry); - error = fs.ListXAttr(entry, out xattrs); + error = fs.ListXAttr(entry, out List xattrs); if(error != Errno.NoError) continue; foreach(string xattr in xattrs) diff --git a/DiscImageChef/Commands/MediaInfo.cs b/DiscImageChef/Commands/MediaInfo.cs index ff74c7a6..b7f1b643 100644 --- a/DiscImageChef/Commands/MediaInfo.cs +++ b/DiscImageChef/Commands/MediaInfo.cs @@ -1283,12 +1283,10 @@ namespace DiscImageChef.Commands case MediaType.XGD2: case MediaType.XGD3: // We need to get INQUIRY to know if it is a Kreon drive - Inquiry.SCSIInquiry? inq; - sense = dev.ScsiInquiry(out byte[] inqBuffer, out senseBuf); if(!sense) { - inq = Inquiry.Decode(inqBuffer); + Inquiry.SCSIInquiry? inq = Inquiry.Decode(inqBuffer); if(inq.HasValue && inq.Value.KreonPresent) { sense = dev.KreonExtractSs(out cmdBuf, out senseBuf, dev.Timeout, out _); @@ -1302,8 +1300,6 @@ namespace DiscImageChef.Commands if(SS.Decode(cmdBuf).HasValue) DicConsole.WriteLine("Xbox Security Sector:\n{0}", SS.Prettify(cmdBuf)); - ulong l0Video, l1Video, middleZone, gameSize, totalSize, layerBreak; - // Get video partition size DicConsole.DebugWriteLine("Dump-media command", "Getting video partition size"); sense = dev.KreonLock(out senseBuf, dev.Timeout, out _); @@ -1320,7 +1316,7 @@ namespace DiscImageChef.Commands return; } - totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]); + ulong totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]); sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _); if(sense) @@ -1331,9 +1327,9 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Dump-media command", "Video partition total size: {0} sectors", totalSize); - l0Video = PFI.Decode(cmdBuf).Value.Layer0EndPSN - - PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1; - l1Video = totalSize - l0Video + 1; + ulong l0Video = PFI.Decode(cmdBuf).Value.Layer0EndPSN - + PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1; + ulong l1Video = totalSize - l0Video + 1; // Get game partition size DicConsole.DebugWriteLine("Dump-media command", "Getting game partition size"); @@ -1351,8 +1347,8 @@ namespace DiscImageChef.Commands return; } - gameSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) + - 1; + ulong gameSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) + + 1; DicConsole.DebugWriteLine("Dump-media command", "Game partition total size: {0} sectors", gameSize); @@ -1383,13 +1379,12 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors", totalSize); - middleZone = - totalSize - - (PFI.Decode(cmdBuf).Value.Layer0EndPSN - - PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1) - gameSize + 1; + ulong middleZone = totalSize - + (PFI.Decode(cmdBuf).Value.Layer0EndPSN - + PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1) - gameSize + 1; totalSize = l0Video + l1Video + middleZone * 2 + gameSize; - layerBreak = l0Video + middleZone + gameSize / 2; + ulong layerBreak = l0Video + middleZone + gameSize / 2; DicConsole.WriteLine("Video layer 0 size: {0} sectors", l0Video); DicConsole.WriteLine("Video layer 1 size: {0} sectors", l1Video); diff --git a/DiscImageChef/Options.cs b/DiscImageChef/Options.cs index 38faebf3..9bcdefe8 100644 --- a/DiscImageChef/Options.cs +++ b/DiscImageChef/Options.cs @@ -267,9 +267,10 @@ namespace DiscImageChef [Option('i', "device", Required = true, HelpText = "Device path.")] public string DevicePath { get; set; } - [Option('r', "raw", Default = false, + // TODO: Disabled temporarily +/* [Option('r', "raw", Default = false, HelpText = "Dump sectors with tags included. For optical media, dump scrambled sectors")] - public bool Raw { get; set; } + public bool Raw { get; set; }*/ [Option('s', "stop-on-error", Default = false, HelpText = "Stop media dump on first error.")] public bool StopOnError { get; set; }