mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add more optimized marshallers.
This commit is contained in:
8
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
8
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -92,12 +92,8 @@
|
||||
</e>
|
||||
</e>
|
||||
<e p="DiscImageChef.CommonTypes" t="IncludeRecursive">
|
||||
<e p="Attributes" t="Include">
|
||||
<e p="MarshallingPropertiesAttribute.cs" t="Include" />
|
||||
</e>
|
||||
<e p="DiscImageChef.CommonTypes.csproj" t="IncludeRecursive" />
|
||||
<e p="Enums" t="Include">
|
||||
<e p="BitEndian.cs" t="Include" />
|
||||
<e p="DeviceType.cs" t="Include" />
|
||||
<e p="ErrorNumber.cs" t="Include" />
|
||||
<e p="Images.cs" t="Include" />
|
||||
@@ -1765,12 +1761,14 @@
|
||||
<e p="ArrayFill.cs" t="Include" />
|
||||
<e p="ArrayIsEmpty.cs" t="Include" />
|
||||
<e p="BigEndianBitConverter.cs" t="Include" />
|
||||
<e p="BigEndianMarshal.cs" t="Include" />
|
||||
<e p="BitEndian.cs" t="Include" />
|
||||
<e p="CHS.cs" t="Include" />
|
||||
<e p="CompareBytes.cs" t="Include" />
|
||||
<e p="CountBits.cs" t="Include" />
|
||||
<e p="DateHandlers.cs" t="Include" />
|
||||
<e p="DiscImageChef.Helpers.csproj" t="IncludeRecursive" />
|
||||
<e p="Marshal.cs" t="Include" />
|
||||
<e p="MarshallingPropertiesAttribute.cs" t="Include" />
|
||||
<e p="PrintHex.cs" t="Include" />
|
||||
<e p="StringHandlers.cs" t="Include" />
|
||||
<e p="Swapping.cs" t="Include" />
|
||||
|
||||
@@ -49,8 +49,6 @@
|
||||
<Compile Include="..\CICMMetadata\dotnet\cicm.cs">
|
||||
<Link>Metadata/cicm.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Attributes\MarshallingPropertiesAttribute.cs" />
|
||||
<Compile Include="Enums\BitEndian.cs" />
|
||||
<Compile Include="Enums\DeviceType.cs" />
|
||||
<Compile Include="Enums\ErrorNumber.cs" />
|
||||
<Compile Include="Enums\Images.cs" />
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using DiscImageChef.CommonTypes.Exceptions;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using DiscImageChef.Helpers;
|
||||
using SharpCompress.Compressors;
|
||||
using SharpCompress.Compressors.Deflate;
|
||||
|
||||
@@ -93,7 +94,7 @@ namespace DiscImageChef.DiscImages
|
||||
case 3:
|
||||
byte[] entryBytes = new byte[16];
|
||||
Array.Copy(hunkMap, (int)(hunkNo * 16), entryBytes, 0, 16);
|
||||
ChdMapV3Entry entry = BigEndianMarshal.ByteArrayToStructureBigEndian<ChdMapV3Entry>(entryBytes);
|
||||
ChdMapV3Entry entry = Marshal.ByteArrayToStructureBigEndian<ChdMapV3Entry>(entryBytes);
|
||||
switch((Chdv3EntryFlags)(entry.flags & 0x0F))
|
||||
{
|
||||
case Chdv3EntryFlags.Invalid: throw new ArgumentException("Invalid hunk found.");
|
||||
|
||||
@@ -44,6 +44,7 @@ using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Decoders.ATA;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
{
|
||||
@@ -75,7 +76,7 @@ namespace DiscImageChef.DiscImages
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
ChdHeaderV1 hdrV1 = BigEndianMarshal.ByteArrayToStructureBigEndian<ChdHeaderV1>(buffer);
|
||||
ChdHeaderV1 hdrV1 = Marshal.ByteArrayToStructureBigEndian<ChdHeaderV1>(buffer);
|
||||
|
||||
DicConsole.DebugWriteLine("CHD plugin", "hdrV1.tag = \"{0}\"",
|
||||
Encoding.ASCII.GetString(hdrV1.tag));
|
||||
@@ -112,7 +113,9 @@ namespace DiscImageChef.DiscImages
|
||||
Array.Reverse(hunkSectorBytes);
|
||||
GCHandle handle = GCHandle.Alloc(hunkSectorBytes, GCHandleType.Pinned);
|
||||
HunkSector hunkSector =
|
||||
(HunkSector)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(HunkSector));
|
||||
(HunkSector)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
|
||||
typeof(HunkSector));
|
||||
handle.Free();
|
||||
// This restores the order of elements
|
||||
Array.Reverse(hunkSector.hunkEntry);
|
||||
@@ -146,7 +149,7 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
ChdHeaderV2 hdrV2 = BigEndianMarshal.ByteArrayToStructureBigEndian<ChdHeaderV2>(buffer);
|
||||
ChdHeaderV2 hdrV2 = Marshal.ByteArrayToStructureBigEndian<ChdHeaderV2>(buffer);
|
||||
|
||||
DicConsole.DebugWriteLine("CHD plugin", "hdrV2.tag = \"{0}\"",
|
||||
Encoding.ASCII.GetString(hdrV2.tag));
|
||||
@@ -185,7 +188,9 @@ namespace DiscImageChef.DiscImages
|
||||
Array.Reverse(hunkSectorBytes);
|
||||
GCHandle handle = GCHandle.Alloc(hunkSectorBytes, GCHandleType.Pinned);
|
||||
HunkSector hunkSector =
|
||||
(HunkSector)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(HunkSector));
|
||||
(HunkSector)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
|
||||
typeof(HunkSector));
|
||||
handle.Free();
|
||||
// This restores the order of elements
|
||||
Array.Reverse(hunkSector.hunkEntry);
|
||||
@@ -219,7 +224,7 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
ChdHeaderV3 hdrV3 = BigEndianMarshal.ByteArrayToStructureBigEndian<ChdHeaderV3>(buffer);
|
||||
ChdHeaderV3 hdrV3 = Marshal.ByteArrayToStructureBigEndian<ChdHeaderV3>(buffer);
|
||||
|
||||
DicConsole.DebugWriteLine("CHD plugin", "hdrV3.tag = \"{0}\"",
|
||||
Encoding.ASCII.GetString(hdrV3.tag));
|
||||
@@ -268,7 +273,7 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
ChdHeaderV4 hdrV4 = BigEndianMarshal.ByteArrayToStructureBigEndian<ChdHeaderV4>(buffer);
|
||||
ChdHeaderV4 hdrV4 = Marshal.ByteArrayToStructureBigEndian<ChdHeaderV4>(buffer);
|
||||
|
||||
DicConsole.DebugWriteLine("CHD plugin", "hdrV4.tag = \"{0}\"",
|
||||
Encoding.ASCII.GetString(hdrV4.tag));
|
||||
@@ -313,7 +318,7 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
ChdHeaderV5 hdrV5 = BigEndianMarshal.ByteArrayToStructureBigEndian<ChdHeaderV5>(buffer);
|
||||
ChdHeaderV5 hdrV5 = Marshal.ByteArrayToStructureBigEndian<ChdHeaderV5>(buffer);
|
||||
|
||||
DicConsole.DebugWriteLine("CHD plugin", "hdrV5.tag = \"{0}\"",
|
||||
Encoding.ASCII.GetString(hdrV5.tag));
|
||||
@@ -366,8 +371,9 @@ namespace DiscImageChef.DiscImages
|
||||
Array.Reverse(hunkSectorBytes);
|
||||
GCHandle handle = GCHandle.Alloc(hunkSectorBytes, GCHandleType.Pinned);
|
||||
HunkSectorSmall hunkSector =
|
||||
(HunkSectorSmall)Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
|
||||
typeof(HunkSectorSmall));
|
||||
(HunkSectorSmall)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
|
||||
typeof(HunkSectorSmall));
|
||||
handle.Free();
|
||||
// This restores the order of elements
|
||||
Array.Reverse(hunkSector.hunkEntry);
|
||||
@@ -419,9 +425,8 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] hdrBytes = new byte[16];
|
||||
stream.Seek((long)nextMetaOff, SeekOrigin.Begin);
|
||||
stream.Read(hdrBytes, 0, hdrBytes.Length);
|
||||
ChdMetadataHeader header =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<ChdMetadataHeader>(hdrBytes);
|
||||
byte[] meta = new byte[header.flagsAndLength & 0xFFFFFF];
|
||||
ChdMetadataHeader header = Marshal.ByteArrayToStructureBigEndian<ChdMetadataHeader>(hdrBytes);
|
||||
byte[] meta = new byte[header.flagsAndLength & 0xFFFFFF];
|
||||
stream.Read(meta, 0, meta.Length);
|
||||
DicConsole.DebugWriteLine("CHD plugin", "Found metadata \"{0}\"",
|
||||
Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(header.tag)));
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] headerB = new byte[Marshal.SizeOf(header)];
|
||||
|
||||
stream.Read(headerB, 0, Marshal.SizeOf(header));
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<DartHeader>(headerB);
|
||||
header = Helpers.Marshal.ByteArrayToStructureBigEndian<DartHeader>(headerB);
|
||||
|
||||
if(header.srcCmp > COMPRESS_NONE) return false;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] headerB = new byte[Marshal.SizeOf(header)];
|
||||
|
||||
stream.Read(headerB, 0, Marshal.SizeOf(header));
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<DartHeader>(headerB);
|
||||
header = Helpers.Marshal.ByteArrayToStructureBigEndian<DartHeader>(headerB);
|
||||
|
||||
if(header.srcCmp > COMPRESS_NONE) return false;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace DiscImageChef.DiscImages
|
||||
DfiBlockHeader blockHeader = new DfiBlockHeader();
|
||||
byte[] blk = new byte[Marshal.SizeOf(blockHeader)];
|
||||
stream.Read(blk, 0, Marshal.SizeOf(blockHeader));
|
||||
blockHeader = BigEndianMarshal.ByteArrayToStructureBigEndian<DfiBlockHeader>(blk);
|
||||
blockHeader = Helpers.Marshal.ByteArrayToStructureBigEndian<DfiBlockHeader>(blk);
|
||||
|
||||
DicConsole.DebugWriteLine("DiscFerret plugin", "block@{0}.cylinder = {1}", thisOffset,
|
||||
blockHeader.cylinder);
|
||||
|
||||
@@ -34,12 +34,12 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using DiscImageChef.Helpers;
|
||||
using Schemas;
|
||||
using Marshal = System.Runtime.InteropServices.Marshal;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
{
|
||||
|
||||
@@ -42,6 +42,7 @@ using DiscImageChef.CommonTypes.Exceptions;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Compression;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Helpers;
|
||||
using SharpCompress.Compressors.ADC;
|
||||
using Version = Resources.Version;
|
||||
|
||||
@@ -75,7 +76,7 @@ namespace DiscImageChef.DiscImages
|
||||
{
|
||||
if(bcem.Length < 128) return false;
|
||||
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<ChunkHeader>(bcem);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<ChunkHeader>(bcem);
|
||||
|
||||
DicConsole.DebugWriteLine("NDIF plugin", "footer.type = {0}", header.version);
|
||||
DicConsole.DebugWriteLine("NDIF plugin", "footer.driver = {0}", header.driver);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
using System.IO;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Helpers;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
{
|
||||
@@ -46,7 +47,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
byte[] qHdrB = new byte[48];
|
||||
stream.Read(qHdrB, 0, 48);
|
||||
qHdr = BigEndianMarshal.ByteArrayToStructureBigEndian<QCowHeader>(qHdrB);
|
||||
qHdr = Marshal.ByteArrayToStructureBigEndian<QCowHeader>(qHdrB);
|
||||
|
||||
return qHdr.magic == QCOW_MAGIC && qHdr.version == QCOW_VERSION;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Helpers;
|
||||
using SharpCompress.Compressors;
|
||||
using SharpCompress.Compressors.Deflate;
|
||||
|
||||
@@ -53,7 +54,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
byte[] qHdrB = new byte[48];
|
||||
stream.Read(qHdrB, 0, 48);
|
||||
qHdr = BigEndianMarshal.ByteArrayToStructureBigEndian<QCowHeader>(qHdrB);
|
||||
qHdr = Marshal.ByteArrayToStructureBigEndian<QCowHeader>(qHdrB);
|
||||
|
||||
DicConsole.DebugWriteLine("QCOW plugin", "qHdr.magic = 0x{0:X8}", qHdr.magic);
|
||||
DicConsole.DebugWriteLine("QCOW plugin", "qHdr.version = {0}", qHdr.version);
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
byte[] qHdrB = new byte[Marshal.SizeOf(qHdr)];
|
||||
stream.Read(qHdrB, 0, Marshal.SizeOf(qHdr));
|
||||
qHdr = BigEndianMarshal.ByteArrayToStructureBigEndian<QCow2Header>(qHdrB);
|
||||
qHdr = Helpers.Marshal.ByteArrayToStructureBigEndian<QCow2Header>(qHdrB);
|
||||
|
||||
DicConsole.DebugWriteLine("QCOW plugin", "qHdr.magic = 0x{0:X8}", qHdr.magic);
|
||||
DicConsole.DebugWriteLine("QCOW plugin", "qHdr.version = {0}", qHdr.version);
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
byte[] qHdrB = new byte[Marshal.SizeOf(qHdr)];
|
||||
stream.Read(qHdrB, 0, Marshal.SizeOf(qHdr));
|
||||
qHdr = BigEndianMarshal.ByteArrayToStructureBigEndian<QCow2Header>(qHdrB);
|
||||
qHdr = Helpers.Marshal.ByteArrayToStructureBigEndian<QCow2Header>(qHdrB);
|
||||
|
||||
DicConsole.DebugWriteLine("QCOW plugin", "qHdr.magic = 0x{0:X8}", qHdr.magic);
|
||||
DicConsole.DebugWriteLine("QCOW plugin", "qHdr.version = {0}", qHdr.version);
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] footerB = new byte[Marshal.SizeOf(footer)];
|
||||
|
||||
stream.Read(footerB, 0, Marshal.SizeOf(footer));
|
||||
footer = BigEndianMarshal.ByteArrayToStructureBigEndian<UdifFooter>(footerB);
|
||||
footer = Helpers.Marshal.ByteArrayToStructureBigEndian<UdifFooter>(footerB);
|
||||
|
||||
if(footer.signature == UDIF_SIGNATURE) return true;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] headerB = new byte[Marshal.SizeOf(footer)];
|
||||
|
||||
stream.Read(headerB, 0, Marshal.SizeOf(footer));
|
||||
footer = BigEndianMarshal.ByteArrayToStructureBigEndian<UdifFooter>(headerB);
|
||||
footer = Helpers.Marshal.ByteArrayToStructureBigEndian<UdifFooter>(headerB);
|
||||
|
||||
return footer.signature == UDIF_SIGNATURE;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] footerB = new byte[Marshal.SizeOf(footer)];
|
||||
|
||||
stream.Read(footerB, 0, Marshal.SizeOf(footer));
|
||||
footer = BigEndianMarshal.ByteArrayToStructureBigEndian<UdifFooter>(footerB);
|
||||
footer = Helpers.Marshal.ByteArrayToStructureBigEndian<UdifFooter>(footerB);
|
||||
|
||||
if(footer.signature != UDIF_SIGNATURE)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ namespace DiscImageChef.DiscImages
|
||||
footerB = new byte[Marshal.SizeOf(footer)];
|
||||
|
||||
stream.Read(footerB, 0, Marshal.SizeOf(footer));
|
||||
footer = BigEndianMarshal.ByteArrayToStructureBigEndian<UdifFooter>(footerB);
|
||||
footer = Helpers.Marshal.ByteArrayToStructureBigEndian<UdifFooter>(footerB);
|
||||
|
||||
if(footer.signature != UDIF_SIGNATURE) throw new Exception("Unable to find UDIF signature.");
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace DiscImageChef.DiscImages
|
||||
BlockHeader bHdr = new BlockHeader();
|
||||
byte[] bHdrB = new byte[Marshal.SizeOf(bHdr)];
|
||||
Array.Copy(blkxBytes, 0, bHdrB, 0, Marshal.SizeOf(bHdr));
|
||||
bHdr = BigEndianMarshal.ByteArrayToStructureBigEndian<BlockHeader>(bHdrB);
|
||||
bHdr = Helpers.Marshal.ByteArrayToStructureBigEndian<BlockHeader>(bHdrB);
|
||||
|
||||
DicConsole.DebugWriteLine("UDIF plugin", "bHdr.signature = 0x{0:X8}", bHdr.signature);
|
||||
DicConsole.DebugWriteLine("UDIF plugin", "bHdr.version = {0}", bHdr.version);
|
||||
@@ -283,7 +283,7 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] bChnkB = new byte[Marshal.SizeOf(bChnk)];
|
||||
Array.Copy(blkxBytes, Marshal.SizeOf(bHdr) + Marshal.SizeOf(bChnk) * i, bChnkB, 0,
|
||||
Marshal.SizeOf(bChnk));
|
||||
bChnk = BigEndianMarshal.ByteArrayToStructureBigEndian<BlockChunk>(bChnkB);
|
||||
bChnk = Helpers.Marshal.ByteArrayToStructureBigEndian<BlockChunk>(bChnkB);
|
||||
|
||||
DicConsole.DebugWriteLine("UDIF plugin", "bHdr.chunk[{0}].type = 0x{1:X8}", i, bChnk.type);
|
||||
DicConsole.DebugWriteLine("UDIF plugin", "bHdr.chunk[{0}].comment = {1}", i, bChnk.comment);
|
||||
|
||||
@@ -39,6 +39,7 @@ using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filesystems
|
||||
{
|
||||
@@ -69,14 +70,14 @@ namespace DiscImageChef.Filesystems
|
||||
// size for floppies is the sector size, and for RDB is usually is the hard disk sector size,
|
||||
// so this is not entirely wrong...
|
||||
byte[] sector = imagePlugin.ReadSectors(0 + partition.Start, 2);
|
||||
BootBlock bblk = BigEndianMarshal.ByteArrayToStructureBigEndian<BootBlock>(sector);
|
||||
BootBlock bblk = Marshal.ByteArrayToStructureBigEndian<BootBlock>(sector);
|
||||
|
||||
// AROS boot floppies...
|
||||
if(sector.Length >= 512 && sector[510] == 0x55 && sector[511] == 0xAA &&
|
||||
(bblk.diskType & FFS_MASK) != FFS_MASK && (bblk.diskType & MUFS_MASK) != MUFS_MASK)
|
||||
{
|
||||
sector = imagePlugin.ReadSectors(1 + partition.Start, 2);
|
||||
bblk = BigEndianMarshal.ByteArrayToStructureBigEndian<BootBlock>(sector);
|
||||
bblk = Marshal.ByteArrayToStructureBigEndian<BootBlock>(sector);
|
||||
}
|
||||
|
||||
// Not FFS or MuFS?
|
||||
@@ -164,7 +165,7 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
byte[] bootBlockSectors = imagePlugin.ReadSectors(0 + partition.Start, 2);
|
||||
|
||||
BootBlock bootBlk = BigEndianMarshal.ByteArrayToStructureBigEndian<BootBlock>(bootBlockSectors);
|
||||
BootBlock bootBlk = Marshal.ByteArrayToStructureBigEndian<BootBlock>(bootBlockSectors);
|
||||
bootBlk.bootCode = new byte[bootBlockSectors.Length - 12];
|
||||
Array.Copy(bootBlockSectors, 12, bootBlk.bootCode, 0, bootBlk.bootCode.Length);
|
||||
bootBlockSectors[4] = bootBlockSectors[5] = bootBlockSectors[6] = bootBlockSectors[7] = 0;
|
||||
@@ -339,7 +340,7 @@ namespace DiscImageChef.Filesystems
|
||||
byte[] tmp = new byte[228];
|
||||
Array.Copy(block, 0, tmp, 0, 24);
|
||||
Array.Copy(block, block.Length - 200, tmp, 28, 200);
|
||||
RootBlock root = BigEndianMarshal.ByteArrayToStructureBigEndian<RootBlock>(tmp);
|
||||
RootBlock root = Marshal.ByteArrayToStructureBigEndian<RootBlock>(tmp);
|
||||
root.hashTable = new uint[(block.Length - 224) / 4];
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
for(int i = 0; i < root.hashTable.Length; i++)
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filesystems
|
||||
{
|
||||
@@ -143,9 +144,8 @@ namespace DiscImageChef.Filesystems
|
||||
else return;
|
||||
}
|
||||
|
||||
HfsMasterDirectoryBlock mdb =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<HfsMasterDirectoryBlock>(mdbSector);
|
||||
HfsBootBlock bb = BigEndianMarshal.ByteArrayToStructureBigEndian<HfsBootBlock>(bbSector);
|
||||
HfsMasterDirectoryBlock mdb = Marshal.ByteArrayToStructureBigEndian<HfsMasterDirectoryBlock>(mdbSector);
|
||||
HfsBootBlock bb = Marshal.ByteArrayToStructureBigEndian<HfsBootBlock>(bbSector);
|
||||
|
||||
sb.AppendLine("Apple Hierarchical File System");
|
||||
sb.AppendLine();
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filesystems
|
||||
{
|
||||
@@ -159,7 +160,7 @@ namespace DiscImageChef.Filesystems
|
||||
Array.Copy(vhSector, 0x400, tmp, 0, 0x400);
|
||||
vhSector = tmp;
|
||||
|
||||
vh = BigEndianMarshal.ByteArrayToStructureBigEndian<HfsPlusVolumeHeader>(vhSector);
|
||||
vh = Marshal.ByteArrayToStructureBigEndian<HfsPlusVolumeHeader>(vhSector);
|
||||
|
||||
if(vh.version == 4 || vh.version == 5)
|
||||
{
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace DiscImageChef.Filesystems
|
||||
besb = (BeSuperBlock)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(BeSuperBlock));
|
||||
handle.Free();
|
||||
}
|
||||
else besb = BigEndianMarshal.ByteArrayToStructureBigEndian<BeSuperBlock>(sbSector);
|
||||
else besb = Helpers.Marshal.ByteArrayToStructureBigEndian<BeSuperBlock>(sbSector);
|
||||
|
||||
sb.AppendLine(littleEndian ? "Little-endian BeFS" : "Big-endian BeFS");
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace DiscImageChef.Filesystems
|
||||
Marshal.FreeHGlobal(crSbPtr);
|
||||
break;
|
||||
case CRAM_CIGAM:
|
||||
crSb = BigEndianMarshal.ByteArrayToStructureBigEndian<CramSuperBlock>(sector);
|
||||
crSb = Helpers.Marshal.ByteArrayToStructureBigEndian<CramSuperBlock>(sector);
|
||||
littleEndian = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf(efsSb));
|
||||
|
||||
efsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sbpiece);
|
||||
efsSb = Helpers.Marshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sbpiece);
|
||||
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})",
|
||||
0x200, efsSb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW);
|
||||
@@ -89,7 +89,7 @@ namespace DiscImageChef.Filesystems
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + 1, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(efsSb)) return false;
|
||||
|
||||
efsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sector);
|
||||
efsSb = Helpers.Marshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 1,
|
||||
efsSb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW);
|
||||
@@ -122,7 +122,7 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf(efsSb));
|
||||
|
||||
efsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sbpiece);
|
||||
efsSb = Helpers.Marshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sbpiece);
|
||||
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})",
|
||||
0x200, efsSb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW);
|
||||
@@ -135,7 +135,7 @@ namespace DiscImageChef.Filesystems
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + 1, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(efsSb)) return;
|
||||
|
||||
efsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sector);
|
||||
efsSb = Helpers.Marshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 1,
|
||||
efsSb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW);
|
||||
|
||||
@@ -42,6 +42,7 @@ using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Helpers;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filesystems
|
||||
{
|
||||
@@ -138,10 +139,10 @@ namespace DiscImageChef.Filesystems
|
||||
("d3e93f8b82ef250db216037d827a4896dc97d2be", "TracerST"), // OEM ID: "TracerST"
|
||||
//("b741f85ef40288ccc8887de1f6e849009097e1c9", "Norton Utilities"), // OEM ID: "IBM PNCI", need to confirm
|
||||
("c49b275537ac7237cac64d83f34d2024ae0ca96a",
|
||||
"Windows NT (Spanish)"), // Need to check Windows >= 2000 (Spanish)
|
||||
"Windows NT (Spanish)"), // Need to check Windows >= 2000 (Spanish)
|
||||
//("a48b0e4b696317eed829e960d1aa576562a4f185", "TracerST"), // Unknown OEM ID, apparently Tracer, unconfirmed
|
||||
("fe477972602ba76658ff7143859045b3c4036ca5",
|
||||
"iomega"), // OEM ID: "SHIPDISK", contains timedate on boot code may not be unique
|
||||
"iomega"), // OEM ID: "SHIPDISK", contains timedate on boot code may not be unique
|
||||
("ef79a1f33e5237827eb812dda548f0e4e916d815", "GEOS"), // OEM ID: "GEOWORKS"
|
||||
("8524587ee91494cc51cc2c9d07453e84be0cdc33", "Hero Soft v1.10"),
|
||||
("681a0d9d662ba368e6acb0d0bf602e1f56411144", "Human68k 2.00")
|
||||
@@ -182,8 +183,7 @@ namespace DiscImageChef.Filesystems
|
||||
byte[] bpbSector = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb);
|
||||
byte[] fatSector = imagePlugin.ReadSector(sectorsPerBpb + partition.Start);
|
||||
|
||||
HumanParameterBlock humanBpb =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<HumanParameterBlock>(bpbSector);
|
||||
HumanParameterBlock humanBpb = Marshal.ByteArrayToStructureBigEndian<HumanParameterBlock>(bpbSector);
|
||||
|
||||
ulong expectedClusters = humanBpb.bpc > 0 ? partition.Size / humanBpb.bpc : 0;
|
||||
|
||||
@@ -484,8 +484,7 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
byte[] bpbSector = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb);
|
||||
|
||||
HumanParameterBlock humanBpb =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<HumanParameterBlock>(bpbSector);
|
||||
HumanParameterBlock humanBpb = Marshal.ByteArrayToStructureBigEndian<HumanParameterBlock>(bpbSector);
|
||||
|
||||
ulong expectedClusters = humanBpb.bpc > 0 ? partition.Size / humanBpb.bpc : 0;
|
||||
|
||||
@@ -517,24 +516,43 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
if(imagePlugin.Info.SectorSize >= 256 && !useHumanBpb)
|
||||
{
|
||||
IntPtr bpbPtr = Marshal.AllocHGlobal(512);
|
||||
Marshal.Copy(bpbSector, 0, bpbPtr, 512);
|
||||
IntPtr bpbPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512);
|
||||
System.Runtime.InteropServices.Marshal.Copy(bpbSector, 0, bpbPtr, 512);
|
||||
|
||||
atariBpb = (AtariParameterBlock)Marshal.PtrToStructure(bpbPtr, typeof(AtariParameterBlock));
|
||||
msxBpb = (MsxParameterBlock)Marshal.PtrToStructure(bpbPtr, typeof(MsxParameterBlock));
|
||||
dos2Bpb = (BiosParameterBlock2)Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlock2));
|
||||
dos30Bpb = (BiosParameterBlock30)Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlock30));
|
||||
dos32Bpb = (BiosParameterBlock32)Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlock32));
|
||||
dos33Bpb = (BiosParameterBlock33)Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlock33));
|
||||
atariBpb =
|
||||
(AtariParameterBlock)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(AtariParameterBlock));
|
||||
msxBpb =
|
||||
(MsxParameterBlock)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(MsxParameterBlock));
|
||||
dos2Bpb =
|
||||
(BiosParameterBlock2)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlock2));
|
||||
dos30Bpb =
|
||||
(BiosParameterBlock30)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlock30));
|
||||
dos32Bpb =
|
||||
(BiosParameterBlock32)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlock32));
|
||||
dos33Bpb =
|
||||
(BiosParameterBlock33)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlock33));
|
||||
shortEbpb =
|
||||
(BiosParameterBlockShortEbpb)Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlockShortEbpb));
|
||||
ebpb = (BiosParameterBlockEbpb)Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlockEbpb));
|
||||
(BiosParameterBlockShortEbpb)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlockShortEbpb));
|
||||
ebpb =
|
||||
(BiosParameterBlockEbpb)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(BiosParameterBlockEbpb));
|
||||
shortFat32Bpb =
|
||||
(Fat32ParameterBlockShort)Marshal.PtrToStructure(bpbPtr, typeof(Fat32ParameterBlockShort));
|
||||
fat32Bpb = (Fat32ParameterBlock)Marshal.PtrToStructure(bpbPtr, typeof(Fat32ParameterBlock));
|
||||
apricotBpb = (ApricotLabel)Marshal.PtrToStructure(bpbPtr, typeof(ApricotLabel));
|
||||
(Fat32ParameterBlockShort)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(Fat32ParameterBlockShort));
|
||||
fat32Bpb =
|
||||
(Fat32ParameterBlock)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(Fat32ParameterBlock));
|
||||
apricotBpb =
|
||||
(ApricotLabel)System.Runtime.InteropServices.Marshal.PtrToStructure(bpbPtr, typeof(ApricotLabel));
|
||||
|
||||
Marshal.FreeHGlobal(bpbPtr);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(bpbPtr);
|
||||
|
||||
int bitsInBpsAtari = CountBits.Count(atariBpb.bps);
|
||||
int bitsInBpsMsx = CountBits.Count(msxBpb.bps);
|
||||
@@ -1104,10 +1122,12 @@ namespace DiscImageChef.Filesystems
|
||||
if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End)
|
||||
{
|
||||
byte[] fsinfoSector = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start);
|
||||
IntPtr fsinfoPtr = Marshal.AllocHGlobal(512);
|
||||
Marshal.Copy(fsinfoSector, 0, fsinfoPtr, 512);
|
||||
FsInfoSector fsInfo = (FsInfoSector)Marshal.PtrToStructure(fsinfoPtr, typeof(FsInfoSector));
|
||||
Marshal.FreeHGlobal(fsinfoPtr);
|
||||
IntPtr fsinfoPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512);
|
||||
System.Runtime.InteropServices.Marshal.Copy(fsinfoSector, 0, fsinfoPtr, 512);
|
||||
FsInfoSector fsInfo =
|
||||
(FsInfoSector)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(fsinfoPtr, typeof(FsInfoSector));
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(fsinfoPtr);
|
||||
|
||||
if(fsInfo.signature1 == FSINFO_SIGNATURE1 && fsInfo.signature2 == FSINFO_SIGNATURE2 &&
|
||||
fsInfo.signature3 == FSINFO_SIGNATURE3)
|
||||
@@ -1540,10 +1560,12 @@ namespace DiscImageChef.Filesystems
|
||||
// Not a volume label
|
||||
if(rootDirectory[i + 0x0B] != 0x08 && rootDirectory[i + 0x0B] != 0x28) continue;
|
||||
|
||||
IntPtr entryPtr = Marshal.AllocHGlobal(32);
|
||||
Marshal.Copy(rootDirectory, i, entryPtr, 32);
|
||||
DirectoryEntry entry = (DirectoryEntry)Marshal.PtrToStructure(entryPtr, typeof(DirectoryEntry));
|
||||
Marshal.FreeHGlobal(entryPtr);
|
||||
IntPtr entryPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(32);
|
||||
System.Runtime.InteropServices.Marshal.Copy(rootDirectory, i, entryPtr, 32);
|
||||
DirectoryEntry entry =
|
||||
(DirectoryEntry)
|
||||
System.Runtime.InteropServices.Marshal.PtrToStructure(entryPtr, typeof(DirectoryEntry));
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(entryPtr);
|
||||
|
||||
byte[] fullname = new byte[11];
|
||||
Array.Copy(entry.filename, 0, fullname, 0, 8);
|
||||
@@ -2137,15 +2159,18 @@ namespace DiscImageChef.Filesystems
|
||||
/// <summary>Operating system.</summary>
|
||||
public byte operatingSystem;
|
||||
/// <summary>Software write protection.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool writeProtected;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool writeProtected;
|
||||
/// <summary>Copy protected.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool copyProtected;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool copyProtected;
|
||||
/// <summary>Boot type.</summary>
|
||||
public byte bootType;
|
||||
/// <summary>Partitions.</summary>
|
||||
public byte partitionCount;
|
||||
/// <summary>Is hard disk?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool winchester;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool winchester;
|
||||
/// <summary>Sector size.</summary>
|
||||
public ushort sectorSize;
|
||||
/// <summary>Sectors per track.</summary>
|
||||
@@ -2198,15 +2223,18 @@ namespace DiscImageChef.Filesystems
|
||||
/// <summary>Major BIOS version.</summary>
|
||||
public byte biosMajorVersion;
|
||||
/// <summary>Diagnostics enabled?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool diagnosticsFlag;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool diagnosticsFlag;
|
||||
/// <summary>Printer device.</summary>
|
||||
public byte prnDevice;
|
||||
/// <summary>Bell volume.</summary>
|
||||
public byte bellVolume;
|
||||
/// <summary>Cache enabled?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool enableCache;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool enableCache;
|
||||
/// <summary>Graphics enabled?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool enableGraphics;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool enableGraphics;
|
||||
/// <summary>Length in sectors of DOS.</summary>
|
||||
public byte dosLength;
|
||||
/// <summary>Length in sectors of FONT file.</summary>
|
||||
@@ -2222,7 +2250,8 @@ namespace DiscImageChef.Filesystems
|
||||
/// <summary>Keyboard click volume.</summary>
|
||||
public byte keyboardVolume;
|
||||
/// <summary>Auto-repeat enabled?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool autorepeat;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool autorepeat;
|
||||
/// <summary>Auto-repeat lead-in.</summary>
|
||||
public byte autorepeatLeadIn;
|
||||
/// <summary>Auto-repeat interval.</summary>
|
||||
@@ -2237,7 +2266,8 @@ namespace DiscImageChef.Filesystems
|
||||
/// <summary>Screen line width.</summary>
|
||||
public byte lineWidth;
|
||||
/// <summary>Screen disabled?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool imageOff;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool imageOff;
|
||||
/// <summary>Spare area for screen values expansion.</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)]
|
||||
public byte[] spareScreen;
|
||||
@@ -2252,13 +2282,16 @@ namespace DiscImageChef.Filesystems
|
||||
/// <summary>Stop bits.</summary>
|
||||
public byte stopBits;
|
||||
/// <summary>Parity enabled?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool parityCheck;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool parityCheck;
|
||||
/// <summary>Parity type.</summary>
|
||||
public byte parityType;
|
||||
/// <summary>Xon/Xoff enabled on TX.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool txXonXoff;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool txXonXoff;
|
||||
/// <summary>Xon/Xoff enabled on RX.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool rxXonXoff;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool rxXonXoff;
|
||||
/// <summary>Xon character.</summary>
|
||||
public byte xonCharacter;
|
||||
/// <summary>Xoff character.</summary>
|
||||
@@ -2266,30 +2299,39 @@ namespace DiscImageChef.Filesystems
|
||||
/// <summary>Xon/Xoff buffer on RX.</summary>
|
||||
public ushort rxXonXoffBuffer;
|
||||
/// <summary>DTR/DSR enabled?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool dtrDsr;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool dtrDsr;
|
||||
/// <summary>CTS/RTS enabled?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool ctsRts;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool ctsRts;
|
||||
/// <summary>NULLs after CR.</summary>
|
||||
public byte nullsAfterCr;
|
||||
/// <summary>NULLs after 0xFF.</summary>
|
||||
public byte nullsAfterFF;
|
||||
/// <summary>Send LF after CR in serial port.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool lfAfterCRSerial;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool lfAfterCRSerial;
|
||||
/// <summary>BIOS error report in serial port.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool biosErrorReportSerial;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool biosErrorReportSerial;
|
||||
/// <summary>Spare area for serial port values expansion.</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)]
|
||||
public byte[] spareSerial;
|
||||
/// <summary>Send LF after CR in parallel port.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool lfAfterCrParallel;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool lfAfterCrParallel;
|
||||
/// <summary>Select line supported?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool selectLine;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool selectLine;
|
||||
/// <summary>Paper empty supported?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool paperEmpty;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool paperEmpty;
|
||||
/// <summary>Fault line supported?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool faultLine;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool faultLine;
|
||||
/// <summary>BIOS error report in parallel port.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool biosErrorReportParallel;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool biosErrorReportParallel;
|
||||
/// <summary>Spare area for parallel port values expansion.</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
|
||||
public byte[] spareParallel;
|
||||
@@ -2297,9 +2339,11 @@ namespace DiscImageChef.Filesystems
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)]
|
||||
public byte[] spareWinchester;
|
||||
/// <summary>Parking enabled?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool parkingEnabled;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool parkingEnabled;
|
||||
/// <summary>Format protection?.</summary>
|
||||
[MarshalAs(UnmanagedType.U1)] public bool formatProtection;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool formatProtection;
|
||||
/// <summary>Spare area for RAM disk values expansion.</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[] spareRamDisk;
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filesystems
|
||||
{
|
||||
@@ -55,7 +56,7 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(partition.Start);
|
||||
|
||||
FATX_Superblock fatxSb = BigEndianMarshal.ByteArrayToStructureBigEndian<FATX_Superblock>(sector);
|
||||
FATX_Superblock fatxSb = Marshal.ByteArrayToStructureBigEndian<FATX_Superblock>(sector);
|
||||
|
||||
return fatxSb.magic == FATX_MAGIC;
|
||||
}
|
||||
@@ -69,7 +70,7 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(partition.Start);
|
||||
|
||||
FATX_Superblock fatxSb = BigEndianMarshal.ByteArrayToStructureBigEndian<FATX_Superblock>(sector);
|
||||
FATX_Superblock fatxSb = Marshal.ByteArrayToStructureBigEndian<FATX_Superblock>(sector);
|
||||
|
||||
if(fatxSb.magic != FATX_MAGIC) return;
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace DiscImageChef.Filesystems
|
||||
UFSSuperBlock ufs_sb = (UFSSuperBlock)Marshal.PtrToStructure(sbPtr, typeof(UFSSuperBlock));
|
||||
Marshal.FreeHGlobal(sbPtr);
|
||||
|
||||
UFSSuperBlock bs_sfu = BigEndianMarshal.ByteArrayToStructureBigEndian<UFSSuperBlock>(ufs_sb_sectors);
|
||||
UFSSuperBlock bs_sfu = Helpers.Marshal.ByteArrayToStructureBigEndian<UFSSuperBlock>(ufs_sb_sectors);
|
||||
if(bs_sfu.fs_magic == UFS_MAGIC && ufs_sb.fs_magic == UFS_CIGAM ||
|
||||
bs_sfu.fs_magic == UFS_MAGIC_BW && ufs_sb.fs_magic == UFS_CIGAM_BW ||
|
||||
bs_sfu.fs_magic == UFS2_MAGIC && ufs_sb.fs_magic == UFS2_CIGAM ||
|
||||
|
||||
@@ -37,6 +37,7 @@ using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filesystems
|
||||
{
|
||||
@@ -60,7 +61,7 @@ namespace DiscImageChef.Filesystems
|
||||
if(partition.Start + hdrSector > imagePlugin.Info.Sectors) return false;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(partition.Start + hdrSector);
|
||||
FossilHeader hdr = BigEndianMarshal.ByteArrayToStructureBigEndian<FossilHeader>(sector);
|
||||
FossilHeader hdr = Marshal.ByteArrayToStructureBigEndian<FossilHeader>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("Fossil plugin", "magic at 0x{0:X8} (expected 0x{1:X8})", hdr.magic,
|
||||
FOSSIL_HDR_MAGIC);
|
||||
@@ -79,7 +80,7 @@ namespace DiscImageChef.Filesystems
|
||||
ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(partition.Start + hdrSector);
|
||||
FossilHeader hdr = BigEndianMarshal.ByteArrayToStructureBigEndian<FossilHeader>(sector);
|
||||
FossilHeader hdr = Marshal.ByteArrayToStructureBigEndian<FossilHeader>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("Fossil plugin", "magic at 0x{0:X8} (expected 0x{1:X8})", hdr.magic,
|
||||
FOSSIL_HDR_MAGIC);
|
||||
@@ -104,7 +105,7 @@ namespace DiscImageChef.Filesystems
|
||||
if(sbLocation <= partition.End)
|
||||
{
|
||||
sector = imagePlugin.ReadSector(sbLocation);
|
||||
FossilSuperBlock fsb = BigEndianMarshal.ByteArrayToStructureBigEndian<FossilSuperBlock>(sector);
|
||||
FossilSuperBlock fsb = Marshal.ByteArrayToStructureBigEndian<FossilSuperBlock>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("Fossil plugin", "magic 0x{0:X8} (expected 0x{1:X8})", fsb.magic,
|
||||
FOSSIL_SB_MAGIC);
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace DiscImageChef.Filesystems
|
||||
typeof(HammerSuperBlock));
|
||||
handle.Free();
|
||||
}
|
||||
else hammerSb = BigEndianMarshal.ByteArrayToStructureBigEndian<HammerSuperBlock>(sbSector);
|
||||
else hammerSb = Helpers.Marshal.ByteArrayToStructureBigEndian<HammerSuperBlock>(sbSector);
|
||||
|
||||
sb.AppendLine("HAMMER filesystem");
|
||||
|
||||
|
||||
@@ -94,9 +94,9 @@ namespace DiscImageChef.Filesystems
|
||||
Marshal.FreeHGlobal(bpbPtr);
|
||||
|
||||
MediaInformationBlock mib =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<MediaInformationBlock>(medInfoSector);
|
||||
Helpers.Marshal.ByteArrayToStructureBigEndian<MediaInformationBlock>(medInfoSector);
|
||||
VolumeInformationBlock vib =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<VolumeInformationBlock>(volInfoSector);
|
||||
Helpers.Marshal.ByteArrayToStructureBigEndian<VolumeInformationBlock>(volInfoSector);
|
||||
|
||||
DicConsole.DebugWriteLine("HPOFS Plugin", "bpb.oem_name = \"{0}\"",
|
||||
StringHandlers.CToString(bpb.oem_name));
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
}
|
||||
else if(cdi)
|
||||
fsvd =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<FileStructureVolumeDescriptor>(vdSector);
|
||||
Helpers.Marshal.ByteArrayToStructureBigEndian<FileStructureVolumeDescriptor>(vdSector);
|
||||
else
|
||||
{
|
||||
IntPtr ptr = Marshal.AllocHGlobal(2048);
|
||||
@@ -295,7 +295,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
|
||||
if(Marshal.SizeOf(typeof(CdromXa)) + saOff <= saLen)
|
||||
{
|
||||
CdromXa xa = BigEndianMarshal.ByteArrayToStructureBigEndian<CdromXa>(sa);
|
||||
CdromXa xa = Helpers.Marshal.ByteArrayToStructureBigEndian<CdromXa>(sa);
|
||||
if(xa.signature == XA_MAGIC)
|
||||
{
|
||||
xaExtensions = true;
|
||||
@@ -360,8 +360,8 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
case SUSP_CONTINUATION when saOff + sa[saOff + 2] <= saLen:
|
||||
byte[] ce = new byte[sa[saOff + 2]];
|
||||
Array.Copy(sa, saOff, ce, 0, ce.Length);
|
||||
ContinuationArea ca = BigEndianMarshal
|
||||
.ByteArrayToStructureBigEndian<ContinuationArea>(ce);
|
||||
ContinuationArea ca =
|
||||
Helpers.Marshal.ByteArrayToStructureBigEndian<ContinuationArea>(ce);
|
||||
contareas.Add(ca);
|
||||
break;
|
||||
case SUSP_REFERENCE when saOff + sa[saOff + 2] <= saLen:
|
||||
@@ -458,7 +458,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
counter = 1;
|
||||
foreach(byte[] erb in refareas)
|
||||
{
|
||||
ReferenceArea er = BigEndianMarshal.ByteArrayToStructureBigEndian<ReferenceArea>(erb);
|
||||
ReferenceArea er = Helpers.Marshal.ByteArrayToStructureBigEndian<ReferenceArea>(erb);
|
||||
string extId =
|
||||
Encoding.GetString(erb, Marshal.SizeOf(er), er.id_len);
|
||||
string extDes =
|
||||
|
||||
@@ -37,6 +37,7 @@ using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filesystems
|
||||
{
|
||||
@@ -56,7 +57,7 @@ namespace DiscImageChef.Filesystems
|
||||
if(imagePlugin.Info.SectorSize < 256) return false;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(partition.Start);
|
||||
LifSystemBlock lifSb = BigEndianMarshal.ByteArrayToStructureBigEndian<LifSystemBlock>(sector);
|
||||
LifSystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian<LifSystemBlock>(sector);
|
||||
DicConsole.DebugWriteLine("LIF plugin", "magic 0x{0:X8} (expected 0x{1:X8})", lifSb.magic, LIF_MAGIC);
|
||||
|
||||
return lifSb.magic == LIF_MAGIC;
|
||||
@@ -71,7 +72,7 @@ namespace DiscImageChef.Filesystems
|
||||
if(imagePlugin.Info.SectorSize < 256) return;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(partition.Start);
|
||||
LifSystemBlock lifSb = BigEndianMarshal.ByteArrayToStructureBigEndian<LifSystemBlock>(sector);
|
||||
LifSystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian<LifSystemBlock>(sector);
|
||||
|
||||
if(lifSb.magic != LIF_MAGIC) return;
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace DiscImageChef.Filesystems
|
||||
// Numerical arrays are not important for information so no need to swap them
|
||||
if(locusSb.s_magic == LOCUS_CIGAM || locusSb.s_magic == LOCUS_CIGAM_OLD)
|
||||
{
|
||||
locusSb = BigEndianMarshal.ByteArrayToStructureBigEndian<Locus_Superblock>(sector);
|
||||
locusSb = Helpers.Marshal.ByteArrayToStructureBigEndian<Locus_Superblock>(sector);
|
||||
locusSb.s_flags = (LocusFlags)Swapping.Swap((ushort)locusSb.s_flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace DiscImageChef.Filesystems
|
||||
typeof(Minix3SuperBlock));
|
||||
handle.Free();
|
||||
}
|
||||
else mnxSb = BigEndianMarshal.ByteArrayToStructureBigEndian<Minix3SuperBlock>(minixSbSector);
|
||||
else mnxSb = Helpers.Marshal.ByteArrayToStructureBigEndian<Minix3SuperBlock>(minixSbSector);
|
||||
|
||||
if(magic != MINIX3_MAGIC && magic != MINIX3_CIGAM) mnxSb.s_blocksize = 1024;
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace DiscImageChef.Filesystems
|
||||
typeof(MinixSuperBlock));
|
||||
handle.Free();
|
||||
}
|
||||
else mnxSb = BigEndianMarshal.ByteArrayToStructureBigEndian<MinixSuperBlock>(minixSbSector);
|
||||
else mnxSb = Helpers.Marshal.ByteArrayToStructureBigEndian<MinixSuperBlock>(minixSbSector);
|
||||
|
||||
sb.AppendLine(minixVersion);
|
||||
sb.AppendFormat("{0} chars in filename", filenamesize).AppendLine();
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filesystems
|
||||
{
|
||||
@@ -74,7 +75,7 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
byte[] sbSector = imagePlugin.ReadSector(0 + partition.Start);
|
||||
|
||||
OperaSuperBlock sb = BigEndianMarshal.ByteArrayToStructureBigEndian<OperaSuperBlock>(sbSector);
|
||||
OperaSuperBlock sb = Marshal.ByteArrayToStructureBigEndian<OperaSuperBlock>(sbSector);
|
||||
sb.sync_bytes = new byte[5];
|
||||
|
||||
if(sb.record_type != 1 || sb.record_version != 1) return;
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filesystems
|
||||
{
|
||||
@@ -87,7 +88,7 @@ namespace DiscImageChef.Filesystems
|
||||
{
|
||||
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1");
|
||||
byte[] rootBlockSector = imagePlugin.ReadSector(2 + partition.Start);
|
||||
RootBlock rootBlock = BigEndianMarshal.ByteArrayToStructureBigEndian<RootBlock>(rootBlockSector);
|
||||
RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndian<RootBlock>(rootBlockSector);
|
||||
|
||||
StringBuilder sbInformation = new StringBuilder();
|
||||
XmlFsType = new FileSystemType();
|
||||
|
||||
@@ -72,8 +72,8 @@ namespace DiscImageChef.Filesystems
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(rbfSb)) return false;
|
||||
|
||||
rbfSb = BigEndianMarshal.ByteArrayToStructureBigEndian<RBF_IdSector>(sector);
|
||||
RBF_NewIdSector rbf9000Sb = BigEndianMarshal.ByteArrayToStructureBigEndian<RBF_NewIdSector>(sector);
|
||||
rbfSb = Helpers.Marshal.ByteArrayToStructureBigEndian<RBF_IdSector>(sector);
|
||||
RBF_NewIdSector rbf9000Sb = Helpers.Marshal.ByteArrayToStructureBigEndian<RBF_NewIdSector>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("RBF plugin",
|
||||
"magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})",
|
||||
@@ -105,8 +105,8 @@ namespace DiscImageChef.Filesystems
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(rbfSb)) return;
|
||||
|
||||
rbfSb = BigEndianMarshal.ByteArrayToStructureBigEndian<RBF_IdSector>(sector);
|
||||
rbf9000Sb = BigEndianMarshal.ByteArrayToStructureBigEndian<RBF_NewIdSector>(sector);
|
||||
rbfSb = Helpers.Marshal.ByteArrayToStructureBigEndian<RBF_IdSector>(sector);
|
||||
rbf9000Sb = Helpers.Marshal.ByteArrayToStructureBigEndian<RBF_NewIdSector>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("RBF plugin",
|
||||
"magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})",
|
||||
@@ -118,7 +118,7 @@ namespace DiscImageChef.Filesystems
|
||||
if(rbfSb.dd_sync != RBF_SYNC && rbf9000Sb.rid_sync != RBF_SYNC && rbf9000Sb.rid_sync != RBF_CNYS) return;
|
||||
|
||||
if(rbf9000Sb.rid_sync == RBF_CNYS)
|
||||
rbf9000Sb = (RBF_NewIdSector)BigEndianMarshal.SwapStructureMembersEndian(rbf9000Sb);
|
||||
rbf9000Sb = (RBF_NewIdSector)Helpers.Marshal.SwapStructureMembersEndian(rbf9000Sb);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filesystems
|
||||
{
|
||||
@@ -70,7 +71,7 @@ namespace DiscImageChef.Filesystems
|
||||
{
|
||||
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1");
|
||||
byte[] rootBlockSector = imagePlugin.ReadSector(partition.Start);
|
||||
RootBlock rootBlock = BigEndianMarshal.ByteArrayToStructureBigEndian<RootBlock>(rootBlockSector);
|
||||
RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndian<RootBlock>(rootBlockSector);
|
||||
|
||||
StringBuilder sbInformation = new StringBuilder();
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace DiscImageChef.Filesystems
|
||||
Marshal.FreeHGlobal(sqSbPtr);
|
||||
break;
|
||||
case SQUASH_CIGAM:
|
||||
sqSb = BigEndianMarshal.ByteArrayToStructureBigEndian<SquashSuperBlock>(sector);
|
||||
sqSb = Helpers.Marshal.ByteArrayToStructureBigEndian<SquashSuperBlock>(sector);
|
||||
littleEndian = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace DiscImageChef.Filesystems
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(unicosSb)) return false;
|
||||
|
||||
unicosSb = BigEndianMarshal.ByteArrayToStructureBigEndian<UNICOS_Superblock>(sector);
|
||||
unicosSb = Helpers.Marshal.ByteArrayToStructureBigEndian<UNICOS_Superblock>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("UNICOS plugin", "magic = 0x{0:X16} (expected 0x{1:X16})", unicosSb.s_magic,
|
||||
UNICOS_MAGIC);
|
||||
@@ -97,7 +97,7 @@ namespace DiscImageChef.Filesystems
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(unicosSb)) return;
|
||||
|
||||
unicosSb = BigEndianMarshal.ByteArrayToStructureBigEndian<UNICOS_Superblock>(sector);
|
||||
unicosSb = Helpers.Marshal.ByteArrayToStructureBigEndian<UNICOS_Superblock>(sector);
|
||||
|
||||
if(unicosSb.s_magic != UNICOS_MAGIC) return;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace DiscImageChef.Filesystems
|
||||
{
|
||||
Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf(xfsSb));
|
||||
|
||||
xfsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<XFS_Superblock>(sbpiece);
|
||||
xfsSb = Helpers.Marshal.ByteArrayToStructureBigEndian<XFS_Superblock>(sbpiece);
|
||||
|
||||
DicConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})",
|
||||
location, xfsSb.magicnum, XFS_MAGIC);
|
||||
@@ -92,7 +92,7 @@ namespace DiscImageChef.Filesystems
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(xfsSb)) return false;
|
||||
|
||||
xfsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<XFS_Superblock>(sector);
|
||||
xfsSb = Helpers.Marshal.ByteArrayToStructureBigEndian<XFS_Superblock>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("XFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8})", location,
|
||||
xfsSb.magicnum, XFS_MAGIC);
|
||||
@@ -127,7 +127,7 @@ namespace DiscImageChef.Filesystems
|
||||
{
|
||||
Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf(xfsSb));
|
||||
|
||||
xfsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<XFS_Superblock>(sbpiece);
|
||||
xfsSb = Helpers.Marshal.ByteArrayToStructureBigEndian<XFS_Superblock>(sbpiece);
|
||||
|
||||
DicConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})",
|
||||
location, xfsSb.magicnum, XFS_MAGIC);
|
||||
@@ -145,7 +145,7 @@ namespace DiscImageChef.Filesystems
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(xfsSb)) return;
|
||||
|
||||
xfsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<XFS_Superblock>(sector);
|
||||
xfsSb = Helpers.Marshal.ByteArrayToStructureBigEndian<XFS_Superblock>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("XFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8})", location,
|
||||
xfsSb.magicnum, XFS_MAGIC);
|
||||
|
||||
@@ -186,14 +186,14 @@ namespace DiscImageChef.Filesystems
|
||||
newHdr.c_magic == NFS_CIGAM || newHdr.c_magic == UFS2_MAGIC || newHdr.c_magic == UFS2_CIGAM)
|
||||
{
|
||||
if(newHdr.c_magic == OFS_CIGAM || newHdr.c_magic == NFS_CIGAM || newHdr.c_magic == UFS2_CIGAM)
|
||||
newHdr = BigEndianMarshal.ByteArrayToStructureBigEndian<s_spcl>(sector);
|
||||
newHdr = Helpers.Marshal.ByteArrayToStructureBigEndian<s_spcl>(sector);
|
||||
}
|
||||
else if(aixHdr.c_magic == XIX_MAGIC || aixHdr.c_magic == XIX_CIGAM)
|
||||
{
|
||||
useAix = true;
|
||||
|
||||
if(aixHdr.c_magic == XIX_CIGAM)
|
||||
aixHdr = BigEndianMarshal.ByteArrayToStructureBigEndian<spcl_aix>(sector);
|
||||
aixHdr = Helpers.Marshal.ByteArrayToStructureBigEndian<spcl_aix>(sector);
|
||||
}
|
||||
else if(oldHdr.c_magic == OFS_MAGIC)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filters
|
||||
{
|
||||
@@ -157,7 +158,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] prodos_b = new byte[26];
|
||||
prodosStream.Read(prodos_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(prodos_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(prodos_b);
|
||||
prodosStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
@@ -172,7 +173,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] unix_b = new byte[26];
|
||||
unixStream.Read(unix_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unix_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unix_b);
|
||||
unixStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
@@ -187,7 +188,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] dos_b = new byte[26];
|
||||
dosStream.Read(dos_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dos_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dos_b);
|
||||
dosStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
@@ -202,7 +203,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] dosl_b = new byte[26];
|
||||
doslStream.Read(dosl_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dosl_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dosl_b);
|
||||
doslStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
@@ -217,7 +218,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] netatalk_b = new byte[26];
|
||||
netatalkStream.Read(netatalk_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(netatalk_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(netatalk_b);
|
||||
netatalkStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
@@ -232,7 +233,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] dave_b = new byte[26];
|
||||
daveStream.Read(dave_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dave_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dave_b);
|
||||
daveStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
@@ -247,7 +248,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] osx_b = new byte[26];
|
||||
osxStream.Read(osx_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(osx_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(osx_b);
|
||||
osxStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
@@ -262,7 +263,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] unar_b = new byte[26];
|
||||
unarStream.Read(unar_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unar_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unar_b);
|
||||
unarStream.Close();
|
||||
return header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2);
|
||||
@@ -315,7 +316,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] prodos_b = new byte[26];
|
||||
prodosStream.Read(prodos_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(prodos_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(prodos_b);
|
||||
prodosStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
@@ -331,7 +332,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] unix_b = new byte[26];
|
||||
unixStream.Read(unix_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unix_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unix_b);
|
||||
unixStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
@@ -347,7 +348,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] dos_b = new byte[26];
|
||||
dosStream.Read(dos_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dos_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dos_b);
|
||||
dosStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
@@ -363,7 +364,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] dosl_b = new byte[26];
|
||||
doslStream.Read(dosl_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dosl_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dosl_b);
|
||||
doslStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
@@ -379,7 +380,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] netatalk_b = new byte[26];
|
||||
netatalkStream.Read(netatalk_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(netatalk_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(netatalk_b);
|
||||
netatalkStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
@@ -395,7 +396,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] dave_b = new byte[26];
|
||||
daveStream.Read(dave_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dave_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dave_b);
|
||||
daveStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
@@ -411,7 +412,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] osx_b = new byte[26];
|
||||
osxStream.Read(osx_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(osx_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(osx_b);
|
||||
osxStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
@@ -427,7 +428,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
byte[] unar_b = new byte[26];
|
||||
unarStream.Read(unar_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unar_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unar_b);
|
||||
unarStream.Close();
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
@@ -440,14 +441,14 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[26];
|
||||
fs.Read(hdr_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(hdr_b);
|
||||
|
||||
AppleDoubleEntry[] entries = new AppleDoubleEntry[header.entries];
|
||||
for(int i = 0; i < header.entries; i++)
|
||||
{
|
||||
byte[] entry = new byte[12];
|
||||
fs.Read(entry, 0, 12);
|
||||
entries[i] = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleEntry>(entry);
|
||||
entries[i] = Marshal.ByteArrayToStructureBigEndian<AppleDoubleEntry>(entry);
|
||||
}
|
||||
|
||||
creationTime = DateTime.UtcNow;
|
||||
@@ -463,7 +464,7 @@ namespace DiscImageChef.Filters
|
||||
byte[] dates_b = new byte[16];
|
||||
fs.Read(dates_b, 0, 16);
|
||||
AppleDoubleFileDates dates =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleFileDates>(dates_b);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleDoubleFileDates>(dates_b);
|
||||
creationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate);
|
||||
lastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate);
|
||||
break;
|
||||
@@ -474,28 +475,28 @@ namespace DiscImageChef.Filters
|
||||
if(MacintoshHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleDoubleMacFileInfo macinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleMacFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleDoubleMacFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(macinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate);
|
||||
}
|
||||
else if(ProDOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleDoubleProDOSFileInfo prodosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleProDOSFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleDoubleProDOSFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
|
||||
}
|
||||
else if(UNIXHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleDoubleUNIXFileInfo unixinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleUNIXFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleDoubleUNIXFileInfo>(finfo);
|
||||
creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate);
|
||||
}
|
||||
else if(DOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleDoubleDOSFileInfo dosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleDOSFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleDoubleDOSFileInfo>(finfo);
|
||||
lastWriteTime =
|
||||
DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filters
|
||||
{
|
||||
@@ -148,7 +149,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[26];
|
||||
Array.Copy(buffer, 0, hdr_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
|
||||
return header.magic == AppleSingleMagic &&
|
||||
(header.version == AppleSingleVersion || header.version == AppleSingleVersion2);
|
||||
@@ -161,7 +162,7 @@ namespace DiscImageChef.Filters
|
||||
byte[] hdr_b = new byte[26];
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
stream.Read(hdr_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
|
||||
return header.magic == AppleSingleMagic &&
|
||||
(header.version == AppleSingleVersion || header.version == AppleSingleVersion2);
|
||||
@@ -174,7 +175,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[26];
|
||||
fstream.Read(hdr_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
|
||||
fstream.Close();
|
||||
return header.magic == AppleSingleMagic &&
|
||||
@@ -190,14 +191,14 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[26];
|
||||
ms.Read(hdr_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
|
||||
AppleSingleEntry[] entries = new AppleSingleEntry[header.entries];
|
||||
for(int i = 0; i < header.entries; i++)
|
||||
{
|
||||
byte[] entry = new byte[12];
|
||||
ms.Read(entry, 0, 12);
|
||||
entries[i] = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleEntry>(entry);
|
||||
entries[i] = Marshal.ByteArrayToStructureBigEndian<AppleSingleEntry>(entry);
|
||||
}
|
||||
|
||||
creationTime = DateTime.UtcNow;
|
||||
@@ -213,7 +214,7 @@ namespace DiscImageChef.Filters
|
||||
byte[] dates_b = new byte[16];
|
||||
ms.Read(dates_b, 0, 16);
|
||||
AppleSingleFileDates dates =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
creationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate);
|
||||
lastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate);
|
||||
break;
|
||||
@@ -224,28 +225,28 @@ namespace DiscImageChef.Filters
|
||||
if(MacintoshHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleMacFileInfo macinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(macinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate);
|
||||
}
|
||||
else if(ProDOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleProDOSFileInfo prodosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
|
||||
}
|
||||
else if(UNIXHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleUNIXFileInfo unixinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate);
|
||||
}
|
||||
else if(DOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleDOSFileInfo dosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
lastWriteTime =
|
||||
DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
}
|
||||
@@ -268,14 +269,14 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[26];
|
||||
stream.Read(hdr_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
|
||||
AppleSingleEntry[] entries = new AppleSingleEntry[header.entries];
|
||||
for(int i = 0; i < header.entries; i++)
|
||||
{
|
||||
byte[] entry = new byte[12];
|
||||
stream.Read(entry, 0, 12);
|
||||
entries[i] = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleEntry>(entry);
|
||||
entries[i] = Marshal.ByteArrayToStructureBigEndian<AppleSingleEntry>(entry);
|
||||
}
|
||||
|
||||
creationTime = DateTime.UtcNow;
|
||||
@@ -291,7 +292,7 @@ namespace DiscImageChef.Filters
|
||||
byte[] dates_b = new byte[16];
|
||||
stream.Read(dates_b, 0, 16);
|
||||
AppleSingleFileDates dates =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
creationTime = DateHandlers.MacToDateTime(dates.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate);
|
||||
break;
|
||||
@@ -302,28 +303,28 @@ namespace DiscImageChef.Filters
|
||||
if(MacintoshHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleMacFileInfo macinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(macinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate);
|
||||
}
|
||||
else if(ProDOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleProDOSFileInfo prodosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
|
||||
}
|
||||
else if(UNIXHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleUNIXFileInfo unixinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate);
|
||||
}
|
||||
else if(DOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleDOSFileInfo dosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
lastWriteTime =
|
||||
DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
}
|
||||
@@ -347,14 +348,14 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[26];
|
||||
fs.Read(hdr_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
|
||||
AppleSingleEntry[] entries = new AppleSingleEntry[header.entries];
|
||||
for(int i = 0; i < header.entries; i++)
|
||||
{
|
||||
byte[] entry = new byte[12];
|
||||
fs.Read(entry, 0, 12);
|
||||
entries[i] = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleEntry>(entry);
|
||||
entries[i] = Marshal.ByteArrayToStructureBigEndian<AppleSingleEntry>(entry);
|
||||
}
|
||||
|
||||
creationTime = DateTime.UtcNow;
|
||||
@@ -370,7 +371,7 @@ namespace DiscImageChef.Filters
|
||||
byte[] dates_b = new byte[16];
|
||||
fs.Read(dates_b, 0, 16);
|
||||
AppleSingleFileDates dates =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
creationTime = DateHandlers.MacToDateTime(dates.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate);
|
||||
break;
|
||||
@@ -381,28 +382,28 @@ namespace DiscImageChef.Filters
|
||||
if(MacintoshHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleMacFileInfo macinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(macinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate);
|
||||
}
|
||||
else if(ProDOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleProDOSFileInfo prodosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
|
||||
}
|
||||
else if(UNIXHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleUNIXFileInfo unixinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate);
|
||||
}
|
||||
else if(DOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleDOSFileInfo dosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
lastWriteTime =
|
||||
DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Filters
|
||||
{
|
||||
@@ -123,7 +124,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[128];
|
||||
Array.Copy(buffer, 0, hdr_b, 0, 128);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
|
||||
return header.magic == MACBINARY_MAGIC || header.version == 0 && header.filename[0] > 0 &&
|
||||
header.filename[0] < 64 && header.zero1 == 0 &&
|
||||
@@ -138,7 +139,7 @@ namespace DiscImageChef.Filters
|
||||
byte[] hdr_b = new byte[128];
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
stream.Read(hdr_b, 0, 128);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
|
||||
return header.magic == MACBINARY_MAGIC || header.version == 0 && header.filename[0] > 0 &&
|
||||
header.filename[0] < 64 && header.zero1 == 0 &&
|
||||
@@ -153,7 +154,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[128];
|
||||
fstream.Read(hdr_b, 0, 128);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
|
||||
fstream.Close();
|
||||
return header.magic == MACBINARY_MAGIC || header.version == 0 && header.filename[0] > 0 &&
|
||||
@@ -171,7 +172,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[128];
|
||||
ms.Read(hdr_b, 0, 128);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
|
||||
uint blocks = 1;
|
||||
blocks += (uint)(header.secondaryHeaderLength / 128);
|
||||
@@ -197,7 +198,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[128];
|
||||
stream.Read(hdr_b, 0, 128);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
|
||||
uint blocks = 1;
|
||||
blocks += (uint)(header.secondaryHeaderLength / 128);
|
||||
@@ -224,7 +225,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
byte[] hdr_b = new byte[128];
|
||||
fs.Read(hdr_b, 0, 128);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
header = Marshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
|
||||
uint blocks = 1;
|
||||
blocks += (uint)(header.secondaryHeaderLength / 128);
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace DiscImageChef.Filters
|
||||
PCExchangeEntry datEntry = new PCExchangeEntry();
|
||||
byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)];
|
||||
finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry));
|
||||
datEntry = BigEndianMarshal.ByteArrayToStructureBigEndian<PCExchangeEntry>(datEntry_b);
|
||||
datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian<PCExchangeEntry>(datEntry_b);
|
||||
// TODO: Add support for encoding on filters
|
||||
string macName =
|
||||
StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));
|
||||
@@ -173,7 +173,7 @@ namespace DiscImageChef.Filters
|
||||
PCExchangeEntry datEntry = new PCExchangeEntry();
|
||||
byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)];
|
||||
finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry));
|
||||
datEntry = BigEndianMarshal.ByteArrayToStructureBigEndian<PCExchangeEntry>(datEntry_b);
|
||||
datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian<PCExchangeEntry>(datEntry_b);
|
||||
string macName =
|
||||
StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));
|
||||
byte[] tmpDosName_b = new byte[8];
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : BigEndianMarshal.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides marshalling for big-endian data.
|
||||
//
|
||||
// --[ 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DiscImageChef
|
||||
{
|
||||
public static class BigEndianMarshal
|
||||
{
|
||||
/// <summary>
|
||||
/// Marshals a big endian structure from a byte array.
|
||||
/// Nested structures are still marshalled as little endian.
|
||||
/// </summary>
|
||||
/// <returns>The structure.</returns>
|
||||
/// <param name="bytes">Byte array.</param>
|
||||
/// <typeparam name="T">Structure type.</typeparam>
|
||||
public static T ByteArrayToStructureBigEndian<T>(byte[] bytes) where T : struct
|
||||
{
|
||||
GCHandle ptr = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
T str = (T)Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(T));
|
||||
ptr.Free();
|
||||
return (T)SwapStructureMembersEndian(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps endian of structure members that correspond to numerical types.
|
||||
/// Does not traverse nested structures.
|
||||
/// </summary>
|
||||
/// <returns>The structure with its members endian swapped.</returns>
|
||||
/// <param name="str">The structure.</param>
|
||||
public static object SwapStructureMembersEndian(object str)
|
||||
{
|
||||
Type t = str.GetType();
|
||||
FieldInfo[] fieldInfo = t.GetFields();
|
||||
foreach(FieldInfo fi in fieldInfo)
|
||||
if(fi.FieldType == typeof(short))
|
||||
{
|
||||
short x = (short)fi.GetValue(str);
|
||||
fi.SetValue(str, (short)((x << 8) | ((x >> 8) & 0xFF)));
|
||||
}
|
||||
else if(fi.FieldType == typeof(int))
|
||||
{
|
||||
int x = (int)fi.GetValue(str);
|
||||
x = (int)(((x << 8) & 0xFF00FF00) | (((uint)x >> 8) & 0xFF00FF));
|
||||
fi.SetValue(str, (int)(((uint)x << 16) | (((uint)x >> 16) & 0xFFFF)));
|
||||
}
|
||||
else if(fi.FieldType == typeof(long))
|
||||
{
|
||||
long x = (long)fi.GetValue(str);
|
||||
x = ((x & 0x00000000FFFFFFFF) << 32) | (long)(((ulong)x & 0xFFFFFFFF00000000) >> 32);
|
||||
x = ((x & 0x0000FFFF0000FFFF) << 16) | (long)(((ulong)x & 0xFFFF0000FFFF0000) >> 16);
|
||||
x = ((x & 0x00FF00FF00FF00FF) << 8) | (long)(((ulong)x & 0xFF00FF00FF00FF00) >> 8);
|
||||
|
||||
fi.SetValue(str, x);
|
||||
}
|
||||
else if(fi.FieldType == typeof(ushort))
|
||||
{
|
||||
ushort x = (ushort)fi.GetValue(str);
|
||||
fi.SetValue(str, (ushort)((x << 8) | (x >> 8)));
|
||||
}
|
||||
else if(fi.FieldType == typeof(uint))
|
||||
{
|
||||
uint x = (uint)fi.GetValue(str);
|
||||
x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF);
|
||||
fi.SetValue(str, (x << 16) | (x >> 16));
|
||||
}
|
||||
else if(fi.FieldType == typeof(ulong))
|
||||
{
|
||||
ulong x = (ulong)fi.GetValue(str);
|
||||
x = ((x & 0x00000000FFFFFFFF) << 32) | ((x & 0xFFFFFFFF00000000) >> 32);
|
||||
x = ((x & 0x0000FFFF0000FFFF) << 16) | ((x & 0xFFFF0000FFFF0000) >> 16);
|
||||
x = ((x & 0x00FF00FF00FF00FF) << 8) | ((x & 0xFF00FF00FF00FF00) >> 8);
|
||||
fi.SetValue(str, x);
|
||||
}
|
||||
else if(fi.FieldType == typeof(float))
|
||||
{
|
||||
float flt = (float)fi.GetValue(str);
|
||||
byte[] flt_b = BitConverter.GetBytes(flt);
|
||||
fi.SetValue(str, BitConverter.ToSingle(new[] {flt_b[3], flt_b[2], flt_b[1], flt_b[0]}, 0));
|
||||
}
|
||||
else if(fi.FieldType == typeof(double))
|
||||
{
|
||||
double dbl = (double)fi.GetValue(str);
|
||||
byte[] dbl_b = BitConverter.GetBytes(dbl);
|
||||
fi.SetValue(str,
|
||||
BitConverter
|
||||
.ToDouble(new[] {dbl_b[7], dbl_b[6], dbl_b[5], dbl_b[4], dbl_b[3], dbl_b[2], dbl_b[1], dbl_b[0]},
|
||||
0));
|
||||
}
|
||||
else if(fi.FieldType == typeof(byte) || fi.FieldType == typeof(sbyte))
|
||||
{
|
||||
// Do nothing, can't byteswap them!
|
||||
}
|
||||
else if(fi.FieldType == typeof(Guid))
|
||||
{
|
||||
// TODO: Swap GUID
|
||||
}
|
||||
// TODO: Swap arrays and enums
|
||||
else if(fi.FieldType.IsValueType && !fi.FieldType.IsEnum && !fi.FieldType.IsArray)
|
||||
{
|
||||
object obj = fi.GetValue(str);
|
||||
Type ty = obj.GetType();
|
||||
object strc = SwapStructureMembersEndian(obj);
|
||||
fi.SetValue(str, strc);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Enums
|
||||
namespace DiscImageChef.Helpers
|
||||
{
|
||||
/// <summary>Describes the endianness of bits on a data structure</summary>
|
||||
public enum BitEndian
|
||||
@@ -48,12 +48,14 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="ArrayFill.cs" />
|
||||
<Compile Include="BigEndianBitConverter.cs" />
|
||||
<Compile Include="BitEndian.cs" />
|
||||
<Compile Include="DateHandlers.cs" />
|
||||
<Compile Include="Marshal.cs" />
|
||||
<Compile Include="MarshallingPropertiesAttribute.cs" />
|
||||
<Compile Include="PrintHex.cs" />
|
||||
<Compile Include="StringHandlers.cs" />
|
||||
<Compile Include="Swapping.cs" />
|
||||
<Compile Include="ArrayIsEmpty.cs" />
|
||||
<Compile Include="BigEndianMarshal.cs" />
|
||||
<Compile Include="CompareBytes.cs" />
|
||||
<Compile Include="CountBits.cs" />
|
||||
<Compile Include="CHS.cs" />
|
||||
@@ -70,6 +72,7 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Memory" Version="4.5.2" />
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.2.5" />
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
|
||||
283
DiscImageChef.Helpers/Marshal.cs
Normal file
283
DiscImageChef.Helpers/Marshal.cs
Normal file
@@ -0,0 +1,283 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Marshal.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Helpers.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides marshalling for binary data.
|
||||
//
|
||||
// --[ 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DiscImageChef.Helpers
|
||||
{
|
||||
/// <summary>Provides methods to marshal binary data into C# structs</summary>
|
||||
public static class Marshal
|
||||
{
|
||||
static int count;
|
||||
|
||||
/// <summary>
|
||||
/// Marshal little-endian binary data to a structure
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
public static T ByteArrayToStructureLittleEndian<T>(byte[] bytes) where T : struct
|
||||
{
|
||||
GCHandle ptr = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
T str =
|
||||
(T)System.Runtime.InteropServices.Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(T));
|
||||
ptr.Free();
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marshal big-endian binary data to a structure
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
public static T ByteArrayToStructureBigEndian<T>(byte[] bytes) where T : struct
|
||||
{
|
||||
GCHandle ptr = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
object str =
|
||||
(T)System.Runtime.InteropServices.Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(T));
|
||||
ptr.Free();
|
||||
return (T)SwapStructureMembersEndian(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marshal PDP-11 binary data to a structure
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
public static T ByteArrayToStructurePdpEndian<T>(byte[] bytes) where T : struct
|
||||
{
|
||||
{
|
||||
GCHandle ptr = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
object str =
|
||||
(T)System.Runtime.InteropServices.Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(T));
|
||||
ptr.Free();
|
||||
return (T)SwapStructureMembersEndianPdp(str);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marshal little-endian binary data to a structure. If the structure type contains any non value type, this method
|
||||
/// will crash.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
public static T SpanToStructureLittleEndian<T>(ReadOnlySpan<byte> bytes) where T : struct =>
|
||||
MemoryMarshal.Read<T>(bytes);
|
||||
|
||||
/// <summary>
|
||||
/// Marshal big-endian binary data to a structure. If the structure type contains any non value type, this method will
|
||||
/// crash.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
public static T SpanToStructureBigEndian<T>(ReadOnlySpan<byte> bytes) where T : struct
|
||||
{
|
||||
T str = SpanToStructureLittleEndian<T>(bytes);
|
||||
return (T)SwapStructureMembersEndian(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marshal PDP-11 binary data to a structure. If the structure type contains any non value type, this method will
|
||||
/// crash.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
public static T SpanToStructurePdpEndian<T>(ReadOnlySpan<byte> bytes) where T : struct
|
||||
{
|
||||
object str = SpanToStructureLittleEndian<T>(bytes);
|
||||
return (T)SwapStructureMembersEndianPdp(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marshal a structure depending on the decoration of <see cref="MarshallingPropertiesAttribute" />. If the decoration
|
||||
/// is not present it will marshal as a reference type containing little endian structure.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the binary data</param>
|
||||
/// <typeparam name="T">Type of the structure to marshal</typeparam>
|
||||
/// <returns>The binary data marshalled in a structure with the specified type</returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// The <see cref="MarshallingPropertiesAttribute" /> contains an unsupported
|
||||
/// endian
|
||||
/// </exception>
|
||||
public static T MarshalStructure<T>(byte[] bytes) where T : struct
|
||||
{
|
||||
if(!(typeof(T).GetCustomAttribute(typeof(MarshallingPropertiesAttribute)) is MarshallingPropertiesAttribute
|
||||
properties)) return ByteArrayToStructureLittleEndian<T>(bytes);
|
||||
|
||||
switch(properties.Endian)
|
||||
{
|
||||
case BitEndian.Little:
|
||||
return properties.HasReferences
|
||||
? ByteArrayToStructureLittleEndian<T>(bytes)
|
||||
: SpanToStructureLittleEndian<T>(bytes);
|
||||
|
||||
break;
|
||||
case BitEndian.Big:
|
||||
return properties.HasReferences
|
||||
? ByteArrayToStructureBigEndian<T>(bytes)
|
||||
: SpanToStructureBigEndian<T>(bytes);
|
||||
|
||||
break;
|
||||
|
||||
case BitEndian.Pdp:
|
||||
return properties.HasReferences
|
||||
? ByteArrayToStructurePdpEndian<T>(bytes)
|
||||
: SpanToStructurePdpEndian<T>(bytes);
|
||||
default: throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps all members of a structure
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
public static object SwapStructureMembersEndian(object str)
|
||||
{
|
||||
Type t = str.GetType();
|
||||
FieldInfo[] fieldInfo = t.GetFields();
|
||||
foreach(FieldInfo fi in fieldInfo)
|
||||
if(fi.FieldType == typeof(short))
|
||||
{
|
||||
short x = (short)fi.GetValue(str);
|
||||
fi.SetValue(str, (short)((x << 8) | ((x >> 8) & 0xFF)));
|
||||
}
|
||||
else if(fi.FieldType == typeof(int))
|
||||
{
|
||||
int x = (int)fi.GetValue(str);
|
||||
x = (int)(((x << 8) & 0xFF00FF00) | (((uint)x >> 8) & 0xFF00FF));
|
||||
fi.SetValue(str, (int)(((uint)x << 16) | (((uint)x >> 16) & 0xFFFF)));
|
||||
}
|
||||
else if(fi.FieldType == typeof(long))
|
||||
{
|
||||
long x = (long)fi.GetValue(str);
|
||||
x = ((x & 0x00000000FFFFFFFF) << 32) | (long)(((ulong)x & 0xFFFFFFFF00000000) >> 32);
|
||||
x = ((x & 0x0000FFFF0000FFFF) << 16) | (long)(((ulong)x & 0xFFFF0000FFFF0000) >> 16);
|
||||
x = ((x & 0x00FF00FF00FF00FF) << 8) | (long)(((ulong)x & 0xFF00FF00FF00FF00) >> 8);
|
||||
|
||||
fi.SetValue(str, x);
|
||||
}
|
||||
else if(fi.FieldType == typeof(ushort))
|
||||
{
|
||||
ushort x = (ushort)fi.GetValue(str);
|
||||
fi.SetValue(str, (ushort)((x << 8) | (x >> 8)));
|
||||
}
|
||||
else if(fi.FieldType == typeof(uint))
|
||||
{
|
||||
uint x = (uint)fi.GetValue(str);
|
||||
x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF);
|
||||
fi.SetValue(str, (x << 16) | (x >> 16));
|
||||
}
|
||||
else if(fi.FieldType == typeof(ulong))
|
||||
{
|
||||
ulong x = (ulong)fi.GetValue(str);
|
||||
x = ((x & 0x00000000FFFFFFFF) << 32) | ((x & 0xFFFFFFFF00000000) >> 32);
|
||||
x = ((x & 0x0000FFFF0000FFFF) << 16) | ((x & 0xFFFF0000FFFF0000) >> 16);
|
||||
x = ((x & 0x00FF00FF00FF00FF) << 8) | ((x & 0xFF00FF00FF00FF00) >> 8);
|
||||
fi.SetValue(str, x);
|
||||
}
|
||||
else if(fi.FieldType == typeof(float))
|
||||
{
|
||||
float flt = (float)fi.GetValue(str);
|
||||
byte[] flt_b = BitConverter.GetBytes(flt);
|
||||
fi.SetValue(str, BitConverter.ToSingle(new[] {flt_b[3], flt_b[2], flt_b[1], flt_b[0]}, 0));
|
||||
}
|
||||
else if(fi.FieldType == typeof(double))
|
||||
{
|
||||
double dbl = (double)fi.GetValue(str);
|
||||
byte[] dbl_b = BitConverter.GetBytes(dbl);
|
||||
fi.SetValue(str,
|
||||
BitConverter
|
||||
.ToDouble(new[] {dbl_b[7], dbl_b[6], dbl_b[5], dbl_b[4], dbl_b[3], dbl_b[2], dbl_b[1], dbl_b[0]},
|
||||
0));
|
||||
}
|
||||
else if(fi.FieldType == typeof(byte) || fi.FieldType == typeof(sbyte))
|
||||
{
|
||||
// Do nothing, can't byteswap them!
|
||||
}
|
||||
else if(fi.FieldType == typeof(Guid))
|
||||
{
|
||||
// TODO: Swap GUID
|
||||
}
|
||||
// TODO: Swap arrays and enums
|
||||
else if(fi.FieldType.IsValueType && !fi.FieldType.IsEnum && !fi.FieldType.IsArray)
|
||||
{
|
||||
object obj = fi.GetValue(str);
|
||||
object strc = SwapStructureMembersEndian(obj);
|
||||
fi.SetValue(str, strc);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public static object SwapStructureMembersEndianPdp(object str)
|
||||
{
|
||||
Type t = str.GetType();
|
||||
FieldInfo[] fieldInfo = t.GetFields();
|
||||
foreach(FieldInfo fi in fieldInfo)
|
||||
if(fi.FieldType == typeof(short) || fi.FieldType == typeof(long) || fi.FieldType == typeof(ushort) ||
|
||||
fi.FieldType == typeof(ulong) || fi.FieldType == typeof(float) || fi.FieldType == typeof(double) ||
|
||||
fi.FieldType == typeof(byte) || fi.FieldType == typeof(sbyte) || fi.FieldType == typeof(Guid))
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else if(fi.FieldType == typeof(int))
|
||||
{
|
||||
int x = (int)fi.GetValue(str);
|
||||
fi.SetValue(str, ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16));
|
||||
}
|
||||
else if(fi.FieldType == typeof(uint))
|
||||
{
|
||||
uint x = (uint)fi.GetValue(str);
|
||||
fi.SetValue(str, ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16));
|
||||
}
|
||||
// TODO: Swap arrays and enums
|
||||
else if(fi.FieldType.IsValueType && !fi.FieldType.IsEnum && !fi.FieldType.IsArray)
|
||||
{
|
||||
System.Console.WriteLine("PDP {0}", count++);
|
||||
|
||||
object obj = fi.GetValue(str);
|
||||
object strc = SwapStructureMembersEndianPdp(obj);
|
||||
fi.SetValue(str, strc);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,9 +37,8 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Attributes
|
||||
namespace DiscImageChef.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines properties to help marshalling structs from binary data
|
||||
@@ -37,6 +37,7 @@ using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
@@ -83,8 +84,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
else if(sectorSize < 256) return false;
|
||||
|
||||
AppleDriverDescriptorMap ddm =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDriverDescriptorMap>(ddmSector);
|
||||
AppleDriverDescriptorMap ddm = Marshal.ByteArrayToStructureBigEndian<AppleDriverDescriptorMap>(ddmSector);
|
||||
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbSig = 0x{0:X4}", ddm.sbSig);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbBlockSize = {0}", ddm.sbBlockSize);
|
||||
@@ -104,7 +104,7 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
byte[] tmp = new byte[8];
|
||||
Array.Copy(ddmSector, 18 + i * 8, tmp, 0, 8);
|
||||
ddm.sbMap[i] = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDriverEntry>(tmp);
|
||||
ddm.sbMap[i] = Marshal.ByteArrayToStructureBigEndian<AppleDriverEntry>(tmp);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddBlock = {0}",
|
||||
ddm.sbMap[i].ddBlock, i);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddSize = {0}", ddm.sbMap[i].ddSize,
|
||||
@@ -134,7 +134,7 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
byte[] partSector = imagePlugin.ReadSector(1 + sectorOffset);
|
||||
AppleOldDevicePartitionMap oldMap =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleOldDevicePartitionMap>(partSector);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleOldDevicePartitionMap>(partSector);
|
||||
|
||||
// This is the easy one, no sector size mixing
|
||||
if(oldMap.pdSig == APM_MAGIC_OLD)
|
||||
@@ -144,7 +144,7 @@ namespace DiscImageChef.Partitions
|
||||
byte[] tmp = new byte[12];
|
||||
Array.Copy(partSector, i, tmp, 0, 12);
|
||||
AppleMapOldPartitionEntry oldEntry =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapOldPartitionEntry>(tmp);
|
||||
Marshal.ByteArrayToStructureBigEndian<AppleMapOldPartitionEntry>(tmp);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdStart = {0}", oldEntry.pdStart,
|
||||
(i - 2) / 12);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdSize = {0}", oldEntry.pdSize,
|
||||
@@ -189,7 +189,7 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
byte[] tmp = new byte[512];
|
||||
Array.Copy(ddmSector, 512, tmp, 0, 512);
|
||||
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(tmp);
|
||||
entry = Marshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(tmp);
|
||||
// Check for a partition entry that's 512-byte aligned
|
||||
if(entry.signature == APM_MAGIC)
|
||||
{
|
||||
@@ -201,7 +201,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
else
|
||||
{
|
||||
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(partSector);
|
||||
entry = Marshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(partSector);
|
||||
if(entry.signature == APM_MAGIC)
|
||||
{
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "Found aligned entry.");
|
||||
@@ -215,7 +215,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
else
|
||||
{
|
||||
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(partSector);
|
||||
entry = Marshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(partSector);
|
||||
if(entry.signature == APM_MAGIC)
|
||||
{
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "Found aligned entry.");
|
||||
@@ -241,7 +241,7 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
byte[] tmp = new byte[entrySize];
|
||||
Array.Copy(entries, i * entrySize, tmp, 0, entrySize);
|
||||
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(tmp);
|
||||
entry = Marshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(tmp);
|
||||
if(entry.signature != APM_MAGIC) continue;
|
||||
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].signature = 0x{1:X4}", i, entry.signature);
|
||||
|
||||
@@ -214,14 +214,13 @@ namespace DiscImageChef.Partitions
|
||||
return dl;
|
||||
}
|
||||
|
||||
static DiskLabel SwapDiskLabel(DiskLabel disklabel)
|
||||
static DiskLabel SwapDiskLabel(DiskLabel dl)
|
||||
{
|
||||
DiskLabel dl =
|
||||
(DiskLabel)BigEndianMarshal.SwapStructureMembersEndian(disklabel);
|
||||
dl = (DiskLabel)Helpers.Marshal.SwapStructureMembersEndian(dl);
|
||||
for(int i = 0; i < dl.d_drivedata.Length; i++) dl.d_drivedata[i] = Swapping.Swap(dl.d_drivedata[i]);
|
||||
for(int i = 0; i < dl.d_spare.Length; i++) dl.d_spare[i] = Swapping.Swap(dl.d_spare[i]);
|
||||
for(int i = 0; i < dl.d_partitions.Length; i++)
|
||||
dl.d_partitions[i] = (BSDPartition)BigEndianMarshal.SwapStructureMembersEndian(dl.d_partitions[i]);
|
||||
dl.d_partitions[i] = (BSDPartition)Helpers.Marshal.SwapStructureMembersEndian(dl.d_partitions[i]);
|
||||
|
||||
return dl;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
@@ -76,14 +77,14 @@ namespace DiscImageChef.Partitions
|
||||
default: return false;
|
||||
}
|
||||
|
||||
X68kTable table = BigEndianMarshal.ByteArrayToStructureBigEndian<X68kTable>(sector);
|
||||
X68kTable table = Marshal.ByteArrayToStructureBigEndian<X68kTable>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("Human68k plugin", "table.magic = {0:X4}", table.magic);
|
||||
|
||||
if(table.magic != X68K_MAGIC) return false;
|
||||
|
||||
for(int i = 0; i < table.entries.Length; i++)
|
||||
table.entries[i] = (X68kEntry)BigEndianMarshal.SwapStructureMembersEndian(table.entries[i]);
|
||||
table.entries[i] = (X68kEntry)Marshal.SwapStructureMembersEndian(table.entries[i]);
|
||||
|
||||
DicConsole.DebugWriteLine("Human68k plugin", "table.size = {0:X4}", table.size);
|
||||
DicConsole.DebugWriteLine("Human68k plugin", "table.size2 = {0:X4}", table.size2);
|
||||
|
||||
@@ -38,6 +38,7 @@ using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Helpers;
|
||||
using Marshal = System.Runtime.InteropServices.Marshal;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@ using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
// Information learnt from XNU source and testing against real disks
|
||||
namespace DiscImageChef.Partitions
|
||||
@@ -95,10 +96,10 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
labelSector = imagePlugin.ReadSectors(labelPosition, sectorsToRead);
|
||||
|
||||
NeXTLabel label = BigEndianMarshal.ByteArrayToStructureBigEndian<NeXTLabel>(labelSector);
|
||||
NeXTLabel label = Marshal.ByteArrayToStructureBigEndian<NeXTLabel>(labelSector);
|
||||
byte[] disktabB = new byte[498];
|
||||
Array.Copy(labelSector, 44, disktabB, 0, 498);
|
||||
label.dl_dt = BigEndianMarshal.ByteArrayToStructureBigEndian<NeXTDiskTab>(disktabB);
|
||||
label.dl_dt = Marshal.ByteArrayToStructureBigEndian<NeXTDiskTab>(disktabB);
|
||||
label.dl_dt.d_partitions = new NeXTEntry[8];
|
||||
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_version = 0x{0:X8}", label.dl_version);
|
||||
@@ -138,7 +139,7 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
byte[] partB = new byte[44];
|
||||
Array.Copy(labelSector, 44 + 146 + 44 * i, partB, 0, 44);
|
||||
label.dl_dt.d_partitions[i] = BigEndianMarshal.ByteArrayToStructureBigEndian<NeXTEntry>(partB);
|
||||
label.dl_dt.d_partitions[i] = Marshal.ByteArrayToStructureBigEndian<NeXTEntry>(partB);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_base = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_base);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i,
|
||||
|
||||
@@ -38,6 +38,7 @@ using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Helpers;
|
||||
using Marshal = System.Runtime.InteropServices.Marshal;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
#pragma warning disable 169
|
||||
#pragma warning disable 649
|
||||
@@ -59,11 +60,12 @@ namespace DiscImageChef.Partitions
|
||||
byte[] sector = imagePlugin.ReadSector(sectorOffset);
|
||||
if(sector.Length < 512) return false;
|
||||
|
||||
SGILabel dvh = BigEndianMarshal.ByteArrayToStructureBigEndian<SGILabel>(sector);
|
||||
SGILabel dvh = Marshal.ByteArrayToStructureBigEndian<SGILabel>(sector);
|
||||
for(int i = 0; i < dvh.volume.Length; i++)
|
||||
dvh.volume[i] = (SGIVolume)BigEndianMarshal.SwapStructureMembersEndian(dvh.volume[i]);
|
||||
dvh.volume[i] = (SGIVolume)Marshal.SwapStructureMembersEndian(dvh.volume[i]);
|
||||
|
||||
for(int i = 0; i < dvh.partitions.Length; i++)
|
||||
dvh.partitions[i] = (SGIPartition)BigEndianMarshal.SwapStructureMembersEndian(dvh.partitions[i]);
|
||||
dvh.partitions[i] = (SGIPartition)Marshal.SwapStructureMembersEndian(dvh.partitions[i]);
|
||||
|
||||
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.magic = 0x{0:X8} (should be 0x{1:X8})", dvh.magic,
|
||||
SGI_MAGIC);
|
||||
|
||||
@@ -322,55 +322,56 @@ namespace DiscImageChef.Partitions
|
||||
static dk_label SwapDiskLabel(dk_label label)
|
||||
{
|
||||
DicConsole.DebugWriteLine("Sun plugin", "Swapping dk_label");
|
||||
dk_label lebal = (dk_label)BigEndianMarshal.SwapStructureMembersEndian(label);
|
||||
label = (dk_label)Helpers.Marshal.SwapStructureMembersEndian(label);
|
||||
for(int i = 0; i < label.dkl_map.Length; i++)
|
||||
lebal.dkl_map[i] = (dk_map)BigEndianMarshal.SwapStructureMembersEndian(label.dkl_map[i]);
|
||||
label.dkl_map[i] = (dk_map)Helpers.Marshal.SwapStructureMembersEndian(label.dkl_map[i]);
|
||||
|
||||
return lebal;
|
||||
return label;
|
||||
}
|
||||
|
||||
static dk_label8 SwapDiskLabel(dk_label8 label)
|
||||
{
|
||||
DicConsole.DebugWriteLine("Sun plugin", "Swapping dk_label8");
|
||||
dk_label8 lebal = (dk_label8)BigEndianMarshal.SwapStructureMembersEndian(label);
|
||||
label = (dk_label8)Helpers.Marshal.SwapStructureMembersEndian(label);
|
||||
for(int i = 0; i < label.dkl_map.Length; i++)
|
||||
lebal.dkl_map[i] = (dk_map)BigEndianMarshal.SwapStructureMembersEndian(label.dkl_map[i]);
|
||||
label.dkl_map[i] = (dk_map)Helpers.Marshal.SwapStructureMembersEndian(label.dkl_map[i]);
|
||||
|
||||
for(int i = 0; i < label.dkl_vtoc.v_bootinfo.Length; i++)
|
||||
lebal.dkl_vtoc.v_bootinfo[i] = Swapping.Swap(label.dkl_vtoc.v_bootinfo[i]);
|
||||
label.dkl_vtoc.v_bootinfo[i] = Swapping.Swap(label.dkl_vtoc.v_bootinfo[i]);
|
||||
for(int i = 0; i < label.dkl_vtoc.v_part.Length; i++)
|
||||
{
|
||||
lebal.dkl_vtoc.v_part[i].p_flag = (SunFlags)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_flag);
|
||||
lebal.dkl_vtoc.v_part[i].p_tag = (SunTag)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_tag);
|
||||
label.dkl_vtoc.v_part[i].p_flag = (SunFlags)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_flag);
|
||||
label.dkl_vtoc.v_part[i].p_tag = (SunTag)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_tag);
|
||||
}
|
||||
|
||||
for(int i = 0; i < label.dkl_vtoc.v_timestamp.Length; i++)
|
||||
lebal.dkl_vtoc.v_timestamp[i] = Swapping.Swap(label.dkl_vtoc.v_timestamp[i]);
|
||||
label.dkl_vtoc.v_timestamp[i] = Swapping.Swap(label.dkl_vtoc.v_timestamp[i]);
|
||||
for(int i = 0; i < label.dkl_vtoc.v_reserved.Length; i++)
|
||||
lebal.dkl_vtoc.v_reserved[i] = Swapping.Swap(label.dkl_vtoc.v_reserved[i]);
|
||||
label.dkl_vtoc.v_reserved[i] = Swapping.Swap(label.dkl_vtoc.v_reserved[i]);
|
||||
|
||||
return lebal;
|
||||
return label;
|
||||
}
|
||||
|
||||
static dk_label16 SwapDiskLabel(dk_label16 label)
|
||||
{
|
||||
DicConsole.DebugWriteLine("Sun plugin", "Swapping dk_label16");
|
||||
dk_label16 lebal = (dk_label16)BigEndianMarshal.SwapStructureMembersEndian(label);
|
||||
label = (dk_label16)Helpers.Marshal.SwapStructureMembersEndian(label);
|
||||
for(int i = 0; i < label.dkl_vtoc.v_bootinfo.Length; i++)
|
||||
lebal.dkl_vtoc.v_bootinfo[i] = Swapping.Swap(label.dkl_vtoc.v_bootinfo[i]);
|
||||
label.dkl_vtoc.v_bootinfo[i] = Swapping.Swap(label.dkl_vtoc.v_bootinfo[i]);
|
||||
for(int i = 0; i < label.dkl_vtoc.v_part.Length; i++)
|
||||
{
|
||||
lebal.dkl_vtoc.v_part[i].p_flag = (SunFlags)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_flag);
|
||||
lebal.dkl_vtoc.v_part[i].p_tag = (SunTag)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_tag);
|
||||
lebal.dkl_vtoc.v_part[i].p_size = Swapping.Swap(label.dkl_vtoc.v_part[i].p_size);
|
||||
lebal.dkl_vtoc.v_part[i].p_start = Swapping.Swap(label.dkl_vtoc.v_part[i].p_start);
|
||||
label.dkl_vtoc.v_part[i].p_flag = (SunFlags)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_flag);
|
||||
label.dkl_vtoc.v_part[i].p_tag = (SunTag)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_tag);
|
||||
label.dkl_vtoc.v_part[i].p_size = Swapping.Swap(label.dkl_vtoc.v_part[i].p_size);
|
||||
label.dkl_vtoc.v_part[i].p_start = Swapping.Swap(label.dkl_vtoc.v_part[i].p_start);
|
||||
}
|
||||
|
||||
for(int i = 0; i < label.dkl_vtoc.v_timestamp.Length; i++)
|
||||
lebal.dkl_vtoc.v_timestamp[i] = Swapping.Swap(label.dkl_vtoc.v_timestamp[i]);
|
||||
label.dkl_vtoc.v_timestamp[i] = Swapping.Swap(label.dkl_vtoc.v_timestamp[i]);
|
||||
for(int i = 0; i < label.dkl_vtoc.v_reserved.Length; i++)
|
||||
lebal.dkl_vtoc.v_reserved[i] = Swapping.Swap(label.dkl_vtoc.v_reserved[i]);
|
||||
label.dkl_vtoc.v_reserved[i] = Swapping.Swap(label.dkl_vtoc.v_reserved[i]);
|
||||
|
||||
return lebal;
|
||||
return label;
|
||||
}
|
||||
|
||||
static string SunFlagsToString(SunFlags flags)
|
||||
|
||||
@@ -91,8 +91,8 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
else
|
||||
{
|
||||
pd = BigEndianMarshal.ByteArrayToStructureBigEndian<PDInfo>(pdsector);
|
||||
pdold = BigEndianMarshal.ByteArrayToStructureBigEndian<PDInfoOld>(pdsector);
|
||||
pd = Helpers.Marshal.ByteArrayToStructureBigEndian<PDInfo>(pdsector);
|
||||
pdold = Helpers.Marshal.ByteArrayToStructureBigEndian<PDInfoOld>(pdsector);
|
||||
}
|
||||
|
||||
DicConsole.DebugWriteLine("VTOC plugin", "pdinfo.driveid = {0}", pd.driveid);
|
||||
@@ -157,7 +157,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
else
|
||||
{
|
||||
vtoc = BigEndianMarshal.ByteArrayToStructureBigEndian<vtoc>(vtocsector);
|
||||
vtoc = Helpers.Marshal.ByteArrayToStructureBigEndian<vtoc>(vtocsector);
|
||||
for(int i = 0; i < vtoc.v_part.Length; i++)
|
||||
{
|
||||
vtoc.v_part[i].p_tag = (pTag)Swapping.Swap((ushort)vtoc.v_part[i].p_tag);
|
||||
@@ -186,7 +186,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
else
|
||||
{
|
||||
vtocOld = BigEndianMarshal.ByteArrayToStructureBigEndian<vtocold>(vtocsector);
|
||||
vtocOld = Helpers.Marshal.ByteArrayToStructureBigEndian<vtocold>(vtocsector);
|
||||
for(int i = 0; i < vtocOld.v_part.Length; i++)
|
||||
{
|
||||
vtocOld.v_part[i].p_tag = (pTag)Swapping.Swap((ushort)vtocOld.v_part[i].p_tag);
|
||||
@@ -232,7 +232,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
else
|
||||
{
|
||||
vtoc = BigEndianMarshal.ByteArrayToStructureBigEndian<vtoc>(vtocsector);
|
||||
vtoc = Helpers.Marshal.ByteArrayToStructureBigEndian<vtoc>(vtocsector);
|
||||
for(int i = 0; i < vtoc.v_part.Length; i++)
|
||||
{
|
||||
vtoc.v_part[i].p_tag = (pTag)Swapping.Swap((ushort)vtoc.v_part[i].p_tag);
|
||||
|
||||
@@ -35,6 +35,7 @@ using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
@@ -75,7 +76,7 @@ namespace DiscImageChef.Partitions
|
||||
if(sector.Length < 512) return false;
|
||||
|
||||
Xbox360DevKitPartitionTable table =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<Xbox360DevKitPartitionTable>(sector);
|
||||
Marshal.ByteArrayToStructureBigEndian<Xbox360DevKitPartitionTable>(sector);
|
||||
|
||||
if(table.magic == XBOX360_DEVKIT_MAGIC &&
|
||||
table.contentOff + table.contentLen <= imagePlugin.Info.Sectors &&
|
||||
|
||||
Reference in New Issue
Block a user