mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
* 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:
@@ -14,121 +14,121 @@ namespace FileSystemIDandChk.PartPlugins
|
||||
|
||||
public AppleMap (PluginBase Core)
|
||||
{
|
||||
base.Name = "Apple Partition Map";
|
||||
base.PluginUUID = new Guid("36405F8D-4F1A-07F5-209C-223D735D6D22");
|
||||
Name = "Apple Partition Map";
|
||||
PluginUUID = new Guid("36405F8D-4F1A-07F5-209C-223D735D6D22");
|
||||
}
|
||||
|
||||
public override bool GetInformation (FileStream stream, out List<Partition> partitions)
|
||||
public override bool GetInformation (ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions)
|
||||
{
|
||||
byte[] cString;
|
||||
|
||||
ulong apm_entries;
|
||||
uint sector_size;
|
||||
|
||||
if (imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448)
|
||||
sector_size = 2048;
|
||||
else
|
||||
sector_size = imagePlugin.GetSectorSize();
|
||||
|
||||
partitions = new List<Partition>();
|
||||
|
||||
AppleMapBootEntry APMB = new AppleMapBootEntry();
|
||||
AppleMapPartitionEntry APMEntry = new AppleMapPartitionEntry();
|
||||
EndianAwareBinaryReader eabr = new EndianAwareBinaryReader(stream, false); // BigEndian
|
||||
|
||||
eabr.BaseStream.Seek(0, SeekOrigin.Begin);
|
||||
APMB.signature = eabr.ReadUInt16();
|
||||
|
||||
if(APMB.signature == APM_MAGIC)
|
||||
{
|
||||
APMB.sector_size = eabr.ReadUInt16();
|
||||
}
|
||||
else
|
||||
APMB.sector_size = 512; // Some disks omit the boot entry
|
||||
byte[] APMB_sector = imagePlugin.ReadSector(0);
|
||||
|
||||
if(APMB.sector_size == 2048) // A CD, search if buggy (aligns in 512 bytes blocks) first
|
||||
{
|
||||
eabr.BaseStream.Seek(512, SeekOrigin.Begin); // Seek to first entry
|
||||
APMEntry.signature = eabr.ReadUInt16();
|
||||
if(APMEntry.signature != APM_ENTRY && APMEntry.signature != APM_OLDENT) // It should have partition entry signature if buggy
|
||||
{
|
||||
eabr.BaseStream.Seek(2048, SeekOrigin.Begin); // Seek to first entry considering 2048 bytes blocks. Unbuggy.
|
||||
APMEntry.signature = eabr.ReadUInt16();
|
||||
if(APMEntry.signature != APM_ENTRY && APMEntry.signature != APM_OLDENT)
|
||||
return false;
|
||||
else
|
||||
APMB.sector_size = 2048;
|
||||
}
|
||||
else
|
||||
APMB.sector_size = 512;
|
||||
}
|
||||
else
|
||||
{
|
||||
eabr.BaseStream.Seek(APMB.sector_size, SeekOrigin.Begin); // Seek to first entry
|
||||
APMEntry.signature = eabr.ReadUInt16();
|
||||
if(APMEntry.signature != APM_ENTRY && APMEntry.signature != APM_OLDENT) // It should have partition entry signature if buggy
|
||||
{
|
||||
eabr.BaseStream.Seek(512, SeekOrigin.Begin); // Seek to first entry considering 512 bytes blocks. Buggy.
|
||||
APMEntry.signature = eabr.ReadUInt16();
|
||||
if(APMEntry.signature != APM_ENTRY && APMEntry.signature != APM_OLDENT)
|
||||
return false;
|
||||
else
|
||||
APMB.sector_size = 512;
|
||||
}
|
||||
}
|
||||
APMB.signature = BigEndianBitConverter.ToUInt16(APMB_sector, 0x00);
|
||||
APMB.sector_size = BigEndianBitConverter.ToUInt16(APMB_sector, 0x02);
|
||||
APMB.sectors = BigEndianBitConverter.ToUInt32(APMB_sector, 0x04);
|
||||
APMB.reserved1 = BigEndianBitConverter.ToUInt16(APMB_sector, 0x08);
|
||||
APMB.reserved2 = BigEndianBitConverter.ToUInt16(APMB_sector, 0x0A);
|
||||
APMB.reserved3 = BigEndianBitConverter.ToUInt32(APMB_sector, 0x0C);
|
||||
APMB.driver_entries = BigEndianBitConverter.ToUInt16(APMB_sector, 0x10);
|
||||
APMB.first_driver_blk = BigEndianBitConverter.ToUInt32(APMB_sector, 0x12);
|
||||
APMB.driver_size = BigEndianBitConverter.ToUInt16(APMB_sector, 0x16);
|
||||
APMB.operating_system = BigEndianBitConverter.ToUInt16(APMB_sector, 0x18);
|
||||
|
||||
eabr.BaseStream.Seek(2, SeekOrigin.Current); // Skip reserved1
|
||||
APMEntry.entries = eabr.ReadUInt32();
|
||||
if(APMEntry.entries <= 1) // It should have more than one entry
|
||||
return false;
|
||||
ulong first_sector = 0;
|
||||
|
||||
if (APMB.signature == APM_MAGIC) // APM boot block found, APM starts in next sector
|
||||
first_sector = 1;
|
||||
|
||||
// Read first entry
|
||||
byte[] APMEntry_sector = imagePlugin.ReadSector(first_sector);
|
||||
APMEntry.signature = BigEndianBitConverter.ToUInt16(APMEntry_sector, 0x00);
|
||||
APMEntry.reserved1 = BigEndianBitConverter.ToUInt16(APMEntry_sector, 0x02);
|
||||
APMEntry.entries = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x04);
|
||||
APMEntry.start = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x08);
|
||||
APMEntry.sectors = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x0C);
|
||||
cString = new byte[32];
|
||||
Array.Copy(APMEntry_sector, 0x10, cString, 0, 32);
|
||||
APMEntry.name = StringHandlers.CToString(cString);
|
||||
cString = new byte[32];
|
||||
Array.Copy(APMEntry_sector, 0x30, cString, 0, 32);
|
||||
APMEntry.type = StringHandlers.CToString(cString);
|
||||
APMEntry.first_data_block = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x50);
|
||||
APMEntry.data_sectors = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x54);
|
||||
APMEntry.status = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x58);
|
||||
APMEntry.first_boot_block = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x5C);
|
||||
APMEntry.boot_size = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x60);
|
||||
APMEntry.load_address = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x64);
|
||||
APMEntry.reserved2 = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x68);
|
||||
APMEntry.entry_point = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x6C);
|
||||
APMEntry.reserved3 = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x70);
|
||||
APMEntry.checksum = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x74);
|
||||
cString = new byte[16];
|
||||
Array.Copy(APMEntry_sector, 0x78, cString, 0, 16);
|
||||
APMEntry.processor = StringHandlers.CToString(cString);
|
||||
|
||||
if (APMEntry.signature != APM_ENTRY && APMEntry.signature != APM_OLDENT)
|
||||
return false;
|
||||
|
||||
if (APMEntry.entries <= 1)
|
||||
return false;
|
||||
|
||||
apm_entries = APMEntry.entries;
|
||||
|
||||
// eabr.BaseStream.Seek(4, SeekOrigin.Current); // Skip start, we don't need it
|
||||
// eabr.BaseStream.Seek(4, SeekOrigin.Current); // Skip sectors, we don't need it
|
||||
// eabr.BaseStream.Seek(32, SeekOrigin.Current); // Skip name, we don't ned it
|
||||
|
||||
// cString = eabr.ReadBytes(32);
|
||||
// APMEntry.type = StringHandlers.CToString(cString);
|
||||
// if(APMEntry.type != "Apple_partition_map") // APM self-describes, if not, this is incorrect
|
||||
// return false;
|
||||
|
||||
apm_entries = APMEntry.entries;
|
||||
|
||||
for(ulong i = 1; i <= apm_entries; i++) // For each partition
|
||||
for(ulong i = 0; i < apm_entries; i++) // For each partition
|
||||
{
|
||||
APMEntry = new AppleMapPartitionEntry();
|
||||
|
||||
eabr.BaseStream.Seek((long)(APMB.sector_size*i), SeekOrigin.Begin); // Seek to partition descriptor
|
||||
//eabr.BaseStream.Seek((long)(0x200*i), SeekOrigin.Begin); // Seek to partition descriptor
|
||||
|
||||
APMEntry.signature = eabr.ReadUInt16();
|
||||
if(APMEntry.signature == APM_ENTRY || APMEntry.signature == APM_OLDENT) // It should have partition entry signature
|
||||
APMEntry = new AppleMapPartitionEntry();
|
||||
APMEntry_sector = imagePlugin.ReadSector(first_sector + i);
|
||||
APMEntry.signature = BigEndianBitConverter.ToUInt16(APMEntry_sector, 0x00);
|
||||
APMEntry.reserved1 = BigEndianBitConverter.ToUInt16(APMEntry_sector, 0x02);
|
||||
APMEntry.entries = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x04);
|
||||
APMEntry.start = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x08);
|
||||
APMEntry.sectors = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x0C);
|
||||
cString = new byte[32];
|
||||
Array.Copy(APMEntry_sector, 0x10, cString, 0, 32);
|
||||
APMEntry.name = StringHandlers.CToString(cString);
|
||||
cString = new byte[32];
|
||||
Array.Copy(APMEntry_sector, 0x30, cString, 0, 32);
|
||||
APMEntry.type = StringHandlers.CToString(cString);
|
||||
APMEntry.first_data_block = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x50);
|
||||
APMEntry.data_sectors = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x54);
|
||||
APMEntry.status = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x58);
|
||||
APMEntry.first_boot_block = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x5C);
|
||||
APMEntry.boot_size = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x60);
|
||||
APMEntry.load_address = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x64);
|
||||
APMEntry.reserved2 = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x68);
|
||||
APMEntry.entry_point = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x6C);
|
||||
APMEntry.reserved3 = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x70);
|
||||
APMEntry.checksum = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x74);
|
||||
cString = new byte[16];
|
||||
Array.Copy(APMEntry_sector, 0x78, cString, 0, 16);
|
||||
APMEntry.processor = StringHandlers.CToString(cString);
|
||||
|
||||
if(APMEntry.signature == APM_ENTRY || APMEntry.signature == APM_OLDENT) // It should have partition entry signature
|
||||
{
|
||||
Partition _partition = new Partition();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
eabr.BaseStream.Seek(2, SeekOrigin.Current); // Skip reserved1
|
||||
eabr.BaseStream.Seek(4, SeekOrigin.Current); // Skip entries
|
||||
|
||||
APMEntry.start = eabr.ReadUInt32();
|
||||
APMEntry.sectors = eabr.ReadUInt32();
|
||||
cString = eabr.ReadBytes(32);
|
||||
APMEntry.name = StringHandlers.CToString(cString);
|
||||
cString = eabr.ReadBytes(32);
|
||||
APMEntry.type = StringHandlers.CToString(cString);
|
||||
APMEntry.first_data_block = eabr.ReadUInt32();
|
||||
APMEntry.data_sectors = eabr.ReadUInt32();
|
||||
APMEntry.status = eabr.ReadUInt32();
|
||||
APMEntry.first_boot_block = eabr.ReadUInt32();
|
||||
APMEntry.boot_size = eabr.ReadUInt32();
|
||||
APMEntry.load_address = eabr.ReadUInt32();
|
||||
eabr.BaseStream.Seek(4, SeekOrigin.Current);
|
||||
APMEntry.entry_point = eabr.ReadUInt32();
|
||||
eabr.BaseStream.Seek(4, SeekOrigin.Current);
|
||||
APMEntry.checksum = eabr.ReadUInt32();
|
||||
cString = eabr.ReadBytes(16);
|
||||
APMEntry.processor = StringHandlers.CToString(cString);
|
||||
|
||||
_partition.PartitionSequence = i;
|
||||
_partition.PartitionType = APMEntry.type;
|
||||
_partition.PartitionName = APMEntry.name;
|
||||
// _partition.PartitionStart = APMEntry.start * 0x200; // This seems to be hardcoded
|
||||
_partition.PartitionStart = APMEntry.start * APMB.sector_size;
|
||||
// _partition.PartitionLength = APMEntry.sectors * 0x200; // This seems to be hardcoded
|
||||
_partition.PartitionLength = APMEntry.sectors * APMB.sector_size;
|
||||
_partition.PartitionStart = APMEntry.start * sector_size;
|
||||
_partition.PartitionLength = APMEntry.sectors * sector_size;
|
||||
_partition.PartitionStartSector = APMEntry.start;
|
||||
_partition.PartitionSectors = APMEntry.sectors;
|
||||
|
||||
sb.AppendLine("Partition flags:");
|
||||
if((APMEntry.status & 0x01) == 0x01)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,140 +6,159 @@ using FileSystemIDandChk;
|
||||
|
||||
namespace FileSystemIDandChk.PartPlugins
|
||||
{
|
||||
class NeXTDisklabel : PartPlugin
|
||||
{
|
||||
public const UInt32 NEXT_MAGIC1 = 0x4E655854; // "NeXT"
|
||||
public const UInt32 NEXT_MAGIC2 = 0x646C5632; // "dlV2"
|
||||
public const UInt32 NEXT_MAGIC3 = 0x646C5633; // "dlV3"
|
||||
class NeXTDisklabel : PartPlugin
|
||||
{
|
||||
const UInt32 NEXT_MAGIC1 = 0x4E655854;
|
||||
// "NeXT"
|
||||
const UInt32 NEXT_MAGIC2 = 0x646C5632;
|
||||
// "dlV2"
|
||||
const UInt32 NEXT_MAGIC3 = 0x646C5633;
|
||||
// "dlV3"
|
||||
|
||||
public NeXTDisklabel (PluginBase Core)
|
||||
{
|
||||
base.Name = "NeXT Disklabel";
|
||||
base.PluginUUID = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
}
|
||||
|
||||
public override bool GetInformation (FileStream stream, out List<Partition> partitions)
|
||||
{
|
||||
byte[] cString;
|
||||
bool magic_found = false;
|
||||
|
||||
UInt32 magic;
|
||||
UInt32 sector_size;
|
||||
UInt16 front_porch;
|
||||
|
||||
partitions = new List<Partition>();
|
||||
const UInt16 disktabStart = 0xB4; // 180
|
||||
const UInt16 disktabEntrySize = 0x2C; // 44
|
||||
|
||||
EndianAwareBinaryReader eabr = new EndianAwareBinaryReader(stream, false); // BigEndian
|
||||
public NeXTDisklabel(PluginBase Core)
|
||||
{
|
||||
Name = "NeXT Disklabel";
|
||||
PluginUUID = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
}
|
||||
|
||||
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions)
|
||||
{
|
||||
byte[] cString;
|
||||
bool magic_found;
|
||||
byte[] entry_sector;
|
||||
|
||||
eabr.BaseStream.Seek(0, SeekOrigin.Begin); // Starts on sector 0 on NeXT machines, CDs and floppies
|
||||
magic = eabr.ReadUInt32();
|
||||
UInt32 magic;
|
||||
UInt32 sector_size;
|
||||
UInt16 front_porch;
|
||||
|
||||
if (imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448)
|
||||
sector_size = 2048;
|
||||
else
|
||||
sector_size = imagePlugin.GetSectorSize();
|
||||
|
||||
if(magic == NEXT_MAGIC1 || magic == NEXT_MAGIC2 || magic == NEXT_MAGIC3)
|
||||
magic_found = true;
|
||||
else
|
||||
{
|
||||
eabr.BaseStream.Seek(0x1E00, SeekOrigin.Begin); // Starts on sector 15 on MBR machines
|
||||
magic = eabr.ReadUInt32();
|
||||
|
||||
if(magic == NEXT_MAGIC1 || magic == NEXT_MAGIC2 || magic == NEXT_MAGIC3)
|
||||
magic_found = true;
|
||||
else
|
||||
{
|
||||
eabr.BaseStream.Seek(0x2000, SeekOrigin.Begin); // Starts on sector 16 (4 on CD) on RISC disks
|
||||
magic = eabr.ReadUInt32();
|
||||
partitions = new List<Partition>();
|
||||
|
||||
entry_sector = imagePlugin.ReadSector(0); // Starts on sector 0 on NeXT machines, CDs and floppies
|
||||
magic = BigEndianBitConverter.ToUInt32(entry_sector, 0x00);
|
||||
|
||||
if (magic == NEXT_MAGIC1 || magic == NEXT_MAGIC2 || magic == NEXT_MAGIC3)
|
||||
magic_found = true;
|
||||
else
|
||||
{
|
||||
entry_sector = imagePlugin.ReadSector(15); // Starts on sector 15 on MBR machines
|
||||
magic = BigEndianBitConverter.ToUInt32(entry_sector, 0x00);
|
||||
|
||||
if (magic == NEXT_MAGIC1 || magic == NEXT_MAGIC2 || magic == NEXT_MAGIC3)
|
||||
magic_found = true;
|
||||
else
|
||||
{
|
||||
if (sector_size == 2048)
|
||||
entry_sector = imagePlugin.ReadSector(4); // Starts on sector 4 on RISC CDs
|
||||
else
|
||||
entry_sector = imagePlugin.ReadSector(16); // Starts on sector 16 on RISC disks
|
||||
magic = BigEndianBitConverter.ToUInt32(entry_sector, 0x00);
|
||||
|
||||
if(magic == NEXT_MAGIC1 || magic == NEXT_MAGIC2 || magic == NEXT_MAGIC3)
|
||||
magic_found = true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (magic == NEXT_MAGIC1 || magic == NEXT_MAGIC2 || magic == NEXT_MAGIC3)
|
||||
magic_found = true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(magic_found)
|
||||
{
|
||||
eabr.BaseStream.Seek(88, SeekOrigin.Current); // Seek to sector size
|
||||
sector_size = eabr.ReadUInt32();
|
||||
eabr.BaseStream.Seek(16, SeekOrigin.Current); // Seek to front porch
|
||||
front_porch = eabr.ReadUInt16();
|
||||
|
||||
eabr.BaseStream.Seek(76, SeekOrigin.Current); // Seek to first partition entry
|
||||
|
||||
for(int i = 0; i < 8; i ++)
|
||||
{
|
||||
NeXTEntry entry = new NeXTEntry();
|
||||
front_porch = BigEndianBitConverter.ToUInt16(entry_sector, 0x6A);
|
||||
|
||||
entry.start = eabr.ReadUInt32();
|
||||
entry.sectors = eabr.ReadUInt32();
|
||||
entry.block_size = eabr.ReadUInt16();
|
||||
entry.frag_size = eabr.ReadUInt16();
|
||||
entry.optimization = eabr.ReadByte();
|
||||
entry.cpg = eabr.ReadUInt16();
|
||||
entry.bpi = eabr.ReadUInt16();
|
||||
entry.freemin = eabr.ReadByte();
|
||||
entry.unknown = eabr.ReadByte();
|
||||
entry.newfs = eabr.ReadByte();
|
||||
cString = eabr.ReadBytes(16);
|
||||
entry.mount_point = StringHandlers.CToString(cString);
|
||||
entry.automount = eabr.ReadByte();
|
||||
cString = eabr.ReadBytes(8);
|
||||
entry.type = StringHandlers.CToString(cString);
|
||||
entry.unknown2 = eabr.ReadByte();
|
||||
|
||||
if(entry.sectors > 0 && entry.sectors < 0xFFFFFFFF && entry.start < 0xFFFFFFFF)
|
||||
{
|
||||
Partition part = new Partition();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (magic_found)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
NeXTEntry entry = new NeXTEntry();
|
||||
|
||||
entry.start = BigEndianBitConverter.ToUInt32(entry_sector, disktabStart + disktabEntrySize * i + 0x00);
|
||||
entry.sectors = BigEndianBitConverter.ToUInt32(entry_sector, disktabStart + disktabEntrySize * i + 0x04);
|
||||
entry.block_size = BigEndianBitConverter.ToUInt16(entry_sector, disktabStart + disktabEntrySize * i + 0x08);
|
||||
entry.frag_size = BigEndianBitConverter.ToUInt16(entry_sector, disktabStart + disktabEntrySize * i + 0x0A);
|
||||
entry.optimization = entry_sector[disktabStart + disktabEntrySize * i + 0x0C];
|
||||
entry.cpg = BigEndianBitConverter.ToUInt16(entry_sector, disktabStart + disktabEntrySize * i + 0x0D);
|
||||
entry.bpi = BigEndianBitConverter.ToUInt16(entry_sector, disktabStart + disktabEntrySize * i + 0x0F);
|
||||
entry.freemin = entry_sector[disktabStart + disktabEntrySize * i + 0x11];
|
||||
entry.newfs = entry_sector[disktabStart + disktabEntrySize * i + 0x12];
|
||||
cString = new byte[16];
|
||||
Array.Copy(entry_sector, disktabStart + disktabEntrySize * i + 0x13, cString, 0, 16);
|
||||
entry.mount_point = StringHandlers.CToString(cString);
|
||||
entry.automount = entry_sector[disktabStart + disktabEntrySize * i + 0x23];
|
||||
cString = new byte[8];
|
||||
Array.Copy(entry_sector, disktabStart + disktabEntrySize * i + 0x24, cString, 0, 8);
|
||||
entry.type = StringHandlers.CToString(cString);
|
||||
|
||||
if (entry.sectors > 0 && entry.sectors < 0xFFFFFFFF && entry.start < 0xFFFFFFFF)
|
||||
{
|
||||
Partition part = new Partition();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
part.PartitionLength = (long)entry.sectors * sector_size;
|
||||
part.PartitionStart = ((long)entry.start + front_porch) * sector_size;
|
||||
part.PartitionType = entry.type;
|
||||
part.PartitionSequence = (ulong)i;
|
||||
part.PartitionName = entry.mount_point;
|
||||
part.PartitionLength = (ulong)entry.sectors * sector_size;
|
||||
part.PartitionStart = ((ulong)entry.start + front_porch) * sector_size;
|
||||
part.PartitionType = entry.type;
|
||||
part.PartitionSequence = (ulong)i;
|
||||
part.PartitionName = entry.mount_point;
|
||||
part.PartitionSectors = (ulong)entry.sectors;
|
||||
part.PartitionStartSector = ((ulong)entry.start + front_porch);
|
||||
|
||||
sb.AppendFormat("{0} bytes per block", entry.block_size).AppendLine();
|
||||
sb.AppendFormat("{0} bytes per fragment", entry.frag_size).AppendLine();
|
||||
if(entry.optimization == 's')
|
||||
sb.AppendLine("Space optimized");
|
||||
else if(entry.optimization == 't')
|
||||
sb.AppendLine("Time optimized");
|
||||
else
|
||||
sb.AppendFormat("Unknown optimization {0:X2}", entry.optimization).AppendLine();
|
||||
sb.AppendFormat("{0} cylinders per group", entry.cpg).AppendLine();
|
||||
sb.AppendFormat("{0} bytes per inode", entry.bpi).AppendLine();
|
||||
sb.AppendFormat("{0}% of space must be free at minimum", entry.freemin).AppendLine();
|
||||
if(entry.newfs != 1) // Seems to indicate news has been already run
|
||||
sb.AppendFormat("{0} bytes per block", entry.block_size).AppendLine();
|
||||
sb.AppendFormat("{0} bytes per fragment", entry.frag_size).AppendLine();
|
||||
if (entry.optimization == 's')
|
||||
sb.AppendLine("Space optimized");
|
||||
else if (entry.optimization == 't')
|
||||
sb.AppendLine("Time optimized");
|
||||
else
|
||||
sb.AppendFormat("Unknown optimization {0:X2}", entry.optimization).AppendLine();
|
||||
sb.AppendFormat("{0} cylinders per group", entry.cpg).AppendLine();
|
||||
sb.AppendFormat("{0} bytes per inode", entry.bpi).AppendLine();
|
||||
sb.AppendFormat("{0}% of space must be free at minimum", entry.freemin).AppendLine();
|
||||
if (entry.newfs != 1) // Seems to indicate newfs has been already run
|
||||
sb.AppendLine("Filesystem should be formatted at start");
|
||||
if(entry.automount == 1)
|
||||
sb.AppendLine("Filesystem should be automatically mounted");
|
||||
if (entry.automount == 1)
|
||||
sb.AppendLine("Filesystem should be automatically mounted");
|
||||
|
||||
part.PartitionDescription = sb.ToString();
|
||||
part.PartitionDescription = sb.ToString();
|
||||
|
||||
partitions.Add(part);
|
||||
}
|
||||
}
|
||||
partitions.Add(part);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private struct NeXTEntry
|
||||
{
|
||||
public UInt32 start; // Sector of start, counting from front porch
|
||||
public UInt32 sectors; // Length in sectors
|
||||
public UInt16 block_size; // Filesystem's block size
|
||||
public UInt16 frag_size; // Filesystem's fragment size
|
||||
public byte optimization; // 's'pace or 't'ime
|
||||
public UInt16 cpg; // Cylinders per group
|
||||
public UInt16 bpi; // Bytes per inode
|
||||
public byte freemin; // % of minimum free space
|
||||
public byte unknown; // Unknown
|
||||
public byte newfs; // Should newfs be run on first start?
|
||||
public string mount_point; // Mount point or empty if mount where you want
|
||||
public byte automount; // Should automount
|
||||
public string type; // Filesystem type, always "4.3BSD"?
|
||||
public byte unknown2; // Unknown
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct NeXTEntry
|
||||
{
|
||||
public UInt32 start;
|
||||
// Sector of start, counting from front porch
|
||||
public UInt32 sectors;
|
||||
// Length in sectors
|
||||
public UInt16 block_size;
|
||||
// Filesystem's block size
|
||||
public UInt16 frag_size;
|
||||
// Filesystem's fragment size
|
||||
public byte optimization;
|
||||
// 's'pace or 't'ime
|
||||
public UInt16 cpg;
|
||||
// Cylinders per group
|
||||
public UInt16 bpi;
|
||||
// Bytes per inode
|
||||
public byte freemin;
|
||||
// % of minimum free space
|
||||
public byte newfs;
|
||||
// Should newfs be run on first start?
|
||||
public string mount_point;
|
||||
// Mount point or empty if mount where you want
|
||||
public byte automount;
|
||||
// Should automount
|
||||
public string type;
|
||||
// Filesystem type, always "4.3BSD"?
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,25 +4,35 @@ using System.Collections.Generic;
|
||||
|
||||
namespace FileSystemIDandChk.PartPlugins
|
||||
{
|
||||
public abstract class PartPlugin
|
||||
{
|
||||
public string Name;
|
||||
public abstract class PartPlugin
|
||||
{
|
||||
public string Name;
|
||||
public Guid PluginUUID;
|
||||
|
||||
protected PartPlugin ()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract bool GetInformation(FileStream stream, out List<Partition> partitions);
|
||||
}
|
||||
|
||||
public struct Partition
|
||||
{
|
||||
public ulong PartitionSequence; // Partition number, 0-started
|
||||
public string PartitionType; // Partition type
|
||||
public string PartitionName; // Partition name (if the scheme supports it)
|
||||
public long PartitionStart; // Start of the partition, in bytes
|
||||
public long PartitionLength; // Length in bytes of the partition
|
||||
public string PartitionDescription; // Information that does not find space in this struct
|
||||
}
|
||||
|
||||
protected PartPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions);
|
||||
}
|
||||
|
||||
public struct Partition
|
||||
{
|
||||
public ulong PartitionSequence;
|
||||
// Partition number, 0-started
|
||||
public string PartitionType;
|
||||
// Partition type
|
||||
public string PartitionName;
|
||||
// Partition name (if the scheme supports it)
|
||||
public ulong PartitionStart;
|
||||
// Start of the partition, in bytes
|
||||
public ulong PartitionStartSector;
|
||||
// LBA of partition start
|
||||
public ulong PartitionLength;
|
||||
// Length in bytes of the partition
|
||||
public ulong PartitionSectors;
|
||||
// Length in sectors of the partition
|
||||
public string PartitionDescription;
|
||||
// Information that does not find space in this struct
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user