Refactor and reformat code

git-svn-id: svn://claunia.com/FileSystemIDandChk@29 17725271-3d32-4980-a8cb-9ff532f270ba
This commit is contained in:
2014-04-14 02:29:13 +00:00
parent 27791637fb
commit 430d71693a
33 changed files with 5333 additions and 4426 deletions

View File

@@ -15,8 +15,8 @@ namespace FileSystemIDandChk
/// Indicates the byte order ("endianess") in which data is stored in this computer /// Indicates the byte order ("endianess") in which data is stored in this computer
/// architecture. /// architecture.
///</summary> ///</summary>
public static bool IsLittleEndian { get; set; } // should default to false, which is what we want for Empire public static bool IsLittleEndian { get; set; }
// should default to false, which is what we want for Empire
/// <summary> /// <summary>
/// Converts the specified double-precision floating point number to a 64-bit /// Converts the specified double-precision floating point number to a 64-bit
/// signed integer. /// signed integer.
@@ -28,7 +28,11 @@ namespace FileSystemIDandChk
/// Returns: /// Returns:
/// A 64-bit signed integer whose value is equivalent to value. /// A 64-bit signed integer whose value is equivalent to value.
///</summary> ///</summary>
public static long DoubleToInt64Bits(double value) { throw new NotImplementedException(); } public static long DoubleToInt64Bits(double value)
{
throw new NotImplementedException();
}
/// ///
/// <summary> /// <summary>
/// Returns the specified Boolean value as an array of bytes. /// Returns the specified Boolean value as an array of bytes.
@@ -44,6 +48,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray();
} }
/// ///
/// <summary> /// <summary>
/// Returns the specified Unicode character value as an array of bytes. /// Returns the specified Unicode character value as an array of bytes.
@@ -59,6 +64,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray();
} }
/// ///
/// <summary> /// <summary>
/// Returns the specified double-precision floating point value as an array of /// Returns the specified double-precision floating point value as an array of
@@ -75,6 +81,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray();
} }
/// ///
/// <summary> /// <summary>
/// Returns the specified single-precision floating point value as an array of /// Returns the specified single-precision floating point value as an array of
@@ -91,6 +98,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray();
} }
/// ///
/// <summary> /// <summary>
/// Returns the specified 32-bit signed integer value as an array of bytes. /// Returns the specified 32-bit signed integer value as an array of bytes.
@@ -106,6 +114,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray();
} }
/// ///
/// <summary> /// <summary>
/// Returns the specified 64-bit signed integer value as an array of bytes. /// Returns the specified 64-bit signed integer value as an array of bytes.
@@ -121,6 +130,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray();
} }
/// ///
/// <summary> /// <summary>
/// Returns the specified 16-bit signed integer value as an array of bytes. /// Returns the specified 16-bit signed integer value as an array of bytes.
@@ -136,6 +146,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray();
} }
/// ///
/// <summary> /// <summary>
/// Returns the specified 32-bit unsigned integer value as an array of bytes. /// Returns the specified 32-bit unsigned integer value as an array of bytes.
@@ -147,11 +158,12 @@ namespace FileSystemIDandChk
/// Returns: /// Returns:
/// An array of bytes with length 4. /// An array of bytes with length 4.
///</summary> ///</summary>
[CLSCompliant(false)] //[CLSCompliant(false)]
public static byte[] GetBytes(uint value) public static byte[] GetBytes(uint value)
{ {
return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray();
} }
/// ///
/// <summary> /// <summary>
/// Returns the specified 64-bit unsigned integer value as an array of bytes. /// Returns the specified 64-bit unsigned integer value as an array of bytes.
@@ -163,11 +175,12 @@ namespace FileSystemIDandChk
/// Returns: /// Returns:
/// An array of bytes with length 8. /// An array of bytes with length 8.
///</summary> ///</summary>
[CLSCompliant(false)] //[CLSCompliant(false)]
public static byte[] GetBytes(ulong value) public static byte[] GetBytes(ulong value)
{ {
return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray();
} }
/// ///
/// <summary> /// <summary>
/// Returns the specified 16-bit unsigned integer value as an array of bytes. /// Returns the specified 16-bit unsigned integer value as an array of bytes.
@@ -183,6 +196,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray();
} }
/// ///
/// <summary> /// <summary>
/// Converts the specified 64-bit signed integer to a double-precision floating /// Converts the specified 64-bit signed integer to a double-precision floating
@@ -195,7 +209,11 @@ namespace FileSystemIDandChk
/// Returns: /// Returns:
/// A double-precision floating point number whose value is equivalent to value. /// A double-precision floating point number whose value is equivalent to value.
///</summary> ///</summary>
public static double Int64BitsToDouble(long value) { throw new NotImplementedException(); } public static double Int64BitsToDouble(long value)
{
throw new NotImplementedException();
}
/// ///
/// <summary> /// <summary>
/// Returns a Boolean value converted from one byte at a specified position in /// Returns a Boolean value converted from one byte at a specified position in
@@ -218,7 +236,11 @@ namespace FileSystemIDandChk
/// System.ArgumentOutOfRangeException: /// System.ArgumentOutOfRangeException:
/// startIndex is less than zero or greater than the length of value minus 1. /// startIndex is less than zero or greater than the length of value minus 1.
///</summary> ///</summary>
public static bool ToBoolean(byte[] value, int startIndex) { throw new NotImplementedException(); } public static bool ToBoolean(byte[] value, int startIndex)
{
throw new NotImplementedException();
}
/// ///
/// <summary> /// <summary>
/// Returns a Unicode character converted from two bytes at a specified position /// Returns a Unicode character converted from two bytes at a specified position
@@ -244,7 +266,11 @@ namespace FileSystemIDandChk
/// System.ArgumentOutOfRangeException: /// System.ArgumentOutOfRangeException:
/// startIndex is less than zero or greater than the length of value minus 1. /// startIndex is less than zero or greater than the length of value minus 1.
///</summary> ///</summary>
public static char ToChar(byte[] value, int startIndex) { throw new NotImplementedException(); } public static char ToChar(byte[] value, int startIndex)
{
throw new NotImplementedException();
}
/// ///
/// <summary> /// <summary>
/// Returns a double-precision floating point number converted from eight bytes /// Returns a double-precision floating point number converted from eight bytes
@@ -272,7 +298,11 @@ namespace FileSystemIDandChk
/// System.ArgumentOutOfRangeException: /// System.ArgumentOutOfRangeException:
/// startIndex is less than zero or greater than the length of value minus 1. /// startIndex is less than zero or greater than the length of value minus 1.
///</summary> ///</summary>
public static double ToDouble(byte[] value, int startIndex) { throw new NotImplementedException(); } public static double ToDouble(byte[] value, int startIndex)
{
throw new NotImplementedException();
}
/// ///
/// <summary> /// <summary>
/// Returns a 16-bit signed integer converted from two bytes at a specified position /// Returns a 16-bit signed integer converted from two bytes at a specified position
@@ -302,6 +332,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.ToInt16(value, startIndex) : BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(Int16) - startIndex); return !IsLittleEndian ? BitConverter.ToInt16(value, startIndex) : BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(Int16) - startIndex);
} }
/// ///
/// <summary> /// <summary>
/// Returns a 32-bit signed integer converted from four bytes at a specified /// Returns a 32-bit signed integer converted from four bytes at a specified
@@ -332,6 +363,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.ToInt32(value, startIndex) : BitConverter.ToInt32(value.Reverse().ToArray(), value.Length - sizeof(Int32) - startIndex); return !IsLittleEndian ? BitConverter.ToInt32(value, startIndex) : BitConverter.ToInt32(value.Reverse().ToArray(), value.Length - sizeof(Int32) - startIndex);
} }
/// ///
/// <summary> /// <summary>
/// Returns a 64-bit signed integer converted from eight bytes at a specified /// Returns a 64-bit signed integer converted from eight bytes at a specified
@@ -362,6 +394,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.ToInt64(value, startIndex) : BitConverter.ToInt64(value.Reverse().ToArray(), value.Length - sizeof(Int64) - startIndex); return !IsLittleEndian ? BitConverter.ToInt64(value, startIndex) : BitConverter.ToInt64(value.Reverse().ToArray(), value.Length - sizeof(Int64) - startIndex);
} }
/// ///
/// <summary> /// <summary>
/// Returns a single-precision floating point number converted from four bytes /// Returns a single-precision floating point number converted from four bytes
@@ -393,6 +426,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.ToSingle(value, startIndex) : BitConverter.ToSingle(value.Reverse().ToArray(), value.Length - sizeof(Single) - startIndex); return !IsLittleEndian ? BitConverter.ToSingle(value, startIndex) : BitConverter.ToSingle(value.Reverse().ToArray(), value.Length - sizeof(Single) - startIndex);
} }
/// ///
/// <summary> /// <summary>
/// Converts the numeric value of each element of a specified array of bytes /// Converts the numeric value of each element of a specified array of bytes
@@ -414,6 +448,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.ToString(value) : BitConverter.ToString(value.Reverse().ToArray()); return !IsLittleEndian ? BitConverter.ToString(value) : BitConverter.ToString(value.Reverse().ToArray());
} }
/// ///
/// <summary> /// <summary>
/// Converts the numeric value of each element of a specified subarray of bytes /// Converts the numeric value of each element of a specified subarray of bytes
@@ -442,6 +477,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.ToString(value, startIndex) : BitConverter.ToString(value.Reverse().ToArray(), startIndex); return !IsLittleEndian ? BitConverter.ToString(value, startIndex) : BitConverter.ToString(value.Reverse().ToArray(), startIndex);
} }
/// ///
/// <summary> /// <summary>
/// Converts the numeric value of each element of a specified subarray of bytes /// Converts the numeric value of each element of a specified subarray of bytes
@@ -479,6 +515,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.ToString(value, startIndex, length) : BitConverter.ToString(value.Reverse().ToArray(), startIndex, length); return !IsLittleEndian ? BitConverter.ToString(value, startIndex, length) : BitConverter.ToString(value.Reverse().ToArray(), startIndex, length);
} }
/// ///
/// <summary> /// <summary>
/// Returns a 16-bit unsigned integer converted from two bytes at a specified /// Returns a 16-bit unsigned integer converted from two bytes at a specified
@@ -508,6 +545,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.ToUInt16(value, startIndex) : BitConverter.ToUInt16(value.Reverse().ToArray(), value.Length - sizeof(UInt16) - startIndex); return !IsLittleEndian ? BitConverter.ToUInt16(value, startIndex) : BitConverter.ToUInt16(value.Reverse().ToArray(), value.Length - sizeof(UInt16) - startIndex);
} }
/// ///
/// <summary> /// <summary>
/// Returns a 32-bit unsigned integer converted from four bytes at a specified /// Returns a 32-bit unsigned integer converted from four bytes at a specified
@@ -538,6 +576,7 @@ namespace FileSystemIDandChk
{ {
return !IsLittleEndian ? BitConverter.ToUInt32(value, startIndex) : BitConverter.ToUInt32(value.Reverse().ToArray(), value.Length - sizeof(UInt32) - startIndex); return !IsLittleEndian ? BitConverter.ToUInt32(value, startIndex) : BitConverter.ToUInt32(value.Reverse().ToArray(), value.Length - sizeof(UInt32) - startIndex);
} }
/// ///
/// <summary> /// <summary>
/// Returns a 64-bit unsigned integer converted from eight bytes at a specified /// Returns a 64-bit unsigned integer converted from eight bytes at a specified

View File

@@ -1,3 +1,39 @@
2014-04-14 Natalia Portillo <claunia@claunia.com>
* Main.cs:
* Plugins.cs:
* Swapping.cs:
* Plugins/BFS.cs:
* Plugins/FAT.cs:
* Plugins/FFS.cs:
* Plugins/ODS.cs:
* Plugins/NTFS.cs:
* Plugins/HPFS.cs:
* DateHandlers.cs:
* Plugins/SysV.cs:
* Plugins/extFS.cs:
* Plugins/Opera.cs:
* Plugins/Plugin.cs:
* StringHandlers.cs:
* Plugins/ext2FS.cs:
* Plugins/SolarFS.cs:
* Plugins/UNIXBFS.cs:
* Plugins/MinixFS.cs:
* Plugins/ISO9660.cs:
* PartPlugins/MBR.cs:
* Plugins/AppleMFS.cs:
* PartPlugins/NeXT.cs:
* Plugins/PCEngine.cs:
* Plugins/AppleHFS.cs:
* ImagePlugins/CDRWin.cs:
* PartPlugins/AppleMap.cs:
* Plugins/AppleHFSPlus.cs:
* BigEndianBitConverter.cs:
* FileSystemIDandChk.csproj:
* EndianAwareBinaryReader.cs:
* ImagePlugins/ImagePlugin.cs:
Refactor and reformat code
2014-04-14 Natalia Portillo <claunia@claunia.com> 2014-04-14 Natalia Portillo <claunia@claunia.com>
* Main.cs: * Main.cs:

View File

@@ -4,10 +4,10 @@ namespace FileSystemIDandChk
{ {
public static class DateHandlers public static class DateHandlers
{ {
private static DateTime MacEpoch = new DateTime(1904, 1, 1, 0, 0, 0); static readonly DateTime MacEpoch = new DateTime(1904, 1, 1, 0, 0, 0);
private static DateTime UNIXEpoch = new DateTime(1970, 1, 1, 0, 0, 0); static readonly DateTime UNIXEpoch = new DateTime(1970, 1, 1, 0, 0, 0);
private static DateTime JulianEpoch = new DateTime(1858, 11, 17, 0, 0, 0); // Day 0 of Julian Date system static readonly DateTime JulianEpoch = new DateTime(1858, 11, 17, 0, 0, 0);
// Day 0 of Julian Date system
public static DateTime MacToDateTime(ulong MacTimeStamp) public static DateTime MacToDateTime(ulong MacTimeStamp)
{ {
return MacEpoch.AddTicks((long)(MacTimeStamp * 10000000)); return MacEpoch.AddTicks((long)(MacTimeStamp * 10000000));
@@ -88,11 +88,11 @@ namespace FileSystemIDandChk
// hundredths = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); // hundredths = Convert.ToInt32(StringHandlers.CToString(twocharvalue));
if (MainClass.isDebug) if (MainClass.isDebug)
Console.WriteLine("ISO9600ToDateTime: decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);", year, month, day, hour, minute, second, hundredths *10); DateTime decodedDT = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Unspecified); Console.WriteLine("ISO9600ToDateTime: decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);", year, month, day, hour, minute, second, hundredths * 10);
DateTime decodedDT = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Unspecified);
return decodedDT; return decodedDT;
} }
// C# works in UTC, VMS on Julian Date, some displacement may occur on disks created outside UTC // C# works in UTC, VMS on Julian Date, some displacement may occur on disks created outside UTC
public static DateTime VMSToDateTime(UInt64 vmsDate) public static DateTime VMSToDateTime(UInt64 vmsDate)
{ {

View File

@@ -7,13 +7,12 @@ namespace FileSystemIDandChk
{ {
public class EndianAwareBinaryReader : BinaryReader public class EndianAwareBinaryReader : BinaryReader
{ {
private bool isLittleEndian; byte[] buffer = new byte[8];
private byte[] buffer = new byte[8];
public EndianAwareBinaryReader(Stream input, Encoding encoding, bool isLittleEndian) public EndianAwareBinaryReader(Stream input, Encoding encoding, bool isLittleEndian)
: base(input, encoding) : base(input, encoding)
{ {
this.isLittleEndian = isLittleEndian; IsLittleEndian = isLittleEndian;
} }
public EndianAwareBinaryReader(Stream input, bool isLittleEndian) public EndianAwareBinaryReader(Stream input, bool isLittleEndian)
@@ -23,14 +22,13 @@ namespace FileSystemIDandChk
public bool IsLittleEndian public bool IsLittleEndian
{ {
get { return isLittleEndian; } get;
set { isLittleEndian = value; } set;
} }
public override double ReadDouble() public override double ReadDouble()
{ {
if (isLittleEndian) if (IsLittleEndian)
return base.ReadDouble(); return base.ReadDouble();
FillMyBuffer(8); FillMyBuffer(8);
return BitConverter.ToDouble(buffer.Take(8).Reverse().ToArray(), 0); return BitConverter.ToDouble(buffer.Take(8).Reverse().ToArray(), 0);
@@ -38,7 +36,7 @@ namespace FileSystemIDandChk
public override short ReadInt16() public override short ReadInt16()
{ {
if (isLittleEndian) if (IsLittleEndian)
return base.ReadInt16(); return base.ReadInt16();
FillMyBuffer(2); FillMyBuffer(2);
return BitConverter.ToInt16(buffer.Take(2).Reverse().ToArray(), 0); return BitConverter.ToInt16(buffer.Take(2).Reverse().ToArray(), 0);
@@ -47,7 +45,7 @@ namespace FileSystemIDandChk
public override int ReadInt32() public override int ReadInt32()
{ {
if (isLittleEndian) if (IsLittleEndian)
return base.ReadInt32(); return base.ReadInt32();
FillMyBuffer(4); FillMyBuffer(4);
return BitConverter.ToInt32(buffer.Take(4).Reverse().ToArray(), 0); return BitConverter.ToInt32(buffer.Take(4).Reverse().ToArray(), 0);
@@ -56,7 +54,7 @@ namespace FileSystemIDandChk
public override long ReadInt64() public override long ReadInt64()
{ {
if (isLittleEndian) if (IsLittleEndian)
return base.ReadInt64(); return base.ReadInt64();
FillMyBuffer(8); FillMyBuffer(8);
return BitConverter.ToInt64(buffer.Take(8).Reverse().ToArray(), 0); return BitConverter.ToInt64(buffer.Take(8).Reverse().ToArray(), 0);
@@ -65,7 +63,7 @@ namespace FileSystemIDandChk
public override float ReadSingle() public override float ReadSingle()
{ {
if (isLittleEndian) if (IsLittleEndian)
return base.ReadSingle(); return base.ReadSingle();
FillMyBuffer(4); FillMyBuffer(4);
return BitConverter.ToSingle(buffer.Take(4).Reverse().ToArray(), 0); return BitConverter.ToSingle(buffer.Take(4).Reverse().ToArray(), 0);
@@ -73,16 +71,15 @@ namespace FileSystemIDandChk
public override ushort ReadUInt16() public override ushort ReadUInt16()
{ {
if (isLittleEndian) if (IsLittleEndian)
return base.ReadUInt16(); return base.ReadUInt16();
FillMyBuffer(2); FillMyBuffer(2);
return BitConverter.ToUInt16(buffer.Take(2).Reverse().ToArray(), 0); return BitConverter.ToUInt16(buffer.Take(2).Reverse().ToArray(), 0);
} }
public override uint ReadUInt32() public override uint ReadUInt32()
{ {
if (isLittleEndian) if (IsLittleEndian)
return base.ReadUInt32(); return base.ReadUInt32();
FillMyBuffer(4); FillMyBuffer(4);
return BitConverter.ToUInt32(buffer.Take(4).Reverse().ToArray(), 0); return BitConverter.ToUInt32(buffer.Take(4).Reverse().ToArray(), 0);
@@ -90,16 +87,16 @@ namespace FileSystemIDandChk
public override ulong ReadUInt64() public override ulong ReadUInt64()
{ {
if (isLittleEndian) if (IsLittleEndian)
return base.ReadUInt64(); return base.ReadUInt64();
FillMyBuffer(8); FillMyBuffer(8);
return BitConverter.ToUInt64(buffer.Take(8).Reverse().ToArray(), 0); return BitConverter.ToUInt64(buffer.Take(8).Reverse().ToArray(), 0);
} }
private void FillMyBuffer(int numBytes) void FillMyBuffer(int numBytes)
{ {
int offset = 0; int offset = 0;
int num2 = 0; int num2;
if (numBytes == 1) if (numBytes == 1)
{ {
num2 = BaseStream.ReadByte(); num2 = BaseStream.ReadByte();

View File

@@ -87,6 +87,63 @@
<ChangeLogPolicy UpdateMode="ProjectRoot" VcsIntegration="RequireEntry" inheritsSet="Mono"> <ChangeLogPolicy UpdateMode="ProjectRoot" VcsIntegration="RequireEntry" inheritsSet="Mono">
<MessageStyle LastFilePostfix=":&#xA; " IncludeDirectoryPaths="True" /> <MessageStyle LastFilePostfix=":&#xA; " IncludeDirectoryPaths="True" />
</ChangeLogPolicy> </ChangeLogPolicy>
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
<TextStylePolicy inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
<CSharpFormattingPolicy IndentSwitchBody="True" AnonymousMethodBraceStyle="NextLine" PropertyBraceStyle="NextLine" PropertyGetBraceStyle="NextLine" PropertySetBraceStyle="NextLine" EventBraceStyle="NextLine" EventAddBraceStyle="NextLine" EventRemoveBraceStyle="NextLine" StatementBraceStyle="NextLine" ElseNewLinePlacement="NewLine" CatchNewLinePlacement="NewLine" FinallyNewLinePlacement="NewLine" WhileNewLinePlacement="DoNotCare" ArrayInitializerWrapping="DoNotChange" ArrayInitializerBraceStyle="NextLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
<TextStylePolicy inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
<NameConventionPolicy>
<Rules>
<NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
<RequiredPrefixes>
<String>I</String>
</RequiredPrefixes>
</NamingRule>
<NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
<RequiredSuffixes>
<String>Attribute</String>
</RequiredSuffixes>
</NamingRule>
<NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
<RequiredSuffixes>
<String>EventArgs</String>
</RequiredSuffixes>
</NamingRule>
<NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
<RequiredSuffixes>
<String>Exception</String>
</RequiredSuffixes>
</NamingRule>
<NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="PascalCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
<NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Protected, Public" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" />
<NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
<AllowedPrefixes>
<String>_</String>
<String>m_</String>
</AllowedPrefixes>
</NamingRule>
<NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
<NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
<AllowedPrefixes>
<String>_</String>
<String>m_</String>
</AllowedPrefixes>
</NamingRule>
<NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Parameters" AffectedEntity="Parameter" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
<RequiredPrefixes>
<String>T</String>
</RequiredPrefixes>
</NamingRule>
</Rules>
</NameConventionPolicy>
</Policies> </Policies>
</Properties> </Properties>
</MonoDevelop> </MonoDevelop>

View File

@@ -207,7 +207,6 @@ namespace FileSystemIDandChk.ImagePlugins
#region Internal variables #region Internal variables
bool initialized;
string imagePath; string imagePath;
StreamReader cueStream; StreamReader cueStream;
FileStream imageStream; FileStream imageStream;
@@ -622,11 +621,11 @@ namespace FileSystemIDandChk.ImagePlugins
} }
else if (MatchFlags.Success) else if (MatchFlags.Success)
{ {
// TODO: Implement FLAGS support.
if (MainClass.isDebug) if (MainClass.isDebug)
Console.WriteLine("DEBUG (CDRWin plugin): Found FLAGS at line {0}", line); Console.WriteLine("DEBUG (CDRWin plugin): Found FLAGS at line {0}", line);
if (!intrack) if (!intrack)
throw new FeatureUnsupportedImageException(String.Format("Found FLAGS field in incorrect place at line {0}", line)); throw new FeatureUnsupportedImageException(String.Format("Found FLAGS field in incorrect place at line {0}", line));
// TODO: Implement FLAGS support.
} }
else if (MatchGenre.Success) else if (MatchGenre.Success)
{ {
@@ -769,8 +768,6 @@ namespace FileSystemIDandChk.ImagePlugins
currenttrack.tracktype = MatchTrack.Groups[2].Value; currenttrack.tracktype = MatchTrack.Groups[2].Value;
currenttrack.session = currentsession; currenttrack.session = currentsession;
intrack = true; intrack = true;
// TODO
} }
else if (_line == "") // Empty line, ignore it else if (_line == "") // Empty line, ignore it
{ {
@@ -796,7 +793,6 @@ namespace FileSystemIDandChk.ImagePlugins
for (int s = 1; s <= _sessions.Length; s++) for (int s = 1; s <= _sessions.Length; s++)
{ {
_sessions[s - 1].SessionSequence = 1; _sessions[s - 1].SessionSequence = 1;
ulong _session_offset;
if (s > 1) if (s > 1)
_sessions[s - 1].StartSector = _sessions[s - 2].EndSector + 1; _sessions[s - 1].StartSector = _sessions[s - 2].EndSector + 1;
@@ -804,7 +800,6 @@ namespace FileSystemIDandChk.ImagePlugins
_sessions[s - 1].StartSector = 0; _sessions[s - 1].StartSector = 0;
ulong session_sectors = 0; ulong session_sectors = 0;
bool first_session_track = true;
int last_session_track = 0; int last_session_track = 0;
for (int i = 0; i < cuetracks.Length; i++) for (int i = 0; i < cuetracks.Length; i++)
@@ -1375,25 +1370,26 @@ namespace FileSystemIDandChk.ImagePlugins
byte[] buffer = new byte[sector_size * length]; byte[] buffer = new byte[sector_size * length];
this.imageStream = new FileStream(_track.trackfile.datafile, FileMode.Open, FileAccess.Read); imageStream = new FileStream(_track.trackfile.datafile, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(this.imageStream); using (BinaryReader br = new BinaryReader(imageStream))
{
br.BaseStream.Seek((long)_track.trackfile.offset + (long)(sectorAddress * (sector_offset + sector_size + sector_skip)), SeekOrigin.Begin); br.BaseStream.Seek((long)_track.trackfile.offset + (long)(sectorAddress * (sector_offset + sector_size + sector_skip)), SeekOrigin.Begin);
if (sector_offset == 0 && sector_skip == 0) if (sector_offset == 0 && sector_skip == 0)
buffer = br.ReadBytes((int)(sector_size * length)); buffer = br.ReadBytes((int)(sector_size * length));
else else
{ {
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
byte[] sector = new byte[sector_size]; byte[] sector;
br.BaseStream.Seek(sector_offset, SeekOrigin.Current); br.BaseStream.Seek(sector_offset, SeekOrigin.Current);
sector = br.ReadBytes((int)sector_size); sector = br.ReadBytes((int)sector_size);
br.BaseStream.Seek(sector_skip, SeekOrigin.Current); br.BaseStream.Seek(sector_skip, SeekOrigin.Current);
Array.Copy(sector, 0, buffer, i * sector_size, sector_size);
}
}
}
System.Array.Copy(sector, 0, buffer, i * sector_size, sector_size);
}
}
return buffer; return buffer;
} }
@@ -1569,25 +1565,26 @@ namespace FileSystemIDandChk.ImagePlugins
byte[] buffer = new byte[sector_size * length]; byte[] buffer = new byte[sector_size * length];
this.imageStream = new FileStream(_track.trackfile.datafile, FileMode.Open, FileAccess.Read); imageStream = new FileStream(_track.trackfile.datafile, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(this.imageStream); using (BinaryReader br = new BinaryReader(imageStream))
{
br.BaseStream.Seek((long)_track.trackfile.offset + (long)(sectorAddress * (sector_offset + sector_size + sector_skip)), SeekOrigin.Begin); br.BaseStream.Seek((long)_track.trackfile.offset + (long)(sectorAddress * (sector_offset + sector_size + sector_skip)), SeekOrigin.Begin);
if (sector_offset == 0 && sector_skip == 0) if (sector_offset == 0 && sector_skip == 0)
buffer = br.ReadBytes((int)(sector_size * length)); buffer = br.ReadBytes((int)(sector_size * length));
else else
{ {
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
byte[] sector = new byte[sector_size]; byte[] sector;
br.BaseStream.Seek(sector_offset, SeekOrigin.Current); br.BaseStream.Seek(sector_offset, SeekOrigin.Current);
sector = br.ReadBytes((int)sector_size); sector = br.ReadBytes((int)sector_size);
br.BaseStream.Seek(sector_skip, SeekOrigin.Current); br.BaseStream.Seek(sector_skip, SeekOrigin.Current);
Array.Copy(sector, 0, buffer, i * sector_size, sector_size);
}
}
}
System.Array.Copy(sector, 0, buffer, i * sector_size, sector_size);
}
}
return buffer; return buffer;
} }
@@ -1695,8 +1692,8 @@ namespace FileSystemIDandChk.ImagePlugins
byte[] buffer = new byte[sector_size * length]; byte[] buffer = new byte[sector_size * length];
this.imageStream = new FileStream(_track.trackfile.datafile, FileMode.Open, FileAccess.Read); imageStream = new FileStream(_track.trackfile.datafile, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(this.imageStream); BinaryReader br = new BinaryReader(imageStream);
br.BaseStream.Seek((long)_track.trackfile.offset + (long)(sectorAddress * (sector_offset + sector_size + sector_skip)), SeekOrigin.Begin); br.BaseStream.Seek((long)_track.trackfile.offset + (long)(sectorAddress * (sector_offset + sector_size + sector_skip)), SeekOrigin.Begin);
@@ -1706,12 +1703,12 @@ namespace FileSystemIDandChk.ImagePlugins
{ {
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
byte[] sector = new byte[sector_size]; byte[] sector;
br.BaseStream.Seek(sector_offset, SeekOrigin.Current); br.BaseStream.Seek(sector_offset, SeekOrigin.Current);
sector = br.ReadBytes((int)sector_size); sector = br.ReadBytes((int)sector_size);
br.BaseStream.Seek(sector_skip, SeekOrigin.Current); br.BaseStream.Seek(sector_skip, SeekOrigin.Current);
System.Array.Copy(sector, 0, buffer, i * sector_size, sector_size); Array.Copy(sector, 0, buffer, i * sector_size, sector_size);
} }
} }
@@ -1810,7 +1807,6 @@ namespace FileSystemIDandChk.ImagePlugins
{ {
return GetSessionTracks(session.SessionSequence); return GetSessionTracks(session.SessionSequence);
} }
else
throw new ImageNotSupportedException("Session does not exist in disc image"); throw new ImageNotSupportedException("Session does not exist in disc image");
} }

View File

@@ -1,6 +1,6 @@
using System; using System;
using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
namespace FileSystemIDandChk.ImagePlugins namespace FileSystemIDandChk.ImagePlugins
{ {

View File

@@ -82,8 +82,6 @@ namespace FileSystemIDandChk
case "--debug": case "--debug":
isDebug = true; isDebug = true;
break; break;
default:
break;
} }
} }
@@ -92,9 +90,8 @@ namespace FileSystemIDandChk
} }
} }
private static void Runner (string filename) static void Runner(string filename)
{ {
FileStream stream;
List<string> id_plugins; List<string> id_plugins;
Plugin _plugin; Plugin _plugin;
string information; string information;
@@ -178,7 +175,6 @@ namespace FileSystemIDandChk
Console.WriteLine("No partitions founds, not searching for filesystems"); Console.WriteLine("No partitions founds, not searching for filesystems");
return; return;
} }
else
checkraw = true; checkraw = true;
} }
else else
@@ -264,13 +260,9 @@ namespace FileSystemIDandChk
if (isDebug) if (isDebug)
Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.StackTrace);
} }
finally
{
stream = null;
}
} }
private static void Identify (ImagePlugins.ImagePlugin imagePlugin, out List<string> id_plugins, ulong partitionOffset) static void Identify(ImagePlugin imagePlugin, out List<string> id_plugins, ulong partitionOffset)
{ {
id_plugins = new List<string>(); id_plugins = new List<string>();
@@ -281,7 +273,7 @@ namespace FileSystemIDandChk
} }
} }
private static void Usage () static void Usage()
{ {
Console.WriteLine("Usage: filesystemidandchk [options] file"); Console.WriteLine("Usage: filesystemidandchk [options] file");
Console.WriteLine(); Console.WriteLine();

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -8,9 +7,12 @@ namespace FileSystemIDandChk.PartPlugins
{ {
class AppleMap : PartPlugin class AppleMap : PartPlugin
{ {
private const UInt16 APM_MAGIC = 0x4552; // "ER" // "ER"
private const UInt16 APM_ENTRY = 0x504D; // "PM" const UInt16 APM_MAGIC = 0x4552;
private const UInt16 APM_OLDENT = 0x5453; // "TS", old entry magic // "PM"
const UInt16 APM_ENTRY = 0x504D;
// "TS", old entry magic
const UInt16 APM_OLDENT = 0x5453;
public AppleMap(PluginBase Core) public AppleMap(PluginBase Core)
{ {
@@ -169,38 +171,66 @@ namespace FileSystemIDandChk.PartPlugins
public struct AppleMapBootEntry public struct AppleMapBootEntry
{ {
public UInt16 signature; // Signature ("ER") // Signature ("ER")
public UInt16 sector_size; // Byter per sector public UInt16 signature;
public UInt32 sectors; // Sectors of the disk // Byter per sector
public UInt16 reserved1; // Reserved public UInt16 sector_size;
public UInt16 reserved2; // Reserved // Sectors of the disk
public UInt32 reserved3; // Reserved public UInt32 sectors;
public UInt16 driver_entries; // Number of entries of the driver descriptor // Reserved
public UInt32 first_driver_blk; // First sector of the driver public UInt16 reserved1;
public UInt16 driver_size; // Size in 512bytes sectors of the driver // Reserved
public UInt16 operating_system; // Operating system (MacOS = 1) public UInt16 reserved2;
// Reserved
public UInt32 reserved3;
// Number of entries of the driver descriptor
public UInt16 driver_entries;
// First sector of the driver
public UInt32 first_driver_blk;
// Size in 512bytes sectors of the driver
public UInt16 driver_size;
// Operating system (MacOS = 1)
public UInt16 operating_system;
} }
public struct AppleMapPartitionEntry public struct AppleMapPartitionEntry
{ {
public UInt16 signature; // Signature ("PM" or "TS") // Signature ("PM" or "TS")
public UInt16 reserved1; // Reserved public UInt16 signature;
public UInt32 entries; // Number of entries on the partition map, each one sector // Reserved
public UInt32 start; // First sector of the partition public UInt16 reserved1;
public UInt32 sectors; // Number of sectos of the partition // Number of entries on the partition map, each one sector
public string name; // Partition name, 32 bytes, null-padded public UInt32 entries;
public string type; // Partition type. 32 bytes, null-padded // First sector of the partition
public UInt32 first_data_block; // First sector of the data area public UInt32 start;
public UInt32 data_sectors; // Number of sectors of the data area // Number of sectos of the partition
public UInt32 status; // Partition status public UInt32 sectors;
public UInt32 first_boot_block; // First sector of the boot code // Partition name, 32 bytes, null-padded
public UInt32 boot_size; // Size in bytes of the boot code public string name;
public UInt32 load_address; // Load address of the boot code // Partition type. 32 bytes, null-padded
public UInt32 reserved2; // Reserved public string type;
public UInt32 entry_point; // Entry point of the boot code // First sector of the data area
public UInt32 reserved3; // Reserved public UInt32 first_data_block;
public UInt32 checksum; // Boot code checksum // Number of sectors of the data area
public string processor; // Processor type, 16 bytes, null-padded public UInt32 data_sectors;
// Partition status
public UInt32 status;
// First sector of the boot code
public UInt32 first_boot_block;
// Size in bytes of the boot code
public UInt32 boot_size;
// Load address of the boot code
public UInt32 load_address;
// Reserved
public UInt32 reserved2;
// Entry point of the boot code
public UInt32 entry_point;
// Reserved
public UInt32 reserved3;
// Boot code checksum
public UInt32 checksum;
// Processor type, 16 bytes, null-padded
public string processor;
} }
} }
} }

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Collections.Generic;
using FileSystemIDandChk; using FileSystemIDandChk;
// TODO: Support AAP, AST, SpeedStor and Ontrack extensions // TODO: Support AAP, AST, SpeedStor and Ontrack extensions
@@ -13,15 +13,14 @@ namespace FileSystemIDandChk.PartPlugins
public MBR(PluginBase Core) public MBR(PluginBase Core)
{ {
base.Name = "Master Boot Record"; Name = "Master Boot Record";
base.PluginUUID = new Guid("5E8A34E8-4F1A-59E6-4BF7-7EA647063A76"); PluginUUID = new Guid("5E8A34E8-4F1A-59E6-4BF7-7EA647063A76");
} }
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions) public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions)
{ {
byte cyl_sect1, cyl_sect2; // For decoding cylinder and sector byte cyl_sect1, cyl_sect2; // For decoding cylinder and sector
UInt16 signature; UInt16 signature;
UInt32 serial;
ulong counter = 0; ulong counter = 0;
partitions = new List<Partition>(); partitions = new List<Partition>();
@@ -33,8 +32,6 @@ namespace FileSystemIDandChk.PartPlugins
if (signature != MBRSignature) if (signature != MBRSignature)
return false; // Not MBR return false; // Not MBR
serial = BitConverter.ToUInt32(sector, 0x1B8);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
MBRPartitionEntry entry = new MBRPartitionEntry(); MBRPartitionEntry entry = new MBRPartitionEntry();
@@ -68,8 +65,7 @@ namespace FileSystemIDandChk.PartPlugins
if (entry.status != 0x00 && entry.status != 0x80) if (entry.status != 0x00 && entry.status != 0x80)
return false; // Maybe a FAT filesystem return false; // Maybe a FAT filesystem
if (entry.type == 0x00) valid &= entry.type != 0x00;
valid = false;
if (entry.type == 0xEE || entry.type == 0xEF) if (entry.type == 0xEE || entry.type == 0xEF)
return false; // This is a GPT return false; // This is a GPT
if (entry.type == 0x05 || entry.type == 0x0F || entry.type == 0x85) if (entry.type == 0x05 || entry.type == 0x0F || entry.type == 0x85)
@@ -84,8 +80,7 @@ namespace FileSystemIDandChk.PartPlugins
disklabel = true; disklabel = true;
} }
if (entry.lba_start == 0 && entry.lba_sectors == 0 && entry.start_cylinder == 0 && entry.start_head == 0 && entry.start_sector == 0 && entry.end_cylinder == 0 && entry.end_head == 0 && entry.end_sector == 0) valid &= entry.lba_start != 0 || entry.lba_sectors != 0 || entry.start_cylinder != 0 || entry.start_head != 0 || entry.start_sector != 0 || entry.end_cylinder != 0 || entry.end_head != 0 || entry.end_sector != 0;
valid = false;
if (entry.lba_start == 0 && entry.lba_sectors == 0 && valid) if (entry.lba_start == 0 && entry.lba_sectors == 0 && valid)
{ {
entry.lba_start = CHStoLBA(entry.start_cylinder, entry.start_head, entry.start_sector); entry.lba_start = CHStoLBA(entry.start_cylinder, entry.start_head, entry.start_sector);
@@ -302,8 +297,7 @@ namespace FileSystemIDandChk.PartPlugins
counter++; counter++;
} }
} }
if (!minix_subs) valid |= !minix_subs;
valid = true;
break; break;
} }
@@ -338,10 +332,7 @@ namespace FileSystemIDandChk.PartPlugins
part.PartitionType = String.Format("0x{0:X2}", entry.type); part.PartitionType = String.Format("0x{0:X2}", entry.type);
part.PartitionName = decodeMBRType(entry.type); part.PartitionName = decodeMBRType(entry.type);
part.PartitionSequence = counter; part.PartitionSequence = counter;
if (entry.status == 0x80) part.PartitionDescription = entry.status == 0x80 ? "Partition is bootable." : "";
part.PartitionDescription = "Partition is bootable.";
else
part.PartitionDescription = "";
counter++; counter++;
@@ -388,10 +379,8 @@ namespace FileSystemIDandChk.PartPlugins
// Let's start the fun... // Let's start the fun...
if (entry2.status != 0x00 && entry2.status != 0x80) ext_valid &= entry2.status == 0x00 || entry2.status == 0x80;
ext_valid = false; valid &= entry2.type != 0x00;
if (entry2.type == 0x00)
valid = false;
if (entry2.type == 0x82 || entry2.type == 0xBF || entry2.type == 0xA5 || entry2.type == 0xA6 || if (entry2.type == 0x82 || entry2.type == 0xBF || entry2.type == 0xA5 || entry2.type == 0xA6 ||
entry2.type == 0xA9 || entry2.type == 0xB7 || entry2.type == 0x81 || entry2.type == 0x63) entry2.type == 0xA9 || entry2.type == 0xB7 || entry2.type == 0x81 || entry2.type == 0x63)
{ {
@@ -404,8 +393,8 @@ namespace FileSystemIDandChk.PartPlugins
ext_disklabel = false; ext_disklabel = false;
ext_extended = true; // Extended partition ext_extended = true; // Extended partition
} }
else if (l == 1) else
processing_extended = false; processing_extended &= l != 1;
if (ext_disklabel) if (ext_disklabel)
{ {
@@ -610,8 +599,7 @@ namespace FileSystemIDandChk.PartPlugins
counter++; counter++;
} }
} }
if (!minix_subs) ext_valid |= !minix_subs;
ext_valid = true;
break; break;
} }
@@ -647,10 +635,7 @@ namespace FileSystemIDandChk.PartPlugins
part.PartitionType = String.Format("0x{0:X2}", entry2.type); part.PartitionType = String.Format("0x{0:X2}", entry2.type);
part.PartitionName = decodeMBRType(entry2.type); part.PartitionName = decodeMBRType(entry2.type);
part.PartitionSequence = counter; part.PartitionSequence = counter;
if (entry2.status == 0x80) part.PartitionDescription = entry2.status == 0x80 ? "Partition is bootable." : "";
part.PartitionDescription = "Partition is bootable.";
else
part.PartitionDescription = "";
counter++; counter++;
@@ -668,18 +653,15 @@ namespace FileSystemIDandChk.PartPlugins
} }
// An empty MBR may exist, NeXT creates one and then hardcodes its disklabel // An empty MBR may exist, NeXT creates one and then hardcodes its disklabel
if (partitions.Count == 0) return partitions.Count != 0;
return false;
else
return true;
} }
private UInt32 CHStoLBA(ushort cyl, byte head, byte sector) static UInt32 CHStoLBA(ushort cyl, byte head, byte sector)
{ {
return (((UInt32)cyl * 16) + (UInt32)head) * 63 + (UInt32)sector - 1; return (((UInt32)cyl * 16) + (UInt32)head) * 63 + (UInt32)sector - 1;
} }
private string decodeBSDType(byte type) static string decodeBSDType(byte type)
{ {
switch (type) switch (type)
{ {
@@ -716,7 +698,7 @@ namespace FileSystemIDandChk.PartPlugins
} }
} }
private string decodeMBRType(byte type) static string decodeMBRType(byte type)
{ {
switch (type) switch (type)
{ {
@@ -1057,10 +1039,10 @@ namespace FileSystemIDandChk.PartPlugins
// Total sectors // Total sectors
} }
private const UInt32 UNIXDiskLabel_MAGIC = 0xCA5E600D; const UInt32 UNIXDiskLabel_MAGIC = 0xCA5E600D;
private const UInt32 UNIXVTOC_MAGIC = 0x600DDEEE; const UInt32 UNIXVTOC_MAGIC = 0x600DDEEE;
// Same as Solaris VTOC // Same as Solaris VTOC
private struct UNIXDiskLabel struct UNIXDiskLabel
{ {
public UInt32 type; public UInt32 type;
// Drive type, seems always 0 // Drive type, seems always 0
@@ -1103,7 +1085,7 @@ namespace FileSystemIDandChk.PartPlugins
// 32bytes // 32bytes
} }
private struct UNIXVTOC struct UNIXVTOC
{ {
public UInt32 magic; public UInt32 magic;
// UNIXVTOC_MAGIC // UNIXVTOC_MAGIC
@@ -1119,7 +1101,7 @@ namespace FileSystemIDandChk.PartPlugins
// 40 bytes // 40 bytes
} }
private struct UNIXVTOCEntry struct UNIXVTOCEntry
{ {
public UInt16 tag; public UInt16 tag;
// TAG // TAG
@@ -1131,51 +1113,51 @@ namespace FileSystemIDandChk.PartPlugins
// Length of slice in sectors // Length of slice in sectors
} }
private const UInt16 UNIX_TAG_EMPTY = 0x0000; const UInt16 UNIX_TAG_EMPTY = 0x0000;
// empty // empty
private const UInt16 UNIX_TAG_BOOT = 0x0001; const UInt16 UNIX_TAG_BOOT = 0x0001;
// boot // boot
private const UInt16 UNIX_TAG_ROOT = 0x0002; const UInt16 UNIX_TAG_ROOT = 0x0002;
// root // root
private const UInt16 UNIX_TAG_SWAP = 0x0003; const UInt16 UNIX_TAG_SWAP = 0x0003;
// swap // swap
private const UInt16 UNIX_TAG_USER = 0x0004; const UInt16 UNIX_TAG_USER = 0x0004;
// /usr // /usr
private const UInt16 UNIX_TAG_WHOLE = 0x0005; const UInt16 UNIX_TAG_WHOLE = 0x0005;
// whole disk // whole disk
private const UInt16 UNIX_TAG_STAND = 0x0006; const UInt16 UNIX_TAG_STAND = 0x0006;
// stand partition ?? // stand partition ??
private const UInt16 UNIX_TAG_ALT_S = 0x0006; const UInt16 UNIX_TAG_ALT_S = 0x0006;
// alternate sector space // alternate sector space
private const UInt16 UNIX_TAG_VAR = 0x0007; const UInt16 UNIX_TAG_VAR = 0x0007;
// /var // /var
private const UInt16 UNIX_TAG_OTHER = 0x0007; const UInt16 UNIX_TAG_OTHER = 0x0007;
// non UNIX // non UNIX
private const UInt16 UNIX_TAG_HOME = 0x0008; const UInt16 UNIX_TAG_HOME = 0x0008;
// /home // /home
private const UInt16 UNIX_TAG_ALT_T = 0x0008; const UInt16 UNIX_TAG_ALT_T = 0x0008;
// alternate track space // alternate track space
private const UInt16 UNIX_TAG_ALT_ST = 0x0009; const UInt16 UNIX_TAG_ALT_ST = 0x0009;
// alternate sector track // alternate sector track
private const UInt16 UNIX_TAG_NEW_STAND = 0x0009; const UInt16 UNIX_TAG_NEW_STAND = 0x0009;
// stand partition ?? // stand partition ??
private const UInt16 UNIX_TAG_CACHE = 0x000A; const UInt16 UNIX_TAG_CACHE = 0x000A;
// cache // cache
private const UInt16 UNIX_TAG_NEW_VAR = 0x000A; const UInt16 UNIX_TAG_NEW_VAR = 0x000A;
// /var // /var
private const UInt16 UNIX_TAG_RESERVED = 0x000B; const UInt16 UNIX_TAG_RESERVED = 0x000B;
// reserved // reserved
private const UInt16 UNIX_TAG_NEW_HOME = 0x000B; const UInt16 UNIX_TAG_NEW_HOME = 0x000B;
// /home // /home
private const UInt16 UNIX_TAG_DUMP = 0x000C; const UInt16 UNIX_TAG_DUMP = 0x000C;
// dump partition // dump partition
private const UInt16 UNIX_TAG_NEW_ALT_ST = 0x000D; const UInt16 UNIX_TAG_NEW_ALT_ST = 0x000D;
// alternate sector track // alternate sector track
private const UInt16 UNIX_TAG_VM_PUBLIC = 0x000E; const UInt16 UNIX_TAG_VM_PUBLIC = 0x000E;
// volume mgt public partition // volume mgt public partition
private const UInt16 UNIX_TAG_VM_PRIVATE = 0x000F; const UInt16 UNIX_TAG_VM_PRIVATE = 0x000F;
// volume mgt private partition // volume mgt private partition
private string decodeUNIXTAG(UInt16 type, bool isNew) static string decodeUNIXTAG(UInt16 type, bool isNew)
{ {
switch (type) switch (type)
{ {
@@ -1192,35 +1174,17 @@ namespace FileSystemIDandChk.PartPlugins
case UNIX_TAG_WHOLE: case UNIX_TAG_WHOLE:
return "Whole disk"; return "Whole disk";
case UNIX_TAG_STAND: case UNIX_TAG_STAND:
if (isNew) return isNew ? "Stand" : "Alternate sector space";
return "Stand";
else
return "Alternate sector space";
case UNIX_TAG_VAR: case UNIX_TAG_VAR:
if (isNew) return isNew ? "/var" : "non UNIX";
return "/var";
else
return "non UNIX";
case UNIX_TAG_HOME: case UNIX_TAG_HOME:
if (isNew) return isNew ? "/home" : "Alternate track space";
return "/home";
else
return "Alternate track space";
case UNIX_TAG_ALT_ST: case UNIX_TAG_ALT_ST:
if (isNew) return isNew ? "Alternate sector track" : "Stand";
return "Alternate sector track";
else
return "Stand";
case UNIX_TAG_CACHE: case UNIX_TAG_CACHE:
if (isNew) return isNew ? "Cache" : "/var";
return "Cache";
else
return "/var";
case UNIX_TAG_RESERVED: case UNIX_TAG_RESERVED:
if (isNew) return isNew ? "Reserved" : "/home";
return "Reserved";
else
return "/home";
case UNIX_TAG_DUMP: case UNIX_TAG_DUMP:
return "dump"; return "dump";
case UNIX_TAG_NEW_ALT_ST: case UNIX_TAG_NEW_ALT_ST:

View File

@@ -1,7 +1,6 @@
using System; using System;
using System.IO;
using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
namespace FileSystemIDandChk.PartPlugins namespace FileSystemIDandChk.PartPlugins
@@ -14,10 +13,10 @@ namespace FileSystemIDandChk.PartPlugins
// "dlV2" // "dlV2"
const UInt32 NEXT_MAGIC3 = 0x646C5633; const UInt32 NEXT_MAGIC3 = 0x646C5633;
// "dlV3" // "dlV3"
const UInt16 disktabStart = 0xB4;
const UInt16 disktabStart = 0xB4; // 180 // 180
const UInt16 disktabEntrySize = 0x2C; // 44 const UInt16 disktabEntrySize = 0x2C;
// 44
public NeXTDisklabel(PluginBase Core) public NeXTDisklabel(PluginBase Core)
{ {
Name = "NeXT Disklabel"; Name = "NeXT Disklabel";

View File

@@ -1,9 +1,9 @@
using System; using System;
using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using FileSystemIDandChk.Plugins; using System.Reflection;
using FileSystemIDandChk.PartPlugins;
using FileSystemIDandChk.ImagePlugins; using FileSystemIDandChk.ImagePlugins;
using FileSystemIDandChk.PartPlugins;
using FileSystemIDandChk.Plugins;
namespace FileSystemIDandChk namespace FileSystemIDandChk
{ {
@@ -15,9 +15,9 @@ namespace FileSystemIDandChk
public PluginBase() public PluginBase()
{ {
this.PluginsList = new Dictionary<string, Plugin>(); PluginsList = new Dictionary<string, Plugin>();
this.PartPluginsList = new Dictionary<string, PartPlugin>(); PartPluginsList = new Dictionary<string, PartPlugin>();
this.ImagePluginsList = new Dictionary<string, ImagePlugin>(); ImagePluginsList = new Dictionary<string, ImagePlugin>();
} }
public void RegisterAllPlugins() public void RegisterAllPlugins()
@@ -30,49 +30,49 @@ namespace FileSystemIDandChk
{ {
if (type.IsSubclassOf(typeof(ImagePlugin))) if (type.IsSubclassOf(typeof(ImagePlugin)))
{ {
ImagePlugin plugin = (ImagePlugin)type.GetConstructor(new Type[] { typeof(PluginBase) }).Invoke(new object[] { this }); ImagePlugin plugin = (ImagePlugin)type.GetConstructor(new [] { typeof(PluginBase) }).Invoke(new object[] { this });
this.RegisterImagePlugin(plugin); RegisterImagePlugin(plugin);
} }
if (type.IsSubclassOf(typeof(Plugin))) if (type.IsSubclassOf(typeof(Plugin)))
{ {
Plugin plugin = (Plugin)type.GetConstructor(new Type[] { typeof(PluginBase) }).Invoke(new object[] { this }); Plugin plugin = (Plugin)type.GetConstructor(new [] { typeof(PluginBase) }).Invoke(new object[] { this });
this.RegisterPlugin(plugin); RegisterPlugin(plugin);
} }
else if (type.IsSubclassOf(typeof(PartPlugin))) else if (type.IsSubclassOf(typeof(PartPlugin)))
{ {
PartPlugin partplugin = (PartPlugin)type.GetConstructor(new Type[] { typeof(PluginBase) }).Invoke(new object[] { this }); PartPlugin partplugin = (PartPlugin)type.GetConstructor(new [] { typeof(PluginBase) }).Invoke(new object[] { this });
this.RegisterPartPlugin(partplugin); RegisterPartPlugin(partplugin);
} }
} }
catch (Exception exception) catch (Exception exception)
{ {
Console.WriteLine(exception.ToString()); Console.WriteLine(exception);
} }
} }
} }
private void RegisterImagePlugin(ImagePlugin plugin) void RegisterImagePlugin(ImagePlugin plugin)
{ {
if (!this.ImagePluginsList.ContainsKey(plugin.Name.ToLower())) if (!ImagePluginsList.ContainsKey(plugin.Name.ToLower()))
{ {
this.ImagePluginsList.Add(plugin.Name.ToLower(), plugin); ImagePluginsList.Add(plugin.Name.ToLower(), plugin);
} }
} }
private void RegisterPlugin(Plugin plugin) void RegisterPlugin(Plugin plugin)
{ {
if (!this.PluginsList.ContainsKey(plugin.Name.ToLower())) if (!PluginsList.ContainsKey(plugin.Name.ToLower()))
{ {
this.PluginsList.Add(plugin.Name.ToLower(), plugin); PluginsList.Add(plugin.Name.ToLower(), plugin);
} }
} }
private void RegisterPartPlugin(PartPlugin partplugin) void RegisterPartPlugin(PartPlugin partplugin)
{ {
if (!this.PartPluginsList.ContainsKey(partplugin.Name.ToLower())) if (!PartPluginsList.ContainsKey(partplugin.Name.ToLower()))
{ {
this.PartPluginsList.Add(partplugin.Name.ToLower(), partplugin); PartPluginsList.Add(partplugin.Name.ToLower(), partplugin);
} }
} }
} }

View File

@@ -9,14 +9,16 @@ namespace FileSystemIDandChk.Plugins
{ {
class AppleHFS : Plugin class AppleHFS : Plugin
{ {
private const UInt16 HFS_MAGIC = 0x4244; // "BD" const UInt16 HFS_MAGIC = 0x4244;
private const UInt16 HFSP_MAGIC = 0x482B; // "H+" // "BD"
private const UInt16 HFSBB_MAGIC = 0x4C4B; // "LK" const UInt16 HFSP_MAGIC = 0x482B;
// "H+"
const UInt16 HFSBB_MAGIC = 0x4C4B;
// "LK"
public AppleHFS(PluginBase Core) public AppleHFS(PluginBase Core)
{ {
base.Name = "Apple Hierarchical File System"; Name = "Apple Hierarchical File System";
base.PluginUUID = new Guid("36405F8D-0D26-6ECC-0BBB-1D5225FF404F"); PluginUUID = new Guid("36405F8D-0D26-6ECC-0BBB-1D5225FF404F");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -28,12 +30,8 @@ namespace FileSystemIDandChk.Plugins
{ {
drSigWord = BigEndianBitConverter.ToUInt16(mdb_sector, 0x7C); // Seek to embedded HFS+ signature drSigWord = BigEndianBitConverter.ToUInt16(mdb_sector, 0x7C); // Seek to embedded HFS+ signature
if(drSigWord == HFSP_MAGIC) // "H+" return drSigWord != HFSP_MAGIC;
return false;
else
return true;
} }
else
return false; return false;
} }
@@ -253,72 +251,128 @@ namespace FileSystemIDandChk.Plugins
return; return;
} }
private struct HFS_MasterDirectoryBlock // Should be sector 2 in volume struct HFS_MasterDirectoryBlock // Should be sector 2 in volume
{ {
public UInt16 drSigWord; // 0x000, Signature, 0x4244 public UInt16 drSigWord;
public UInt32 drCrDate; // 0x002, Volume creation date // 0x000, Signature, 0x4244
public UInt32 drLsMod; // 0x006, Volume last modification date public UInt32 drCrDate;
public UInt16 drAtrb; // 0x00A, Volume attributes // 0x002, Volume creation date
public UInt16 drNmFls; // 0x00C, Files in root directory public UInt32 drLsMod;
public UInt16 drVBMSt; // 0x00E, Start 512-byte sector of volume bitmap // 0x006, Volume last modification date
public UInt16 drAllocPtr; // 0x010, Allocation block to begin next allocation public UInt16 drAtrb;
public UInt16 drNmAlBlks; // 0x012, Allocation blocks // 0x00A, Volume attributes
public UInt32 drAlBlkSiz; // 0x014, Bytes per allocation block public UInt16 drNmFls;
public UInt32 drClpSiz; // 0x018, Bytes to allocate when extending a file // 0x00C, Files in root directory
public UInt16 drAlBlSt; // 0x01C, Start 512-byte sector of first allocation block public UInt16 drVBMSt;
public UInt32 drNxtCNID; // 0x01E, CNID for next file // 0x00E, Start 512-byte sector of volume bitmap
public UInt16 drFreeBks; // 0x022, Free allocation blocks public UInt16 drAllocPtr;
public string drVN; // 0x024, Volume name (28 bytes) // 0x010, Allocation block to begin next allocation
public UInt32 drVolBkUp; // 0x040, Volume last backup time public UInt16 drNmAlBlks;
public UInt16 drVSeqNum; // 0x044, Volume backup sequence number // 0x012, Allocation blocks
public UInt32 drWrCnt; // 0x046, Filesystem write count public UInt32 drAlBlkSiz;
public UInt32 drXTClpSiz; // 0x04A, Bytes to allocate when extending the extents B-Tree // 0x014, Bytes per allocation block
public UInt32 drCTClpSiz; // 0x04E, Bytes to allocate when extending the catalog B-Tree public UInt32 drClpSiz;
public UInt16 drNmRtDirs; // 0x052, Number of directories in root directory // 0x018, Bytes to allocate when extending a file
public UInt32 drFilCnt; // 0x054, Number of files in the volume public UInt16 drAlBlSt;
public UInt32 drDirCnt; // 0x058, Number of directories in the volume // 0x01C, Start 512-byte sector of first allocation block
public UInt32 drFndrInfo0; // 0x05C, finderInfo[0], CNID for bootable system's directory public UInt32 drNxtCNID;
public UInt32 drFndrInfo1; // 0x060, finderInfo[1], CNID of the directory containing the boot application // 0x01E, CNID for next file
public UInt32 drFndrInfo2; // 0x064, finderInfo[2], CNID of the directory that should be opened on boot public UInt16 drFreeBks;
public UInt32 drFndrInfo3; // 0x068, finderInfo[3], CNID for Mac OS 8 or 9 directory // 0x022, Free allocation blocks
public UInt32 drFndrInfo4; // 0x06C, finderInfo[4], Reserved public string drVN;
public UInt32 drFndrInfo5; // 0x070, finderInfo[5], CNID for Mac OS X directory // 0x024, Volume name (28 bytes)
public UInt32 drFndrInfo6; // 0x074, finderInfo[6], first part of Mac OS X volume ID public UInt32 drVolBkUp;
public UInt32 drFndrInfo7; // 0x078, finderInfo[7], second part of Mac OS X volume ID // 0x040, Volume last backup time
public UInt16 drVSeqNum;
// 0x044, Volume backup sequence number
public UInt32 drWrCnt;
// 0x046, Filesystem write count
public UInt32 drXTClpSiz;
// 0x04A, Bytes to allocate when extending the extents B-Tree
public UInt32 drCTClpSiz;
// 0x04E, Bytes to allocate when extending the catalog B-Tree
public UInt16 drNmRtDirs;
// 0x052, Number of directories in root directory
public UInt32 drFilCnt;
// 0x054, Number of files in the volume
public UInt32 drDirCnt;
// 0x058, Number of directories in the volume
public UInt32 drFndrInfo0;
// 0x05C, finderInfo[0], CNID for bootable system's directory
public UInt32 drFndrInfo1;
// 0x060, finderInfo[1], CNID of the directory containing the boot application
public UInt32 drFndrInfo2;
// 0x064, finderInfo[2], CNID of the directory that should be opened on boot
public UInt32 drFndrInfo3;
// 0x068, finderInfo[3], CNID for Mac OS 8 or 9 directory
public UInt32 drFndrInfo4;
// 0x06C, finderInfo[4], Reserved
public UInt32 drFndrInfo5;
// 0x070, finderInfo[5], CNID for Mac OS X directory
public UInt32 drFndrInfo6;
// 0x074, finderInfo[6], first part of Mac OS X volume ID
public UInt32 drFndrInfo7;
// 0x078, finderInfo[7], second part of Mac OS X volume ID
// If wrapping HFS+ // If wrapping HFS+
public UInt16 drEmbedSigWord; // 0x07C, Embedded volume signature, "H+" if HFS+ is embedded ignore following two fields if not public UInt16 drEmbedSigWord;
public UInt16 xdrStABNt; // 0x07E, Starting block number of embedded HFS+ volume // 0x07C, Embedded volume signature, "H+" if HFS+ is embedded ignore following two fields if not
public UInt16 xdrNumABlks; // 0x080, Allocation blocks used by embedded volume public UInt16 xdrStABNt;
// 0x07E, Starting block number of embedded HFS+ volume
public UInt16 xdrNumABlks;
// 0x080, Allocation blocks used by embedded volume
// If not // If not
public UInt16 drVCSize; // 0x07C, Size in blocks of volume cache public UInt16 drVCSize;
public UInt16 drVBMCSize; // 0x07E, Size in blocks of volume bitmap cache // 0x07C, Size in blocks of volume cache
public UInt16 drCtlCSize; // 0x080, Size in blocks of volume common cache public UInt16 drVBMCSize;
// 0x07E, Size in blocks of volume bitmap cache
public UInt16 drCtlCSize;
// 0x080, Size in blocks of volume common cache
// End of variable variables :D // End of variable variables :D
public UInt32 drXTFlSize; // 0x082, Bytes in the extents B-Tree public UInt32 drXTFlSize;
// 0x082, Bytes in the extents B-Tree
// 3 HFS extents following, 32 bits each // 3 HFS extents following, 32 bits each
public UInt32 drCTFlSize; // 0x092, Bytes in the catalog B-Tree public UInt32 drCTFlSize;
// 0x092, Bytes in the catalog B-Tree
// 3 HFS extents following, 32 bits each // 3 HFS extents following, 32 bits each
} }
private struct HFS_BootBlock // Should be sectors 0 and 1 in volume struct HFS_BootBlock // Should be sectors 0 and 1 in volume
{ {
public UInt16 signature; // 0x000, Signature, 0x4C4B if bootable public UInt16 signature;
public UInt32 branch; // 0x002, Branch // 0x000, Signature, 0x4C4B if bootable
public byte boot_flags; // 0x006, Boot block flags public UInt32 branch;
public byte boot_version; // 0x007, Boot block version // 0x002, Branch
public Int16 sec_sv_pages; // 0x008, Allocate secondary buffers public byte boot_flags;
public string system_name; // 0x00A, System file name (16 bytes) // 0x006, Boot block flags
public string finder_name; // 0x01A, Finder file name (16 bytes) public byte boot_version;
public string debug_name; // 0x02A, Debugger file name (16 bytes) // 0x007, Boot block version
public string disasm_name; // 0x03A, Disassembler file name (16 bytes) public Int16 sec_sv_pages;
public string stupscr_name; // 0x04A, Startup screen file name (16 bytes) // 0x008, Allocate secondary buffers
public string bootup_name; // 0x05A, First program to execute on boot (16 bytes) public string system_name;
public string clipbrd_name; // 0x06A, Clipboard file name (16 bytes) // 0x00A, System file name (16 bytes)
public UInt16 max_files; // 0x07A, 1/4 of maximum opened at a time files public string finder_name;
public UInt16 queue_size; // 0x07C, Event queue size // 0x01A, Finder file name (16 bytes)
public UInt32 heap_128k; // 0x07E, Heap size on a Mac with 128KiB of RAM public string debug_name;
public UInt32 heap_256k; // 0x082, Heap size on a Mac with 256KiB of RAM // 0x02A, Debugger file name (16 bytes)
public UInt32 heap_512k; // 0x086, Heap size on a Mac with 512KiB of RAM or more public string disasm_name;
} // Follows boot code // 0x03A, Disassembler file name (16 bytes)
public string stupscr_name;
// 0x04A, Startup screen file name (16 bytes)
public string bootup_name;
// 0x05A, First program to execute on boot (16 bytes)
public string clipbrd_name;
// 0x06A, Clipboard file name (16 bytes)
public UInt16 max_files;
// 0x07A, 1/4 of maximum opened at a time files
public UInt16 queue_size;
// 0x07C, Event queue size
public UInt32 heap_128k;
// 0x07E, Heap size on a Mac with 128KiB of RAM
public UInt32 heap_256k;
// 0x082, Heap size on a Mac with 256KiB of RAM
public UInt32 heap_512k;
// 0x086, Heap size on a Mac with 512KiB of RAM or more
}
// Follows boot code
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -8,14 +7,16 @@ namespace FileSystemIDandChk.Plugins
{ {
class AppleHFSPlus : Plugin class AppleHFSPlus : Plugin
{ {
private const UInt16 HFS_MAGIC = 0x4244; // "BD" const UInt16 HFS_MAGIC = 0x4244;
private const UInt16 HFSP_MAGIC = 0x482B; // "H+" // "BD"
private const UInt16 HFSX_MAGIC = 0x4858; // "HX" const UInt16 HFSP_MAGIC = 0x482B;
// "H+"
const UInt16 HFSX_MAGIC = 0x4858;
// "HX"
public AppleHFSPlus(PluginBase Core) public AppleHFSPlus(PluginBase Core)
{ {
base.Name = "Apple HFS+ filesystem"; Name = "Apple HFS+ filesystem";
base.PluginUUID = new Guid("36405F8D-0D26-6EBE-436F-62F0586B4F08"); PluginUUID = new Guid("36405F8D-0D26-6EBE-436F-62F0586B4F08");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -61,7 +62,6 @@ namespace FileSystemIDandChk.Plugins
drSigWord = BigEndianBitConverter.ToUInt16(vh_sector, 0); drSigWord = BigEndianBitConverter.ToUInt16(vh_sector, 0);
if (drSigWord == HFSP_MAGIC || drSigWord == HFSX_MAGIC) if (drSigWord == HFSP_MAGIC || drSigWord == HFSX_MAGIC)
return true; return true;
else
return false; return false;
} }
@@ -76,7 +76,7 @@ namespace FileSystemIDandChk.Plugins
HFSPlusVolumeHeader HPVH = new HFSPlusVolumeHeader(); HFSPlusVolumeHeader HPVH = new HFSPlusVolumeHeader();
ulong hfsp_offset; ulong hfsp_offset;
bool wrapped = false; bool wrapped;
byte[] vh_sector; byte[] vh_sector;
vh_sector = imagePlugin.ReadSector(2 + partitionOffset); // Read volume header, of HFS Wrapper MDB vh_sector = imagePlugin.ReadSector(2 + partitionOffset); // Read volume header, of HFS Wrapper MDB
@@ -227,150 +227,265 @@ namespace FileSystemIDandChk.Plugins
else else
return; return;
} }
// Size = 532 bytes // Size = 532 bytes
private struct HFSPlusVolumeHeader // Should be offset 0x0400 bytes in volume struct HFSPlusVolumeHeader // Should be offset 0x0400 bytes in volume
{ {
public UInt16 signature; // 0x000, "H+" for HFS+, "HX" for HFSX public UInt16 signature;
public UInt16 version; // 0x002, 4 for HFS+, 5 for HFSX // 0x000, "H+" for HFS+, "HX" for HFSX
public UInt32 attributes; // 0x004, Volume attributes public UInt16 version;
public string lastMountedVersion; // 0x008, Implementation that last mounted the volume. // 0x002, 4 for HFS+, 5 for HFSX
public UInt32 attributes;
// 0x004, Volume attributes
public string lastMountedVersion;
// 0x008, Implementation that last mounted the volume.
// Reserved by Apple: // Reserved by Apple:
// "8.10" Mac OS 8.1 to 9.2.2 // "8.10" Mac OS 8.1 to 9.2.2
// "10.0" Mac OS X // "10.0" Mac OS X
// "HFSJ" Journaled implementation // "HFSJ" Journaled implementation
// "fsck" /sbin/fsck // "fsck" /sbin/fsck
public UInt32 journalInfoBlock; // 0x00C, Allocation block number containing the journal public UInt32 journalInfoBlock;
// 0x00C, Allocation block number containing the journal
public ulong createDate; // 0x010, Date of volume creation public ulong createDate;
public ulong modifyDate; // 0x018, Date of last volume modification // 0x010, Date of volume creation
public ulong backupDate; // 0x020, Date of last backup public ulong modifyDate;
public ulong checkedDate; // 0x028, Date of last consistency check // 0x018, Date of last volume modification
public ulong backupDate;
public UInt32 fileCount; // 0x030, File on the volume // 0x020, Date of last backup
public UInt32 folderCount; // 0x034, Folders on the volume public ulong checkedDate;
// 0x028, Date of last consistency check
public UInt32 blockSize; // 0x038, Bytes per allocation block public UInt32 fileCount;
public UInt32 totalBlocks; // 0x03C, Allocation blocks on the volume // 0x030, File on the volume
public UInt32 freeBlocks; // 0x040, Free allocation blocks public UInt32 folderCount;
// 0x034, Folders on the volume
public UInt32 nextAllocation; // 0x044, Hint for next allocation block public UInt32 blockSize;
public UInt32 rsrcClumpSize; // 0x048, Resource fork clump size // 0x038, Bytes per allocation block
public UInt32 dataClumpSize; // 0x04C, Data fork clump size public UInt32 totalBlocks;
public UInt32 nextCatalogID; // 0x050, Next unused CNID // 0x03C, Allocation blocks on the volume
public UInt32 freeBlocks;
public UInt32 writeCount; // 0x054, Times that the volume has been mounted writable // 0x040, Free allocation blocks
public UInt64 encodingsBitmap; // 0x058, Used text encoding hints public UInt32 nextAllocation;
// 0x044, Hint for next allocation block
public UInt32 drFndrInfo0; // 0x060, finderInfo[0], CNID for bootable system's directory public UInt32 rsrcClumpSize;
public UInt32 drFndrInfo1; // 0x064, finderInfo[1], CNID of the directory containing the boot application // 0x048, Resource fork clump size
public UInt32 drFndrInfo2; // 0x068, finderInfo[2], CNID of the directory that should be opened on boot public UInt32 dataClumpSize;
public UInt32 drFndrInfo3; // 0x06C, finderInfo[3], CNID for Mac OS 8 or 9 directory // 0x04C, Data fork clump size
public UInt32 drFndrInfo4; // 0x070, finderInfo[4], Reserved public UInt32 nextCatalogID;
public UInt32 drFndrInfo5; // 0x074, finderInfo[5], CNID for Mac OS X directory // 0x050, Next unused CNID
public UInt32 drFndrInfo6; // 0x078, finderInfo[6], first part of Mac OS X volume ID public UInt32 writeCount;
public UInt32 drFndrInfo7; // 0x07C, finderInfo[7], second part of Mac OS X volume ID // 0x054, Times that the volume has been mounted writable
public UInt64 encodingsBitmap;
// 0x058, Used text encoding hints
public UInt32 drFndrInfo0;
// 0x060, finderInfo[0], CNID for bootable system's directory
public UInt32 drFndrInfo1;
// 0x064, finderInfo[1], CNID of the directory containing the boot application
public UInt32 drFndrInfo2;
// 0x068, finderInfo[2], CNID of the directory that should be opened on boot
public UInt32 drFndrInfo3;
// 0x06C, finderInfo[3], CNID for Mac OS 8 or 9 directory
public UInt32 drFndrInfo4;
// 0x070, finderInfo[4], Reserved
public UInt32 drFndrInfo5;
// 0x074, finderInfo[5], CNID for Mac OS X directory
public UInt32 drFndrInfo6;
// 0x078, finderInfo[6], first part of Mac OS X volume ID
public UInt32 drFndrInfo7;
// 0x07C, finderInfo[7], second part of Mac OS X volume ID
// HFSPlusForkData allocationFile; // HFSPlusForkData allocationFile;
public UInt64 allocationFile_logicalSize; // 0x080 public UInt64 allocationFile_logicalSize;
public UInt32 allocationFile_clumpSize; // 0x088 // 0x080
public UInt32 allocationFile_totalBlocks; // 0x08C public UInt32 allocationFile_clumpSize;
public UInt32 allocationFile_extents_startBlock0; // 0x090 // 0x088
public UInt32 allocationFile_extents_blockCount0; // 0x094 public UInt32 allocationFile_totalBlocks;
public UInt32 allocationFile_extents_startBlock1; // 0x098 // 0x08C
public UInt32 allocationFile_extents_blockCount1; // 0x09C public UInt32 allocationFile_extents_startBlock0;
public UInt32 allocationFile_extents_startBlock2; // 0x0A0 // 0x090
public UInt32 allocationFile_extents_blockCount2; // 0x0A4 public UInt32 allocationFile_extents_blockCount0;
public UInt32 allocationFile_extents_startBlock3; // 0x0A8 // 0x094
public UInt32 allocationFile_extents_blockCount3; // 0x0AC public UInt32 allocationFile_extents_startBlock1;
public UInt32 allocationFile_extents_startBlock4; // 0x0B0 // 0x098
public UInt32 allocationFile_extents_blockCount4; // 0x0B4 public UInt32 allocationFile_extents_blockCount1;
public UInt32 allocationFile_extents_startBlock5; // 0x0B8 // 0x09C
public UInt32 allocationFile_extents_blockCount5; // 0x0BC public UInt32 allocationFile_extents_startBlock2;
public UInt32 allocationFile_extents_startBlock6; // 0x0C0 // 0x0A0
public UInt32 allocationFile_extents_blockCount6; // 0x0C4 public UInt32 allocationFile_extents_blockCount2;
public UInt32 allocationFile_extents_startBlock7; // 0x0C8 // 0x0A4
public UInt32 allocationFile_extents_blockCount7; // 0x0CC public UInt32 allocationFile_extents_startBlock3;
// 0x0A8
public UInt32 allocationFile_extents_blockCount3;
// 0x0AC
public UInt32 allocationFile_extents_startBlock4;
// 0x0B0
public UInt32 allocationFile_extents_blockCount4;
// 0x0B4
public UInt32 allocationFile_extents_startBlock5;
// 0x0B8
public UInt32 allocationFile_extents_blockCount5;
// 0x0BC
public UInt32 allocationFile_extents_startBlock6;
// 0x0C0
public UInt32 allocationFile_extents_blockCount6;
// 0x0C4
public UInt32 allocationFile_extents_startBlock7;
// 0x0C8
public UInt32 allocationFile_extents_blockCount7;
// 0x0CC
// HFSPlusForkData extentsFile; // HFSPlusForkData extentsFile;
public UInt64 extentsFile_logicalSize; // 0x0D0 public UInt64 extentsFile_logicalSize;
public UInt32 extentsFile_clumpSize; // 0x0D8 // 0x0D0
public UInt32 extentsFile_totalBlocks; // 0x0DC public UInt32 extentsFile_clumpSize;
public UInt32 extentsFile_extents_startBlock0; // 0x0E0 // 0x0D8
public UInt32 extentsFile_extents_blockCount0; // 0x0E4 public UInt32 extentsFile_totalBlocks;
public UInt32 extentsFile_extents_startBlock1; // 0x0E8 // 0x0DC
public UInt32 extentsFile_extents_blockCount1; // 0x0EC public UInt32 extentsFile_extents_startBlock0;
public UInt32 extentsFile_extents_startBlock2; // 0x0F0 // 0x0E0
public UInt32 extentsFile_extents_blockCount2; // 0x0F4 public UInt32 extentsFile_extents_blockCount0;
public UInt32 extentsFile_extents_startBlock3; // 0x0F8 // 0x0E4
public UInt32 extentsFile_extents_blockCount3; // 0x0FC public UInt32 extentsFile_extents_startBlock1;
public UInt32 extentsFile_extents_startBlock4; // 0x100 // 0x0E8
public UInt32 extentsFile_extents_blockCount4; // 0x104 public UInt32 extentsFile_extents_blockCount1;
public UInt32 extentsFile_extents_startBlock5; // 0x108 // 0x0EC
public UInt32 extentsFile_extents_blockCount5; // 0x10C public UInt32 extentsFile_extents_startBlock2;
public UInt32 extentsFile_extents_startBlock6; // 0x110 // 0x0F0
public UInt32 extentsFile_extents_blockCount6; // 0x114 public UInt32 extentsFile_extents_blockCount2;
public UInt32 extentsFile_extents_startBlock7; // 0x118 // 0x0F4
public UInt32 extentsFile_extents_blockCount7; // 0x11C public UInt32 extentsFile_extents_startBlock3;
// 0x0F8
public UInt32 extentsFile_extents_blockCount3;
// 0x0FC
public UInt32 extentsFile_extents_startBlock4;
// 0x100
public UInt32 extentsFile_extents_blockCount4;
// 0x104
public UInt32 extentsFile_extents_startBlock5;
// 0x108
public UInt32 extentsFile_extents_blockCount5;
// 0x10C
public UInt32 extentsFile_extents_startBlock6;
// 0x110
public UInt32 extentsFile_extents_blockCount6;
// 0x114
public UInt32 extentsFile_extents_startBlock7;
// 0x118
public UInt32 extentsFile_extents_blockCount7;
// 0x11C
// HFSPlusForkData catalogFile; // HFSPlusForkData catalogFile;
public UInt64 catalogFile_logicalSize; // 0x120 public UInt64 catalogFile_logicalSize;
public UInt32 catalogFile_clumpSize; // 0x128 // 0x120
public UInt32 catalogFile_totalBlocks; // 0x12C public UInt32 catalogFile_clumpSize;
public UInt32 catalogFile_extents_startBlock0; // 0x130 // 0x128
public UInt32 catalogFile_extents_blockCount0; // 0x134 public UInt32 catalogFile_totalBlocks;
public UInt32 catalogFile_extents_startBlock1; // 0x138 // 0x12C
public UInt32 catalogFile_extents_blockCount1; // 0x13C public UInt32 catalogFile_extents_startBlock0;
public UInt32 catalogFile_extents_startBlock2; // 0x140 // 0x130
public UInt32 catalogFile_extents_blockCount2; // 0x144 public UInt32 catalogFile_extents_blockCount0;
public UInt32 catalogFile_extents_startBlock3; // 0x148 // 0x134
public UInt32 catalogFile_extents_blockCount3; // 0x14C public UInt32 catalogFile_extents_startBlock1;
public UInt32 catalogFile_extents_startBlock4; // 0x150 // 0x138
public UInt32 catalogFile_extents_blockCount4; // 0x154 public UInt32 catalogFile_extents_blockCount1;
public UInt32 catalogFile_extents_startBlock5; // 0x158 // 0x13C
public UInt32 catalogFile_extents_blockCount5; // 0x15C public UInt32 catalogFile_extents_startBlock2;
public UInt32 catalogFile_extents_startBlock6; // 0x160 // 0x140
public UInt32 catalogFile_extents_blockCount6; // 0x164 public UInt32 catalogFile_extents_blockCount2;
public UInt32 catalogFile_extents_startBlock7; // 0x168 // 0x144
public UInt32 catalogFile_extents_blockCount7; // 0x16C public UInt32 catalogFile_extents_startBlock3;
// 0x148
public UInt32 catalogFile_extents_blockCount3;
// 0x14C
public UInt32 catalogFile_extents_startBlock4;
// 0x150
public UInt32 catalogFile_extents_blockCount4;
// 0x154
public UInt32 catalogFile_extents_startBlock5;
// 0x158
public UInt32 catalogFile_extents_blockCount5;
// 0x15C
public UInt32 catalogFile_extents_startBlock6;
// 0x160
public UInt32 catalogFile_extents_blockCount6;
// 0x164
public UInt32 catalogFile_extents_startBlock7;
// 0x168
public UInt32 catalogFile_extents_blockCount7;
// 0x16C
// HFSPlusForkData attributesFile; // HFSPlusForkData attributesFile;
public UInt64 attributesFile_logicalSize; // 0x170 public UInt64 attributesFile_logicalSize;
public UInt32 attributesFile_clumpSize; // 0x178 // 0x170
public UInt32 attributesFile_totalBlocks; // 0x17C public UInt32 attributesFile_clumpSize;
public UInt32 attributesFile_extents_startBlock0; // 0x180 // 0x178
public UInt32 attributesFile_extents_blockCount0; // 0x184 public UInt32 attributesFile_totalBlocks;
public UInt32 attributesFile_extents_startBlock1; // 0x188 // 0x17C
public UInt32 attributesFile_extents_blockCount1; // 0x18C public UInt32 attributesFile_extents_startBlock0;
public UInt32 attributesFile_extents_startBlock2; // 0x190 // 0x180
public UInt32 attributesFile_extents_blockCount2; // 0x194 public UInt32 attributesFile_extents_blockCount0;
public UInt32 attributesFile_extents_startBlock3; // 0x198 // 0x184
public UInt32 attributesFile_extents_blockCount3; // 0x19C public UInt32 attributesFile_extents_startBlock1;
public UInt32 attributesFile_extents_startBlock4; // 0x1A0 // 0x188
public UInt32 attributesFile_extents_blockCount4; // 0x1A4 public UInt32 attributesFile_extents_blockCount1;
public UInt32 attributesFile_extents_startBlock5; // 0x1A8 // 0x18C
public UInt32 attributesFile_extents_blockCount5; // 0x1AC public UInt32 attributesFile_extents_startBlock2;
public UInt32 attributesFile_extents_startBlock6; // 0x1B0 // 0x190
public UInt32 attributesFile_extents_blockCount6; // 0x1B4 public UInt32 attributesFile_extents_blockCount2;
public UInt32 attributesFile_extents_startBlock7; // 0x1B8 // 0x194
public UInt32 attributesFile_extents_blockCount7; // 0x1BC public UInt32 attributesFile_extents_startBlock3;
// 0x198
public UInt32 attributesFile_extents_blockCount3;
// 0x19C
public UInt32 attributesFile_extents_startBlock4;
// 0x1A0
public UInt32 attributesFile_extents_blockCount4;
// 0x1A4
public UInt32 attributesFile_extents_startBlock5;
// 0x1A8
public UInt32 attributesFile_extents_blockCount5;
// 0x1AC
public UInt32 attributesFile_extents_startBlock6;
// 0x1B0
public UInt32 attributesFile_extents_blockCount6;
// 0x1B4
public UInt32 attributesFile_extents_startBlock7;
// 0x1B8
public UInt32 attributesFile_extents_blockCount7;
// 0x1BC
// HFSPlusForkData startupFile; // HFSPlusForkData startupFile;
public UInt64 startupFile_logicalSize; // 0x1C0 public UInt64 startupFile_logicalSize;
public UInt32 startupFile_clumpSize; // 0x1C8 // 0x1C0
public UInt32 startupFile_totalBlocks; // 0x1CC public UInt32 startupFile_clumpSize;
public UInt32 startupFile_extents_startBlock0; // 0x1D0 // 0x1C8
public UInt32 startupFile_extents_blockCount0; // 0x1D4 public UInt32 startupFile_totalBlocks;
public UInt32 startupFile_extents_startBlock1; // 0x1D8 // 0x1CC
public UInt32 startupFile_extents_blockCount1; // 0x1E0 public UInt32 startupFile_extents_startBlock0;
public UInt32 startupFile_extents_startBlock2; // 0x1E4 // 0x1D0
public UInt32 startupFile_extents_blockCount2; // 0x1E8 public UInt32 startupFile_extents_blockCount0;
public UInt32 startupFile_extents_startBlock3; // 0x1EC // 0x1D4
public UInt32 startupFile_extents_blockCount3; // 0x1F0 public UInt32 startupFile_extents_startBlock1;
public UInt32 startupFile_extents_startBlock4; // 0x1F4 // 0x1D8
public UInt32 startupFile_extents_blockCount4; // 0x1F8 public UInt32 startupFile_extents_blockCount1;
public UInt32 startupFile_extents_startBlock5; // 0x1FC // 0x1E0
public UInt32 startupFile_extents_blockCount5; // 0x200 public UInt32 startupFile_extents_startBlock2;
public UInt32 startupFile_extents_startBlock6; // 0x204 // 0x1E4
public UInt32 startupFile_extents_blockCount6; // 0x208 public UInt32 startupFile_extents_blockCount2;
public UInt32 startupFile_extents_startBlock7; // 0x20C // 0x1E8
public UInt32 startupFile_extents_blockCount7; // 0x210 public UInt32 startupFile_extents_startBlock3;
// 0x1EC
public UInt32 startupFile_extents_blockCount3;
// 0x1F0
public UInt32 startupFile_extents_startBlock4;
// 0x1F4
public UInt32 startupFile_extents_blockCount4;
// 0x1F8
public UInt32 startupFile_extents_startBlock5;
// 0x1FC
public UInt32 startupFile_extents_blockCount5;
// 0x200
public UInt32 startupFile_extents_startBlock6;
// 0x204
public UInt32 startupFile_extents_blockCount6;
// 0x208
public UInt32 startupFile_extents_startBlock7;
// 0x20C
public UInt32 startupFile_extents_blockCount7;
// 0x210
} }
} }
} }

View File

@@ -1,40 +1,34 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
// Information from Inside Macintosh // Information from Inside Macintosh
// TODO: Implement support for disc images
/*
namespace FileSystemIDandChk.Plugins namespace FileSystemIDandChk.Plugins
{ {
class AppleMFS : Plugin class AppleMFS : Plugin
{ {
private const UInt16 MFS_MAGIC = 0xD2D7; const UInt16 MFS_MAGIC = 0xD2D7;
private const UInt16 MFSBB_MAGIC = 0x4C4B; // "LK" // "LK"
const UInt16 MFSBB_MAGIC = 0x4C4B;
public AppleMFS(PluginBase Core) public AppleMFS(PluginBase Core)
{ {
base.Name = "Apple Macintosh File System"; Name = "Apple Macintosh File System";
base.PluginUUID = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A"); PluginUUID = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
} }
public override bool Identify(FileStream stream, long offset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
{ {
UInt16 drSigWord; UInt16 drSigWord;
EndianAwareBinaryReader eabr = new EndianAwareBinaryReader(stream, false); // BigEndian byte[] mdb_sector = imagePlugin.ReadSector(2 + partitionOffset);
eabr.BaseStream.Seek(0x400 + offset, SeekOrigin.Begin);
drSigWord = eabr.ReadUInt16(); drSigWord = BigEndianBitConverter.ToUInt16(mdb_sector, 0x000);
if(drSigWord == MFS_MAGIC) return drSigWord == MFS_MAGIC;
return true;
else
return false;
} }
public override void GetInformation (FileStream stream, long offset, out string information) public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
{ {
information = ""; information = "";
@@ -43,62 +37,63 @@ namespace FileSystemIDandChk.Plugins
MFS_MasterDirectoryBlock MDB = new MFS_MasterDirectoryBlock(); MFS_MasterDirectoryBlock MDB = new MFS_MasterDirectoryBlock();
MFS_BootBlock BB = new MFS_BootBlock(); MFS_BootBlock BB = new MFS_BootBlock();
byte[] pString; byte[] pString = new byte[16];
byte[] variable_size; byte[] variable_size;
EndianAwareBinaryReader eabr = new EndianAwareBinaryReader(stream, false); // BigEndian byte[] mdb_sector = imagePlugin.ReadSector(2 + partitionOffset);
eabr.BaseStream.Seek(0x400 + offset, SeekOrigin.Begin); byte[] bb_sector = imagePlugin.ReadSector(0 + partitionOffset);
MDB.drSigWord = eabr.ReadUInt16();
MDB.drSigWord = BigEndianBitConverter.ToUInt16(mdb_sector, 0x000);
if (MDB.drSigWord != MFS_MAGIC) if (MDB.drSigWord != MFS_MAGIC)
return; return;
MDB.drCrDate = eabr.ReadUInt32(); MDB.drCrDate = BigEndianBitConverter.ToUInt32(mdb_sector, 0x002);
MDB.drLsBkUp = eabr.ReadUInt32(); MDB.drLsBkUp = BigEndianBitConverter.ToUInt32(mdb_sector, 0x00A);
MDB.drAtrb = eabr.ReadUInt16(); MDB.drAtrb = BigEndianBitConverter.ToUInt16(mdb_sector, 0x012);
MDB.drNmFls = eabr.ReadUInt16(); MDB.drNmFls = BigEndianBitConverter.ToUInt16(mdb_sector, 0x014);
MDB.drDirSt = eabr.ReadUInt16(); MDB.drDirSt = BigEndianBitConverter.ToUInt16(mdb_sector, 0x016);
MDB.drBlLen = eabr.ReadUInt16(); MDB.drBlLen = BigEndianBitConverter.ToUInt16(mdb_sector, 0x018);
MDB.drNmAlBlks = eabr.ReadUInt16(); MDB.drNmAlBlks = BigEndianBitConverter.ToUInt16(mdb_sector, 0x01A);
MDB.drAlBlkSiz = eabr.ReadUInt32(); MDB.drAlBlkSiz = BigEndianBitConverter.ToUInt32(mdb_sector, 0x01C);
MDB.drClpSiz = eabr.ReadUInt32(); MDB.drClpSiz = BigEndianBitConverter.ToUInt32(mdb_sector, 0x020);
MDB.drAlBlSt = eabr.ReadUInt16(); MDB.drAlBlSt = BigEndianBitConverter.ToUInt16(mdb_sector, 0x024);
MDB.drNxtFNum = eabr.ReadUInt32(); MDB.drNxtFNum = BigEndianBitConverter.ToUInt32(mdb_sector, 0x026);
MDB.drFreeBks = eabr.ReadUInt16(); MDB.drFreeBks = BigEndianBitConverter.ToUInt16(mdb_sector, 0x02A);
MDB.drVNSiz = eabr.ReadByte(); MDB.drVNSiz = mdb_sector[0x02C];
variable_size = eabr.ReadBytes(MDB.drVNSiz); variable_size = new byte[MDB.drVNSiz];
Array.Copy(mdb_sector, 0x02D, variable_size, 0, MDB.drVNSiz);
MDB.drVN = Encoding.ASCII.GetString(variable_size); MDB.drVN = Encoding.ASCII.GetString(variable_size);
eabr.BaseStream.Seek(0 + offset, SeekOrigin.Begin); BB.signature = BigEndianBitConverter.ToUInt16(bb_sector, 0x000);
BB.signature = eabr.ReadUInt16();
if (BB.signature == MFSBB_MAGIC) if (BB.signature == MFSBB_MAGIC)
{ {
BB.branch = eabr.ReadUInt32(); BB.branch = BigEndianBitConverter.ToUInt32(bb_sector, 0x002);
BB.boot_flags = eabr.ReadByte(); BB.boot_flags = bb_sector[0x006];
BB.boot_version = eabr.ReadByte(); BB.boot_version = bb_sector[0x007];
BB.sec_sv_pages = eabr.ReadInt16(); BB.sec_sv_pages = BigEndianBitConverter.ToInt16(bb_sector, 0x008);
pString = eabr.ReadBytes(16); Array.Copy(mdb_sector, 0x00A, pString, 0, 16);
BB.system_name = StringHandlers.PascalToString(pString); BB.system_name = StringHandlers.PascalToString(pString);
pString = eabr.ReadBytes(16); Array.Copy(mdb_sector, 0x01A, pString, 0, 16);
BB.finder_name = StringHandlers.PascalToString(pString); BB.finder_name = StringHandlers.PascalToString(pString);
pString = eabr.ReadBytes(16); Array.Copy(mdb_sector, 0x02A, pString, 0, 16);
BB.debug_name = StringHandlers.PascalToString(pString); BB.debug_name = StringHandlers.PascalToString(pString);
pString = eabr.ReadBytes(16); Array.Copy(mdb_sector, 0x03A, pString, 0, 16);
BB.disasm_name = StringHandlers.PascalToString(pString); BB.disasm_name = StringHandlers.PascalToString(pString);
pString = eabr.ReadBytes(16); Array.Copy(mdb_sector, 0x04A, pString, 0, 16);
BB.stupscr_name = StringHandlers.PascalToString(pString); BB.stupscr_name = StringHandlers.PascalToString(pString);
pString = eabr.ReadBytes(16); Array.Copy(mdb_sector, 0x05A, pString, 0, 16);
BB.bootup_name = StringHandlers.PascalToString(pString); BB.bootup_name = StringHandlers.PascalToString(pString);
pString = eabr.ReadBytes(16); Array.Copy(mdb_sector, 0x06A, pString, 0, 16);
BB.clipbrd_name = StringHandlers.PascalToString(pString); BB.clipbrd_name = StringHandlers.PascalToString(pString);
BB.max_files = eabr.ReadUInt16(); BB.max_files = BigEndianBitConverter.ToUInt16(bb_sector, 0x07A);
BB.queue_size = eabr.ReadUInt16(); BB.queue_size = BigEndianBitConverter.ToUInt16(bb_sector, 0x07C);
BB.heap_128k = eabr.ReadUInt32(); BB.heap_128k = BigEndianBitConverter.ToUInt32(bb_sector, 0x07E);
BB.heap_256k = eabr.ReadUInt32(); BB.heap_256k = BigEndianBitConverter.ToUInt32(bb_sector, 0x082);
BB.heap_512k = eabr.ReadUInt32(); BB.heap_512k = BigEndianBitConverter.ToUInt32(bb_sector, 0x086);
} }
else else
BB.signature = 0x0000; BB.signature = 0x0000;
@@ -163,45 +158,77 @@ namespace FileSystemIDandChk.Plugins
return; return;
} }
private struct MFS_MasterDirectoryBlock // Should be offset 0x0400 bytes in volume struct MFS_MasterDirectoryBlock // Should be offset 0x0400 bytes in volume
{ {
public UInt16 drSigWord; // 0x000, Signature, 0xD2D7 public UInt16 drSigWord;
public ulong drCrDate; // 0x002, Volume creation date // 0x000, Signature, 0xD2D7
public ulong drLsBkUp; // 0x00A, Volume last backup date public ulong drCrDate;
public UInt16 drAtrb; // 0x012, Volume attributes // 0x002, Volume creation date
public UInt16 drNmFls; // 0x014, Volume number of files public ulong drLsBkUp;
public UInt16 drDirSt; // 0x016, First directory block // 0x00A, Volume last backup date
public UInt16 drBlLen; // 0x018, Length of directory in blocks public UInt16 drAtrb;
public UInt16 drNmAlBlks; // 0x01A, Volume allocation blocks // 0x012, Volume attributes
public UInt32 drAlBlkSiz; // 0x01C, Size of allocation blocks public UInt16 drNmFls;
public UInt32 drClpSiz; // 0x020, Number of bytes to allocate // 0x014, Volume number of files
public UInt16 drAlBlSt; // 0x024, First allocation block in block map public UInt16 drDirSt;
public UInt32 drNxtFNum; // 0x026. Next unused file number // 0x016, First directory block
public UInt16 drFreeBks; // 0x02A, Number of unused allocation blocks public UInt16 drBlLen;
public byte drVNSiz; // 0x02C, Length of volume name // 0x018, Length of directory in blocks
public string drVN; // 0x02D, Characters of volume name public UInt16 drNmAlBlks;
// 0x01A, Volume allocation blocks
public UInt32 drAlBlkSiz;
// 0x01C, Size of allocation blocks
public UInt32 drClpSiz;
// 0x020, Number of bytes to allocate
public UInt16 drAlBlSt;
// 0x024, First allocation block in block map
public UInt32 drNxtFNum;
// 0x026. Next unused file number
public UInt16 drFreeBks;
// 0x02A, Number of unused allocation blocks
public byte drVNSiz;
// 0x02C, Length of volume name
public string drVN;
// 0x02D, Characters of volume name
} }
private struct MFS_BootBlock // Should be offset 0x0000 bytes in volume struct MFS_BootBlock // Should be offset 0x0000 bytes in volume
{ {
public UInt16 signature; // 0x000, Signature, 0x4C4B if bootable public UInt16 signature;
public UInt32 branch; // 0x002, Branch // 0x000, Signature, 0x4C4B if bootable
public byte boot_flags; // 0x006, Boot block flags public UInt32 branch;
public byte boot_version; // 0x007, Boot block version // 0x002, Branch
public short sec_sv_pages; // 0x008, Allocate secondary buffers public byte boot_flags;
public string system_name; // 0x00A, System file name (10 bytes) // 0x006, Boot block flags
public string finder_name; // 0x014, Finder file name (10 bytes) public byte boot_version;
public string debug_name; // 0x01E, Debugger file name (10 bytes) // 0x007, Boot block version
public string disasm_name; // 0x028, Disassembler file name (10 bytes) public short sec_sv_pages;
public string stupscr_name; // 0x032, Startup screen file name (10 bytes) // 0x008, Allocate secondary buffers
public string bootup_name; // 0x03C, First program to execute on boot (10 bytes) public string system_name;
public string clipbrd_name; // 0x046, Clipboard file name (10 bytes) // 0x00A, System file name (16 bytes)
public UInt16 max_files; // 0x050, 1/4 of maximum opened at a time files public string finder_name;
public UInt16 queue_size; // 0x052, Event queue size // 0x01A, Finder file name (16 bytes)
public UInt32 heap_128k; // 0x054, Heap size on a Mac with 128KiB of RAM public string debug_name;
public UInt32 heap_256k; // 0x058, Heap size on a Mac with 256KiB of RAM // 0x02A, Debugger file name (16 bytes)
public UInt32 heap_512k; // 0x05C, Heap size on a Mac with 512KiB of RAM or more public string disasm_name;
} // Follows boot code // 0x03A, Disassembler file name (16 bytes)
public string stupscr_name;
// 0x04A, Startup screen file name (16 bytes)
public string bootup_name;
// 0x05A, First program to execute on boot (16 bytes)
public string clipbrd_name;
// 0x06A, Clipboard file name (16 bytes)
public UInt16 max_files;
// 0x07A, 1/4 of maximum opened at a time files
public UInt16 queue_size;
// 0x07C, Event queue size
public UInt32 heap_128k;
// 0x07E, Heap size on a Mac with 128KiB of RAM
public UInt32 heap_256k;
// 0x082, Heap size on a Mac with 256KiB of RAM
public UInt32 heap_512k;
// 0x086, Heap size on a Mac with 512KiB of RAM or more
}
// Follows boot code
} }
} }
*/

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -8,23 +7,21 @@ namespace FileSystemIDandChk.Plugins
class BeFS : Plugin class BeFS : Plugin
{ {
// Little endian constants (that is, as read by .NET :p) // Little endian constants (that is, as read by .NET :p)
private const UInt32 BEFS_MAGIC1 = 0x42465331; const UInt32 BEFS_MAGIC1 = 0x42465331;
private const UInt32 BEFS_MAGIC2 = 0xDD121031; const UInt32 BEFS_MAGIC2 = 0xDD121031;
private const UInt32 BEFS_MAGIC3 = 0x15B6830E; const UInt32 BEFS_MAGIC3 = 0x15B6830E;
private const UInt32 BEFS_ENDIAN = 0x42494745; const UInt32 BEFS_ENDIAN = 0x42494745;
// Big endian constants // Big endian constants
private const UInt32 BEFS_CIGAM1 = 0x31534642; const UInt32 BEFS_CIGAM1 = 0x31534642;
private const UInt32 BEFS_NAIDNE = 0x45474942; const UInt32 BEFS_NAIDNE = 0x45474942;
// Common constants // Common constants
private const UInt32 BEFS_CLEAN = 0x434C454E; const UInt32 BEFS_CLEAN = 0x434C454E;
private const UInt32 BEFS_DIRTY = 0x44495254; const UInt32 BEFS_DIRTY = 0x44495254;
public BeFS(PluginBase Core) public BeFS(PluginBase Core)
{ {
base.Name = "Be Filesystem"; Name = "Be Filesystem";
base.PluginUUID = new Guid("dc8572b3-b6ad-46e4-8de9-cbe123ff6672"); PluginUUID = new Guid("dc8572b3-b6ad-46e4-8de9-cbe123ff6672");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -39,8 +36,6 @@ namespace FileSystemIDandChk.Plugins
if (magic == BEFS_MAGIC1 || magic_be == BEFS_MAGIC1) if (magic == BEFS_MAGIC1 || magic_be == BEFS_MAGIC1)
return true; return true;
else
{
sb_sector = imagePlugin.ReadSector(1 + partitionOffset); sb_sector = imagePlugin.ReadSector(1 + partitionOffset);
magic = BitConverter.ToUInt32(sb_sector, 0x20); magic = BitConverter.ToUInt32(sb_sector, 0x20);
@@ -48,10 +43,8 @@ namespace FileSystemIDandChk.Plugins
if (magic == BEFS_MAGIC1 || magic_be == BEFS_MAGIC1) if (magic == BEFS_MAGIC1 || magic_be == BEFS_MAGIC1)
return true; return true;
else
return false; return false;
} }
}
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information) public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
{ {
@@ -69,8 +62,7 @@ namespace FileSystemIDandChk.Plugins
besb.magic1 = BigEndianBitConverter.ToUInt32(sb_sector, 0x20); besb.magic1 = BigEndianBitConverter.ToUInt32(sb_sector, 0x20);
if (besb.magic1 == BEFS_MAGIC1 || besb.magic1 == BEFS_CIGAM1) // Magic is at offset if (besb.magic1 == BEFS_MAGIC1 || besb.magic1 == BEFS_CIGAM1) // Magic is at offset
{ {
if(besb.magic1 == BEFS_CIGAM1) BigEndianBitConverter.IsLittleEndian &= besb.magic1 != BEFS_CIGAM1;
BigEndianBitConverter.IsLittleEndian = false;
} }
else else
{ {
@@ -79,8 +71,7 @@ namespace FileSystemIDandChk.Plugins
if (besb.magic1 == BEFS_MAGIC1 || besb.magic1 == BEFS_CIGAM1) // There is a boot sector if (besb.magic1 == BEFS_MAGIC1 || besb.magic1 == BEFS_CIGAM1) // There is a boot sector
{ {
if(besb.magic1 == BEFS_CIGAM1) BigEndianBitConverter.IsLittleEndian &= besb.magic1 != BEFS_CIGAM1;
BigEndianBitConverter.IsLittleEndian = false;
} }
else else
return; return;
@@ -164,33 +155,58 @@ namespace FileSystemIDandChk.Plugins
information = sb.ToString(); information = sb.ToString();
} }
private struct BeSuperBlock struct BeSuperBlock
{ {
public string name; // 0x000, Volume name, 32 bytes public string name;
public UInt32 magic1; // 0x020, "BFS1", 0x42465331 // 0x000, Volume name, 32 bytes
public UInt32 fs_byte_order; // 0x024, "BIGE", 0x42494745 public UInt32 magic1;
public UInt32 block_size; // 0x028, Bytes per block // 0x020, "BFS1", 0x42465331
public UInt32 block_shift; // 0x02C, 1 << block_shift == block_size public UInt32 fs_byte_order;
public Int64 num_blocks; // 0x030, Blocks in volume // 0x024, "BIGE", 0x42494745
public Int64 used_blocks; // 0x038, Used blocks in volume public UInt32 block_size;
public Int32 inode_size; // 0x040, Bytes per inode // 0x028, Bytes per block
public UInt32 magic2; // 0x044, 0xDD121031 public UInt32 block_shift;
public Int32 blocks_per_ag; // 0x048, Blocks per allocation group // 0x02C, 1 << block_shift == block_size
public Int32 ag_shift; // 0x04C, 1 << ag_shift == blocks_per_ag public Int64 num_blocks;
public Int32 num_ags; // 0x050, Allocation groups in volume // 0x030, Blocks in volume
public UInt32 flags; // 0x054, 0x434c454e if clean, 0x44495254 if dirty public Int64 used_blocks;
public Int32 log_blocks_ag; // 0x058, Allocation group of journal // 0x038, Used blocks in volume
public UInt16 log_blocks_start; // 0x05C, Start block of journal, inside ag public Int32 inode_size;
public UInt16 log_blocks_len; // 0x05E, Length in blocks of journal, inside ag // 0x040, Bytes per inode
public Int64 log_start; // 0x060, Start of journal public UInt32 magic2;
public Int64 log_end; // 0x068, End of journal // 0x044, 0xDD121031
public UInt32 magic3; // 0x070, 0x15B6830E public Int32 blocks_per_ag;
public Int32 root_dir_ag; // 0x074, Allocation group where root folder's i-node resides // 0x048, Blocks per allocation group
public UInt16 root_dir_start; // 0x078, Start in ag of root folder's i-node public Int32 ag_shift;
public UInt16 root_dir_len; // 0x07A, As this is part of inode_addr, this is 1 // 0x04C, 1 << ag_shift == blocks_per_ag
public Int32 indices_ag; // 0x07C, Allocation group where indices' i-node resides public Int32 num_ags;
public UInt16 indices_start; // 0x080, Start in ag of indices' i-node // 0x050, Allocation groups in volume
public UInt16 indices_len; // 0x082, As this is part of inode_addr, this is 1 public UInt32 flags;
// 0x054, 0x434c454e if clean, 0x44495254 if dirty
public Int32 log_blocks_ag;
// 0x058, Allocation group of journal
public UInt16 log_blocks_start;
// 0x05C, Start block of journal, inside ag
public UInt16 log_blocks_len;
// 0x05E, Length in blocks of journal, inside ag
public Int64 log_start;
// 0x060, Start of journal
public Int64 log_end;
// 0x068, End of journal
public UInt32 magic3;
// 0x070, 0x15B6830E
public Int32 root_dir_ag;
// 0x074, Allocation group where root folder's i-node resides
public UInt16 root_dir_start;
// 0x078, Start in ag of root folder's i-node
public UInt16 root_dir_len;
// 0x07A, As this is part of inode_addr, this is 1
public Int32 indices_ag;
// 0x07C, Allocation group where indices' i-node resides
public UInt16 indices_start;
// 0x080, Start in ag of indices' i-node
public UInt16 indices_len;
// 0x082, As this is part of inode_addr, this is 1
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -11,8 +10,8 @@ namespace FileSystemIDandChk.Plugins
{ {
public FAT(PluginBase Core) public FAT(PluginBase Core)
{ {
base.Name = "Microsoft File Allocation Table"; Name = "Microsoft File Allocation Table";
base.PluginUUID = new Guid("33513B2C-0D26-0D2D-32C3-79D8611158E0"); PluginUUID = new Guid("33513B2C-0D26-0D2D-32C3-79D8611158E0");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -130,7 +129,7 @@ namespace FileSystemIDandChk.Plugins
dosString = new byte[8]; dosString = new byte[8];
Array.Copy(bpb_sector, 0x03, dosString, 0, 8); Array.Copy(bpb_sector, 0x03, dosString, 0, 8);
BPB.OEMName = Encoding.ASCII.GetString(dosString); BPB.OEMName = Encoding.ASCII.GetString(dosString);
BPB.bps = BitConverter.ToUInt16(bpb_sector, 0x0B);; BPB.bps = BitConverter.ToUInt16(bpb_sector, 0x0B);
BPB.spc = bpb_sector[0x0D]; BPB.spc = bpb_sector[0x0D];
BPB.rsectors = BitConverter.ToUInt16(bpb_sector, 0x0E); BPB.rsectors = BitConverter.ToUInt16(bpb_sector, 0x0E);
BPB.fats_no = bpb_sector[0x10]; BPB.fats_no = bpb_sector[0x10];
@@ -236,64 +235,106 @@ namespace FileSystemIDandChk.Plugins
public struct BIOSParameterBlock public struct BIOSParameterBlock
{ {
public string OEMName; // 0x03, OEM Name, 8 bytes, space-padded public string OEMName;
public UInt16 bps; // 0x0B, Bytes per sector // 0x03, OEM Name, 8 bytes, space-padded
public byte spc; // 0x0D, Sectors per cluster public UInt16 bps;
public UInt16 rsectors; // 0x0E, Reserved sectors between BPB and FAT // 0x0B, Bytes per sector
public byte fats_no; // 0x10, Number of FATs public byte spc;
public UInt16 root_ent; // 0x11, Number of entries on root directory // 0x0D, Sectors per cluster
public UInt16 sectors; // 0x13, Sectors in volume public UInt16 rsectors;
public byte media; // 0x15, Media descriptor // 0x0E, Reserved sectors between BPB and FAT
public UInt16 spfat; // 0x16, Sectors per FAT public byte fats_no;
public UInt16 sptrk; // 0x18, Sectors per track // 0x10, Number of FATs
public UInt16 heads; // 0x1A, Heads public UInt16 root_ent;
public UInt32 hsectors; // 0x1C, Hidden sectors before BPB // 0x11, Number of entries on root directory
public UInt32 big_sectors; // 0x20, Sectors in volume if > 65535 public UInt16 sectors;
// 0x13, Sectors in volume
public byte media;
// 0x15, Media descriptor
public UInt16 spfat;
// 0x16, Sectors per FAT
public UInt16 sptrk;
// 0x18, Sectors per track
public UInt16 heads;
// 0x1A, Heads
public UInt32 hsectors;
// 0x1C, Hidden sectors before BPB
public UInt32 big_sectors;
// 0x20, Sectors in volume if > 65535
} }
// This only applies for bootable disks // This only applies for bootable disks
// From http://info-coach.fr/atari/software/FD-Soft.php // From http://info-coach.fr/atari/software/FD-Soft.php
public struct AtariBootBlock public struct AtariBootBlock
{ {
public UInt16 hsectors; // 0x01C, Atari ST use 16 bit for hidden sectors, probably so did old DOS public UInt16 hsectors;
public UInt16 xflag; // 0x01E, indicates if COMMAND.PRG must be executed after OS load // 0x01C, Atari ST use 16 bit for hidden sectors, probably so did old DOS
public UInt16 ldmode; // 0x020, load mode for, or 0 if fname indicates boot file public UInt16 xflag;
public UInt16 bsect; // 0x022, sector from which to boot // 0x01E, indicates if COMMAND.PRG must be executed after OS load
public UInt16 bsects_no; // 0x024, how many sectors to boot public UInt16 ldmode;
public UInt32 ldaddr; // 0x026, RAM address where boot should be located // 0x020, load mode for, or 0 if fname indicates boot file
public UInt32 fatbuf; // 0x02A, RAM address to copy the FAT and root directory public UInt16 bsect;
public string fname; // 0x02E, 11 bytes, name of boot file // 0x022, sector from which to boot
public UInt16 reserved; // 0x039, unused public UInt16 bsects_no;
public byte[] boot_code; // 0x03B, 451 bytes boot code // 0x024, how many sectors to boot
public UInt16 checksum; // 0x1FE, the sum of all the BPB+ABB must be 0x1234, so this bigendian value works as adjustment public UInt32 ldaddr;
// 0x026, RAM address where boot should be located
public UInt32 fatbuf;
// 0x02A, RAM address to copy the FAT and root directory
public string fname;
// 0x02E, 11 bytes, name of boot file
public UInt16 reserved;
// 0x039, unused
public byte[] boot_code;
// 0x03B, 451 bytes boot code
public UInt16 checksum;
// 0x1FE, the sum of all the BPB+ABB must be 0x1234, so this bigendian value works as adjustment
} }
public struct ExtendedParameterBlock public struct ExtendedParameterBlock
{ {
public byte drive_no; // 0x24, Drive number public byte drive_no;
public byte nt_flags; // 0x25, Volume flags if NT (must be 0x29 signature) // 0x24, Drive number
public byte signature; // 0x26, EPB signature, 0x28 or 0x29 public byte nt_flags;
public UInt32 serial_no; // 0x27, Volume serial number // 0x25, Volume flags if NT (must be 0x29 signature)
public byte signature;
// 0x26, EPB signature, 0x28 or 0x29
public UInt32 serial_no;
// 0x27, Volume serial number
/* Present only if signature == 0x29 */ /* Present only if signature == 0x29 */
public string volume_label; // 0x2B, Volume label, 11 bytes, space-padded public string volume_label;
public string fs_type; // 0x36, Filesystem type, 8 bytes, space-padded // 0x2B, Volume label, 11 bytes, space-padded
public string fs_type;
// 0x36, Filesystem type, 8 bytes, space-padded
} }
public struct FAT32ParameterBlock public struct FAT32ParameterBlock
{ {
public UInt32 spfat; // 0x24, Sectors per FAT public UInt32 spfat;
public UInt16 fat_flags; // 0x28, FAT flags // 0x24, Sectors per FAT
public UInt16 version; // 0x2A, FAT32 version public UInt16 fat_flags;
public UInt32 root_cluster; // 0x2C, Cluster of root directory // 0x28, FAT flags
public UInt16 fsinfo_sector; // 0x30, Sector of FSINFO structure public UInt16 version;
public UInt16 backup_sector; // 0x32, Sector of FAT32PB bacup // 0x2A, FAT32 version
byte[] reserved; // 0x34, 12 reserved bytes public UInt32 root_cluster;
public byte drive_no; // 0x40, Drive number // 0x2C, Cluster of root directory
public byte nt_flags; // 0x41, Volume flags public UInt16 fsinfo_sector;
public byte signature; // 0x42, FAT32PB signature, should be 0x29 // 0x30, Sector of FSINFO structure
public UInt32 serial_no; // 0x43, Volume serial number public UInt16 backup_sector;
public string volume_label; // 0x47, Volume label, 11 bytes, space-padded // 0x32, Sector of FAT32PB bacup
public string fs_type; // 0x52, Filesystem type, 8 bytes, space-padded, must be "FAT32 " byte[] reserved;
// 0x34, 12 reserved bytes
public byte drive_no;
// 0x40, Drive number
public byte nt_flags;
// 0x41, Volume flags
public byte signature;
// 0x42, FAT32PB signature, should be 0x29
public UInt32 serial_no;
// 0x43, Volume serial number
public string volume_label;
// 0x47, Volume label, 11 bytes, space-padded
public string fs_type;
// 0x52, Filesystem type, 8 bytes, space-padded, must be "FAT32 "
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -10,8 +9,8 @@ namespace FileSystemIDandChk.Plugins
{ {
public FFSPlugin(PluginBase Core) public FFSPlugin(PluginBase Core)
{ {
base.Name = "BSD Fast File System (aka UNIX File System, UFS)"; Name = "BSD Fast File System (aka UNIX File System, UFS)";
base.PluginUUID = new Guid("CC90D342-05DB-48A8-988C-C1FE000034A3"); PluginUUID = new Guid("CC90D342-05DB-48A8-988C-C1FE000034A3");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -154,14 +153,9 @@ namespace FileSystemIDandChk.Plugins
sbInformation.AppendLine("Incompletely initialized UFS filesystem"); sbInformation.AppendLine("Incompletely initialized UFS filesystem");
sbInformation.AppendLine("BEWARE!!! Following information may be completely wrong!"); sbInformation.AppendLine("BEWARE!!! Following information may be completely wrong!");
break; break;
default:
break;
} }
if (magic == UFS_CIGAM) BigEndianBitConverter.IsLittleEndian = magic != UFS_CIGAM; // Little-endian UFS
BigEndianBitConverter.IsLittleEndian = false; // Big-endian UFS
else
BigEndianBitConverter.IsLittleEndian = true; // Little-endian UFS
// Are there any other cases to detect big-endian UFS? // Are there any other cases to detect big-endian UFS?
// Fun with seeking follows on superblock reading! // Fun with seeking follows on superblock reading!
@@ -486,7 +480,7 @@ namespace FileSystemIDandChk.Plugins
} }
else else
{ {
UInt32 SunOSEpoch = 0x1A54C580; // We are supposing there cannot be a Sun's fs created before 1/1/1982 00:00:00 const UInt32 SunOSEpoch = 0x1A54C580; // We are supposing there cannot be a Sun's fs created before 1/1/1982 00:00:00
fs_type_43bsd = true; // There is no way of knowing this is the version, but there is of knowing it is not. fs_type_43bsd = true; // There is no way of knowing this is the version, but there is of knowing it is not.
@@ -522,12 +516,10 @@ namespace FileSystemIDandChk.Plugins
} }
// 4.3BSD code does not use these fields, they are always set up to 0 // 4.3BSD code does not use these fields, they are always set up to 0
if(ufs_sb.fs_trkseek_43bsd != 0 || ufs_sb.fs_headswitch_43bsd != 0) fs_type_43bsd &= ufs_sb.fs_trkseek_43bsd == 0 && ufs_sb.fs_headswitch_43bsd == 0;
fs_type_43bsd = false;
// This is the only 4.4BSD inode format // This is the only 4.4BSD inode format
if(ufs_sb.fs_inodefmt_44bsd == 2) fs_type_44bsd |= ufs_sb.fs_inodefmt_44bsd == 2;
fs_type_44bsd = true;
} }
if (fs_type_42bsd) if (fs_type_42bsd)
@@ -661,21 +653,27 @@ namespace FileSystemIDandChk.Plugins
information = sbInformation.ToString(); information = sbInformation.ToString();
} }
private const uint block_size = 8192; const uint block_size = 8192;
// As specified in FreeBSD source code, FFS/UFS can start in any of four places // As specified in FreeBSD source code, FFS/UFS can start in any of four places
private const ulong sb_start_floppy = 0; // For floppies, start at offset 0 const ulong sb_start_floppy = 0;
private const ulong sb_start_ufs1 = 1; // For normal devices, start at offset 8192 // For floppies, start at offset 0
private const ulong sb_start_ufs2 = 8; // For UFS2, start at offset 65536 const ulong sb_start_ufs1 = 1;
private const ulong sb_start_piggy = 32; // For piggy devices (?), start at offset 262144 // For normal devices, start at offset 8192
const ulong sb_start_ufs2 = 8;
// For UFS2, start at offset 65536
const ulong sb_start_piggy = 32;
// For piggy devices (?), start at offset 262144
// MAGICs // MAGICs
private const UInt32 UFS_MAGIC = 0x00011954; // UFS magic const UInt32 UFS_MAGIC = 0x00011954;
private const UInt32 UFS_MAGIC_BW = 0x0f242697; // BorderWare UFS // UFS magic
private const UInt32 UFS2_MAGIC = 0x19540119; // UFS2 magic const UInt32 UFS_MAGIC_BW = 0x0f242697;
private const UInt32 UFS_CIGAM = 0x54190100; // byteswapped // BorderWare UFS
private const UInt32 UFS_BAD_MAGIC = 0x19960408; // Incomplete newfs const UInt32 UFS2_MAGIC = 0x19540119;
// UFS2 magic
const UInt32 UFS_CIGAM = 0x54190100;
// byteswapped
const UInt32 UFS_BAD_MAGIC = 0x19960408;
// Incomplete newfs
// On-disk superblock is quite a mixture of all the UFS/FFS variants // On-disk superblock is quite a mixture of all the UFS/FFS variants
// There is no clear way to detect which one is correct // There is no clear way to detect which one is correct
// And as C# does not support unions this struct will clearly appear quite dirty :p // And as C# does not support unions this struct will clearly appear quite dirty :p
@@ -684,179 +682,351 @@ namespace FileSystemIDandChk.Plugins
public struct UFSSuperBlock public struct UFSSuperBlock
{ {
#region 42BSD #region 42BSD
public UInt32 fs_link_42bsd; // 0x0000 linked list of file systems
public UInt32 fs_link_42bsd;
// 0x0000 linked list of file systems
#endregion #endregion
#region Sun #region Sun
public UInt32 fs_state_sun; // 0x0000 file system state flag
public UInt32 fs_state_sun;
// 0x0000 file system state flag
#endregion #endregion
#region COMMON #region COMMON
public UInt32 fs_rlink; // 0x0004 used for incore super blocks
public UInt32 fs_sblkno; // 0x0008 addr of super-block in filesys public UInt32 fs_rlink;
public UInt32 fs_cblkno; // 0x000C offset of cyl-block in filesys // 0x0004 used for incore super blocks
public UInt32 fs_iblkno; // 0x0010 offset of inode-blocks in filesys public UInt32 fs_sblkno;
public UInt32 fs_dblkno; // 0x0014 offset of first data after cg // 0x0008 addr of super-block in filesys
public UInt32 fs_cgoffset; // 0x0018 cylinder group offset in cylinder public UInt32 fs_cblkno;
public UInt32 fs_cgmask; // 0x001C used to calc mod fs_ntrak // 0x000C offset of cyl-block in filesys
public UInt32 fs_time_t; // 0x0020 last time written -- time_t public UInt32 fs_iblkno;
public UInt32 fs_size; // 0x0024 number of blocks in fs // 0x0010 offset of inode-blocks in filesys
public UInt32 fs_dsize; // 0x0028 number of data blocks in fs public UInt32 fs_dblkno;
public UInt32 fs_ncg; // 0x002C number of cylinder groups // 0x0014 offset of first data after cg
public UInt32 fs_bsize; // 0x0030 size of basic blocks in fs public UInt32 fs_cgoffset;
public UInt32 fs_fsize; // 0x0034 size of frag blocks in fs // 0x0018 cylinder group offset in cylinder
public UInt32 fs_frag; // 0x0038 number of frags in a block in fs public UInt32 fs_cgmask;
// 0x001C used to calc mod fs_ntrak
public UInt32 fs_time_t;
// 0x0020 last time written -- time_t
public UInt32 fs_size;
// 0x0024 number of blocks in fs
public UInt32 fs_dsize;
// 0x0028 number of data blocks in fs
public UInt32 fs_ncg;
// 0x002C number of cylinder groups
public UInt32 fs_bsize;
// 0x0030 size of basic blocks in fs
public UInt32 fs_fsize;
// 0x0034 size of frag blocks in fs
public UInt32 fs_frag;
// 0x0038 number of frags in a block in fs
// these are configuration parameters // these are configuration parameters
public UInt32 fs_minfree; // 0x003C minimum percentage of free blocks public UInt32 fs_minfree;
public UInt32 fs_rotdelay; // 0x0040 num of ms for optimal next block // 0x003C minimum percentage of free blocks
public UInt32 fs_rps; // 0x0044 disk revolutions per second public UInt32 fs_rotdelay;
// 0x0040 num of ms for optimal next block
public UInt32 fs_rps;
// 0x0044 disk revolutions per second
// these fields can be computed from the others // these fields can be computed from the others
public UInt32 fs_bmask; // 0x0048 ``blkoff'' calc of blk offsets public UInt32 fs_bmask;
public UInt32 fs_fmask; // 0x004C ``fragoff'' calc of frag offsets // 0x0048 ``blkoff'' calc of blk offsets
public UInt32 fs_bshift; // 0x0050 ``lblkno'' calc of logical blkno public UInt32 fs_fmask;
public UInt32 fs_fshift; // 0x0054 ``numfrags'' calc number of frags // 0x004C ``fragoff'' calc of frag offsets
public UInt32 fs_bshift;
// 0x0050 ``lblkno'' calc of logical blkno
public UInt32 fs_fshift;
// 0x0054 ``numfrags'' calc number of frags
// these are configuration parameters // these are configuration parameters
public UInt32 fs_maxcontig; // 0x0058 max number of contiguous blks public UInt32 fs_maxcontig;
public UInt32 fs_maxbpg; // 0x005C max number of blks per cyl group // 0x0058 max number of contiguous blks
public UInt32 fs_maxbpg;
// 0x005C max number of blks per cyl group
// these fields can be computed from the others // these fields can be computed from the others
public UInt32 fs_fragshift; // 0x0060 block to frag shift public UInt32 fs_fragshift;
public UInt32 fs_fsbtodb; // 0x0064 fsbtodb and dbtofsb shift constant // 0x0060 block to frag shift
public UInt32 fs_sbsize; // 0x0068 actual size of super block public UInt32 fs_fsbtodb;
public UInt32 fs_csmask; // 0x006C csum block offset // 0x0064 fsbtodb and dbtofsb shift constant
public UInt32 fs_csshift; // 0x0070 csum block number public UInt32 fs_sbsize;
public UInt32 fs_nindir; // 0x0074 value of NINDIR // 0x0068 actual size of super block
public UInt32 fs_inopb; // 0x0078 value of INOPB public UInt32 fs_csmask;
public UInt32 fs_nspf; // 0x007C value of NSPF // 0x006C csum block offset
public UInt32 fs_csshift;
// 0x0070 csum block number
public UInt32 fs_nindir;
// 0x0074 value of NINDIR
public UInt32 fs_inopb;
// 0x0078 value of INOPB
public UInt32 fs_nspf;
// 0x007C value of NSPF
// yet another configuration parameter // yet another configuration parameter
public UInt32 fs_optim; // 0x0080 optimization preference, see below public UInt32 fs_optim;
// 0x0080 optimization preference, see below
#endregion COMMON #endregion COMMON
// these fields are derived from the hardware // these fields are derived from the hardware
#region Sun #region Sun
public UInt32 fs_npsect_sun; // 0x0084 # sectors/track including spares
public UInt32 fs_npsect_sun;
// 0x0084 # sectors/track including spares
#endregion Sun #endregion Sun
#region Sunx86 #region Sunx86
public UInt32 fs_state_t_sun86; // 0x0084 file system state time stamp
public UInt32 fs_state_t_sun86;
// 0x0084 file system state time stamp
#endregion Sunx86 #endregion Sunx86
#region COMMON #region COMMON
public UInt32 fs_interleave; // 0x0088 hardware sector interleave
public UInt32 fs_trackskew; // 0x008C sector 0 skew, per track public UInt32 fs_interleave;
// 0x0088 hardware sector interleave
public UInt32 fs_trackskew;
// 0x008C sector 0 skew, per track
#endregion COMMON #endregion COMMON
// a unique id for this filesystem (currently unused and unmaintained) // a unique id for this filesystem (currently unused and unmaintained)
// In 4.3 Tahoe this space is used by fs_headswitch and fs_trkseek // In 4.3 Tahoe this space is used by fs_headswitch and fs_trkseek
// Neither of those fields is used in the Tahoe code right now but // Neither of those fields is used in the Tahoe code right now but
// there could be problems if they are. // there could be problems if they are.
#region COMMON #region COMMON
public UInt32 fs_id_1; // 0x0090
public UInt32 fs_id_2; // 0x0094 public UInt32 fs_id_1;
// 0x0090
public UInt32 fs_id_2;
// 0x0094
#endregion COMMON #endregion COMMON
#region 43BSD #region 43BSD
public UInt32 fs_headswitch_43bsd; // 0x0090 head switch time, usec
public UInt32 fs_trkseek_43bsd; // 0x0094 track-to-track seek, usec public UInt32 fs_headswitch_43bsd;
// 0x0090 head switch time, usec
public UInt32 fs_trkseek_43bsd;
// 0x0094 track-to-track seek, usec
#endregion 43BSD #endregion 43BSD
#region COMMON #region COMMON
// sizes determined by number of cylinder groups and their sizes // sizes determined by number of cylinder groups and their sizes
public UInt32 fs_csaddr; // 0x0098 blk addr of cyl grp summary area public UInt32 fs_csaddr;
public UInt32 fs_cssize; // 0x009C size of cyl grp summary area // 0x0098 blk addr of cyl grp summary area
public UInt32 fs_cgsize; // 0x00A0 cylinder group size public UInt32 fs_cssize;
// 0x009C size of cyl grp summary area
public UInt32 fs_cgsize;
// 0x00A0 cylinder group size
// these fields are derived from the hardware // these fields are derived from the hardware
public UInt32 fs_ntrak; // 0x00A4 tracks per cylinder public UInt32 fs_ntrak;
public UInt32 fs_nsect; // 0x00A8 sectors per track // 0x00A4 tracks per cylinder
public UInt32 fs_spc; // 0x00AC sectors per cylinder public UInt32 fs_nsect;
// 0x00A8 sectors per track
public UInt32 fs_spc;
// 0x00AC sectors per cylinder
// this comes from the disk driver partitioning // this comes from the disk driver partitioning
public UInt32 fs_ncyl; // 0x00B0 cylinders in file system public UInt32 fs_ncyl;
// 0x00B0 cylinders in file system
// these fields can be computed from the others // these fields can be computed from the others
public UInt32 fs_cpg; // 0x00B4 cylinders per group public UInt32 fs_cpg;
public UInt32 fs_ipg; // 0x00B8 inodes per cylinder group // 0x00B4 cylinders per group
public UInt32 fs_fpg; // 0x00BC blocks per group * fs_frag public UInt32 fs_ipg;
// 0x00B8 inodes per cylinder group
public UInt32 fs_fpg;
// 0x00BC blocks per group * fs_frag
// this data must be re-computed after crashes // this data must be re-computed after crashes
// struct ufs_csum fs_cstotal; // cylinder summary information // struct ufs_csum fs_cstotal; // cylinder summary information
public UInt32 fs_cstotal_ndir; // 0x00C0 number of directories public UInt32 fs_cstotal_ndir;
public UInt32 fs_cstotal_nbfree; // 0x00C4 number of free blocks // 0x00C0 number of directories
public UInt32 fs_cstotal_nifree; // 0x00C8 number of free inodes public UInt32 fs_cstotal_nbfree;
public UInt32 fs_cstotal_nffree; // 0x00CC number of free frags // 0x00C4 number of free blocks
public UInt32 fs_cstotal_nifree;
// 0x00C8 number of free inodes
public UInt32 fs_cstotal_nffree;
// 0x00CC number of free frags
// these fields are cleared at mount time // these fields are cleared at mount time
public byte fs_fmod; // 0x00D0 super block modified flag public byte fs_fmod;
public byte fs_clean; // 0x00D1 file system is clean flag // 0x00D0 super block modified flag
public byte fs_ronly; // 0x00D2 mounted read-only flag public byte fs_clean;
public byte fs_flags; // 0x00D3 // 0x00D1 file system is clean flag
public byte fs_ronly;
// 0x00D2 mounted read-only flag
public byte fs_flags;
// 0x00D3
#endregion common #endregion common
#region UFS1 #region UFS1
public string fs_fsmnt_ufs1; // 0x00D4, 512 bytes, name mounted on
public UInt32 fs_cgrotor_ufs1; // 0x02D4 last cg searched public string fs_fsmnt_ufs1;
public byte[] fs_cs_ufs1; // 0x02D8, 124 bytes, UInt32s, list of fs_cs info buffers // 0x00D4, 512 bytes, name mounted on
public UInt32 fs_maxcluster_ufs1; // 0x0354 public UInt32 fs_cgrotor_ufs1;
public UInt32 fs_cpc_ufs1; // 0x0358 cyl per cycle in postbl // 0x02D4 last cg searched
public byte[] fs_opostbl_ufs1; // 0x035C, 256 bytes, [16][8] matrix of UInt16s, old rotation block list head public byte[] fs_cs_ufs1;
// 0x02D8, 124 bytes, UInt32s, list of fs_cs info buffers
public UInt32 fs_maxcluster_ufs1;
// 0x0354
public UInt32 fs_cpc_ufs1;
// 0x0358 cyl per cycle in postbl
public byte[] fs_opostbl_ufs1;
// 0x035C, 256 bytes, [16][8] matrix of UInt16s, old rotation block list head
#endregion UFS1 #endregion UFS1
#region UFS2 #region UFS2
public string fs_fsmnt_ufs2; // 0x00D4, 468 bytes, name mounted on
public string fs_volname_ufs2; // 0x02A8, 32 bytes, volume name public string fs_fsmnt_ufs2;
public UInt64 fs_swuid_ufs2; // 0x02C8 system-wide uid // 0x00D4, 468 bytes, name mounted on
public UInt32 fs_pad_ufs2; // 0x02D0 due to alignment of fs_swuid public string fs_volname_ufs2;
public UInt32 fs_cgrotor_ufs2; // 0x02D4 last cg searched // 0x02A8, 32 bytes, volume name
public byte[] fs_ocsp_ufs2; // 0x02D8, 112 bytes, UInt32s, list of fs_cs info buffers public UInt64 fs_swuid_ufs2;
public UInt32 fs_contigdirs_ufs2; // 0x0348 # of contiguously allocated dirs // 0x02C8 system-wide uid
public UInt32 fs_csp_ufs2; // 0x034C cg summary info buffer for fs_cs public UInt32 fs_pad_ufs2;
public UInt32 fs_maxcluster_ufs2; // 0x0350 // 0x02D0 due to alignment of fs_swuid
public UInt32 fs_active_ufs2; // 0x0354 used by snapshots to track fs public UInt32 fs_cgrotor_ufs2;
public UInt32 fs_old_cpc_ufs2; // 0x0358 cyl per cycle in postbl // 0x02D4 last cg searched
public UInt32 fs_maxbsize_ufs2; // 0x035C maximum blocking factor permitted public byte[] fs_ocsp_ufs2;
public byte[] fs_sparecon64_ufs2; // 0x0360, 136 bytes, UInt64s, old rotation block list head // 0x02D8, 112 bytes, UInt32s, list of fs_cs info buffers
public UInt64 fs_sblockloc_ufs2; // 0x03E8 byte offset of standard superblock public UInt32 fs_contigdirs_ufs2;
// 0x0348 # of contiguously allocated dirs
public UInt32 fs_csp_ufs2;
// 0x034C cg summary info buffer for fs_cs
public UInt32 fs_maxcluster_ufs2;
// 0x0350
public UInt32 fs_active_ufs2;
// 0x0354 used by snapshots to track fs
public UInt32 fs_old_cpc_ufs2;
// 0x0358 cyl per cycle in postbl
public UInt32 fs_maxbsize_ufs2;
// 0x035C maximum blocking factor permitted
public byte[] fs_sparecon64_ufs2;
// 0x0360, 136 bytes, UInt64s, old rotation block list head
public UInt64 fs_sblockloc_ufs2;
// 0x03E8 byte offset of standard superblock
//cylinder summary information*/ //cylinder summary information*/
public UInt64 fs_cstotal_ndir_ufs2; // 0x03F0 number of directories public UInt64 fs_cstotal_ndir_ufs2;
public UInt64 fs_cstotal_nbfree_ufs2; // 0x03F8 number of free blocks // 0x03F0 number of directories
public UInt64 fs_cstotal_nifree_ufs2; // 0x0400 number of free inodes public UInt64 fs_cstotal_nbfree_ufs2;
public UInt64 fs_cstotal_nffree_ufs2; // 0x0408 number of free frags // 0x03F8 number of free blocks
public UInt64 fs_cstotal_numclusters_ufs2; // 0x0410 number of free clusters public UInt64 fs_cstotal_nifree_ufs2;
public UInt64 fs_cstotal_spare0_ufs2; // 0x0418 future expansion // 0x0400 number of free inodes
public UInt64 fs_cstotal_spare1_ufs2; // 0x0420 future expansion public UInt64 fs_cstotal_nffree_ufs2;
public UInt64 fs_cstotal_spare2_ufs2; // 0x0428 future expansion // 0x0408 number of free frags
public UInt32 fs_time_sec_ufs2; // 0x0430 last time written public UInt64 fs_cstotal_numclusters_ufs2;
public UInt32 fs_time_usec_ufs2; // 0x0434 last time written // 0x0410 number of free clusters
public UInt64 fs_size_ufs2; // 0x0438 number of blocks in fs public UInt64 fs_cstotal_spare0_ufs2;
public UInt64 fs_dsize_ufs2; // 0x0440 number of data blocks in fs // 0x0418 future expansion
public UInt64 fs_csaddr_ufs2; // 0x0448 blk addr of cyl grp summary area public UInt64 fs_cstotal_spare1_ufs2;
public UInt64 fs_pendingblocks_ufs2; // 0x0450 blocks in process of being freed // 0x0420 future expansion
public UInt32 fs_pendinginodes_ufs2; // 0x0458 inodes in process of being freed public UInt64 fs_cstotal_spare2_ufs2;
// 0x0428 future expansion
public UInt32 fs_time_sec_ufs2;
// 0x0430 last time written
public UInt32 fs_time_usec_ufs2;
// 0x0434 last time written
public UInt64 fs_size_ufs2;
// 0x0438 number of blocks in fs
public UInt64 fs_dsize_ufs2;
// 0x0440 number of data blocks in fs
public UInt64 fs_csaddr_ufs2;
// 0x0448 blk addr of cyl grp summary area
public UInt64 fs_pendingblocks_ufs2;
// 0x0450 blocks in process of being freed
public UInt32 fs_pendinginodes_ufs2;
// 0x0458 inodes in process of being freed
#endregion UFS2 #endregion UFS2
#region Sun #region Sun
public byte[] fs_sparecon_sun; // 0x045C, 212 bytes, reserved for future constants
public UInt32 fs_reclaim_sun; // 0x0530 public byte[] fs_sparecon_sun;
public UInt32 fs_sparecon2_sun; // 0x0534 // 0x045C, 212 bytes, reserved for future constants
public UInt32 fs_state_t_sun; // 0x0538 file system state time stamp public UInt32 fs_reclaim_sun;
public UInt32 fs_qbmask0_sun; // 0x053C ~usb_bmask // 0x0530
public UInt32 fs_qbmask1_sun; // 0x0540 ~usb_bmask public UInt32 fs_sparecon2_sun;
public UInt32 fs_qfmask0_sun; // 0x0544 ~usb_fmask // 0x0534
public UInt32 fs_qfmask1_sun; // 0x0548 ~usb_fmask public UInt32 fs_state_t_sun;
// 0x0538 file system state time stamp
public UInt32 fs_qbmask0_sun;
// 0x053C ~usb_bmask
public UInt32 fs_qbmask1_sun;
// 0x0540 ~usb_bmask
public UInt32 fs_qfmask0_sun;
// 0x0544 ~usb_fmask
public UInt32 fs_qfmask1_sun;
// 0x0548 ~usb_fmask
#endregion Sun #endregion Sun
#region Sunx86 #region Sunx86
public byte[] fs_sparecon_sun86; // 0x045C, 212 bytes, reserved for future constants
public UInt32 fs_reclaim_sun86; // 0x0530 public byte[] fs_sparecon_sun86;
public UInt32 fs_sparecon2_sun86; // 0x0534 // 0x045C, 212 bytes, reserved for future constants
public UInt32 fs_npsect_sun86; // 0x0538 # sectors/track including spares public UInt32 fs_reclaim_sun86;
public UInt32 fs_qbmask0_sun86; // 0x053C ~usb_bmask // 0x0530
public UInt32 fs_qbmask1_sun86; // 0x0540 ~usb_bmask public UInt32 fs_sparecon2_sun86;
public UInt32 fs_qfmask0_sun86; // 0x0544 ~usb_fmask // 0x0534
public UInt32 fs_qfmask1_sun86; // 0x0548 ~usb_fmask public UInt32 fs_npsect_sun86;
// 0x0538 # sectors/track including spares
public UInt32 fs_qbmask0_sun86;
// 0x053C ~usb_bmask
public UInt32 fs_qbmask1_sun86;
// 0x0540 ~usb_bmask
public UInt32 fs_qfmask0_sun86;
// 0x0544 ~usb_fmask
public UInt32 fs_qfmask1_sun86;
// 0x0548 ~usb_fmask
#endregion Sunx86 #endregion Sunx86
#region 44BSD #region 44BSD
public byte[] fs_sparecon_44bsd; // 0x045C, 200 bytes
public UInt32 fs_contigsumsize_44bsd; // 0x0524 size of cluster summary array public byte[] fs_sparecon_44bsd;
public UInt32 fs_maxsymlinklen_44bsd; // 0x0528 max length of an internal symlink // 0x045C, 200 bytes
public UInt32 fs_inodefmt_44bsd; // 0x052C format of on-disk inodes public UInt32 fs_contigsumsize_44bsd;
public UInt32 fs_maxfilesize0_44bsd; // 0x0530 max representable file size // 0x0524 size of cluster summary array
public UInt32 fs_maxfilesize1_44bsd; // 0x0534 max representable file size public UInt32 fs_maxsymlinklen_44bsd;
public UInt32 fs_qbmask0_44bsd; // 0x0538 ~usb_bmask // 0x0528 max length of an internal symlink
public UInt32 fs_qbmask1_44bsd; // 0x053C ~usb_bmask public UInt32 fs_inodefmt_44bsd;
public UInt32 fs_qfmask0_44bsd; // 0x0540 ~usb_fmask // 0x052C format of on-disk inodes
public UInt32 fs_qfmask1_44bsd; // 0x0544 ~usb_fmask public UInt32 fs_maxfilesize0_44bsd;
public UInt32 fs_state_t_44bsd; // 0x0548 file system state time stamp // 0x0530 max representable file size
public UInt32 fs_maxfilesize1_44bsd;
// 0x0534 max representable file size
public UInt32 fs_qbmask0_44bsd;
// 0x0538 ~usb_bmask
public UInt32 fs_qbmask1_44bsd;
// 0x053C ~usb_bmask
public UInt32 fs_qfmask0_44bsd;
// 0x0540 ~usb_fmask
public UInt32 fs_qfmask1_44bsd;
// 0x0544 ~usb_fmask
public UInt32 fs_state_t_44bsd;
// 0x0548 file system state time stamp
#endregion 44BSD #endregion 44BSD
public UInt32 fs_postblformat; // 0x054C format of positional layout tables
public UInt32 fs_nrpos; // 0x0550 number of rotational positions public UInt32 fs_postblformat;
public UInt32 fs_postbloff; // 0x0554 (__s16) rotation block list head // 0x054C format of positional layout tables
public UInt32 fs_rotbloff; // 0x0558 (__u8) blocks for each rotation public UInt32 fs_nrpos;
public UInt32 fs_magic; // 0x055C magic number // 0x0550 number of rotational positions
public byte fs_space; // 0x0560 list of blocks for each rotation public UInt32 fs_postbloff;
// 0x0554 (__s16) rotation block list head
public UInt32 fs_rotbloff;
// 0x0558 (__u8) blocks for each rotation
public UInt32 fs_magic;
// 0x055C magic number
public byte fs_space;
// 0x0560 list of blocks for each rotation
// 0x0561 // 0x0561
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -9,8 +8,8 @@ namespace FileSystemIDandChk.Plugins
{ {
public HPFS(PluginBase Core) public HPFS(PluginBase Core)
{ {
base.Name = "OS/2 High Performance File System"; Name = "OS/2 High Performance File System";
base.PluginUUID = new Guid("33513B2C-f590-4acb-8bf2-0b1d5e19dec5"); PluginUUID = new Guid("33513B2C-f590-4acb-8bf2-0b1d5e19dec5");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -23,7 +22,6 @@ namespace FileSystemIDandChk.Plugins
if (magic1 == 0xF995E849 && magic2 == 0xFA53E9C5) if (magic1 == 0xF995E849 && magic2 == 0xFA53E9C5)
return true; return true;
else
return false; return false;
} }
@@ -210,74 +208,132 @@ namespace FileSystemIDandChk.Plugins
information = sb.ToString(); information = sb.ToString();
} }
private struct HPFS_BIOSParameterBlock // Sector 0 struct HPFS_BIOSParameterBlock // Sector 0
{ {
public byte jmp1; // 0x000, Jump to boot code public byte jmp1;
public UInt16 jmp2; // 0x001, ...; // 0x000, Jump to boot code
public string OEMName; // 0x003, OEM Name, 8 bytes, space-padded public UInt16 jmp2;
public UInt16 bps; // 0x00B, Bytes per sector // 0x001, ...;
public byte spc; // 0x00D, Sectors per cluster public string OEMName;
public UInt16 rsectors; // 0x00E, Reserved sectors between BPB and... does it have sense in HPFS? // 0x003, OEM Name, 8 bytes, space-padded
public byte fats_no; // 0x010, Number of FATs... seriously? public UInt16 bps;
public UInt16 root_ent; // 0x011, Number of entries on root directory... ok // 0x00B, Bytes per sector
public UInt16 sectors; // 0x013, Sectors in volume... doubt it public byte spc;
public byte media; // 0x015, Media descriptor // 0x00D, Sectors per cluster
public UInt16 spfat; // 0x016, Sectors per FAT... again public UInt16 rsectors;
public UInt16 sptrk; // 0x018, Sectors per track... you're kidding // 0x00E, Reserved sectors between BPB and... does it have sense in HPFS?
public UInt16 heads; // 0x01A, Heads... stop! public byte fats_no;
public UInt32 hsectors; // 0x01C, Hidden sectors before BPB // 0x010, Number of FATs... seriously?
public UInt32 big_sectors; // 0x024, Sectors in volume if > 65535... public UInt16 root_ent;
public byte drive_no; // 0x028, Drive number // 0x011, Number of entries on root directory... ok
public byte nt_flags; // 0x029, Volume flags? public UInt16 sectors;
public byte signature; // 0x02A, EPB signature, 0x29 // 0x013, Sectors in volume... doubt it
public UInt32 serial_no; // 0x02B, Volume serial number public byte media;
public string volume_label; // 0x02F, Volume label, 11 bytes, space-padded // 0x015, Media descriptor
public string fs_type; // 0x03A, Filesystem type, 8 bytes, space-padded ("HPFS ") public UInt16 spfat;
// 0x016, Sectors per FAT... again
public UInt16 sptrk;
// 0x018, Sectors per track... you're kidding
public UInt16 heads;
// 0x01A, Heads... stop!
public UInt32 hsectors;
// 0x01C, Hidden sectors before BPB
public UInt32 big_sectors;
// 0x024, Sectors in volume if > 65535...
public byte drive_no;
// 0x028, Drive number
public byte nt_flags;
// 0x029, Volume flags?
public byte signature;
// 0x02A, EPB signature, 0x29
public UInt32 serial_no;
// 0x02B, Volume serial number
public string volume_label;
// 0x02F, Volume label, 11 bytes, space-padded
public string fs_type;
// 0x03A, Filesystem type, 8 bytes, space-padded ("HPFS ")
} }
private struct HPFS_SuperBlock // Sector 16 struct HPFS_SuperBlock // Sector 16
{ {
public UInt32 magic1; // 0x000, 0xF995E849 public UInt32 magic1;
public UInt32 magic2; // 0x004, 0xFA53E9C5 // 0x000, 0xF995E849
public byte version; // 0x008, HPFS version public UInt32 magic2;
public byte func_version; // 0x009, 2 if <= 4 GiB, 3 if > 4 GiB // 0x004, 0xFA53E9C5
public UInt16 dummy; // 0x00A, Alignment public byte version;
public UInt32 root_fnode; // 0x00C, LSN pointer to root fnode // 0x008, HPFS version
public UInt32 sectors; // 0x010, Sectors on volume public byte func_version;
public UInt32 badblocks; // 0x014, Bad blocks on volume // 0x009, 2 if <= 4 GiB, 3 if > 4 GiB
public UInt32 bitmap_lsn; // 0x018, LSN pointer to volume bitmap public UInt16 dummy;
public UInt32 zero1; // 0x01C, 0 // 0x00A, Alignment
public UInt32 badblock_lsn; // 0x020, LSN pointer to badblock directory public UInt32 root_fnode;
public UInt32 zero2; // 0x024, 0 // 0x00C, LSN pointer to root fnode
public Int32 last_chkdsk; // 0x028, Time of last CHKDSK public UInt32 sectors;
public Int32 last_optim; // 0x02C, Time of last optimization // 0x010, Sectors on volume
public UInt32 dband_sectors; // 0x030, Sectors of dir band public UInt32 badblocks;
public UInt32 dband_start; // 0x034, Start sector of dir band // 0x014, Bad blocks on volume
public UInt32 dband_last; // 0x038, Last sector of dir band public UInt32 bitmap_lsn;
public UInt32 dband_bitmap; // 0x03C, LSN of free space bitmap // 0x018, LSN pointer to volume bitmap
public UInt64 zero3; // 0x040, Can be used for volume name (32 bytes) public UInt32 zero1;
public UInt64 zero4; // 0x048, ... // 0x01C, 0
public UInt64 zero5; // 0x04C, ... public UInt32 badblock_lsn;
public UInt64 zero6; // 0x050, ...; // 0x020, LSN pointer to badblock directory
public UInt32 acl_start; // 0x058, LSN pointer to ACLs (only HPFS386) public UInt32 zero2;
// 0x024, 0
public Int32 last_chkdsk;
// 0x028, Time of last CHKDSK
public Int32 last_optim;
// 0x02C, Time of last optimization
public UInt32 dband_sectors;
// 0x030, Sectors of dir band
public UInt32 dband_start;
// 0x034, Start sector of dir band
public UInt32 dband_last;
// 0x038, Last sector of dir band
public UInt32 dband_bitmap;
// 0x03C, LSN of free space bitmap
public UInt64 zero3;
// 0x040, Can be used for volume name (32 bytes)
public UInt64 zero4;
// 0x048, ...
public UInt64 zero5;
// 0x04C, ...
public UInt64 zero6;
// 0x050, ...;
public UInt32 acl_start;
// 0x058, LSN pointer to ACLs (only HPFS386)
} }
private struct HPFS_SpareBlock // Sector 17 struct HPFS_SpareBlock // Sector 17
{ {
public UInt32 magic1; // 0x000, 0xF9911849 public UInt32 magic1;
public UInt32 magic2; // 0x004, 0xFA5229C5 // 0x000, 0xF9911849
public byte flags1; // 0x008, HPFS flags public UInt32 magic2;
public byte flags2; // 0x009, HPFS386 flags // 0x004, 0xFA5229C5
public UInt16 dummy; // 0x00A, Alignment public byte flags1;
public UInt32 hotfix_start; // 0x00C, LSN of hotfix directory // 0x008, HPFS flags
public UInt32 hotfix_used; // 0x010, Used hotfixes public byte flags2;
public UInt32 hotfix_entries; // 0x014, Total hotfixes available // 0x009, HPFS386 flags
public UInt32 spare_dnodes_free; // 0x018, Unused spare dnodes public UInt16 dummy;
public UInt32 spare_dnodes; // 0x01C, Length of spare dnodes list // 0x00A, Alignment
public UInt32 codepage_lsn; // 0x020, LSN of codepage directory public UInt32 hotfix_start;
public UInt32 codepages; // 0x024, Number of codepages used // 0x00C, LSN of hotfix directory
public UInt32 sb_crc32; // 0x028, SuperBlock CRC32 (only HPFS386) public UInt32 hotfix_used;
public UInt32 sp_crc32; // 0x02C, SpareBlock CRC32 (only HPFS386) // 0x010, Used hotfixes
public UInt32 hotfix_entries;
// 0x014, Total hotfixes available
public UInt32 spare_dnodes_free;
// 0x018, Unused spare dnodes
public UInt32 spare_dnodes;
// 0x01C, Length of spare dnodes list
public UInt32 codepage_lsn;
// 0x020, LSN of codepage directory
public UInt32 codepages;
// 0x024, Number of codepages used
public UInt32 sb_crc32;
// 0x028, SuperBlock CRC32 (only HPFS386)
public UInt32 sp_crc32;
// 0x02C, SpareBlock CRC32 (only HPFS386)
} }
} }
} }

View File

@@ -1,7 +1,6 @@
using System; using System;
using System.IO;
using System.Text;
using System.Globalization; using System.Globalization;
using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
// This is coded following ECMA-119. // This is coded following ECMA-119.
@@ -13,16 +12,16 @@ namespace FileSystemIDandChk.Plugins
{ {
class ISO9660Plugin : Plugin class ISO9660Plugin : Plugin
{ {
private static bool alreadyLaunched; static bool alreadyLaunched;
public ISO9660Plugin(PluginBase Core) public ISO9660Plugin(PluginBase Core)
{ {
base.Name = "ISO9660 Filesystem"; Name = "ISO9660 Filesystem";
base.PluginUUID = new Guid("d812f4d3-c357-400d-90fd-3b22ef786aa8"); PluginUUID = new Guid("d812f4d3-c357-400d-90fd-3b22ef786aa8");
alreadyLaunched = false; alreadyLaunched = false;
} }
private struct DecodedVolumeDescriptor struct DecodedVolumeDescriptor
{ {
public string SystemIdentifier; public string SystemIdentifier;
public string VolumeIdentifier; public string VolumeIdentifier;
@@ -43,7 +42,6 @@ namespace FileSystemIDandChk.Plugins
{ {
if (alreadyLaunched) if (alreadyLaunched)
return false; return false;
else
alreadyLaunched = true; alreadyLaunched = true;
byte VDType; byte VDType;
@@ -68,10 +66,7 @@ namespace FileSystemIDandChk.Plugins
Array.Copy(vd_sector, 0x001, VDMagic, 0, 5); Array.Copy(vd_sector, 0x001, VDMagic, 0, 5);
if (Encoding.ASCII.GetString(VDMagic) != "CD001") // Recognized, it is an ISO9660, now check for rest of data. return Encoding.ASCII.GetString(VDMagic) == "CD001";
return false;
return true;
} }
public override void GetInformation (ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information) public override void GetInformation (ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
@@ -246,10 +241,7 @@ namespace FileSystemIDandChk.Plugins
if (Encoding.ASCII.GetString(SUSPMagic) == "SP") if (Encoding.ASCII.GetString(SUSPMagic) == "SP")
{ {
Array.Copy(root_dir, 0x29, RRMagic, 0, 2); Array.Copy(root_dir, 0x29, RRMagic, 0, 2);
if (Encoding.ASCII.GetString(RRMagic) == "RR") RockRidge |= Encoding.ASCII.GetString(RRMagic) == "RR";
{
RockRidge = true;
}
} }
#region SEGA IP.BIN Read and decoding #region SEGA IP.BIN Read and decoding
@@ -345,7 +337,7 @@ namespace FileSystemIDandChk.Plugins
Array.Copy(ipbin_sector, 0x1B0, spare_space7, 0, 64); // Inside here should be modem information, but I need to get a modem-enabled game Array.Copy(ipbin_sector, 0x1B0, spare_space7, 0, 64); // Inside here should be modem information, but I need to get a modem-enabled game
Array.Copy(ipbin_sector, 0x1F0, region_codes, 0, 16); // Region codes, space-filled Array.Copy(ipbin_sector, 0x1F0, region_codes, 0, 16); // Region codes, space-filled
// Decoding all data // Decoding all data
DateTime ipbindate = new DateTime(); DateTime ipbindate;
CultureInfo provider = CultureInfo.InvariantCulture; CultureInfo provider = CultureInfo.InvariantCulture;
ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date), "MMddyyyy", provider); ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date), "MMddyyyy", provider);
@@ -377,7 +369,7 @@ namespace FileSystemIDandChk.Plugins
IPBinInformation.AppendFormat("System program load size: {0} bytes", BitConverter.ToInt32(sp_loadsize, 0)).AppendLine(); IPBinInformation.AppendFormat("System program load size: {0} bytes", BitConverter.ToInt32(sp_loadsize, 0)).AppendLine();
IPBinInformation.AppendFormat("System program entry address: 0x{0}", BitConverter.ToInt32(sp_entry_address, 0).ToString("X")).AppendLine(); IPBinInformation.AppendFormat("System program entry address: 0x{0}", BitConverter.ToInt32(sp_entry_address, 0).ToString("X")).AppendLine();
IPBinInformation.AppendFormat("System program work RAM: {0} bytes", BitConverter.ToInt32(sp_work_ram_size, 0)).AppendLine(); IPBinInformation.AppendFormat("System program work RAM: {0} bytes", BitConverter.ToInt32(sp_work_ram_size, 0)).AppendLine();
IPBinInformation.AppendFormat("Release date: {0}", ipbindate.ToString()).AppendLine(); IPBinInformation.AppendFormat("Release date: {0}", ipbindate).AppendLine();
IPBinInformation.AppendFormat("Release date (other format): {0}", Encoding.ASCII.GetString(release_date2)).AppendLine(); IPBinInformation.AppendFormat("Release date (other format): {0}", Encoding.ASCII.GetString(release_date2)).AppendLine();
IPBinInformation.AppendFormat("Hardware ID: {0}", Encoding.ASCII.GetString(hardware_id)).AppendLine(); IPBinInformation.AppendFormat("Hardware ID: {0}", Encoding.ASCII.GetString(hardware_id)).AppendLine();
IPBinInformation.AppendFormat("Developer code: {0}", Encoding.ASCII.GetString(developer_code)).AppendLine(); IPBinInformation.AppendFormat("Developer code: {0}", Encoding.ASCII.GetString(developer_code)).AppendLine();
@@ -425,7 +417,7 @@ namespace FileSystemIDandChk.Plugins
case ' ': case ' ':
break; break;
default: default:
IPBinInformation.AppendFormat("Game supports unknown peripheral {0}.", peripheral.ToString()).AppendLine(); IPBinInformation.AppendFormat("Game supports unknown peripheral {0}.", peripheral).AppendLine();
break; break;
} }
} }
@@ -446,7 +438,7 @@ namespace FileSystemIDandChk.Plugins
case ' ': case ' ':
break; break;
default: default:
IPBinInformation.AppendFormat("Game supports unknown region {0}.", region.ToString()).AppendLine(); IPBinInformation.AppendFormat("Game supports unknown region {0}.", region).AppendLine();
break; break;
} }
} }
@@ -488,13 +480,13 @@ namespace FileSystemIDandChk.Plugins
Array.Copy(ipbin_sector, 0x050, peripherals, 0, 16); // Supported peripherals, see above Array.Copy(ipbin_sector, 0x050, peripherals, 0, 16); // Supported peripherals, see above
Array.Copy(ipbin_sector, 0x060, product_name, 0, 112); // Game name, space-filled Array.Copy(ipbin_sector, 0x060, product_name, 0, 112); // Game name, space-filled
// Decoding all data // Decoding all data
DateTime ipbindate = new DateTime(); DateTime ipbindate;
CultureInfo provider = CultureInfo.InvariantCulture; CultureInfo provider = CultureInfo.InvariantCulture;
ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date), "yyyyMMdd", provider); ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date), "yyyyMMdd", provider);
IPBinInformation.AppendFormat("Product name: {0}", Encoding.ASCII.GetString(product_name)).AppendLine(); IPBinInformation.AppendFormat("Product name: {0}", Encoding.ASCII.GetString(product_name)).AppendLine();
IPBinInformation.AppendFormat("Product number: {0}", Encoding.ASCII.GetString(product_no)).AppendLine(); IPBinInformation.AppendFormat("Product number: {0}", Encoding.ASCII.GetString(product_no)).AppendLine();
IPBinInformation.AppendFormat("Product version: {0}", Encoding.ASCII.GetString(product_version)).AppendLine(); IPBinInformation.AppendFormat("Product version: {0}", Encoding.ASCII.GetString(product_version)).AppendLine();
IPBinInformation.AppendFormat("Release date: {0}", ipbindate.ToString()).AppendLine(); IPBinInformation.AppendFormat("Release date: {0}", ipbindate).AppendLine();
IPBinInformation.AppendFormat("Disc number {0} of {1}", Encoding.ASCII.GetString(disc_no), Encoding.ASCII.GetString(disc_total_nos)).AppendLine(); IPBinInformation.AppendFormat("Disc number {0} of {1}", Encoding.ASCII.GetString(disc_no), Encoding.ASCII.GetString(disc_total_nos)).AppendLine();
IPBinInformation.AppendFormat("Peripherals:").AppendLine(); IPBinInformation.AppendFormat("Peripherals:").AppendLine();
@@ -523,7 +515,7 @@ namespace FileSystemIDandChk.Plugins
case ' ': case ' ':
break; break;
default: default:
IPBinInformation.AppendFormat("Game supports unknown peripheral {0}.", peripheral.ToString()).AppendLine(); IPBinInformation.AppendFormat("Game supports unknown peripheral {0}.", peripheral).AppendLine();
break; break;
} }
} }
@@ -547,7 +539,7 @@ namespace FileSystemIDandChk.Plugins
case ' ': case ' ':
break; break;
default: default:
IPBinInformation.AppendFormat("Game supports unknown region {0}.", region.ToString()).AppendLine(); IPBinInformation.AppendFormat("Game supports unknown region {0}.", region).AppendLine();
break; break;
} }
} }
@@ -599,7 +591,7 @@ namespace FileSystemIDandChk.Plugins
Array.Copy(ipbin_sector, 0x068, producer, 0, 16); // Game producer, space-filled Array.Copy(ipbin_sector, 0x068, producer, 0, 16); // Game producer, space-filled
Array.Copy(ipbin_sector, 0x078, product_name, 0, 128); // Game name, space-filled Array.Copy(ipbin_sector, 0x078, product_name, 0, 128); // Game name, space-filled
// Decoding all data // Decoding all data
DateTime ipbindate = new DateTime(); DateTime ipbindate;
CultureInfo provider = CultureInfo.InvariantCulture; CultureInfo provider = CultureInfo.InvariantCulture;
ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date), "yyyyMMdd", provider); ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date), "yyyyMMdd", provider);
IPBinInformation.AppendFormat("Product name: {0}", Encoding.ASCII.GetString(product_name)).AppendLine(); IPBinInformation.AppendFormat("Product name: {0}", Encoding.ASCII.GetString(product_name)).AppendLine();
@@ -607,7 +599,7 @@ namespace FileSystemIDandChk.Plugins
IPBinInformation.AppendFormat("Producer: {0}", Encoding.ASCII.GetString(producer)).AppendLine(); IPBinInformation.AppendFormat("Producer: {0}", Encoding.ASCII.GetString(producer)).AppendLine();
IPBinInformation.AppendFormat("Disc media: {0}", Encoding.ASCII.GetString(dreamcast_media)).AppendLine(); IPBinInformation.AppendFormat("Disc media: {0}", Encoding.ASCII.GetString(dreamcast_media)).AppendLine();
IPBinInformation.AppendFormat("Disc number {0} of {1}", Encoding.ASCII.GetString(disc_no), Encoding.ASCII.GetString(disc_total_nos)).AppendLine(); IPBinInformation.AppendFormat("Disc number {0} of {1}", Encoding.ASCII.GetString(disc_no), Encoding.ASCII.GetString(disc_total_nos)).AppendLine();
IPBinInformation.AppendFormat("Release date: {0}", ipbindate.ToString()).AppendLine(); IPBinInformation.AppendFormat("Release date: {0}", ipbindate).AppendLine();
switch (Encoding.ASCII.GetString(boot_filename)) switch (Encoding.ASCII.GetString(boot_filename))
{ {
case "1ST_READ.BIN": case "1ST_READ.BIN":
@@ -637,7 +629,7 @@ namespace FileSystemIDandChk.Plugins
case ' ': case ' ':
break; break;
default: default:
IPBinInformation.AppendFormat("Game supports unknown region {0}.", region.ToString()).AppendLine(); IPBinInformation.AppendFormat("Game supports unknown region {0}.", region).AppendLine();
break; break;
} }
} }
@@ -728,17 +720,17 @@ namespace FileSystemIDandChk.Plugins
ISOMetadata.AppendFormat("Publisher identifier: {0}", decodedVD.PublisherIdentifier).AppendLine(); ISOMetadata.AppendFormat("Publisher identifier: {0}", decodedVD.PublisherIdentifier).AppendLine();
ISOMetadata.AppendFormat("Data preparer identifier: {0}", decodedVD.DataPreparerIdentifier).AppendLine(); ISOMetadata.AppendFormat("Data preparer identifier: {0}", decodedVD.DataPreparerIdentifier).AppendLine();
ISOMetadata.AppendFormat("Application identifier: {0}", decodedVD.ApplicationIdentifier).AppendLine(); ISOMetadata.AppendFormat("Application identifier: {0}", decodedVD.ApplicationIdentifier).AppendLine();
ISOMetadata.AppendFormat("Volume creation date: {0}", decodedVD.CreationTime.ToString()).AppendLine(); ISOMetadata.AppendFormat("Volume creation date: {0}", decodedVD.CreationTime).AppendLine();
if (decodedVD.HasModificationTime) if (decodedVD.HasModificationTime)
ISOMetadata.AppendFormat("Volume modification date: {0}", decodedVD.ModificationTime.ToString()).AppendLine(); ISOMetadata.AppendFormat("Volume modification date: {0}", decodedVD.ModificationTime).AppendLine();
else else
ISOMetadata.AppendFormat("Volume has not been modified.").AppendLine(); ISOMetadata.AppendFormat("Volume has not been modified.").AppendLine();
if (decodedVD.HasExpirationTime) if (decodedVD.HasExpirationTime)
ISOMetadata.AppendFormat("Volume expiration date: {0}", decodedVD.ExpirationTime.ToString()).AppendLine(); ISOMetadata.AppendFormat("Volume expiration date: {0}", decodedVD.ExpirationTime).AppendLine();
else else
ISOMetadata.AppendFormat("Volume does not expire.").AppendLine(); ISOMetadata.AppendFormat("Volume does not expire.").AppendLine();
if (decodedVD.HasEffectiveTime) if (decodedVD.HasEffectiveTime)
ISOMetadata.AppendFormat("Volume effective date: {0}", decodedVD.EffectiveTime.ToString()).AppendLine(); ISOMetadata.AppendFormat("Volume effective date: {0}", decodedVD.EffectiveTime).AppendLine();
else else
ISOMetadata.AppendFormat("Volume has always been effective.").AppendLine(); ISOMetadata.AppendFormat("Volume has always been effective.").AppendLine();
@@ -753,17 +745,17 @@ namespace FileSystemIDandChk.Plugins
ISOMetadata.AppendFormat("Publisher identifier: {0}", decodedJolietVD.PublisherIdentifier).AppendLine(); ISOMetadata.AppendFormat("Publisher identifier: {0}", decodedJolietVD.PublisherIdentifier).AppendLine();
ISOMetadata.AppendFormat("Data preparer identifier: {0}", decodedJolietVD.DataPreparerIdentifier).AppendLine(); ISOMetadata.AppendFormat("Data preparer identifier: {0}", decodedJolietVD.DataPreparerIdentifier).AppendLine();
ISOMetadata.AppendFormat("Application identifier: {0}", decodedJolietVD.ApplicationIdentifier).AppendLine(); ISOMetadata.AppendFormat("Application identifier: {0}", decodedJolietVD.ApplicationIdentifier).AppendLine();
ISOMetadata.AppendFormat("Volume creation date: {0}", decodedJolietVD.CreationTime.ToString()).AppendLine(); ISOMetadata.AppendFormat("Volume creation date: {0}", decodedJolietVD.CreationTime).AppendLine();
if (decodedJolietVD.HasModificationTime) if (decodedJolietVD.HasModificationTime)
ISOMetadata.AppendFormat("Volume modification date: {0}", decodedJolietVD.ModificationTime.ToString()).AppendLine(); ISOMetadata.AppendFormat("Volume modification date: {0}", decodedJolietVD.ModificationTime).AppendLine();
else else
ISOMetadata.AppendFormat("Volume has not been modified.").AppendLine(); ISOMetadata.AppendFormat("Volume has not been modified.").AppendLine();
if (decodedJolietVD.HasExpirationTime) if (decodedJolietVD.HasExpirationTime)
ISOMetadata.AppendFormat("Volume expiration date: {0}", decodedJolietVD.ExpirationTime.ToString()).AppendLine(); ISOMetadata.AppendFormat("Volume expiration date: {0}", decodedJolietVD.ExpirationTime).AppendLine();
else else
ISOMetadata.AppendFormat("Volume does not expire.").AppendLine(); ISOMetadata.AppendFormat("Volume does not expire.").AppendLine();
if (decodedJolietVD.HasEffectiveTime) if (decodedJolietVD.HasEffectiveTime)
ISOMetadata.AppendFormat("Volume effective date: {0}", decodedJolietVD.EffectiveTime.ToString()).AppendLine(); ISOMetadata.AppendFormat("Volume effective date: {0}", decodedJolietVD.EffectiveTime).AppendLine();
else else
ISOMetadata.AppendFormat("Volume has always been effective.").AppendLine(); ISOMetadata.AppendFormat("Volume has always been effective.").AppendLine();
} }
@@ -771,7 +763,7 @@ namespace FileSystemIDandChk.Plugins
information = ISOMetadata.ToString(); information = ISOMetadata.ToString();
} }
private DecodedVolumeDescriptor DecodeJolietDescriptor(byte[] VDSysId, byte[] VDVolId, byte[] VDVolSetId, byte[] VDPubId, byte[] VDDataPrepId, byte[] VDAppId, byte[] VCTime, byte[] VMTime, byte[] VXTime, byte[] VETime) static DecodedVolumeDescriptor DecodeJolietDescriptor(byte[] VDSysId, byte[] VDVolId, byte[] VDVolSetId, byte[] VDPubId, byte[] VDDataPrepId, byte[] VDAppId, byte[] VCTime, byte[] VMTime, byte[] VXTime, byte[] VETime)
{ {
DecodedVolumeDescriptor decodedVD = new DecodedVolumeDescriptor(); DecodedVolumeDescriptor decodedVD = new DecodedVolumeDescriptor();
@@ -819,7 +811,7 @@ namespace FileSystemIDandChk.Plugins
return decodedVD; return decodedVD;
} }
private DecodedVolumeDescriptor DecodeVolumeDescriptor(byte[] VDSysId, byte[] VDVolId, byte[] VDVolSetId, byte[] VDPubId, byte[] VDDataPrepId, byte[] VDAppId, byte[] VCTime, byte[] VMTime, byte[] VXTime, byte[] VETime) static DecodedVolumeDescriptor DecodeVolumeDescriptor(byte[] VDSysId, byte[] VDVolId, byte[] VDVolSetId, byte[] VDPubId, byte[] VDDataPrepId, byte[] VDAppId, byte[] VCTime, byte[] VMTime, byte[] VXTime, byte[] VETime)
{ {
DecodedVolumeDescriptor decodedVD = new DecodedVolumeDescriptor(); DecodedVolumeDescriptor decodedVD = new DecodedVolumeDescriptor();

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -7,23 +6,32 @@ namespace FileSystemIDandChk.Plugins
{ {
class MinixFS : Plugin class MinixFS : Plugin
{ {
private const UInt16 MINIX_MAGIC = 0x137F; // Minix v1, 14 char filenames const UInt16 MINIX_MAGIC = 0x137F;
private const UInt16 MINIX_MAGIC2 = 0x138F; // Minix v1, 30 char filenames // Minix v1, 14 char filenames
private const UInt16 MINIX2_MAGIC = 0x2468; // Minix v2, 14 char filenames const UInt16 MINIX_MAGIC2 = 0x138F;
private const UInt16 MINIX2_MAGIC2 = 0x2478; // Minix v2, 30 char filenames // Minix v1, 30 char filenames
private const UInt16 MINIX3_MAGIC = 0x4D5A; // Minix v3, 60 char filenames const UInt16 MINIX2_MAGIC = 0x2468;
// Minix v2, 14 char filenames
const UInt16 MINIX2_MAGIC2 = 0x2478;
// Minix v2, 30 char filenames
const UInt16 MINIX3_MAGIC = 0x4D5A;
// Minix v3, 60 char filenames
// Byteswapped // Byteswapped
private const UInt16 MINIX_CIGAM = 0x7F13; // Minix v1, 14 char filenames const UInt16 MINIX_CIGAM = 0x7F13;
private const UInt16 MINIX_CIGAM2 = 0x8F13; // Minix v1, 30 char filenames // Minix v1, 14 char filenames
private const UInt16 MINIX2_CIGAM = 0x6824; // Minix v2, 14 char filenames const UInt16 MINIX_CIGAM2 = 0x8F13;
private const UInt16 MINIX2_CIGAM2 = 0x7824; // Minix v2, 30 char filenames // Minix v1, 30 char filenames
private const UInt16 MINIX3_CIGAM = 0x5A4D; // Minix v3, 60 char filenames const UInt16 MINIX2_CIGAM = 0x6824;
// Minix v2, 14 char filenames
const UInt16 MINIX2_CIGAM2 = 0x7824;
// Minix v2, 30 char filenames
const UInt16 MINIX3_CIGAM = 0x5A4D;
// Minix v3, 60 char filenames
public MinixFS(PluginBase Core) public MinixFS(PluginBase Core)
{ {
base.Name = "Minix Filesystem"; Name = "Minix Filesystem";
base.PluginUUID = new Guid("FE248C3B-B727-4AE5-A39F-79EA9A07D4B3"); PluginUUID = new Guid("FE248C3B-B727-4AE5-A39F-79EA9A07D4B3");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -36,16 +44,12 @@ namespace FileSystemIDandChk.Plugins
if (magic == MINIX_MAGIC || magic == MINIX_MAGIC2 || magic == MINIX2_MAGIC || magic == MINIX2_MAGIC2 || if (magic == MINIX_MAGIC || magic == MINIX_MAGIC2 || magic == MINIX2_MAGIC || magic == MINIX2_MAGIC2 ||
magic == MINIX_CIGAM || magic == MINIX_CIGAM2 || magic == MINIX2_CIGAM || magic == MINIX2_CIGAM2) magic == MINIX_CIGAM || magic == MINIX_CIGAM2 || magic == MINIX2_CIGAM || magic == MINIX2_CIGAM2)
return true; return true;
else
{
magic = BitConverter.ToUInt16(minix_sb_sector, 0x018); // Here should reside magic number on Minix V3 magic = BitConverter.ToUInt16(minix_sb_sector, 0x018); // Here should reside magic number on Minix V3
if (magic == MINIX3_MAGIC || magic == MINIX3_CIGAM) if (magic == MINIX3_MAGIC || magic == MINIX3_CIGAM)
return true; return true;
else
return false; return false;
} }
}
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information) public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
{ {
@@ -53,9 +57,8 @@ namespace FileSystemIDandChk.Plugins
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
bool littleendian = true;
bool minix3 = false; bool minix3 = false;
int filenamesize = 0; int filenamesize;
string minixVersion; string minixVersion;
UInt16 magic; UInt16 magic;
byte[] minix_sb_sector = imagePlugin.ReadSector(2 + partitionOffset); byte[] minix_sb_sector = imagePlugin.ReadSector(2 + partitionOffset);
@@ -66,10 +69,7 @@ namespace FileSystemIDandChk.Plugins
{ {
filenamesize = 60; filenamesize = 60;
minixVersion = "Minix V3 filesystem"; minixVersion = "Minix V3 filesystem";
if(magic == MINIX3_CIGAM) BigEndianBitConverter.IsLittleEndian = magic != MINIX3_CIGAM;
littleendian = false;
else
littleendian = true;
minix3 = true; minix3 = true;
} }
@@ -121,7 +121,6 @@ namespace FileSystemIDandChk.Plugins
break; break;
default: default:
return; return;
break;
} }
} }
@@ -189,33 +188,56 @@ namespace FileSystemIDandChk.Plugins
public struct MinixSuperBlock public struct MinixSuperBlock
{ {
public UInt16 s_ninodes; // 0x00, inodes on volume public UInt16 s_ninodes;
public UInt16 s_nzones; // 0x02, zones on volume // 0x00, inodes on volume
public UInt16 s_imap_blocks; // 0x04, blocks on inode map public UInt16 s_nzones;
public UInt16 s_zmap_blocks; // 0x06, blocks on zone map // 0x02, zones on volume
public UInt16 s_firstdatazone; // 0x08, first data zone public UInt16 s_imap_blocks;
public UInt16 s_log_zone_size; // 0x0A, log2 of blocks/zone // 0x04, blocks on inode map
public UInt32 s_max_size; // 0x0C, max file size public UInt16 s_zmap_blocks;
public UInt16 s_magic; // 0x10, magic // 0x06, blocks on zone map
public UInt16 s_state; // 0x12, filesystem state public UInt16 s_firstdatazone;
public UInt32 s_zones; // 0x14, number of zones // 0x08, first data zone
public UInt16 s_log_zone_size;
// 0x0A, log2 of blocks/zone
public UInt32 s_max_size;
// 0x0C, max file size
public UInt16 s_magic;
// 0x10, magic
public UInt16 s_state;
// 0x12, filesystem state
public UInt32 s_zones;
// 0x14, number of zones
} }
public struct Minix3SuperBlock public struct Minix3SuperBlock
{ {
public UInt32 s_ninodes; // 0x00, inodes on volume public UInt32 s_ninodes;
public UInt16 s_pad0; // 0x04, padding // 0x00, inodes on volume
public UInt16 s_imap_blocks; // 0x06, blocks on inode map public UInt16 s_pad0;
public UInt16 s_zmap_blocks; // 0x08, blocks on zone map // 0x04, padding
public UInt16 s_firstdatazone; // 0x0A, first data zone public UInt16 s_imap_blocks;
public UInt16 s_log_zone_size; // 0x0C, log2 of blocks/zone // 0x06, blocks on inode map
public UInt16 s_pad1; // 0x0E, padding public UInt16 s_zmap_blocks;
public UInt32 s_max_size; // 0x10, max file size // 0x08, blocks on zone map
public UInt32 s_zones; // 0x14, number of zones public UInt16 s_firstdatazone;
public UInt16 s_magic; // 0x18, magic // 0x0A, first data zone
public UInt16 s_pad2; // 0x1A, padding public UInt16 s_log_zone_size;
public UInt16 s_blocksize; // 0x1C, bytes in a block // 0x0C, log2 of blocks/zone
public byte s_disk_version; // 0x1E, on-disk structures version public UInt16 s_pad1;
// 0x0E, padding
public UInt32 s_max_size;
// 0x10, max file size
public UInt32 s_zones;
// 0x14, number of zones
public UInt16 s_magic;
// 0x18, magic
public UInt16 s_pad2;
// 0x1A, padding
public UInt16 s_blocksize;
// 0x1C, bytes in a block
public byte s_disk_version;
// 0x1E, on-disk structures version
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -9,8 +8,8 @@ namespace FileSystemIDandChk.Plugins
{ {
public NTFS(PluginBase Core) public NTFS(PluginBase Core)
{ {
base.Name = "New Technology File System (NTFS)"; Name = "New Technology File System (NTFS)";
base.PluginUUID = new Guid("33513B2C-1e6d-4d21-a660-0bbc789c3871"); PluginUUID = new Guid("33513B2C-1e6d-4d21-a660-0bbc789c3871");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -45,10 +44,8 @@ namespace FileSystemIDandChk.Plugins
signature2 = BitConverter.ToUInt16(ntfs_bpb, 0x1FE); signature2 = BitConverter.ToUInt16(ntfs_bpb, 0x1FE);
if(signature2 != 0xAA55) return signature2 == 0xAA55;
return false;
return true;
} }
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information) public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
@@ -131,42 +128,72 @@ namespace FileSystemIDandChk.Plugins
information = sb.ToString(); information = sb.ToString();
} }
private struct NTFS_BootBlock // Sector 0 struct NTFS_BootBlock // Sector 0
{ {
// BIOS Parameter Block // BIOS Parameter Block
public byte jmp1; // 0x000, Jump to boot code public byte jmp1;
public UInt16 jmp2; // 0x001, ...; // 0x000, Jump to boot code
public string OEMName; // 0x003, OEM Name, 8 bytes, space-padded, must be "NTFS " public UInt16 jmp2;
public UInt16 bps; // 0x00B, Bytes per sector // 0x001, ...;
public byte spc; // 0x00D, Sectors per cluster public string OEMName;
public UInt16 rsectors; // 0x00E, Reserved sectors, seems 0 // 0x003, OEM Name, 8 bytes, space-padded, must be "NTFS "
public byte fats_no; // 0x010, Number of FATs... obviously, 0 public UInt16 bps;
public UInt16 root_ent; // 0x011, Number of entries on root directory... 0 // 0x00B, Bytes per sector
public UInt16 sml_sectors; // 0x013, Sectors in volume... 0 public byte spc;
public byte media; // 0x015, Media descriptor // 0x00D, Sectors per cluster
public UInt16 spfat; // 0x016, Sectors per FAT... 0 public UInt16 rsectors;
public UInt16 sptrk; // 0x018, Sectors per track, required to boot // 0x00E, Reserved sectors, seems 0
public UInt16 heads; // 0x01A, Heads... required to boot public byte fats_no;
public UInt32 hsectors; // 0x01C, Hidden sectors before BPB // 0x010, Number of FATs... obviously, 0
public UInt32 big_sectors; // 0x020, Sectors in volume if > 65535... 0 public UInt16 root_ent;
public byte drive_no; // 0x024, Drive number // 0x011, Number of entries on root directory... 0
public byte nt_flags; // 0x025, 0 public UInt16 sml_sectors;
public byte signature1; // 0x026, EPB signature, 0x80 // 0x013, Sectors in volume... 0
public byte dummy; // 0x027, Alignment public byte media;
// 0x015, Media descriptor
public UInt16 spfat;
// 0x016, Sectors per FAT... 0
public UInt16 sptrk;
// 0x018, Sectors per track, required to boot
public UInt16 heads;
// 0x01A, Heads... required to boot
public UInt32 hsectors;
// 0x01C, Hidden sectors before BPB
public UInt32 big_sectors;
// 0x020, Sectors in volume if > 65535... 0
public byte drive_no;
// 0x024, Drive number
public byte nt_flags;
// 0x025, 0
public byte signature1;
// 0x026, EPB signature, 0x80
public byte dummy;
// 0x027, Alignment
// End of BIOS Parameter Block // End of BIOS Parameter Block
// NTFS real superblock // NTFS real superblock
public Int64 sectors; // 0x028, Sectors on volume public Int64 sectors;
public Int64 mft_lsn; // 0x030, LSN of $MFT // 0x028, Sectors on volume
public Int64 mftmirror_lsn; // 0x038, LSN of $MFTMirror public Int64 mft_lsn;
public sbyte mft_rc_clusters; // 0x040, Clusters per MFT record // 0x030, LSN of $MFT
public byte dummy2; // 0x041, Alignment public Int64 mftmirror_lsn;
public UInt16 dummy3; // 0x042, Alignment // 0x038, LSN of $MFTMirror
public sbyte index_blk_cts; // 0x044, Clusters per index block public sbyte mft_rc_clusters;
public byte dummy4; // 0x045, Alignment // 0x040, Clusters per MFT record
public UInt16 dummy5; // 0x046, Alignment public byte dummy2;
public UInt64 serial_no; // 0x048, Volume serial number // 0x041, Alignment
public UInt16 dummy3;
// 0x042, Alignment
public sbyte index_blk_cts;
// 0x044, Clusters per index block
public byte dummy4;
// 0x045, Alignment
public UInt16 dummy5;
// 0x046, Alignment
public UInt64 serial_no;
// 0x048, Volume serial number
// End of NTFS superblock, followed by 430 bytes of boot code // End of NTFS superblock, followed by 430 bytes of boot code
public UInt16 signature2; // 0x1FE, 0xAA55 public UInt16 signature2;
// 0x1FE, 0xAA55
} }
} }
} }

View File

@@ -1,29 +1,24 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
// Information from VMS File System Internals by Kirby McCoy // Information from VMS File System Internals by Kirby McCoy
// ISBN: 1-55558-056-4 // ISBN: 1-55558-056-4
// With some hints from http://www.decuslib.com/DECUS/vmslt97b/gnusoftware/gccaxp/7_1/vms/hm2def.h // With some hints from http://www.decuslib.com/DECUS/vmslt97b/gnusoftware/gccaxp/7_1/vms/hm2def.h
// Expects the home block to be always in sector #1 (does not check deltas) // Expects the home block to be always in sector #1 (does not check deltas)
// Assumes a sector size of 512 bytes (VMS does on HDDs and optical drives, dunno about M.O.) // Assumes a sector size of 512 bytes (VMS does on HDDs and optical drives, dunno about M.O.)
// Book only describes ODS-2. Need to test ODS-1 and OSD-5 // Book only describes ODS-2. Need to test ODS-1 and OSD-5
// There is an ODS with signature "DECFILES11A", yet to be seen // There is an ODS with signature "DECFILES11A", yet to be seen
// Time is a 64 bit unsigned integer, tenths of microseconds since 1858/11/17 00:00:00. // Time is a 64 bit unsigned integer, tenths of microseconds since 1858/11/17 00:00:00.
// TODO: Implement checksum // TODO: Implement checksum
namespace FileSystemIDandChk.Plugins namespace FileSystemIDandChk.Plugins
{ {
class ODS : Plugin class ODS : Plugin
{ {
public ODS(PluginBase Core) public ODS(PluginBase Core)
{ {
base.Name = "Files-11 On-Disk Structure"; Name = "Files-11 On-Disk Structure";
base.PluginUUID = new Guid("de20633c-8021-4384-aeb0-83b0df14491f"); PluginUUID = new Guid("de20633c-8021-4384-aeb0-83b0df14491f");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -35,10 +30,7 @@ namespace FileSystemIDandChk.Plugins
Array.Copy(hb_sector, 0x1F0, magic_b, 0, 12); Array.Copy(hb_sector, 0x1F0, magic_b, 0, 12);
magic = Encoding.ASCII.GetString(magic_b); magic = Encoding.ASCII.GetString(magic_b);
if(magic == "DECFILE11A " || magic == "DECFILE11B ") return magic == "DECFILE11A " || magic == "DECFILE11B ";
return true;
else
return false;
} }
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information) public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
@@ -124,11 +116,11 @@ namespace FileSystemIDandChk.Plugins
sb.AppendFormat("Volume owner is \"{0}\" (ID 0x{1:X8})", homeblock.ownername, homeblock.volowner).AppendLine(); sb.AppendFormat("Volume owner is \"{0}\" (ID 0x{1:X8})", homeblock.ownername, homeblock.volowner).AppendLine();
sb.AppendFormat("Volume label: \"{0}\"", homeblock.volname).AppendLine(); sb.AppendFormat("Volume label: \"{0}\"", homeblock.volname).AppendLine();
sb.AppendFormat("Drive serial number: 0x{0:X8}", homeblock.serialnum).AppendLine(); sb.AppendFormat("Drive serial number: 0x{0:X8}", homeblock.serialnum).AppendLine();
sb.AppendFormat("Volume was created on {0}", DateHandlers.VMSToDateTime(homeblock.credate).ToString()).AppendLine(); sb.AppendFormat("Volume was created on {0}", DateHandlers.VMSToDateTime(homeblock.credate)).AppendLine();
if (homeblock.revdate > 0) if (homeblock.revdate > 0)
sb.AppendFormat("Volume was last modified on {0}", DateHandlers.VMSToDateTime(homeblock.revdate).ToString()).AppendLine(); sb.AppendFormat("Volume was last modified on {0}", DateHandlers.VMSToDateTime(homeblock.revdate)).AppendLine();
if (homeblock.copydate > 0) if (homeblock.copydate > 0)
sb.AppendFormat("Volume copied on {0}", DateHandlers.VMSToDateTime(homeblock.copydate).ToString()).AppendLine(); sb.AppendFormat("Volume copied on {0}", DateHandlers.VMSToDateTime(homeblock.copydate)).AppendLine();
sb.AppendFormat("Checksums: 0x{0:X4} and 0x{1:X4}", homeblock.checksum1, homeblock.checksum2).AppendLine(); sb.AppendFormat("Checksums: 0x{0:X4} and 0x{1:X4}", homeblock.checksum1, homeblock.checksum2).AppendLine();
sb.AppendLine("Flags:"); sb.AppendLine("Flags:");
sb.AppendFormat("Window: {0}", homeblock.window).AppendLine(); sb.AppendFormat("Window: {0}", homeblock.window).AppendLine();
@@ -225,54 +217,100 @@ namespace FileSystemIDandChk.Plugins
information = sb.ToString(); information = sb.ToString();
} }
private struct ODSHomeBlock struct ODSHomeBlock
{ {
public UInt32 homelbn; // 0x000, LBN of THIS home block public UInt32 homelbn;
public UInt32 alhomelbn; // 0x004, LBN of the secondary home block // 0x000, LBN of THIS home block
public UInt32 altidxlbn; // 0x008, LBN of backup INDEXF.SYS;1 public UInt32 alhomelbn;
public UInt16 struclev; // 0x00C, High byte contains filesystem version (1, 2 or 5), low byte contains revision (1) // 0x004, LBN of the secondary home block
public UInt16 cluster; // 0x00E, Number of blocks each bit of the volume bitmap represents public UInt32 altidxlbn;
public UInt16 homevbn; // 0x010, VBN of THIS home block // 0x008, LBN of backup INDEXF.SYS;1
public UInt16 alhomevbn; // 0x012, VBN of the secondary home block public UInt16 struclev;
public UInt16 altidxvbn; // 0x014, VBN of backup INDEXF.SYS;1 // 0x00C, High byte contains filesystem version (1, 2 or 5), low byte contains revision (1)
public UInt16 ibmapvbn; // 0x016, VBN of the bitmap public UInt16 cluster;
public UInt32 ibmaplbn; // 0x018, LBN of the bitmap // 0x00E, Number of blocks each bit of the volume bitmap represents
public UInt32 maxfiles; // 0x01C, Max files on volume public UInt16 homevbn;
public UInt16 ibmapsize; // 0x020, Bitmap size in sectors // 0x010, VBN of THIS home block
public UInt16 resfiles; // 0x022, Reserved files, 5 at minimum public UInt16 alhomevbn;
public UInt16 devtype; // 0x024, Device type, ODS-2 defines it as always 0 // 0x012, VBN of the secondary home block
public UInt16 rvn; // 0x026, Relative volume number (number of the volume in a set) public UInt16 altidxvbn;
public UInt16 setcount; // 0x028, Total number of volumes in the set this volume is // 0x014, VBN of backup INDEXF.SYS;1
public UInt16 volchar; // 0x02A, Flags public UInt16 ibmapvbn;
public UInt32 volowner; // 0x02C, User ID of the volume owner // 0x016, VBN of the bitmap
public UInt32 sec_mask; // 0x030, Security mask (??) public UInt32 ibmaplbn;
public UInt16 protect; // 0x034, Volume permissions (system, owner, group and other) // 0x018, LBN of the bitmap
public UInt16 fileprot; // 0x036, Default file protection, unsupported in ODS-2 public UInt32 maxfiles;
public UInt16 recprot; // 0x038, Default file record protection // 0x01C, Max files on volume
public UInt16 checksum1; // 0x03A, Checksum of all preceding entries public UInt16 ibmapsize;
public UInt64 credate; // 0x03C, Creation date // 0x020, Bitmap size in sectors
public byte window; // 0x044, Window size (pointers for the window) public UInt16 resfiles;
public byte lru_lim; // 0x045, Directories to be stored in cache // 0x022, Reserved files, 5 at minimum
public UInt16 extend; // 0x046, Default allocation size in blocks public UInt16 devtype;
public UInt64 retainmin; // 0x048, Minimum file retention period // 0x024, Device type, ODS-2 defines it as always 0
public UInt64 retainmax; // 0x050, Maximum file retention period public UInt16 rvn;
public UInt64 revdate; // 0x058, Last modification date // 0x026, Relative volume number (number of the volume in a set)
public byte[] min_class; // 0x060, Minimum security class, 20 bytes public UInt16 setcount;
public byte[] max_class; // 0x074, Maximum security class, 20 bytes // 0x028, Total number of volumes in the set this volume is
public UInt16 filetab_fid1; // 0x088, File lookup table FID public UInt16 volchar;
public UInt16 filetab_fid2; // 0x08A, File lookup table FID // 0x02A, Flags
public UInt16 filetab_fid3; // 0x08C, File lookup table FID public UInt32 volowner;
public UInt16 lowstruclev; // 0x08E, Lowest structure level on the volume // 0x02C, User ID of the volume owner
public UInt16 highstruclev; // 0x090, Highest structure level on the volume public UInt32 sec_mask;
public UInt64 copydate; // 0x092, Volume copy date (??) // 0x030, Security mask (??)
public byte[] reserved1; // 0x09A, 302 bytes public UInt16 protect;
public UInt32 serialnum; // 0x1C8, Physical drive serial number // 0x034, Volume permissions (system, owner, group and other)
public string strucname; // 0x1CC, Name of the volume set, 12 bytes public UInt16 fileprot;
public string volname; // 0x1D8, Volume label, 12 bytes // 0x036, Default file protection, unsupported in ODS-2
public string ownername; // 0x1E4, Name of the volume owner, 12 bytes public UInt16 recprot;
public string format; // 0x1F0, ODS-2 defines it as "DECFILE11B", 12 bytes // 0x038, Default file record protection
public UInt16 reserved2; // 0x1FC, Reserved public UInt16 checksum1;
public UInt16 checksum2; // 0x1FE, Checksum of preceding 255 words (16 bit units) // 0x03A, Checksum of all preceding entries
public UInt64 credate;
// 0x03C, Creation date
public byte window;
// 0x044, Window size (pointers for the window)
public byte lru_lim;
// 0x045, Directories to be stored in cache
public UInt16 extend;
// 0x046, Default allocation size in blocks
public UInt64 retainmin;
// 0x048, Minimum file retention period
public UInt64 retainmax;
// 0x050, Maximum file retention period
public UInt64 revdate;
// 0x058, Last modification date
public byte[] min_class;
// 0x060, Minimum security class, 20 bytes
public byte[] max_class;
// 0x074, Maximum security class, 20 bytes
public UInt16 filetab_fid1;
// 0x088, File lookup table FID
public UInt16 filetab_fid2;
// 0x08A, File lookup table FID
public UInt16 filetab_fid3;
// 0x08C, File lookup table FID
public UInt16 lowstruclev;
// 0x08E, Lowest structure level on the volume
public UInt16 highstruclev;
// 0x090, Highest structure level on the volume
public UInt64 copydate;
// 0x092, Volume copy date (??)
public byte[] reserved1;
// 0x09A, 302 bytes
public UInt32 serialnum;
// 0x1C8, Physical drive serial number
public string strucname;
// 0x1CC, Name of the volume set, 12 bytes
public string volname;
// 0x1D8, Volume label, 12 bytes
public string ownername;
// 0x1E4, Name of the volume owner, 12 bytes
public string format;
// 0x1F0, ODS-2 defines it as "DECFILE11B", 12 bytes
public UInt16 reserved2;
// 0x1FC, Reserved
public UInt16 checksum2;
// 0x1FE, Checksum of preceding 255 words (16 bit units)
} }
} }
} }

View File

@@ -1,17 +1,15 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
namespace FileSystemIDandChk.Plugins namespace FileSystemIDandChk.Plugins
{ {
class OperaFS : Plugin class OperaFS : Plugin
{ {
public OperaFS(PluginBase Core) public OperaFS(PluginBase Core)
{ {
base.Name = "Opera Filesystem Plugin"; Name = "Opera Filesystem Plugin";
base.PluginUUID = new Guid("0ec84ec7-eae6-4196-83fe-943b3fe46dbd"); PluginUUID = new Guid("0ec84ec7-eae6-4196-83fe-943b3fe46dbd");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -28,10 +26,8 @@ namespace FileSystemIDandChk.Plugins
if (record_type != 1 || record_version != 1) if (record_type != 1 || record_version != 1)
return false; return false;
if(Encoding.ASCII.GetString(sync_bytes) != "ZZZZZ") return Encoding.ASCII.GetString(sync_bytes) == "ZZZZZ";
return false;
return true;
} }
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information) public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
@@ -95,21 +91,34 @@ namespace FileSystemIDandChk.Plugins
information = SuperBlockMetadata.ToString(); information = SuperBlockMetadata.ToString();
} }
private struct OperaSuperBlock struct OperaSuperBlock
{ {
public byte record_type; // 0x000, Record type, must be 1 public byte record_type;
public byte[] sync_bytes; // 0x001, 5 bytes, "ZZZZZ" = new byte[5]; // 0x000, Record type, must be 1
public byte record_version; // 0x006, Record version, must be 1 public byte[] sync_bytes;
public byte volume_flags; // 0x007, Volume flags // 0x001, 5 bytes, "ZZZZZ" = new byte[5];
public string volume_comment; // 0x008, 32 bytes, volume comment public byte record_version;
public string volume_label; // 0x028, 32 bytes, volume label // 0x006, Record version, must be 1
public Int32 volume_id; // 0x048, Volume ID public byte volume_flags;
public Int32 block_size; // 0x04C, Block size in bytes // 0x007, Volume flags
public Int32 block_count; // 0x050, Blocks in volume public string volume_comment;
public Int32 root_dirid; // 0x054, Root directory ID // 0x008, 32 bytes, volume comment
public Int32 rootdir_blocks; // 0x058, Root directory blocks public string volume_label;
public Int32 rootdir_bsize; // 0x05C, Root directory block size // 0x028, 32 bytes, volume label
public Int32 last_root_copy; // 0x060, Last root directory copy public Int32 volume_id;
// 0x048, Volume ID
public Int32 block_size;
// 0x04C, Block size in bytes
public Int32 block_count;
// 0x050, Blocks in volume
public Int32 root_dirid;
// 0x054, Root directory ID
public Int32 rootdir_blocks;
// 0x058, Root directory blocks
public Int32 rootdir_bsize;
// 0x05C, Root directory block size
public Int32 last_root_copy;
// 0x060, Last root directory copy
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -9,8 +8,8 @@ namespace FileSystemIDandChk.Plugins
{ {
public PCEnginePlugin(PluginBase Core) public PCEnginePlugin(PluginBase Core)
{ {
base.Name = "PC Engine CD Plugin"; Name = "PC Engine CD Plugin";
base.PluginUUID = new Guid("e5ee6d7c-90fa-49bd-ac89-14ef750b8af3"); PluginUUID = new Guid("e5ee6d7c-90fa-49bd-ac89-14ef750b8af3");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -20,10 +19,7 @@ namespace FileSystemIDandChk.Plugins
Array.Copy(sector, 0x20, system_descriptor, 0, 23); Array.Copy(sector, 0x20, system_descriptor, 0, 23);
if(Encoding.ASCII.GetString(system_descriptor) == "PC Engine CD-ROM SYSTEM") return Encoding.ASCII.GetString(system_descriptor) == "PC Engine CD-ROM SYSTEM";
return true;
else
return false;
} }
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information) public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
namespace FileSystemIDandChk.Plugins namespace FileSystemIDandChk.Plugins
{ {

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -10,8 +9,8 @@ namespace FileSystemIDandChk.Plugins
{ {
public SolarFS(PluginBase Core) public SolarFS(PluginBase Core)
{ {
base.Name = "Solar_OS filesystem"; Name = "Solar_OS filesystem";
base.PluginUUID = new Guid("EA3101C1-E777-4B4F-B5A3-8C57F50F6E65"); PluginUUID = new Guid("EA3101C1-E777-4B4F-B5A3-8C57F50F6E65");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -29,7 +28,6 @@ namespace FileSystemIDandChk.Plugins
if (signature == 0x29 && fs_type == "SOL_FS ") if (signature == 0x29 && fs_type == "SOL_FS ")
return true; return true;
else
return false; return false;
} }
@@ -99,8 +97,7 @@ namespace FileSystemIDandChk.Plugins
sb.AppendFormat("WARNING: Filesystem describes a {0} bytes/sector, while device describes a {1} bytes/sector", BPB.bps, 2048).AppendLine(); sb.AppendFormat("WARNING: Filesystem describes a {0} bytes/sector, while device describes a {1} bytes/sector", BPB.bps, 2048).AppendLine();
} }
} }
else else if (BPB.bps != imagePlugin.GetSectorSize())
if (BPB.bps != imagePlugin.GetSectorSize())
{ {
sb.AppendFormat("WARNING: Filesystem describes a {0} bytes/sector, while device describes a {1} bytes/sector", BPB.bps, imagePlugin.GetSectorSize()).AppendLine(); sb.AppendFormat("WARNING: Filesystem describes a {0} bytes/sector, while device describes a {1} bytes/sector", BPB.bps, imagePlugin.GetSectorSize()).AppendLine();
} }
@@ -116,22 +113,38 @@ namespace FileSystemIDandChk.Plugins
public struct SolarOSParameterBlock public struct SolarOSParameterBlock
{ {
public byte[] x86_jump; // 0x00, x86 jump (3 bytes), jumps to 0x60 public byte[] x86_jump;
public string OEMName; // 0x03, 8 bytes, "SOLAR_OS" // 0x00, x86 jump (3 bytes), jumps to 0x60
public UInt16 bps; // 0x0B, Bytes per sector public string OEMName;
public byte unk1; // 0x0D, unknown, 0x01 // 0x03, 8 bytes, "SOLAR_OS"
public UInt16 unk2; // 0x0E, unknown, 0x0201 public UInt16 bps;
public UInt16 root_ent; // 0x10, Number of entries on root directory ? (no root directory found) // 0x0B, Bytes per sector
public UInt16 sectors; // 0x12, Sectors in volume public byte unk1;
public byte media; // 0x14, Media descriptor // 0x0D, unknown, 0x01
public UInt16 spfat; // 0x15, Sectors per FAT ? (no FAT found) public UInt16 unk2;
public UInt16 sptrk; // 0x17, Sectors per track // 0x0E, unknown, 0x0201
public UInt16 heads; // 0x19, Heads public UInt16 root_ent;
public byte[] unk3; // 0x1B, unknown, 10 bytes, zero-filled // 0x10, Number of entries on root directory ? (no root directory found)
public byte signature; // 0x25, 0x29 public UInt16 sectors;
public UInt32 unk4; // 0x26, unknown, zero-filled // 0x12, Sectors in volume
public string vol_name; // 0x2A, 11 bytes, volume name, space-padded public byte media;
public string fs_type; // 0x35, 8 bytes, "SOL_FS " // 0x14, Media descriptor
public UInt16 spfat;
// 0x15, Sectors per FAT ? (no FAT found)
public UInt16 sptrk;
// 0x17, Sectors per track
public UInt16 heads;
// 0x19, Heads
public byte[] unk3;
// 0x1B, unknown, 10 bytes, zero-filled
public byte signature;
// 0x25, 0x29
public UInt32 unk4;
// 0x26, unknown, zero-filled
public string vol_name;
// 0x2A, 11 bytes, volume name, space-padded
public string fs_type;
// 0x35, 8 bytes, "SOL_FS "
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -7,25 +6,25 @@ namespace FileSystemIDandChk.Plugins
{ {
class SysVfs : Plugin class SysVfs : Plugin
{ {
private const UInt32 XENIX_MAGIC = 0x002B5544; const UInt32 XENIX_MAGIC = 0x002B5544;
private const UInt32 XENIX_CIGAM = 0x44552B00; const UInt32 XENIX_CIGAM = 0x44552B00;
private const UInt32 SYSV_MAGIC = 0xFD187E20; const UInt32 SYSV_MAGIC = 0xFD187E20;
private const UInt32 SYSV_CIGAM = 0xFD187E20; const UInt32 SYSV_CIGAM = 0xFD187E20;
// Rest have no magic. // Rest have no magic.
// Per a Linux kernel, Coherent fs has following: // Per a Linux kernel, Coherent fs has following:
private const string COH_FNAME = "nonamexxxxx "; const string COH_FNAME = "nonamexxxxx ";
private const string COH_FPACK = "nopackxxxxx\n"; const string COH_FPACK = "nopackxxxxx\n";
// SCO AFS // SCO AFS
private const UInt16 SCO_NFREE = 0xFFFF; const UInt16 SCO_NFREE = 0xFFFF;
// UNIX 7th Edition has nothing to detect it, so check for a valid filesystem is a must :( // UNIX 7th Edition has nothing to detect it, so check for a valid filesystem is a must :(
private const UInt16 V7_NICINOD = 100; const UInt16 V7_NICINOD = 100;
private const UInt16 V7_NICFREE = 50; const UInt16 V7_NICFREE = 50;
private const UInt32 V7_MAXSIZE = 0x00FFFFFF; const UInt32 V7_MAXSIZE = 0x00FFFFFF;
public SysVfs(PluginBase Core) public SysVfs(PluginBase Core)
{ {
base.Name = "UNIX System V filesystem"; Name = "UNIX System V filesystem";
base.PluginUUID = new Guid("9B8D016A-8561-400E-A12A-A198283C211D"); PluginUUID = new Guid("9B8D016A-8561-400E-A12A-A198283C211D");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -123,7 +122,6 @@ namespace FileSystemIDandChk.Plugins
information = ""; information = "";
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
bool littleendian = true;
BigEndianBitConverter.IsLittleEndian = true; // Start in little endian until we know what are we handling here BigEndianBitConverter.IsLittleEndian = true; // Start in little endian until we know what are we handling here
int start; int start;
UInt32 magic; UInt32 magic;
@@ -132,7 +130,6 @@ namespace FileSystemIDandChk.Plugins
UInt32 s_fsize; UInt32 s_fsize;
bool xenix = false; bool xenix = false;
bool sysv = false; bool sysv = false;
bool sysvr2 = false;
bool sysvr4 = false; bool sysvr4 = false;
bool sys7th = false; bool sys7th = false;
bool coherent = false; bool coherent = false;
@@ -156,7 +153,7 @@ namespace FileSystemIDandChk.Plugins
xenix = true; xenix = true;
break; break;
} }
else if(magic == XENIX_CIGAM) if (magic == XENIX_CIGAM)
{ {
BigEndianBitConverter.IsLittleEndian = false; // Big endian BigEndianBitConverter.IsLittleEndian = false; // Big endian
xenix = true; xenix = true;
@@ -171,7 +168,7 @@ namespace FileSystemIDandChk.Plugins
sysv = true; sysv = true;
break; break;
} }
else if(magic == SYSV_CIGAM) if (magic == SYSV_CIGAM)
{ {
BigEndianBitConverter.IsLittleEndian = false; // Big endian BigEndianBitConverter.IsLittleEndian = false; // Big endian
sysv = true; sysv = true;
@@ -198,14 +195,12 @@ namespace FileSystemIDandChk.Plugins
if (s_fsize > 0 && s_fsize < 0xFFFFFFFF && s_nfree > 0 && s_nfree < 0xFFFF && s_ninode > 0 && s_ninode < 0xFFFF) if (s_fsize > 0 && s_fsize < 0xFFFFFFFF && s_nfree > 0 && s_nfree < 0xFFFF && s_ninode > 0 && s_ninode < 0xFFFF)
{ {
bool byteswapped = false;
if ((s_fsize & 0xFF) == 0x00 && (s_nfree & 0xFF) == 0x00 && (s_ninode & 0xFF) == 0x00) if ((s_fsize & 0xFF) == 0x00 && (s_nfree & 0xFF) == 0x00 && (s_ninode & 0xFF) == 0x00)
{ {
// Byteswap // Byteswap
s_fsize = ((s_fsize & 0xFF) << 24) + ((s_fsize & 0xFF00) << 8) + ((s_fsize & 0xFF0000) >> 8) + ((s_fsize & 0xFF000000) >> 24); s_fsize = ((s_fsize & 0xFF) << 24) + ((s_fsize & 0xFF00) << 8) + ((s_fsize & 0xFF0000) >> 8) + ((s_fsize & 0xFF000000) >> 24);
s_nfree = (UInt16)(s_nfree >> 8); s_nfree = (UInt16)(s_nfree >> 8);
s_ninode = (UInt16)(s_ninode >> 8); s_ninode = (UInt16)(s_ninode >> 8);
byteswapped = true;
} }
if ((s_fsize & 0xFF000000) == 0x00 && (s_nfree & 0xFF00) == 0x00 && (s_ninode & 0xFF00) == 0x00) if ((s_fsize & 0xFF000000) == 0x00 && (s_nfree & 0xFF00) == 0x00 && (s_ninode & 0xFF00) == 0x00)
@@ -311,19 +306,15 @@ namespace FileSystemIDandChk.Plugins
if (sysv) if (sysv)
{ {
sb_sector = imagePlugin.ReadSectors((ulong)start + partitionOffset, sb_size_in_sectors); sb_sector = imagePlugin.ReadSectors((ulong)start + partitionOffset, sb_size_in_sectors);
UInt16 pad0, pad1, pad2, pad3; UInt16 pad0, pad1, pad2;
byte[] sysv_strings = new byte[6]; byte[] sysv_strings = new byte[6];
pad0 = BigEndianBitConverter.ToUInt16(sb_sector, 0x002); // First padding pad0 = BigEndianBitConverter.ToUInt16(sb_sector, 0x002); // First padding
pad1 = BigEndianBitConverter.ToUInt16(sb_sector, 0x00A); // Second padding pad1 = BigEndianBitConverter.ToUInt16(sb_sector, 0x00A); // Second padding
pad2 = BigEndianBitConverter.ToUInt16(sb_sector, 0x0D6); // Third padding pad2 = BigEndianBitConverter.ToUInt16(sb_sector, 0x0D6); // Third padding
pad3 = BigEndianBitConverter.ToUInt16(sb_sector, 0x1B6); // Fourth padding
// This detection is not working as expected // This detection is not working as expected
if(pad0 == 0 && pad1 == 0 && pad2 == 0) sysvr4 |= pad0 == 0 && pad1 == 0 && pad2 == 0;
sysvr4 = true;
else
sysvr2 = true;
SystemVRelease4SuperBlock sysv_sb = new SystemVRelease4SuperBlock(); SystemVRelease4SuperBlock sysv_sb = new SystemVRelease4SuperBlock();
@@ -530,142 +521,250 @@ namespace FileSystemIDandChk.Plugins
BigEndianBitConverter.IsLittleEndian = false; // Return to default (bigendian) BigEndianBitConverter.IsLittleEndian = false; // Return to default (bigendian)
} }
private struct XenixSuperBlock struct XenixSuperBlock
{ {
public UInt16 s_isize; // 0x000, index of first data zone public UInt16 s_isize;
public UInt32 s_fsize; // 0x002, total number of zones of this volume // 0x000, index of first data zone
public UInt32 s_fsize;
// 0x002, total number of zones of this volume
// the start of the free block list: // the start of the free block list:
public UInt16 s_nfree; // 0x006, blocks in s_free, <=100 public UInt16 s_nfree;
public UInt32[] s_free; // 0x008, 100 entries, first free block list chunk // 0x006, blocks in s_free, <=100
public UInt32[] s_free;
// 0x008, 100 entries, first free block list chunk
// the cache of free inodes: // the cache of free inodes:
public UInt16 s_ninode; // 0x198, number of inodes in s_inode, <= 100 public UInt16 s_ninode;
public UInt16[] s_inode; // 0x19A, 100 entries, some free inodes // 0x198, number of inodes in s_inode, <= 100
public byte s_flock; // 0x262, free block list manipulation lock public UInt16[] s_inode;
public byte s_ilock; // 0x263, inode cache manipulation lock // 0x19A, 100 entries, some free inodes
public byte s_fmod; // 0x264, superblock modification flag public byte s_flock;
public byte s_ronly; // 0x265, read-only mounted flag // 0x262, free block list manipulation lock
public UInt32 s_time; // 0x266, time of last superblock update public byte s_ilock;
public UInt32 s_tfree; // 0x26A, total number of free zones // 0x263, inode cache manipulation lock
public UInt16 s_tinode; // 0x26E, total number of free inodes public byte s_fmod;
public UInt16 s_cylblks; // 0x270, blocks per cylinder // 0x264, superblock modification flag
public UInt16 s_gapblks; // 0x272, blocks per gap public byte s_ronly;
public UInt16 s_dinfo0; // 0x274, device information ?? // 0x265, read-only mounted flag
public UInt16 s_dinfo1; // 0x276, device information ?? public UInt32 s_time;
public string s_fname; // 0x278, 6 bytes, volume name // 0x266, time of last superblock update
public string s_fpack; // 0x27E, 6 bytes, pack name public UInt32 s_tfree;
public byte s_clean; // 0x284, 0x46 if volume is clean // 0x26A, total number of free zones
public byte[] s_fill; // 0x285, 371 bytes public UInt16 s_tinode;
public UInt32 s_magic; // 0x3F8, magic // 0x26E, total number of free inodes
public UInt32 s_type; // 0x3FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk, 3 = 2048 bytes/blk) public UInt16 s_cylblks;
// 0x270, blocks per cylinder
public UInt16 s_gapblks;
// 0x272, blocks per gap
public UInt16 s_dinfo0;
// 0x274, device information ??
public UInt16 s_dinfo1;
// 0x276, device information ??
public string s_fname;
// 0x278, 6 bytes, volume name
public string s_fpack;
// 0x27E, 6 bytes, pack name
public byte s_clean;
// 0x284, 0x46 if volume is clean
public byte[] s_fill;
// 0x285, 371 bytes
public UInt32 s_magic;
// 0x3F8, magic
public UInt32 s_type;
// 0x3FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk, 3 = 2048 bytes/blk)
} }
private struct SystemVRelease4SuperBlock struct SystemVRelease4SuperBlock
{ {
public UInt16 s_isize; // 0x000, index of first data zone public UInt16 s_isize;
public UInt16 s_pad0; // 0x002, padding // 0x000, index of first data zone
public UInt32 s_fsize; // 0x004, total number of zones of this volume public UInt16 s_pad0;
// 0x002, padding
public UInt32 s_fsize;
// 0x004, total number of zones of this volume
// the start of the free block list: // the start of the free block list:
public UInt16 s_nfree; // 0x008, blocks in s_free, <=100 public UInt16 s_nfree;
public UInt16 s_pad1; // 0x00A, padding // 0x008, blocks in s_free, <=100
public UInt32[] s_free; // 0x00C, 50 entries, first free block list chunk public UInt16 s_pad1;
// 0x00A, padding
public UInt32[] s_free;
// 0x00C, 50 entries, first free block list chunk
// the cache of free inodes: // the cache of free inodes:
public UInt16 s_ninode; // 0x0D4, number of inodes in s_inode, <= 100 public UInt16 s_ninode;
public UInt16 s_pad2; // 0x0D6, padding // 0x0D4, number of inodes in s_inode, <= 100
public UInt16[] s_inode; // 0x0D8, 100 entries, some free inodes public UInt16 s_pad2;
public byte s_flock; // 0x1A0, free block list manipulation lock // 0x0D6, padding
public byte s_ilock; // 0x1A1, inode cache manipulation lock public UInt16[] s_inode;
public byte s_fmod; // 0x1A2, superblock modification flag // 0x0D8, 100 entries, some free inodes
public byte s_ronly; // 0x1A3, read-only mounted flag public byte s_flock;
public UInt32 s_time; // 0x1A4, time of last superblock update // 0x1A0, free block list manipulation lock
public UInt16 s_cylblks; // 0x1A8, blocks per cylinder public byte s_ilock;
public UInt16 s_gapblks; // 0x1AA, blocks per gap // 0x1A1, inode cache manipulation lock
public UInt16 s_dinfo0; // 0x1AC, device information ?? public byte s_fmod;
public UInt16 s_dinfo1; // 0x1AE, device information ?? // 0x1A2, superblock modification flag
public UInt32 s_tfree; // 0x1B0, total number of free zones public byte s_ronly;
public UInt16 s_tinode; // 0x1B4, total number of free inodes // 0x1A3, read-only mounted flag
public UInt16 s_pad3; // 0x1B6, padding public UInt32 s_time;
public string s_fname; // 0x1B8, 6 bytes, volume name // 0x1A4, time of last superblock update
public string s_fpack; // 0x1BE, 6 bytes, pack name public UInt16 s_cylblks;
public byte[] s_fill; // 0x1C4, 48 bytes // 0x1A8, blocks per cylinder
public UInt32 s_state; // 0x1F4, if s_state == (0x7C269D38 - s_time) then filesystem is clean public UInt16 s_gapblks;
public UInt32 s_magic; // 0x1F8, magic // 0x1AA, blocks per gap
public UInt32 s_type; // 0x1FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk) public UInt16 s_dinfo0;
// 0x1AC, device information ??
public UInt16 s_dinfo1;
// 0x1AE, device information ??
public UInt32 s_tfree;
// 0x1B0, total number of free zones
public UInt16 s_tinode;
// 0x1B4, total number of free inodes
public UInt16 s_pad3;
// 0x1B6, padding
public string s_fname;
// 0x1B8, 6 bytes, volume name
public string s_fpack;
// 0x1BE, 6 bytes, pack name
public byte[] s_fill;
// 0x1C4, 48 bytes
public UInt32 s_state;
// 0x1F4, if s_state == (0x7C269D38 - s_time) then filesystem is clean
public UInt32 s_magic;
// 0x1F8, magic
public UInt32 s_type;
// 0x1FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk)
} }
private struct SystemVRelease2SuperBlock struct SystemVRelease2SuperBlock
{ {
public UInt16 s_isize; // 0x000, index of first data zone public UInt16 s_isize;
public UInt32 s_fsize; // 0x002, total number of zones of this volume // 0x000, index of first data zone
public UInt32 s_fsize;
// 0x002, total number of zones of this volume
// the start of the free block list: // the start of the free block list:
public UInt16 s_nfree; // 0x006, blocks in s_free, <=100 public UInt16 s_nfree;
public UInt32[] s_free; // 0x008, 50 entries, first free block list chunk // 0x006, blocks in s_free, <=100
public UInt32[] s_free;
// 0x008, 50 entries, first free block list chunk
// the cache of free inodes: // the cache of free inodes:
public UInt16 s_ninode; // 0x0D0, number of inodes in s_inode, <= 100 public UInt16 s_ninode;
public UInt16[] s_inode; // 0x0D2, 100 entries, some free inodes // 0x0D0, number of inodes in s_inode, <= 100
public byte s_flock; // 0x19A, free block list manipulation lock public UInt16[] s_inode;
public byte s_ilock; // 0x19B, inode cache manipulation lock // 0x0D2, 100 entries, some free inodes
public byte s_fmod; // 0x19C, superblock modification flag public byte s_flock;
public byte s_ronly; // 0x19D, read-only mounted flag // 0x19A, free block list manipulation lock
public UInt32 s_time; // 0x19E, time of last superblock update public byte s_ilock;
public UInt16 s_cylblks; // 0x1A2, blocks per cylinder // 0x19B, inode cache manipulation lock
public UInt16 s_gapblks; // 0x1A4, blocks per gap public byte s_fmod;
public UInt16 s_dinfo0; // 0x1A6, device information ?? // 0x19C, superblock modification flag
public UInt16 s_dinfo1; // 0x1A8, device information ?? public byte s_ronly;
public UInt32 s_tfree; // 0x1AA, total number of free zones // 0x19D, read-only mounted flag
public UInt16 s_tinode; // 0x1AE, total number of free inodes public UInt32 s_time;
public string s_fname; // 0x1B0, 6 bytes, volume name // 0x19E, time of last superblock update
public string s_fpack; // 0x1B6, 6 bytes, pack name public UInt16 s_cylblks;
public byte[] s_fill; // 0x1BC, 56 bytes // 0x1A2, blocks per cylinder
public UInt32 s_state; // 0x1F4, if s_state == (0x7C269D38 - s_time) then filesystem is clean public UInt16 s_gapblks;
public UInt32 s_magic; // 0x1F8, magic // 0x1A4, blocks per gap
public UInt32 s_type; // 0x1FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk) public UInt16 s_dinfo0;
// 0x1A6, device information ??
public UInt16 s_dinfo1;
// 0x1A8, device information ??
public UInt32 s_tfree;
// 0x1AA, total number of free zones
public UInt16 s_tinode;
// 0x1AE, total number of free inodes
public string s_fname;
// 0x1B0, 6 bytes, volume name
public string s_fpack;
// 0x1B6, 6 bytes, pack name
public byte[] s_fill;
// 0x1BC, 56 bytes
public UInt32 s_state;
// 0x1F4, if s_state == (0x7C269D38 - s_time) then filesystem is clean
public UInt32 s_magic;
// 0x1F8, magic
public UInt32 s_type;
// 0x1FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk)
} }
private struct UNIX7thEditionSuperBlock struct UNIX7thEditionSuperBlock
{ {
public UInt16 s_isize; // 0x000, index of first data zone public UInt16 s_isize;
public UInt32 s_fsize; // 0x002, total number of zones of this volume // 0x000, index of first data zone
public UInt32 s_fsize;
// 0x002, total number of zones of this volume
// the start of the free block list: // the start of the free block list:
public UInt16 s_nfree; // 0x006, blocks in s_free, <=100 public UInt16 s_nfree;
public UInt32[] s_free; // 0x008, 50 entries, first free block list chunk // 0x006, blocks in s_free, <=100
public UInt32[] s_free;
// 0x008, 50 entries, first free block list chunk
// the cache of free inodes: // the cache of free inodes:
public UInt16 s_ninode; // 0x0D0, number of inodes in s_inode, <= 100 public UInt16 s_ninode;
public UInt16[] s_inode; // 0x0D2, 100 entries, some free inodes // 0x0D0, number of inodes in s_inode, <= 100
public byte s_flock; // 0x19A, free block list manipulation lock public UInt16[] s_inode;
public byte s_ilock; // 0x19B, inode cache manipulation lock // 0x0D2, 100 entries, some free inodes
public byte s_fmod; // 0x19C, superblock modification flag public byte s_flock;
public byte s_ronly; // 0x19D, read-only mounted flag // 0x19A, free block list manipulation lock
public UInt32 s_time; // 0x19E, time of last superblock update public byte s_ilock;
public UInt32 s_tfree; // 0x1A2, total number of free zones // 0x19B, inode cache manipulation lock
public UInt16 s_tinode; // 0x1A6, total number of free inodes public byte s_fmod;
public UInt16 s_int_m; // 0x1A8, interleave factor // 0x19C, superblock modification flag
public UInt16 s_int_n; // 0x1AA, interleave factor public byte s_ronly;
public string s_fname; // 0x1AC, 6 bytes, volume name // 0x19D, read-only mounted flag
public string s_fpack; // 0x1B2, 6 bytes, pack name public UInt32 s_time;
// 0x19E, time of last superblock update
public UInt32 s_tfree;
// 0x1A2, total number of free zones
public UInt16 s_tinode;
// 0x1A6, total number of free inodes
public UInt16 s_int_m;
// 0x1A8, interleave factor
public UInt16 s_int_n;
// 0x1AA, interleave factor
public string s_fname;
// 0x1AC, 6 bytes, volume name
public string s_fpack;
// 0x1B2, 6 bytes, pack name
} }
private struct CoherentSuperBlock struct CoherentSuperBlock
{ {
public UInt16 s_isize; // 0x000, index of first data zone public UInt16 s_isize;
public UInt32 s_fsize; // 0x002, total number of zones of this volume // 0x000, index of first data zone
public UInt32 s_fsize;
// 0x002, total number of zones of this volume
// the start of the free block list: // the start of the free block list:
public UInt16 s_nfree; // 0x006, blocks in s_free, <=100 public UInt16 s_nfree;
public UInt32[] s_free; // 0x008, 64 entries, first free block list chunk // 0x006, blocks in s_free, <=100
public UInt32[] s_free;
// 0x008, 64 entries, first free block list chunk
// the cache of free inodes: // the cache of free inodes:
public UInt16 s_ninode; // 0x108, number of inodes in s_inode, <= 100 public UInt16 s_ninode;
public UInt16[] s_inode; // 0x10A, 100 entries, some free inodes // 0x108, number of inodes in s_inode, <= 100
public byte s_flock; // 0x1D2, free block list manipulation lock public UInt16[] s_inode;
public byte s_ilock; // 0x1D3, inode cache manipulation lock // 0x10A, 100 entries, some free inodes
public byte s_fmod; // 0x1D4, superblock modification flag public byte s_flock;
public byte s_ronly; // 0x1D5, read-only mounted flag // 0x1D2, free block list manipulation lock
public UInt32 s_time; // 0x1D6, time of last superblock update public byte s_ilock;
public UInt32 s_tfree; // 0x1DE, total number of free zones // 0x1D3, inode cache manipulation lock
public UInt16 s_tinode; // 0x1E2, total number of free inodes public byte s_fmod;
public UInt16 s_int_m; // 0x1E4, interleave factor // 0x1D4, superblock modification flag
public UInt16 s_int_n; // 0x1E6, interleave factor public byte s_ronly;
public string s_fname; // 0x1E8, 6 bytes, volume name // 0x1D5, read-only mounted flag
public string s_fpack; // 0x1EE, 6 bytes, pack name public UInt32 s_time;
public UInt32 s_unique; // 0x1F4, zero-filled // 0x1D6, time of last superblock update
public UInt32 s_tfree;
// 0x1DE, total number of free zones
public UInt16 s_tinode;
// 0x1E2, total number of free inodes
public UInt16 s_int_m;
// 0x1E4, interleave factor
public UInt16 s_int_n;
// 0x1E6, interleave factor
public string s_fname;
// 0x1E8, 6 bytes, volume name
public string s_fpack;
// 0x1EE, 6 bytes, pack name
public UInt32 s_unique;
// 0x1F4, zero-filled
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -7,12 +6,12 @@ namespace FileSystemIDandChk.Plugins
{ {
class BFS : Plugin class BFS : Plugin
{ {
private const UInt32 BFS_MAGIC = 0x1BADFACE; const UInt32 BFS_MAGIC = 0x1BADFACE;
public BFS(PluginBase Core) public BFS(PluginBase Core)
{ {
base.Name = "UNIX Boot filesystem"; Name = "UNIX Boot filesystem";
base.PluginUUID = new Guid("1E6E0DA6-F7E4-494C-80C6-CB5929E96155"); PluginUUID = new Guid("1E6E0DA6-F7E4-494C-80C6-CB5929E96155");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -21,10 +20,7 @@ namespace FileSystemIDandChk.Plugins
magic = BitConverter.ToUInt32(imagePlugin.ReadSector(0 + partitionOffset), 0); magic = BitConverter.ToUInt32(imagePlugin.ReadSector(0 + partitionOffset), 0);
if(magic == BFS_MAGIC) return magic == BFS_MAGIC;
return true;
else
return false;
} }
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information) public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
@@ -70,17 +66,26 @@ namespace FileSystemIDandChk.Plugins
information = sb.ToString(); information = sb.ToString();
} }
private struct BFSSuperBlock struct BFSSuperBlock
{ {
public UInt32 s_magic; // 0x00, 0x1BADFACE public UInt32 s_magic;
public UInt32 s_start; // 0x04, start in bytes of volume // 0x00, 0x1BADFACE
public UInt32 s_end; // 0x08, end in bytes of volume public UInt32 s_start;
public UInt32 s_from; // 0x0C, unknown :p // 0x04, start in bytes of volume
public UInt32 s_to; // 0x10, unknown :p public UInt32 s_end;
public Int32 s_bfrom; // 0x14, unknown :p // 0x08, end in bytes of volume
public Int32 s_bto; // 0x18, unknown :p public UInt32 s_from;
public string s_fsname; // 0x1C, 6 bytes, filesystem name // 0x0C, unknown :p
public string s_volume; // 0x22, 6 bytes, volume name public UInt32 s_to;
// 0x10, unknown :p
public Int32 s_bfrom;
// 0x14, unknown :p
public Int32 s_bto;
// 0x18, unknown :p
public string s_fsname;
// 0x1C, 6 bytes, filesystem name
public string s_volume;
// 0x22, 6 bytes, volume name
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -9,8 +8,8 @@ namespace FileSystemIDandChk.Plugins
{ {
public ext2FS(PluginBase Core) public ext2FS(PluginBase Core)
{ {
base.Name = "Linux extended Filesystem 2, 3 and 4"; Name = "Linux extended Filesystem 2, 3 and 4";
base.PluginUUID = new Guid("6AA91B88-150B-4A7B-AD56-F84FB2DF4184"); PluginUUID = new Guid("6AA91B88-150B-4A7B-AD56-F84FB2DF4184");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -21,7 +20,6 @@ namespace FileSystemIDandChk.Plugins
if (magic == ext2FSMagic || magic == ext2OldFSMagic) if (magic == ext2FSMagic || magic == ext2OldFSMagic)
return true; return true;
else
return false; return false;
} }
@@ -33,7 +31,6 @@ namespace FileSystemIDandChk.Plugins
ext2FSSuperBlock supblk = new ext2FSSuperBlock(); ext2FSSuperBlock supblk = new ext2FSSuperBlock();
byte[] forstrings; byte[] forstrings;
bool old_ext2 = false;
bool new_ext2 = false; bool new_ext2 = false;
bool ext3 = false; bool ext3 = false;
bool ext4 = false; bool ext4 = false;
@@ -41,14 +38,15 @@ namespace FileSystemIDandChk.Plugins
byte[] guid_a = new byte[16]; byte[] guid_a = new byte[16];
byte[] guid_b = new byte[16]; byte[] guid_b = new byte[16];
uint sb_size_in_sectors = 0; uint sb_size_in_sectors;
if (imagePlugin.GetSectorSize() < 1024) if (imagePlugin.GetSectorSize() < 1024)
sb_size_in_sectors = 1024 / imagePlugin.GetSectorSize(); sb_size_in_sectors = 1024 / imagePlugin.GetSectorSize();
else else
sb_size_in_sectors = 1; sb_size_in_sectors = 1;
if (sb_size_in_sectors == 0) { if (sb_size_in_sectors == 0)
{
information = "Error calculating size in sectors of ext2/3/4 superblocks"; information = "Error calculating size in sectors of ext2/3/4 superblocks";
return; return;
} }
@@ -187,17 +185,11 @@ namespace FileSystemIDandChk.Plugins
if (supblk.magic == ext2OldFSMagic) if (supblk.magic == ext2OldFSMagic)
{ {
old_ext2 = true;
sb.AppendLine("ext2 (old) filesystem"); sb.AppendLine("ext2 (old) filesystem");
} }
else if (supblk.magic == ext2FSMagic) else if (supblk.magic == ext2FSMagic)
{ {
if((supblk.ftr_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) == EXT3_FEATURE_COMPAT_HAS_JOURNAL || ext3 |= (supblk.ftr_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) == EXT3_FEATURE_COMPAT_HAS_JOURNAL || (supblk.ftr_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) == EXT3_FEATURE_INCOMPAT_RECOVER || (supblk.ftr_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) == EXT3_FEATURE_INCOMPAT_JOURNAL_DEV;
(supblk.ftr_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) == EXT3_FEATURE_INCOMPAT_RECOVER ||
(supblk.ftr_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) == EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)
{
ext3 = true;
}
if ((supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE) == EXT4_FEATURE_RO_COMPAT_HUGE_FILE || if ((supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE) == EXT4_FEATURE_RO_COMPAT_HUGE_FILE ||
(supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) == EXT4_FEATURE_RO_COMPAT_GDT_CSUM || (supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) == EXT4_FEATURE_RO_COMPAT_GDT_CSUM ||
@@ -213,8 +205,7 @@ namespace FileSystemIDandChk.Plugins
ext4 = true; ext4 = true;
} }
if(ext3 == false && ext4 == false) new_ext2 |= !ext3 && !ext4;
new_ext2 = true;
if (new_ext2) if (new_ext2)
sb.AppendLine("ext2 filesystem"); sb.AppendLine("ext2 filesystem");
@@ -225,7 +216,7 @@ namespace FileSystemIDandChk.Plugins
} }
else else
{ {
information = "Not a ext2/3/4 filesystem" + System.Environment.NewLine; information = "Not a ext2/3/4 filesystem" + Environment.NewLine;
return; return;
} }
@@ -248,7 +239,7 @@ namespace FileSystemIDandChk.Plugins
ext_os = "MasIX"; ext_os = "MasIX";
break; break;
default: default:
ext_os = "Unknown OS (" + supblk.creator_os.ToString() + ")"; ext_os = string.Format("Unknown OS ({0})", supblk.creator_os);
break; break;
} }
@@ -457,7 +448,7 @@ namespace FileSystemIDandChk.Plugins
} }
} }
sb.AppendFormat("Flags…:", supblk.flags).AppendLine(); sb.AppendFormat("Flags…:").AppendLine();
if ((supblk.flags & EXT2_FLAGS_SIGNED_HASH) == EXT2_FLAGS_SIGNED_HASH) if ((supblk.flags & EXT2_FLAGS_SIGNED_HASH) == EXT2_FLAGS_SIGNED_HASH)
sb.AppendLine("Signed directory hash is in use"); sb.AppendLine("Signed directory hash is in use");
if ((supblk.flags & EXT2_FLAGS_UNSIGNED_HASH) == EXT2_FLAGS_UNSIGNED_HASH) if ((supblk.flags & EXT2_FLAGS_UNSIGNED_HASH) == EXT2_FLAGS_UNSIGNED_HASH)
@@ -469,7 +460,7 @@ namespace FileSystemIDandChk.Plugins
sb.AppendLine(); sb.AppendLine();
sb.AppendFormat("Default mount options…:", supblk.default_mnt_opts).AppendLine(); sb.AppendFormat("Default mount options…:").AppendLine();
if ((supblk.default_mnt_opts & EXT2_DEFM_DEBUG) == EXT2_DEFM_DEBUG) if ((supblk.default_mnt_opts & EXT2_DEFM_DEBUG) == EXT2_DEFM_DEBUG)
sb.AppendLine("(debug): Enable debugging code"); sb.AppendLine("(debug): Enable debugging code");
if ((supblk.default_mnt_opts & EXT2_DEFM_BSDGROUPS) == EXT2_DEFM_BSDGROUPS) if ((supblk.default_mnt_opts & EXT2_DEFM_BSDGROUPS) == EXT2_DEFM_BSDGROUPS)
@@ -491,7 +482,7 @@ namespace FileSystemIDandChk.Plugins
sb.AppendLine(); sb.AppendLine();
sb.AppendFormat("Compatible features…:", supblk.ftr_compat).AppendLine(); sb.AppendFormat("Compatible features…:").AppendLine();
if ((supblk.ftr_compat & EXT2_FEATURE_COMPAT_DIR_PREALLOC) == EXT2_FEATURE_COMPAT_DIR_PREALLOC) if ((supblk.ftr_compat & EXT2_FEATURE_COMPAT_DIR_PREALLOC) == EXT2_FEATURE_COMPAT_DIR_PREALLOC)
sb.AppendLine("Pre-allocate directories"); sb.AppendLine("Pre-allocate directories");
if ((supblk.ftr_compat & EXT2_FEATURE_COMPAT_IMAGIC_INODES) == EXT2_FEATURE_COMPAT_IMAGIC_INODES) if ((supblk.ftr_compat & EXT2_FEATURE_COMPAT_IMAGIC_INODES) == EXT2_FEATURE_COMPAT_IMAGIC_INODES)
@@ -509,7 +500,7 @@ namespace FileSystemIDandChk.Plugins
sb.AppendLine(); sb.AppendLine();
sb.AppendFormat("Compatible features if read-only…:", supblk.ftr_ro_compat).AppendLine(); sb.AppendFormat("Compatible features if read-only…:").AppendLine();
if ((supblk.ftr_ro_compat & EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) == EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) if ((supblk.ftr_ro_compat & EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) == EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)
sb.AppendLine("Reduced number of superblocks"); sb.AppendLine("Reduced number of superblocks");
if ((supblk.ftr_ro_compat & EXT2_FEATURE_RO_COMPAT_LARGE_FILE) == EXT2_FEATURE_RO_COMPAT_LARGE_FILE) if ((supblk.ftr_ro_compat & EXT2_FEATURE_RO_COMPAT_LARGE_FILE) == EXT2_FEATURE_RO_COMPAT_LARGE_FILE)
@@ -529,7 +520,7 @@ namespace FileSystemIDandChk.Plugins
sb.AppendLine(); sb.AppendLine();
sb.AppendFormat("Incompatible features…:", supblk.ftr_incompat).AppendLine(); sb.AppendFormat("Incompatible features…:").AppendLine();
if ((supblk.ftr_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION) == EXT2_FEATURE_INCOMPAT_COMPRESSION) if ((supblk.ftr_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION) == EXT2_FEATURE_INCOMPAT_COMPRESSION)
sb.AppendLine("Uses compression"); sb.AppendLine("Uses compression");
if ((supblk.ftr_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE) == EXT2_FEATURE_INCOMPAT_FILETYPE) if ((supblk.ftr_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE) == EXT2_FEATURE_INCOMPAT_FILETYPE)
@@ -558,172 +549,288 @@ namespace FileSystemIDandChk.Plugins
information = sb.ToString(); information = sb.ToString();
} }
public const UInt16 ext2FSMagic = 0xEF53; // Same for ext3 and ext4 public const UInt16 ext2FSMagic = 0xEF53;
// Same for ext3 and ext4
public const UInt16 ext2OldFSMagic = 0xEF51; public const UInt16 ext2OldFSMagic = 0xEF51;
// Size = 536 bytes // Size = 536 bytes
public struct ext2FSSuperBlock public struct ext2FSSuperBlock
{ {
public UInt32 inodes; // 0x000, inodes on volume public UInt32 inodes;
public UInt32 blocks; // 0x004, blocks on volume // 0x000, inodes on volume
public UInt32 reserved_blocks; // 0x008, reserved blocks public UInt32 blocks;
public UInt32 free_blocks; // 0x00C, free blocks count // 0x004, blocks on volume
public UInt32 free_inodes; // 0x010, free inodes count public UInt32 reserved_blocks;
public UInt32 first_block; // 0x014, first data block // 0x008, reserved blocks
public UInt32 block_size; // 0x018, block size public UInt32 free_blocks;
public Int32 frag_size; // 0x01C, fragment size // 0x00C, free blocks count
public UInt32 blocks_per_grp; // 0x020, blocks per group public UInt32 free_inodes;
public UInt32 flags_per_grp; // 0x024, fragments per group // 0x010, free inodes count
public UInt32 inodes_per_grp; // 0x028, inodes per group public UInt32 first_block;
public UInt32 mount_t; // 0x02C, last mount time // 0x014, first data block
public UInt32 write_t; // 0x030, last write time public UInt32 block_size;
public UInt16 mount_c; // 0x034, mounts count // 0x018, block size
public Int16 max_mount_c; // 0x036, max mounts public Int32 frag_size;
public UInt16 magic; // 0x038, (little endian) // 0x01C, fragment size
public UInt16 state; // 0x03A, filesystem state public UInt32 blocks_per_grp;
public UInt16 err_behaviour; // 0x03C, behaviour on errors // 0x020, blocks per group
public UInt16 minor_revision; // 0x03E, From 0.5b onward public UInt32 flags_per_grp;
public UInt32 check_t; // 0x040, last check time // 0x024, fragments per group
public UInt32 check_inv; // 0x044, max time between checks public UInt32 inodes_per_grp;
// 0x028, inodes per group
public UInt32 mount_t;
// 0x02C, last mount time
public UInt32 write_t;
// 0x030, last write time
public UInt16 mount_c;
// 0x034, mounts count
public Int16 max_mount_c;
// 0x036, max mounts
public UInt16 magic;
// 0x038, (little endian)
public UInt16 state;
// 0x03A, filesystem state
public UInt16 err_behaviour;
// 0x03C, behaviour on errors
public UInt16 minor_revision;
// 0x03E, From 0.5b onward
public UInt32 check_t;
// 0x040, last check time
public UInt32 check_inv;
// 0x044, max time between checks
// From 0.5a onward // From 0.5a onward
public UInt32 creator_os; // 0x048, Creation OS public UInt32 creator_os;
public UInt32 revision; // 0x04C, Revison level // 0x048, Creation OS
public UInt16 default_uid; // 0x050, Default UID for reserved blocks public UInt32 revision;
public UInt16 default_gid; // 0x052, Default GID for reserved blocks // 0x04C, Revison level
public UInt16 default_uid;
// 0x050, Default UID for reserved blocks
public UInt16 default_gid;
// 0x052, Default GID for reserved blocks
// From 0.5b onward // From 0.5b onward
public UInt32 first_inode; // 0x054, First unreserved inode public UInt32 first_inode;
public UInt16 inode_size; // 0x058, inode size // 0x054, First unreserved inode
public UInt16 block_group_no; // 0x05A, Block group number of THIS superblock public UInt16 inode_size;
public UInt32 ftr_compat; // 0x05C, Compatible features set // 0x058, inode size
public UInt32 ftr_incompat; // 0x060, Incompatible features set public UInt16 block_group_no;
// 0x05A, Block group number of THIS superblock
public UInt32 ftr_compat;
// 0x05C, Compatible features set
public UInt32 ftr_incompat;
// 0x060, Incompatible features set
// Found on Linux 2.0.40 // Found on Linux 2.0.40
public UInt32 ftr_ro_compat; // 0x064, Read-only compatible features set public UInt32 ftr_ro_compat;
// 0x064, Read-only compatible features set
// Found on Linux 2.1.132 // Found on Linux 2.1.132
public Guid uuid; // 0x068, 16 bytes, UUID public Guid uuid;
public string volume_name; // 0x078, 16 bytes, volume name // 0x068, 16 bytes, UUID
public string last_mount_dir; // 0x088, 64 bytes, where last mounted public string volume_name;
public UInt32 algo_usage_bmp; // 0x0C8, Usage bitmap algorithm, for compression // 0x078, 16 bytes, volume name
public byte prealloc_blks; // 0x0CC, Block to try to preallocate public string last_mount_dir;
public byte prealloc_dir_blks; // 0x0CD, Blocks to try to preallocate for directories // 0x088, 64 bytes, where last mounted
public UInt16 rsrvd_gdt_blocks; // 0x0CE, Per-group desc for online growth public UInt32 algo_usage_bmp;
// 0x0C8, Usage bitmap algorithm, for compression
public byte prealloc_blks;
// 0x0CC, Block to try to preallocate
public byte prealloc_dir_blks;
// 0x0CD, Blocks to try to preallocate for directories
public UInt16 rsrvd_gdt_blocks;
// 0x0CE, Per-group desc for online growth
// Found on Linux 2.4 // Found on Linux 2.4
// ext3 // ext3
public Guid journal_uuid; // 0x0D0, 16 bytes, UUID of journal superblock public Guid journal_uuid;
public UInt32 journal_inode; // 0x0E0, inode no. of journal file // 0x0D0, 16 bytes, UUID of journal superblock
public UInt32 journal_dev; // 0x0E4, device no. of journal file public UInt32 journal_inode;
public UInt32 last_orphan; // 0x0E8, Start of list of inodes to delete // 0x0E0, inode no. of journal file
public UInt32 hash_seed_1; // 0x0EC, First byte of 128bit HTREE hash seed public UInt32 journal_dev;
public UInt32 hash_seed_2; // 0x0F0, Second byte of 128bit HTREE hash seed // 0x0E4, device no. of journal file
public UInt32 hash_seed_3; // 0x0F4, Third byte of 128bit HTREE hash seed public UInt32 last_orphan;
public UInt32 hash_seed_4; // 0x0F8, Fourth byte of 128bit HTREE hash seed // 0x0E8, Start of list of inodes to delete
public byte hash_version; // 0x0FC, Hash version public UInt32 hash_seed_1;
public byte jnl_backup_type; // 0x0FD, Journal backup type // 0x0EC, First byte of 128bit HTREE hash seed
public UInt16 desc_grp_size; // 0x0FE, Size of group descriptor public UInt32 hash_seed_2;
public UInt32 default_mnt_opts; // 0x100, Default mount options // 0x0F0, Second byte of 128bit HTREE hash seed
public UInt32 first_meta_bg; // 0x104, First metablock block group public UInt32 hash_seed_3;
// 0x0F4, Third byte of 128bit HTREE hash seed
public UInt32 hash_seed_4;
// 0x0F8, Fourth byte of 128bit HTREE hash seed
public byte hash_version;
// 0x0FC, Hash version
public byte jnl_backup_type;
// 0x0FD, Journal backup type
public UInt16 desc_grp_size;
// 0x0FE, Size of group descriptor
public UInt32 default_mnt_opts;
// 0x100, Default mount options
public UInt32 first_meta_bg;
// 0x104, First metablock block group
// Introduced with ext4, some can be ext3 // Introduced with ext4, some can be ext3
public UInt32 mkfs_t; // 0x108, Filesystem creation time public UInt32 mkfs_t;
// 0x108, Filesystem creation time
// Follows 17 uint32 (68 bytes) of journal inode backup // Follows 17 uint32 (68 bytes) of journal inode backup
// Following 3 fields are valid if EXT4_FEATURE_COMPAT_64BIT is set // Following 3 fields are valid if EXT4_FEATURE_COMPAT_64BIT is set
public UInt32 blocks_hi; // 0x14C, High 32bits of blocks no. public UInt32 blocks_hi;
public UInt32 reserved_blocks_hi; // 0x150, High 32bits of reserved blocks no. // 0x14C, High 32bits of blocks no.
public UInt32 free_blocks_hi; // 0x154, High 32bits of free blocks no. public UInt32 reserved_blocks_hi;
public UInt16 min_inode_size; // 0x158, inodes minimal size in bytes // 0x150, High 32bits of reserved blocks no.
public UInt16 rsv_inode_size; // 0x15A, Bytes reserved by new inodes public UInt32 free_blocks_hi;
public UInt32 flags; // 0x15C, Flags // 0x154, High 32bits of free blocks no.
public UInt16 raid_stride; // 0x160, RAID stride public UInt16 min_inode_size;
public UInt16 mmp_interval; // 0x162, Waiting seconds in MMP check // 0x158, inodes minimal size in bytes
public UInt64 mmp_block; // 0x164, Block for multi-mount protection public UInt16 rsv_inode_size;
public UInt32 raid_stripe_width; // 0x16C, Blocks on all data disks (N*stride) // 0x15A, Bytes reserved by new inodes
public byte flex_bg_grp_size; // 0x170, FLEX_BG group size public UInt32 flags;
public byte padding; // 0x171 // 0x15C, Flags
public UInt16 padding2; // 0x172 public UInt16 raid_stride;
// 0x160, RAID stride
public UInt16 mmp_interval;
// 0x162, Waiting seconds in MMP check
public UInt64 mmp_block;
// 0x164, Block for multi-mount protection
public UInt32 raid_stripe_width;
// 0x16C, Blocks on all data disks (N*stride)
public byte flex_bg_grp_size;
// 0x170, FLEX_BG group size
public byte padding;
// 0x171
public UInt16 padding2;
// 0x172
// Following are introduced with ext4 // Following are introduced with ext4
public UInt64 kbytes_written; // 0x174, Kibibytes written in volume lifetime public UInt64 kbytes_written;
public UInt32 snapshot_inum; // 0x17C, Active snapshot inode number // 0x174, Kibibytes written in volume lifetime
public UInt32 snapshot_id; // 0x180, Active snapshot sequential ID public UInt32 snapshot_inum;
public UInt64 snapshot_blocks; // 0x184, Reserved blocks for active snapshot's future use // 0x17C, Active snapshot inode number
public UInt32 snapshot_list; // 0x18C, inode number of the on-disk start of the snapshot list public UInt32 snapshot_id;
// 0x180, Active snapshot sequential ID
public UInt64 snapshot_blocks;
// 0x184, Reserved blocks for active snapshot's future use
public UInt32 snapshot_list;
// 0x18C, inode number of the on-disk start of the snapshot list
// Optional ext4 error-handling features // Optional ext4 error-handling features
public UInt32 error_count; // 0x190, total registered filesystem errors public UInt32 error_count;
public UInt32 first_error_t; // 0x194, time on first error // 0x190, total registered filesystem errors
public UInt32 first_error_inode; // 0x198, inode involved in first error public UInt32 first_error_t;
public UInt64 first_error_block; // 0x19C, block involved of first error // 0x194, time on first error
public string first_error_func; // 0x1A0, 32 bytes, function where the error happened public UInt32 first_error_inode;
public UInt32 first_error_line; // 0x1B0, line number where error happened // 0x198, inode involved in first error
public UInt32 last_error_t; // 0x1B4, time of most recent error public UInt64 first_error_block;
public UInt32 last_error_inode; // 0x1B8, inode involved in last error // 0x19C, block involved of first error
public UInt32 last_error_line; // 0x1BC, line number where error happened public string first_error_func;
public UInt64 last_error_block; // 0x1C0, block involved of last error // 0x1A0, 32 bytes, function where the error happened
public string last_error_func; // 0x1C8, 32 bytes, function where the error happened public UInt32 first_error_line;
// 0x1B0, line number where error happened
public UInt32 last_error_t;
// 0x1B4, time of most recent error
public UInt32 last_error_inode;
// 0x1B8, inode involved in last error
public UInt32 last_error_line;
// 0x1BC, line number where error happened
public UInt64 last_error_block;
// 0x1C0, block involved of last error
public string last_error_func;
// 0x1C8, 32 bytes, function where the error happened
// End of optional error-handling features // End of optional error-handling features
public string mount_options; // 0x1D8, 64 bytes, last used mount options public string mount_options;
// 0x1D8, 64 bytes, last used mount options
} }
// ext? filesystem states // ext? filesystem states
public const UInt16 EXT2_VALID_FS = 0x0001; // Cleanly-unmounted volume public const UInt16 EXT2_VALID_FS = 0x0001;
public const UInt16 EXT2_ERROR_FS = 0x0002; // Dirty volume // Cleanly-unmounted volume
public const UInt16 EXT3_ORPHAN_FS = 0x0004; // Recovering orphan files public const UInt16 EXT2_ERROR_FS = 0x0002;
// Dirty volume
public const UInt16 EXT3_ORPHAN_FS = 0x0004;
// Recovering orphan files
// ext? default mount flags // ext? default mount flags
public const UInt32 EXT2_DEFM_DEBUG = 0x000001; // Enable debugging messages public const UInt32 EXT2_DEFM_DEBUG = 0x000001;
public const UInt32 EXT2_DEFM_BSDGROUPS = 0x000002; // Emulates BSD behaviour on new file creation // Enable debugging messages
public const UInt32 EXT2_DEFM_XATTR_USER = 0x000004; // Enable user xattrs public const UInt32 EXT2_DEFM_BSDGROUPS = 0x000002;
public const UInt32 EXT2_DEFM_ACL = 0x000008; // Enable POSIX ACLs // Emulates BSD behaviour on new file creation
public const UInt32 EXT2_DEFM_UID16 = 0x000010; // Use 16bit UIDs public const UInt32 EXT2_DEFM_XATTR_USER = 0x000004;
public const UInt32 EXT3_DEFM_JMODE_DATA = 0x000040; // Journal data mode // Enable user xattrs
public const UInt32 EXT3_DEFM_JMODE_ORDERED = 0x000080; // Journal ordered mode public const UInt32 EXT2_DEFM_ACL = 0x000008;
public const UInt32 EXT3_DEFM_JMODE_WBACK = 0x000100; // Journal writeback mode // Enable POSIX ACLs
public const UInt32 EXT2_DEFM_UID16 = 0x000010;
// Use 16bit UIDs
public const UInt32 EXT3_DEFM_JMODE_DATA = 0x000040;
// Journal data mode
public const UInt32 EXT3_DEFM_JMODE_ORDERED = 0x000080;
// Journal ordered mode
public const UInt32 EXT3_DEFM_JMODE_WBACK = 0x000100;
// Journal writeback mode
// Behaviour on errors // Behaviour on errors
public const UInt16 EXT2_ERRORS_CONTINUE = 1; // Continue execution public const UInt16 EXT2_ERRORS_CONTINUE = 1;
public const UInt16 EXT2_ERRORS_RO = 2; // Remount fs read-only // Continue execution
public const UInt16 EXT2_ERRORS_PANIC = 3; // Panic public const UInt16 EXT2_ERRORS_RO = 2;
// Remount fs read-only
public const UInt16 EXT2_ERRORS_PANIC = 3;
// Panic
// OS codes // OS codes
public const UInt32 EXT2_OS_LINUX = 0; public const UInt32 EXT2_OS_LINUX = 0;
public const UInt32 EXT2_OS_HURD = 1; public const UInt32 EXT2_OS_HURD = 1;
public const UInt32 EXT2_OS_MASIX = 2; public const UInt32 EXT2_OS_MASIX = 2;
public const UInt32 EXT2_OS_FREEBSD = 3; public const UInt32 EXT2_OS_FREEBSD = 3;
public const UInt32 EXT2_OS_LITES = 4; public const UInt32 EXT2_OS_LITES = 4;
// Revision levels // Revision levels
public const UInt32 EXT2_GOOD_OLD_REV = 0; /* The good old (original) format */ public const UInt32 EXT2_GOOD_OLD_REV = 0;
public const UInt32 EXT2_DYNAMIC_REV = 1; /* V2 format w/ dynamic inode sizes */ /* The good old (original) format */
public const UInt32 EXT2_DYNAMIC_REV = 1;
/* V2 format w/ dynamic inode sizes */
// Compatible features // Compatible features
public const UInt32 EXT2_FEATURE_COMPAT_DIR_PREALLOC = 0x00000001; // Pre-allocate directories public const UInt32 EXT2_FEATURE_COMPAT_DIR_PREALLOC = 0x00000001;
public const UInt32 EXT2_FEATURE_COMPAT_IMAGIC_INODES = 0x00000002; // imagic inodes ? // Pre-allocate directories
public const UInt32 EXT3_FEATURE_COMPAT_HAS_JOURNAL = 0x00000004; // Has journal (it's ext3) public const UInt32 EXT2_FEATURE_COMPAT_IMAGIC_INODES = 0x00000002;
public const UInt32 EXT2_FEATURE_COMPAT_EXT_ATTR = 0x00000008; // EA blocks // imagic inodes ?
public const UInt32 EXT2_FEATURE_COMPAT_RESIZE_INO = 0x00000010; // Online filesystem resize reservations public const UInt32 EXT3_FEATURE_COMPAT_HAS_JOURNAL = 0x00000004;
public const UInt32 EXT2_FEATURE_COMPAT_DIR_INDEX = 0x00000020; // Can use hashed indexes on directories // Has journal (it's ext3)
public const UInt32 EXT2_FEATURE_COMPAT_EXT_ATTR = 0x00000008;
// EA blocks
public const UInt32 EXT2_FEATURE_COMPAT_RESIZE_INO = 0x00000010;
// Online filesystem resize reservations
public const UInt32 EXT2_FEATURE_COMPAT_DIR_INDEX = 0x00000020;
// Can use hashed indexes on directories
// Read-only compatible features // Read-only compatible features
public const UInt32 EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER = 0x00000001; // Reduced number of superblocks public const UInt32 EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER = 0x00000001;
public const UInt32 EXT2_FEATURE_RO_COMPAT_LARGE_FILE = 0x00000002; // Can have files bigger than 2GiB // Reduced number of superblocks
public const UInt32 EXT2_FEATURE_RO_COMPAT_BTREE_DIR = 0x00000004; // Use B-Tree for directories public const UInt32 EXT2_FEATURE_RO_COMPAT_LARGE_FILE = 0x00000002;
public const UInt32 EXT4_FEATURE_RO_COMPAT_HUGE_FILE = 0x00000008; // Can have files bigger than 2TiB *ext4* // Can have files bigger than 2GiB
public const UInt32 EXT4_FEATURE_RO_COMPAT_GDT_CSUM = 0x00000010; // Group descriptor checksums and sparse inode table *ext4* public const UInt32 EXT2_FEATURE_RO_COMPAT_BTREE_DIR = 0x00000004;
public const UInt32 EXT4_FEATURE_RO_COMPAT_DIR_NLINK = 0x00000020; // More than 32000 directory entries *ext4* // Use B-Tree for directories
public const UInt32 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE = 0x00000040; // Nanosecond timestamps and creation time *ext4* public const UInt32 EXT4_FEATURE_RO_COMPAT_HUGE_FILE = 0x00000008;
// Can have files bigger than 2TiB *ext4*
public const UInt32 EXT4_FEATURE_RO_COMPAT_GDT_CSUM = 0x00000010;
// Group descriptor checksums and sparse inode table *ext4*
public const UInt32 EXT4_FEATURE_RO_COMPAT_DIR_NLINK = 0x00000020;
// More than 32000 directory entries *ext4*
public const UInt32 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE = 0x00000040;
// Nanosecond timestamps and creation time *ext4*
// Incompatible features // Incompatible features
public const UInt32 EXT2_FEATURE_INCOMPAT_COMPRESSION = 0x00000001; // Uses compression public const UInt32 EXT2_FEATURE_INCOMPAT_COMPRESSION = 0x00000001;
public const UInt32 EXT2_FEATURE_INCOMPAT_FILETYPE = 0x00000002; // Filetype in directory entries // Uses compression
public const UInt32 EXT3_FEATURE_INCOMPAT_RECOVER = 0x00000004; // Journal needs recovery *ext3* public const UInt32 EXT2_FEATURE_INCOMPAT_FILETYPE = 0x00000002;
public const UInt32 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV = 0x00000008; // Has journal on another device *ext3* // Filetype in directory entries
public const UInt32 EXT2_FEATURE_INCOMPAT_META_BG = 0x00000010; // Reduced block group backups public const UInt32 EXT3_FEATURE_INCOMPAT_RECOVER = 0x00000004;
public const UInt32 EXT4_FEATURE_INCOMPAT_EXTENTS = 0x00000040; // Volume use extents *ext4* // Journal needs recovery *ext3*
public const UInt32 EXT4_FEATURE_INCOMPAT_64BIT = 0x00000080; // Supports volumes bigger than 2^32 blocks *ext4* public const UInt32 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV = 0x00000008;
public const UInt32 EXT4_FEATURE_INCOMPAT_MMP = 0x00000100; // Multi-mount protection *ext4* // Has journal on another device *ext3*
public const UInt32 EXT4_FEATURE_INCOMPAT_FLEX_BG = 0x00000200; // Flexible block group metadata location *ext4* public const UInt32 EXT2_FEATURE_INCOMPAT_META_BG = 0x00000010;
public const UInt32 EXT4_FEATURE_INCOMPAT_EA_INODE = 0x00000400; // EA in inode *ext4* // Reduced block group backups
public const UInt32 EXT4_FEATURE_INCOMPAT_DIRDATA = 0x00001000; // Data can reside in directory entry *ext4* public const UInt32 EXT4_FEATURE_INCOMPAT_EXTENTS = 0x00000040;
// Volume use extents *ext4*
public const UInt32 EXT4_FEATURE_INCOMPAT_64BIT = 0x00000080;
// Supports volumes bigger than 2^32 blocks *ext4*
public const UInt32 EXT4_FEATURE_INCOMPAT_MMP = 0x00000100;
// Multi-mount protection *ext4*
public const UInt32 EXT4_FEATURE_INCOMPAT_FLEX_BG = 0x00000200;
// Flexible block group metadata location *ext4*
public const UInt32 EXT4_FEATURE_INCOMPAT_EA_INODE = 0x00000400;
// EA in inode *ext4*
public const UInt32 EXT4_FEATURE_INCOMPAT_DIRDATA = 0x00001000;
// Data can reside in directory entry *ext4*
// Miscellaneous filesystem flags // Miscellaneous filesystem flags
public const UInt32 EXT2_FLAGS_SIGNED_HASH = 0x00000001; // Signed dirhash in use public const UInt32 EXT2_FLAGS_SIGNED_HASH = 0x00000001;
public const UInt32 EXT2_FLAGS_UNSIGNED_HASH = 0x00000002; // Unsigned dirhash in use // Signed dirhash in use
public const UInt32 EXT2_FLAGS_TEST_FILESYS = 0x00000004; // Testing development code public const UInt32 EXT2_FLAGS_UNSIGNED_HASH = 0x00000002;
// Unsigned dirhash in use
public const UInt32 EXT2_FLAGS_TEST_FILESYS = 0x00000004;
// Testing development code
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
using FileSystemIDandChk; using FileSystemIDandChk;
@@ -9,8 +8,8 @@ namespace FileSystemIDandChk.Plugins
{ {
public extFS(PluginBase Core) public extFS(PluginBase Core)
{ {
base.Name = "Linux extended Filesystem"; Name = "Linux extended Filesystem";
base.PluginUUID = new Guid("076CB3A2-08C2-4D69-BC8A-FCAA2E502BE2"); PluginUUID = new Guid("076CB3A2-08C2-4D69-BC8A-FCAA2E502BE2");
} }
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset) public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
@@ -19,10 +18,7 @@ namespace FileSystemIDandChk.Plugins
UInt16 magic = BitConverter.ToUInt16(sb_sector, 0x038); // Here should reside magic number UInt16 magic = BitConverter.ToUInt16(sb_sector, 0x038); // Here should reside magic number
if(magic == extFSMagic) return magic == extFSMagic;
return true;
else
return false;
} }
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information) public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
@@ -61,21 +57,36 @@ namespace FileSystemIDandChk.Plugins
public struct extFSSuperBlock public struct extFSSuperBlock
{ {
public UInt32 inodes; // 0x000, inodes on volume public UInt32 inodes;
public UInt32 zones; // 0x004, zones on volume // 0x000, inodes on volume
public UInt32 firstfreeblk; // 0x008, first free block public UInt32 zones;
public UInt32 freecountblk; // 0x00C, free blocks count // 0x004, zones on volume
public UInt32 firstfreeind; // 0x010, first free inode public UInt32 firstfreeblk;
public UInt32 freecountind; // 0x014, free inodes count // 0x008, first free block
public UInt32 firstdatazone; // 0x018, first data zone public UInt32 freecountblk;
public UInt32 logzonesize; // 0x01C, log zone size // 0x00C, free blocks count
public UInt32 maxsize; // 0x020, max zone size public UInt32 firstfreeind;
public UInt32 reserved1; // 0x024, reserved // 0x010, first free inode
public UInt32 reserved2; // 0x028, reserved public UInt32 freecountind;
public UInt32 reserved3; // 0x02C, reserved // 0x014, free inodes count
public UInt32 reserved4; // 0x030, reserved public UInt32 firstdatazone;
public UInt32 reserved5; // 0x034, reserved // 0x018, first data zone
public UInt16 magic; // 0x038, 0x137D (little endian) public UInt32 logzonesize;
// 0x01C, log zone size
public UInt32 maxsize;
// 0x020, max zone size
public UInt32 reserved1;
// 0x024, reserved
public UInt32 reserved2;
// 0x028, reserved
public UInt32 reserved3;
// 0x02C, reserved
public UInt32 reserved4;
// 0x030, reserved
public UInt32 reserved5;
// 0x034, reserved
public UInt16 magic;
// 0x038, 0x137D (little endian)
} }
} }
} }