REFACTOR: Invert 'if' statement to reduce nesting.

This commit is contained in:
2017-12-21 06:06:19 +00:00
parent 9cd1869d1d
commit 4d886dae25
138 changed files with 9447 additions and 9806 deletions

View File

@@ -145,19 +145,18 @@ namespace DiscImageChef.Filesystems.LisaFS
{
ExtentFile ext;
error = ReadExtentsFile(entV2.fileID, out ext);
if(error == Errno.NoError)
{
CatalogEntry entV3 = new CatalogEntry();
entV3.fileID = entV2.fileID;
entV3.filename = new byte[32];
Array.Copy(entV2.filename, 0, entV3.filename, 0, entV2.filenameLen);
entV3.fileType = entV2.fileType;
entV3.length = (int)srecords[entV2.fileID].filesize;
entV3.dtc = ext.dtc;
entV3.dtm = ext.dtm;
if(error != Errno.NoError) continue;
catalogCache.Add(entV3);
}
CatalogEntry entV3 = new CatalogEntry();
entV3.fileID = entV2.fileID;
entV3.filename = new byte[32];
Array.Copy(entV2.filename, 0, entV3.filename, 0, entV2.filenameLen);
entV3.fileType = entV2.fileType;
entV3.length = (int)srecords[entV2.fileID].filesize;
entV3.dtc = ext.dtc;
entV3.dtm = ext.dtm;
catalogCache.Add(entV3);
}
return Errno.NoError;
@@ -173,11 +172,10 @@ namespace DiscImageChef.Filesystems.LisaFS
LisaTag.PriamTag catTag;
DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out catTag);
if(catTag.fileID == FILEID_CATALOG && catTag.relPage == 0)
{
firstCatalogBlock = device.ReadSectors(i, 4);
break;
}
if(catTag.fileID != FILEID_CATALOG || catTag.relPage != 0) continue;
firstCatalogBlock = device.ReadSectors(i, 4);
break;
}
// Catalog not found

View File

@@ -85,11 +85,10 @@ namespace DiscImageChef.Filesystems.LisaFS
for(ulong i = 0; i < device.ImageInfo.Sectors; i++)
{
DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out extTag);
if(extTag.fileID == fileId * -1)
{
ptr = i;
break;
}
if(extTag.fileID != fileId * -1) continue;
ptr = i;
break;
}
if(!found) return Errno.InvalidArgument;
@@ -98,180 +97,169 @@ namespace DiscImageChef.Filesystems.LisaFS
// Checks that the sector tag indicates its the Extents File we are searching for
DecodeTag(device.ReadSectorTag(ptr, SectorTagType.AppleSectorTag), out extTag);
if(extTag.fileID == (short)(-1 * fileId))
if(extTag.fileID != (short)(-1 * fileId)) return Errno.NoSuchFile;
byte[] sector;
if(mddf.fsversion == LisaFSv1) sector = device.ReadSectors(ptr, 2);
else sector = device.ReadSector(ptr);
if(sector[0] >= 32 || sector[0] == 0) return Errno.InvalidArgument;
file.filenameLen = sector[0];
file.filename = new byte[file.filenameLen];
Array.Copy(sector, 0x01, file.filename, 0, file.filenameLen);
file.unknown1 = BigEndianBitConverter.ToUInt16(sector, 0x20);
file.file_uid = BigEndianBitConverter.ToUInt64(sector, 0x22);
file.unknown2 = sector[0x2A];
file.etype = sector[0x2B];
file.ftype = (FileType)sector[0x2C];
file.unknown3 = sector[0x2D];
file.dtc = BigEndianBitConverter.ToUInt32(sector, 0x2E);
file.dta = BigEndianBitConverter.ToUInt32(sector, 0x32);
file.dtm = BigEndianBitConverter.ToUInt32(sector, 0x36);
file.dtb = BigEndianBitConverter.ToUInt32(sector, 0x3A);
file.dts = BigEndianBitConverter.ToUInt32(sector, 0x3E);
file.serial = BigEndianBitConverter.ToUInt32(sector, 0x42);
file.unknown4 = sector[0x46];
file.locked = sector[0x47];
file.protect = sector[0x48];
file.master = sector[0x49];
file.scavenged = sector[0x4A];
file.closed = sector[0x4B];
file.open = sector[0x4C];
file.unknown5 = new byte[11];
Array.Copy(sector, 0x4D, file.unknown5, 0, 11);
file.release = BigEndianBitConverter.ToUInt16(sector, 0x58);
file.build = BigEndianBitConverter.ToUInt16(sector, 0x5A);
file.compatibility = BigEndianBitConverter.ToUInt16(sector, 0x5C);
file.revision = BigEndianBitConverter.ToUInt16(sector, 0x5E);
file.unknown6 = BigEndianBitConverter.ToUInt16(sector, 0x60);
file.password_valid = sector[0x62];
file.password = new byte[8];
Array.Copy(sector, 0x63, file.password, 0, 8);
file.unknown7 = new byte[3];
Array.Copy(sector, 0x6B, file.unknown7, 0, 3);
file.overhead = BigEndianBitConverter.ToUInt16(sector, 0x6E);
file.unknown8 = new byte[16];
Array.Copy(sector, 0x70, file.unknown8, 0, 16);
file.unknown10 = BigEndianBitConverter.ToInt16(sector, 0x17E);
file.LisaInfo = new byte[128];
Array.Copy(sector, 0x180, file.LisaInfo, 0, 128);
int extentsCount = 0;
int extentsOffset;
if(mddf.fsversion == LisaFSv1)
{
byte[] sector;
if(mddf.fsversion == LisaFSv1) sector = device.ReadSectors(ptr, 2);
else sector = device.ReadSector(ptr);
if(sector[0] >= 32 || sector[0] == 0) return Errno.InvalidArgument;
file.filenameLen = sector[0];
file.filename = new byte[file.filenameLen];
Array.Copy(sector, 0x01, file.filename, 0, file.filenameLen);
file.unknown1 = BigEndianBitConverter.ToUInt16(sector, 0x20);
file.file_uid = BigEndianBitConverter.ToUInt64(sector, 0x22);
file.unknown2 = sector[0x2A];
file.etype = sector[0x2B];
file.ftype = (FileType)sector[0x2C];
file.unknown3 = sector[0x2D];
file.dtc = BigEndianBitConverter.ToUInt32(sector, 0x2E);
file.dta = BigEndianBitConverter.ToUInt32(sector, 0x32);
file.dtm = BigEndianBitConverter.ToUInt32(sector, 0x36);
file.dtb = BigEndianBitConverter.ToUInt32(sector, 0x3A);
file.dts = BigEndianBitConverter.ToUInt32(sector, 0x3E);
file.serial = BigEndianBitConverter.ToUInt32(sector, 0x42);
file.unknown4 = sector[0x46];
file.locked = sector[0x47];
file.protect = sector[0x48];
file.master = sector[0x49];
file.scavenged = sector[0x4A];
file.closed = sector[0x4B];
file.open = sector[0x4C];
file.unknown5 = new byte[11];
Array.Copy(sector, 0x4D, file.unknown5, 0, 11);
file.release = BigEndianBitConverter.ToUInt16(sector, 0x58);
file.build = BigEndianBitConverter.ToUInt16(sector, 0x5A);
file.compatibility = BigEndianBitConverter.ToUInt16(sector, 0x5C);
file.revision = BigEndianBitConverter.ToUInt16(sector, 0x5E);
file.unknown6 = BigEndianBitConverter.ToUInt16(sector, 0x60);
file.password_valid = sector[0x62];
file.password = new byte[8];
Array.Copy(sector, 0x63, file.password, 0, 8);
file.unknown7 = new byte[3];
Array.Copy(sector, 0x6B, file.unknown7, 0, 3);
file.overhead = BigEndianBitConverter.ToUInt16(sector, 0x6E);
file.unknown8 = new byte[16];
Array.Copy(sector, 0x70, file.unknown8, 0, 16);
file.unknown10 = BigEndianBitConverter.ToInt16(sector, 0x17E);
file.LisaInfo = new byte[128];
Array.Copy(sector, 0x180, file.LisaInfo, 0, 128);
int extentsCount = 0;
int extentsOffset;
if(mddf.fsversion == LisaFSv1)
{
file.length = BigEndianBitConverter.ToInt32(sector, 0x200);
file.unknown9 = BigEndianBitConverter.ToInt32(sector, 0x204);
extentsOffset = 0x208;
}
else
{
file.length = BigEndianBitConverter.ToInt32(sector, 0x80);
file.unknown9 = BigEndianBitConverter.ToInt32(sector, 0x84);
extentsOffset = 0x88;
}
for(int j = 0; j < 41; j++)
{
if(BigEndianBitConverter.ToInt16(sector, extentsOffset + j * 6 + 4) == 0) break;
extentsCount++;
}
file.extents = new Extent[extentsCount];
for(int j = 0; j < extentsCount; j++)
{
file.extents[j] = new Extent();
file.extents[j].start = BigEndianBitConverter.ToInt32(sector, extentsOffset + j * 6);
file.extents[j].length = BigEndianBitConverter.ToInt16(sector, extentsOffset + j * 6 + 4);
}
extentCache.Add(fileId, file);
if(debug)
if(!printedExtents.Contains(fileId))
{
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filenameLen = {1}", fileId,
file.filenameLen);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filename = {1}", fileId,
StringHandlers.CToString(file.filename, CurrentEncoding));
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown1 = 0x{1:X4}", fileId,
file.unknown1);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].file_uid = 0x{1:X16}", fileId,
file.file_uid);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown2 = 0x{1:X2}", fileId,
file.unknown2);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].etype = 0x{1:X2}", fileId,
file.etype);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].ftype = {1}", fileId, file.ftype);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown3 = 0x{1:X2}", fileId,
file.unknown3);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].dtc = {1}", fileId, file.dtc);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].dta = {1}", fileId, file.dta);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].dtm = {1}", fileId, file.dtm);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].dtb = {1}", fileId, file.dtb);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].dts = {1}", fileId, file.dts);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].serial = {1}", fileId, file.serial);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown4 = 0x{1:X2}", fileId,
file.unknown4);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].locked = {1}", fileId,
file.locked > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].protect = {1}", fileId,
file.protect > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].master = {1}", fileId,
file.master > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].scavenged = {1}", fileId,
file.scavenged > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].closed = {1}", fileId,
file.closed > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].open = {1}", fileId, file.open > 0);
DicConsole.DebugWriteLine("LisaFS plugin",
"ExtentFile[{0}].unknown5 = 0x{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}{9:X2}" +
"{10:X2}{11:X2}", fileId, file.unknown5[0], file.unknown5[1],
file.unknown5[2], file.unknown5[3], file.unknown5[4],
file.unknown5[5], file.unknown5[6], file.unknown5[7],
file.unknown5[8], file.unknown5[9], file.unknown5[10]);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].release = {1}", fileId,
file.release);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].build = {1}", fileId, file.build);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].compatibility = {1}", fileId,
file.compatibility);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].revision = {1}", fileId,
file.revision);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown6 = 0x{1:X4}", fileId,
file.unknown6);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].password_valid = {1}", fileId,
file.password_valid > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].password = {1}", fileId,
CurrentEncoding.GetString(file.password));
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown7 = 0x{1:X2}{2:X2}{3:X2}",
fileId, file.unknown7[0], file.unknown7[1], file.unknown7[2]);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].overhead = {1}", fileId,
file.overhead);
DicConsole.DebugWriteLine("LisaFS plugin",
"ExtentFile[{0}].unknown8 = 0x{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}{9:X2}" +
"{10:X2}{11:X2}{12:X2}{13:X2}{14:X2}{15:X2}{16:X2}", fileId,
file.unknown8[0], file.unknown8[1], file.unknown8[2],
file.unknown8[3], file.unknown8[4], file.unknown8[5],
file.unknown8[6], file.unknown8[7], file.unknown8[8],
file.unknown8[9], file.unknown8[10], file.unknown8[11],
file.unknown8[12], file.unknown8[13], file.unknown8[14],
file.unknown8[15]);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].length = {1}", fileId, file.length);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown9 = 0x{1:X8}", fileId,
file.unknown9);
for(int ext = 0; ext < file.extents.Length; ext++)
{
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].extents[{1}].start = {2}",
fileId, ext, file.extents[ext].start);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].extents[{1}].length = {2}",
fileId, ext, file.extents[ext].length);
}
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown10 = 0x{1:X4}", fileId,
file.unknown10);
printedExtents.Add(fileId);
}
return Errno.NoError;
file.length = BigEndianBitConverter.ToInt32(sector, 0x200);
file.unknown9 = BigEndianBitConverter.ToInt32(sector, 0x204);
extentsOffset = 0x208;
}
else
{
file.length = BigEndianBitConverter.ToInt32(sector, 0x80);
file.unknown9 = BigEndianBitConverter.ToInt32(sector, 0x84);
extentsOffset = 0x88;
}
return Errno.NoSuchFile;
for(int j = 0; j < 41; j++)
{
if(BigEndianBitConverter.ToInt16(sector, extentsOffset + j * 6 + 4) == 0) break;
extentsCount++;
}
file.extents = new Extent[extentsCount];
for(int j = 0; j < extentsCount; j++)
{
file.extents[j] = new Extent();
file.extents[j].start = BigEndianBitConverter.ToInt32(sector, extentsOffset + j * 6);
file.extents[j].length = BigEndianBitConverter.ToInt16(sector, extentsOffset + j * 6 + 4);
}
extentCache.Add(fileId, file);
if(!debug) return Errno.NoError;
if(printedExtents.Contains(fileId)) return Errno.NoError;
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filenameLen = {1}", fileId,
file.filenameLen);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filename = {1}", fileId,
StringHandlers.CToString(file.filename, CurrentEncoding));
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown1 = 0x{1:X4}", fileId,
file.unknown1);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].file_uid = 0x{1:X16}", fileId,
file.file_uid);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown2 = 0x{1:X2}", fileId,
file.unknown2);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].etype = 0x{1:X2}", fileId, file.etype);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].ftype = {1}", fileId, file.ftype);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown3 = 0x{1:X2}", fileId,
file.unknown3);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].dtc = {1}", fileId, file.dtc);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].dta = {1}", fileId, file.dta);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].dtm = {1}", fileId, file.dtm);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].dtb = {1}", fileId, file.dtb);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].dts = {1}", fileId, file.dts);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].serial = {1}", fileId, file.serial);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown4 = 0x{1:X2}", fileId,
file.unknown4);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].locked = {1}", fileId, file.locked > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].protect = {1}", fileId,
file.protect > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].master = {1}", fileId, file.master > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].scavenged = {1}", fileId,
file.scavenged > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].closed = {1}", fileId, file.closed > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].open = {1}", fileId, file.open > 0);
DicConsole.DebugWriteLine("LisaFS plugin",
"ExtentFile[{0}].unknown5 = 0x{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}{9:X2}" +
"{10:X2}{11:X2}", fileId, file.unknown5[0], file.unknown5[1],
file.unknown5[2], file.unknown5[3], file.unknown5[4], file.unknown5[5],
file.unknown5[6], file.unknown5[7], file.unknown5[8], file.unknown5[9],
file.unknown5[10]);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].release = {1}", fileId, file.release);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].build = {1}", fileId, file.build);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].compatibility = {1}", fileId,
file.compatibility);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].revision = {1}", fileId, file.revision);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown6 = 0x{1:X4}", fileId,
file.unknown6);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].password_valid = {1}", fileId,
file.password_valid > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].password = {1}", fileId,
CurrentEncoding.GetString(file.password));
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown7 = 0x{1:X2}{2:X2}{3:X2}",
fileId, file.unknown7[0], file.unknown7[1], file.unknown7[2]);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].overhead = {1}", fileId, file.overhead);
DicConsole.DebugWriteLine("LisaFS plugin",
"ExtentFile[{0}].unknown8 = 0x{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}{9:X2}" +
"{10:X2}{11:X2}{12:X2}{13:X2}{14:X2}{15:X2}{16:X2}", fileId,
file.unknown8[0], file.unknown8[1], file.unknown8[2], file.unknown8[3],
file.unknown8[4], file.unknown8[5], file.unknown8[6], file.unknown8[7],
file.unknown8[8], file.unknown8[9], file.unknown8[10], file.unknown8[11],
file.unknown8[12], file.unknown8[13], file.unknown8[14],
file.unknown8[15]);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].length = {1}", fileId, file.length);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown9 = 0x{1:X8}", fileId,
file.unknown9);
for(int ext = 0; ext < file.extents.Length; ext++)
{
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].extents[{1}].start = {2}", fileId,
ext, file.extents[ext].start);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].extents[{1}].length = {2}", fileId,
ext, file.extents[ext].length);
}
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown10 = 0x{1:X4}", fileId,
file.unknown10);
printedExtents.Add(fileId);
return Errno.NoError;
}
/// <summary>

View File

@@ -208,18 +208,17 @@ namespace DiscImageChef.Filesystems.LisaFS
{
DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out sysTag);
if(sysTag.fileID == fileId)
{
byte[] sector;
if(sysTag.fileID != fileId) continue;
if(!tags) sector = device.ReadSector(i);
else sector = device.ReadSectorTag(i, SectorTagType.AppleSectorTag);
byte[] sector;
// Relative block for $Loader starts at $Boot block
if(sysTag.fileID == FILEID_LOADER_SIGNED) sysTag.relPage--;
if(!tags) sector = device.ReadSector(i);
else sector = device.ReadSectorTag(i, SectorTagType.AppleSectorTag);
Array.Copy(sector, 0, buf, sector.Length * sysTag.relPage, sector.Length);
}
// Relative block for $Loader starts at $Boot block
if(sysTag.fileID == FILEID_LOADER_SIGNED) sysTag.relPage--;
Array.Copy(sector, 0, buf, sector.Length * sysTag.relPage, sector.Length);
}
if(!tags) systemFileCache.Add(fileId, buf);
@@ -445,18 +444,17 @@ namespace DiscImageChef.Filesystems.LisaFS
string filename = StringHandlers.CToString(entry.filename, CurrentEncoding);
// LisaOS is case insensitive
if(string.Compare(wantedFilename, filename, StringComparison.InvariantCultureIgnoreCase) == 0 &&
entry.parentID == fileId)
{
fileId = entry.fileID;
isDir = entry.fileType == 0x01;
if(string.Compare(wantedFilename, filename, StringComparison.InvariantCultureIgnoreCase) != 0 ||
entry.parentID != fileId) continue;
// Not last path element, and it's not a directory
if(lvl != pathElements.Length - 1 && !isDir) return Errno.NotDirectory;
fileId = entry.fileID;
isDir = entry.fileType == 0x01;
// Arrived last path element
if(lvl == pathElements.Length - 1) return Errno.NoError;
}
// Not last path element, and it's not a directory
if(lvl != pathElements.Length - 1 && !isDir) return Errno.NotDirectory;
// Arrived last path element
if(lvl == pathElements.Length - 1) return Errno.NoError;
}
}

View File

@@ -67,48 +67,44 @@ namespace DiscImageChef.Filesystems.LisaFS
if(before_mddf == -1 && searchTag.fileID == FILEID_LOADER_SIGNED) before_mddf = i - 1;
if(searchTag.fileID == FILEID_MDDF)
{
byte[] sector = imagePlugin.ReadSector((ulong)i);
MDDF info_mddf = new MDDF();
if(searchTag.fileID != FILEID_MDDF) continue;
info_mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C);
info_mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70);
info_mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74);
info_mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78);
info_mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C);
info_mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E);
byte[] sector = imagePlugin.ReadSector((ulong)i);
MDDF info_mddf = new MDDF();
DicConsole.DebugWriteLine("LisaFS plugin", "Current sector = {0}", i);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.mddf_block = {0}", info_mddf.mddf_block);
DicConsole.DebugWriteLine("LisaFS plugin", "Disk size = {0} sectors", imagePlugin.GetSectors());
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size = {0} sectors", info_mddf.vol_size);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - 1 = {0}",
info_mddf.volsize_minus_one);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - mddf.mddf_block -1 = {0}",
info_mddf.volsize_minus_mddf_minus_one);
DicConsole.DebugWriteLine("LisaFS plugin", "Disk sector = {0} bytes",
imagePlugin.GetSectorSize());
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.blocksize = {0} bytes", info_mddf.blocksize);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.datasize = {0} bytes", info_mddf.datasize);
info_mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C);
info_mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70);
info_mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74);
info_mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78);
info_mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C);
info_mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E);
if(info_mddf.mddf_block != i - before_mddf) return false;
DicConsole.DebugWriteLine("LisaFS plugin", "Current sector = {0}", i);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.mddf_block = {0}", info_mddf.mddf_block);
DicConsole.DebugWriteLine("LisaFS plugin", "Disk size = {0} sectors", imagePlugin.GetSectors());
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size = {0} sectors", info_mddf.vol_size);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - 1 = {0}", info_mddf.volsize_minus_one);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - mddf.mddf_block -1 = {0}",
info_mddf.volsize_minus_mddf_minus_one);
DicConsole.DebugWriteLine("LisaFS plugin", "Disk sector = {0} bytes", imagePlugin.GetSectorSize());
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.blocksize = {0} bytes", info_mddf.blocksize);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.datasize = {0} bytes", info_mddf.datasize);
if(info_mddf.vol_size > imagePlugin.GetSectors()) return false;
if(info_mddf.mddf_block != i - before_mddf) return false;
if(info_mddf.vol_size - 1 != info_mddf.volsize_minus_one) return false;
if(info_mddf.vol_size > imagePlugin.GetSectors()) return false;
if(info_mddf.vol_size - i - 1 != info_mddf.volsize_minus_mddf_minus_one - before_mddf)
return false;
if(info_mddf.vol_size - 1 != info_mddf.volsize_minus_one) return false;
if(info_mddf.datasize > info_mddf.blocksize) return false;
if(info_mddf.vol_size - i - 1 != info_mddf.volsize_minus_mddf_minus_one - before_mddf) return false;
if(info_mddf.blocksize < imagePlugin.GetSectorSize()) return false;
if(info_mddf.datasize > info_mddf.blocksize) return false;
if(info_mddf.datasize != imagePlugin.GetSectorSize()) return false;
if(info_mddf.blocksize < imagePlugin.GetSectorSize()) return false;
return true;
}
if(info_mddf.datasize != imagePlugin.GetSectorSize()) return false;
return true;
}
return false;
@@ -149,272 +145,233 @@ namespace DiscImageChef.Filesystems.LisaFS
if(before_mddf == -1 && searchTag.fileID == FILEID_LOADER_SIGNED) before_mddf = i - 1;
if(searchTag.fileID == FILEID_MDDF)
if(searchTag.fileID != FILEID_MDDF) continue;
byte[] sector = imagePlugin.ReadSector((ulong)i);
MDDF info_mddf = new MDDF();
byte[] pString = new byte[33];
uint lisa_time;
info_mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00);
info_mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02);
info_mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A);
Array.Copy(sector, 0x0C, pString, 0, 33);
info_mddf.volname = StringHandlers.PascalToString(pString, CurrentEncoding);
info_mddf.unknown1 = sector[0x2D];
Array.Copy(sector, 0x2E, pString, 0, 33);
// Prevent garbage
if(pString[0] <= 32) info_mddf.password = StringHandlers.PascalToString(pString, CurrentEncoding);
else info_mddf.password = "";
info_mddf.unknown2 = sector[0x4F];
info_mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50);
info_mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x58);
info_mddf.dtvc = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x5C);
info_mddf.dtcc = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x60);
info_mddf.dtvb = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x64);
info_mddf.dtvs = DateHandlers.LisaToDateTime(lisa_time);
info_mddf.unknown3 = BigEndianBitConverter.ToUInt32(sector, 0x68);
info_mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C);
info_mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70);
info_mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74);
info_mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78);
info_mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C);
info_mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E);
info_mddf.unknown4 = BigEndianBitConverter.ToUInt16(sector, 0x80);
info_mddf.unknown5 = BigEndianBitConverter.ToUInt32(sector, 0x82);
info_mddf.unknown6 = BigEndianBitConverter.ToUInt32(sector, 0x86);
info_mddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A);
info_mddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C);
info_mddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90);
info_mddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94);
info_mddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98);
info_mddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A);
info_mddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
info_mddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0);
info_mddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4);
info_mddf.unknown13 = BigEndianBitConverter.ToUInt32(sector, 0xA8);
info_mddf.unknown14 = BigEndianBitConverter.ToUInt32(sector, 0xAC);
info_mddf.filecount = BigEndianBitConverter.ToUInt16(sector, 0xB0);
info_mddf.unknown15 = BigEndianBitConverter.ToUInt32(sector, 0xB2);
info_mddf.unknown16 = BigEndianBitConverter.ToUInt32(sector, 0xB6);
info_mddf.freecount = BigEndianBitConverter.ToUInt32(sector, 0xBA);
info_mddf.unknown17 = BigEndianBitConverter.ToUInt16(sector, 0xBE);
info_mddf.unknown18 = BigEndianBitConverter.ToUInt32(sector, 0xC0);
info_mddf.overmount_stamp = BigEndianBitConverter.ToUInt64(sector, 0xC4);
info_mddf.serialization = BigEndianBitConverter.ToUInt32(sector, 0xCC);
info_mddf.unknown19 = BigEndianBitConverter.ToUInt32(sector, 0xD0);
info_mddf.unknown_timestamp = BigEndianBitConverter.ToUInt32(sector, 0xD4);
info_mddf.unknown20 = BigEndianBitConverter.ToUInt32(sector, 0xD8);
info_mddf.unknown21 = BigEndianBitConverter.ToUInt32(sector, 0xDC);
info_mddf.unknown22 = BigEndianBitConverter.ToUInt32(sector, 0xE0);
info_mddf.unknown23 = BigEndianBitConverter.ToUInt32(sector, 0xE4);
info_mddf.unknown24 = BigEndianBitConverter.ToUInt32(sector, 0xE8);
info_mddf.unknown25 = BigEndianBitConverter.ToUInt32(sector, 0xEC);
info_mddf.unknown26 = BigEndianBitConverter.ToUInt32(sector, 0xF0);
info_mddf.unknown27 = BigEndianBitConverter.ToUInt32(sector, 0xF4);
info_mddf.unknown28 = BigEndianBitConverter.ToUInt32(sector, 0xF8);
info_mddf.unknown29 = BigEndianBitConverter.ToUInt32(sector, 0xFC);
info_mddf.unknown30 = BigEndianBitConverter.ToUInt32(sector, 0x100);
info_mddf.unknown31 = BigEndianBitConverter.ToUInt32(sector, 0x104);
info_mddf.unknown32 = BigEndianBitConverter.ToUInt32(sector, 0x108);
info_mddf.unknown33 = BigEndianBitConverter.ToUInt32(sector, 0x10C);
info_mddf.unknown34 = BigEndianBitConverter.ToUInt32(sector, 0x110);
info_mddf.unknown35 = BigEndianBitConverter.ToUInt32(sector, 0x114);
info_mddf.backup_volid = BigEndianBitConverter.ToUInt64(sector, 0x118);
info_mddf.label_size = BigEndianBitConverter.ToUInt16(sector, 0x120);
info_mddf.fs_overhead = BigEndianBitConverter.ToUInt16(sector, 0x122);
info_mddf.result_scavenge = BigEndianBitConverter.ToUInt16(sector, 0x124);
info_mddf.boot_code = BigEndianBitConverter.ToUInt16(sector, 0x126);
info_mddf.boot_environ = BigEndianBitConverter.ToUInt16(sector, 0x6C);
info_mddf.unknown36 = BigEndianBitConverter.ToUInt32(sector, 0x12A);
info_mddf.unknown37 = BigEndianBitConverter.ToUInt32(sector, 0x12E);
info_mddf.unknown38 = BigEndianBitConverter.ToUInt32(sector, 0x132);
info_mddf.vol_sequence = BigEndianBitConverter.ToUInt16(sector, 0x136);
info_mddf.vol_left_mounted = sector[0x138];
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown1 = 0x{0:X2} ({0})", info_mddf.unknown1);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown2 = 0x{0:X2} ({0})", info_mddf.unknown2);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown3 = 0x{0:X8} ({0})", info_mddf.unknown3);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown4 = 0x{0:X4} ({0})", info_mddf.unknown4);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown5 = 0x{0:X8} ({0})", info_mddf.unknown5);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown6 = 0x{0:X8} ({0})", info_mddf.unknown6);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown7 = 0x{0:X8} ({0})", info_mddf.unknown7);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown9 = 0x{0:X4} ({0})", info_mddf.unknown9);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown10 = 0x{0:X8} ({0})", info_mddf.unknown10);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown11 = 0x{0:X8} ({0})", info_mddf.unknown11);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown12 = 0x{0:X8} ({0})", info_mddf.unknown12);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown13 = 0x{0:X8} ({0})", info_mddf.unknown13);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown14 = 0x{0:X8} ({0})", info_mddf.unknown14);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown15 = 0x{0:X8} ({0})", info_mddf.unknown15);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown16 = 0x{0:X8} ({0})", info_mddf.unknown16);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown17 = 0x{0:X4} ({0})", info_mddf.unknown17);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown18 = 0x{0:X8} ({0})", info_mddf.unknown18);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown19 = 0x{0:X8} ({0})", info_mddf.unknown19);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown20 = 0x{0:X8} ({0})", info_mddf.unknown20);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown21 = 0x{0:X8} ({0})", info_mddf.unknown21);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown22 = 0x{0:X8} ({0})", info_mddf.unknown22);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown23 = 0x{0:X8} ({0})", info_mddf.unknown23);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown24 = 0x{0:X8} ({0})", info_mddf.unknown24);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown25 = 0x{0:X8} ({0})", info_mddf.unknown25);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown26 = 0x{0:X8} ({0})", info_mddf.unknown26);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown27 = 0x{0:X8} ({0})", info_mddf.unknown27);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown28 = 0x{0:X8} ({0})", info_mddf.unknown28);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown29 = 0x{0:X8} ({0})", info_mddf.unknown29);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown30 = 0x{0:X8} ({0})", info_mddf.unknown30);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown31 = 0x{0:X8} ({0})", info_mddf.unknown31);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown32 = 0x{0:X8} ({0})", info_mddf.unknown32);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown33 = 0x{0:X8} ({0})", info_mddf.unknown33);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown34 = 0x{0:X8} ({0})", info_mddf.unknown34);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown35 = 0x{0:X8} ({0})", info_mddf.unknown35);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown36 = 0x{0:X8} ({0})", info_mddf.unknown36);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown37 = 0x{0:X8} ({0})", info_mddf.unknown37);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown38 = 0x{0:X8} ({0})", info_mddf.unknown38);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown_timestamp = 0x{0:X8} ({0}, {1})",
info_mddf.unknown_timestamp,
DateHandlers.LisaToDateTime(info_mddf.unknown_timestamp));
if(info_mddf.mddf_block != i - before_mddf) return;
if(info_mddf.vol_size > imagePlugin.GetSectors()) return;
if(info_mddf.vol_size - 1 != info_mddf.volsize_minus_one) return;
if(info_mddf.vol_size - i - 1 != info_mddf.volsize_minus_mddf_minus_one - before_mddf) return;
if(info_mddf.datasize > info_mddf.blocksize) return;
if(info_mddf.blocksize < imagePlugin.GetSectorSize()) return;
if(info_mddf.datasize != imagePlugin.GetSectorSize()) return;
switch(info_mddf.fsversion)
{
byte[] sector = imagePlugin.ReadSector((ulong)i);
MDDF info_mddf = new MDDF();
byte[] pString = new byte[33];
uint lisa_time;
info_mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00);
info_mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02);
info_mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A);
Array.Copy(sector, 0x0C, pString, 0, 33);
info_mddf.volname = StringHandlers.PascalToString(pString, CurrentEncoding);
info_mddf.unknown1 = sector[0x2D];
Array.Copy(sector, 0x2E, pString, 0, 33);
// Prevent garbage
if(pString[0] <= 32)
info_mddf.password = StringHandlers.PascalToString(pString, CurrentEncoding);
else info_mddf.password = "";
info_mddf.unknown2 = sector[0x4F];
info_mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50);
info_mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x58);
info_mddf.dtvc = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x5C);
info_mddf.dtcc = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x60);
info_mddf.dtvb = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x64);
info_mddf.dtvs = DateHandlers.LisaToDateTime(lisa_time);
info_mddf.unknown3 = BigEndianBitConverter.ToUInt32(sector, 0x68);
info_mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C);
info_mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70);
info_mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74);
info_mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78);
info_mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C);
info_mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E);
info_mddf.unknown4 = BigEndianBitConverter.ToUInt16(sector, 0x80);
info_mddf.unknown5 = BigEndianBitConverter.ToUInt32(sector, 0x82);
info_mddf.unknown6 = BigEndianBitConverter.ToUInt32(sector, 0x86);
info_mddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A);
info_mddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C);
info_mddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90);
info_mddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94);
info_mddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98);
info_mddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A);
info_mddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
info_mddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0);
info_mddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4);
info_mddf.unknown13 = BigEndianBitConverter.ToUInt32(sector, 0xA8);
info_mddf.unknown14 = BigEndianBitConverter.ToUInt32(sector, 0xAC);
info_mddf.filecount = BigEndianBitConverter.ToUInt16(sector, 0xB0);
info_mddf.unknown15 = BigEndianBitConverter.ToUInt32(sector, 0xB2);
info_mddf.unknown16 = BigEndianBitConverter.ToUInt32(sector, 0xB6);
info_mddf.freecount = BigEndianBitConverter.ToUInt32(sector, 0xBA);
info_mddf.unknown17 = BigEndianBitConverter.ToUInt16(sector, 0xBE);
info_mddf.unknown18 = BigEndianBitConverter.ToUInt32(sector, 0xC0);
info_mddf.overmount_stamp = BigEndianBitConverter.ToUInt64(sector, 0xC4);
info_mddf.serialization = BigEndianBitConverter.ToUInt32(sector, 0xCC);
info_mddf.unknown19 = BigEndianBitConverter.ToUInt32(sector, 0xD0);
info_mddf.unknown_timestamp = BigEndianBitConverter.ToUInt32(sector, 0xD4);
info_mddf.unknown20 = BigEndianBitConverter.ToUInt32(sector, 0xD8);
info_mddf.unknown21 = BigEndianBitConverter.ToUInt32(sector, 0xDC);
info_mddf.unknown22 = BigEndianBitConverter.ToUInt32(sector, 0xE0);
info_mddf.unknown23 = BigEndianBitConverter.ToUInt32(sector, 0xE4);
info_mddf.unknown24 = BigEndianBitConverter.ToUInt32(sector, 0xE8);
info_mddf.unknown25 = BigEndianBitConverter.ToUInt32(sector, 0xEC);
info_mddf.unknown26 = BigEndianBitConverter.ToUInt32(sector, 0xF0);
info_mddf.unknown27 = BigEndianBitConverter.ToUInt32(sector, 0xF4);
info_mddf.unknown28 = BigEndianBitConverter.ToUInt32(sector, 0xF8);
info_mddf.unknown29 = BigEndianBitConverter.ToUInt32(sector, 0xFC);
info_mddf.unknown30 = BigEndianBitConverter.ToUInt32(sector, 0x100);
info_mddf.unknown31 = BigEndianBitConverter.ToUInt32(sector, 0x104);
info_mddf.unknown32 = BigEndianBitConverter.ToUInt32(sector, 0x108);
info_mddf.unknown33 = BigEndianBitConverter.ToUInt32(sector, 0x10C);
info_mddf.unknown34 = BigEndianBitConverter.ToUInt32(sector, 0x110);
info_mddf.unknown35 = BigEndianBitConverter.ToUInt32(sector, 0x114);
info_mddf.backup_volid = BigEndianBitConverter.ToUInt64(sector, 0x118);
info_mddf.label_size = BigEndianBitConverter.ToUInt16(sector, 0x120);
info_mddf.fs_overhead = BigEndianBitConverter.ToUInt16(sector, 0x122);
info_mddf.result_scavenge = BigEndianBitConverter.ToUInt16(sector, 0x124);
info_mddf.boot_code = BigEndianBitConverter.ToUInt16(sector, 0x126);
info_mddf.boot_environ = BigEndianBitConverter.ToUInt16(sector, 0x6C);
info_mddf.unknown36 = BigEndianBitConverter.ToUInt32(sector, 0x12A);
info_mddf.unknown37 = BigEndianBitConverter.ToUInt32(sector, 0x12E);
info_mddf.unknown38 = BigEndianBitConverter.ToUInt32(sector, 0x132);
info_mddf.vol_sequence = BigEndianBitConverter.ToUInt16(sector, 0x136);
info_mddf.vol_left_mounted = sector[0x138];
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown1 = 0x{0:X2} ({0})",
info_mddf.unknown1);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown2 = 0x{0:X2} ({0})",
info_mddf.unknown2);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown3 = 0x{0:X8} ({0})",
info_mddf.unknown3);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown4 = 0x{0:X4} ({0})",
info_mddf.unknown4);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown5 = 0x{0:X8} ({0})",
info_mddf.unknown5);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown6 = 0x{0:X8} ({0})",
info_mddf.unknown6);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown7 = 0x{0:X8} ({0})",
info_mddf.unknown7);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown9 = 0x{0:X4} ({0})",
info_mddf.unknown9);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown10 = 0x{0:X8} ({0})",
info_mddf.unknown10);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown11 = 0x{0:X8} ({0})",
info_mddf.unknown11);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown12 = 0x{0:X8} ({0})",
info_mddf.unknown12);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown13 = 0x{0:X8} ({0})",
info_mddf.unknown13);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown14 = 0x{0:X8} ({0})",
info_mddf.unknown14);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown15 = 0x{0:X8} ({0})",
info_mddf.unknown15);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown16 = 0x{0:X8} ({0})",
info_mddf.unknown16);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown17 = 0x{0:X4} ({0})",
info_mddf.unknown17);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown18 = 0x{0:X8} ({0})",
info_mddf.unknown18);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown19 = 0x{0:X8} ({0})",
info_mddf.unknown19);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown20 = 0x{0:X8} ({0})",
info_mddf.unknown20);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown21 = 0x{0:X8} ({0})",
info_mddf.unknown21);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown22 = 0x{0:X8} ({0})",
info_mddf.unknown22);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown23 = 0x{0:X8} ({0})",
info_mddf.unknown23);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown24 = 0x{0:X8} ({0})",
info_mddf.unknown24);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown25 = 0x{0:X8} ({0})",
info_mddf.unknown25);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown26 = 0x{0:X8} ({0})",
info_mddf.unknown26);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown27 = 0x{0:X8} ({0})",
info_mddf.unknown27);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown28 = 0x{0:X8} ({0})",
info_mddf.unknown28);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown29 = 0x{0:X8} ({0})",
info_mddf.unknown29);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown30 = 0x{0:X8} ({0})",
info_mddf.unknown30);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown31 = 0x{0:X8} ({0})",
info_mddf.unknown31);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown32 = 0x{0:X8} ({0})",
info_mddf.unknown32);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown33 = 0x{0:X8} ({0})",
info_mddf.unknown33);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown34 = 0x{0:X8} ({0})",
info_mddf.unknown34);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown35 = 0x{0:X8} ({0})",
info_mddf.unknown35);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown36 = 0x{0:X8} ({0})",
info_mddf.unknown36);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown37 = 0x{0:X8} ({0})",
info_mddf.unknown37);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown38 = 0x{0:X8} ({0})",
info_mddf.unknown38);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown_timestamp = 0x{0:X8} ({0}, {1})",
info_mddf.unknown_timestamp,
DateHandlers.LisaToDateTime(info_mddf.unknown_timestamp));
if(info_mddf.mddf_block != i - before_mddf) return;
if(info_mddf.vol_size > imagePlugin.GetSectors()) return;
if(info_mddf.vol_size - 1 != info_mddf.volsize_minus_one) return;
if(info_mddf.vol_size - i - 1 != info_mddf.volsize_minus_mddf_minus_one - before_mddf) return;
if(info_mddf.datasize > info_mddf.blocksize) return;
if(info_mddf.blocksize < imagePlugin.GetSectorSize()) return;
if(info_mddf.datasize != imagePlugin.GetSectorSize()) return;
switch(info_mddf.fsversion)
{
case LisaFSv1:
sb.AppendLine("LisaFS v1");
break;
case LisaFSv2:
sb.AppendLine("LisaFS v2");
break;
case LisaFSv3:
sb.AppendLine("LisaFS v3");
break;
default:
sb.AppendFormat("Uknown LisaFS version {0}", info_mddf.fsversion).AppendLine();
break;
}
sb.AppendFormat("Volume name: \"{0}\"", info_mddf.volname).AppendLine();
sb.AppendFormat("Volume password: \"{0}\"", info_mddf.password).AppendLine();
sb.AppendFormat("Volume ID: 0x{0:X16}", info_mddf.volid).AppendLine();
sb.AppendFormat("Backup volume ID: 0x{0:X16}", info_mddf.backup_volid).AppendLine();
sb.AppendFormat("Master copy ID: 0x{0:X8}", info_mddf.master_copy_id).AppendLine();
sb.AppendFormat("Volume is number {0} of {1}", info_mddf.volnum, info_mddf.vol_sequence)
.AppendLine();
sb.AppendFormat("Serial number of Lisa computer that created this volume: {0}",
info_mddf.machine_id).AppendLine();
sb.AppendFormat("Serial number of Lisa computer that can use this volume's software {0}",
info_mddf.serialization).AppendLine();
sb.AppendFormat("Volume created on {0}", info_mddf.dtvc).AppendLine();
sb.AppendFormat("Some timestamp, says {0}", info_mddf.dtcc).AppendLine();
sb.AppendFormat("Volume backed up on {0}", info_mddf.dtvb).AppendLine();
sb.AppendFormat("Volume scavenged on {0}", info_mddf.dtvs).AppendLine();
sb.AppendFormat("MDDF is in block {0}", info_mddf.mddf_block + before_mddf).AppendLine();
sb.AppendFormat("There are {0} reserved blocks before volume", before_mddf).AppendLine();
sb.AppendFormat("{0} blocks minus one", info_mddf.volsize_minus_one).AppendLine();
sb.AppendFormat("{0} blocks minus one minus MDDF offset",
info_mddf.volsize_minus_mddf_minus_one).AppendLine();
sb.AppendFormat("{0} blocks in volume", info_mddf.vol_size).AppendLine();
sb.AppendFormat("{0} bytes per sector (uncooked)", info_mddf.blocksize).AppendLine();
sb.AppendFormat("{0} bytes per sector", info_mddf.datasize).AppendLine();
sb.AppendFormat("{0} blocks per cluster", info_mddf.clustersize).AppendLine();
sb.AppendFormat("{0} blocks in filesystem", info_mddf.fs_size).AppendLine();
sb.AppendFormat("{0} files in volume", info_mddf.filecount).AppendLine();
sb.AppendFormat("{0} blocks free", info_mddf.freecount).AppendLine();
sb.AppendFormat("{0} bytes in LisaInfo", info_mddf.label_size).AppendLine();
sb.AppendFormat("Filesystem overhead: {0}", info_mddf.fs_overhead).AppendLine();
sb.AppendFormat("Scanvenger result code: 0x{0:X8}", info_mddf.result_scavenge).AppendLine();
sb.AppendFormat("Boot code: 0x{0:X8}", info_mddf.boot_code).AppendLine();
sb.AppendFormat("Boot environment: 0x{0:X8}", info_mddf.boot_environ).AppendLine();
sb.AppendFormat("Overmount stamp: 0x{0:X16}", info_mddf.overmount_stamp).AppendLine();
sb.AppendFormat("S-Records start at {0} and spans for {1} blocks",
info_mddf.srec_ptr + info_mddf.mddf_block + before_mddf, info_mddf.srec_len)
.AppendLine();
if(info_mddf.vol_left_mounted == 0) sb.AppendLine("Volume is clean");
else sb.AppendLine("Volume is dirty");
information = sb.ToString();
xmlFSType = new Schemas.FileSystemType();
if(DateTime.Compare(info_mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFSType.BackupDate = info_mddf.dtvb;
xmlFSType.BackupDateSpecified = true;
}
xmlFSType.Clusters = info_mddf.vol_size;
xmlFSType.ClusterSize = info_mddf.clustersize * info_mddf.datasize;
if(DateTime.Compare(info_mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFSType.CreationDate = info_mddf.dtvc;
xmlFSType.CreationDateSpecified = true;
}
xmlFSType.Dirty = info_mddf.vol_left_mounted != 0;
xmlFSType.Files = info_mddf.filecount;
xmlFSType.FilesSpecified = true;
xmlFSType.FreeClusters = info_mddf.freecount;
xmlFSType.FreeClustersSpecified = true;
xmlFSType.Type = "LisaFS";
xmlFSType.VolumeName = info_mddf.volname;
xmlFSType.VolumeSerial = string.Format("{0:X16}", info_mddf.volid);
return;
case LisaFSv1:
sb.AppendLine("LisaFS v1");
break;
case LisaFSv2:
sb.AppendLine("LisaFS v2");
break;
case LisaFSv3:
sb.AppendLine("LisaFS v3");
break;
default:
sb.AppendFormat("Uknown LisaFS version {0}", info_mddf.fsversion).AppendLine();
break;
}
sb.AppendFormat("Volume name: \"{0}\"", info_mddf.volname).AppendLine();
sb.AppendFormat("Volume password: \"{0}\"", info_mddf.password).AppendLine();
sb.AppendFormat("Volume ID: 0x{0:X16}", info_mddf.volid).AppendLine();
sb.AppendFormat("Backup volume ID: 0x{0:X16}", info_mddf.backup_volid).AppendLine();
sb.AppendFormat("Master copy ID: 0x{0:X8}", info_mddf.master_copy_id).AppendLine();
sb.AppendFormat("Volume is number {0} of {1}", info_mddf.volnum, info_mddf.vol_sequence)
.AppendLine();
sb.AppendFormat("Serial number of Lisa computer that created this volume: {0}",
info_mddf.machine_id).AppendLine();
sb.AppendFormat("Serial number of Lisa computer that can use this volume's software {0}",
info_mddf.serialization).AppendLine();
sb.AppendFormat("Volume created on {0}", info_mddf.dtvc).AppendLine();
sb.AppendFormat("Some timestamp, says {0}", info_mddf.dtcc).AppendLine();
sb.AppendFormat("Volume backed up on {0}", info_mddf.dtvb).AppendLine();
sb.AppendFormat("Volume scavenged on {0}", info_mddf.dtvs).AppendLine();
sb.AppendFormat("MDDF is in block {0}", info_mddf.mddf_block + before_mddf).AppendLine();
sb.AppendFormat("There are {0} reserved blocks before volume", before_mddf).AppendLine();
sb.AppendFormat("{0} blocks minus one", info_mddf.volsize_minus_one).AppendLine();
sb.AppendFormat("{0} blocks minus one minus MDDF offset", info_mddf.volsize_minus_mddf_minus_one)
.AppendLine();
sb.AppendFormat("{0} blocks in volume", info_mddf.vol_size).AppendLine();
sb.AppendFormat("{0} bytes per sector (uncooked)", info_mddf.blocksize).AppendLine();
sb.AppendFormat("{0} bytes per sector", info_mddf.datasize).AppendLine();
sb.AppendFormat("{0} blocks per cluster", info_mddf.clustersize).AppendLine();
sb.AppendFormat("{0} blocks in filesystem", info_mddf.fs_size).AppendLine();
sb.AppendFormat("{0} files in volume", info_mddf.filecount).AppendLine();
sb.AppendFormat("{0} blocks free", info_mddf.freecount).AppendLine();
sb.AppendFormat("{0} bytes in LisaInfo", info_mddf.label_size).AppendLine();
sb.AppendFormat("Filesystem overhead: {0}", info_mddf.fs_overhead).AppendLine();
sb.AppendFormat("Scanvenger result code: 0x{0:X8}", info_mddf.result_scavenge).AppendLine();
sb.AppendFormat("Boot code: 0x{0:X8}", info_mddf.boot_code).AppendLine();
sb.AppendFormat("Boot environment: 0x{0:X8}", info_mddf.boot_environ).AppendLine();
sb.AppendFormat("Overmount stamp: 0x{0:X16}", info_mddf.overmount_stamp).AppendLine();
sb.AppendFormat("S-Records start at {0} and spans for {1} blocks",
info_mddf.srec_ptr + info_mddf.mddf_block + before_mddf, info_mddf.srec_len)
.AppendLine();
if(info_mddf.vol_left_mounted == 0) sb.AppendLine("Volume is clean");
else sb.AppendLine("Volume is dirty");
information = sb.ToString();
xmlFSType = new Schemas.FileSystemType();
if(DateTime.Compare(info_mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFSType.BackupDate = info_mddf.dtvb;
xmlFSType.BackupDateSpecified = true;
}
xmlFSType.Clusters = info_mddf.vol_size;
xmlFSType.ClusterSize = info_mddf.clustersize * info_mddf.datasize;
if(DateTime.Compare(info_mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFSType.CreationDate = info_mddf.dtvc;
xmlFSType.CreationDateSpecified = true;
}
xmlFSType.Dirty = info_mddf.vol_left_mounted != 0;
xmlFSType.Files = info_mddf.filecount;
xmlFSType.FilesSpecified = true;
xmlFSType.FreeClusters = info_mddf.freecount;
xmlFSType.FreeClustersSpecified = true;
xmlFSType.Type = "LisaFS";
xmlFSType.VolumeName = info_mddf.volname;
xmlFSType.VolumeSerial = string.Format("{0:X16}", info_mddf.volid);
return;
}
return;

View File

@@ -89,230 +89,229 @@ namespace DiscImageChef.Filesystems.LisaFS
if(volumePrefix == device.ImageInfo.Sectors && searchTag.fileID == FILEID_LOADER_SIGNED)
volumePrefix = i - 1;
if(searchTag.fileID == FILEID_MDDF)
if(searchTag.fileID != FILEID_MDDF) continue;
devTagSize = device.ReadSectorTag(i, SectorTagType.AppleSectorTag).Length;
byte[] sector = device.ReadSector(i);
mddf = new MDDF();
byte[] pString = new byte[33];
uint lisa_time;
mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00);
mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02);
mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A);
Array.Copy(sector, 0x0C, pString, 0, 33);
mddf.volname = StringHandlers.PascalToString(pString, CurrentEncoding);
mddf.unknown1 = sector[0x2D];
Array.Copy(sector, 0x2E, pString, 0, 33);
// Prevent garbage
if(pString[0] <= 32) mddf.password = StringHandlers.PascalToString(pString, CurrentEncoding);
else mddf.password = "";
mddf.unknown2 = sector[0x4F];
mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50);
mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x58);
mddf.dtvc = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x5C);
mddf.dtcc = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x60);
mddf.dtvb = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x64);
mddf.dtvs = DateHandlers.LisaToDateTime(lisa_time);
mddf.unknown3 = BigEndianBitConverter.ToUInt32(sector, 0x68);
mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C);
mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70);
mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74);
mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78);
mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C);
mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E);
mddf.unknown4 = BigEndianBitConverter.ToUInt16(sector, 0x80);
mddf.unknown5 = BigEndianBitConverter.ToUInt32(sector, 0x82);
mddf.unknown6 = BigEndianBitConverter.ToUInt32(sector, 0x86);
mddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A);
mddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C);
mddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90);
mddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94);
mddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98);
mddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A);
mddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
mddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0);
mddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4);
mddf.unknown13 = BigEndianBitConverter.ToUInt32(sector, 0xA8);
mddf.unknown14 = BigEndianBitConverter.ToUInt32(sector, 0xAC);
mddf.filecount = BigEndianBitConverter.ToUInt16(sector, 0xB0);
mddf.unknown15 = BigEndianBitConverter.ToUInt32(sector, 0xB2);
mddf.unknown16 = BigEndianBitConverter.ToUInt32(sector, 0xB6);
mddf.freecount = BigEndianBitConverter.ToUInt32(sector, 0xBA);
mddf.unknown17 = BigEndianBitConverter.ToUInt16(sector, 0xBE);
mddf.unknown18 = BigEndianBitConverter.ToUInt32(sector, 0xC0);
mddf.overmount_stamp = BigEndianBitConverter.ToUInt64(sector, 0xC4);
mddf.serialization = BigEndianBitConverter.ToUInt32(sector, 0xCC);
mddf.unknown19 = BigEndianBitConverter.ToUInt32(sector, 0xD0);
mddf.unknown_timestamp = BigEndianBitConverter.ToUInt32(sector, 0xD4);
mddf.unknown20 = BigEndianBitConverter.ToUInt32(sector, 0xD8);
mddf.unknown21 = BigEndianBitConverter.ToUInt32(sector, 0xDC);
mddf.unknown22 = BigEndianBitConverter.ToUInt32(sector, 0xE0);
mddf.unknown23 = BigEndianBitConverter.ToUInt32(sector, 0xE4);
mddf.unknown24 = BigEndianBitConverter.ToUInt32(sector, 0xE8);
mddf.unknown25 = BigEndianBitConverter.ToUInt32(sector, 0xEC);
mddf.unknown26 = BigEndianBitConverter.ToUInt32(sector, 0xF0);
mddf.unknown27 = BigEndianBitConverter.ToUInt32(sector, 0xF4);
mddf.unknown28 = BigEndianBitConverter.ToUInt32(sector, 0xF8);
mddf.unknown29 = BigEndianBitConverter.ToUInt32(sector, 0xFC);
mddf.unknown30 = BigEndianBitConverter.ToUInt32(sector, 0x100);
mddf.unknown31 = BigEndianBitConverter.ToUInt32(sector, 0x104);
mddf.unknown32 = BigEndianBitConverter.ToUInt32(sector, 0x108);
mddf.unknown33 = BigEndianBitConverter.ToUInt32(sector, 0x10C);
mddf.unknown34 = BigEndianBitConverter.ToUInt32(sector, 0x110);
mddf.unknown35 = BigEndianBitConverter.ToUInt32(sector, 0x114);
mddf.backup_volid = BigEndianBitConverter.ToUInt64(sector, 0x118);
mddf.label_size = BigEndianBitConverter.ToUInt16(sector, 0x120);
mddf.fs_overhead = BigEndianBitConverter.ToUInt16(sector, 0x122);
mddf.result_scavenge = BigEndianBitConverter.ToUInt16(sector, 0x124);
mddf.boot_code = BigEndianBitConverter.ToUInt16(sector, 0x126);
mddf.boot_environ = BigEndianBitConverter.ToUInt16(sector, 0x6C);
mddf.unknown36 = BigEndianBitConverter.ToUInt32(sector, 0x12A);
mddf.unknown37 = BigEndianBitConverter.ToUInt32(sector, 0x12E);
mddf.unknown38 = BigEndianBitConverter.ToUInt32(sector, 0x132);
mddf.vol_sequence = BigEndianBitConverter.ToUInt16(sector, 0x136);
mddf.vol_left_mounted = sector[0x138];
// Check that the MDDF is correct
if(mddf.mddf_block != i - volumePrefix || mddf.vol_size > device.GetSectors() ||
mddf.vol_size - 1 != mddf.volsize_minus_one ||
mddf.vol_size - i - 1 != mddf.volsize_minus_mddf_minus_one - volumePrefix ||
mddf.datasize > mddf.blocksize || mddf.blocksize < device.GetSectorSize() ||
mddf.datasize != device.GetSectorSize())
{
devTagSize = device.ReadSectorTag(i, SectorTagType.AppleSectorTag).Length;
DicConsole.DebugWriteLine("LisaFS plugin", "Incorrect MDDF found");
return Errno.InvalidArgument;
}
byte[] sector = device.ReadSector(i);
mddf = new MDDF();
byte[] pString = new byte[33];
uint lisa_time;
// Check MDDF version
switch(mddf.fsversion)
{
case LisaFSv1:
DicConsole.DebugWriteLine("LisaFS plugin", "Mounting LisaFS v1");
break;
case LisaFSv2:
DicConsole.DebugWriteLine("LisaFS plugin", "Mounting LisaFS v2");
break;
case LisaFSv3:
DicConsole.DebugWriteLine("LisaFS plugin", "Mounting LisaFS v3");
break;
default:
DicConsole.ErrorWriteLine("Cannot mount LisaFS version {0}", mddf.fsversion.ToString());
return Errno.NotSupported;
}
mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00);
mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02);
mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A);
Array.Copy(sector, 0x0C, pString, 0, 33);
mddf.volname = StringHandlers.PascalToString(pString, CurrentEncoding);
mddf.unknown1 = sector[0x2D];
Array.Copy(sector, 0x2E, pString, 0, 33);
// Prevent garbage
if(pString[0] <= 32) mddf.password = StringHandlers.PascalToString(pString, CurrentEncoding);
else mddf.password = "";
mddf.unknown2 = sector[0x4F];
mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50);
mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x58);
mddf.dtvc = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x5C);
mddf.dtcc = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x60);
mddf.dtvb = DateHandlers.LisaToDateTime(lisa_time);
lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x64);
mddf.dtvs = DateHandlers.LisaToDateTime(lisa_time);
mddf.unknown3 = BigEndianBitConverter.ToUInt32(sector, 0x68);
mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C);
mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70);
mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74);
mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78);
mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C);
mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E);
mddf.unknown4 = BigEndianBitConverter.ToUInt16(sector, 0x80);
mddf.unknown5 = BigEndianBitConverter.ToUInt32(sector, 0x82);
mddf.unknown6 = BigEndianBitConverter.ToUInt32(sector, 0x86);
mddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A);
mddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C);
mddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90);
mddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94);
mddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98);
mddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A);
mddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
mddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0);
mddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4);
mddf.unknown13 = BigEndianBitConverter.ToUInt32(sector, 0xA8);
mddf.unknown14 = BigEndianBitConverter.ToUInt32(sector, 0xAC);
mddf.filecount = BigEndianBitConverter.ToUInt16(sector, 0xB0);
mddf.unknown15 = BigEndianBitConverter.ToUInt32(sector, 0xB2);
mddf.unknown16 = BigEndianBitConverter.ToUInt32(sector, 0xB6);
mddf.freecount = BigEndianBitConverter.ToUInt32(sector, 0xBA);
mddf.unknown17 = BigEndianBitConverter.ToUInt16(sector, 0xBE);
mddf.unknown18 = BigEndianBitConverter.ToUInt32(sector, 0xC0);
mddf.overmount_stamp = BigEndianBitConverter.ToUInt64(sector, 0xC4);
mddf.serialization = BigEndianBitConverter.ToUInt32(sector, 0xCC);
mddf.unknown19 = BigEndianBitConverter.ToUInt32(sector, 0xD0);
mddf.unknown_timestamp = BigEndianBitConverter.ToUInt32(sector, 0xD4);
mddf.unknown20 = BigEndianBitConverter.ToUInt32(sector, 0xD8);
mddf.unknown21 = BigEndianBitConverter.ToUInt32(sector, 0xDC);
mddf.unknown22 = BigEndianBitConverter.ToUInt32(sector, 0xE0);
mddf.unknown23 = BigEndianBitConverter.ToUInt32(sector, 0xE4);
mddf.unknown24 = BigEndianBitConverter.ToUInt32(sector, 0xE8);
mddf.unknown25 = BigEndianBitConverter.ToUInt32(sector, 0xEC);
mddf.unknown26 = BigEndianBitConverter.ToUInt32(sector, 0xF0);
mddf.unknown27 = BigEndianBitConverter.ToUInt32(sector, 0xF4);
mddf.unknown28 = BigEndianBitConverter.ToUInt32(sector, 0xF8);
mddf.unknown29 = BigEndianBitConverter.ToUInt32(sector, 0xFC);
mddf.unknown30 = BigEndianBitConverter.ToUInt32(sector, 0x100);
mddf.unknown31 = BigEndianBitConverter.ToUInt32(sector, 0x104);
mddf.unknown32 = BigEndianBitConverter.ToUInt32(sector, 0x108);
mddf.unknown33 = BigEndianBitConverter.ToUInt32(sector, 0x10C);
mddf.unknown34 = BigEndianBitConverter.ToUInt32(sector, 0x110);
mddf.unknown35 = BigEndianBitConverter.ToUInt32(sector, 0x114);
mddf.backup_volid = BigEndianBitConverter.ToUInt64(sector, 0x118);
mddf.label_size = BigEndianBitConverter.ToUInt16(sector, 0x120);
mddf.fs_overhead = BigEndianBitConverter.ToUInt16(sector, 0x122);
mddf.result_scavenge = BigEndianBitConverter.ToUInt16(sector, 0x124);
mddf.boot_code = BigEndianBitConverter.ToUInt16(sector, 0x126);
mddf.boot_environ = BigEndianBitConverter.ToUInt16(sector, 0x6C);
mddf.unknown36 = BigEndianBitConverter.ToUInt32(sector, 0x12A);
mddf.unknown37 = BigEndianBitConverter.ToUInt32(sector, 0x12E);
mddf.unknown38 = BigEndianBitConverter.ToUInt32(sector, 0x132);
mddf.vol_sequence = BigEndianBitConverter.ToUInt16(sector, 0x136);
mddf.vol_left_mounted = sector[0x138];
// Initialize caches
extentCache = new Dictionary<short, ExtentFile>();
systemFileCache = new Dictionary<short, byte[]>();
fileCache = new Dictionary<short, byte[]>();
//catalogCache = new Dictionary<short, List<CatalogEntry>>();
fileSizeCache = new Dictionary<short, int>();
// Check that the MDDF is correct
if(mddf.mddf_block != i - volumePrefix || mddf.vol_size > device.GetSectors() ||
mddf.vol_size - 1 != mddf.volsize_minus_one ||
mddf.vol_size - i - 1 != mddf.volsize_minus_mddf_minus_one - volumePrefix ||
mddf.datasize > mddf.blocksize || mddf.blocksize < device.GetSectorSize() ||
mddf.datasize != device.GetSectorSize())
{
DicConsole.DebugWriteLine("LisaFS plugin", "Incorrect MDDF found");
return Errno.InvalidArgument;
}
Errno error;
// Check MDDF version
switch(mddf.fsversion)
{
case LisaFSv1:
DicConsole.DebugWriteLine("LisaFS plugin", "Mounting LisaFS v1");
break;
case LisaFSv2:
DicConsole.DebugWriteLine("LisaFS plugin", "Mounting LisaFS v2");
break;
case LisaFSv3:
DicConsole.DebugWriteLine("LisaFS plugin", "Mounting LisaFS v3");
break;
default:
DicConsole.ErrorWriteLine("Cannot mount LisaFS version {0}", mddf.fsversion.ToString());
return Errno.NotSupported;
}
mounted = true;
this.debug = debug;
// Initialize caches
extentCache = new Dictionary<short, ExtentFile>();
systemFileCache = new Dictionary<short, byte[]>();
fileCache = new Dictionary<short, byte[]>();
//catalogCache = new Dictionary<short, List<CatalogEntry>>();
fileSizeCache = new Dictionary<short, int>();
if(debug) printedExtents = new List<short>();
Errno error;
// Read the S-Records file
error = ReadSRecords();
if(error != Errno.NoError)
{
DicConsole.ErrorWriteLine("Error {0} reading S-Records file.", error);
return error;
}
mounted = true;
this.debug = debug;
directoryDTCCache = new Dictionary<short, DateTime>();
directoryDTCCache.Add(DIRID_ROOT, mddf.dtcc);
if(debug) printedExtents = new List<short>();
// Read the Catalog File
error = ReadCatalog();
// Read the S-Records file
error = ReadSRecords();
if(error != Errno.NoError)
{
DicConsole.DebugWriteLine("LisaFS plugin", "Cannot read Catalog File, error {0}",
error.ToString());
mounted = false;
return error;
}
// If debug, cache system files
if(debug)
{
byte[] temp;
error = ReadSystemFile(FILEID_BOOT_SIGNED, out temp);
if(error != Errno.NoError)
{
DicConsole.ErrorWriteLine("Error {0} reading S-Records file.", error);
return error;
}
directoryDTCCache = new Dictionary<short, DateTime>();
directoryDTCCache.Add(DIRID_ROOT, mddf.dtcc);
// Read the Catalog File
error = ReadCatalog();
if(error != Errno.NoError)
{
DicConsole.DebugWriteLine("LisaFS plugin", "Cannot read Catalog File, error {0}",
error.ToString());
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read boot blocks");
mounted = false;
return error;
}
// If debug, cache system files
if(debug)
error = ReadSystemFile(FILEID_LOADER_SIGNED, out temp);
if(error != Errno.NoError)
{
byte[] temp;
error = ReadSystemFile(FILEID_BOOT_SIGNED, out temp);
if(error != Errno.NoError)
{
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read boot blocks");
mounted = false;
return error;
}
error = ReadSystemFile(FILEID_LOADER_SIGNED, out temp);
if(error != Errno.NoError)
{
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read boot loader");
mounted = false;
return error;
}
error = ReadSystemFile((short)FILEID_MDDF, out temp);
if(error != Errno.NoError)
{
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read MDDF");
mounted = false;
return error;
}
error = ReadSystemFile((short)FILEID_BITMAP, out temp);
if(error != Errno.NoError)
{
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read volume bitmap");
mounted = false;
return error;
}
error = ReadSystemFile((short)FILEID_SRECORD, out temp);
if(error != Errno.NoError)
{
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read S-Records file");
mounted = false;
return error;
}
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read boot loader");
mounted = false;
return error;
}
// Create XML metadata for mounted filesystem
xmlFSType = new Schemas.FileSystemType();
if(DateTime.Compare(mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0)
error = ReadSystemFile((short)FILEID_MDDF, out temp);
if(error != Errno.NoError)
{
xmlFSType.BackupDate = mddf.dtvb;
xmlFSType.BackupDateSpecified = true;
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read MDDF");
mounted = false;
return error;
}
xmlFSType.Clusters = mddf.vol_size;
xmlFSType.ClusterSize = mddf.clustersize * mddf.datasize;
if(DateTime.Compare(mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFSType.CreationDate = mddf.dtvc;
xmlFSType.CreationDateSpecified = true;
}
xmlFSType.Dirty = mddf.vol_left_mounted != 0;
xmlFSType.Files = mddf.filecount;
xmlFSType.FilesSpecified = true;
xmlFSType.FreeClusters = mddf.freecount;
xmlFSType.FreeClustersSpecified = true;
xmlFSType.Type = "LisaFS";
xmlFSType.VolumeName = mddf.volname;
xmlFSType.VolumeSerial = string.Format("{0:X16}", mddf.volid);
return Errno.NoError;
error = ReadSystemFile((short)FILEID_BITMAP, out temp);
if(error != Errno.NoError)
{
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read volume bitmap");
mounted = false;
return error;
}
error = ReadSystemFile((short)FILEID_SRECORD, out temp);
if(error != Errno.NoError)
{
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read S-Records file");
mounted = false;
return error;
}
}
// Create XML metadata for mounted filesystem
xmlFSType = new Schemas.FileSystemType();
if(DateTime.Compare(mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFSType.BackupDate = mddf.dtvb;
xmlFSType.BackupDateSpecified = true;
}
xmlFSType.Clusters = mddf.vol_size;
xmlFSType.ClusterSize = mddf.clustersize * mddf.datasize;
if(DateTime.Compare(mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFSType.CreationDate = mddf.dtvc;
xmlFSType.CreationDateSpecified = true;
}
xmlFSType.Dirty = mddf.vol_left_mounted != 0;
xmlFSType.Files = mddf.filecount;
xmlFSType.FilesSpecified = true;
xmlFSType.FreeClusters = mddf.freecount;
xmlFSType.FreeClustersSpecified = true;
xmlFSType.Type = "LisaFS";
xmlFSType.VolumeName = mddf.volname;
xmlFSType.VolumeSerial = string.Format("{0:X16}", mddf.volid);
return Errno.NoError;
}
DicConsole.DebugWriteLine("LisaFS plugin", "Not a Lisa filesystem");