From 59799daccfc0e30de5505237d9b16f8f9d79c076 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 13 Sep 2016 14:52:31 +0100 Subject: [PATCH] * DiscImageChef.Filters/PCExchange.cs: Removed debug messages. * DiscImageChef.Filesystems/FAT.cs: Corrected syntax bug. * DiscImageChef.Filters/Filters.cs: Corrected handling of "No filter". * DiscImageChef.Filesystems/AmigaDOS.cs: Corrected detection of FFS on hard disks and FFS with block sizes > sector size. --- DiscImageChef.Filesystems/AmigaDOS.cs | 45 ++++++++++++++++++++++++--- DiscImageChef.Filesystems/FAT.cs | 2 +- DiscImageChef.Filters/Filters.cs | 9 +++++- DiscImageChef.Filters/PCExchange.cs | 10 ------ 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/DiscImageChef.Filesystems/AmigaDOS.cs b/DiscImageChef.Filesystems/AmigaDOS.cs index 030568ef..a15e0221 100644 --- a/DiscImageChef.Filesystems/AmigaDOS.cs +++ b/DiscImageChef.Filesystems/AmigaDOS.cs @@ -200,9 +200,14 @@ namespace DiscImageChef.Filesystems ulong root_ptr = BigEndianBitConverter.ToUInt32(sector, 0x08); DicConsole.DebugWriteLine("AmigaDOS plugin", "Bootblock points to {0} as Rootblock", root_ptr); - root_ptr = (partitionEnd - partitionStart) / 2 + partitionStart + 1; + if(root_ptr == 0) + { + root_ptr = (partitionEnd - partitionStart) / 2 + partitionStart; - DicConsole.DebugWriteLine("AmigaDOS plugin", "Nonetheless, going to block {0} for Rootblock", root_ptr); + DicConsole.DebugWriteLine("AmigaDOS plugin", "Nonetheless, going to block {0} for Rootblock", root_ptr); + } + else + root_ptr += partitionStart; if(root_ptr >= partitionEnd) return false; @@ -212,8 +217,15 @@ namespace DiscImageChef.Filesystems uint type = BigEndianBitConverter.ToUInt32(sector, 0x00); uint hashTableSize = BigEndianBitConverter.ToUInt32(sector, 0x0C); - if((0x18 + hashTableSize * 4 + 196) > sector.Length) - return false; + uint blockSize = 0x18 + hashTableSize * 4 + 196; + uint sectorsPerBlock = (uint)(blockSize / sector.Length); + if(blockSize % sector.Length > 0) + sectorsPerBlock++; + + sector = imagePlugin.ReadSectors(root_ptr, sectorsPerBlock); + + //if((0x18 + hashTableSize * 4 + 196) > sector.Length) + // return false; uint sec_type = BigEndianBitConverter.ToUInt32(sector, (int)(0x18 + hashTableSize * 4 + 196)); @@ -225,7 +237,30 @@ namespace DiscImageChef.Filesystems StringBuilder sbInformation = new StringBuilder(); byte[] BootBlockSectors = imagePlugin.ReadSectors(0 + partitionStart, 2); - byte[] RootBlockSector = imagePlugin.ReadSector((partitionEnd - partitionStart) / 2 + partitionStart + 1); + + ulong root_ptr = BigEndianBitConverter.ToUInt32(BootBlockSectors, 0x08); + DicConsole.DebugWriteLine("AmigaDOS plugin", "Bootblock points to {0} as Rootblock", root_ptr); + + if(root_ptr == 0) + { + root_ptr = (partitionEnd - partitionStart) / 2 + partitionStart; + + DicConsole.DebugWriteLine("AmigaDOS plugin", "Nonetheless, going to block {0} for Rootblock", root_ptr); + } + else + root_ptr += partitionStart; + + byte[] RootBlockSector = imagePlugin.ReadSector(root_ptr); + + uint hashTableSize = BigEndianBitConverter.ToUInt32(RootBlockSector, 0x0C); + + uint blockSize = 0x18 + hashTableSize * 4 + 196; + uint sectorsPerBlock = (uint)(blockSize / RootBlockSector.Length); + if(blockSize % RootBlockSector.Length > 0) + sectorsPerBlock++; + + RootBlockSector = imagePlugin.ReadSectors(root_ptr, sectorsPerBlock); + byte[] diskName = new byte[32]; BootBlock bootBlk = new BootBlock(); diff --git a/DiscImageChef.Filesystems/FAT.cs b/DiscImageChef.Filesystems/FAT.cs index 75591da8..f0d4a0d5 100644 --- a/DiscImageChef.Filesystems/FAT.cs +++ b/DiscImageChef.Filesystems/FAT.cs @@ -216,7 +216,7 @@ namespace DiscImageChef.Filesystems if(fat32_signature == "FAT32 ") { // TODO: Check with a real FAT+ to see where the version is set - if(bpb_sector[0x2A] == 1 || (bpb_sector[0x2B] == 1) + if(bpb_sector[0x2A] == 1 || bpb_sector[0x2B] == 1) { sb.AppendLine("FAT+"); // Seems easy, check reading xmlFSType.Type = "FAT+"; diff --git a/DiscImageChef.Filters/Filters.cs b/DiscImageChef.Filters/Filters.cs index fec045e6..966e2526 100644 --- a/DiscImageChef.Filters/Filters.cs +++ b/DiscImageChef.Filters/Filters.cs @@ -73,7 +73,6 @@ namespace DiscImageChef.Filters { if(filter.UUID != new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) { - System.Console.WriteLine("Trying filter {0}", filter.Name); if(filter.Identify(path)) { Filter foundFilter = (Filter)filter.GetType().GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); @@ -87,6 +86,14 @@ namespace DiscImageChef.Filters noFilter = filter; } + if(noFilter.Identify(path)) + { + noFilter.Open(path); + + if(noFilter.IsOpened()) + return noFilter; + } + return noFilter; } diff --git a/DiscImageChef.Filters/PCExchange.cs b/DiscImageChef.Filters/PCExchange.cs index 36e2b71b..2e8b734f 100644 --- a/DiscImageChef.Filters/PCExchange.cs +++ b/DiscImageChef.Filters/PCExchange.cs @@ -189,7 +189,6 @@ namespace DiscImageChef.Filters public override bool Identify(byte[] buffer) { - System.Console.WriteLine("parentFolder"); return false; } @@ -201,11 +200,8 @@ namespace DiscImageChef.Filters public override bool Identify(string path) { - System.Console.WriteLine("parentFolder"); string parentFolder = Path.GetDirectoryName(path); - System.Console.WriteLine("parentFolder {0}", parentFolder); - if(!File.Exists(Path.Combine(parentFolder, FinderInfo))) return false; @@ -314,12 +310,6 @@ namespace DiscImageChef.Filters dataLen = new FileInfo(dataPath).Length; rsrcLen = new FileInfo(rsrcPath).Length; - System.Console.WriteLine("dataPath = {0}", dataPath); - System.Console.WriteLine("rsrcPath = {0}", rsrcPath); - System.Console.WriteLine("dataLen = {0}", dataLen); - System.Console.WriteLine("rsrcLen = {0}", rsrcLen); - System.Console.WriteLine("basePath = {0}", basePath); - basePath = path; opened = true; }