Files
Aaru/DiscImageChef.Filesystems/HPFS.cs

400 lines
21 KiB
C#
Raw Normal View History

/***************************************************************************
The Disc Image Chef
----------------------------------------------------------------------------
Filename : HPFS.cs
Version : 1.0
Author(s) : Natalia Portillo
Component : Filesystem plugins
Revision : $Revision$
Last change by : $Author$
Date : $Date$
--[ Description ] ----------------------------------------------------------
Identifies OS/2 HPFS filesystems and shows information.
No pinball playing allowed.
--[ License ] --------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
Copyright (C) 2011-2014 Claunia.com
****************************************************************************/
//$Id$
using System;
using System.Text;
using DiscImageChef;
// Information from an old unnamed document
namespace DiscImageChef.Plugins
{
class HPFS : Plugin
{
public HPFS()
{
Name = "OS/2 High Performance File System";
PluginUUID = new Guid("33513B2C-f590-4acb-8bf2-0b1d5e19dec5");
}
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd)
{
2016-04-19 02:11:47 +01:00
if((2 + partitionStart) >= imagePlugin.GetSectors())
2014-07-09 19:49:14 +01:00
return false;
UInt32 magic1, magic2;
2016-04-19 02:11:47 +01:00
byte[] hpfs_sb_sector = imagePlugin.ReadSector(16 + partitionStart); // Seek to superblock, on logical sector 16
* FileSystemIDandChk/BigEndianBitConverter.cs: Added BitConverter for BigEndian * FileSystemIDandChk/FileSystemIDandChk.csproj: FileSystemIDandChk/BigEndianBitConverter.cs * FileSystemIDandChk/ImagePlugins/CDRWin.cs: Corrected parsing Implemented all ImagePlugin methods * FileSystemIDandChk/ImagePlugins/ImagePlugin.cs: Used document auto formatting * FileSystemIDandChk/Main.cs: * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/FFS.cs: * FileSystemIDandChk/Plugins/ODS.cs: * FileSystemIDandChk/Plugins/HPFS.cs: * FileSystemIDandChk/Plugins/SysV.cs: * FileSystemIDandChk/Plugins/NTFS.cs: * FileSystemIDandChk/Plugins/extFS.cs: * FileSystemIDandChk/Plugins/Opera.cs: * FileSystemIDandChk/Plugins/ext2FS.cs: * FileSystemIDandChk/Plugins/Plugin.cs: * FileSystemIDandChk/Plugins/UNIXBFS.cs: * FileSystemIDandChk/Plugins/SolarFS.cs: * FileSystemIDandChk/PartPlugins/MBR.cs: * FileSystemIDandChk/Plugins/MinixFS.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: * FileSystemIDandChk/Plugins/PCEngine.cs: * FileSystemIDandChk/Plugins/AppleHFS.cs: * FileSystemIDandChk/PartPlugins/NeXT.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/PartPlugins/AppleMap.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Added support for disc image plugins * FileSystemIDandChk/PartPlugins/PartPlugin.cs: Added support for disc image plugins Added start sector and length in sectors to partitions * FileSystemIDandChk/Plugins/Symbian.cs: Commented til code is adapted for disc image plugins git-svn-id: svn://claunia.com/FileSystemIDandChk@27 17725271-3d32-4980-a8cb-9ff532f270ba
2014-04-14 01:14:20 +00:00
magic1 = BitConverter.ToUInt32(hpfs_sb_sector, 0x000);
magic2 = BitConverter.ToUInt32(hpfs_sb_sector, 0x004);
2016-04-19 02:11:47 +01:00
if(magic1 == 0xF995E849 && magic2 == 0xFA53E9C5)
return true;
return false;
}
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, out string information)
{
information = "";
2016-04-19 02:11:47 +01:00
StringBuilder sb = new StringBuilder();
2016-04-19 02:11:47 +01:00
HPFS_BIOSParameterBlock hpfs_bpb = new HPFS_BIOSParameterBlock();
HPFS_SuperBlock hpfs_sb = new HPFS_SuperBlock();
HPFS_SpareBlock hpfs_sp = new HPFS_SpareBlock();
2016-04-19 02:11:47 +01:00
byte[] oem_name = new byte[8];
byte[] volume_name = new byte[11];
2016-04-19 02:11:47 +01:00
byte[] hpfs_bpb_sector = imagePlugin.ReadSector(0 + partitionStart); // Seek to BIOS parameter block, on logical sector 0
byte[] hpfs_sb_sector = imagePlugin.ReadSector(16 + partitionStart); // Seek to superblock, on logical sector 16
byte[] hpfs_sp_sector = imagePlugin.ReadSector(17 + partitionStart); // Seek to spareblock, on logical sector 17
* FileSystemIDandChk/BigEndianBitConverter.cs: Added BitConverter for BigEndian * FileSystemIDandChk/FileSystemIDandChk.csproj: FileSystemIDandChk/BigEndianBitConverter.cs * FileSystemIDandChk/ImagePlugins/CDRWin.cs: Corrected parsing Implemented all ImagePlugin methods * FileSystemIDandChk/ImagePlugins/ImagePlugin.cs: Used document auto formatting * FileSystemIDandChk/Main.cs: * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/FFS.cs: * FileSystemIDandChk/Plugins/ODS.cs: * FileSystemIDandChk/Plugins/HPFS.cs: * FileSystemIDandChk/Plugins/SysV.cs: * FileSystemIDandChk/Plugins/NTFS.cs: * FileSystemIDandChk/Plugins/extFS.cs: * FileSystemIDandChk/Plugins/Opera.cs: * FileSystemIDandChk/Plugins/ext2FS.cs: * FileSystemIDandChk/Plugins/Plugin.cs: * FileSystemIDandChk/Plugins/UNIXBFS.cs: * FileSystemIDandChk/Plugins/SolarFS.cs: * FileSystemIDandChk/PartPlugins/MBR.cs: * FileSystemIDandChk/Plugins/MinixFS.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: * FileSystemIDandChk/Plugins/PCEngine.cs: * FileSystemIDandChk/Plugins/AppleHFS.cs: * FileSystemIDandChk/PartPlugins/NeXT.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/PartPlugins/AppleMap.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Added support for disc image plugins * FileSystemIDandChk/PartPlugins/PartPlugin.cs: Added support for disc image plugins Added start sector and length in sectors to partitions * FileSystemIDandChk/Plugins/Symbian.cs: Commented til code is adapted for disc image plugins git-svn-id: svn://claunia.com/FileSystemIDandChk@27 17725271-3d32-4980-a8cb-9ff532f270ba
2014-04-14 01:14:20 +00:00
hpfs_bpb.jmp1 = hpfs_bpb_sector[0x000];
hpfs_bpb.jmp2 = BitConverter.ToUInt16(hpfs_bpb_sector, 0x001);
Array.Copy(hpfs_bpb_sector, 0x003, oem_name, 0, 8);
hpfs_bpb.OEMName = StringHandlers.CToString(oem_name);
* FileSystemIDandChk/BigEndianBitConverter.cs: Added BitConverter for BigEndian * FileSystemIDandChk/FileSystemIDandChk.csproj: FileSystemIDandChk/BigEndianBitConverter.cs * FileSystemIDandChk/ImagePlugins/CDRWin.cs: Corrected parsing Implemented all ImagePlugin methods * FileSystemIDandChk/ImagePlugins/ImagePlugin.cs: Used document auto formatting * FileSystemIDandChk/Main.cs: * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/FFS.cs: * FileSystemIDandChk/Plugins/ODS.cs: * FileSystemIDandChk/Plugins/HPFS.cs: * FileSystemIDandChk/Plugins/SysV.cs: * FileSystemIDandChk/Plugins/NTFS.cs: * FileSystemIDandChk/Plugins/extFS.cs: * FileSystemIDandChk/Plugins/Opera.cs: * FileSystemIDandChk/Plugins/ext2FS.cs: * FileSystemIDandChk/Plugins/Plugin.cs: * FileSystemIDandChk/Plugins/UNIXBFS.cs: * FileSystemIDandChk/Plugins/SolarFS.cs: * FileSystemIDandChk/PartPlugins/MBR.cs: * FileSystemIDandChk/Plugins/MinixFS.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: * FileSystemIDandChk/Plugins/PCEngine.cs: * FileSystemIDandChk/Plugins/AppleHFS.cs: * FileSystemIDandChk/PartPlugins/NeXT.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/PartPlugins/AppleMap.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Added support for disc image plugins * FileSystemIDandChk/PartPlugins/PartPlugin.cs: Added support for disc image plugins Added start sector and length in sectors to partitions * FileSystemIDandChk/Plugins/Symbian.cs: Commented til code is adapted for disc image plugins git-svn-id: svn://claunia.com/FileSystemIDandChk@27 17725271-3d32-4980-a8cb-9ff532f270ba
2014-04-14 01:14:20 +00:00
hpfs_bpb.bps = BitConverter.ToUInt16(hpfs_bpb_sector, 0x00B);
hpfs_bpb.spc = hpfs_bpb_sector[0x00D];
hpfs_bpb.rsectors = BitConverter.ToUInt16(hpfs_bpb_sector, 0x00E);
hpfs_bpb.fats_no = hpfs_bpb_sector[0x010];
hpfs_bpb.root_ent = BitConverter.ToUInt16(hpfs_bpb_sector, 0x011);
hpfs_bpb.sectors = BitConverter.ToUInt16(hpfs_bpb_sector, 0x013);
hpfs_bpb.media = hpfs_bpb_sector[0x015];
hpfs_bpb.spfat = BitConverter.ToUInt16(hpfs_bpb_sector, 0x016);
hpfs_bpb.sptrk = BitConverter.ToUInt16(hpfs_bpb_sector, 0x018);
hpfs_bpb.heads = BitConverter.ToUInt16(hpfs_bpb_sector, 0x01A);
hpfs_bpb.hsectors = BitConverter.ToUInt32(hpfs_bpb_sector, 0x01C);
hpfs_bpb.big_sectors = BitConverter.ToUInt32(hpfs_bpb_sector, 0x024);
hpfs_bpb.drive_no = hpfs_bpb_sector[0x028];
hpfs_bpb.nt_flags = hpfs_bpb_sector[0x029];
hpfs_bpb.signature = hpfs_bpb_sector[0x02A];
hpfs_bpb.serial_no = BitConverter.ToUInt32(hpfs_bpb_sector, 0x02B);
Array.Copy(hpfs_bpb_sector, 0x02F, volume_name, 0, 11);
hpfs_bpb.volume_label = StringHandlers.CToString(volume_name);
* FileSystemIDandChk/BigEndianBitConverter.cs: Added BitConverter for BigEndian * FileSystemIDandChk/FileSystemIDandChk.csproj: FileSystemIDandChk/BigEndianBitConverter.cs * FileSystemIDandChk/ImagePlugins/CDRWin.cs: Corrected parsing Implemented all ImagePlugin methods * FileSystemIDandChk/ImagePlugins/ImagePlugin.cs: Used document auto formatting * FileSystemIDandChk/Main.cs: * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/FFS.cs: * FileSystemIDandChk/Plugins/ODS.cs: * FileSystemIDandChk/Plugins/HPFS.cs: * FileSystemIDandChk/Plugins/SysV.cs: * FileSystemIDandChk/Plugins/NTFS.cs: * FileSystemIDandChk/Plugins/extFS.cs: * FileSystemIDandChk/Plugins/Opera.cs: * FileSystemIDandChk/Plugins/ext2FS.cs: * FileSystemIDandChk/Plugins/Plugin.cs: * FileSystemIDandChk/Plugins/UNIXBFS.cs: * FileSystemIDandChk/Plugins/SolarFS.cs: * FileSystemIDandChk/PartPlugins/MBR.cs: * FileSystemIDandChk/Plugins/MinixFS.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: * FileSystemIDandChk/Plugins/PCEngine.cs: * FileSystemIDandChk/Plugins/AppleHFS.cs: * FileSystemIDandChk/PartPlugins/NeXT.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/PartPlugins/AppleMap.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Added support for disc image plugins * FileSystemIDandChk/PartPlugins/PartPlugin.cs: Added support for disc image plugins Added start sector and length in sectors to partitions * FileSystemIDandChk/Plugins/Symbian.cs: Commented til code is adapted for disc image plugins git-svn-id: svn://claunia.com/FileSystemIDandChk@27 17725271-3d32-4980-a8cb-9ff532f270ba
2014-04-14 01:14:20 +00:00
Array.Copy(hpfs_bpb_sector, 0x03A, oem_name, 0, 8);
hpfs_bpb.fs_type = StringHandlers.CToString(oem_name);
2016-04-19 02:11:47 +01:00
hpfs_sb.magic1 = BitConverter.ToUInt32(hpfs_sb_sector, 0x000);
* FileSystemIDandChk/BigEndianBitConverter.cs: Added BitConverter for BigEndian * FileSystemIDandChk/FileSystemIDandChk.csproj: FileSystemIDandChk/BigEndianBitConverter.cs * FileSystemIDandChk/ImagePlugins/CDRWin.cs: Corrected parsing Implemented all ImagePlugin methods * FileSystemIDandChk/ImagePlugins/ImagePlugin.cs: Used document auto formatting * FileSystemIDandChk/Main.cs: * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/FFS.cs: * FileSystemIDandChk/Plugins/ODS.cs: * FileSystemIDandChk/Plugins/HPFS.cs: * FileSystemIDandChk/Plugins/SysV.cs: * FileSystemIDandChk/Plugins/NTFS.cs: * FileSystemIDandChk/Plugins/extFS.cs: * FileSystemIDandChk/Plugins/Opera.cs: * FileSystemIDandChk/Plugins/ext2FS.cs: * FileSystemIDandChk/Plugins/Plugin.cs: * FileSystemIDandChk/Plugins/UNIXBFS.cs: * FileSystemIDandChk/Plugins/SolarFS.cs: * FileSystemIDandChk/PartPlugins/MBR.cs: * FileSystemIDandChk/Plugins/MinixFS.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: * FileSystemIDandChk/Plugins/PCEngine.cs: * FileSystemIDandChk/Plugins/AppleHFS.cs: * FileSystemIDandChk/PartPlugins/NeXT.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/PartPlugins/AppleMap.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Added support for disc image plugins * FileSystemIDandChk/PartPlugins/PartPlugin.cs: Added support for disc image plugins Added start sector and length in sectors to partitions * FileSystemIDandChk/Plugins/Symbian.cs: Commented til code is adapted for disc image plugins git-svn-id: svn://claunia.com/FileSystemIDandChk@27 17725271-3d32-4980-a8cb-9ff532f270ba
2014-04-14 01:14:20 +00:00
hpfs_sb.magic2 = BitConverter.ToUInt32(hpfs_sb_sector, 0x004);
hpfs_sb.version = hpfs_sb_sector[0x008];
hpfs_sb.func_version = hpfs_sb_sector[0x009];
hpfs_sb.dummy = BitConverter.ToUInt16(hpfs_sb_sector, 0x00A);
hpfs_sb.root_fnode = BitConverter.ToUInt32(hpfs_sb_sector, 0x00C);
hpfs_sb.sectors = BitConverter.ToUInt32(hpfs_sb_sector, 0x010);
hpfs_sb.badblocks = BitConverter.ToUInt32(hpfs_sb_sector, 0x014);
hpfs_sb.bitmap_lsn = BitConverter.ToUInt32(hpfs_sb_sector, 0x018);
hpfs_sb.zero1 = BitConverter.ToUInt32(hpfs_sb_sector, 0x01C);
hpfs_sb.badblock_lsn = BitConverter.ToUInt32(hpfs_sb_sector, 0x020);
hpfs_sb.zero2 = BitConverter.ToUInt32(hpfs_sb_sector, 0x024);
hpfs_sb.last_chkdsk = BitConverter.ToInt32(hpfs_sb_sector, 0x028);
hpfs_sb.last_optim = BitConverter.ToInt32(hpfs_sb_sector, 0x02C);
hpfs_sb.dband_sectors = BitConverter.ToUInt32(hpfs_sb_sector, 0x030);
hpfs_sb.dband_start = BitConverter.ToUInt32(hpfs_sb_sector, 0x034);
hpfs_sb.dband_last = BitConverter.ToUInt32(hpfs_sb_sector, 0x038);
hpfs_sb.dband_bitmap = BitConverter.ToUInt32(hpfs_sb_sector, 0x03C);
hpfs_sb.zero3 = BitConverter.ToUInt64(hpfs_sb_sector, 0x040);
hpfs_sb.zero4 = BitConverter.ToUInt64(hpfs_sb_sector, 0x048);
hpfs_sb.zero5 = BitConverter.ToUInt64(hpfs_sb_sector, 0x04C);
hpfs_sb.zero6 = BitConverter.ToUInt64(hpfs_sb_sector, 0x050);
hpfs_sb.acl_start = BitConverter.ToUInt32(hpfs_sb_sector, 0x058);
* FileSystemIDandChk/BigEndianBitConverter.cs: Added BitConverter for BigEndian * FileSystemIDandChk/FileSystemIDandChk.csproj: FileSystemIDandChk/BigEndianBitConverter.cs * FileSystemIDandChk/ImagePlugins/CDRWin.cs: Corrected parsing Implemented all ImagePlugin methods * FileSystemIDandChk/ImagePlugins/ImagePlugin.cs: Used document auto formatting * FileSystemIDandChk/Main.cs: * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/FFS.cs: * FileSystemIDandChk/Plugins/ODS.cs: * FileSystemIDandChk/Plugins/HPFS.cs: * FileSystemIDandChk/Plugins/SysV.cs: * FileSystemIDandChk/Plugins/NTFS.cs: * FileSystemIDandChk/Plugins/extFS.cs: * FileSystemIDandChk/Plugins/Opera.cs: * FileSystemIDandChk/Plugins/ext2FS.cs: * FileSystemIDandChk/Plugins/Plugin.cs: * FileSystemIDandChk/Plugins/UNIXBFS.cs: * FileSystemIDandChk/Plugins/SolarFS.cs: * FileSystemIDandChk/PartPlugins/MBR.cs: * FileSystemIDandChk/Plugins/MinixFS.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: * FileSystemIDandChk/Plugins/PCEngine.cs: * FileSystemIDandChk/Plugins/AppleHFS.cs: * FileSystemIDandChk/PartPlugins/NeXT.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/PartPlugins/AppleMap.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Added support for disc image plugins * FileSystemIDandChk/PartPlugins/PartPlugin.cs: Added support for disc image plugins Added start sector and length in sectors to partitions * FileSystemIDandChk/Plugins/Symbian.cs: Commented til code is adapted for disc image plugins git-svn-id: svn://claunia.com/FileSystemIDandChk@27 17725271-3d32-4980-a8cb-9ff532f270ba
2014-04-14 01:14:20 +00:00
hpfs_sp.magic1 = BitConverter.ToUInt32(hpfs_sp_sector, 0x000);
hpfs_sp.magic2 = BitConverter.ToUInt32(hpfs_sp_sector, 0x004);
hpfs_sp.flags1 = hpfs_sp_sector[0x008];
hpfs_sp.flags2 = hpfs_sp_sector[0x009];
hpfs_sp.dummy = BitConverter.ToUInt16(hpfs_sp_sector, 0x00A);
hpfs_sp.hotfix_start = BitConverter.ToUInt32(hpfs_sp_sector, 0x00C);
hpfs_sp.hotfix_used = BitConverter.ToUInt32(hpfs_sp_sector, 0x010);
hpfs_sp.hotfix_entries = BitConverter.ToUInt32(hpfs_sp_sector, 0x014);
hpfs_sp.spare_dnodes_free = BitConverter.ToUInt32(hpfs_sp_sector, 0x018);
hpfs_sp.spare_dnodes = BitConverter.ToUInt32(hpfs_sp_sector, 0x01C);
hpfs_sp.codepage_lsn = BitConverter.ToUInt32(hpfs_sp_sector, 0x020);
hpfs_sp.codepages = BitConverter.ToUInt32(hpfs_sp_sector, 0x024);
hpfs_sp.sb_crc32 = BitConverter.ToUInt32(hpfs_sp_sector, 0x028);
hpfs_sp.sp_crc32 = BitConverter.ToUInt32(hpfs_sp_sector, 0x02C);
2016-04-19 02:11:47 +01:00
if(hpfs_bpb.fs_type != "HPFS " ||
hpfs_sb.magic1 != 0xF995E849 || hpfs_sb.magic2 != 0xFA53E9C5 ||
hpfs_sp.magic1 != 0xF9911849 || hpfs_sp.magic2 != 0xFA5229C5)
{
sb.AppendLine("This may not be HPFS, following information may be not correct.");
sb.AppendFormat("File system type: \"{0}\" (Should be \"HPFS \")", hpfs_bpb.fs_type).AppendLine();
sb.AppendFormat("Superblock magic1: 0x{0:X8} (Should be 0xF995E849)", hpfs_sb.magic1).AppendLine();
sb.AppendFormat("Superblock magic2: 0x{0:X8} (Should be 0xFA53E9C5)", hpfs_sb.magic2).AppendLine();
sb.AppendFormat("Spareblock magic1: 0x{0:X8} (Should be 0xF9911849)", hpfs_sp.magic1).AppendLine();
sb.AppendFormat("Spareblock magic2: 0x{0:X8} (Should be 0xFA5229C5)", hpfs_sp.magic2).AppendLine();
}
2016-04-19 02:11:47 +01:00
sb.AppendFormat("OEM name: {0}", hpfs_bpb.OEMName).AppendLine();
sb.AppendFormat("{0} bytes per sector", hpfs_bpb.bps).AppendLine();
sb.AppendFormat("{0} sectors per cluster", hpfs_bpb.spc).AppendLine();
2016-04-19 02:11:47 +01:00
// sb.AppendFormat("{0} reserved sectors", hpfs_bpb.rsectors).AppendLine();
// sb.AppendFormat("{0} FATs", hpfs_bpb.fats_no).AppendLine();
// sb.AppendFormat("{0} entries on root directory", hpfs_bpb.root_ent).AppendLine();
// sb.AppendFormat("{0} mini sectors on volume", hpfs_bpb.sectors).AppendLine();
sb.AppendFormat("Media descriptor: 0x{0:X2}", hpfs_bpb.media).AppendLine();
2016-04-19 02:11:47 +01:00
// sb.AppendFormat("{0} sectors per FAT", hpfs_bpb.spfat).AppendLine();
// sb.AppendFormat("{0} sectors per track", hpfs_bpb.sptrk).AppendLine();
// sb.AppendFormat("{0} heads", hpfs_bpb.heads).AppendLine();
sb.AppendFormat("{0} sectors hidden before BPB", hpfs_bpb.hsectors).AppendLine();
sb.AppendFormat("{0} sectors on volume ({1} bytes)", hpfs_bpb.big_sectors, hpfs_bpb.big_sectors * hpfs_bpb.bps).AppendLine();
sb.AppendFormat("BIOS Drive Number: 0x{0:X2}", hpfs_bpb.drive_no).AppendLine();
2016-04-19 02:11:47 +01:00
// sb.AppendFormat("NT Flags: 0x{0:X2}", hpfs_bpb.nt_flags).AppendLine();
sb.AppendFormat("Signature: 0x{0:X2}", hpfs_bpb.signature).AppendLine();
sb.AppendFormat("Serial number: 0x{0:X8}", hpfs_bpb.serial_no).AppendLine();
sb.AppendFormat("Volume label: {0}", hpfs_bpb.volume_label).AppendLine();
2016-04-19 02:11:47 +01:00
// sb.AppendFormat("Filesystem type: \"{0}\"", hpfs_bpb.fs_type).AppendLine();
DateTime last_chk = DateHandlers.UNIXToDateTime(hpfs_sb.last_chkdsk);
DateTime last_optim = DateHandlers.UNIXToDateTime(hpfs_sb.last_optim);
2016-04-19 02:11:47 +01:00
sb.AppendFormat("HPFS version: {0}", hpfs_sb.version).AppendLine();
sb.AppendFormat("Functional version: {0}", hpfs_sb.func_version).AppendLine();
sb.AppendFormat("Sector of root directory FNode: {0}", hpfs_sb.root_fnode).AppendLine();
2016-04-19 02:11:47 +01:00
// sb.AppendFormat("{0} sectors on volume", hpfs_sb.sectors).AppendLine();
sb.AppendFormat("{0} sectors are marked bad", hpfs_sb.badblocks).AppendLine();
sb.AppendFormat("Sector of free space bitmaps: {0}", hpfs_sb.bitmap_lsn).AppendLine();
sb.AppendFormat("Sector of bad blocks list: {0}", hpfs_sb.badblock_lsn).AppendLine();
sb.AppendFormat("Date of last integrity check: {0}", last_chk).AppendLine();
2016-04-19 02:11:47 +01:00
if(hpfs_sb.last_optim > 0)
sb.AppendFormat("Date of last optimization {0}", last_optim).AppendLine();
else
sb.AppendLine("Filesystem has never been optimized");
sb.AppendFormat("Directory band has {0} sectors", hpfs_sb.dband_sectors).AppendLine();
sb.AppendFormat("Directory band starts at sector {0}", hpfs_sb.dband_start).AppendLine();
sb.AppendFormat("Directory band ends at sector {0}", hpfs_sb.dband_last).AppendLine();
sb.AppendFormat("Sector of directory band bitmap: {0}", hpfs_sb.dband_bitmap).AppendLine();
sb.AppendFormat("Sector of ACL directory: {0}", hpfs_sb.acl_start).AppendLine();
2016-04-19 02:11:47 +01:00
sb.AppendFormat("Sector of Hotfix directory: {0}", hpfs_sp.hotfix_start).AppendLine();
sb.AppendFormat("{0} used Hotfix entries", hpfs_sp.hotfix_used).AppendLine();
sb.AppendFormat("{0} total Hotfix entries", hpfs_sp.hotfix_entries).AppendLine();
sb.AppendFormat("{0} free spare DNodes", hpfs_sp.spare_dnodes_free).AppendLine();
sb.AppendFormat("{0} total spare DNodes", hpfs_sp.spare_dnodes).AppendLine();
sb.AppendFormat("Sector of codepage directory: {0}", hpfs_sp.codepage_lsn).AppendLine();
sb.AppendFormat("{0} codepages used in the volume", hpfs_sp.codepages).AppendLine();
sb.AppendFormat("SuperBlock CRC32: {0:X8}", hpfs_sp.sb_crc32).AppendLine();
sb.AppendFormat("SpareBlock CRC32: {0:X8}", hpfs_sp.sp_crc32).AppendLine();
2016-04-19 02:11:47 +01:00
sb.AppendLine("Flags:");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags1 & 0x01) == 0x01)
sb.AppendLine("Filesystem is dirty.");
else
sb.AppendLine("Filesystem is clean.");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags1 & 0x02) == 0x02)
sb.AppendLine("Spare directory blocks are in use");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags1 & 0x04) == 0x04)
sb.AppendLine("Hotfixes are in use");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags1 & 0x08) == 0x08)
sb.AppendLine("Disk contains bad sectors");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags1 & 0x10) == 0x10)
sb.AppendLine("Disk has a bad bitmap");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags1 & 0x20) == 0x20)
sb.AppendLine("Filesystem was formatted fast");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags1 & 0x40) == 0x40)
sb.AppendLine("Unknown flag 0x40 on flags1 is active");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags1 & 0x80) == 0x80)
sb.AppendLine("Filesystem has been mounted by an old IFS");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags2 & 0x01) == 0x01)
sb.AppendLine("Install DASD limits");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags2 & 0x02) == 0x02)
sb.AppendLine("Resync DASD limits");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags2 & 0x04) == 0x04)
sb.AppendLine("DASD limits are operational");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags2 & 0x08) == 0x08)
sb.AppendLine("Multimedia is active");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags2 & 0x10) == 0x10)
sb.AppendLine("DCE ACLs are active");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags2 & 0x20) == 0x20)
sb.AppendLine("DASD limits are dirty");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags2 & 0x40) == 0x40)
sb.AppendLine("Unknown flag 0x40 on flags2 is active");
2016-04-19 02:11:47 +01:00
if((hpfs_sp.flags2 & 0x80) == 0x80)
sb.AppendLine("Unknown flag 0x80 on flags2 is active");
xmlFSType = new Schemas.FileSystemType();
xmlFSType.Dirty |= (hpfs_sp.flags1 & 0x01) == 0x01;
xmlFSType.Clusters = hpfs_bpb.big_sectors / hpfs_bpb.spc;
xmlFSType.ClusterSize = hpfs_bpb.bps * hpfs_bpb.spc;
xmlFSType.Type = "HPFS";
xmlFSType.VolumeName = hpfs_bpb.volume_label;
xmlFSType.VolumeSerial = String.Format("{0:X8}", hpfs_bpb.serial_no);
2016-04-19 02:11:47 +01:00
information = sb.ToString();
}
2015-12-06 07:18:36 +00:00
/// <summary>
/// BIOS Parameter Block, at sector 0
/// </summary>
struct HPFS_BIOSParameterBlock
{
2015-12-06 07:18:36 +00:00
/// <summary>0x000, Jump to boot code</summary>
public byte jmp1;
2015-12-06 07:18:36 +00:00
/// <summary>0x001, ...;</summary>
public UInt16 jmp2;
2015-12-06 07:18:36 +00:00
/// <summary>0x003, OEM Name, 8 bytes, space-padded</summary>
public string OEMName;
2015-12-06 07:18:36 +00:00
/// <summary>0x00B, Bytes per sector</summary>
public UInt16 bps;
2015-12-06 07:18:36 +00:00
/// <summary>0x00D, Sectors per cluster</summary>
public byte spc;
2015-12-06 07:18:36 +00:00
/// <summary>0x00E, Reserved sectors between BPB and... does it have sense in HPFS?</summary>
public UInt16 rsectors;
2015-12-06 07:18:36 +00:00
/// <summary>0x010, Number of FATs... seriously?</summary>
public byte fats_no;
2015-12-06 07:18:36 +00:00
/// <summary>0x011, Number of entries on root directory... ok</summary>
public UInt16 root_ent;
2015-12-06 07:18:36 +00:00
/// <summary>0x013, Sectors in volume... doubt it</summary>
public UInt16 sectors;
2015-12-06 07:18:36 +00:00
/// <summary>0x015, Media descriptor</summary>
public byte media;
2015-12-06 07:18:36 +00:00
/// <summary>0x016, Sectors per FAT... again</summary>
public UInt16 spfat;
2015-12-06 07:18:36 +00:00
/// <summary>0x018, Sectors per track... you're kidding</summary>
public UInt16 sptrk;
2015-12-06 07:18:36 +00:00
/// <summary>0x01A, Heads... stop!</summary>
public UInt16 heads;
2015-12-06 07:18:36 +00:00
/// <summary>0x01C, Hidden sectors before BPB</summary>
public UInt32 hsectors;
2015-12-06 07:18:36 +00:00
/// <summary>0x024, Sectors in volume if &gt; 65535...</summary>
public UInt32 big_sectors;
2015-12-06 07:18:36 +00:00
/// <summary>0x028, Drive number</summary>
public byte drive_no;
2015-12-06 07:18:36 +00:00
/// <summary>0x029, Volume flags?</summary>
public byte nt_flags;
2015-12-06 07:18:36 +00:00
/// <summary>0x02A, EPB signature, 0x29</summary>
public byte signature;
2015-12-06 07:18:36 +00:00
/// <summary>0x02B, Volume serial number</summary>
public UInt32 serial_no;
2015-12-06 07:18:36 +00:00
/// <summary>0x02F, Volume label, 11 bytes, space-padded</summary>
public string volume_label;
2015-12-06 07:18:36 +00:00
/// <summary>0x03A, Filesystem type, 8 bytes, space-padded ("HPFS ")</summary>
public string fs_type;
}
2015-12-06 07:18:36 +00:00
/// <summary>
/// HPFS superblock at sector 16
/// </summary>
struct HPFS_SuperBlock
{
2015-12-06 07:18:36 +00:00
/// <summary>0x000, 0xF995E849</summary>
public UInt32 magic1;
2015-12-06 07:18:36 +00:00
/// <summary>0x004, 0xFA53E9C5</summary>
public UInt32 magic2;
2015-12-06 07:18:36 +00:00
/// <summary>0x008, HPFS version</summary>
public byte version;
2015-12-06 07:18:36 +00:00
/// <summary>0x009, 2 if &lt;= 4 GiB, 3 if &gt; 4 GiB</summary>
public byte func_version;
2015-12-06 07:18:36 +00:00
/// <summary>0x00A, Alignment</summary>
public UInt16 dummy;
2015-12-06 07:18:36 +00:00
/// <summary>0x00C, LSN pointer to root fnode</summary>
public UInt32 root_fnode;
2015-12-06 07:18:36 +00:00
/// <summary>0x010, Sectors on volume</summary>
public UInt32 sectors;
2015-12-06 07:18:36 +00:00
/// <summary>0x014, Bad blocks on volume</summary>
public UInt32 badblocks;
2015-12-06 07:18:36 +00:00
/// <summary>0x018, LSN pointer to volume bitmap</summary>
public UInt32 bitmap_lsn;
2015-12-06 07:18:36 +00:00
/// <summary>0x01C, 0</summary>
public UInt32 zero1;
2015-12-06 07:18:36 +00:00
/// <summary>0x020, LSN pointer to badblock directory</summary>
public UInt32 badblock_lsn;
2015-12-06 07:18:36 +00:00
/// <summary>0x024, 0</summary>
public UInt32 zero2;
2015-12-06 07:18:36 +00:00
/// <summary>0x028, Time of last CHKDSK</summary>
public Int32 last_chkdsk;
2015-12-06 07:18:36 +00:00
/// <summary>0x02C, Time of last optimization</summary>
public Int32 last_optim;
2015-12-06 07:18:36 +00:00
/// <summary>0x030, Sectors of dir band</summary>
public UInt32 dband_sectors;
2015-12-06 07:18:36 +00:00
/// <summary>0x034, Start sector of dir band</summary>
public UInt32 dband_start;
2015-12-06 07:18:36 +00:00
/// <summary>0x038, Last sector of dir band</summary>
public UInt32 dband_last;
2015-12-06 07:18:36 +00:00
/// <summary>0x03C, LSN of free space bitmap</summary>
public UInt32 dband_bitmap;
2015-12-06 07:18:36 +00:00
/// <summary>0x040, Can be used for volume name (32 bytes)</summary>
public UInt64 zero3;
2015-12-06 07:18:36 +00:00
/// <summary>0x048, ...</summary>
public UInt64 zero4;
2015-12-06 07:18:36 +00:00
/// <summary>0x04C, ...</summary>
public UInt64 zero5;
2015-12-06 07:18:36 +00:00
/// <summary>0x050, ...;</summary>
public UInt64 zero6;
2015-12-06 07:18:36 +00:00
/// <summary>0x058, LSN pointer to ACLs (only HPFS386)</summary>
public UInt32 acl_start;
}
2015-12-06 07:18:36 +00:00
/// <summary>
/// HPFS spareblock at sector 17
/// </summary>
struct HPFS_SpareBlock
{
2015-12-06 07:18:36 +00:00
/// <summary>0x000, 0xF9911849</summary>
public UInt32 magic1;
2015-12-06 07:18:36 +00:00
/// <summary>0x004, 0xFA5229C5</summary>
public UInt32 magic2;
2015-12-06 07:18:36 +00:00
/// <summary>0x008, HPFS flags</summary>
public byte flags1;
2015-12-06 07:18:36 +00:00
/// <summary>0x009, HPFS386 flags</summary>
public byte flags2;
2015-12-06 07:18:36 +00:00
/// <summary>0x00A, Alignment</summary>
public UInt16 dummy;
2015-12-06 07:18:36 +00:00
/// <summary>0x00C, LSN of hotfix directory</summary>
public UInt32 hotfix_start;
2015-12-06 07:18:36 +00:00
/// <summary>0x010, Used hotfixes</summary>
public UInt32 hotfix_used;
2015-12-06 07:18:36 +00:00
/// <summary>0x014, Total hotfixes available</summary>
public UInt32 hotfix_entries;
2015-12-06 07:18:36 +00:00
/// <summary>0x018, Unused spare dnodes</summary>
public UInt32 spare_dnodes_free;
2015-12-06 07:18:36 +00:00
/// <summary>0x01C, Length of spare dnodes list</summary>
public UInt32 spare_dnodes;
2015-12-06 07:18:36 +00:00
/// <summary>0x020, LSN of codepage directory</summary>
public UInt32 codepage_lsn;
2015-12-06 07:18:36 +00:00
/// <summary>0x024, Number of codepages used</summary>
public UInt32 codepages;
2015-12-06 07:18:36 +00:00
/// <summary>0x028, SuperBlock CRC32 (only HPFS386)</summary>
public UInt32 sb_crc32;
2015-12-06 07:18:36 +00:00
/// <summary>0x02C, SpareBlock CRC32 (only HPFS386)</summary>
public UInt32 sp_crc32;
}
}
}