2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-08-02 18:09:24 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : BLU.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
// Component : Disk image plugins.
|
2016-08-02 18:09:24 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
// Manages Basic Lisa Utility disk images.
|
2016-08-02 18:09:24 +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
|
2016-08-02 18:09:24 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
2017-12-19 19:33:46 +00:00
|
|
|
using DiscImageChef.Console;
|
2016-09-05 17:37:31 +01:00
|
|
|
using DiscImageChef.Filters;
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
namespace DiscImageChef.DiscImages
|
2016-08-02 18:09:24 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
public class Blu : ImagePlugin
|
2016-08-02 18:09:24 +01:00
|
|
|
{
|
|
|
|
|
#region Internal Structures
|
2017-12-20 17:15:26 +00:00
|
|
|
struct BluHeader
|
2016-08-02 18:09:24 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
public byte[] DeviceName;
|
|
|
|
|
public uint DeviceType;
|
|
|
|
|
public uint DeviceBlocks;
|
|
|
|
|
public ushort BytesPerBlock;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
#endregion Internal Structures
|
|
|
|
|
|
|
|
|
|
#region Internal Constants
|
2017-12-20 17:15:26 +00:00
|
|
|
const string PROFILE_NAME = "PROFILE ";
|
|
|
|
|
const string PROFILE10_NAME = "PROFILE 10 ";
|
|
|
|
|
const string WIDGET_NAME = "WIDGET-10 ";
|
|
|
|
|
const string PRIAM_NAME = "PRIAMDTATOWER";
|
2016-08-02 18:09:24 +01:00
|
|
|
#endregion Internal Constants
|
|
|
|
|
|
|
|
|
|
#region Internal variables
|
2017-12-20 17:15:26 +00:00
|
|
|
BluHeader imageHeader;
|
2016-09-05 17:37:31 +01:00
|
|
|
Filter bluImageFilter;
|
2016-08-02 18:09:24 +01:00
|
|
|
int bptag;
|
|
|
|
|
#endregion Internal variables
|
|
|
|
|
|
|
|
|
|
#region Public methods
|
2017-12-20 17:15:26 +00:00
|
|
|
public Blu()
|
2016-08-02 18:09:24 +01:00
|
|
|
{
|
|
|
|
|
Name = "Basic Lisa Utility";
|
2017-12-20 17:15:26 +00:00
|
|
|
PluginUuid = new Guid("A153E2F8-4235-432D-9A7F-20807B0BCD74");
|
2016-08-02 18:09:24 +01:00
|
|
|
ImageInfo = new ImageInfo();
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.ReadableSectorTags = new List<SectorTagType>();
|
|
|
|
|
ImageInfo.ReadableMediaTags = new List<MediaTagType>();
|
|
|
|
|
ImageInfo.ImageHasPartitions = false;
|
|
|
|
|
ImageInfo.ImageHasSessions = false;
|
|
|
|
|
ImageInfo.ImageVersion = null;
|
|
|
|
|
ImageInfo.ImageApplication = null;
|
|
|
|
|
ImageInfo.ImageApplicationVersion = null;
|
|
|
|
|
ImageInfo.ImageCreator = null;
|
|
|
|
|
ImageInfo.ImageComments = null;
|
|
|
|
|
ImageInfo.MediaManufacturer = null;
|
|
|
|
|
ImageInfo.MediaModel = null;
|
|
|
|
|
ImageInfo.MediaSerialNumber = null;
|
|
|
|
|
ImageInfo.MediaBarcode = null;
|
|
|
|
|
ImageInfo.MediaPartNumber = null;
|
|
|
|
|
ImageInfo.MediaSequence = 0;
|
|
|
|
|
ImageInfo.LastMediaSequence = 0;
|
|
|
|
|
ImageInfo.DriveManufacturer = null;
|
|
|
|
|
ImageInfo.DriveModel = null;
|
|
|
|
|
ImageInfo.DriveSerialNumber = null;
|
|
|
|
|
ImageInfo.DriveFirmwareRevision = null;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
public override bool IdentifyImage(Filter imageFilter)
|
2016-08-02 18:09:24 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
2016-08-02 18:09:24 +01:00
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(stream.Length < 0x200) return false;
|
2016-08-02 18:09:24 +01:00
|
|
|
|
|
|
|
|
byte[] header = new byte[0x17];
|
|
|
|
|
stream.Read(header, 0, 0x17);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
BluHeader tmpHdr = new BluHeader();
|
|
|
|
|
tmpHdr.DeviceName = new byte[0x0D];
|
2016-08-02 18:09:24 +01:00
|
|
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
Array.Copy(header, 0, tmpHdr.DeviceName, 0, 0x0D);
|
|
|
|
|
tmpHdr.DeviceType = BigEndianBitConverter.ToUInt32(header, 0x0C) & 0x00FFFFFF;
|
|
|
|
|
tmpHdr.DeviceBlocks = BigEndianBitConverter.ToUInt32(header, 0x11) & 0x00FFFFFF;
|
|
|
|
|
tmpHdr.BytesPerBlock = BigEndianBitConverter.ToUInt16(header, 0x15);
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
for(int i = 0; i < 0xD; i++) { if(tmpHdr.DeviceName[i] < 0x20) return false; }
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if((tmpHdr.BytesPerBlock & 0xFE00) != 0x200) return false;
|
2016-08-02 18:09:24 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
public override bool OpenImage(Filter imageFilter)
|
2016-08-02 18:09:24 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
2016-08-02 18:09:24 +01:00
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
imageHeader = new BluHeader();
|
|
|
|
|
imageHeader.DeviceName = new byte[0x0D];
|
2016-08-02 18:09:24 +01:00
|
|
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
|
|
|
|
|
|
|
|
|
byte[] header = new byte[0x17];
|
|
|
|
|
stream.Read(header, 0, 0x17);
|
2017-12-20 17:15:26 +00:00
|
|
|
Array.Copy(header, 0, imageHeader.DeviceName, 0, 0x0D);
|
|
|
|
|
imageHeader.DeviceType = BigEndianBitConverter.ToUInt32(header, 0x0C) & 0x00FFFFFF;
|
|
|
|
|
imageHeader.DeviceBlocks = BigEndianBitConverter.ToUInt32(header, 0x11) & 0x00FFFFFF;
|
|
|
|
|
imageHeader.BytesPerBlock = BigEndianBitConverter.ToUInt16(header, 0x15);
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("BLU plugin", "ImageHeader.deviceName = \"{0}\"",
|
2017-12-20 17:15:26 +00:00
|
|
|
StringHandlers.CToString(imageHeader.DeviceName));
|
|
|
|
|
DicConsole.DebugWriteLine("BLU plugin", "ImageHeader.deviceType = {0}", imageHeader.DeviceType);
|
|
|
|
|
DicConsole.DebugWriteLine("BLU plugin", "ImageHeader.deviceBlock = {0}", imageHeader.DeviceBlocks);
|
|
|
|
|
DicConsole.DebugWriteLine("BLU plugin", "ImageHeader.bytesPerBlock = {0}", imageHeader.BytesPerBlock);
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
for(int i = 0; i < 0xD; i++) { if(imageHeader.DeviceName[i] < 0x20) return false; }
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if((imageHeader.BytesPerBlock & 0xFE00) != 0x200) return false;
|
2016-08-02 18:09:24 +01:00
|
|
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
header = new byte[imageHeader.BytesPerBlock];
|
|
|
|
|
stream.Read(header, 0, imageHeader.BytesPerBlock);
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.SectorSize = 0x200;
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.Sectors = imageHeader.DeviceBlocks;
|
|
|
|
|
ImageInfo.ImageSize = imageHeader.DeviceBlocks * imageHeader.BytesPerBlock;
|
|
|
|
|
bptag = imageHeader.BytesPerBlock - 0x200;
|
2016-08-02 18:09:24 +01:00
|
|
|
byte[] hdrTag = new byte[bptag];
|
|
|
|
|
Array.Copy(header, 0x200, hdrTag, 0, bptag);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
switch(StringHandlers.CToString(imageHeader.DeviceName))
|
2016-08-02 18:09:24 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case PROFILE_NAME:
|
|
|
|
|
if(ImageInfo.Sectors == 0x2600) ImageInfo.MediaType = MediaType.AppleProfile;
|
|
|
|
|
else ImageInfo.MediaType = MediaType.GENERIC_HDD;
|
|
|
|
|
ImageInfo.Cylinders = 152;
|
|
|
|
|
ImageInfo.Heads = 4;
|
|
|
|
|
ImageInfo.SectorsPerTrack = 16;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case PROFILE10_NAME:
|
|
|
|
|
if(ImageInfo.Sectors == 0x4C00) ImageInfo.MediaType = MediaType.AppleProfile;
|
|
|
|
|
else ImageInfo.MediaType = MediaType.GENERIC_HDD;
|
|
|
|
|
ImageInfo.Cylinders = 304;
|
|
|
|
|
ImageInfo.Heads = 4;
|
|
|
|
|
ImageInfo.SectorsPerTrack = 16;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case WIDGET_NAME:
|
|
|
|
|
if(ImageInfo.Sectors == 0x4C00) ImageInfo.MediaType = MediaType.AppleWidget;
|
|
|
|
|
else ImageInfo.MediaType = MediaType.GENERIC_HDD;
|
|
|
|
|
ImageInfo.Cylinders = 304;
|
|
|
|
|
ImageInfo.Heads = 4;
|
|
|
|
|
ImageInfo.SectorsPerTrack = 16;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case PRIAM_NAME:
|
|
|
|
|
if(ImageInfo.Sectors == 0x022C7C) ImageInfo.MediaType = MediaType.PriamDataTower;
|
|
|
|
|
else ImageInfo.MediaType = MediaType.GENERIC_HDD;
|
2017-12-19 20:33:03 +00:00
|
|
|
// This values are invented...
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.Cylinders = 419;
|
|
|
|
|
ImageInfo.Heads = 4;
|
|
|
|
|
ImageInfo.SectorsPerTrack = 85;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
2016-08-02 18:09:24 +01:00
|
|
|
default:
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.MediaType = MediaType.GENERIC_HDD;
|
|
|
|
|
ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63);
|
|
|
|
|
ImageInfo.Heads = 16;
|
|
|
|
|
ImageInfo.SectorsPerTrack = 63;
|
2016-08-02 18:09:24 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.ImageApplication = StringHandlers.CToString(hdrTag);
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.ImageCreationTime = imageFilter.GetCreationTime();
|
|
|
|
|
ImageInfo.ImageLastModificationTime = imageFilter.GetLastWriteTime();
|
|
|
|
|
ImageInfo.ImageName = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
bluImageFilter = imageFilter;
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.XmlMediaType = XmlMediaType.BlockMedia;
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(bptag > 0) ImageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag);
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.VerboseWriteLine("BLU image contains a disk of type {0}", ImageInfo.MediaType);
|
2016-08-21 17:35:35 +01:00
|
|
|
|
2016-08-02 18:09:24 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Verification, should add tag checksum checks
|
|
|
|
|
public override bool? VerifySector(ulong sectorAddress)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool? VerifySector(ulong sectorAddress, uint track)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
|
|
|
|
|
out List<ulong> unknownLbas)
|
2016-08-02 18:09:24 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
for(ulong i = sectorAddress; i < sectorAddress + length; i++) unknownLbas.Add(i);
|
2016-08-02 18:09:24 +01:00
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
|
|
|
|
out List<ulong> unknownLbas)
|
2016-08-02 18:09:24 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
for(ulong i = sectorAddress; i < sectorAddress + length; i++) unknownLbas.Add(i);
|
2016-08-02 18:09:24 +01:00
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool? VerifyMediaImage()
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
#endregion Verification, should add tag checksum checks
|
|
|
|
|
|
|
|
|
|
public override bool ImageHasPartitions()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageHasPartitions;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override ulong GetImageSize()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageSize;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override ulong GetSectors()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.Sectors;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override uint GetSectorSize()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.SectorSize;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSector(ulong sectorAddress)
|
|
|
|
|
{
|
|
|
|
|
return ReadSectors(sectorAddress, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
|
|
|
|
|
{
|
|
|
|
|
return ReadSectorsTag(sectorAddress, 1, tag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectors(ulong sectorAddress, uint length)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorAddress > ImageInfo.Sectors - 1)
|
2016-08-02 18:09:24 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorAddress + length > ImageInfo.Sectors)
|
2016-08-02 18:09:24 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
|
|
|
|
|
|
|
|
|
|
MemoryStream buffer = new MemoryStream();
|
|
|
|
|
int seek = 0;
|
|
|
|
|
int read = 0x200;
|
|
|
|
|
int skip = bptag;
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = bluImageFilter.GetDataForkStream();
|
2017-12-20 17:15:26 +00:00
|
|
|
stream.Seek((long)((sectorAddress + 1) * imageHeader.BytesPerBlock), SeekOrigin.Begin);
|
2016-08-02 18:09:24 +01:00
|
|
|
|
|
|
|
|
for(int i = 0; i < length; i++)
|
|
|
|
|
{
|
|
|
|
|
stream.Seek(seek, SeekOrigin.Current);
|
|
|
|
|
byte[] sector = new byte[read];
|
|
|
|
|
stream.Read(sector, 0, read);
|
|
|
|
|
buffer.Write(sector, 0, read);
|
|
|
|
|
stream.Seek(skip, SeekOrigin.Current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
|
|
|
|
|
{
|
|
|
|
|
if(tag != SectorTagType.AppleSectorTag)
|
|
|
|
|
throw new FeatureUnsupportedImageException(string.Format("Tag {0} not supported by image format", tag));
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(bptag == 0) throw new FeatureNotPresentImageException("Disk image does not have tags");
|
2016-08-02 18:09:24 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorAddress > ImageInfo.Sectors - 1)
|
2016-08-02 18:09:24 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorAddress + length > ImageInfo.Sectors)
|
2016-08-02 18:09:24 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
|
|
|
|
|
|
|
|
|
|
MemoryStream buffer = new MemoryStream();
|
|
|
|
|
int seek = 0x200;
|
|
|
|
|
int read = bptag;
|
|
|
|
|
int skip = 0;
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = bluImageFilter.GetDataForkStream();
|
2017-12-20 17:15:26 +00:00
|
|
|
stream.Seek((long)((sectorAddress + 1) * imageHeader.BytesPerBlock), SeekOrigin.Begin);
|
2016-08-02 18:09:24 +01:00
|
|
|
|
|
|
|
|
for(int i = 0; i < length; i++)
|
|
|
|
|
{
|
|
|
|
|
stream.Seek(seek, SeekOrigin.Current);
|
|
|
|
|
byte[] sector = new byte[read];
|
|
|
|
|
stream.Read(sector, 0, read);
|
|
|
|
|
buffer.Write(sector, 0, read);
|
|
|
|
|
stream.Seek(skip, SeekOrigin.Current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorLong(ulong sectorAddress)
|
|
|
|
|
{
|
|
|
|
|
return ReadSectorsLong(sectorAddress, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorAddress > ImageInfo.Sectors - 1)
|
2016-08-02 18:09:24 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorAddress + length > ImageInfo.Sectors)
|
2016-08-02 18:09:24 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] buffer = new byte[length * imageHeader.BytesPerBlock];
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = bluImageFilter.GetDataForkStream();
|
2017-12-20 17:15:26 +00:00
|
|
|
stream.Seek((long)((sectorAddress + 1) * imageHeader.BytesPerBlock), SeekOrigin.Begin);
|
2016-08-02 18:09:24 +01:00
|
|
|
stream.Read(buffer, 0, buffer.Length);
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageFormat()
|
|
|
|
|
{
|
|
|
|
|
return "Basic Lisa Utility";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageVersion()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageVersion;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageApplication()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageApplication;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageApplicationVersion()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageApplicationVersion;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override DateTime GetImageCreationTime()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageCreationTime;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override DateTime GetImageLastModificationTime()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageLastModificationTime;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageName()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageName;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MediaType GetMediaType()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaType;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
#endregion Public methods
|
|
|
|
|
|
|
|
|
|
#region Unsupported features
|
|
|
|
|
public override byte[] ReadDiskTag(MediaTagType tag)
|
|
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageCreator()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageCreator;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetImageComments()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.ImageComments;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetMediaManufacturer()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaManufacturer;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetMediaModel()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaModel;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetMediaSerialNumber()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaSerialNumber;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetMediaBarcode()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaBarcode;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetMediaPartNumber()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaPartNumber;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetMediaSequence()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.MediaSequence;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetLastDiskSequence()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.LastMediaSequence;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetDriveManufacturer()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.DriveManufacturer;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetDriveModel()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.DriveModel;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetDriveSerialNumber()
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
return ImageInfo.DriveSerialNumber;
|
2016-08-02 18:09:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override List<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 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[] 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, uint track)
|
|
|
|
|
{
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
#endregion Unsupported features
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|