From 830f78120d27ef67cd0ecd78d174a53914ce032c Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 8 Oct 2017 21:49:04 +0100 Subject: [PATCH] Added missing structures and corrected both-endian fields for ISO9660. --- .../DiscImageChef.Filesystems.csproj | 1 + DiscImageChef.Filesystems/ISO9660/Consts.cs | 77 +++++++++++++++++ DiscImageChef.Filesystems/ISO9660/ISO9660.cs | 3 + DiscImageChef.Filesystems/ISO9660/Structs.cs | 86 +++++++++++++++++-- 4 files changed, 162 insertions(+), 5 deletions(-) create mode 100644 DiscImageChef.Filesystems/ISO9660/Consts.cs diff --git a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj index f69670551..23e082e49 100644 --- a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj +++ b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj @@ -144,6 +144,7 @@ + diff --git a/DiscImageChef.Filesystems/ISO9660/Consts.cs b/DiscImageChef.Filesystems/ISO9660/Consts.cs new file mode 100644 index 000000000..63c220f94 --- /dev/null +++ b/DiscImageChef.Filesystems/ISO9660/Consts.cs @@ -0,0 +1,77 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Component +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2017 Natalia Portillo +// ****************************************************************************/ +using System; + +namespace DiscImageChef.Filesystems.ISO9660 +{ + public partial class ISO9660 : Filesystem + { + [Flags] + enum FileFlags : byte + { + Hidden = 0x01, + Directory = 0x02, + Associated = 0x04, + Record = 0x08, + Protected = 0x10, + MultiExtent = 0x80 + } + + [Flags] + enum Permissions : ushort + { + SystemRead = 0x01, + SystemExecute = 0x04, + OwnerRead = 0x10, + OwnerExecute = 0x40, + GroupRead = 0x100, + GroupExecute = 0x400, + OtherRead = 0x1000, + OtherExecute = 0x4000, + } + + enum RecordFormat : byte + { + Unspecified = 0, + FixedLength = 1, + VariableLength = 2, + VariableLengthAlternate = 3 + } + + enum RecordAttribute : byte + { + LFCR = 0, + ISO1539 = 1, + ControlContained = 2, + } + } +} diff --git a/DiscImageChef.Filesystems/ISO9660/ISO9660.cs b/DiscImageChef.Filesystems/ISO9660/ISO9660.cs index 9a1b0ee7a..c60dcfb46 100644 --- a/DiscImageChef.Filesystems/ISO9660/ISO9660.cs +++ b/DiscImageChef.Filesystems/ISO9660/ISO9660.cs @@ -38,6 +38,9 @@ namespace DiscImageChef.Filesystems.ISO9660 // This is coded following ECMA-119. // TODO: Differentiate ISO Level 1, 2, 3 and ISO 9660:1999 // TODO: Apple extensiones, requires XA or advance RR interpretation. + // TODO: Check ECMA-167 + // TODO: Check ECMA-168 + // TODO: HighSierra public partial class ISO9660 : Filesystem { public ISO9660() diff --git a/DiscImageChef.Filesystems/ISO9660/Structs.cs b/DiscImageChef.Filesystems/ISO9660/Structs.cs index a22168af5..4d2a8bd9f 100644 --- a/DiscImageChef.Filesystems/ISO9660/Structs.cs +++ b/DiscImageChef.Filesystems/ISO9660/Structs.cs @@ -51,14 +51,19 @@ namespace DiscImageChef.Filesystems.ISO9660 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] volume_id; public ulong reserved2; - public ulong volume_space_size; + public uint volume_space_size; + public uint volume_space_size_be; // Only used in SVDs [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] escape_sequences; - public uint volume_set_size; - public uint volume_sequence_number; - public uint logical_block_size; - public ulong path_table_size; + public ushort volume_set_size; + public ushort volume_set_size_be; + public ushort volume_sequence_number; + public ushort volume_sequence_number_be; + public ushort logical_block_size; + public ushort logical_block_size_be; + public uint path_table_size; + public uint path_table_size_be; public uint type_1_path_table; public uint opt_type_1_path_table; public uint type_m_path_table; @@ -110,6 +115,77 @@ namespace DiscImageChef.Filesystems.ISO9660 public byte[] boot_use; } + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct PartitionDescriptor + { + public byte type; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] + public byte[] id; + public byte version; + public byte reserved1; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public byte[] system_id; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public byte[] partition_id; + public uint partition_location; + public uint partition_location_be; + public uint partition_size; + public uint partition_size_be; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1960)] + public byte[] system_use; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct DirectoryRecord + { + public byte length; + public byte xattr_len; + public uint extent; + public uint extent_be; + public uint size; + public uint size_be; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] + public byte[] date; + public FileFlags flags; + public byte file_unit_size; + public byte interleave; + public ushort volume_sequence_number; + public ushort volume_sequence_number_be; + public byte name_len; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct ExtendedAttributeRecord + { + public ushort owner; + public ushort owner_be; + public ushort group; + public ushort group_be; + public Permissions permissions; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] + public byte[] creation_date; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] + public byte[] modification_date; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] + public byte[] expiration_date; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] + public byte[] effective_date; + public RecordFormat record_format; + public RecordAttribute record_attributes; + public ushort record_length; + public ushort record_length_be; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public byte[] system_id; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public byte[] system_use; + public byte record_version; + public byte escape_len; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public byte[] reserved1; + public ushort app_use_len; + public ushort app_use_len_be; + } + struct DecodedVolumeDescriptor { public string SystemIdentifier;