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

@@ -1317,7 +1317,12 @@
<e p="Super.cs" t="Include" />
<e p="Xattr.cs" t="Include" />
</e>
<e p="AppleHFS" t="Include">
<e p="AppleHFS.cs" t="Include" />
<e p="Consts.cs" t="Include" />
<e p="Info.cs" t="Include" />
<e p="Structs.cs" t="Include" />
</e>
<e p="AppleHFSPlus.cs" t="Include" />
<e p="AppleMFS" t="Include">
<e p="AppleMFS.cs" t="Include" />

View File

@@ -238,50 +238,50 @@ namespace DiscImageChef.Filesystems
sb.AppendFormat("{0} blocks in volume common cache", mdb.drCtlCSize).AppendLine();
}
if(bb.signature == HFSBB_MAGIC)
if(bb.bbID == HFSBB_MAGIC)
{
sb.AppendLine("Volume is bootable.");
sb.AppendLine();
sb.AppendLine("Boot Block:");
if((bb.boot_flags & 0x40) == 0x40)
if((bb.bbPageFlags & 0x40) == 0x40)
sb.AppendLine("Boot block should be executed.");
if((bb.boot_flags & 0x80) == 0x80)
if((bb.bbPageFlags & 0x80) == 0x80)
sb.AppendLine("Boot block is in new unknown format.");
else
{
if(bb.boot_flags > 0)
if(bb.bbPageFlags > 0)
sb.AppendLine("Allocate secondary sound buffer at boot.");
else if(bb.boot_flags < 0)
else if(bb.bbPageFlags < 0)
sb.AppendLine("Allocate secondary sound and video buffers at boot.");
sb.AppendFormat("System filename: {0}", StringHandlers.PascalToString(bb.system_name, Encoding)).
sb.AppendFormat("System filename: {0}", StringHandlers.PascalToString(bb.bbSysName, Encoding)).
AppendLine();
sb.AppendFormat("Finder filename: {0}", StringHandlers.PascalToString(bb.finder_name, Encoding)).
sb.AppendFormat("Finder filename: {0}", StringHandlers.PascalToString(bb.bbShellName, Encoding)).
AppendLine();
sb.AppendFormat("Debugger filename: {0}", StringHandlers.PascalToString(bb.debug_name, Encoding)).
sb.AppendFormat("Debugger filename: {0}", StringHandlers.PascalToString(bb.bbDbg1Name, Encoding)).
AppendLine();
sb.AppendFormat("Disassembler filename: {0}",
StringHandlers.PascalToString(bb.disasm_name, Encoding)).AppendLine();
StringHandlers.PascalToString(bb.bbDbg2Name, Encoding)).AppendLine();
sb.AppendFormat("Startup screen filename: {0}",
StringHandlers.PascalToString(bb.stupscr_name, Encoding)).AppendLine();
StringHandlers.PascalToString(bb.bbScreenName, Encoding)).AppendLine();
sb.AppendFormat("First program to execute at boot: {0}",
StringHandlers.PascalToString(bb.bootup_name, Encoding)).AppendLine();
StringHandlers.PascalToString(bb.bbHelloName, Encoding)).AppendLine();
sb.AppendFormat("Clipboard filename: {0}",
StringHandlers.PascalToString(bb.clipbrd_name, Encoding)).AppendLine();
sb.AppendFormat("Clipboard filename: {0}", StringHandlers.PascalToString(bb.bbScrapName, Encoding)).
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("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 if(mdb.drFndrInfo0 != 0 ||
@@ -301,7 +301,7 @@ namespace DiscImageChef.Filesystems
XmlFsType.BackupDateSpecified = true;
}
XmlFsType.Bootable = bb.signature == HFSBB_MAGIC || mdb.drFndrInfo0 != 0 || mdb.drFndrInfo3 != 0 ||
XmlFsType.Bootable = bb.bbID == HFSBB_MAGIC || mdb.drFndrInfo0 != 0 || mdb.drFndrInfo3 != 0 ||
mdb.drFndrInfo5 != 0;
XmlFsType.Clusters = mdb.drNmAlBlks;

View File

@@ -43,50 +43,50 @@ namespace DiscImageChef.Filesystems
struct HfsBootBlock // Should be sectors 0 and 1 in volume
{
/// <summary>0x000, Signature, 0x4C4B if bootable</summary>
public readonly ushort signature;
public readonly ushort bbID;
/// <summary>0x002, Branch</summary>
public readonly uint branch;
public readonly uint bbEntry;
/// <summary>0x007, Boot block version</summary>
public readonly ushort boot_version;
public readonly ushort bbVersion;
/// <summary>0x006, Boot block flags</summary>
public readonly short boot_flags;
public readonly short bbPageFlags;
/// <summary>0x00A, System file name (16 bytes)</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] system_name;
public readonly byte[] bbSysName;
/// <summary>0x01A, Finder file name (16 bytes)</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] finder_name;
public readonly byte[] bbShellName;
/// <summary>0x02A, Debugger file name (16 bytes)</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] debug_name;
public readonly byte[] bbDbg1Name;
/// <summary>0x03A, Disassembler file name (16 bytes)</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] disasm_name;
public readonly byte[] bbDbg2Name;
/// <summary>0x04A, Startup screen file name (16 bytes)</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] stupscr_name;
public readonly byte[] bbScreenName;
/// <summary>0x05A, First program to execute on boot (16 bytes)</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] bootup_name;
public readonly byte[] bbHelloName;
/// <summary>0x06A, Clipboard file name (16 bytes)</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] clipbrd_name;
public readonly byte[] bbScrapName;
/// <summary>0x07A, 1/4 of maximum opened at a time files</summary>
public readonly ushort max_files;
public readonly ushort bbCntFCBs;
/// <summary>0x07C, Event queue size</summary>
public readonly ushort queue_size;
public readonly ushort bbCntEvts;
/// <summary>0x07E, Heap size on a Mac with 128KiB of RAM</summary>
public readonly uint heap_128k;
public readonly uint bb128KSHeap;
/// <summary>0x082, Heap size on a Mac with 256KiB of RAM</summary>
public readonly uint heap_256k;
public readonly uint bb256KSHeap;
/// <summary>0x086, Heap size on a Mac with 512KiB of RAM or more</summary>
public readonly uint heap_512k;
public readonly uint bbSysHeapSize;
/// <summary>Padding</summary>
public readonly ushort padding;
public readonly ushort filler;
/// <summary>Additional system heap space</summary>
public readonly uint heap_extra;
public readonly uint bbSysHeapExtra;
/// <summary>Fraction of RAM for system heap</summary>
public readonly uint heap_fract;
public readonly uint bbSysHeapFract;
}
/// <summary>Master Directory Block, should be sector 2 in volume</summary>

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);
@@ -60,10 +61,10 @@ namespace DiscImageChef.Filesystems.AppleMFS
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.bbEntry = BigEndianBitConverter.ToUInt32(bbSector, 0x002);
bb.boot_flags = bbSector[0x006];
bb.boot_version = bbSector[0x007];
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);

View File

@@ -38,13 +38,10 @@ using System.Diagnostics.CodeAnalysis;
namespace DiscImageChef.Filesystems.AppleMFS
{
// Information from Inside Macintosh Volume II
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "NotAccessedField.Local")]
public partial class AppleMFS
{
/// <summary>
/// Master Directory Block, should be at offset 0x0400 bytes in volume
/// </summary>
/// <summary>Master Directory Block, should be at offset 0x0400 bytes in volume</summary>
struct MFS_MasterDirectoryBlock
{
/// <summary>0x000, Signature, 0xD2D7</summary>
@@ -79,71 +76,59 @@ namespace DiscImageChef.Filesystems.AppleMFS
public string drVN;
}
/// <summary>
/// Should be at offset 0x0000 in volume, followed by boot code
/// </summary>
/// <summary>Should be at offset 0x0000 in volume, followed by boot code</summary>
struct MFS_BootBlock
{
/// <summary>0x000, Signature, 0x4C4B if bootable</summary>
public ushort signature;
public ushort bbID;
/// <summary>0x002, Branch</summary>
public uint branch;
public uint bbEntry;
/// <summary>0x006, Boot block flags</summary>
public byte boot_flags;
/// <summary>0x007, Boot block version</summary>
public byte boot_version;
public byte bbVersion;
/// <summary>0x008, Allocate secondary buffers</summary>
public short sec_sv_pages;
public short bbPageFlags;
/// <summary>0x00A, System file name (16 bytes)</summary>
public string system_name;
public string bbSysName;
/// <summary>0x01A, Finder file name (16 bytes)</summary>
public string finder_name;
public string bbShellName;
/// <summary>0x02A, Debugger file name (16 bytes)</summary>
public string debug_name;
public string bbDbg1Name;
/// <summary>0x03A, Disassembler file name (16 bytes)</summary>
public string disasm_name;
public string bbDbg2Name;
/// <summary>0x04A, Startup screen file name (16 bytes)</summary>
public string stupscr_name;
public string bbScreenName;
/// <summary>0x05A, First program to execute on boot (16 bytes)</summary>
public string bootup_name;
public string bbHelloName;
/// <summary>0x06A, Clipboard file name (16 bytes)</summary>
public string clipbrd_name;
public string bbScrapName;
/// <summary>0x07A, 1/4 of maximum opened at a time files</summary>
public ushort max_files;
public ushort bbCntFCBs;
/// <summary>0x07C, Event queue size</summary>
public ushort queue_size;
public ushort bbCntEvts;
/// <summary>0x07E, Heap size on a Mac with 128KiB of RAM</summary>
public uint heap_128k;
public uint bb128KSHeap;
/// <summary>0x082, Heap size on a Mac with 256KiB of RAM</summary>
public uint heap_256k;
public uint bb256KSHeap;
/// <summary>0x086, Heap size on a Mac with 512KiB of RAM or more</summary>
public uint heap_512k;
public uint bbSysHeapSize;
}
[Flags]
enum MFS_FileFlags : byte
{
Locked = 0x01,
Used = 0x80
Locked = 0x01, Used = 0x80
}
[Flags]
enum MFS_FinderFlags : ushort
{
kIsOnDesk = 0x0001,
kColor = 0x000E,
kRequireSwitchLaunch = 0x0020,
kIsShared = 0x0040,
kHasNoINITs = 0x0080,
kHasBeenInited = 0x0100,
kHasCustomIcon = 0x0400,
kLetter = 0x0200,
kChanged = 0x0200,
kIsStationery = 0x0800,
kNameLocked = 0x1000,
kHasBundle = 0x2000,
kIsInvisible = 0x4000,
kIsAlias = 0x8000
kIsOnDesk = 0x0001, kColor = 0x000E, kRequireSwitchLaunch = 0x0020,
kIsShared = 0x0040, kHasNoINITs = 0x0080, kHasBeenInited = 0x0100,
kHasCustomIcon = 0x0400, kLetter = 0x0200, kChanged = 0x0200,
kIsStationery = 0x0800, kNameLocked = 0x1000, kHasBundle = 0x2000,
kIsInvisible = 0x4000, kIsAlias = 0x8000
}
struct MFS_Point