mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
* FileSystemIDandChk/Plugins/ODS.cs:
Use StringHandlers class to prevent garbage coming from strings (even if they are not C strings, it does not hurt). * FileSystemIDandChk/Plugins/AppleHFS.cs: Use constants. * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Use constants and EndianAwareBinaryReader class. * FileSystemIDandChk/Plugins/Opera.cs: Use a superblock structure and EndianAwareBinaryReader class, reduces lots of code. git-svn-id: svn://claunia.com/FileSystemIDandChk@15 17725271-3d32-4980-a8cb-9ff532f270ba
This commit is contained in:
@@ -1,3 +1,21 @@
|
||||
2012-08-05 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* Plugins/ODS.cs:
|
||||
Use StringHandlers class to prevent garbage coming from
|
||||
strings (even if they are not C strings, it does not hurt).
|
||||
|
||||
* Plugins/AppleHFS.cs:
|
||||
Use constants.
|
||||
|
||||
* Plugins/BFS.cs:
|
||||
* Plugins/AppleMFS.cs:
|
||||
* Plugins/AppleHFSPlus.cs:
|
||||
Use constants and EndianAwareBinaryReader class.
|
||||
|
||||
* Plugins/Opera.cs:
|
||||
Use a superblock structure and EndianAwareBinaryReader
|
||||
class, reduces lots of code.
|
||||
|
||||
2012-08-04 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* CToString.cs:
|
||||
|
||||
@@ -196,14 +196,14 @@ namespace FileSystemIDandChk.Plugins
|
||||
sb.AppendFormat("CNID of bootable Mac OS X directory: {0}", MDB.drFndrInfo5).AppendLine();
|
||||
sb.AppendFormat("Mac OS X Volume ID: {0:X8}{1:X8}", MDB.drFndrInfo6, MDB.drFndrInfo7).AppendLine();
|
||||
|
||||
if(MDB.drEmbedSigWord == 0x482B)
|
||||
if(MDB.drEmbedSigWord == HFSP_MAGIC)
|
||||
{
|
||||
sb.AppendLine("Volume wraps a HFS+ volume.");
|
||||
sb.AppendFormat("Starting block of the HFS+ volume: {0}", MDB.xdrStABNt).AppendLine();
|
||||
sb.AppendFormat("Allocations blocks of the HFS+ volume: {0}", MDB.xdrNumABlks).AppendLine();
|
||||
}
|
||||
|
||||
if(BB.signature == 0x4C4B)
|
||||
if(BB.signature == HFSBB_MAGIC)
|
||||
{
|
||||
sb.AppendLine("Volume is bootable.");
|
||||
sb.AppendLine();
|
||||
|
||||
@@ -9,6 +9,10 @@ namespace FileSystemIDandChk.Plugins
|
||||
{
|
||||
class AppleHFSPlus : Plugin
|
||||
{
|
||||
private const UInt16 HFS_MAGIC = 0x4244; // "BD"
|
||||
private const UInt16 HFSP_MAGIC = 0x482B; // "H+"
|
||||
private const UInt16 HFSX_MAGIC = 0x4858; // "HX"
|
||||
|
||||
public AppleHFSPlus(PluginBase Core)
|
||||
{
|
||||
base.Name = "Apple HFS+ filesystem";
|
||||
@@ -17,68 +21,49 @@ namespace FileSystemIDandChk.Plugins
|
||||
|
||||
public override bool Identify(FileStream stream, long offset)
|
||||
{
|
||||
byte[] sixteen_bit = new byte[2];
|
||||
byte[] thirtytwo_bit = new byte[4];
|
||||
UInt16 drSigWord;
|
||||
UInt16 xdrStABNt;
|
||||
UInt16 drAlBlSt;
|
||||
UInt32 drAlBlkSiz;
|
||||
|
||||
ushort signature;
|
||||
long hfsp_offset;
|
||||
bool wrapped = false;
|
||||
|
||||
EndianAwareBinaryReader eabr = new EndianAwareBinaryReader(stream, false); // BigEndian
|
||||
eabr.BaseStream.Seek(0x400 + offset, SeekOrigin.Begin);
|
||||
|
||||
stream.Seek(0x400 + offset, SeekOrigin.Begin);
|
||||
drSigWord = eabr.ReadUInt16();
|
||||
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
|
||||
drSigWord = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
|
||||
if(drSigWord == 0x4244) // "BD"
|
||||
if(drSigWord == HFS_MAGIC) // "BD"
|
||||
{
|
||||
stream.Seek(0x47C + offset, SeekOrigin.Begin); // Seek to embedded HFS+ signature
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
drSigWord = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
eabr.BaseStream.Seek(0x47C + offset, SeekOrigin.Begin); // Seek to embedded HFS+ signature
|
||||
drSigWord = eabr.ReadUInt16();
|
||||
|
||||
if(drSigWord == 0x482B) // "H+"
|
||||
if(drSigWord == HFSP_MAGIC) // "H+"
|
||||
{
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
xdrStABNt = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
xdrStABNt = eabr.ReadUInt16();
|
||||
|
||||
stream.Seek(0x414 + offset, SeekOrigin.Begin);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
drAlBlkSiz = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
eabr.BaseStream.Seek(0x414 + offset, SeekOrigin.Begin);
|
||||
drAlBlkSiz = eabr.ReadUInt32();
|
||||
|
||||
stream.Seek(0x41C + offset, SeekOrigin.Begin);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
drAlBlSt = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
eabr.BaseStream.Seek(0x41C + offset, SeekOrigin.Begin);
|
||||
drAlBlSt = eabr.ReadUInt16();
|
||||
|
||||
hfsp_offset = (drAlBlSt + xdrStABNt * (drAlBlkSiz / 512))*512;
|
||||
wrapped = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hfsp_offset = 0;
|
||||
wrapped = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hfsp_offset = 0;
|
||||
wrapped = false;
|
||||
}
|
||||
|
||||
stream.Seek(0x400 + offset + hfsp_offset, SeekOrigin.Begin);
|
||||
eabr.BaseStream.Seek(0x400 + offset + hfsp_offset, SeekOrigin.Begin);
|
||||
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
signature = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
if(signature == 0x482B || signature == 0x4858)
|
||||
drSigWord = eabr.ReadUInt16();
|
||||
if(drSigWord == HFSP_MAGIC || drSigWord == HFSX_MAGIC)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@@ -88,9 +73,6 @@ namespace FileSystemIDandChk.Plugins
|
||||
{
|
||||
information = "";
|
||||
|
||||
byte[] sixteen_bit = new byte[2];
|
||||
byte[] thirtytwo_bit = new byte[4];
|
||||
byte[] sixtyfour_bit = new byte[8];
|
||||
UInt16 drSigWord;
|
||||
UInt16 xdrStABNt;
|
||||
UInt16 drAlBlSt;
|
||||
@@ -99,36 +81,26 @@ namespace FileSystemIDandChk.Plugins
|
||||
|
||||
long hfsp_offset;
|
||||
bool wrapped = false;
|
||||
EndianAwareBinaryReader eabr = new EndianAwareBinaryReader(stream, false); // BigEndian
|
||||
|
||||
stream.Seek(0x400 + offset, SeekOrigin.Begin);
|
||||
eabr.BaseStream.Seek(0x400 + offset, SeekOrigin.Begin);
|
||||
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
drSigWord = eabr.ReadUInt16();
|
||||
|
||||
drSigWord = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
|
||||
if(drSigWord == 0x4244) // "BD"
|
||||
if(drSigWord == HFS_MAGIC) // "BD"
|
||||
{
|
||||
stream.Seek(0x47C + offset, SeekOrigin.Begin); // Seek to embedded HFS+ signature
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
drSigWord = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
eabr.BaseStream.Seek(0x47C + offset, SeekOrigin.Begin); // Seek to embedded HFS+ signature
|
||||
drSigWord = eabr.ReadUInt16();
|
||||
|
||||
if(drSigWord == 0x482B) // "H+"
|
||||
if(drSigWord == HFSP_MAGIC) // "H+"
|
||||
{
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
xdrStABNt = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
xdrStABNt = eabr.ReadUInt16();
|
||||
|
||||
stream.Seek(0x414 + offset, SeekOrigin.Begin);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
drAlBlkSiz = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
eabr.BaseStream.Seek(0x414 + offset, SeekOrigin.Begin);
|
||||
drAlBlkSiz = eabr.ReadUInt32();
|
||||
|
||||
stream.Seek(0x41C + offset, SeekOrigin.Begin);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
drAlBlSt = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
eabr.BaseStream.Seek(0x41C + offset, SeekOrigin.Begin);
|
||||
drAlBlSt = eabr.ReadUInt16();
|
||||
|
||||
hfsp_offset = (drAlBlSt + xdrStABNt * (drAlBlkSiz / 512))*512;
|
||||
wrapped = true;
|
||||
@@ -145,12 +117,10 @@ namespace FileSystemIDandChk.Plugins
|
||||
wrapped = false;
|
||||
}
|
||||
|
||||
stream.Seek(0x400 + offset + hfsp_offset, SeekOrigin.Begin);
|
||||
eabr.BaseStream.Seek(0x400 + offset + hfsp_offset, SeekOrigin.Begin);
|
||||
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
HPVH.signature = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
if(HPVH.signature == 0x482B || HPVH.signature == 0x4858)
|
||||
HPVH.signature = eabr.ReadUInt16();
|
||||
if(HPVH.signature == HFSP_MAGIC || HPVH.signature == HFSX_MAGIC)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -161,111 +131,53 @@ namespace FileSystemIDandChk.Plugins
|
||||
if(wrapped)
|
||||
sb.AppendLine("Volume is wrapped inside an HFS volume.");
|
||||
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
HPVH.version = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
HPVH.version = eabr.ReadUInt16();
|
||||
|
||||
if(HPVH.version == 4 || HPVH.version == 5)
|
||||
{
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.attributes = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
HPVH.lastMountedVersion = Encoding.ASCII.GetString(sixteen_bit);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.journalInfoBlock = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
HPVH.attributes = eabr.ReadUInt32();
|
||||
byte[] lastMountedVersion_b = eabr.ReadBytes(4);
|
||||
HPVH.lastMountedVersion = Encoding.ASCII.GetString(lastMountedVersion_b);
|
||||
HPVH.journalInfoBlock = eabr.ReadUInt32();
|
||||
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.createDate = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.modifyDate = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.backupDate = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.checkedDate = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
HPVH.createDate = eabr.ReadUInt32();
|
||||
HPVH.modifyDate = eabr.ReadUInt32();
|
||||
HPVH.backupDate = eabr.ReadUInt32();
|
||||
HPVH.checkedDate = eabr.ReadUInt32();
|
||||
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.fileCount = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.folderCount = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
HPVH.fileCount = eabr.ReadUInt32();
|
||||
HPVH.folderCount = eabr.ReadUInt32();
|
||||
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.blockSize = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.totalBlocks = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.freeBlocks = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
HPVH.blockSize = eabr.ReadUInt32();
|
||||
HPVH.totalBlocks = eabr.ReadUInt32();
|
||||
HPVH.freeBlocks = eabr.ReadUInt32();
|
||||
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.nextAllocation = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.rsrcClumpSize = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.dataClumpSize = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.nextCatalogID = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
HPVH.nextAllocation = eabr.ReadUInt32();
|
||||
HPVH.rsrcClumpSize = eabr.ReadUInt32();
|
||||
HPVH.dataClumpSize = eabr.ReadUInt32();
|
||||
HPVH.nextCatalogID = eabr.ReadUInt32();
|
||||
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.writeCount = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Seek(8,SeekOrigin.Current); // Skipping encoding bitmap
|
||||
HPVH.writeCount = eabr.ReadUInt32();
|
||||
eabr.BaseStream.Seek(8,SeekOrigin.Current); // Skipping encoding bitmap
|
||||
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.drFndrInfo0 = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.drFndrInfo1 = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.drFndrInfo2 = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.drFndrInfo3 = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Seek(4, SeekOrigin.Current); // Skipping reserved finder info
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.drFndrInfo5 = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.drFndrInfo6 = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
HPVH.drFndrInfo7 = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
HPVH.drFndrInfo0 = eabr.ReadUInt32();
|
||||
HPVH.drFndrInfo1 = eabr.ReadUInt32();
|
||||
HPVH.drFndrInfo2 = eabr.ReadUInt32();
|
||||
HPVH.drFndrInfo3 = eabr.ReadUInt32();
|
||||
eabr.BaseStream.Seek(4, SeekOrigin.Current); // Skipping reserved finder info
|
||||
HPVH.drFndrInfo5 = eabr.ReadUInt32();
|
||||
HPVH.drFndrInfo6 = eabr.ReadUInt32();
|
||||
HPVH.drFndrInfo7 = eabr.ReadUInt32();
|
||||
|
||||
stream.Read(sixtyfour_bit, 0, 8);
|
||||
sixtyfour_bit = Swapping.SwapEightBytes(sixtyfour_bit);
|
||||
HPVH.allocationFile_logicalSize = BitConverter.ToUInt64(sixtyfour_bit, 0);
|
||||
stream.Seek(72, SeekOrigin.Current); // Skip to next file info
|
||||
stream.Read(sixtyfour_bit, 0, 8);
|
||||
sixtyfour_bit = Swapping.SwapEightBytes(sixtyfour_bit);
|
||||
HPVH.extentsFile_logicalSize = BitConverter.ToUInt64(sixtyfour_bit, 0);
|
||||
stream.Seek(72, SeekOrigin.Current); // Skip to next file info
|
||||
stream.Read(sixtyfour_bit, 0, 8);
|
||||
sixtyfour_bit = Swapping.SwapEightBytes(sixtyfour_bit);
|
||||
HPVH.catalogFile_logicalSize = BitConverter.ToUInt64(sixtyfour_bit, 0);
|
||||
stream.Seek(72, SeekOrigin.Current); // Skip to next file info
|
||||
stream.Read(sixtyfour_bit, 0, 8);
|
||||
sixtyfour_bit = Swapping.SwapEightBytes(sixtyfour_bit);
|
||||
HPVH.attributesFile_logicalSize = BitConverter.ToUInt64(sixtyfour_bit, 0);
|
||||
stream.Seek(72, SeekOrigin.Current); // Skip to next file info
|
||||
stream.Read(sixtyfour_bit, 0, 8);
|
||||
sixtyfour_bit = Swapping.SwapEightBytes(sixtyfour_bit);
|
||||
HPVH.startupFile_logicalSize = BitConverter.ToUInt64(sixtyfour_bit, 0);
|
||||
HPVH.allocationFile_logicalSize = eabr.ReadUInt64();
|
||||
eabr.BaseStream.Seek(72, SeekOrigin.Current); // Skip to next file info
|
||||
HPVH.extentsFile_logicalSize = eabr.ReadUInt64();
|
||||
eabr.BaseStream.Seek(72, SeekOrigin.Current); // Skip to next file info
|
||||
HPVH.catalogFile_logicalSize = eabr.ReadUInt64();
|
||||
eabr.BaseStream.Seek(72, SeekOrigin.Current); // Skip to next file info
|
||||
HPVH.attributesFile_logicalSize = eabr.ReadUInt64();
|
||||
eabr.BaseStream.Seek(72, SeekOrigin.Current); // Skip to next file info
|
||||
HPVH.startupFile_logicalSize = eabr.ReadUInt64();
|
||||
|
||||
sb.AppendFormat("Filesystem version is {0}.", HPVH.version).AppendLine();
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace FileSystemIDandChk.Plugins
|
||||
{
|
||||
class AppleMFS : Plugin
|
||||
{
|
||||
private const UInt16 MFS_MAGIC = 0xD2D7;
|
||||
private const UInt16 MFSBB_MAGIC = 0x4C4B; // "LK"
|
||||
|
||||
public AppleMFS(PluginBase Core)
|
||||
{
|
||||
base.Name = "Apple Macintosh File System";
|
||||
@@ -17,17 +20,14 @@ namespace FileSystemIDandChk.Plugins
|
||||
|
||||
public override bool Identify(FileStream stream, long offset)
|
||||
{
|
||||
byte[] signature = new byte[2];
|
||||
ushort drSigWord;
|
||||
UInt16 drSigWord;
|
||||
|
||||
EndianAwareBinaryReader eabr = new EndianAwareBinaryReader(stream, false); // BigEndian
|
||||
eabr.BaseStream.Seek(0x400 + offset, SeekOrigin.Begin);
|
||||
|
||||
stream.Seek(0x400 + offset, SeekOrigin.Begin);
|
||||
drSigWord = eabr.ReadUInt16();
|
||||
|
||||
stream.Read(signature, 0, 2);
|
||||
signature = Swapping.SwapTwoBytes(signature);
|
||||
|
||||
drSigWord = BitConverter.ToUInt16(signature, 0);
|
||||
|
||||
if(drSigWord == 0xD2D7)
|
||||
if(drSigWord == MFS_MAGIC)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@@ -42,113 +42,62 @@ namespace FileSystemIDandChk.Plugins
|
||||
MFS_MasterDirectoryBlock MDB = new MFS_MasterDirectoryBlock();
|
||||
MFS_BootBlock BB = new MFS_BootBlock();
|
||||
|
||||
byte[] sixteen_bit = new byte[2];
|
||||
byte[] thirtytwo_bit = new byte[4];
|
||||
byte[] fifthteen_bytes = new byte[15];
|
||||
byte[] pString;
|
||||
byte[] variable_size;
|
||||
|
||||
stream.Seek(0x400 + offset, SeekOrigin.Begin);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
MDB.drSigWord = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
if(MDB.drSigWord != 0xD2D7)
|
||||
|
||||
EndianAwareBinaryReader eabr = new EndianAwareBinaryReader(stream, false); // BigEndian
|
||||
eabr.BaseStream.Seek(0x400 + offset, SeekOrigin.Begin);
|
||||
MDB.drSigWord = eabr.ReadUInt16();
|
||||
if(MDB.drSigWord != MFS_MAGIC)
|
||||
return;
|
||||
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
MDB.drCrDate = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
MDB.drLsBkUp = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
MDB.drAtrb = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
MDB.drNmFls = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
MDB.drDirSt = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
MDB.drBlLen = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
MDB.drNmAlBlks = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
MDB.drAlBlkSiz = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
MDB.drClpSiz = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
MDB.drAlBlSt = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
MDB.drNxtFNum = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
MDB.drFreeBks = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
MDB.drVNSiz = (byte)stream.ReadByte();
|
||||
variable_size = new byte[MDB.drVNSiz];
|
||||
stream.Read(variable_size, 0, MDB.drVNSiz);
|
||||
MDB.drCrDate = eabr.ReadUInt32();
|
||||
MDB.drLsBkUp = eabr.ReadUInt32();
|
||||
MDB.drAtrb = eabr.ReadUInt16();
|
||||
MDB.drNmFls = eabr.ReadUInt16();
|
||||
MDB.drDirSt = eabr.ReadUInt16();
|
||||
MDB.drBlLen = eabr.ReadUInt16();
|
||||
MDB.drNmAlBlks = eabr.ReadUInt16();
|
||||
MDB.drAlBlkSiz = eabr.ReadUInt32();
|
||||
MDB.drClpSiz = eabr.ReadUInt32();
|
||||
MDB.drAlBlSt = eabr.ReadUInt16();
|
||||
MDB.drNxtFNum = eabr.ReadUInt32();
|
||||
MDB.drFreeBks = eabr.ReadUInt16();
|
||||
MDB.drVNSiz = eabr.ReadByte();
|
||||
variable_size = eabr.ReadBytes(MDB.drVNSiz);
|
||||
MDB.drVN = Encoding.ASCII.GetString(variable_size);
|
||||
|
||||
stream.Seek(0 + offset, SeekOrigin.Begin);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
BB.signature = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
eabr.BaseStream.Seek(0 + offset, SeekOrigin.Begin);
|
||||
BB.signature = eabr.ReadUInt16();
|
||||
|
||||
if(BB.signature == 0x4C4B)
|
||||
if(BB.signature == MFSBB_MAGIC)
|
||||
{
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
BB.branch = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
BB.boot_flags = (byte)stream.ReadByte();
|
||||
BB.boot_version = (byte)stream.ReadByte();
|
||||
BB.branch = eabr.ReadUInt32();
|
||||
BB.boot_flags = eabr.ReadByte();
|
||||
BB.boot_version = eabr.ReadByte();
|
||||
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
BB.sec_sv_pages = BitConverter.ToInt16(sixteen_bit, 0);
|
||||
|
||||
stream.Seek(1, SeekOrigin.Current);
|
||||
stream.Read(fifthteen_bytes, 0, 15);
|
||||
BB.system_name = Encoding.ASCII.GetString(fifthteen_bytes);
|
||||
stream.Seek(1, SeekOrigin.Current);
|
||||
stream.Read(fifthteen_bytes, 0, 15);
|
||||
BB.finder_name = Encoding.ASCII.GetString(fifthteen_bytes);
|
||||
stream.Seek(1, SeekOrigin.Current);
|
||||
stream.Read(fifthteen_bytes, 0, 15);
|
||||
BB.debug_name = Encoding.ASCII.GetString(fifthteen_bytes);
|
||||
stream.Seek(1, SeekOrigin.Current);
|
||||
stream.Read(fifthteen_bytes, 0, 15);
|
||||
BB.disasm_name = Encoding.ASCII.GetString(fifthteen_bytes);
|
||||
stream.Seek(1, SeekOrigin.Current);
|
||||
stream.Read(fifthteen_bytes, 0, 15);
|
||||
BB.stupscr_name = Encoding.ASCII.GetString(fifthteen_bytes);
|
||||
stream.Seek(1, SeekOrigin.Current);
|
||||
stream.Read(fifthteen_bytes, 0, 15);
|
||||
BB.bootup_name = Encoding.ASCII.GetString(fifthteen_bytes);
|
||||
stream.Seek(1, SeekOrigin.Current);
|
||||
stream.Read(fifthteen_bytes, 0, 15);
|
||||
BB.clipbrd_name = Encoding.ASCII.GetString(fifthteen_bytes);
|
||||
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
BB.max_files = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
stream.Read(sixteen_bit, 0, 2);
|
||||
sixteen_bit = Swapping.SwapTwoBytes(sixteen_bit);
|
||||
BB.queue_size = BitConverter.ToUInt16(sixteen_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
BB.heap_128k = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
BB.heap_256k = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
stream.Read(thirtytwo_bit, 0, 4);
|
||||
thirtytwo_bit = Swapping.SwapFourBytes(thirtytwo_bit);
|
||||
BB.heap_512k = BitConverter.ToUInt32(thirtytwo_bit, 0);
|
||||
BB.sec_sv_pages = eabr.ReadInt16();
|
||||
|
||||
pString = eabr.ReadBytes(16);
|
||||
BB.system_name = StringHandlers.PascalToString(pString);
|
||||
pString = eabr.ReadBytes(16);
|
||||
BB.finder_name = StringHandlers.PascalToString(pString);
|
||||
pString = eabr.ReadBytes(16);
|
||||
BB.debug_name = StringHandlers.PascalToString(pString);
|
||||
pString = eabr.ReadBytes(16);
|
||||
BB.disasm_name = StringHandlers.PascalToString(pString);
|
||||
pString = eabr.ReadBytes(16);
|
||||
BB.stupscr_name = StringHandlers.PascalToString(pString);
|
||||
pString = eabr.ReadBytes(16);
|
||||
BB.bootup_name = StringHandlers.PascalToString(pString);
|
||||
pString = eabr.ReadBytes(16);
|
||||
BB.clipbrd_name = StringHandlers.PascalToString(pString);
|
||||
|
||||
BB.max_files = eabr.ReadUInt16();
|
||||
BB.queue_size = eabr.ReadUInt16();
|
||||
BB.heap_128k = eabr.ReadUInt32();
|
||||
BB.heap_256k = eabr.ReadUInt32();
|
||||
BB.heap_512k = eabr.ReadUInt32();
|
||||
}
|
||||
else
|
||||
BB.signature = 0x0000;
|
||||
@@ -173,7 +122,7 @@ namespace FileSystemIDandChk.Plugins
|
||||
sb.AppendFormat("{0} unused allocation blocks.", MDB.drFreeBks).AppendLine();
|
||||
sb.AppendFormat("Volume name: {0}", MDB.drVN).AppendLine();
|
||||
|
||||
if(BB.signature == 0x4C4B)
|
||||
if(BB.signature == MFSBB_MAGIC)
|
||||
{
|
||||
sb.AppendLine("Volume is bootable.");
|
||||
sb.AppendLine();
|
||||
|
||||
@@ -9,6 +9,20 @@ namespace FileSystemIDandChk.Plugins
|
||||
{
|
||||
class BeFS : Plugin
|
||||
{
|
||||
// Little endian constants (that is, as read by .NET :p)
|
||||
private const UInt32 BEFS_MAGIC1 = 0x42465331;
|
||||
private const UInt32 BEFS_MAGIC2 = 0xDD121031;
|
||||
private const UInt32 BEFS_MAGIC3 = 0x15B6830E;
|
||||
private const UInt32 BEFS_ENDIAN = 0x42494745;
|
||||
|
||||
// Big endian constants
|
||||
private const UInt32 BEFS_CIGAM1 = 0x31534642;
|
||||
private const UInt32 BEFS_NAIDNE = 0x45474942;
|
||||
|
||||
// Common constants
|
||||
private const UInt32 BEFS_CLEAN = 0x434C454E;
|
||||
private const UInt32 BEFS_DIRTY = 0x44495254;
|
||||
|
||||
public BeFS(PluginBase Core)
|
||||
{
|
||||
base.Name = "Be Filesystem";
|
||||
@@ -25,9 +39,9 @@ namespace FileSystemIDandChk.Plugins
|
||||
|
||||
magic = br.ReadUInt32();
|
||||
|
||||
if(magic == 0x42465331) // Little-endian BFS
|
||||
if(magic == BEFS_MAGIC1) // Little-endian BFS
|
||||
return true;
|
||||
else if(magic == 0x31534642) // Big-endian BFS
|
||||
else if(magic == BEFS_CIGAM1) // Big-endian BFS
|
||||
return true;
|
||||
else
|
||||
{
|
||||
@@ -35,9 +49,9 @@ namespace FileSystemIDandChk.Plugins
|
||||
|
||||
magic = br.ReadUInt32();
|
||||
|
||||
if(magic == 0x42465331) // Little-endian BFS
|
||||
if(magic == BEFS_MAGIC1) // Little-endian BFS
|
||||
return true;
|
||||
else if(magic == 0x31534642) // Big-endian BFS
|
||||
else if(magic == BEFS_CIGAM1) // Big-endian BFS
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@@ -48,6 +62,7 @@ namespace FileSystemIDandChk.Plugins
|
||||
{
|
||||
information = "";
|
||||
byte[] name_bytes = new byte[32];
|
||||
bool littleendian = true;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -57,134 +72,63 @@ namespace FileSystemIDandChk.Plugins
|
||||
|
||||
br.BaseStream.Seek(32 + offset, SeekOrigin.Begin); // Seek to magic
|
||||
besb.magic1 = br.ReadUInt32();
|
||||
if(besb.magic1 == 0x42465331 || besb.magic1 == 0x31534642) // Magic is at offset
|
||||
if(besb.magic1 == BEFS_MAGIC1 || besb.magic1 == BEFS_CIGAM1) // Magic is at offset
|
||||
{
|
||||
br.BaseStream.Seek(offset, SeekOrigin.Begin);
|
||||
if(besb.magic1 == BEFS_CIGAM1)
|
||||
littleendian = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
br.BaseStream.Seek(32 + 512 + offset, SeekOrigin.Begin); // Seek to magic
|
||||
besb.magic1 = br.ReadUInt32();
|
||||
|
||||
if(besb.magic1 == 0x42465331 || besb.magic1 == 0x31534642) // There is a boot sector
|
||||
if(besb.magic1 == BEFS_MAGIC1 || besb.magic1 == BEFS_CIGAM1) // There is a boot sector
|
||||
{
|
||||
br.BaseStream.Seek(offset + 512, SeekOrigin.Begin);
|
||||
if(besb.magic1 == BEFS_CIGAM1)
|
||||
littleendian = false;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
name_bytes = br.ReadBytes(32);
|
||||
|
||||
EndianAwareBinaryReader eabr = new EndianAwareBinaryReader(stream, littleendian);
|
||||
name_bytes = eabr.ReadBytes(32);
|
||||
|
||||
besb.name = StringHandlers.CToString(name_bytes);
|
||||
besb.magic1 = br.ReadUInt32();
|
||||
besb.fs_byte_order = br.ReadUInt32();
|
||||
besb.block_size = br.ReadUInt32();
|
||||
besb.block_shift = br.ReadUInt32();
|
||||
besb.num_blocks = br.ReadInt64();
|
||||
besb.used_blocks = br.ReadInt64();
|
||||
besb.inode_size = br.ReadInt32();
|
||||
besb.magic2 = br.ReadUInt32();
|
||||
besb.blocks_per_ag = br.ReadInt32();
|
||||
besb.ag_shift = br.ReadInt32();
|
||||
besb.num_ags = br.ReadInt32();
|
||||
besb.flags = br.ReadUInt32();
|
||||
besb.log_blocks_ag = br.ReadInt32();
|
||||
besb.log_blocks_start = br.ReadUInt16();
|
||||
besb.log_blocks_len = br.ReadUInt16();
|
||||
besb.log_start = br.ReadInt64();
|
||||
besb.log_end = br.ReadInt64();
|
||||
besb.magic3 = br.ReadUInt32();
|
||||
besb.root_dir_ag = br.ReadInt32();
|
||||
besb.root_dir_start = br.ReadUInt16();
|
||||
besb.root_dir_len = br.ReadUInt16();
|
||||
besb.indices_ag = br.ReadInt32();
|
||||
besb.indices_start = br.ReadUInt16();
|
||||
besb.indices_len = br.ReadUInt16();
|
||||
besb.magic1 = eabr.ReadUInt32();
|
||||
besb.fs_byte_order = eabr.ReadUInt32();
|
||||
besb.block_size = eabr.ReadUInt32();
|
||||
besb.block_shift = eabr.ReadUInt32();
|
||||
besb.num_blocks = eabr.ReadInt64();
|
||||
besb.used_blocks = eabr.ReadInt64();
|
||||
besb.inode_size = eabr.ReadInt32();
|
||||
besb.magic2 = eabr.ReadUInt32();
|
||||
besb.blocks_per_ag = eabr.ReadInt32();
|
||||
besb.ag_shift = eabr.ReadInt32();
|
||||
besb.num_ags = eabr.ReadInt32();
|
||||
besb.flags = eabr.ReadUInt32();
|
||||
besb.log_blocks_ag = eabr.ReadInt32();
|
||||
besb.log_blocks_start = eabr.ReadUInt16();
|
||||
besb.log_blocks_len = eabr.ReadUInt16();
|
||||
besb.log_start = eabr.ReadInt64();
|
||||
besb.log_end = eabr.ReadInt64();
|
||||
besb.magic3 = eabr.ReadUInt32();
|
||||
besb.root_dir_ag = eabr.ReadInt32();
|
||||
besb.root_dir_start = eabr.ReadUInt16();
|
||||
besb.root_dir_len = eabr.ReadUInt16();
|
||||
besb.indices_ag = eabr.ReadInt32();
|
||||
besb.indices_start = eabr.ReadUInt16();
|
||||
besb.indices_len = eabr.ReadUInt16();
|
||||
|
||||
if(besb.magic1 == 0x31534642 && besb.fs_byte_order == 0x45474942) // Big-endian filesystem
|
||||
{
|
||||
if(littleendian) // Big-endian filesystem
|
||||
sb.AppendLine("Big-endian BeFS");
|
||||
|
||||
// Swap everything in the super block
|
||||
byte[] sixteen_bits = new byte[2];
|
||||
byte[] thirtytwo_bits = new byte[4];
|
||||
byte[] sixtyfour_bits = new byte[8];
|
||||
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.magic1);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.magic1 = BitConverter.ToUInt32(thirtytwo_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.fs_byte_order);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.fs_byte_order = BitConverter.ToUInt32(thirtytwo_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.block_size);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.block_size = BitConverter.ToUInt32(thirtytwo_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.block_shift);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.block_shift = BitConverter.ToUInt32(thirtytwo_bits, 0);
|
||||
sixtyfour_bits = BitConverter.GetBytes(besb.num_blocks);
|
||||
sixtyfour_bits = Swapping.SwapEightBytes(sixtyfour_bits);
|
||||
besb.num_blocks = BitConverter.ToInt64(sixtyfour_bits, 0);
|
||||
sixtyfour_bits = BitConverter.GetBytes(besb.used_blocks);
|
||||
sixtyfour_bits = Swapping.SwapEightBytes(sixtyfour_bits);
|
||||
besb.used_blocks = BitConverter.ToInt64(sixtyfour_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.inode_size);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.inode_size = BitConverter.ToInt32(thirtytwo_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.magic2);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.magic2 = BitConverter.ToUInt32(thirtytwo_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.blocks_per_ag);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.blocks_per_ag = BitConverter.ToInt32(thirtytwo_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.ag_shift);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.ag_shift = BitConverter.ToInt32(thirtytwo_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.num_ags);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.num_ags = BitConverter.ToInt32(thirtytwo_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.flags);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.flags = BitConverter.ToUInt32(thirtytwo_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.log_blocks_ag);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.log_blocks_ag = BitConverter.ToInt32(thirtytwo_bits, 0);
|
||||
sixteen_bits = BitConverter.GetBytes(besb.log_blocks_start);
|
||||
sixteen_bits = Swapping.SwapTwoBytes(sixteen_bits);
|
||||
besb.log_blocks_start = BitConverter.ToUInt16(sixteen_bits, 0);
|
||||
sixteen_bits = BitConverter.GetBytes(besb.log_blocks_len);
|
||||
sixteen_bits = Swapping.SwapTwoBytes(sixteen_bits);
|
||||
besb.log_blocks_len = BitConverter.ToUInt16(sixteen_bits, 0);
|
||||
sixtyfour_bits = BitConverter.GetBytes(besb.log_start);
|
||||
sixtyfour_bits = Swapping.SwapEightBytes(sixtyfour_bits);
|
||||
besb.log_start = BitConverter.ToInt64(sixtyfour_bits, 0);
|
||||
sixtyfour_bits = BitConverter.GetBytes(besb.log_end);
|
||||
sixtyfour_bits = Swapping.SwapEightBytes(sixtyfour_bits);
|
||||
besb.log_end = BitConverter.ToInt64(sixtyfour_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.magic3);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.magic3 = BitConverter.ToUInt32(thirtytwo_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.root_dir_ag);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.root_dir_ag = BitConverter.ToInt32(thirtytwo_bits, 0);
|
||||
sixteen_bits = BitConverter.GetBytes(besb.root_dir_start);
|
||||
sixteen_bits = Swapping.SwapTwoBytes(sixteen_bits);
|
||||
besb.root_dir_start = BitConverter.ToUInt16(sixteen_bits, 0);
|
||||
sixteen_bits = BitConverter.GetBytes(besb.root_dir_len);
|
||||
sixteen_bits = Swapping.SwapTwoBytes(sixteen_bits);
|
||||
besb.root_dir_len = BitConverter.ToUInt16(sixteen_bits, 0);
|
||||
thirtytwo_bits = BitConverter.GetBytes(besb.indices_ag);
|
||||
thirtytwo_bits = Swapping.SwapFourBytes(thirtytwo_bits);
|
||||
besb.indices_ag = BitConverter.ToInt32(thirtytwo_bits, 0);
|
||||
sixteen_bits = BitConverter.GetBytes(besb.indices_start);
|
||||
sixteen_bits = Swapping.SwapTwoBytes(sixteen_bits);
|
||||
besb.indices_start = BitConverter.ToUInt16(sixteen_bits, 0);
|
||||
sixteen_bits = BitConverter.GetBytes(besb.indices_len);
|
||||
sixteen_bits = Swapping.SwapTwoBytes(sixteen_bits);
|
||||
besb.indices_len = BitConverter.ToUInt16(sixteen_bits, 0);
|
||||
}
|
||||
else
|
||||
sb.AppendLine("Little-endian BeFS");
|
||||
|
||||
if(besb.magic1 != 0x42465331 || besb.fs_byte_order != 0x42494745 ||
|
||||
besb.magic2 != 0xDD121031 || besb.magic3 != 0x15B6830E ||
|
||||
if(besb.magic1 != BEFS_MAGIC1 || besb.fs_byte_order != BEFS_ENDIAN ||
|
||||
besb.magic2 != BEFS_MAGIC2 || besb.magic3 != BEFS_MAGIC3 ||
|
||||
besb.root_dir_len != 1 || besb.indices_len != 1 ||
|
||||
(1 << (int)besb.block_shift) != besb.block_size)
|
||||
{
|
||||
@@ -199,14 +143,14 @@ namespace FileSystemIDandChk.Plugins
|
||||
1 << (int)besb.block_shift, besb.block_size).AppendLine();
|
||||
}
|
||||
|
||||
if(besb.flags == 0x434C454E)
|
||||
if(besb.flags == BEFS_CLEAN)
|
||||
{
|
||||
if(besb.log_start == besb.log_end)
|
||||
sb.AppendLine("Filesystem is clean");
|
||||
else
|
||||
sb.AppendLine("Filesystem is dirty");
|
||||
}
|
||||
else if(besb.flags == 0x44495254)
|
||||
else if(besb.flags == BEFS_DIRTY)
|
||||
sb.AppendLine("Filesystem is dirty");
|
||||
else
|
||||
sb.AppendFormat("Unknown flags: {0:X8}", besb.flags).AppendLine();
|
||||
|
||||
@@ -98,13 +98,13 @@ namespace FileSystemIDandChk.Plugins
|
||||
homeblock.reserved1 = br.ReadBytes(302);
|
||||
homeblock.serialnum = br.ReadUInt32();
|
||||
temp_string = br.ReadBytes(12);
|
||||
homeblock.strucname = Encoding.ASCII.GetString(temp_string);
|
||||
homeblock.strucname = StringHandlers.CToString(temp_string);
|
||||
temp_string = br.ReadBytes(12);
|
||||
homeblock.volname = Encoding.ASCII.GetString(temp_string);
|
||||
homeblock.volname = StringHandlers.CToString(temp_string);
|
||||
temp_string = br.ReadBytes(12);
|
||||
homeblock.ownername = Encoding.ASCII.GetString(temp_string);
|
||||
homeblock.ownername = StringHandlers.CToString(temp_string);
|
||||
temp_string = br.ReadBytes(12);
|
||||
homeblock.format = Encoding.ASCII.GetString(temp_string);
|
||||
homeblock.format = StringHandlers.CToString(temp_string);
|
||||
homeblock.reserved2 = br.ReadUInt16();
|
||||
homeblock.checksum2 = br.ReadUInt16();
|
||||
|
||||
|
||||
@@ -42,93 +42,67 @@ namespace FileSystemIDandChk.Plugins
|
||||
|
||||
fileStream.Seek(0 + offset, SeekOrigin.Begin);
|
||||
|
||||
byte[] record_type = new byte[1];
|
||||
byte[] sync_bytes = new byte[5];
|
||||
byte[] record_version = new byte[1];
|
||||
byte[] volume_flags = new byte[1];
|
||||
byte[] volume_comment = new byte[32];
|
||||
byte[] volume_label = new byte[32];
|
||||
byte[] volume_id = new byte[4];
|
||||
byte[] block_size = new byte[4];
|
||||
byte[] block_count = new byte[4];
|
||||
byte[] root_dirid = new byte[4];
|
||||
byte[] rootdir_blocks = new byte[4];
|
||||
byte[] rootdir_bsize = new byte[4];
|
||||
byte[] last_root_copy = new byte[4];
|
||||
EndianAwareBinaryReader eabr = new EndianAwareBinaryReader(fileStream, false); // BigEndian
|
||||
OperaSuperBlock sb = new OperaSuperBlock();
|
||||
byte[] cString;
|
||||
|
||||
fileStream.Read(record_type, 0, 1);
|
||||
fileStream.Read(sync_bytes, 0, 5);
|
||||
fileStream.Read(record_version, 0, 1);
|
||||
fileStream.Read(volume_flags, 0, 1);
|
||||
fileStream.Read(volume_comment, 0, 32);
|
||||
fileStream.Read(volume_label, 0, 32);
|
||||
fileStream.Read(volume_id, 0, 4);
|
||||
fileStream.Read(block_size, 0, 4);
|
||||
fileStream.Read(block_count, 0, 4);
|
||||
fileStream.Read(root_dirid, 0, 4);
|
||||
fileStream.Read(rootdir_blocks, 0, 4);
|
||||
fileStream.Read(rootdir_bsize, 0, 4);
|
||||
fileStream.Read(last_root_copy, 0, 4);
|
||||
sb.record_type = eabr.ReadByte();
|
||||
sb.sync_bytes = eabr.ReadBytes(5);
|
||||
sb.record_version = eabr.ReadByte();
|
||||
sb.volume_flags = eabr.ReadByte();
|
||||
cString = eabr.ReadBytes(32);
|
||||
sb.volume_comment = StringHandlers.CToString(cString);
|
||||
cString = eabr.ReadBytes(32);
|
||||
sb.volume_label = StringHandlers.CToString(cString);
|
||||
sb.volume_id = eabr.ReadInt32();
|
||||
sb.block_size = eabr.ReadInt32();
|
||||
sb.block_count = eabr.ReadInt32();
|
||||
sb.root_dirid = eabr.ReadInt32();
|
||||
sb.rootdir_blocks = eabr.ReadInt32();
|
||||
sb.rootdir_bsize = eabr.ReadInt32();
|
||||
sb.last_root_copy = eabr.ReadInt32();
|
||||
|
||||
if (record_type[0] != 1 || record_version[0] != 1)
|
||||
if (sb.record_type != 1 || sb.record_version != 1)
|
||||
return;
|
||||
if(Encoding.ASCII.GetString(sync_bytes) != "ZZZZZ")
|
||||
if(Encoding.ASCII.GetString(sb.sync_bytes) != "ZZZZZ")
|
||||
return;
|
||||
|
||||
// Swapping data (C# is LE, Opera is BE)
|
||||
volume_id = Swapping.SwapFourBytes(volume_id);
|
||||
block_size = Swapping.SwapFourBytes(block_size);
|
||||
block_count = Swapping.SwapFourBytes(block_count);
|
||||
root_dirid = Swapping.SwapFourBytes(root_dirid);
|
||||
rootdir_blocks = Swapping.SwapFourBytes(rootdir_blocks);
|
||||
rootdir_bsize = Swapping.SwapFourBytes(rootdir_bsize);
|
||||
last_root_copy = Swapping.SwapFourBytes(last_root_copy);
|
||||
if (sb.volume_comment.Length == 0)
|
||||
sb.volume_comment = "Not set.";
|
||||
|
||||
int vid = BitConverter.ToInt32(volume_id, 0);
|
||||
int rdid = BitConverter.ToInt32(root_dirid, 0);
|
||||
|
||||
StringBuilder VolumeComment = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < volume_comment.Length; i++)
|
||||
{
|
||||
if (volume_comment[i] != 0x00)
|
||||
VolumeComment.Append((char)volume_comment[i]);
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (VolumeComment.Length == 0)
|
||||
VolumeComment.Append("Not set.");
|
||||
|
||||
StringBuilder VolumeLabel = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < volume_label.Length; i++)
|
||||
{
|
||||
if (volume_label[i] != 0x00)
|
||||
VolumeLabel.Append((char)volume_label[i]);
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (VolumeLabel.Length == 0)
|
||||
VolumeLabel.Append("Not set.");
|
||||
|
||||
int bs = BitConverter.ToInt32(block_size, 0);
|
||||
int vblocks = BitConverter.ToInt32(block_count, 0);
|
||||
int rbs = BitConverter.ToInt32(rootdir_bsize, 0);
|
||||
int rblocks = BitConverter.ToInt32(rootdir_blocks, 0);
|
||||
if (sb.volume_label.Length == 0)
|
||||
sb.volume_label = "Not set.";
|
||||
|
||||
SuperBlockMetadata.AppendFormat("Opera filesystem disc.").AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume label: {0}", VolumeLabel.ToString()).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume comment: {0}", VolumeComment.ToString()).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume identifier: 0x{0}", vid.ToString("X")).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Block size: {0} bytes", bs).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume size: {0} blocks, {1} bytes", vblocks, bs*vblocks).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory identifier: 0x{0}", rdid.ToString("X")).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory block size: {0} bytes", rbs).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory size: {0} blocks, {1} bytes", rblocks, rbs*rblocks).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Last root directory copy: {0}", BitConverter.ToInt32(last_root_copy, 0)).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume label: {0}", sb.volume_label).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume comment: {0}", sb.volume_comment).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume identifier: 0x{0:X8}", sb.volume_id).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Block size: {0} bytes", sb.block_size).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume size: {0} blocks, {1} bytes", sb.block_count, sb.block_size*sb.block_count).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory identifier: 0x{0:X8}", sb.root_dirid).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory block size: {0} bytes", sb.rootdir_bsize).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory size: {0} blocks, {1} bytes", sb.rootdir_blocks, sb.rootdir_bsize*sb.rootdir_blocks).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Last root directory copy: {0}", sb.last_root_copy).AppendLine();
|
||||
|
||||
information = SuperBlockMetadata.ToString();
|
||||
}
|
||||
|
||||
private struct OperaSuperBlock
|
||||
{
|
||||
public byte record_type; // Record type, must be 1
|
||||
public byte[] sync_bytes; // 5 bytes, "ZZZZZ" = new byte[5];
|
||||
public byte record_version; // Record version, must be 1
|
||||
public byte volume_flags; // Volume flags
|
||||
public string volume_comment; // 32 bytes, volume comment
|
||||
public string volume_label; // 32 bytes, volume label
|
||||
public Int32 volume_id; // Volume ID
|
||||
public Int32 block_size; // Block size in bytes
|
||||
public Int32 block_count; // Blocks in volume
|
||||
public Int32 root_dirid; // Root directory ID
|
||||
public Int32 rootdir_blocks; // Root directory blocks
|
||||
public Int32 rootdir_bsize; // Root directory block size
|
||||
public Int32 last_root_copy; // Last root directory copy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user