* 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
This commit is contained in:
2014-04-14 01:14:20 +00:00
parent 0abc5476b5
commit 32bb28e8c2
30 changed files with 5832 additions and 3656 deletions

View File

@@ -3,8 +3,6 @@ using System.IO;
using System.Text;
using FileSystemIDandChk;
// Information from Inside Macintosh
namespace FileSystemIDandChk.Plugins
{
class NTFS : Plugin
@@ -15,42 +13,37 @@ namespace FileSystemIDandChk.Plugins
base.PluginUUID = new Guid("33513B2C-1e6d-4d21-a660-0bbc789c3871");
}
public override bool Identify(FileStream stream, long offset)
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
{
byte[] eigth_bytes = new byte[8];
byte signature1, fats_no;
UInt16 spfat, signature2;
string oem_name;
BinaryReader br = new BinaryReader(stream);
byte[] ntfs_bpb = imagePlugin.ReadSector(0 + partitionOffset);
br.BaseStream.Seek(3 + offset, SeekOrigin.Begin);
eigth_bytes = br.ReadBytes(8);
Array.Copy(ntfs_bpb, 0x003, eigth_bytes, 0, 8);
oem_name = StringHandlers.CToString(eigth_bytes);
if(oem_name != "NTFS ")
return false;
br.BaseStream.Seek(0x10 + offset, SeekOrigin.Begin);
fats_no = br.ReadByte();
fats_no = ntfs_bpb[0x010];
if(fats_no != 0)
return false;
br.BaseStream.Seek(0x16 + offset, SeekOrigin.Begin);
spfat = br.ReadUInt16();
spfat = BitConverter.ToUInt16(ntfs_bpb, 0x016);
if(spfat != 0)
return false;
br.BaseStream.Seek(0x26 + offset, SeekOrigin.Begin);
signature1 = br.ReadByte();
signature1 = ntfs_bpb[0x026];
if(signature1 != 0x80)
return false;
br.BaseStream.Seek(0x1FE + offset, SeekOrigin.Begin);
signature2 = br.ReadUInt16();
signature2 = BitConverter.ToUInt16(ntfs_bpb, 0x1FE);
if(signature2 != 0xAA55)
return false;
@@ -58,52 +51,49 @@ namespace FileSystemIDandChk.Plugins
return true;
}
public override void GetInformation (FileStream stream, long offset, out string information)
public override void GetInformation (ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
{
information = "";
StringBuilder sb = new StringBuilder();
BinaryReader br = new BinaryReader(stream);
br.BaseStream.Seek(offset, SeekOrigin.Begin);
byte[] ntfs_bpb = imagePlugin.ReadSector(0 + partitionOffset);
NTFS_BootBlock ntfs_bb = new NTFS_BootBlock();
byte[] oem_name = new byte[8];
ntfs_bb.jmp1 = br.ReadByte();
ntfs_bb.jmp2 = br.ReadUInt16();
oem_name = br.ReadBytes(8);
ntfs_bb.jmp1 = ntfs_bpb[0x000];
ntfs_bb.jmp2 = BitConverter.ToUInt16(ntfs_bpb, 0x001);
Array.Copy(ntfs_bpb, 0x003, oem_name, 0, 8);
ntfs_bb.OEMName = StringHandlers.CToString(oem_name);
ntfs_bb.bps = br.ReadUInt16();
ntfs_bb.spc = br.ReadByte();
ntfs_bb.rsectors = br.ReadUInt16();
ntfs_bb.fats_no = br.ReadByte();
ntfs_bb.root_ent = br.ReadUInt16();
ntfs_bb.sml_sectors = br.ReadUInt16();
ntfs_bb.media = br.ReadByte();
ntfs_bb.spfat = br.ReadUInt16();
ntfs_bb.sptrk = br.ReadUInt16();
ntfs_bb.heads = br.ReadUInt16();
ntfs_bb.hsectors = br.ReadUInt32();
ntfs_bb.big_sectors = br.ReadUInt32();
ntfs_bb.drive_no = br.ReadByte();
ntfs_bb.nt_flags = br.ReadByte();
ntfs_bb.signature1 = br.ReadByte();
ntfs_bb.dummy = br.ReadByte();
ntfs_bb.sectors = br.ReadInt64();
ntfs_bb.mft_lsn = br.ReadInt64();
ntfs_bb.mftmirror_lsn = br.ReadInt64();
ntfs_bb.mft_rc_clusters = br.ReadSByte();
ntfs_bb.dummy2 = br.ReadByte();
ntfs_bb.dummy3 = br.ReadUInt16();
ntfs_bb.index_blk_cts = br.ReadSByte();
ntfs_bb.dummy4 = br.ReadByte();
ntfs_bb.dummy5 = br.ReadUInt16();
ntfs_bb.serial_no = br.ReadUInt64();
br.BaseStream.Seek(430, SeekOrigin.Current);
ntfs_bb.signature2 = br.ReadUInt16();
ntfs_bb.bps = BitConverter.ToUInt16(ntfs_bpb, 0x00B);
ntfs_bb.spc = ntfs_bpb[0x00D];
ntfs_bb.rsectors = BitConverter.ToUInt16(ntfs_bpb, 0x00E);
ntfs_bb.fats_no = ntfs_bpb[0x010];
ntfs_bb.root_ent = BitConverter.ToUInt16(ntfs_bpb, 0x011);
ntfs_bb.sml_sectors = BitConverter.ToUInt16(ntfs_bpb, 0x013);
ntfs_bb.media = ntfs_bpb[0x015];
ntfs_bb.spfat = BitConverter.ToUInt16(ntfs_bpb, 0x016);
ntfs_bb.sptrk = BitConverter.ToUInt16(ntfs_bpb, 0x018);
ntfs_bb.heads = BitConverter.ToUInt16(ntfs_bpb, 0x01A);
ntfs_bb.hsectors = BitConverter.ToUInt32(ntfs_bpb, 0x01C);
ntfs_bb.big_sectors = BitConverter.ToUInt32(ntfs_bpb, 0x020);
ntfs_bb.drive_no = ntfs_bpb[0x024];
ntfs_bb.nt_flags = ntfs_bpb[0x025];
ntfs_bb.signature1 = ntfs_bpb[0x026];
ntfs_bb.dummy = ntfs_bpb[0x027];
ntfs_bb.sectors = BitConverter.ToInt64(ntfs_bpb, 0x028);
ntfs_bb.mft_lsn = BitConverter.ToInt64(ntfs_bpb, 0x030);
ntfs_bb.mftmirror_lsn = BitConverter.ToInt64(ntfs_bpb, 0x038);
ntfs_bb.mft_rc_clusters = (sbyte)ntfs_bpb[0x040];
ntfs_bb.dummy2 = ntfs_bpb[0x041];
ntfs_bb.dummy3 = BitConverter.ToUInt16(ntfs_bpb, 0x042);
ntfs_bb.index_blk_cts = (sbyte)ntfs_bpb[0x044];
ntfs_bb.dummy4 = ntfs_bpb[0x045];
ntfs_bb.dummy5 = BitConverter.ToUInt16(ntfs_bpb, 0x046);
ntfs_bb.serial_no = BitConverter.ToUInt64(ntfs_bpb, 0x048);
ntfs_bb.signature2 = BitConverter.ToUInt16(ntfs_bpb, 0x1FE);
sb.AppendFormat("{0} bytes per sector", ntfs_bb.bps).AppendLine();
sb.AppendFormat("{0} sectors per cluster ({1} bytes)", ntfs_bb.spc, ntfs_bb.spc*ntfs_bb.bps).AppendLine();
@@ -144,40 +134,39 @@ namespace FileSystemIDandChk.Plugins
private struct NTFS_BootBlock // Sector 0
{
// BIOS Parameter Block
public byte jmp1; // Jump to boot code
public UInt16 jmp2; // ...;
public string OEMName; // OEM Name, 8 bytes, space-padded, must be "NTFS "
public UInt16 bps; // Bytes per sector
public byte spc; // Sectors per cluster
public UInt16 rsectors; // Reserved sectors, seems 0
public byte fats_no; // Number of FATs... obviously, 0
public UInt16 root_ent; // Number of entries on root directory... 0
public UInt16 sml_sectors; // Sectors in volume... 0
public byte media; // Media descriptor
public UInt16 spfat; // Sectors per FAT... 0
public UInt16 sptrk; // Sectors per track, required to boot
public UInt16 heads; // Heads... required to boot
public UInt32 hsectors; // Hidden sectors before BPB
public UInt32 big_sectors; // Sectors in volume if > 65535... 0
public byte drive_no; // Drive number
public byte nt_flags; // 0
public byte signature1; // EPB signature, 0x80
public byte dummy; // Alignment
public byte jmp1; // 0x000, Jump to boot code
public UInt16 jmp2; // 0x001, ...;
public string OEMName; // 0x003, OEM Name, 8 bytes, space-padded, must be "NTFS "
public UInt16 bps; // 0x00B, Bytes per sector
public byte spc; // 0x00D, Sectors per cluster
public UInt16 rsectors; // 0x00E, Reserved sectors, seems 0
public byte fats_no; // 0x010, Number of FATs... obviously, 0
public UInt16 root_ent; // 0x011, Number of entries on root directory... 0
public UInt16 sml_sectors; // 0x013, Sectors in volume... 0
public byte media; // 0x015, Media descriptor
public UInt16 spfat; // 0x016, Sectors per FAT... 0
public UInt16 sptrk; // 0x018, Sectors per track, required to boot
public UInt16 heads; // 0x01A, Heads... required to boot
public UInt32 hsectors; // 0x01C, Hidden sectors before BPB
public UInt32 big_sectors; // 0x020, Sectors in volume if > 65535... 0
public byte drive_no; // 0x024, Drive number
public byte nt_flags; // 0x025, 0
public byte signature1; // 0x026, EPB signature, 0x80
public byte dummy; // 0x027, Alignment
// End of BIOS Parameter Block
// NTFS real superblock
public Int64 sectors; // Sectors on volume
public Int64 mft_lsn; // LSN of $MFT
public Int64 mftmirror_lsn; // LSN of $MFTMirror
public sbyte mft_rc_clusters; // Clusters per MFT record
public byte dummy2; // Alignment
public UInt16 dummy3; // Alignment
public sbyte index_blk_cts; // Clusters per index block
public byte dummy4; // Alignment
public UInt16 dummy5; // Alignment
public UInt64 serial_no; // Volume serial number
// End of NTFS superblock, followed by 426 bytes of boot code
public UInt16 signature2; // 0xAA55
public Int64 sectors; // 0x028, Sectors on volume
public Int64 mft_lsn; // 0x030, LSN of $MFT
public Int64 mftmirror_lsn; // 0x038, LSN of $MFTMirror
public sbyte mft_rc_clusters; // 0x040, Clusters per MFT record
public byte dummy2; // 0x041, Alignment
public UInt16 dummy3; // 0x042, Alignment
public sbyte index_blk_cts; // 0x044, Clusters per index block
public byte dummy4; // 0x045, Alignment
public UInt16 dummy5; // 0x046, Alignment
public UInt64 serial_no; // 0x048, Volume serial number
// End of NTFS superblock, followed by 430 bytes of boot code
public UInt16 signature2; // 0x1FE, 0xAA55
}
}
}