Rename Apple boot block fields to follow documentation.

This commit is contained in:
2020-02-18 23:52:30 +00:00
parent ace859ca3c
commit 80a38c860d
5 changed files with 133 additions and 125 deletions

View File

@@ -45,7 +45,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
if(2 + partition.Start >= partition.End) return false;
if(2 + partition.Start >= partition.End)
return false;
byte[] mdbSector = imagePlugin.ReadSector(2 + partition.Start);
@@ -55,15 +56,15 @@ namespace DiscImageChef.Filesystems.AppleMFS
}
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
Encoding encoding)
Encoding encoding)
{
Encoding = encoding ?? new MacRoman();
information = "";
StringBuilder sb = new StringBuilder();
var sb = new StringBuilder();
MFS_MasterDirectoryBlock mdb = new MFS_MasterDirectoryBlock();
MFS_BootBlock bb = new MFS_BootBlock();
var mdb = new MFS_MasterDirectoryBlock();
var bb = new MFS_BootBlock();
byte[] pString = new byte[16];
@@ -71,7 +72,9 @@ namespace DiscImageChef.Filesystems.AppleMFS
byte[] bbSector = imagePlugin.ReadSector(0 + partition.Start);
mdb.drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000);
if(mdb.drSigWord != MFS_MAGIC) return;
if(mdb.drSigWord != MFS_MAGIC)
return;
mdb.drCrDate = BigEndianBitConverter.ToUInt32(mdbSector, 0x002);
mdb.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbSector, 0x006);
@@ -90,46 +93,52 @@ namespace DiscImageChef.Filesystems.AppleMFS
Array.Copy(mdbSector, 0x024, variableSize, 0, mdb.drVNSiz + 1);
mdb.drVN = StringHandlers.PascalToString(variableSize, Encoding);
bb.signature = BigEndianBitConverter.ToUInt16(bbSector, 0x000);
bb.bbID = BigEndianBitConverter.ToUInt16(bbSector, 0x000);
if(bb.signature == MFSBB_MAGIC)
if(bb.bbID == MFSBB_MAGIC)
{
bb.branch = BigEndianBitConverter.ToUInt32(bbSector, 0x002);
bb.boot_flags = bbSector[0x006];
bb.boot_version = bbSector[0x007];
bb.bbEntry = BigEndianBitConverter.ToUInt32(bbSector, 0x002);
bb.boot_flags = bbSector[0x006];
bb.bbVersion = bbSector[0x007];
bb.sec_sv_pages = BigEndianBitConverter.ToInt16(bbSector, 0x008);
bb.bbPageFlags = BigEndianBitConverter.ToInt16(bbSector, 0x008);
Array.Copy(mdbSector, 0x00A, pString, 0, 16);
bb.system_name = StringHandlers.PascalToString(pString, Encoding);
bb.bbSysName = StringHandlers.PascalToString(pString, Encoding);
Array.Copy(mdbSector, 0x01A, pString, 0, 16);
bb.finder_name = StringHandlers.PascalToString(pString, Encoding);
bb.bbShellName = StringHandlers.PascalToString(pString, Encoding);
Array.Copy(mdbSector, 0x02A, pString, 0, 16);
bb.debug_name = StringHandlers.PascalToString(pString, Encoding);
bb.bbDbg1Name = StringHandlers.PascalToString(pString, Encoding);
Array.Copy(mdbSector, 0x03A, pString, 0, 16);
bb.disasm_name = StringHandlers.PascalToString(pString, Encoding);
bb.bbDbg2Name = StringHandlers.PascalToString(pString, Encoding);
Array.Copy(mdbSector, 0x04A, pString, 0, 16);
bb.stupscr_name = StringHandlers.PascalToString(pString, Encoding);
bb.bbScreenName = StringHandlers.PascalToString(pString, Encoding);
Array.Copy(mdbSector, 0x05A, pString, 0, 16);
bb.bootup_name = StringHandlers.PascalToString(pString, Encoding);
bb.bbHelloName = StringHandlers.PascalToString(pString, Encoding);
Array.Copy(mdbSector, 0x06A, pString, 0, 16);
bb.clipbrd_name = StringHandlers.PascalToString(pString, Encoding);
bb.bbScrapName = StringHandlers.PascalToString(pString, Encoding);
bb.max_files = BigEndianBitConverter.ToUInt16(bbSector, 0x07A);
bb.queue_size = BigEndianBitConverter.ToUInt16(bbSector, 0x07C);
bb.heap_128k = BigEndianBitConverter.ToUInt32(bbSector, 0x07E);
bb.heap_256k = BigEndianBitConverter.ToUInt32(bbSector, 0x082);
bb.heap_512k = BigEndianBitConverter.ToUInt32(bbSector, 0x086);
bb.bbCntFCBs = BigEndianBitConverter.ToUInt16(bbSector, 0x07A);
bb.bbCntEvts = BigEndianBitConverter.ToUInt16(bbSector, 0x07C);
bb.bb128KSHeap = BigEndianBitConverter.ToUInt32(bbSector, 0x07E);
bb.bb256KSHeap = BigEndianBitConverter.ToUInt32(bbSector, 0x082);
bb.bbSysHeapSize = BigEndianBitConverter.ToUInt32(bbSector, 0x086);
}
else bb.signature = 0x0000;
else
bb.bbID = 0x0000;
sb.AppendLine("Apple Macintosh File System");
sb.AppendLine();
sb.AppendLine("Master Directory Block:");
sb.AppendFormat("Creation date: {0}", DateHandlers.MacToDateTime(mdb.drCrDate)).AppendLine();
sb.AppendFormat("Last backup date: {0}", DateHandlers.MacToDateTime(mdb.drLsBkUp)).AppendLine();
if((mdb.drAtrb & 0x80) == 0x80) sb.AppendLine("Volume is locked by hardware.");
if((mdb.drAtrb & 0x8000) == 0x8000) sb.AppendLine("Volume is locked by software.");
if((mdb.drAtrb & 0x80) == 0x80)
sb.AppendLine("Volume is locked by hardware.");
if((mdb.drAtrb & 0x8000) == 0x8000)
sb.AppendLine("Volume is locked by software.");
sb.AppendFormat("{0} files on volume", mdb.drNmFls).AppendLine();
sb.AppendFormat("First directory sector: {0}", mdb.drDirSt).AppendLine();
sb.AppendFormat("{0} sectors in directory.", mdb.drBlLen).AppendLine();
@@ -141,46 +150,55 @@ namespace DiscImageChef.Filesystems.AppleMFS
sb.AppendFormat("{0} unused allocation blocks.", mdb.drFreeBks).AppendLine();
sb.AppendFormat("Volume name: {0}", mdb.drVN).AppendLine();
if(bb.signature == MFSBB_MAGIC)
if(bb.bbID == MFSBB_MAGIC)
{
sb.AppendLine("Volume is bootable.");
sb.AppendLine();
sb.AppendLine("Boot Block:");
if((bb.boot_flags & 0x40) == 0x40) sb.AppendLine("Boot block should be executed.");
if((bb.boot_flags & 0x80) == 0x80) sb.AppendLine("Boot block is in new unknown format.");
if((bb.boot_flags & 0x40) == 0x40)
sb.AppendLine("Boot block should be executed.");
if((bb.boot_flags & 0x80) == 0x80)
sb.AppendLine("Boot block is in new unknown format.");
else
{
if(bb.sec_sv_pages > 0) sb.AppendLine("Allocate secondary sound buffer at boot.");
else if(bb.sec_sv_pages < 0) sb.AppendLine("Allocate secondary sound and video buffers at boot.");
if(bb.bbPageFlags > 0)
sb.AppendLine("Allocate secondary sound buffer at boot.");
else if(bb.bbPageFlags < 0)
sb.AppendLine("Allocate secondary sound and video buffers at boot.");
sb.AppendFormat("System filename: {0}", bb.system_name).AppendLine();
sb.AppendFormat("Finder filename: {0}", bb.finder_name).AppendLine();
sb.AppendFormat("Debugger filename: {0}", bb.debug_name).AppendLine();
sb.AppendFormat("Disassembler filename: {0}", bb.disasm_name).AppendLine();
sb.AppendFormat("Startup screen filename: {0}", bb.stupscr_name).AppendLine();
sb.AppendFormat("First program to execute at boot: {0}", bb.bootup_name).AppendLine();
sb.AppendFormat("Clipboard filename: {0}", bb.clipbrd_name).AppendLine();
sb.AppendFormat("Maximum opened files: {0}", bb.max_files * 4).AppendLine();
sb.AppendFormat("Event queue size: {0}", bb.queue_size).AppendLine();
sb.AppendFormat("Heap size with 128KiB of RAM: {0} bytes", bb.heap_128k).AppendLine();
sb.AppendFormat("Heap size with 256KiB of RAM: {0} bytes", bb.heap_256k).AppendLine();
sb.AppendFormat("Heap size with 512KiB of RAM or more: {0} bytes", bb.heap_512k).AppendLine();
sb.AppendFormat("System filename: {0}", bb.bbSysName).AppendLine();
sb.AppendFormat("Finder filename: {0}", bb.bbShellName).AppendLine();
sb.AppendFormat("Debugger filename: {0}", bb.bbDbg1Name).AppendLine();
sb.AppendFormat("Disassembler filename: {0}", bb.bbDbg2Name).AppendLine();
sb.AppendFormat("Startup screen filename: {0}", bb.bbScreenName).AppendLine();
sb.AppendFormat("First program to execute at boot: {0}", bb.bbHelloName).AppendLine();
sb.AppendFormat("Clipboard filename: {0}", bb.bbScrapName).AppendLine();
sb.AppendFormat("Maximum opened files: {0}", bb.bbCntFCBs * 4).AppendLine();
sb.AppendFormat("Event queue size: {0}", bb.bbCntEvts).AppendLine();
sb.AppendFormat("Heap size with 128KiB of RAM: {0} bytes", bb.bb128KSHeap).AppendLine();
sb.AppendFormat("Heap size with 256KiB of RAM: {0} bytes", bb.bb256KSHeap).AppendLine();
sb.AppendFormat("Heap size with 512KiB of RAM or more: {0} bytes", bb.bbSysHeapSize).AppendLine();
}
}
else sb.AppendLine("Volume is not bootable.");
else
sb.AppendLine("Volume is not bootable.");
information = sb.ToString();
XmlFsType = new FileSystemType();
if(mdb.drLsBkUp > 0)
{
XmlFsType.BackupDate = DateHandlers.MacToDateTime(mdb.drLsBkUp);
XmlFsType.BackupDateSpecified = true;
}
XmlFsType.Bootable = bb.signature == MFSBB_MAGIC;
XmlFsType.Bootable = bb.bbID == MFSBB_MAGIC;
XmlFsType.Clusters = mdb.drNmAlBlks;
XmlFsType.ClusterSize = mdb.drAlBlkSiz;
if(mdb.drCrDate > 0)
{
XmlFsType.CreationDate = DateHandlers.MacToDateTime(mdb.drCrDate);