From 19d7d0b460e8269de32f05251706f64020dc032e Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 8 Jun 2014 00:43:49 +0100 Subject: [PATCH] * FileSystemIDandChk/Main.cs: partitionOffset should be the sector, not the byte * FileSystemIDandChk/PartPlugins/MBR.cs: Corrected typos on field offsets * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: Corrected typo * FileSystemIDandChk/Plugins/ext2FS.cs: Superblock block_size is shift of base block size (1024 bytes) --- FileSystemIDandChk/Main.cs | 10 ++++---- FileSystemIDandChk/PartPlugins/MBR.cs | 36 +++++++++++++-------------- FileSystemIDandChk/Plugins/FAT.cs | 2 +- FileSystemIDandChk/Plugins/ISO9660.cs | 1 - FileSystemIDandChk/Plugins/ext2FS.cs | 2 +- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/FileSystemIDandChk/Main.cs b/FileSystemIDandChk/Main.cs index 0d3a758e..8771f5cb 100644 --- a/FileSystemIDandChk/Main.cs +++ b/FileSystemIDandChk/Main.cs @@ -249,8 +249,8 @@ namespace FileSystemIDandChk Console.WriteLine("Partition {0}:", partitions[i].PartitionSequence); Console.WriteLine("Partition name: {0}", partitions[i].PartitionName); Console.WriteLine("Partition type: {0}", partitions[i].PartitionType); - Console.WriteLine("Partition start: {0}", partitions[i].PartitionStart); - Console.WriteLine("Partition length: {0}", partitions[i].PartitionLength); + Console.WriteLine("Partition start: sector {0}, byte {1}", partitions[i].PartitionStartSector, partitions[i].PartitionStart); + Console.WriteLine("Partition length: {0} sectors, {1} bytes", partitions[i].PartitionSectors, partitions[i].PartitionLength); Console.WriteLine("Partition description:"); Console.WriteLine(partitions[i].PartitionDescription); @@ -258,7 +258,7 @@ namespace FileSystemIDandChk { Console.WriteLine("Identifying filesystem on partition"); - Identify(_imageFormat, out id_plugins, partitions[i].PartitionStart); + Identify(_imageFormat, out id_plugins, partitions[i].PartitionStartSector); if (id_plugins.Count == 0) Console.WriteLine("Filesystem not identified"); else if (id_plugins.Count > 1) @@ -270,7 +270,7 @@ namespace FileSystemIDandChk if (plugins.PluginsList.TryGetValue(plugin_name, out _plugin)) { Console.WriteLine(String.Format("As identified by {0}.", _plugin.Name)); - _plugin.GetInformation(_imageFormat, partitions[i].PartitionStart, out information); + _plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, out information); Console.Write(information); } } @@ -279,7 +279,7 @@ namespace FileSystemIDandChk { plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin); Console.WriteLine(String.Format("Identified by {0}.", _plugin.Name)); - _plugin.GetInformation(_imageFormat, partitions[i].PartitionStart, out information); + _plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, out information); Console.Write(information); } } diff --git a/FileSystemIDandChk/PartPlugins/MBR.cs b/FileSystemIDandChk/PartPlugins/MBR.cs index 42b682c8..fe8de6a7 100644 --- a/FileSystemIDandChk/PartPlugins/MBR.cs +++ b/FileSystemIDandChk/PartPlugins/MBR.cs @@ -76,25 +76,25 @@ namespace FileSystemIDandChk.PartPlugins MBRPartitionEntry entry = new MBRPartitionEntry(); entry.status = sector[0x1BE + 16 * i + 0x00]; - entry.start_head = sector[0x1BE + 16 * i + 0x00]; + entry.start_head = sector[0x1BE + 16 * i + 0x01]; - cyl_sect1 = sector[0x1BE + 16 * i + 0x00]; - cyl_sect2 = sector[0x1BE + 16 * i + 0x00]; + cyl_sect1 = sector[0x1BE + 16 * i + 0x02]; + cyl_sect2 = sector[0x1BE + 16 * i + 0x03]; entry.start_sector = (byte)(cyl_sect1 & 0x3F); entry.start_cylinder = (ushort)(((cyl_sect1 & 0xC0) << 2) | cyl_sect2); - entry.type = sector[0x1BE + 16 * i + 0x00]; - entry.end_head = sector[0x1BE + 16 * i + 0x00]; + entry.type = sector[0x1BE + 16 * i + 0x04]; + entry.end_head = sector[0x1BE + 16 * i + 0x05]; - cyl_sect1 = sector[0x1BE + 16 * i + 0x00]; - cyl_sect2 = sector[0x1BE + 16 * i + 0x00]; + cyl_sect1 = sector[0x1BE + 16 * i + 0x06]; + cyl_sect2 = sector[0x1BE + 16 * i + 0x07]; entry.end_sector = (byte)(cyl_sect1 & 0x3F); entry.end_cylinder = (ushort)(((cyl_sect1 & 0xC0) << 2) | cyl_sect2); - entry.lba_start = BitConverter.ToUInt32(sector, 0x1BE + 16 * i + 0x00); - entry.lba_sectors = BitConverter.ToUInt32(sector, 0x1BE + 16 * i + 0x00); + entry.lba_start = BitConverter.ToUInt32(sector, 0x1BE + 16 * i + 0x08); + entry.lba_sectors = BitConverter.ToUInt32(sector, 0x1BE + 16 * i + 0x0C); // Let's start the fun... @@ -396,25 +396,25 @@ namespace FileSystemIDandChk.PartPlugins MBRPartitionEntry entry2 = new MBRPartitionEntry(); entry2.status = sector[0x1BE + 16 * i + 0x00]; - entry2.start_head = sector[0x1BE + 16 * i + 0x00]; + entry2.start_head = sector[0x1BE + 16 * i + 0x01]; - cyl_sect1 = sector[0x1BE + 16 * i + 0x00]; - cyl_sect2 = sector[0x1BE + 16 * i + 0x00]; + cyl_sect1 = sector[0x1BE + 16 * i + 0x02]; + cyl_sect2 = sector[0x1BE + 16 * i + 0x03]; entry2.start_sector = (byte)(cyl_sect1 & 0x3F); entry2.start_cylinder = (ushort)(((cyl_sect1 & 0xC0) << 2) | cyl_sect2); - entry2.type = sector[0x1BE + 16 * i + 0x00]; - entry2.end_head = sector[0x1BE + 16 * i + 0x00]; + entry2.type = sector[0x1BE + 16 * i + 0x04]; + entry2.end_head = sector[0x1BE + 16 * i + 0x05]; - cyl_sect1 = sector[0x1BE + 16 * i + 0x00]; - cyl_sect2 = sector[0x1BE + 16 * i + 0x00]; + cyl_sect1 = sector[0x1BE + 16 * i + 0x06]; + cyl_sect2 = sector[0x1BE + 16 * i + 0x07]; entry2.end_sector = (byte)(cyl_sect1 & 0x3F); entry2.end_cylinder = (ushort)(((cyl_sect1 & 0xC0) << 2) | cyl_sect2); - entry2.lba_start = BitConverter.ToUInt32(sector, 0x1BE + 16 * i + 0x00); - entry2.lba_sectors = BitConverter.ToUInt32(sector, 0x1BE + 16 * i + 0x00); + entry2.lba_start = BitConverter.ToUInt32(sector, 0x1BE + 16 * i + 0x08); + entry2.lba_sectors = BitConverter.ToUInt32(sector, 0x1BE + 16 * i + 0x0C); // Let's start the fun... diff --git a/FileSystemIDandChk/Plugins/FAT.cs b/FileSystemIDandChk/Plugins/FAT.cs index 10998eb0..94e54ae6 100644 --- a/FileSystemIDandChk/Plugins/FAT.cs +++ b/FileSystemIDandChk/Plugins/FAT.cs @@ -287,7 +287,7 @@ namespace FileSystemIDandChk.Plugins sb.AppendFormat("{0} sectors per cluster.", BPB.spc).AppendLine(); sb.AppendFormat("{0} sectors reserved between BPB and FAT.", BPB.rsectors).AppendLine(); sb.AppendFormat("{0} FATs.", BPB.fats_no).AppendLine(); - sb.AppendFormat("{0} entires on root directory.", BPB.root_ent).AppendLine(); + sb.AppendFormat("{0} entries on root directory.", BPB.root_ent).AppendLine(); if (BPB.sectors == 0) sb.AppendFormat("{0} sectors on volume ({1} bytes).", BPB.big_sectors, BPB.big_sectors * BPB.bps).AppendLine(); else diff --git a/FileSystemIDandChk/Plugins/ISO9660.cs b/FileSystemIDandChk/Plugins/ISO9660.cs index cdaf4a4c..6cab35e5 100644 --- a/FileSystemIDandChk/Plugins/ISO9660.cs +++ b/FileSystemIDandChk/Plugins/ISO9660.cs @@ -45,7 +45,6 @@ using FileSystemIDandChk; // TODO: Differentiate ISO Level 1, 2, 3 and ISO 9660:1999 // TODO: Apple extensiones, requires XA or advance RR interpretation. // TODO: Needs a major rewrite - namespace FileSystemIDandChk.Plugins { class ISO9660Plugin : Plugin diff --git a/FileSystemIDandChk/Plugins/ext2FS.cs b/FileSystemIDandChk/Plugins/ext2FS.cs index c1376565..0075a316 100644 --- a/FileSystemIDandChk/Plugins/ext2FS.cs +++ b/FileSystemIDandChk/Plugins/ext2FS.cs @@ -339,7 +339,7 @@ namespace FileSystemIDandChk.Plugins if (supblk.block_size == 0) // Then it is 1024 bytes supblk.block_size = 1024; - sb.AppendFormat("Volume has {0} blocks of {1} bytes, for a total of {2} bytes", blocks, supblk.block_size, blocks * supblk.block_size).AppendLine(); + sb.AppendFormat("Volume has {0} blocks of {1} bytes, for a total of {2} bytes", blocks, 1024<<(int)supblk.block_size, blocks * (ulong)(1024<<(int)supblk.block_size)).AppendLine(); if (supblk.mount_t > 0 || supblk.mount_c > 0) { if (supblk.mount_t > 0)