2017-09-25 01:29:38 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : MaxiDisk.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : Disk image plugins.
|
2017-09-25 01:29:38 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Manages MaxiDisk images.
|
2017-09-25 01:29:38 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2017-09-25 01:29:38 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
|
|
|
|
|
using DiscImageChef.Console;
|
|
|
|
|
|
using DiscImageChef.Filters;
|
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
namespace DiscImageChef.DiscImages
|
2017-09-25 01:29:38 +01:00
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
public class MaxiDisk : IMediaImage
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>Disk image file</summary>
|
2017-12-26 06:05:12 +00:00
|
|
|
|
IFilter hdkImageFilter;
|
|
|
|
|
|
ImageInfo imageInfo;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
public MaxiDisk()
|
|
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo = new ImageInfo
|
2017-12-22 06:55:04 +00:00
|
|
|
|
{
|
|
|
|
|
|
ReadableSectorTags = new List<SectorTagType>(),
|
|
|
|
|
|
ReadableMediaTags = new List<MediaTagType>(),
|
2017-12-26 02:51:10 +00:00
|
|
|
|
HasPartitions = false,
|
|
|
|
|
|
HasSessions = false,
|
|
|
|
|
|
Application = "MAXI Disk",
|
|
|
|
|
|
Creator = null,
|
|
|
|
|
|
Comments = null,
|
2017-12-22 06:55:04 +00:00
|
|
|
|
MediaManufacturer = null,
|
|
|
|
|
|
MediaModel = null,
|
|
|
|
|
|
MediaSerialNumber = null,
|
|
|
|
|
|
MediaBarcode = null,
|
|
|
|
|
|
MediaPartNumber = null,
|
|
|
|
|
|
MediaSequence = 0,
|
|
|
|
|
|
LastMediaSequence = 0,
|
|
|
|
|
|
DriveManufacturer = null,
|
|
|
|
|
|
DriveModel = null,
|
|
|
|
|
|
DriveSerialNumber = null,
|
|
|
|
|
|
DriveFirmwareRevision = null
|
|
|
|
|
|
};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public ImageInfo Info => imageInfo;
|
2017-12-26 02:51:10 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public string Name => "MAXI Disk image";
|
|
|
|
|
|
public Guid Id => new Guid("D27D924A-7034-466E-ADE1-B81EF37E469E");
|
2017-12-26 06:05:12 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public string ImageFormat => "MAXI Disk";
|
2017-12-26 06:05:12 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public List<Partition> Partitions =>
|
2017-12-26 02:51:10 +00:00
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public List<Track> Tracks =>
|
2017-12-26 02:51:10 +00:00
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public List<Session> Sessions =>
|
2017-12-26 02:51:10 +00:00
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool IdentifyImage(IFilter imageFilter)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
|
|
|
|
|
|
|
|
|
|
|
if(stream.Length < 8) return false;
|
|
|
|
|
|
|
|
|
|
|
|
byte[] buffer = new byte[8];
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
stream.Read(buffer, 0, buffer.Length);
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr ftrPtr = Marshal.AllocHGlobal(buffer.Length);
|
|
|
|
|
|
Marshal.Copy(buffer, 0, ftrPtr, buffer.Length);
|
2017-12-22 06:55:04 +00:00
|
|
|
|
HdkHeader tmpHeader = (HdkHeader)Marshal.PtrToStructure(ftrPtr, typeof(HdkHeader));
|
2017-12-19 20:33:03 +00:00
|
|
|
|
Marshal.FreeHGlobal(ftrPtr);
|
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
|
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.unknown = {0}", tmpHeader.unknown);
|
|
|
|
|
|
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.diskType = {0}", tmpHeader.diskType);
|
|
|
|
|
|
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.heads = {0}", tmpHeader.heads);
|
|
|
|
|
|
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.cylinders = {0}", tmpHeader.cylinders);
|
|
|
|
|
|
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.bytesPerSector = {0}", tmpHeader.bytesPerSector);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.sectorsPerTrack = {0}",
|
2017-12-22 06:55:04 +00:00
|
|
|
|
tmpHeader.sectorsPerTrack);
|
|
|
|
|
|
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.unknown2 = {0}", tmpHeader.unknown2);
|
|
|
|
|
|
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.unknown3 = {0}", tmpHeader.unknown3);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
// This is hardcoded
|
|
|
|
|
|
// But its possible values are unknown...
|
|
|
|
|
|
//if(tmp_header.diskType > 11)
|
2017-12-22 06:55:04 +00:00
|
|
|
|
// return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
// Only floppies supported
|
2017-12-22 06:55:04 +00:00
|
|
|
|
if(tmpHeader.heads == 0 || tmpHeader.heads > 2) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
// No floppies with more than this?
|
2017-12-22 06:55:04 +00:00
|
|
|
|
if(tmpHeader.cylinders > 90) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
// Maximum supported bps is 16384
|
2017-12-22 06:55:04 +00:00
|
|
|
|
if(tmpHeader.bytesPerSector > 7) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
|
int expectedFileSize = tmpHeader.heads * tmpHeader.cylinders * tmpHeader.sectorsPerTrack *
|
|
|
|
|
|
(128 << tmpHeader.bytesPerSector) + 8;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
return expectedFileSize == stream.Length;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool OpenImage(IFilter imageFilter)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
|
|
|
|
|
|
|
|
|
|
|
if(stream.Length < 8) return false;
|
|
|
|
|
|
|
|
|
|
|
|
byte[] buffer = new byte[8];
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
stream.Read(buffer, 0, buffer.Length);
|
|
|
|
|
|
|
|
|
|
|
|
IntPtr ftrPtr = Marshal.AllocHGlobal(buffer.Length);
|
|
|
|
|
|
Marshal.Copy(buffer, 0, ftrPtr, buffer.Length);
|
2017-12-22 06:55:04 +00:00
|
|
|
|
HdkHeader tmpHeader = (HdkHeader)Marshal.PtrToStructure(ftrPtr, typeof(HdkHeader));
|
2017-12-19 20:33:03 +00:00
|
|
|
|
Marshal.FreeHGlobal(ftrPtr);
|
|
|
|
|
|
|
|
|
|
|
|
// This is hardcoded
|
|
|
|
|
|
// But its possible values are unknown...
|
|
|
|
|
|
//if(tmp_header.diskType > 11)
|
2017-12-22 06:55:04 +00:00
|
|
|
|
// return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
// Only floppies supported
|
2017-12-22 06:55:04 +00:00
|
|
|
|
if(tmpHeader.heads == 0 || tmpHeader.heads > 2) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
// No floppies with more than this?
|
2017-12-22 06:55:04 +00:00
|
|
|
|
if(tmpHeader.cylinders > 90) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
// Maximum supported bps is 16384
|
2017-12-22 06:55:04 +00:00
|
|
|
|
if(tmpHeader.bytesPerSector > 7) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
|
int expectedFileSize = tmpHeader.heads * tmpHeader.cylinders * tmpHeader.sectorsPerTrack *
|
|
|
|
|
|
(128 << tmpHeader.bytesPerSector) + 8;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
if(expectedFileSize != stream.Length) return false;
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.Cylinders = tmpHeader.cylinders;
|
|
|
|
|
|
imageInfo.Heads = tmpHeader.heads;
|
|
|
|
|
|
imageInfo.SectorsPerTrack = tmpHeader.sectorsPerTrack;
|
|
|
|
|
|
imageInfo.Sectors = (ulong)(tmpHeader.heads * tmpHeader.cylinders * tmpHeader.sectorsPerTrack);
|
|
|
|
|
|
imageInfo.SectorSize = (uint)(128 << tmpHeader.bytesPerSector);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
hdkImageFilter = imageFilter;
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.ImageSize = (ulong)(stream.Length - 8);
|
|
|
|
|
|
imageInfo.CreationTime = imageFilter.GetCreationTime();
|
|
|
|
|
|
imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
|
|
|
|
|
|
|
|
|
|
|
|
if(imageInfo.Heads == 2 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 15 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_525_HD;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 16 &&
|
|
|
|
|
|
imageInfo.SectorSize == 256) imageInfo.MediaType = MediaType.ACORN_525_DS_DD;
|
|
|
|
|
|
else if(imageInfo.Heads == 1 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 16 &&
|
|
|
|
|
|
imageInfo.SectorSize == 256) imageInfo.MediaType = MediaType.ACORN_525_SS_DD_80;
|
|
|
|
|
|
else if(imageInfo.Heads == 1 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 10 &&
|
|
|
|
|
|
imageInfo.SectorSize == 256) imageInfo.MediaType = MediaType.ACORN_525_SS_SD_80;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 77 && imageInfo.SectorsPerTrack == 8 &&
|
|
|
|
|
|
imageInfo.SectorSize == 1024) imageInfo.MediaType = MediaType.NEC_525_HD;
|
|
|
|
|
|
else if(imageInfo.Heads == 1 && imageInfo.Cylinders == 40 && imageInfo.SectorsPerTrack == 8 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_525_SS_DD_8;
|
|
|
|
|
|
else if(imageInfo.Heads == 1 && imageInfo.Cylinders == 40 && imageInfo.SectorsPerTrack == 9 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_525_SS_DD_9;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 40 && imageInfo.SectorsPerTrack == 8 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_525_DS_DD_8;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 40 && imageInfo.SectorsPerTrack == 9 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_525_DS_DD_9;
|
|
|
|
|
|
else if(imageInfo.Heads == 1 && imageInfo.Cylinders == 40 && imageInfo.SectorsPerTrack == 18 &&
|
|
|
|
|
|
imageInfo.SectorSize == 128) imageInfo.MediaType = MediaType.ATARI_525_SD;
|
|
|
|
|
|
else if(imageInfo.Heads == 1 && imageInfo.Cylinders == 40 && imageInfo.SectorsPerTrack == 26 &&
|
|
|
|
|
|
imageInfo.SectorSize == 128) imageInfo.MediaType = MediaType.ATARI_525_ED;
|
|
|
|
|
|
else if(imageInfo.Heads == 1 && imageInfo.Cylinders == 40 && imageInfo.SectorsPerTrack == 18 &&
|
|
|
|
|
|
imageInfo.SectorSize == 256) imageInfo.MediaType = MediaType.ATARI_525_DD;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 36 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_35_ED;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 18 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_35_HD;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 21 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DMF;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 82 && imageInfo.SectorsPerTrack == 21 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DMF_82;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 77 && imageInfo.SectorsPerTrack == 8 &&
|
|
|
|
|
|
imageInfo.SectorSize == 1024) imageInfo.MediaType = MediaType.NEC_35_HD_8;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 15 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.NEC_35_HD_15;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 9 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_35_DS_DD_9;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 8 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_35_DS_DD_8;
|
|
|
|
|
|
else if(imageInfo.Heads == 1 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 9 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_35_SS_DD_9;
|
|
|
|
|
|
else if(imageInfo.Heads == 1 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 8 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.DOS_35_SS_DD_8;
|
|
|
|
|
|
else if(imageInfo.Heads == 2 && imageInfo.Cylinders == 80 && imageInfo.SectorsPerTrack == 5 &&
|
|
|
|
|
|
imageInfo.SectorSize == 1024) imageInfo.MediaType = MediaType.ACORN_35_DS_DD;
|
|
|
|
|
|
else if(imageInfo.Heads == 1 && imageInfo.Cylinders == 70 && imageInfo.SectorsPerTrack == 9 &&
|
|
|
|
|
|
imageInfo.SectorSize == 512) imageInfo.MediaType = MediaType.Apricot_35;
|
|
|
|
|
|
else imageInfo.MediaType = MediaType.Unknown;
|
|
|
|
|
|
|
|
|
|
|
|
imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool? VerifySector(ulong sectorAddress)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool? VerifySector(ulong sectorAddress, uint track)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
|
2017-12-20 17:15:26 +00:00
|
|
|
|
out List<ulong> unknownLbas)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
for(ulong i = sectorAddress; i < sectorAddress + length; i++) unknownLbas.Add(i);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
2017-12-20 17:15:26 +00:00
|
|
|
|
out List<ulong> unknownLbas)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
for(ulong i = sectorAddress; i < sectorAddress + length; i++) unknownLbas.Add(i);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool? VerifyMediaImage()
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSector(ulong sectorAddress)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
return ReadSectors(sectorAddress, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(sectorAddress > imageInfo.Sectors - 1)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(sectorAddress + length > imageInfo.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
byte[] buffer = new byte[length * imageInfo.SectorSize];
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
Stream stream = hdkImageFilter.GetDataForkStream();
|
2017-12-26 06:05:12 +00:00
|
|
|
|
stream.Seek((long)(8 + sectorAddress * imageInfo.SectorSize), SeekOrigin.Begin);
|
|
|
|
|
|
stream.Read(buffer, 0, (int)(length * imageInfo.SectorSize));
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsLong(ulong sectorAddress, uint length)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadDiskTag(MediaTagType tag)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public List<Track> GetSessionTracks(Session session)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public List<Track> GetSessionTracks(ushort session)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSector(ulong sectorAddress, uint track)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress, uint track)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
2017-12-24 00:12:31 +00:00
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct HdkHeader
|
|
|
|
|
|
{
|
|
|
|
|
|
public byte unknown;
|
|
|
|
|
|
public byte diskType;
|
|
|
|
|
|
public byte heads;
|
|
|
|
|
|
public byte cylinders;
|
|
|
|
|
|
public byte bytesPerSector;
|
|
|
|
|
|
public byte sectorsPerTrack;
|
|
|
|
|
|
public byte unknown2;
|
|
|
|
|
|
public byte unknown3;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum HdkDiskTypes : byte
|
|
|
|
|
|
{
|
|
|
|
|
|
Dos360 = 0,
|
|
|
|
|
|
Maxi420 = 1,
|
|
|
|
|
|
Dos720 = 2,
|
|
|
|
|
|
Maxi800 = 3,
|
|
|
|
|
|
Dos1200 = 4,
|
|
|
|
|
|
Maxi1400 = 5,
|
|
|
|
|
|
Dos1440 = 6,
|
|
|
|
|
|
Mac1440 = 7,
|
|
|
|
|
|
Maxi1600 = 8,
|
|
|
|
|
|
Dmf = 9,
|
|
|
|
|
|
Dos2880 = 10,
|
|
|
|
|
|
Maxi3200 = 11
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|