From 6694c212924597182ca025609689dfa51e4ed5ed Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 3 Aug 2017 01:15:11 +0100 Subject: [PATCH] Corrected detection of valid partitions. --- DiscImageChef.Partitions/PC98.cs | 37 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/DiscImageChef.Partitions/PC98.cs b/DiscImageChef.Partitions/PC98.cs index 333be410d..33e2ee1f3 100644 --- a/DiscImageChef.Partitions/PC98.cs +++ b/DiscImageChef.Partitions/PC98.cs @@ -46,7 +46,7 @@ namespace DiscImageChef.PartPlugins public PC98() { - Name = "NEC PC-9800 partitions table"; + Name = "NEC PC-9800 partition table"; PluginUUID = new Guid("27333401-C7C2-447D-961C-22AD0641A09A\n"); } @@ -84,28 +84,33 @@ namespace DiscImageChef.PartPlugins DicConsole.DebugWriteLine("PC98 plugin", "entry.dp_ecyl = {0}", entry.dp_ecyl); DicConsole.DebugWriteLine("PC98 plugin", "entry.dp_name = \"{0}\"", StringHandlers.CToString(entry.dp_name, Encoding.GetEncoding(932))); - if(entry.dp_ssect != entry.dp_esect && - entry.dp_shd != entry.dp_ehd && - entry.dp_scyl != entry.dp_ecyl && + if(entry.dp_scyl != entry.dp_ecyl && entry.dp_ecyl > 0) { Partition part = new Partition { - Start = Helpers.CHS.ToLBA(entry.dp_scyl, entry.dp_shd, entry.dp_ssect, imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack), - Type = string.Format("{0}", (entry.dp_sid << 8) | entry.dp_mid), - Name = StringHandlers.CToString(entry.dp_name, Encoding.GetEncoding(932)), + Start = Helpers.CHS.ToLBA(entry.dp_scyl, entry.dp_shd, (uint)(entry.dp_ssect + 1), imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack), + Type = string.Format("{0}", ((entry.dp_sid & 0x7F) << 8) | (entry.dp_mid & 0x7F)), + Name = StringHandlers.CToString(entry.dp_name, Encoding.GetEncoding(932)).Trim(), Sequence = counter, Scheme = Name }; part.Offset = part.Start * imagePlugin.GetSectorSize(); - part.Length = Helpers.CHS.ToLBA(entry.dp_ecyl, entry.dp_ehd, entry.dp_esect, imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack) - part.Start; + part.Length = Helpers.CHS.ToLBA(entry.dp_ecyl, entry.dp_ehd, (uint)(entry.dp_esect + 1), imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack) - part.Start; part.Size = part.Length * imagePlugin.GetSectorSize(); - if((entry.dp_sid & 0x7F) == 0x44 && - (entry.dp_mid & 0x7F) == 0x14 && - part.Start < imagePlugin.ImageInfo.sectors && - part.Length + part.Start <= imagePlugin.ImageInfo.sectors) + DicConsole.DebugWriteLine("PC98 plugin", "part.Start = {0}", part.Start); + DicConsole.DebugWriteLine("PC98 plugin", "part.Type = {0}", part.Type); + DicConsole.DebugWriteLine("PC98 plugin", "part.Name = {0}", part.Name); + DicConsole.DebugWriteLine("PC98 plugin", "part.Sequence = {0}", part.Sequence); + DicConsole.DebugWriteLine("PC98 plugin", "part.Offset = {0}", part.Offset); + DicConsole.DebugWriteLine("PC98 plugin", "part.Length = {0}", part.Length); + DicConsole.DebugWriteLine("PC98 plugin", "part.Size = {0}", part.Size); + + + if(part.Start < imagePlugin.ImageInfo.sectors && + part.End <= imagePlugin.ImageInfo.sectors) { partitions.Add(part); counter++; @@ -126,7 +131,15 @@ namespace DiscImageChef.PartPlugins [StructLayout(LayoutKind.Sequential, Pack = 1)] struct PC98Partition { + /// + /// Some ID, if 0x80 bit is set, it is bootable + /// 386BSD sets it to 0x14 + /// public byte dp_mid; + /// + /// Some ID, if 0x80 bit is set, it is active + /// 386BSD sets it to 0x44 + /// public byte dp_sid; public byte dp_dum1; public byte dp_dum2;