Moved disc image plugins to a separate library.

This commit is contained in:
2015-10-05 19:45:07 +01:00
parent 9530cc1a7a
commit 4a3583d13e
29 changed files with 450 additions and 211 deletions

View File

@@ -1,3 +1,27 @@
2015-10-05 Natalia Portillo <claunia@claunia.com>
* Plugins.cs:
* PartPlugins/RDB.cs:
* PartPlugins/MBR.cs:
* ImagePlugins/VHD.cs:
* PartPlugins/NeXT.cs:
* Commands/Analyze.cs:
* ImagePlugins/Nero.cs:
* DiscImageChef.csproj:
* DetectImageFormat.cs:
* PartPlugins/Atari.cs:
* ImagePlugins/CDRWin.cs:
* PartPlugins/AppleMap.cs:
* ImagePlugins/Apple2MG.cs:
* ImagePlugins/TeleDisk.cs:
* PartPlugins/PartPlugin.cs:
* ImagePlugins/ImageInfo.cs:
* ImagePlugins/DiskCopy42.cs:
* ImagePlugins/ImagePlugin.cs:
* ImagePlugins/ZZZRawImage.cs:
* ImagePlugins/DetectImageFormat.cs:
Moved disc image plugins to a separate library.
2015-10-05 Natalia Portillo <claunia@claunia.com>
* Swapping.cs:

View File

@@ -114,13 +114,13 @@ namespace DiscImageChef.Commands
if (options.SearchForPartitions)
{
List<Partition> partitions = new List<Partition>();
List<CommonTypes.Partition> partitions = new List<CommonTypes.Partition>();
string partition_scheme = "";
// TODO: Solve possibility of multiple partition schemes (CUE + MBR, MBR + RDB, CUE + APM, etc)
foreach (PartPlugin _partplugin in plugins.PartPluginsList.Values)
{
List<Partition> _partitions;
List<CommonTypes.Partition> _partitions;
if (_partplugin.GetInformation(_imageFormat, out _partitions))
{

View File

@@ -64,12 +64,7 @@
<Compile Include="Plugins\SolarFS.cs" />
<Compile Include="Plugins\UNIXBFS.cs" />
<Compile Include="Plugins\SysV.cs" />
<Compile Include="ImagePlugins\ImagePlugin.cs" />
<Compile Include="ImagePlugins\CDRWin.cs" />
<Compile Include="ImagePlugins\DiskCopy42.cs" />
<Compile Include="Plugins\LisaFS.cs" />
<Compile Include="ImagePlugins\TeleDisk.cs" />
<Compile Include="ImagePlugins\ZZZRawImage.cs" />
<Compile Include="Options.cs" />
<Compile Include="Commands\Formats.cs" />
<Compile Include="Commands\Analyze.cs" />
@@ -77,9 +72,6 @@
<Compile Include="Commands\Checksum.cs" />
<Compile Include="Commands\Verify.cs" />
<Compile Include="Commands\Commands.cs" />
<Compile Include="ImagePlugins\DetectImageFormat.cs" />
<Compile Include="ImagePlugins\ImageInfo.cs" />
<Compile Include="ImagePlugins\Nero.cs" />
<Compile Include="Commands\PrintHex.cs" />
<Compile Include="Commands\Decode.cs" />
<Compile Include="Decoders\SCSI.cs" />
@@ -88,13 +80,12 @@
<Compile Include="Decoders\BD.cs" />
<Compile Include="Decoders\DVD.cs" />
<Compile Include="Plugins\ProDOS.cs" />
<Compile Include="ImagePlugins\Apple2MG.cs" />
<Compile Include="PartPlugins\RDB.cs" />
<Compile Include="Plugins\AmigaDOS.cs" />
<Compile Include="PartPlugins\Atari.cs" />
<Compile Include="ImagePlugins\VHD.cs" />
<Compile Include="Commands\Entropy.cs" />
<Compile Include="Decoders\Floppy.cs" />
<Compile Include="DetectImageFormat.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@@ -200,5 +191,13 @@
<Project>{F8BDF57B-1571-4CD0-84B3-B422088D359A}</Project>
<Name>DiscImageChef.Helpers</Name>
</ProjectReference>
<ProjectReference Include="..\DiscImageChef.DiscImages\DiscImageChef.DiscImages.csproj">
<Project>{74032CBC-339B-42F3-AF6F-E96C261F3E6A}</Project>
<Name>DiscImageChef.DiscImages</Name>
</ProjectReference>
<ProjectReference Include="..\DiscImageChef.CommonTypes\DiscImageChef.CommonTypes.csproj">
<Project>{F2B84194-26EB-4227-B1C5-6602517E85AE}</Project>
<Name>DiscImageChef.CommonTypes</Name>
</ProjectReference>
</ItemGroup>
</Project>

View File

@@ -1,643 +0,0 @@
/***************************************************************************
The Disc Image Chef
----------------------------------------------------------------------------
Filename : DiskCopy42.cs
Version : 1.0
Author(s) : Natalia Portillo
Component : Disc image plugins
Revision : $Revision$
Last change by : $Author$
Date : $Date$
--[ Description ] ----------------------------------------------------------
Manages Apple DiskCopy 4.2 disc images, including unofficial modifications.
--[ License ] --------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
Copyright (C) 2011-2014 Claunia.com
****************************************************************************/
//$Id$
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace DiscImageChef.ImagePlugins
{
public class Apple2MG : ImagePlugin
{
#region Internal Structures
// DiskCopy 4.2 header, big-endian, data-fork, start of file, 84 bytes
struct A2IMGHeader
{
/// <summary>
/// Offset 0x00, magic
/// </summary>
public UInt32 magic;
/// <summary>
/// Offset 0x04, disk image creator ID
/// </summary>
public UInt32 creator;
/// <summary>
/// Offset 0x08, header size, constant 0x0040
/// </summary>
public UInt16 headerSize;
/// <summary>
/// Offset 0x0A, disk image version
/// </summary>
public UInt16 version;
/// <summary>
/// Offset 0x0C, disk image format
/// </summary>
public UInt32 imageFormat;
/// <summary>
/// Offset 0x10, flags and volume number
/// </summary>
public UInt32 flags;
/// <summary>
/// Offset 0x14, blocks for ProDOS, 0 otherwise
/// </summary>
public UInt32 blocks;
/// <summary>
/// Offset 0x18, offset to data
/// </summary>
public UInt32 dataOffset;
/// <summary>
/// Offset 0x1C, data size in bytes
/// </summary>
public UInt32 dataSize;
/// <summary>
/// Offset 0x20, offset to optional comment
/// </summary>
public UInt32 commentOffset;
/// <summary>
/// Offset 0x24, length of optional comment
/// </summary>
public UInt32 commentSize;
/// <summary>
/// Offset 0x28, offset to creator specific chunk
/// </summary>
public UInt32 creatorSpecificOffset;
/// <summary>
/// Offset 0x2C, creator specific chunk size
/// </summary>
public UInt32 creatorSpecificSize;
/// <summary>
/// Offset 0x30, reserved, should be zero
/// </summary>
public UInt32 reserved1;
/// <summary>
/// Offset 0x34, reserved, should be zero
/// </summary>
public UInt32 reserved2;
/// <summary>
/// Offset 0x38, reserved, should be zero
/// </summary>
public UInt32 reserved3;
/// <summary>
/// Offset 0x3C, reserved, should be zero
/// </summary>
public UInt32 reserved4;
}
#endregion
#region Internal Constants
/// <summary>
/// Magic number, "2IMG"
/// </summary>
public const UInt32 MAGIC = 0x474D4932;
/// <summary>
/// Disk image created by ASIMOV2, "!nfc"
/// </summary>
public const UInt32 CreatorAsimov = 0x63666E21;
/// <summary>
/// Disk image created by Bernie ][ the Rescue, "B2TR"
/// </summary>
public const UInt32 CreatorBernie = 0x52543242;
/// <summary>
/// Disk image created by Catakig, "CTKG"
/// </summary>
public const UInt32 CreatorCatakig = 0x474B5443;
/// <summary>
/// Disk image created by Sheppy's ImageMaker, "ShIm"
/// </summary>
public const UInt32 CreatorSheppy = 0x6D496853;
/// <summary>
/// Disk image created by Sweet16, "WOOF"
/// </summary>
public const UInt32 CreatorSweet = 0x464F4F57;
/// <summary>
/// Disk image created by XGS, "XGS!"
/// </summary>
public const UInt32 CreatorXGS = 0x21534758;
public const UInt32 DOSSectorOrder = 0x00000000;
public const UInt32 ProDOSSectorOrder = 0x00000001;
public const UInt32 NIBSectorOrder = 0x00000002;
public const UInt32 LockedDisk = 0x80000000;
public const UInt32 ValidVolumeNumber = 0x00000100;
public const UInt32 VolumeNumberMask = 0x000000FF;
#endregion
#region Internal variables
A2IMGHeader ImageHeader;
string a2mgImagePath;
#endregion
public Apple2MG(PluginBase Core)
{
Name = "Apple 2IMG";
PluginUUID = new Guid("CBAF8824-BA5F-415F-953A-19A03519B2D1");
ImageInfo = new ImageInfo();
ImageInfo.readableSectorTags = new List<SectorTagType>();
ImageInfo.readableDiskTags = new List<DiskTagType>();
ImageInfo.imageHasPartitions = false;
ImageInfo.imageHasSessions = false;
ImageInfo.imageVersion = null;
ImageInfo.imageApplication = null;
ImageInfo.imageApplicationVersion = null;
ImageInfo.imageCreator = null;
ImageInfo.imageComments = null;
ImageInfo.diskManufacturer = null;
ImageInfo.diskModel = null;
ImageInfo.diskSerialNumber = null;
ImageInfo.diskBarcode = null;
ImageInfo.diskPartNumber = null;
ImageInfo.diskSequence = 0;
ImageInfo.lastDiskSequence = 0;
ImageInfo.driveManufacturer = null;
ImageInfo.driveModel = null;
ImageInfo.driveSerialNumber = null;
}
public override bool IdentifyImage(string imagePath)
{
FileStream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
stream.Seek(0, SeekOrigin.Begin);
if (stream.Length < 65)
return false;
byte[] header = new byte[64];
stream.Read(header, 0, 64);
UInt32 magic = BitConverter.ToUInt32(header, 0x00);
if (magic != MAGIC)
return false;
UInt32 dataoff = BitConverter.ToUInt32(header, 0x18);
if (dataoff > stream.Length)
return false;
UInt32 datasize = BitConverter.ToUInt32(header, 0x1C);
// There seems to be incorrect endian in some images on the wild
if (datasize == 0x00800C00)
datasize = 0x000C8000;
if (dataoff + datasize > stream.Length)
return false;
UInt32 commentoff = BitConverter.ToUInt32(header, 0x20);
if (commentoff > stream.Length)
return false;
UInt32 commentsize = BitConverter.ToUInt32(header, 0x24);
if (commentoff + commentsize > stream.Length)
return false;
UInt32 creatoroff = BitConverter.ToUInt32(header, 0x28);
if (creatoroff > stream.Length)
return false;
UInt32 creatorsize = BitConverter.ToUInt32(header, 0x2C);
return creatoroff + creatorsize <= stream.Length;
}
public override bool OpenImage(string imagePath)
{
FileStream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
stream.Seek(0, SeekOrigin.Begin);
ImageHeader = new A2IMGHeader();
byte[] header = new byte[64];
stream.Read(header, 0, 64);
byte[] magic = new byte[4];
byte[] creator = new byte[4];
Array.Copy(header, 0, magic, 0, 4);
Array.Copy(header, 4, creator, 0, 4);
ImageHeader.magic = BitConverter.ToUInt32(header, 0x00);
ImageHeader.creator = BitConverter.ToUInt32(header, 0x04);
ImageHeader.headerSize = BitConverter.ToUInt16(header, 0x08);
ImageHeader.version = BitConverter.ToUInt16(header, 0x0A);
ImageHeader.imageFormat = BitConverter.ToUInt32(header, 0x0C);
ImageHeader.flags = BitConverter.ToUInt32(header, 0x10);
ImageHeader.blocks = BitConverter.ToUInt32(header, 0x14);
ImageHeader.dataOffset = BitConverter.ToUInt32(header, 0x18);
ImageHeader.dataSize = BitConverter.ToUInt32(header, 0x1C);
ImageHeader.commentOffset = BitConverter.ToUInt32(header, 0x20);
ImageHeader.commentSize = BitConverter.ToUInt32(header, 0x24);
ImageHeader.creatorSpecificOffset = BitConverter.ToUInt32(header, 0x28);
ImageHeader.creatorSpecificSize = BitConverter.ToUInt32(header, 0x2C);
ImageHeader.reserved1 = BitConverter.ToUInt32(header, 0x30);
ImageHeader.reserved2 = BitConverter.ToUInt32(header, 0x34);
ImageHeader.reserved3 = BitConverter.ToUInt32(header, 0x38);
ImageHeader.reserved4 = BitConverter.ToUInt32(header, 0x3C);
if (ImageHeader.dataSize == 0x00800C00)
{
ImageHeader.dataSize = 0x000C8000;
if (MainClass.isDebug)
Console.WriteLine("DEBUG (2MG plugin): Detected incorrect endian on data size field, correcting.");
}
if (MainClass.isDebug)
{
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.magic = \"{0}\"", Encoding.ASCII.GetString(magic));
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.creator = \"{0}\"", Encoding.ASCII.GetString(creator));
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.headerSize = {0}", ImageHeader.headerSize);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.version = {0}", ImageHeader.version);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.imageFormat = {0}", ImageHeader.imageFormat);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.flags = 0x{0:X8}", ImageHeader.flags);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.blocks = {0}", ImageHeader.blocks);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.dataOffset = 0x{0:X8}", ImageHeader.dataOffset);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.dataSize = {0}", ImageHeader.dataSize);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.commentOffset = 0x{0:X8}", ImageHeader.commentOffset);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.commentSize = {0}", ImageHeader.commentSize);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.creatorSpecificOffset = 0x{0:X8}", ImageHeader.creatorSpecificOffset);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.creatorSpecificSize = {0}", ImageHeader.creatorSpecificSize);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.reserved1 = 0x{0:X8}", ImageHeader.reserved1);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.reserved2 = 0x{0:X8}", ImageHeader.reserved2);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.reserved3 = 0x{0:X8}", ImageHeader.reserved3);
Console.WriteLine("DEBUG (2MG plugin): ImageHeader.reserved4 = 0x{0:X8}", ImageHeader.reserved4);
}
if (ImageHeader.dataSize == 0 && ImageHeader.blocks == 0 && ImageHeader.imageFormat != ProDOSSectorOrder)
return false;
if (ImageHeader.imageFormat == ProDOSSectorOrder && ImageHeader.blocks == 0)
return false;
if (ImageHeader.imageFormat == ProDOSSectorOrder)
ImageHeader.dataSize = ImageHeader.blocks * 512;
else if (ImageHeader.blocks == 0 && ImageHeader.dataSize != 0)
ImageHeader.blocks = ImageHeader.dataSize / 256;
else if (ImageHeader.dataSize == 0 && ImageHeader.blocks != 0)
ImageHeader.dataSize = ImageHeader.blocks * 256;
ImageInfo.sectorSize = (uint)(ImageHeader.imageFormat == ProDOSSectorOrder ? 512 : 256);
ImageInfo.sectors = ImageHeader.blocks;
ImageInfo.imageSize = ImageHeader.dataSize;
switch (ImageHeader.creator)
{
case CreatorAsimov:
ImageInfo.imageApplication = "ASIMOV2";
break;
case CreatorBernie:
ImageInfo.imageApplication = "Bernie ][ the Rescue";
break;
case CreatorCatakig:
ImageInfo.imageApplication = "Catakig";
break;
case CreatorSheppy:
ImageInfo.imageApplication = "Sheppy's ImageMaker";
break;
case CreatorSweet:
ImageInfo.imageApplication = "Sweet16";
break;
case CreatorXGS:
ImageInfo.imageApplication = "XGS";
break;
default:
ImageInfo.imageApplication = String.Format("Unknown creator code \"{0}\"", Encoding.ASCII.GetString(creator));
break;
}
ImageInfo.imageVersion = ImageHeader.version.ToString();
if (ImageHeader.commentOffset != 0 && ImageHeader.commentSize != 0)
{
stream.Seek(ImageHeader.commentOffset, SeekOrigin.Begin);
byte[] comments = new byte[ImageHeader.commentSize];
stream.Read(comments, 0, (int)ImageHeader.commentSize);
ImageInfo.imageComments = Encoding.ASCII.GetString(comments);
}
FileInfo fi = new FileInfo(imagePath);
ImageInfo.imageCreationTime = fi.CreationTimeUtc;
ImageInfo.imageLastModificationTime = fi.LastWriteTimeUtc;
ImageInfo.imageName = Path.GetFileNameWithoutExtension(imagePath);
stream.Close();
a2mgImagePath = imagePath;
return true;
}
public override bool ImageHasPartitions()
{
return false;
}
public override ulong GetImageSize()
{
return ImageInfo.imageSize;
}
public override ulong GetSectors()
{
return ImageInfo.sectors;
}
public override uint GetSectorSize()
{
return ImageInfo.sectorSize;
}
public override string GetImageFormat()
{
return "Apple 2IMG";
}
public override string GetImageVersion()
{
return ImageInfo.imageVersion;
}
public override string GetImageApplication()
{
return ImageInfo.imageApplication;
}
public override string GetImageApplicationVersion()
{
return ImageInfo.imageApplicationVersion;
}
public override string GetImageCreator()
{
return ImageInfo.imageCreator;
}
public override DateTime GetImageCreationTime()
{
return ImageInfo.imageCreationTime;
}
public override DateTime GetImageLastModificationTime()
{
return ImageInfo.imageLastModificationTime;
}
public override string GetImageName()
{
return ImageInfo.imageName;
}
public override string GetImageComments()
{
return ImageInfo.imageComments;
}
public override DiskType GetDiskType()
{
switch (ImageInfo.sectors)
{
case 455:
return DiskType.Apple32SS;
case 910:
return DiskType.Apple32DS;
case 560:
return DiskType.Apple33SS;
case 1120:
return DiskType.Apple33DS;
case 800:
return DiskType.AppleSonySS;
case 1600:
return DiskType.AppleSonyDS;
default:
return DiskType.Unknown;
}
}
public override byte[] ReadSector(ulong sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectors(ulong sectorAddress, uint length)
{
if (sectorAddress > ImageInfo.sectors - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
if (sectorAddress + length > ImageInfo.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
byte[] buffer = new byte[length * ImageInfo.sectorSize];
FileStream stream = new FileStream(a2mgImagePath, FileMode.Open, FileAccess.Read);
stream.Seek((long)(ImageHeader.dataOffset + sectorAddress * ImageInfo.sectorSize), SeekOrigin.Begin);
stream.Read(buffer, 0, (int)(length * ImageInfo.sectorSize));
stream.Close();
return buffer;
}
#region Unsupported features
public override byte[] ReadDiskTag(DiskTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSector(ulong sectorAddress, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorLong(ulong sectorAddress)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override string GetDiskManufacturer()
{
return null;
}
public override string GetDiskModel()
{
return null;
}
public override string GetDiskSerialNumber()
{
return null;
}
public override string GetDiskBarcode()
{
return null;
}
public override string GetDiskPartNumber()
{
return null;
}
public override int GetDiskSequence()
{
return 0;
}
public override int GetLastDiskSequence()
{
return 0;
}
public override string GetDriveManufacturer()
{
return null;
}
public override string GetDriveModel()
{
return null;
}
public override string GetDriveSerialNumber()
{
return null;
}
public override List<DiscImageChef.PartPlugins.Partition> GetPartitions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetTracks()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetSessionTracks(Session session)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetSessionTracks(ushort session)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Session> GetSessions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override bool? VerifySector(ulong sectorAddress)
{
return null;
}
public override bool? VerifySector(ulong sectorAddress, uint track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
FailingLBAs = new List<ulong>();
UnknownLBAs = new List<ulong>();
for (ulong i = 0; i < ImageInfo.sectors; i++)
UnknownLBAs.Add(i);
return null;
}
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> FailingLBAs, out List<ulong> UnknownLBAs)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override bool? VerifyDiskImage()
{
return null;
}
#endregion
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,727 +0,0 @@
/***************************************************************************
The Disc Image Chef
----------------------------------------------------------------------------
Filename : DiskCopy42.cs
Version : 1.0
Author(s) : Natalia Portillo
Component : Disc image plugins
Revision : $Revision$
Last change by : $Author$
Date : $Date$
--[ Description ] ----------------------------------------------------------
Manages Apple DiskCopy 4.2 disc images, including unofficial modifications.
--[ License ] --------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
Copyright (C) 2011-2014 Claunia.com
****************************************************************************/
//$Id$
using System;
using System.IO;
using System.Collections.Generic;
namespace DiscImageChef.ImagePlugins
{
// Checked using several images and strings inside Apple's DiskImages.framework
class DiskCopy42 : ImagePlugin
{
#region Internal Structures
// DiskCopy 4.2 header, big-endian, data-fork, start of file, 84 bytes
struct DC42Header
{
// 0x00, 64 bytes, pascal string, disk name or "-not a Macintosh disk-", filled with garbage
public string diskName;
// 0x40, size of data in bytes (usually sectors*512)
public UInt32 dataSize;
// 0x44, size of tags in bytes (usually sectors*12)
public UInt32 tagSize;
// 0x48, checksum of data bytes
public UInt32 dataChecksum;
// 0x4C, checksum of tag bytes
public UInt32 tagChecksum;
// 0x50, format of disk, see constants
public byte format;
// 0x51, format of sectors, see constants
public byte fmtByte;
// 0x52, is disk image valid? always 0x01
public byte valid;
// 0x53, reserved, always 0x00
public byte reserved;
}
#endregion
#region Internal Constants
// format byte
// 3.5", single side, double density, GCR
const byte kSonyFormat400K = 0x00;
// 3.5", double side, double density, GCR
const byte kSonyFormat800K = 0x01;
// 3.5", double side, double density, MFM
const byte kSonyFormat720K = 0x02;
// 3.5", double side, high density, MFM
const byte kSonyFormat1440K = 0x03;
// 3.5", double side, high density, MFM, 21 sectors/track (aka, Microsoft DMF)
// Unchecked value
const byte kSonyFormat1680K = 0x04;
// Defined by Sigma Seven's BLU
const byte kSigmaFormatTwiggy = 0x54;
// There should be a value for Apple HD20 hard disks, unknown...
// fmyByte byte
// Based on GCR nibble
// Always 0x02 for MFM disks
// Unknown for Apple HD20
// Defined by Sigma Seven's BLU
const byte kSigmaFmtByteTwiggy = 0x01;
// 3.5" single side double density GCR and MFM all use same code
const byte kSonyFmtByte400K = 0x02;
const byte kSonyFmtByte720K = kSonyFmtByte400K;
const byte kSonyFmtByte1440K = kSonyFmtByte400K;
const byte kSonyFmtByte1680K = kSonyFmtByte400K;
// 3.5" double side double density GCR, 512 bytes/sector, interleave 2:1
const byte kSonyFmtByte800K = 0x22;
// 3.5" double side double density GCR, 512 bytes/sector, interleave 2:1, incorrect value (but appears on official documentation)
const byte kSonyFmtByte800KIncorrect = 0x12;
// 3.5" double side double density GCR, ProDOS format, interleave 4:1
const byte kSonyFmtByteProDos = 0x24;
// Unformatted sectors
const byte kInvalidFmtByte = 0x96;
#endregion
#region Internal variables
// Start of data sectors in disk image, should be 0x58
UInt32 dataOffset;
// Start of tags in disk image, after data sectors
UInt32 tagOffset;
// Bytes per tag, should be 12
UInt32 bptag;
// Header of opened image
DC42Header header;
// Disk image file
string dc42ImagePath;
#endregion
public DiskCopy42(PluginBase Core)
{
Name = "Apple DiskCopy 4.2";
PluginUUID = new Guid("0240B7B1-E959-4CDC-B0BD-386D6E467B88");
ImageInfo = new ImageInfo();
ImageInfo.readableSectorTags = new List<SectorTagType>();
ImageInfo.readableDiskTags = new List<DiskTagType>();
ImageInfo.imageHasPartitions = false;
ImageInfo.imageHasSessions = false;
ImageInfo.imageVersion = "4.2";
ImageInfo.imageApplication = "Apple DiskCopy";
ImageInfo.imageApplicationVersion = "4.2";
ImageInfo.imageCreator = null;
ImageInfo.imageComments = null;
ImageInfo.diskManufacturer = null;
ImageInfo.diskModel = null;
ImageInfo.diskSerialNumber = null;
ImageInfo.diskBarcode = null;
ImageInfo.diskPartNumber = null;
ImageInfo.diskSequence = 0;
ImageInfo.lastDiskSequence = 0;
ImageInfo.driveManufacturer = null;
ImageInfo.driveModel = null;
ImageInfo.driveSerialNumber = null;
}
public override bool IdentifyImage(string imagePath)
{
FileStream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
stream.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[0x58];
byte[] pString = new byte[64];
stream.Read(buffer, 0, 0x58);
stream.Close();
// Incorrect pascal string length, not DC42
if (buffer[0] > 63)
return false;
DC42Header tmp_header = new DC42Header();
Array.Copy(buffer, 0, pString, 0, 64);
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
tmp_header.diskName = StringHandlers.PascalToString(pString);
tmp_header.dataSize = BigEndianBitConverter.ToUInt32(buffer, 0x40);
tmp_header.tagSize = BigEndianBitConverter.ToUInt32(buffer, 0x44);
tmp_header.dataChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x48);
tmp_header.tagChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x4C);
tmp_header.format = buffer[0x50];
tmp_header.fmtByte = buffer[0x51];
tmp_header.valid = buffer[0x52];
tmp_header.reserved = buffer[0x53];
if (MainClass.isDebug)
{
Console.WriteLine("DEBUG (DC42 plugin): tmp_header.diskName = \"{0}\"", tmp_header.diskName);
Console.WriteLine("DEBUG (DC42 plugin): tmp_header.dataSize = {0} bytes", tmp_header.dataSize);
Console.WriteLine("DEBUG (DC42 plugin): tmp_header.tagSize = {0} bytes", tmp_header.tagSize);
Console.WriteLine("DEBUG (DC42 plugin): tmp_header.dataChecksum = 0x{0:X8}", tmp_header.dataChecksum);
Console.WriteLine("DEBUG (DC42 plugin): tmp_header.tagChecksum = 0x{0:X8}", tmp_header.tagChecksum);
Console.WriteLine("DEBUG (DC42 plugin): tmp_header.format = 0x{0:X2}", tmp_header.format);
Console.WriteLine("DEBUG (DC42 plugin): tmp_header.fmtByte = 0x{0:X2}", tmp_header.fmtByte);
Console.WriteLine("DEBUG (DC42 plugin): tmp_header.valid = {0}", tmp_header.valid);
Console.WriteLine("DEBUG (DC42 plugin): tmp_header.reserved = {0}", tmp_header.reserved);
}
if (tmp_header.valid != 1 || tmp_header.reserved != 0)
return false;
FileInfo fi = new FileInfo(imagePath);
if (tmp_header.dataSize + tmp_header.tagSize + 0x54 != fi.Length && tmp_header.format != kSigmaFormatTwiggy)
return false;
if (tmp_header.format != kSonyFormat400K && tmp_header.format != kSonyFormat800K && tmp_header.format != kSonyFormat720K &&
tmp_header.format != kSonyFormat1440K && tmp_header.format != kSonyFormat1680K && tmp_header.format != kSigmaFormatTwiggy)
{
if (MainClass.isDebug)
Console.WriteLine("Unknown tmp_header.format = 0x{0:X2} value", tmp_header.format);
return false;
}
if (tmp_header.fmtByte != kSonyFmtByte400K && tmp_header.fmtByte != kSonyFmtByte800K && tmp_header.fmtByte != kSonyFmtByte800KIncorrect &&
tmp_header.fmtByte != kSonyFmtByteProDos && tmp_header.fmtByte != kInvalidFmtByte && tmp_header.fmtByte != kSigmaFmtByteTwiggy)
{
if (MainClass.isDebug)
Console.WriteLine("Unknown tmp_header.fmtByte = 0x{0:X2} value", tmp_header.fmtByte);
return false;
}
if (tmp_header.fmtByte == kInvalidFmtByte)
{
if (MainClass.isDebug)
Console.WriteLine("Image says it's unformatted");
return false;
}
return true;
}
public override bool OpenImage(string imagePath)
{
FileStream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
stream.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[0x58];
byte[] pString = new byte[64];
stream.Read(buffer, 0, 0x58);
stream.Close();
// Incorrect pascal string length, not DC42
if (buffer[0] > 63)
return false;
header = new DC42Header();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
Array.Copy(buffer, 0, pString, 0, 64);
header.diskName = StringHandlers.PascalToString(pString);
header.dataSize = BigEndianBitConverter.ToUInt32(buffer, 0x40);
header.tagSize = BigEndianBitConverter.ToUInt32(buffer, 0x44);
header.dataChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x48);
header.tagChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x4C);
header.format = buffer[0x50];
header.fmtByte = buffer[0x51];
header.valid = buffer[0x52];
header.reserved = buffer[0x53];
if (MainClass.isDebug)
{
Console.WriteLine("DEBUG (DC42 plugin): header.diskName = \"{0}\"", header.diskName);
Console.WriteLine("DEBUG (DC42 plugin): header.dataSize = {0} bytes", header.dataSize);
Console.WriteLine("DEBUG (DC42 plugin): header.tagSize = {0} bytes", header.tagSize);
Console.WriteLine("DEBUG (DC42 plugin): header.dataChecksum = 0x{0:X8}", header.dataChecksum);
Console.WriteLine("DEBUG (DC42 plugin): header.tagChecksum = 0x{0:X8}", header.tagChecksum);
Console.WriteLine("DEBUG (DC42 plugin): header.format = 0x{0:X2}", header.format);
Console.WriteLine("DEBUG (DC42 plugin): header.fmtByte = 0x{0:X2}", header.fmtByte);
Console.WriteLine("DEBUG (DC42 plugin): header.valid = {0}", header.valid);
Console.WriteLine("DEBUG (DC42 plugin): header.reserved = {0}", header.reserved);
}
if (header.valid != 1 || header.reserved != 0)
return false;
FileInfo fi = new FileInfo(imagePath);
if (header.dataSize + header.tagSize + 0x54 != fi.Length && header.format != kSigmaFormatTwiggy)
return false;
if (header.format != kSonyFormat400K && header.format != kSonyFormat800K && header.format != kSonyFormat720K &&
header.format != kSonyFormat1440K && header.format != kSonyFormat1680K && header.format != kSigmaFormatTwiggy)
{
if (MainClass.isDebug)
Console.WriteLine("DEBUG (DC42 plugin): Unknown header.format = 0x{0:X2} value", header.format);
return false;
}
if (header.fmtByte != kSonyFmtByte400K && header.fmtByte != kSonyFmtByte800K && header.fmtByte != kSonyFmtByte800KIncorrect &&
header.fmtByte != kSonyFmtByteProDos && header.fmtByte != kInvalidFmtByte && header.fmtByte != kSigmaFmtByteTwiggy)
{
if (MainClass.isDebug)
Console.WriteLine("DEBUG (DC42 plugin): Unknown tmp_header.fmtByte = 0x{0:X2} value", header.fmtByte);
return false;
}
if (header.fmtByte == kInvalidFmtByte)
{
if (MainClass.isDebug)
Console.WriteLine("DEBUG (DC42 plugin): Image says it's unformatted");
return false;
}
dataOffset = 0x54;
tagOffset = header.tagSize != 0 ? 0x54 + header.dataSize : 0;
ImageInfo.sectorSize = 512;
bptag = (uint)(header.tagSize != 0 ? 12 : 0);
dc42ImagePath = imagePath;
ImageInfo.sectors = header.dataSize / 512;
if (header.tagSize != 0)
{
if (header.tagSize / 12 != ImageInfo.sectors)
{
if (MainClass.isDebug)
Console.WriteLine("DEBUG (DC42 plugin): header.tagSize / 12 != sectors");
return false;
}
ImageInfo.readableSectorTags.Add(SectorTagType.AppleSectorTag);
}
ImageInfo.imageSize = ImageInfo.sectors * ImageInfo.sectorSize + ImageInfo.sectors * bptag;
ImageInfo.imageCreationTime = fi.CreationTimeUtc;
ImageInfo.imageLastModificationTime = fi.LastWriteTimeUtc;
ImageInfo.imageName = header.diskName;
switch (header.format)
{
case kSonyFormat400K:
ImageInfo.diskType = DiskType.AppleSonySS;
break;
case kSonyFormat800K:
ImageInfo.diskType = DiskType.AppleSonyDS;
break;
case kSonyFormat720K:
ImageInfo.diskType = DiskType.DOS_35_DS_DD_9;
break;
case kSonyFormat1440K:
ImageInfo.diskType = DiskType.DOS_35_HD;
break;
case kSonyFormat1680K:
ImageInfo.diskType = DiskType.DMF;
break;
case kSigmaFormatTwiggy:
ImageInfo.diskType = DiskType.AppleFileWare;
break;
default:
ImageInfo.diskType = DiskType.Unknown;
break;
}
return true;
}
public override bool? VerifySector(UInt64 sectorAddress)
{
return null;
}
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
{
return null;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
{
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
for (UInt64 i = sectorAddress; i < sectorAddress + length; i++)
UnknownLBAs.Add(i);
return null;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
{
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
for (UInt64 i = sectorAddress; i < sectorAddress + length; i++)
UnknownLBAs.Add(i);
return null;
}
public override bool? VerifyDiskImage()
{
byte[] data = new byte[header.dataSize];
byte[] tags = new byte[header.tagSize];
UInt32 dataChk;
UInt32 tagsChk = 0;
if (MainClass.isDebug)
Console.WriteLine("DEBUG (DC42 plugin): Reading data");
FileStream datastream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
datastream.Seek((long)(dataOffset), SeekOrigin.Begin);
datastream.Read(data, 0, (int)header.dataSize);
datastream.Close();
if (MainClass.isDebug)
Console.WriteLine("DEBUG (DC42 plugin): Calculating data checksum");
dataChk = DC42CheckSum(data);
if (MainClass.isDebug)
{
Console.WriteLine("DEBUG (DC42 plugin): Calculated data checksum = 0x{0:X8}", dataChk);
Console.WriteLine("DEBUG (DC42 plugin): Stored data checksum = 0x{0:X8}", header.dataChecksum);
}
if (header.tagSize > 0)
{
if (MainClass.isDebug)
Console.WriteLine("DEBUG (DC42 plugin): Reading tags");
FileStream tagstream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
tagstream.Seek((long)(tagOffset), SeekOrigin.Begin);
tagstream.Read(tags, 0, (int)header.tagSize);
tagstream.Close();
if (MainClass.isDebug)
Console.WriteLine("DEBUG (DC42 plugin): Calculating tag checksum");
tagsChk = DC42CheckSum(tags);
if (MainClass.isDebug)
{
Console.WriteLine("DEBUG (DC42 plugin): Calculated tag checksum = 0x{0:X8}", tagsChk);
Console.WriteLine("DEBUG (DC42 plugin): Stored tag checksum = 0x{0:X8}", header.tagChecksum);
}
}
return dataChk == header.dataChecksum && tagsChk == header.tagChecksum;
}
public override bool ImageHasPartitions()
{
return ImageInfo.imageHasPartitions;
}
public override UInt64 GetImageSize()
{
return ImageInfo.imageSize;
}
public override UInt64 GetSectors()
{
return ImageInfo.sectors;
}
public override UInt32 GetSectorSize()
{
return ImageInfo.sectorSize;
}
public override byte[] ReadSector(UInt64 sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
{
return ReadSectorsTag(sectorAddress, 1, tag);
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
{
if (sectorAddress > ImageInfo.sectors - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
if (sectorAddress + length > ImageInfo.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
byte[] buffer = new byte[length * ImageInfo.sectorSize];
FileStream stream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
stream.Seek((long)(dataOffset + sectorAddress * ImageInfo.sectorSize), SeekOrigin.Begin);
stream.Read(buffer, 0, (int)(length * ImageInfo.sectorSize));
stream.Close();
return buffer;
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
{
if (tag != SectorTagType.AppleSectorTag)
throw new FeatureUnsupportedImageException(String.Format("Tag {0} not supported by image format", tag));
if (header.tagSize == 0)
throw new FeatureNotPresentImageException("Disk image does not have tags");
if (sectorAddress > ImageInfo.sectors - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
if (sectorAddress + length > ImageInfo.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
byte[] buffer = new byte[length * bptag];
FileStream stream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
stream.Seek((long)(tagOffset + sectorAddress * bptag), SeekOrigin.Begin);
stream.Read(buffer, 0, (int)(length * bptag));
stream.Close();
return buffer;
}
public override byte[] ReadSectorLong(UInt64 sectorAddress)
{
return ReadSectorsLong(sectorAddress, 1);
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
{
if (sectorAddress > ImageInfo.sectors - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
if (sectorAddress + length > ImageInfo.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
byte[] data = ReadSectors(sectorAddress, length);
byte[] tags = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSectorTag);
byte[] buffer = new byte[data.Length + tags.Length];
for (uint i = 0; i < length; i++)
{
Array.Copy(data, i * (ImageInfo.sectorSize), buffer, i * (ImageInfo.sectorSize + bptag), ImageInfo.sectorSize);
Array.Copy(tags, i * (bptag), buffer, i * (ImageInfo.sectorSize + bptag) + ImageInfo.sectorSize, bptag);
}
return buffer;
}
public override string GetImageFormat()
{
return "Apple DiskCopy 4.2";
}
public override string GetImageVersion()
{
return ImageInfo.imageVersion;
}
public override string GetImageApplication()
{
return ImageInfo.imageApplication;
}
public override string GetImageApplicationVersion()
{
return ImageInfo.imageApplicationVersion;
}
public override DateTime GetImageCreationTime()
{
return ImageInfo.imageCreationTime;
}
public override DateTime GetImageLastModificationTime()
{
return ImageInfo.imageLastModificationTime;
}
public override string GetImageName()
{
return ImageInfo.imageName;
}
public override DiskType GetDiskType()
{
return ImageInfo.diskType;
}
#region Unsupported features
public override byte[] ReadDiskTag(DiskTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override string GetImageCreator()
{
return ImageInfo.imageCreator;
}
public override string GetImageComments()
{
return ImageInfo.imageComments;
}
public override string GetDiskManufacturer()
{
return ImageInfo.diskManufacturer;
}
public override string GetDiskModel()
{
return ImageInfo.diskModel;
}
public override string GetDiskSerialNumber()
{
return ImageInfo.diskSerialNumber;
}
public override string GetDiskBarcode()
{
return ImageInfo.diskBarcode;
}
public override string GetDiskPartNumber()
{
return ImageInfo.diskPartNumber;
}
public override int GetDiskSequence()
{
return ImageInfo.diskSequence;
}
public override int GetLastDiskSequence()
{
return ImageInfo.lastDiskSequence;
}
public override string GetDriveManufacturer()
{
return ImageInfo.driveManufacturer;
}
public override string GetDriveModel()
{
return ImageInfo.driveModel;
}
public override string GetDriveSerialNumber()
{
return ImageInfo.driveSerialNumber;
}
public override List<PartPlugins.Partition> GetPartitions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetTracks()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetSessionTracks(Session session)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetSessionTracks(UInt16 session)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Session> GetSessions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
#endregion Unsupported features
#region Private methods
private static UInt32 DC42CheckSum(byte[] buffer)
{
UInt32 dc42chk = 0;
if ((buffer.Length & 0x01) == 0x01)
return 0xFFFFFFFF;
for (UInt32 i = 0; i < buffer.Length; i += 2)
{
dc42chk += (uint)(buffer[i] << 8);
dc42chk += buffer[i + 1];
dc42chk = (dc42chk >> 1) | (dc42chk << 31);
}
return dc42chk;
}
#endregion
}
}

View File

@@ -1,36 +0,0 @@
using System;
using System.Collections.Generic;
namespace DiscImageChef.ImagePlugins
{
public struct ImageInfo
{
public bool imageHasPartitions;
public bool imageHasSessions;
public UInt64 imageSize;
public UInt64 sectors;
public UInt32 sectorSize;
public List<DiskTagType> readableDiskTags;
public List<SectorTagType> readableSectorTags;
public string imageVersion;
public string imageApplication;
public string imageApplicationVersion;
public string imageCreator;
public DateTime imageCreationTime;
public DateTime imageLastModificationTime;
public string imageName;
public string imageComments;
public string diskManufacturer;
public string diskModel;
public string diskSerialNumber;
public string diskBarcode;
public string diskPartNumber;
public DiskType diskType;
public int diskSequence;
public int lastDiskSequence;
public string driveManufacturer;
public string driveModel;
public string driveSerialNumber;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,684 +0,0 @@
/***************************************************************************
The Disc Image Chef
----------------------------------------------------------------------------
Filename : ZZZRawImage.cs
Version : 1.0
Author(s) : Natalia Portillo
Component : Disc image plugins
Revision : $Revision$
Last change by : $Author$
Date : $Date$
--[ Description ] ----------------------------------------------------------
Manages raw image, that is, user data sector by sector copy.
--[ License ] --------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
Copyright (C) 2011-2014 Claunia.com
****************************************************************************/
//$Id$
using System;
using System.IO;
using System.Collections.Generic;
namespace DiscImageChef.ImagePlugins
{
// Checked using several images and strings inside Apple's DiskImages.framework
class ZZZRawImage : ImagePlugin
{
#region Internal variables
string rawImagePath;
bool differentTrackZeroSize;
#endregion
public ZZZRawImage(PluginBase Core)
{
Name = "Raw Disk Image";
// Non-random UUID to recognize this specific plugin
PluginUUID = new Guid("12345678-AAAA-BBBB-CCCC-123456789000");
ImageInfo = new ImageInfo();
ImageInfo.readableSectorTags = new List<SectorTagType>();
ImageInfo.readableDiskTags = new List<DiskTagType>();
ImageInfo.imageHasPartitions = false;
ImageInfo.imageHasSessions = false;
ImageInfo.imageVersion = null;
ImageInfo.imageApplication = null;
ImageInfo.imageApplicationVersion = null;
ImageInfo.imageCreator = null;
ImageInfo.imageComments = null;
ImageInfo.diskManufacturer = null;
ImageInfo.diskModel = null;
ImageInfo.diskSerialNumber = null;
ImageInfo.diskBarcode = null;
ImageInfo.diskPartNumber = null;
ImageInfo.diskSequence = 0;
ImageInfo.lastDiskSequence = 0;
ImageInfo.driveManufacturer = null;
ImageInfo.driveModel = null;
ImageInfo.driveSerialNumber = null;
}
public override bool IdentifyImage(string imagePath)
{
FileInfo fi = new FileInfo(imagePath);
// Check if file is not multiple of 512
if ((fi.Length % 512) != 0)
{
// Check known disk sizes with sectors smaller than 512
switch (fi.Length)
{
case 81664:
case 116480:
case 242944:
case 256256:
case 287488:
case 306432:
case 495872:
case 988416:
case 995072:
case 1021696:
case 1146624:
case 1177344:
case 1222400:
case 1304320:
case 1255168:
return true;
default:
return false;
}
}
return true;
}
public override bool OpenImage(string imagePath)
{
FileStream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
stream.Seek(0, SeekOrigin.Begin);
stream.Close();
FileInfo fi = new FileInfo(imagePath);
string extension = Path.GetExtension(imagePath).ToLower();
if (extension == ".iso" && (fi.Length % 2048) == 0)
ImageInfo.sectorSize = 2048;
else
{
switch (fi.Length)
{
case 242944:
case 256256:
case 495872:
case 92160:
case 133120:
ImageInfo.sectorSize = 128;
break;
case 116480:
case 287488: // T0S0 = 128bps
case 988416: // T0S0 = 128bps
case 995072: // T0S0 = 128bps, T0S1 = 256bps
case 1021696: // T0S0 = 128bps, T0S1 = 256bps
case 232960:
case 143360:
case 286720:
case 512512:
case 102400:
case 204800:
case 163840:
case 327680:
case 655360:
case 80384: // T0S0 = 128bps
case 325632: // T0S0 = 128bps, T0S1 = 256bps
case 653312: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectorSize = 256;
break;
case 81664:
ImageInfo.sectorSize = 319;
break;
case 306432: // T0S0 = 128bps
case 1146624: // T0S0 = 128bps, T0S1 = 256bps
case 1177344: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectorSize = 512;
break;
case 1222400: // T0S0 = 128bps, T0S1 = 256bps
case 1304320: // T0S0 = 128bps, T0S1 = 256bps
case 1255168: // T0S0 = 128bps, T0S1 = 256bps
case 1261568:
case 1310720:
ImageInfo.sectorSize = 1024;
break;
default:
ImageInfo.sectorSize = 512;
break;
}
}
ImageInfo.imageSize = (ulong)fi.Length;
ImageInfo.imageCreationTime = fi.CreationTimeUtc;
ImageInfo.imageLastModificationTime = fi.LastWriteTimeUtc;
ImageInfo.imageName = Path.GetFileNameWithoutExtension(imagePath);
differentTrackZeroSize = false;
rawImagePath = imagePath;
switch (fi.Length)
{
case 242944:
ImageInfo.sectors = 1898;
break;
case 256256:
ImageInfo.sectors = 2002;
break;
case 495872:
ImageInfo.sectors = 3874;
break;
case 116480:
ImageInfo.sectors = 455;
break;
case 287488: // T0S0 = 128bps
ImageInfo.sectors = 1136;
differentTrackZeroSize = true;
break;
case 988416: // T0S0 = 128bps
ImageInfo.sectors = 3874;
differentTrackZeroSize = true;
break;
case 995072: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectors = 3900;
differentTrackZeroSize = true;
break;
case 1021696: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectors = 4004;
differentTrackZeroSize = true;
break;
case 81664:
ImageInfo.sectors = 256;
break;
case 306432: // T0S0 = 128bps
ImageInfo.sectors = 618;
differentTrackZeroSize = true;
break;
case 1146624: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectors = 2272;
differentTrackZeroSize = true;
break;
case 1177344: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectors = 2332;
differentTrackZeroSize = true;
break;
case 1222400: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectors = 1236;
differentTrackZeroSize = true;
break;
case 1304320: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectors = 1316;
differentTrackZeroSize = true;
break;
case 1255168: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectors = 1268;
differentTrackZeroSize = true;
break;
case 80384: // T0S0 = 128bps
ImageInfo.sectors = 322;
differentTrackZeroSize = true;
break;
case 325632: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectors = 1280;
differentTrackZeroSize = true;
break;
case 653312: // T0S0 = 128bps, T0S1 = 256bps
ImageInfo.sectors = 2560;
differentTrackZeroSize = true;
break;
case 1880064: // IBM XDF, 3,5", real number of sectors
ImageInfo.sectors = 670;
ImageInfo.sectorSize = 8192; // Biggest sector size
differentTrackZeroSize = true;
break;
default:
ImageInfo.sectors = ImageInfo.imageSize / ImageInfo.sectorSize;
break;
}
ImageInfo.diskType = CalculateDiskType();
return true;
}
public override bool ImageHasPartitions()
{
return ImageInfo.imageHasPartitions;
}
public override UInt64 GetImageSize()
{
return ImageInfo.imageSize;
}
public override UInt64 GetSectors()
{
return ImageInfo.sectors;
}
public override UInt32 GetSectorSize()
{
return ImageInfo.sectorSize;
}
public override byte[] ReadSector(UInt64 sectorAddress)
{
return ReadSectors(sectorAddress, 1);
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
{
if (differentTrackZeroSize)
{
throw new NotImplementedException("Not yet implemented");
}
else
{
if (sectorAddress > ImageInfo.sectors - 1)
throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
if (sectorAddress + length > ImageInfo.sectors)
throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
byte[] buffer = new byte[length * ImageInfo.sectorSize];
FileStream stream = new FileStream(rawImagePath, FileMode.Open, FileAccess.Read);
stream.Seek((long)(sectorAddress * ImageInfo.sectorSize), SeekOrigin.Begin);
stream.Read(buffer, 0, (int)(length * ImageInfo.sectorSize));
stream.Close();
return buffer;
}
}
public override string GetImageFormat()
{
return "Raw disk image (sector by sector copy)";
}
public override DateTime GetImageCreationTime()
{
return ImageInfo.imageCreationTime;
}
public override DateTime GetImageLastModificationTime()
{
return ImageInfo.imageLastModificationTime;
}
public override string GetImageName()
{
return ImageInfo.imageName;
}
public override DiskType GetDiskType()
{
return ImageInfo.diskType;
}
public override bool? VerifySector(UInt64 sectorAddress)
{
return null;
}
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
{
return null;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
{
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
for (UInt64 i = sectorAddress; i < sectorAddress + length; i++)
UnknownLBAs.Add(i);
return null;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
{
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
for (UInt64 i = sectorAddress; i < sectorAddress + length; i++)
UnknownLBAs.Add(i);
return null;
}
public override bool? VerifyDiskImage()
{
return null;
}
#region Private methods
DiskType CalculateDiskType()
{
if (ImageInfo.sectorSize == 2048)
{
if (ImageInfo.sectors <= 360000)
return DiskType.CD;
if (ImageInfo.sectors <= 2295104)
return DiskType.DVDPR;
if (ImageInfo.sectors <= 2298496)
return DiskType.DVDR;
if (ImageInfo.sectors <= 4171712)
return DiskType.DVDRDL;
if (ImageInfo.sectors <= 4173824)
return DiskType.DVDPRDL;
if (ImageInfo.sectors <= 24438784)
return DiskType.BDR;
if (ImageInfo.sectors <= 62500864)
return DiskType.BDRXL;
return DiskType.Unknown;
}
else
{
switch (ImageInfo.imageSize)
{
case 80384:
return DiskType.ECMA_66;
case 81664:
return DiskType.IBM23FD;
case 92160:
return DiskType.ATARI_525_SD;
case 102400:
return DiskType.ACORN_525_SS_SD_40;
case 116480:
return DiskType.Apple32SS;
case 133120:
return DiskType.ATARI_525_ED;
case 143360:
return DiskType.Apple33SS;
case 163840:
return DiskType.DOS_525_SS_DD_8;
case 184320:
return DiskType.DOS_525_SS_DD_9;
case 204800:
return DiskType.ACORN_525_SS_SD_80;
case 232960:
return DiskType.Apple32DS;
case 242944:
return DiskType.IBM33FD_128;
case 256256:
return DiskType.ECMA_54;
case 286720:
return DiskType.Apple33DS;
case 287488:
return DiskType.IBM33FD_256;
case 306432:
return DiskType.IBM33FD_512;
case 325632:
return DiskType.ECMA_70;
case 327680:
return DiskType.DOS_525_DS_DD_8;
case 368640:
return DiskType.DOS_525_DS_DD_9;
case 409600:
return DiskType.AppleSonySS;
case 495872:
return DiskType.IBM43FD_128;
case 512512:
return DiskType.ECMA_59;
case 653312:
return DiskType.ECMA_78;
case 655360:
return DiskType.ACORN_525_DS_DD;
case 737280:
return DiskType.DOS_35_DS_DD_9;
case 819200:
return DiskType.AppleSonyDS;
case 839680:
return DiskType.FDFORMAT_35_DD;
case 901120:
return DiskType.CBM_AMIGA_35_DD;
case 988416:
return DiskType.IBM43FD_256;
case 995072:
return DiskType.IBM53FD_256;
case 1021696:
return DiskType.ECMA_99_26;
case 1146624:
return DiskType.IBM53FD_512;
case 1177344:
return DiskType.ECMA_99_15;
case 1222400:
return DiskType.IBM53FD_1024;
case 1228800:
return DiskType.DOS_525_HD;
case 1255168:
return DiskType.ECMA_69_8;
case 1261568:
return DiskType.NEC_8_DD;
case 1304320:
return DiskType.ECMA_99_8;
case 1310720:
return DiskType.NEC_525_HD;
case 1427456:
return DiskType.FDFORMAT_525_HD;
case 1474560:
return DiskType.DOS_35_HD;
case 1720320:
return DiskType.DMF;
case 1763328:
return DiskType.FDFORMAT_35_HD;
case 1802240:
return DiskType.CBM_AMIGA_35_HD;
case 1880064:
return DiskType.XDF_35;
case 1884160:
return DiskType.XDF_35;
case 2949120:
return DiskType.DOS_35_ED;
case 128000000:
return DiskType.ECMA_154;
case 229632000:
return DiskType.ECMA_201;
case 481520640:
return DiskType.ECMA_183_512;
case 533403648:
return DiskType.ECMA_183_1024;
case 596787200:
return DiskType.ECMA_184_512;
case 654540800:
return DiskType.ECMA_184_1024;
default:
return DiskType.GENERIC_HDD;
}
}
}
#endregion
#region Unsupported features
public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorLong(UInt64 sectorAddress)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override string GetImageVersion()
{
return ImageInfo.imageVersion;
}
public override string GetImageApplication()
{
return ImageInfo.imageApplication;
}
public override string GetImageApplicationVersion()
{
return ImageInfo.imageApplicationVersion;
}
public override byte[] ReadDiskTag(DiskTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override string GetImageCreator()
{
return ImageInfo.imageCreator;
}
public override string GetImageComments()
{
return ImageInfo.imageComments;
}
public override string GetDiskManufacturer()
{
return ImageInfo.diskManufacturer;
}
public override string GetDiskModel()
{
return ImageInfo.diskModel;
}
public override string GetDiskSerialNumber()
{
return ImageInfo.diskSerialNumber;
}
public override string GetDiskBarcode()
{
return ImageInfo.diskBarcode;
}
public override string GetDiskPartNumber()
{
return ImageInfo.diskPartNumber;
}
public override int GetDiskSequence()
{
return ImageInfo.diskSequence;
}
public override int GetLastDiskSequence()
{
return ImageInfo.lastDiskSequence;
}
public override string GetDriveManufacturer()
{
return ImageInfo.driveManufacturer;
}
public override string GetDriveModel()
{
return ImageInfo.driveModel;
}
public override string GetDriveSerialNumber()
{
return ImageInfo.driveSerialNumber;
}
public override List<PartPlugins.Partition> GetPartitions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetTracks()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetSessionTracks(Session session)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Track> GetSessionTracks(UInt16 session)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override List<Session> GetSessions()
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
#endregion Unsupported features
}
}

View File

@@ -60,7 +60,7 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("36405F8D-4F1A-07F5-209C-223D735D6D22");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions)
{
ulong apm_entries;
uint sector_size;
@@ -70,7 +70,7 @@ namespace DiscImageChef.PartPlugins
else
sector_size = imagePlugin.GetSectorSize();
partitions = new List<Partition>();
partitions = new List<CommonTypes.Partition>();
AppleMapBootEntry APMB = new AppleMapBootEntry();
AppleMapPartitionEntry APMEntry;
@@ -143,7 +143,7 @@ namespace DiscImageChef.PartPlugins
if (APMEntry.signature == APM_ENTRY || APMEntry.signature == APM_OLDENT) // It should have partition entry signature
{
Partition _partition = new Partition();
CommonTypes.Partition _partition = new CommonTypes.Partition();
StringBuilder sb = new StringBuilder();
_partition.PartitionSequence = i;

View File

@@ -61,9 +61,9 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("d1dd0f24-ec39-4c4d-9072-be31919a3b5e");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions)
{
partitions = new List<Partition>();
partitions = new List<CommonTypes.Partition>();
if (imagePlugin.GetSectorSize() < 512)
return false;
@@ -155,7 +155,7 @@ namespace DiscImageChef.PartPlugins
if (sectorSize == 2448 || sectorSize == 2352)
sectorSize = 2048;
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
part.PartitionLength = table.entries[i].length * sectorSize;
part.PartitionSectors = table.entries[i].length;
part.PartitionSequence = partitionSequence;
@@ -235,7 +235,7 @@ namespace DiscImageChef.PartPlugins
if (sectorSize == 2448 || sectorSize == 2352)
sectorSize = 2048;
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
part.PartitionLength = extendedTable.entries[j].length * sectorSize;
part.PartitionSectors = extendedTable.entries[j].length;
part.PartitionSequence = partitionSequence;
@@ -306,7 +306,7 @@ namespace DiscImageChef.PartPlugins
if (sectorSize == 2448 || sectorSize == 2352)
sectorSize = 2048;
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
part.PartitionLength = table.icdEntries[i].length * sectorSize;
part.PartitionSectors = table.icdEntries[i].length;
part.PartitionSequence = partitionSequence;

View File

@@ -53,13 +53,13 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("5E8A34E8-4F1A-59E6-4BF7-7EA647063A76");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions)
{
byte cyl_sect1, cyl_sect2; // For decoding cylinder and sector
UInt16 signature;
ulong counter = 0;
partitions = new List<Partition>();
partitions = new List<CommonTypes.Partition>();
if (imagePlugin.GetSectorSize() < 512)
return false;
@@ -153,7 +153,7 @@ namespace DiscImageChef.PartPlugins
// TODO: Handle disklabels bigger than 1 sector or search max no_parts
for (int j = 0; j < no_parts; j++)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
byte bsd_type;
part.PartitionSectors = BitConverter.ToUInt32(disklabel_sector, 134 + j * 16 + 4);
@@ -254,7 +254,7 @@ namespace DiscImageChef.PartPlugins
if ((vtoc_ent.flags & 0x200) == 0x200 && vtoc_ent.tag != UNIX_TAG_EMPTY && vtoc_ent.tag != UNIX_TAG_WHOLE)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
// TODO: Check if device bps == disklabel bps
part.PartitionStartSector = vtoc_ent.start;
part.PartitionSectors = vtoc_ent.length;
@@ -292,7 +292,7 @@ namespace DiscImageChef.PartPlugins
{
for (int j = 0; j < 16; j++)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
part.PartitionStartSector = BitConverter.ToUInt32(disklabel_sector, 68 + j * 12 + 4);
part.PartitionSectors = BitConverter.ToUInt32(disklabel_sector, 68 + j * 12 + 8);
part.PartitionStart = part.PartitionStartSector * imagePlugin.GetSectorSize(); // 68+4+j*12
@@ -323,7 +323,7 @@ namespace DiscImageChef.PartPlugins
if (type == 0x81)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
minix_subs = true;
part.PartitionDescription = "Minix subpartition";
part.PartitionType = "Minix";
@@ -348,7 +348,7 @@ namespace DiscImageChef.PartPlugins
if (valid)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
if (entry.lba_start > 0 && entry.lba_sectors > 0)
{
part.PartitionStartSector = entry.lba_start;
@@ -455,7 +455,7 @@ namespace DiscImageChef.PartPlugins
// TODO: Handle disklabels bigger than 1 sector or search max no_parts
for (int j = 0; j < no_parts; j++)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
byte bsd_type;
part.PartitionSectors = BitConverter.ToUInt32(disklabel_sector, 134 + j * 16 + 4);
@@ -556,7 +556,7 @@ namespace DiscImageChef.PartPlugins
if ((vtoc_ent.flags & 0x200) == 0x200 && vtoc_ent.tag != UNIX_TAG_EMPTY && vtoc_ent.tag != UNIX_TAG_WHOLE)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
// TODO: Check if device bps == disklabel bps
part.PartitionStartSector = vtoc_ent.start;
part.PartitionSectors = vtoc_ent.length;
@@ -594,7 +594,7 @@ namespace DiscImageChef.PartPlugins
{
for (int j = 0; j < 16; j++)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
part.PartitionStartSector = BitConverter.ToUInt32(disklabel_sector, 68 + j * 12 + 4);
part.PartitionSectors = BitConverter.ToUInt32(disklabel_sector, 68 + j * 12 + 8);
part.PartitionStart = part.PartitionStartSector * imagePlugin.GetSectorSize(); // 68+4+j*12
@@ -625,7 +625,7 @@ namespace DiscImageChef.PartPlugins
if (type == 0x81)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
minix_subs = true;
part.PartitionDescription = "Minix subpartition";
part.PartitionType = "Minix";
@@ -651,7 +651,7 @@ namespace DiscImageChef.PartPlugins
if (ext_valid)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
if (entry2.lba_start > 0 && entry2.lba_sectors > 0)
{
part.PartitionStartSector = entry2.lba_start;

View File

@@ -62,7 +62,7 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions)
{
byte[] cString;
bool magic_found;
@@ -77,7 +77,7 @@ namespace DiscImageChef.PartPlugins
else
sector_size = imagePlugin.GetSectorSize();
partitions = new List<Partition>();
partitions = new List<CommonTypes.Partition>();
entry_sector = imagePlugin.ReadSector(0); // Starts on sector 0 on NeXT machines, CDs and floppies
magic = BigEndianBitConverter.ToUInt32(entry_sector, 0x00);
@@ -133,7 +133,7 @@ namespace DiscImageChef.PartPlugins
if (entry.sectors > 0 && entry.sectors < 0xFFFFFFFF && entry.start < 0xFFFFFFFF)
{
Partition part = new Partition();
CommonTypes.Partition part = new CommonTypes.Partition();
StringBuilder sb = new StringBuilder();
part.PartitionLength = (ulong)entry.sectors * sector_size;

View File

@@ -61,29 +61,6 @@ namespace DiscImageChef.PartPlugins
/// <returns><c>true</c>, if partitioning scheme is recognized, <c>false</c> otherwise.</returns>
/// <param name="imagePlugin">Disk image.</param>
/// <param name="partitions">Returns list of partitions.</param>
public abstract bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions);
}
/// <summary>
/// Partition structure.
/// </summary>
public struct Partition
{
/// <summary>Partition number, 0-started</summary>
public ulong PartitionSequence;
/// <summary>Partition type</summary>
public string PartitionType;
/// <summary>Partition name (if the scheme supports it)</summary>
public string PartitionName;
/// <summary>Start of the partition, in bytes</summary>
public ulong PartitionStart;
/// <summary>LBA of partition start</summary>
public ulong PartitionStartSector;
/// <summary>Length in bytes of the partition</summary>
public ulong PartitionLength;
/// <summary>Length in sectors of the partition</summary>
public ulong PartitionSectors;
/// <summary>Information that does not find space in this struct</summary>
public string PartitionDescription;
public abstract bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions);
}
}

View File

@@ -889,9 +889,9 @@ namespace DiscImageChef.PartPlugins
public byte[] loadData;
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions)
{
partitions = new List<Partition>();
partitions = new List<CommonTypes.Partition>();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
ulong RDBBlock = 0;
bool foundRDB = false;
@@ -1363,7 +1363,7 @@ namespace DiscImageChef.PartPlugins
ulong sequence = 0;
foreach (PartitionEntry RDBEntry in PartitionEntries)
{
Partition entry = new Partition();
CommonTypes.Partition entry = new CommonTypes.Partition();
entry.PartitionDescription = AmigaDOSTypeToDescriptionString(RDBEntry.dosEnvVec.dosType);
entry.PartitionName = RDBEntry.driveName;

View File

@@ -60,7 +60,7 @@ namespace DiscImageChef
public void RegisterAllPlugins()
{
Assembly assembly = Assembly.GetExecutingAssembly();
Assembly assembly = Assembly.GetAssembly(typeof(ImagePlugin));
foreach (Type type in assembly.GetTypes())
{
@@ -68,9 +68,22 @@ namespace DiscImageChef
{
if (type.IsSubclassOf(typeof(ImagePlugin)))
{
ImagePlugin plugin = (ImagePlugin)type.GetConstructor(new [] { typeof(PluginBase) }).Invoke(new object[] { this });
ImagePlugin plugin = (ImagePlugin)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
RegisterImagePlugin(plugin);
}
}
catch (Exception exception)
{
Console.WriteLine(exception);
}
}
assembly = Assembly.GetExecutingAssembly();
foreach (Type type in assembly.GetTypes())
{
try
{
if (type.IsSubclassOf(typeof(Plugin)))
{
Plugin plugin = (Plugin)type.GetConstructor(new [] { typeof(PluginBase) }).Invoke(new object[] { this });