diff --git a/DiscImageChef/ChangeLog b/DiscImageChef/ChangeLog index 238a512e..cab7d908 100644 --- a/DiscImageChef/ChangeLog +++ b/DiscImageChef/ChangeLog @@ -1,3 +1,9 @@ +2015-04-22 Natalia Portillo + + * ImagePlugins/VHD.cs: + * ImagePlugins/Apple2MG.cs: + Style changes + 2015-04-22 Natalia Portillo * ImagePlugins/VHD.cs: diff --git a/DiscImageChef/ImagePlugins/Apple2MG.cs b/DiscImageChef/ImagePlugins/Apple2MG.cs index 70982489..7dba6167 100644 --- a/DiscImageChef/ImagePlugins/Apple2MG.cs +++ b/DiscImageChef/ImagePlugins/Apple2MG.cs @@ -122,6 +122,7 @@ namespace DiscImageChef.ImagePlugins #endregion #region Internal Constants + /// /// Magic number, "2IMG" /// @@ -158,11 +159,14 @@ namespace DiscImageChef.ImagePlugins 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) @@ -214,7 +218,7 @@ namespace DiscImageChef.ImagePlugins // There seems to be incorrect endian in some images on the wild if (datasize == 0x00800C00) datasize = 0x000C8000; - if (dataoff+datasize > stream.Length) + if (dataoff + datasize > stream.Length) return false; UInt32 commentoff = BitConverter.ToUInt32(header, 0x20); @@ -222,7 +226,7 @@ namespace DiscImageChef.ImagePlugins return false; UInt32 commentsize = BitConverter.ToUInt32(header, 0x24); - if (commentoff+commentsize > stream.Length) + if (commentoff + commentsize > stream.Length) return false; UInt32 creatoroff = BitConverter.ToUInt32(header, 0x28); @@ -230,11 +234,9 @@ namespace DiscImageChef.ImagePlugins return false; UInt32 creatorsize = BitConverter.ToUInt32(header, 0x2C); - if (creatoroff+creatorsize > stream.Length) - return false; - - return true; + return creatoroff + creatorsize <= stream.Length; } + public override bool OpenImage(string imagePath) { FileStream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read); @@ -309,10 +311,7 @@ namespace DiscImageChef.ImagePlugins else if (ImageHeader.dataSize == 0 && ImageHeader.blocks != 0) ImageHeader.dataSize = ImageHeader.blocks * 256; - if (ImageHeader.imageFormat == ProDOSSectorOrder) - ImageInfo.sectorSize = 512; - else - ImageInfo.sectorSize = 256; + ImageInfo.sectorSize = ImageHeader.imageFormat == ProDOSSectorOrder ? 512 : 256; ImageInfo.sectors = ImageHeader.blocks; ImageInfo.imageSize = ImageHeader.dataSize; @@ -365,54 +364,67 @@ namespace DiscImageChef.ImagePlugins 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; @@ -466,118 +478,147 @@ namespace DiscImageChef.ImagePlugins } #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 System.Collections.Generic.List GetPartitions() + + public override List GetPartitions() { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override System.Collections.Generic.List GetTracks() + + public override List GetTracks() { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override System.Collections.Generic.List GetSessionTracks(Session session) + + public override List GetSessionTracks(Session session) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override System.Collections.Generic.List GetSessionTracks(ushort session) + + public override List GetSessionTracks(ushort session) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override System.Collections.Generic.List GetSessions() + + public override List 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 FailingLBAs, out List UnknownLBAs) { FailingLBAs = new List(); @@ -586,14 +627,17 @@ namespace DiscImageChef.ImagePlugins UnknownLBAs.Add(i); return null; } + public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List FailingLBAs, out List UnknownLBAs) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } + public override bool? VerifyDiskImage() { return null; } + #endregion } } diff --git a/DiscImageChef/ImagePlugins/VHD.cs b/DiscImageChef/ImagePlugins/VHD.cs index 7cbd55dc..fc4c65e7 100644 --- a/DiscImageChef/ImagePlugins/VHD.cs +++ b/DiscImageChef/ImagePlugins/VHD.cs @@ -51,6 +51,7 @@ namespace DiscImageChef.ImagePlugins public class VHD : ImagePlugin { #region Internal Structures + struct HardDiskFooter { /// @@ -149,91 +150,93 @@ namespace DiscImageChef.ImagePlugins struct DynamicDiskHeader { /// - /// Header magic, + /// Offset 0x00, Header magic, /// public UInt64 cookie; /// - /// Offset to next structure on disk image. + /// Offset 0x08, Offset to next structure on disk image. /// Currently unused, 0xFFFFFFFF /// public UInt64 dataOffset; /// - /// Offset of the Block Allocation Table (BAT) + /// Offset 0x10, Offset of the Block Allocation Table (BAT) /// public UInt64 tableOffset; /// - /// Version of this header + /// Offset 0x18, Version of this header /// public UInt32 headerVersion; /// - /// Maximum entries present in the BAT + /// Offset 0x1C, Maximum entries present in the BAT /// public UInt32 maxTableEntries; /// - /// Size of a block in bytes + /// Offset 0x20, Size of a block in bytes /// Should always be a power of two of 512 /// public UInt32 blockSize; /// - /// Checksum of this header + /// Offset 0x24, Checksum of this header /// public UInt32 checksum; /// - /// UUID of parent disk image for differencing type + /// Offset 0x28, UUID of parent disk image for differencing type /// public Guid parentID; /// - /// Timestamp of parent disk image + /// Offset 0x38, Timestamp of parent disk image /// public UInt32 parentTimestamp; /// - /// Reserved + /// Offset 0x3C, Reserved /// public UInt32 reserved; /// - /// 512 bytes UTF-16 of paren disk image filename + /// Offset 0x40, 512 bytes UTF-16 of parent disk image filename /// public string parentName; /// - /// Parent disk image locator entry, + /// Offset 0x240, Parent disk image locator entry, /// public ParentLocatorEntry locatorEntry1; /// - /// Parent disk image locator entry, + /// Offset 0x258, Parent disk image locator entry, /// public ParentLocatorEntry locatorEntry2; /// - /// Parent disk image locator entry, + /// Offset 0x270, Parent disk image locator entry, /// public ParentLocatorEntry locatorEntry3; /// - /// Parent disk image locator entry, + /// Offset 0x288, Parent disk image locator entry, /// public ParentLocatorEntry locatorEntry4; /// - /// Parent disk image locator entry, + /// Offset 0x2A0, Parent disk image locator entry, /// public ParentLocatorEntry locatorEntry5; /// - /// Parent disk image locator entry, + /// Offset 0x2B8, Parent disk image locator entry, /// public ParentLocatorEntry locatorEntry6; /// - /// Parent disk image locator entry, + /// Offset 0x2D0, Parent disk image locator entry, /// public ParentLocatorEntry locatorEntry7; /// - /// Parent disk image locator entry, + /// Offset 0x2E8, Parent disk image locator entry, /// public ParentLocatorEntry locatorEntry8; /// - /// 256 reserved bytes + /// Offset 0x300, 256 reserved bytes /// public byte[] reserved2; } + #endregion #region Internal Constants + /// /// File magic number, "conectix" /// @@ -365,9 +368,11 @@ namespace DiscImageChef.ImagePlugins /// Stores a Mac OS X URI (RFC-2396) absolute path in UTF-8, "MacX" /// const UInt32 platformCodeMacintoshURI = 0x4D616358; + #endregion #region Internal variables + HardDiskFooter thisFooter; HardDiskFooter parentFooter; DynamicDiskHeader thisDynamic; @@ -376,6 +381,7 @@ namespace DiscImageChef.ImagePlugins DateTime parentDateTime; string thisPath; string parentPath; + #endregion public VHD(PluginBase Core) @@ -405,6 +411,7 @@ namespace DiscImageChef.ImagePlugins } #region public methods + public override bool IdentifyImage(string imagePath) { FileStream imageStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read); @@ -534,7 +541,7 @@ namespace DiscImageChef.ImagePlugins Console.WriteLine("DEBUG (VirtualPC plugin): footer.originalSize = {0}", thisFooter.originalSize); Console.WriteLine("DEBUG (VirtualPC plugin): footer.currentSize = {0}", thisFooter.currentSize); Console.WriteLine("DEBUG (VirtualPC plugin): footer.diskGeometry = 0x{0:X8} (C/H/S: {1}/{2}/{3})", thisFooter.diskGeometry, - (thisFooter.diskGeometry&0xFFFF0000)>>16, (thisFooter.diskGeometry&0xFF00)>>8, (thisFooter.diskGeometry&0xFF)); + (thisFooter.diskGeometry & 0xFFFF0000) >> 16, (thisFooter.diskGeometry & 0xFF00) >> 8, (thisFooter.diskGeometry & 0xFF)); Console.WriteLine("DEBUG (VirtualPC plugin): footer.diskType = 0x{0:X8}", thisFooter.diskType); Console.WriteLine("DEBUG (VirtualPC plugin): footer.checksum = 0x{0:X8}", thisFooter.checksum); Console.WriteLine("DEBUG (VirtualPC plugin): footer.uniqueId = {0}", thisFooter.uniqueId); @@ -542,7 +549,7 @@ namespace DiscImageChef.ImagePlugins Console.WriteLine("DEBUG (VirtualPC plugin): footer.reserved's SHA1 = 0x{0}", sha1Ctx.End()); } - if(thisFooter.version == Version1) + if (thisFooter.version == Version1) ImageInfo.imageVersion = "1.0"; else throw new ImageNotSupportedException(String.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType)); @@ -579,7 +586,7 @@ namespace DiscImageChef.ImagePlugins case CreatorVirtualServer: { ImageInfo.imageApplication = "Microsoft Virtual Server"; - switch(thisFooter.creatorVersion) + switch (thisFooter.creatorVersion) { case VersionVirtualServer2004: ImageInfo.imageApplicationVersion = "2004"; @@ -596,7 +603,7 @@ namespace DiscImageChef.ImagePlugins { case CreatorMacintosh: case CreatorMacintoshOld: - switch(thisFooter.creatorVersion) + switch (thisFooter.creatorVersion) { case VersionVirtualPCMac: ImageInfo.imageApplication = "Connectix Virtual PC"; @@ -608,7 +615,7 @@ namespace DiscImageChef.ImagePlugins } break; case CreatorWindows: - switch(thisFooter.creatorVersion) + switch (thisFooter.creatorVersion) { case VersionVirtualPCMac: ImageInfo.imageApplication = "Connectix Virtual PC"; @@ -644,7 +651,7 @@ namespace DiscImageChef.ImagePlugins thisPath = imagePath; ImageInfo.imageSize = thisFooter.currentSize; - ImageInfo.sectors = thisFooter.currentSize/512; + ImageInfo.sectors = thisFooter.currentSize / 512; ImageInfo.sectorSize = 512; FileInfo fi = new FileInfo(imagePath); @@ -685,21 +692,25 @@ namespace DiscImageChef.ImagePlugins { 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() { - switch(thisFooter.diskType) + switch (thisFooter.diskType) { case typeFixed: return "Virtual PC fixed size disk image"; @@ -711,6 +722,7 @@ namespace DiscImageChef.ImagePlugins return "Virtual PC disk image"; } } + public override string GetImageVersion() { return ImageInfo.imageVersion; @@ -793,9 +805,11 @@ namespace DiscImageChef.ImagePlugins } } } + #endregion #region private methods + UInt32 VHDChecksum(byte[] data) { UInt32 checksum = 0; @@ -803,125 +817,156 @@ namespace DiscImageChef.ImagePlugins checksum += b; return ~checksum; } + #endregion #region Unsupported features + public override string GetImageComments() { return null; } + 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 System.Collections.Generic.List GetPartitions() { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } + public override System.Collections.Generic.List GetTracks() { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } + public override System.Collections.Generic.List GetSessionTracks(Session session) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } + public override System.Collections.Generic.List GetSessionTracks(ushort session) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } + public override System.Collections.Generic.List 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 FailingLBAs, out List UnknownLBAs) { FailingLBAs = new List(); @@ -930,14 +975,17 @@ namespace DiscImageChef.ImagePlugins UnknownLBAs.Add(i); return null; } + public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List FailingLBAs, out List UnknownLBAs) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } + public override bool? VerifyDiskImage() { return null; } + #endregion } }