Remove DiscImageChef.CommonTypes dependence on DiscImageChef.Decoders.

This commit is contained in:
2020-01-11 20:55:54 +00:00
parent 785638f5f6
commit 1856c6ddb4
12 changed files with 892 additions and 2685 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -32,6 +32,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
namespace DiscImageChef.Decoders.CD
@@ -205,5 +206,95 @@ namespace DiscImageChef.Decoders.CD
return scrambled;
}
// public static byte[] GetUserDataFromMode2(byte[] data)
// {
// byte[] sector;
//
// DiscImageChef.Checksums.CdChecksums.
// EccInit();
//
// if(sectorPrefixDdt == null) sectorPrefixDdt = new uint[imageInfo.Sectors];
//
// sector = new byte[2328];
// if(ArrayHelpers.ArrayIsNullOrEmpty(data))
// {
// sectorPrefixDdt[sectorAddress] = (uint)CdFixFlags.NotDumped;
// return WriteSector(sector, sectorAddress);
// }
//
// prefixCorrect = true;
//
// if(data[0x00] != 0x00 || data[0x01] != 0xFF || data[0x02] != 0xFF || data[0x03] != 0xFF ||
// data[0x04] != 0xFF || data[0x05] != 0xFF || data[0x06] != 0xFF || data[0x07] != 0xFF ||
// data[0x08] != 0xFF || data[0x09] != 0xFF || data[0x0A] != 0xFF || data[0x0B] != 0x00 ||
// data[0x0F] != 0x02) prefixCorrect = false;
//
// if(prefixCorrect)
// {
// minute = (data[0x0C] >> 4) * 10 + (data[0x0C] & 0x0F);
// second = (data[0x0D] >> 4) * 10 + (data[0x0D] & 0x0F);
// frame = (data[0x0E] >> 4) * 10 + (data[0x0E] & 0x0F);
// storedLba = minute * 60 * 75 + second * 75 + frame - 150;
// prefixCorrect = storedLba == (int)sectorAddress;
// }
//
// if(prefixCorrect) sectorPrefixDdt[sectorAddress] = (uint)CdFixFlags.Correct;
// else
// {
// if((sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) > 0)
// sectorPrefixMs.Position =
// ((sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16;
// else sectorPrefixMs.Seek(0, SeekOrigin.End);
//
// sectorPrefixDdt[sectorAddress] = (uint)(sectorPrefixMs.Position / 16 + 1);
//
// sectorPrefixMs.Write(data, 0, 16);
// }
//
// if(mode2Subheaders == null) mode2Subheaders = new byte[imageInfo.Sectors * 8];
//
// bool correctEcc = SuffixIsCorrectMode2(data);
// bool correctEdc = false;
//
// if(correctEcc)
// {
// uint computedEdc = ComputeEdc(0, data, 0x808, 0x10);
// uint edc = BitConverter.ToUInt32(data, 0x818);
// correctEdc = computedEdc == edc;
// }
// else
// {
// uint computedEdc = ComputeEdc(0, data, 0x91C, 0x10);
// uint edc = BitConverter.ToUInt32(data, 0x92C);
// correctEdc = computedEdc == edc;
// }
//
// if(correctEcc && correctEdc)
// {
// sector = new byte[2048];
// if(sectorSuffixDdt == null) sectorSuffixDdt = new uint[imageInfo.Sectors];
// sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Mode2Form1Ok;
// Array.Copy(data, 24, sector, 0, 2048);
// }
// else if(correctEdc)
// {
// sector = new byte[2324];
// if(sectorSuffixDdt == null) sectorSuffixDdt = new uint[imageInfo.Sectors];
// sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Mode2Form2Ok;
// Array.Copy(data, 24, sector, 0, 2324);
// }
// else if(BitConverter.ToUInt32(data, 0x92C) == 0)
// {
// sector = new byte[2324];
// if(sectorSuffixDdt == null) sectorSuffixDdt = new uint[imageInfo.Sectors];
// sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Mode2Form2NoCrc;
// Array.Copy(data, 24, sector, 0, 2324);
// }
// else Array.Copy(data, 24, sector, 0, 2328);
//
// Array.Copy(data, 16, mode2Subheaders, (int)sectorAddress * 8, 8);
// return WriteSector(sector, sectorAddress);
// }
}
}

View File

@@ -87,7 +87,6 @@
<Compile Include="SCSI\MMC\Hybrid.cs" />
<Compile Include="SCSI\MMC\WriteProtect.cs" />
<Compile Include="SCSI\MMC\DiscInformation.cs" />
<Compile Include="SCSI\Enums.cs" />
<Compile Include="SCSI\Modes\00_SFF.cs" />
<Compile Include="SCSI\Modes\01.cs" />
<Compile Include="SCSI\Modes\01_MMC.cs" />
@@ -168,6 +167,7 @@
<Compile Include="Sega\Dreamcast.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DiscImageChef.CommonTypes\DiscImageChef.CommonTypes.csproj" />
<ProjectReference Include="..\DiscImageChef.Helpers\DiscImageChef.Helpers.csproj">
<Project>{F8BDF57B-1571-4CD0-84B3-B422088D359A}</Project>
<Name>DiscImageChef.Helpers</Name>

View File

@@ -36,7 +36,8 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using DiscImageChef.Decoders.ATA;
using DiscImageChef.CommonTypes.Structs.Devices.ATA;
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
namespace DiscImageChef.Decoders.SCSI
{
@@ -293,31 +294,44 @@ namespace DiscImageChef.Decoders.SCSI
public enum IdentificationAssociation : byte
{
/// <summary>Identifier field is associated with the addressed logical unit</summary>
LogicalUnit = 0, /// <summary>Identifier field is associated with the target port</summary>
TargetPort = 1, /// <summary>Identifier field is associated with the target device that contains the LUN</summary>
LogicalUnit = 0,
/// <summary>Identifier field is associated with the target port</summary>
TargetPort = 1,
/// <summary>Identifier field is associated with the target device that contains the LUN</summary>
TargetDevice = 2
}
public enum IdentificationCodeSet : byte
{
/// <summary>Identifier is binary</summary>
Binary = 1, /// <summary>Identifier is pure ASCII</summary>
ASCII = 2, /// <summary>Identifier is in UTF-8</summary>
Binary = 1,
/// <summary>Identifier is pure ASCII</summary>
ASCII = 2,
/// <summary>Identifier is in UTF-8</summary>
UTF8 = 3
}
public enum IdentificationTypes : byte
{
/// <summary>No assignment authority was used and there is no guarantee the identifier is unique</summary>
NoAuthority = 0, /// <summary>Concatenates vendor and product identifier from INQUIRY plus unit serial number from page 80h</summary>
Inquiry = 1, /// <summary>Identifier is a 64-bit IEEE EUI-64, or extended</summary>
EUI = 2, /// <summary>Identifier is compatible with 64-bit FC-PH Name_Identifier</summary>
NAA = 3, /// <summary>Identifier to relative port in device</summary>
Relative = 4, /// <summary>Identifier to group of target ports in device</summary>
TargetPortGroup = 5, /// <summary>Identifier to group of target LUNs in device</summary>
LogicalUnitGroup = 6, /// <summary>MD5 of device identification values</summary>
MD5 = 7, /// <summary>SCSI name string</summary>
SCSI = 8, /// <summary>Protocol specific port identifier</summary>
NoAuthority = 0,
/// <summary>Concatenates vendor and product identifier from INQUIRY plus unit serial number from page 80h</summary>
Inquiry = 1,
/// <summary>Identifier is a 64-bit IEEE EUI-64, or extended</summary>
EUI = 2,
/// <summary>Identifier is compatible with 64-bit FC-PH Name_Identifier</summary>
NAA = 3,
/// <summary>Identifier to relative port in device</summary>
Relative = 4,
/// <summary>Identifier to group of target ports in device</summary>
TargetPortGroup = 5,
/// <summary>Identifier to group of target LUNs in device</summary>
LogicalUnitGroup = 6,
/// <summary>MD5 of device identification values</summary>
MD5 = 7,
/// <summary>SCSI name string</summary>
SCSI = 8,
/// <summary>Protocol specific port identifier</summary>
ProtocolSpecific = 9
}
@@ -1461,7 +1475,7 @@ namespace DiscImageChef.Decoders.SCSI
if(id != null)
{
sb.AppendLine("\tATA IDENTIFY information follows:");
sb.AppendFormat("{0}", Identify.Prettify(id)).AppendLine();
sb.AppendFormat("{0}", ATA.Identify.Prettify(id)).AppendLine();
}
else
sb.AppendLine("\tCould not decode ATA IDENTIFY information");

View File

@@ -1,150 +0,0 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Enums.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Device structures decoders.
//
// --[ Description ] ----------------------------------------------------------
//
// Contains various SCSI enumerations.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System.Diagnostics.CodeAnalysis;
namespace DiscImageChef.Decoders.SCSI
{
public enum PeripheralQualifiers : byte
{
/// <summary>Peripheral qualifier: Device is connected and supported</summary>
Supported = 0x00, /// <summary>Peripheral qualifier: Device is supported but not connected</summary>
Unconnected = 0x01, /// <summary>Peripheral qualifier: Reserved value</summary>
Reserved = 0x02, /// <summary>Peripheral qualifier: Device is connected but unsupported</summary>
Unsupported = 0x03, /// <summary>Peripheral qualifier: Vendor values: 0x04, 0x05, 0x06 and 0x07</summary>
VendorMask = 0x04
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum PeripheralDeviceTypes : byte
{
/// <summary>Direct-access device</summary>
DirectAccess = 0x00, /// <summary>Sequential-access device</summary>
SequentialAccess = 0x01, /// <summary>Printer device</summary>
PrinterDevice = 0x02, /// <summary>Processor device</summary>
ProcessorDevice = 0x03, /// <summary>Write-once device</summary>
WriteOnceDevice = 0x04, /// <summary>CD-ROM/DVD/etc device</summary>
MultiMediaDevice = 0x05, /// <summary>Scanner device</summary>
ScannerDevice = 0x06, /// <summary>Optical memory device</summary>
OpticalDevice = 0x07, /// <summary>Medium change device</summary>
MediumChangerDevice = 0x08, /// <summary>Communications device</summary>
CommsDevice = 0x09, /// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
PrePressDevice1 = 0x0A, /// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
PrePressDevice2 = 0x0B, /// <summary>Array controller device</summary>
ArrayControllerDevice = 0x0C, /// <summary>Enclosure services device</summary>
EnclosureServiceDevice = 0x0D, /// <summary>Simplified direct-access device</summary>
SimplifiedDevice = 0x0E, /// <summary>Optical card reader/writer device</summary>
OCRWDevice = 0x0F, /// <summary>Bridging Expanders</summary>
BridgingExpander = 0x10, /// <summary>Object-based Storage Device</summary>
ObjectDevice = 0x11, /// <summary>Automation/Drive Interface</summary>
ADCDevice = 0x12, /// <summary>Security Manager Device</summary>
SCSISecurityManagerDevice = 0x13, /// <summary>Host managed zoned block device</summary>
SCSIZonedBlockDevice = 0x14, /// <summary>Well known logical unit</summary>
WellKnownDevice = 0x1E, /// <summary>Unknown or no device type</summary>
UnknownDevice = 0x1F
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ANSIVersions : byte
{
/// <summary>Device does not claim conformance to any ANSI version</summary>
ANSINoVersion = 0x00, /// <summary>Device complies with ANSI X3.131:1986</summary>
ANSI1986Version = 0x01, /// <summary>Device complies with ANSI X3.131:1994</summary>
ANSI1994Version = 0x02, /// <summary>Device complies with ANSI X3.301:1997</summary>
ANSI1997Version = 0x03, /// <summary>Device complies with ANSI X3.351:2001</summary>
ANSI2001Version = 0x04, /// <summary>Device complies with ANSI X3.408:2005.</summary>
ANSI2005Version = 0x05, /// <summary>Device complies with SPC-4</summary>
ANSI2008Version = 0x06
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ECMAVersions : byte
{
/// <summary>Device does not claim conformance to any ECMA version</summary>
ECMANoVersion = 0x00, /// <summary>Device complies with a ECMA-111 standard</summary>
ECMA111 = 0x01
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ISOVersions : byte
{
/// <summary>Device does not claim conformance to any ISO/IEC version</summary>
ISONoVersion = 0x00, /// <summary>Device complies with ISO/IEC 9316:1995</summary>
ISO1995Version = 0x02
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum SPIClocking : byte
{
/// <summary>Supports only ST</summary>
ST = 0x00, /// <summary>Supports only DT</summary>
DT = 0x01, /// <summary>Reserved value</summary>
Reserved = 0x02, /// <summary>Supports ST and DT</summary>
STandDT = 0x03
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum TGPSValues : byte
{
/// <summary>Assymetrical access not supported</summary>
NotSupported = 0x00, /// <summary>Only implicit assymetrical access is supported</summary>
OnlyImplicit = 0x01, /// <summary>Only explicit assymetrical access is supported</summary>
OnlyExplicit = 0x02, /// <summary>Both implicit and explicit assymetrical access are supported</summary>
Both = 0x03
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ProtocolIdentifiers : byte
{
/// <summary>Fibre Channel</summary>
FibreChannel = 0, /// <summary>Parallel SCSI</summary>
SCSI = 1, /// <summary>SSA</summary>
SSA = 2, /// <summary>IEEE-1394</summary>
Firewire = 3, /// <summary>SCSI Remote Direct Memory Access Protocol</summary>
RDMAP = 4, /// <summary>Internet SCSI</summary>
iSCSI = 5, /// <summary>Serial SCSI</summary>
SAS = 6, /// <summary>Automation/Drive Interface Transport Protocol</summary>
ADT = 7, /// <summary>AT Attachment Interface (ATA/ATAPI)</summary>
ATA = 8, /// <summary>USB Attached SCSI</summary>
UAS = 9, /// <summary>SCSI over PCI Express</summary>
SCSIe = 10, /// <summary>PCI Express</summary>
PCIe = 11, /// <summary>No specific protocol</summary>
NoProtocol = 15
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ScsiDefinitions : byte
{
Current = 0, SCSI1 = 1, CCS = 2,
SCSI2 = 3, SCSI3 = 4
}
}

View File

@@ -34,7 +34,7 @@ using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using DiscImageChef.Console;
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
namespace DiscImageChef.Decoders.SCSI
{
@@ -46,707 +46,12 @@ namespace DiscImageChef.Decoders.SCSI
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static class Inquiry
{
#region Public structures
// SCSI INQUIRY command response
public struct SCSIInquiry
{
/// <summary>Peripheral qualifier Byte 0, bits 7 to 5</summary>
public byte PeripheralQualifier;
/// <summary>Peripheral device type Byte 0, bits 4 to 0</summary>
public byte PeripheralDeviceType;
/// <summary>Removable device Byte 1, bit 7</summary>
public bool RMB;
/// <summary>SCSI-1 vendor-specific qualification codes Byte 1, bits 6 to 0</summary>
public byte DeviceTypeModifier;
/// <summary>ISO/IEC SCSI Standard Version Byte 2, bits 7 to 6, mask = 0xC0, >> 6</summary>
public byte ISOVersion;
/// <summary>ECMA SCSI Standard Version Byte 2, bits 5 to 3, mask = 0x38, >> 3</summary>
public byte ECMAVersion;
/// <summary>ANSI SCSI Standard Version Byte 2, bits 2 to 0, mask = 0x07</summary>
public byte ANSIVersion;
/// <summary>Asynchronous Event Reporting Capability supported Byte 3, bit 7</summary>
public bool AERC;
/// <summary>Device supports TERMINATE TASK command Byte 3, bit 6</summary>
public bool TrmTsk;
/// <summary>Supports setting Normal ACA Byte 3, bit 5</summary>
public bool NormACA;
/// <summary>Supports LUN hierarchical addressing Byte 3, bit 4</summary>
public bool HiSup;
/// <summary>Responde data format Byte 3, bit 3 to 0</summary>
public byte ResponseDataFormat;
/// <summary>Lenght of total INQUIRY response minus 4 Byte 4</summary>
public byte AdditionalLength;
/// <summary>Device contains an embedded storage array controller Byte 5, bit 7</summary>
public bool SCCS;
/// <summary>Device contains an Access Control Coordinator Byte 5, bit 6</summary>
public bool ACC;
/// <summary>Supports asymetrical logical unit access Byte 5, bits 5 to 4</summary>
public byte TPGS;
/// <summary>Supports third-party copy commands Byte 5, bit 3</summary>
public bool ThreePC;
/// <summary>Reserved Byte 5, bits 2 to 1</summary>
public byte Reserved2;
/// <summary>Supports protection information Byte 5, bit 0</summary>
public bool Protect;
/// <summary>Supports basic queueing Byte 6, bit 7</summary>
public bool BQue;
/// <summary>Device contains an embedded enclosure services component Byte 6, bit 6</summary>
public bool EncServ;
/// <summary>Vendor-specific Byte 6, bit 5</summary>
public bool VS1;
/// <summary>Multi-port device Byte 6, bit 4</summary>
public bool MultiP;
/// <summary>Device contains or is attached to a medium changer Byte 6, bit 3</summary>
public bool MChngr;
/// <summary>Device supports request and acknowledge handshakes Byte 6, bit 2</summary>
public bool ACKREQQ;
/// <summary>Supports 32-bit wide SCSI addresses Byte 6, bit 1</summary>
public bool Addr32;
/// <summary>Supports 16-bit wide SCSI addresses Byte 6, bit 0</summary>
public bool Addr16;
/// <summary>Device supports relative addressing Byte 7, bit 7</summary>
public bool RelAddr;
/// <summary>Supports 32-bit wide data transfers Byte 7, bit 6</summary>
public bool WBus32;
/// <summary>Supports 16-bit wide data transfers Byte 7, bit 5</summary>
public bool WBus16;
/// <summary>Supports synchronous data transfer Byte 7, bit 4</summary>
public bool Sync;
/// <summary>Supports linked commands Byte 7, bit 3</summary>
public bool Linked;
/// <summary>Supports CONTINUE TASK and TARGET TRANSFER DISABLE commands Byte 7, bit 2</summary>
public bool TranDis;
/// <summary>Supports TCQ queue Byte 7, bit 1</summary>
public bool CmdQue;
/// <summary>Indicates that the devices responds to RESET with soft reset Byte 7, bit 0</summary>
public bool SftRe;
/// <summary>Vendor identification Bytes 8 to 15</summary>
public byte[] VendorIdentification;
/// <summary>Product identification Bytes 16 to 31</summary>
public byte[] ProductIdentification;
/// <summary>Product revision level Bytes 32 to 35</summary>
public byte[] ProductRevisionLevel;
/// <summary>Vendor-specific data Bytes 36 to 55</summary>
public byte[] VendorSpecific;
/// <summary>Byte 56, bits 7 to 4</summary>
public byte Reserved3;
/// <summary>Supported SPI clocking Byte 56, bits 3 to 2</summary>
public byte Clocking;
/// <summary>Device supports Quick Arbitration and Selection Byte 56, bit 1</summary>
public bool QAS;
/// <summary>Supports information unit transfers Byte 56, bit 0</summary>
public bool IUS;
/// <summary>Reserved Byte 57</summary>
public byte Reserved4;
/// <summary>Array of version descriptors Bytes 58 to 73</summary>
public ushort[] VersionDescriptors;
/// <summary>Reserved Bytes 74 to 95</summary>
public byte[] Reserved5;
/// <summary>Reserved Bytes 96 to end</summary>
public byte[] VendorSpecific2;
// Per DLT4000/DLT4500/DLT4700 Cartridge Tape Subsystem Product Manual
#region Quantum vendor unique inquiry data structure
/// <summary>Means that the INQUIRY response contains 56 bytes or more, so this data has been filled</summary>
public bool QuantumPresent;
/// <summary>The product family. Byte 36, bits 7 to 5</summary>
public byte Qt_ProductFamily;
/// <summary>The released firmware. Byte 36, bits 4 to 0</summary>
public byte Qt_ReleasedFirmware;
/// <summary>The firmware major version. Byte 37</summary>
public byte Qt_FirmwareMajorVersion;
/// <summary>The firmware minor version. Byte 38</summary>
public byte Qt_FirmwareMinorVersion;
/// <summary>The EEPROM format major version. Byte 39</summary>
public byte Qt_EEPROMFormatMajorVersion;
/// <summary>The EEPROM format minor version. Byte 40</summary>
public byte Qt_EEPROMFormatMinorVersion;
/// <summary>The firmware personality. Byte 41</summary>
public byte Qt_FirmwarePersonality;
/// <summary>The firmware sub personality. Byte 42</summary>
public byte Qt_FirmwareSubPersonality;
/// <summary>The tape directory format version. Byte 43</summary>
public byte Qt_TapeDirectoryFormatVersion;
/// <summary>The controller hardware version. Byte 44</summary>
public byte Qt_ControllerHardwareVersion;
/// <summary>The drive EEPROM version. Byte 45</summary>
public byte Qt_DriveEEPROMVersion;
/// <summary>The drive hardware version. Byte 46</summary>
public byte Qt_DriveHardwareVersion;
/// <summary>The media loader firmware version. Byte 47</summary>
public byte Qt_MediaLoaderFirmwareVersion;
/// <summary>The media loader hardware version. Byte 48</summary>
public byte Qt_MediaLoaderHardwareVersion;
/// <summary>The media loader mechanical version. Byte 49</summary>
public byte Qt_MediaLoaderMechanicalVersion;
/// <summary>Is a media loader present? Byte 50</summary>
public bool Qt_MediaLoaderPresent;
/// <summary>Is a library present? Byte 51</summary>
public bool Qt_LibraryPresent;
/// <summary>The module revision. Bytes 52 to 55</summary>
public byte[] Qt_ModuleRevision;
#endregion Quantum vendor unique inquiry data structure
#region IBM vendor unique inquiry data structure
/// <summary>Means that the INQUIRY response contains 56 bytes or more, so this data has been filled</summary>
public bool IBMPresent;
/// <summary>Drive is not capable of automation Byte 36 bit 0</summary>
public bool IBM_AutDis;
/// <summary>If not zero, limit in MB/s = Max * (this / 256) Byte 37</summary>
public byte IBM_PerformanceLimit;
/// <summary>Byte 41</summary>
public byte IBM_OEMSpecific;
#endregion IBM vendor unique inquiry data structure
#region HP vendor unique inquiry data structure
/// <summary>Means that the INQUIRY response contains 49 bytes or more, so this data has been filled</summary>
public bool HPPresent;
/// <summary>WORM version Byte 40 bits 7 to 1</summary>
public byte HP_WORMVersion;
/// <summary>WORM supported Byte 40 bit 0</summary>
public bool HP_WORM;
/// <summary>Bytes 43 to 48</summary>
public byte[] HP_OBDR;
#endregion HP vendor unique inquiry data structure
#region Seagate vendor unique inquiry data structure
/// <summary>Means that bytes 36 to 43 are filled</summary>
public bool SeagatePresent;
/// <summary>Drive Serial Number Bytes 36 to 43</summary>
public byte[] Seagate_DriveSerialNumber;
/// <summary>Means that bytes 96 to 143 are filled</summary>
public bool Seagate2Present;
/// <summary>Contains Seagate copyright notice Bytes 96 to 143</summary>
public byte[] Seagate_Copyright;
/// <summary>Means that bytes 144 to 147 are filled</summary>
public bool Seagate3Present;
/// <summary>Reserved Seagate field Bytes 144 to 147</summary>
public byte[] Seagate_ServoPROMPartNo;
#endregion Seagate vendor unique inquiry data structure
#region Kreon vendor unique inquiry data structure
/// <summary>Means that firmware is Kreon</summary>
public bool KreonPresent;
/// <summary>Kreon identifier Bytes 36 to 40</summary>
public byte[] KreonIdentifier;
/// <summary>Kreon just a 0x20 Bytes 41</summary>
public byte KreonSpace;
/// <summary>Kreon version string Bytes 42 to 46</summary>
public byte[] KreonVersion;
#endregion Kreon vendor unique inquiry data structure
}
#endregion Public structures
#region Public methods
public static SCSIInquiry? Decode(byte[] SCSIInquiryResponse)
public static string Prettify(CommonTypes.Structs.Devices.SCSI.Inquiry? SCSIInquiryResponse)
{
if(SCSIInquiryResponse == null)
return null;
if(SCSIInquiryResponse.Length < 36 &&
SCSIInquiryResponse.Length != 5)
{
DicConsole.DebugWriteLine("SCSI INQUIRY decoder",
"INQUIRY response is {0} bytes, less than minimum of 36 bytes, decoded data can be incorrect, not decoding.",
SCSIInquiryResponse.Length);
return null;
}
if(SCSIInquiryResponse.Length < SCSIInquiryResponse[4] + 4 &&
SCSIInquiryResponse.Length != SCSIInquiryResponse[4])
{
DicConsole.DebugWriteLine("SCSI INQUIRY decoder",
"INQUIRY response length ({0} bytes) is different than specified in length field ({1} bytes), decoded data can be incorrect, not decoding.",
SCSIInquiryResponse.Length, SCSIInquiryResponse[4] + 4);
return null;
}
var decoded = new SCSIInquiry();
if(SCSIInquiryResponse.Length >= 1)
{
decoded.PeripheralQualifier = (byte)((SCSIInquiryResponse[0] & 0xE0) >> 5);
decoded.PeripheralDeviceType = (byte)(SCSIInquiryResponse[0] & 0x1F);
}
if(SCSIInquiryResponse.Length >= 2)
{
decoded.RMB = Convert.ToBoolean(SCSIInquiryResponse[1] & 0x80);
decoded.DeviceTypeModifier = (byte)(SCSIInquiryResponse[1] & 0x7F);
}
if(SCSIInquiryResponse.Length >= 3)
{
decoded.ISOVersion = (byte)((SCSIInquiryResponse[2] & 0xC0) >> 6);
decoded.ECMAVersion = (byte)((SCSIInquiryResponse[2] & 0x38) >> 3);
decoded.ANSIVersion = (byte)(SCSIInquiryResponse[2] & 0x07);
}
if(SCSIInquiryResponse.Length >= 4)
{
decoded.AERC = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x80);
decoded.TrmTsk = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x40);
decoded.NormACA = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x20);
decoded.HiSup = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x10);
decoded.ResponseDataFormat = (byte)(SCSIInquiryResponse[3] & 0x07);
}
if(SCSIInquiryResponse.Length >= 5)
decoded.AdditionalLength = SCSIInquiryResponse[4];
if(SCSIInquiryResponse.Length >= 6)
{
decoded.SCCS = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x80);
decoded.ACC = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x40);
decoded.TPGS = (byte)((SCSIInquiryResponse[5] & 0x30) >> 4);
decoded.ThreePC = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x08);
decoded.Reserved2 = (byte)((SCSIInquiryResponse[5] & 0x06) >> 1);
decoded.Protect = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x01);
}
if(SCSIInquiryResponse.Length >= 7)
{
decoded.BQue = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x80);
decoded.EncServ = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x40);
decoded.VS1 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x20);
decoded.MultiP = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x10);
decoded.MChngr = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x08);
decoded.ACKREQQ = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x04);
decoded.Addr32 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x02);
decoded.Addr16 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x01);
}
if(SCSIInquiryResponse.Length >= 8)
{
decoded.RelAddr = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x80);
decoded.WBus32 = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x40);
decoded.WBus16 = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x20);
decoded.Sync = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x10);
decoded.Linked = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x08);
decoded.TranDis = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x04);
decoded.CmdQue = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x02);
decoded.SftRe = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x01);
}
if(SCSIInquiryResponse.Length >= 16)
{
decoded.VendorIdentification = new byte[8];
Array.Copy(SCSIInquiryResponse, 8, decoded.VendorIdentification, 0, 8);
}
if(SCSIInquiryResponse.Length >= 32)
{
decoded.ProductIdentification = new byte[16];
Array.Copy(SCSIInquiryResponse, 16, decoded.ProductIdentification, 0, 16);
}
if(SCSIInquiryResponse.Length >= 36)
{
decoded.ProductRevisionLevel = new byte[4];
Array.Copy(SCSIInquiryResponse, 32, decoded.ProductRevisionLevel, 0, 4);
}
if(SCSIInquiryResponse.Length >= 44)
{
// Seagate 1
decoded.SeagatePresent = true;
decoded.Seagate_DriveSerialNumber = new byte[8];
Array.Copy(SCSIInquiryResponse, 36, decoded.Seagate_DriveSerialNumber, 0, 8);
}
if(SCSIInquiryResponse.Length >= 46)
{
// Kreon
decoded.KreonIdentifier = new byte[5];
Array.Copy(SCSIInquiryResponse, 36, decoded.KreonIdentifier, 0, 5);
decoded.KreonSpace = SCSIInquiryResponse[41];
decoded.KreonVersion = new byte[5];
Array.Copy(SCSIInquiryResponse, 42, decoded.KreonVersion, 0, 5);
if(decoded.KreonSpace == 0x20 &&
decoded.KreonIdentifier.SequenceEqual(new byte[]
{
0x4B, 0x52, 0x45, 0x4F, 0x4E
}))
decoded.KreonPresent = true;
}
if(SCSIInquiryResponse.Length >= 49)
{
// HP
decoded.HPPresent = true;
decoded.HP_WORM |= (SCSIInquiryResponse[40] & 0x01) == 0x01;
decoded.HP_WORMVersion = (byte)((SCSIInquiryResponse[40] & 0x7F) >> 1);
decoded.HP_OBDR = new byte[6];
Array.Copy(SCSIInquiryResponse, 43, decoded.HP_OBDR, 0, 6);
}
if(SCSIInquiryResponse.Length >= 56)
{
decoded.VendorSpecific = new byte[20];
Array.Copy(SCSIInquiryResponse, 36, decoded.VendorSpecific, 0, 20);
// Quantum
decoded.QuantumPresent = true;
decoded.Qt_ProductFamily = (byte)((SCSIInquiryResponse[36] & 0xF0) >> 4);
decoded.Qt_ReleasedFirmware = (byte)(SCSIInquiryResponse[36] & 0x0F);
decoded.Qt_FirmwareMajorVersion = SCSIInquiryResponse[37];
decoded.Qt_FirmwareMinorVersion = SCSIInquiryResponse[38];
decoded.Qt_EEPROMFormatMajorVersion = SCSIInquiryResponse[39];
decoded.Qt_EEPROMFormatMinorVersion = SCSIInquiryResponse[40];
decoded.Qt_FirmwarePersonality = SCSIInquiryResponse[41];
decoded.Qt_FirmwareSubPersonality = SCSIInquiryResponse[42];
decoded.Qt_TapeDirectoryFormatVersion = SCSIInquiryResponse[43];
decoded.Qt_ControllerHardwareVersion = SCSIInquiryResponse[44];
decoded.Qt_DriveEEPROMVersion = SCSIInquiryResponse[45];
decoded.Qt_DriveHardwareVersion = SCSIInquiryResponse[46];
decoded.Qt_MediaLoaderFirmwareVersion = SCSIInquiryResponse[47];
decoded.Qt_MediaLoaderHardwareVersion = SCSIInquiryResponse[48];
decoded.Qt_MediaLoaderMechanicalVersion = SCSIInquiryResponse[49];
decoded.Qt_MediaLoaderPresent = SCSIInquiryResponse[50] > 0;
decoded.Qt_LibraryPresent = SCSIInquiryResponse[51] > 0;
decoded.Qt_ModuleRevision = new byte[4];
Array.Copy(SCSIInquiryResponse, 52, decoded.Qt_ModuleRevision, 0, 4);
// IBM
decoded.IBMPresent = true;
decoded.IBM_AutDis |= (SCSIInquiryResponse[36] & 0x01) == 0x01;
decoded.IBM_PerformanceLimit = SCSIInquiryResponse[37];
decoded.IBM_OEMSpecific = SCSIInquiryResponse[41];
}
if(SCSIInquiryResponse.Length >= 57)
{
decoded.Reserved3 = (byte)((SCSIInquiryResponse[56] & 0xF0) >> 4);
decoded.Clocking = (byte)((SCSIInquiryResponse[56] & 0x0C) >> 2);
decoded.QAS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x02);
decoded.IUS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x01);
}
if(SCSIInquiryResponse.Length >= 58)
decoded.Reserved4 = SCSIInquiryResponse[57];
if(SCSIInquiryResponse.Length >= 60)
{
int descriptorsNo;
if(SCSIInquiryResponse.Length >= 74)
descriptorsNo = 8;
else
descriptorsNo = (SCSIInquiryResponse.Length - 58) / 2;
decoded.VersionDescriptors = new ushort[descriptorsNo];
for(int i = 0; i < descriptorsNo; i++)
decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + i * 2);
}
if(SCSIInquiryResponse.Length >= 75 &&
SCSIInquiryResponse.Length < 96)
{
decoded.Reserved5 = new byte[SCSIInquiryResponse.Length - 74];
Array.Copy(SCSIInquiryResponse, 74, decoded.Reserved5, 0, SCSIInquiryResponse.Length - 74);
}
if(SCSIInquiryResponse.Length >= 96)
{
decoded.Reserved5 = new byte[22];
Array.Copy(SCSIInquiryResponse, 74, decoded.Reserved5, 0, 22);
}
if(SCSIInquiryResponse.Length > 96)
{
decoded.VendorSpecific2 = new byte[SCSIInquiryResponse.Length - 96];
Array.Copy(SCSIInquiryResponse, 96, decoded.VendorSpecific2, 0, SCSIInquiryResponse.Length - 96);
}
if(SCSIInquiryResponse.Length >= 144)
{
// Seagate 2
decoded.Seagate2Present = true;
decoded.Seagate_Copyright = new byte[48];
Array.Copy(SCSIInquiryResponse, 96, decoded.Seagate_Copyright, 0, 48);
}
if(SCSIInquiryResponse.Length < 148)
return decoded;
// Seagate 2
decoded.Seagate3Present = true;
decoded.Seagate_ServoPROMPartNo = new byte[4];
Array.Copy(SCSIInquiryResponse, 144, decoded.Seagate_ServoPROMPartNo, 0, 4);
return decoded;
}
public static byte[] Encode(SCSIInquiry? inq)
{
if(inq is null)
return null;
SCSIInquiry decoded = inq.Value;
byte[] buffer = new byte[512];
byte length = 0;
buffer[0] = (byte)(decoded.PeripheralQualifier << 5);
buffer[0] += decoded.PeripheralDeviceType;
if(decoded.RMB)
buffer[1] = 0x80;
buffer[1] += decoded.DeviceTypeModifier;
buffer[2] = (byte)(decoded.ISOVersion << 6);
buffer[2] += (byte)(decoded.ECMAVersion << 3);
buffer[2] += decoded.ANSIVersion;
if(decoded.AERC)
buffer[3] = 0x80;
if(decoded.TrmTsk)
buffer[3] += 0x40;
if(decoded.NormACA)
buffer[3] += 0x20;
if(decoded.HiSup)
buffer[3] += 0x10;
buffer[3] += decoded.ResponseDataFormat;
if(decoded.AdditionalLength > 0)
{
length = 5;
buffer[4] = decoded.AdditionalLength;
}
if(decoded.SCCS ||
decoded.ACC ||
decoded.TPGS > 0 ||
decoded.ThreePC ||
decoded.Reserved2 > 0 ||
decoded.Protect)
{
length = 6;
if(decoded.SCCS)
buffer[5] = 0x80;
if(decoded.ACC)
buffer[5] += 0x40;
buffer[5] += (byte)(decoded.TPGS << 4);
if(decoded.ThreePC)
buffer[5] += 0x08;
buffer[5] += (byte)(decoded.Reserved2 << 1);
if(decoded.Protect)
buffer[5] += 0x01;
}
if(decoded.BQue ||
decoded.EncServ ||
decoded.VS1 ||
decoded.MultiP ||
decoded.MChngr ||
decoded.ACKREQQ ||
decoded.Addr32 ||
decoded.Addr16)
{
length = 7;
if(decoded.BQue)
buffer[6] = 0x80;
if(decoded.EncServ)
buffer[6] += 0x40;
if(decoded.VS1)
buffer[6] += 0x20;
if(decoded.MultiP)
buffer[6] += 0x10;
if(decoded.MChngr)
buffer[6] += 0x08;
if(decoded.ACKREQQ)
buffer[6] += 0x04;
if(decoded.Addr32)
buffer[6] += 0x02;
if(decoded.Addr16)
buffer[6] += 0x01;
}
if(decoded.RelAddr ||
decoded.WBus32 ||
decoded.WBus16 ||
decoded.Sync ||
decoded.Linked ||
decoded.TranDis ||
decoded.CmdQue ||
decoded.SftRe)
{
length = 8;
if(decoded.RelAddr)
buffer[7] = 0x80;
if(decoded.WBus32)
buffer[7] += 0x40;
if(decoded.WBus16)
buffer[7] += 0x20;
if(decoded.Sync)
buffer[7] += 0x10;
if(decoded.Linked)
buffer[7] += 0x08;
if(decoded.TranDis)
buffer[7] += 0x04;
if(decoded.CmdQue)
buffer[7] += 0x02;
if(decoded.SftRe)
buffer[7] += 0x01;
}
if(decoded.VendorIdentification != null)
{
length = 16;
Array.Copy(decoded.VendorIdentification, 0, buffer, 8,
decoded.VendorIdentification.Length >= 8 ? 8 : decoded.VendorIdentification.Length);
}
if(decoded.ProductIdentification != null)
{
length = 32;
Array.Copy(decoded.ProductIdentification, 0, buffer, 16,
decoded.ProductIdentification.Length >= 16 ? 16 : decoded.ProductIdentification.Length);
}
if(decoded.ProductRevisionLevel != null)
{
length = 36;
Array.Copy(decoded.ProductRevisionLevel, 0, buffer, 32,
decoded.ProductRevisionLevel.Length >= 4 ? 4 : decoded.ProductRevisionLevel.Length);
}
if(decoded.Seagate_DriveSerialNumber != null)
{
length = 44;
Array.Copy(decoded.Seagate_DriveSerialNumber, 0, buffer, 36, 8);
}
if(decoded.KreonIdentifier != null &&
decoded.KreonVersion != null)
{
length = 46;
Array.Copy(decoded.KreonIdentifier, 0, buffer, 36, 5);
buffer[41] = decoded.KreonSpace;
Array.Copy(decoded.KreonVersion, 0, buffer, 42, 5);
}
if(decoded.HP_WORM ||
decoded.HP_WORMVersion > 0 ||
decoded.HP_OBDR != null)
{
length = 49;
if(decoded.HP_WORM)
buffer[40] = 0x01;
buffer[40] += (byte)(decoded.HP_WORMVersion << 1);
Array.Copy(decoded.HP_OBDR, 0, buffer, 43, 6);
}
if(decoded.VendorSpecific != null)
{
length = 56;
Array.Copy(decoded.VendorSpecific, 0, buffer, 36, 20);
}
if(decoded.Reserved3 > 0 ||
decoded.Clocking > 0 ||
decoded.QAS ||
decoded.IUS)
{
length = 57;
buffer[56] = (byte)(decoded.Reserved3 << 4);
buffer[56] += (byte)(decoded.Clocking << 2);
if(decoded.QAS)
buffer[56] += 0x02;
if(decoded.IUS)
buffer[56] += 0x01;
}
if(decoded.Reserved4 != 0)
{
length = 58;
buffer[57] = decoded.Reserved4;
}
if(decoded.VersionDescriptors != null)
{
length = (byte)(58 + decoded.VersionDescriptors.Length * 2);
for(int i = 0; i < decoded.VersionDescriptors.Length; i++)
Array.Copy(BitConverter.GetBytes(decoded.VersionDescriptors[i]), 0, buffer, 56 + i * 2, 2);
}
if(decoded.Reserved5 != null)
{
length = (byte)(74 + decoded.Reserved5.Length);
Array.Copy(decoded.Reserved5, 0, buffer, 74, decoded.Reserved5.Length);
}
if(decoded.VendorSpecific2 != null)
{
length = (byte)(96 + decoded.VendorSpecific2.Length);
Array.Copy(decoded.VendorSpecific2, 0, buffer, 96, decoded.VendorSpecific2.Length);
}
if(decoded.Seagate_Copyright != null)
{
length = 144;
Array.Copy(decoded.Seagate_Copyright, 0, buffer, 96, 48);
}
if(decoded.Seagate_ServoPROMPartNo != null)
{
length = 148;
Array.Copy(decoded.Seagate_ServoPROMPartNo, 0, buffer, 144, 4);
}
buffer[4] = length;
byte[] dest = new byte[length];
Array.Copy(buffer, 0, dest, 0, length);
return dest;
}
public static string Prettify(SCSIInquiry? SCSIInquiryResponse)
{
if(SCSIInquiryResponse == null)
return null;
SCSIInquiry response = SCSIInquiryResponse.Value;
CommonTypes.Structs.Devices.SCSI.Inquiry response = SCSIInquiryResponse.Value;
var sb = new StringBuilder();
@@ -3156,10 +2461,10 @@ namespace DiscImageChef.Decoders.SCSI
public static string Prettify(byte[] SCSIInquiryResponse)
{
SCSIInquiry? decoded = Decode(SCSIInquiryResponse);
CommonTypes.Structs.Devices.SCSI.Inquiry? decoded =
CommonTypes.Structs.Devices.SCSI.Inquiry.Decode(SCSIInquiryResponse);
return Prettify(decoded);
}
#endregion Public methods
}
}

View File

@@ -34,6 +34,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
// ReSharper disable MemberCanBePrivate.Global
@@ -44,64 +45,122 @@ namespace DiscImageChef.Decoders.SCSI.MMC
public enum FeatureNumber : ushort
{
/// <summary>Lists all profiles</summary>
ProfileList = 0x0000, /// <summary>Mandatory behaviour</summary>
Core = 0x0001, /// <summary>Operational changes</summary>
Morphing = 0x0002, /// <summary>Removable medium</summary>
Removable = 0x0003, /// <summary>Ability to control write protection status</summary>
WriteProtect = 0x0004, /// <summary>Ability to read sectors with random addressing</summary>
RandomRead = 0x0010, /// <summary>Reads on OSTA Multi-Read</summary>
MultiRead = 0x001D, /// <summary>Able to read CD structures</summary>
CDRead = 0x001E, /// <summary>Able to read DVD structures</summary>
DVDRead = 0x001F, /// <summary>Ability to write sectors with random addressing</summary>
RandomWrite = 0x0020, /// <summary>Ability to sequentially write</summary>
IncrementalWrite = 0x0021, /// <summary>Support for media that requires erase before write</summary>
SectorErasable = 0x0022, /// <summary>Supports formatting media</summary>
Formattable = 0x0023, /// <summary>Ability to provide defect-free space</summary>
HardwareDefectMgmt = 0x0024, /// <summary>Supports for write-once media in random order</summary>
WriteOnce = 0x0025, /// <summary>Supports for media that shall be written from blocking boundaries</summary>
RestrictedOverwrite = 0x0026, /// <summary>Supports high speed CD-RW</summary>
CDRWCAV = 0x0027, /// <summary>Read and optionally write MRW</summary>
MRW = 0x0028, /// <summary>Ability to control RECOVERED ERROR reporting</summary>
EnDefectReport = 0x0029, /// <summary>Ability to recognize, read and optionally write DVD+RW</summary>
DVDRWPlus = 0x002A, /// <summary>Ability to read DVD+R</summary>
DVDRPlus = 0x002B, RigidOverWrite = 0x002C, /// <summary>Ability to write CD in Track-at-Once</summary>
CDTAO = 0x002D, /// <summary>Ability to write CD in Session-at-Once or RAW</summary>
CDMastering = 0x002E, /// <summary>Ability to write DVD structures</summary>
DVDRWrite = 0x002F, /// <summary>Ability to read DDCD</summary>
DDCD = 0x0030, /// <summary>Ability to write DDCD-R</summary>
DDCDR = 0x0031, /// <summary>Ability to write DDCD-RW</summary>
DDCDRW = 0x0032, /// <summary>Ability to record in layer jump mode</summary>
LayerJump = 0x0033, /// <summary>Ability to perform Layer Jump recording on Rigid Restricted Overwrite</summary>
LJRigid = 0x0034, /// <summary>Ability to stop the long immediate operation</summary>
StopLong = 0x0035, /// <summary>Ability to report CD-RW media sub-types supported for write</summary>
CDRWMediaWrite = 0x0037, /// <summary>Logical block overwrite service on BD-R formatted as SRM+POW</summary>
BDRPOW = 0x0038, /// <summary>Ability to read DVD+RW DL</summary>
DVDRWDLPlus = 0x003A, /// <summary>Ability to read DVD+R DL</summary>
DVDRDLPlus = 0x003B, /// <summary>Ability to read BD discs</summary>
BDRead = 0x0040, /// <summary>Ability to write BD discs</summary>
BDWrite = 0x0041, /// <summary>Timely, Safe Recording</summary>
TSR = 0x0042, /// <summary>Ability to read HD DVD</summary>
HDDVDRead = 0x0050, /// <summary>Ability to write HD DVD</summary>
HDDVDWrite = 0x0051, /// <summary>Ability to write HD DVD-RW fragmented</summary>
HDDVDRWFragment = 0x0052, /// <summary>Supports some Hybrid Discs</summary>
Hybrid = 0x0080, /// <summary>Host and device directed power management</summary>
PowerMgmt = 0x0100, /// <summary>Supports S.M.A.R.T.</summary>
SMART = 0x0101, /// <summary>Single machanism multiple disc changer</summary>
Changer = 0x0102, /// <summary>Ability to play CD audio to an analogue output</summary>
CDAudioExt = 0x0103, /// <summary>Ability to accept new microcode</summary>
MicrocodeUpgrade = 0x0104, /// <summary>Ability to respond to all commands within a specific time</summary>
Timeout = 0x0105, /// <summary>Supports DVD CSS/CPPM</summary>
CSS = 0x0106, /// <summary>Ability to read and write using host requested performance parameters</summary>
RTS = 0x0107, /// <summary>Drive has a unique identifier</summary>
DriveSerial = 0x0108, /// <summary>Ability to return unique Media Serial Number</summary>
MediaSerial = 0x0109, /// <summary>Ability to read and/or write DCBs</summary>
DCBs = 0x010A, /// <summary>Supports DVD CPRM</summary>
CPRM = 0x010B, /// <summary>Firmware creation date report</summary>
FirmwareInfo = 0x010C, /// <summary>Ability to decode and optionally encode AACS</summary>
AACS = 0x010D, /// <summary>Ability to perform DVD CSS managed recording</summary>
CSSManagedRec = 0x010E, /// <summary>Ability to decode and optionally encode VCPS</summary>
VCPS = 0x0110, /// <summary>Supports SecurDisc</summary>
SecurDisc = 0x0113, /// <summary>TCG Optical Security Subsystem Class</summary>
ProfileList = 0x0000,
/// <summary>Mandatory behaviour</summary>
Core = 0x0001,
/// <summary>Operational changes</summary>
Morphing = 0x0002,
/// <summary>Removable medium</summary>
Removable = 0x0003,
/// <summary>Ability to control write protection status</summary>
WriteProtect = 0x0004,
/// <summary>Ability to read sectors with random addressing</summary>
RandomRead = 0x0010,
/// <summary>Reads on OSTA Multi-Read</summary>
MultiRead = 0x001D,
/// <summary>Able to read CD structures</summary>
CDRead = 0x001E,
/// <summary>Able to read DVD structures</summary>
DVDRead = 0x001F,
/// <summary>Ability to write sectors with random addressing</summary>
RandomWrite = 0x0020,
/// <summary>Ability to sequentially write</summary>
IncrementalWrite = 0x0021,
/// <summary>Support for media that requires erase before write</summary>
SectorErasable = 0x0022,
/// <summary>Supports formatting media</summary>
Formattable = 0x0023,
/// <summary>Ability to provide defect-free space</summary>
HardwareDefectMgmt = 0x0024,
/// <summary>Supports for write-once media in random order</summary>
WriteOnce = 0x0025,
/// <summary>Supports for media that shall be written from blocking boundaries</summary>
RestrictedOverwrite = 0x0026,
/// <summary>Supports high speed CD-RW</summary>
CDRWCAV = 0x0027,
/// <summary>Read and optionally write MRW</summary>
MRW = 0x0028,
/// <summary>Ability to control RECOVERED ERROR reporting</summary>
EnDefectReport = 0x0029,
/// <summary>Ability to recognize, read and optionally write DVD+RW</summary>
DVDRWPlus = 0x002A,
/// <summary>Ability to read DVD+R</summary>
DVDRPlus = 0x002B, RigidOverWrite = 0x002C,
/// <summary>Ability to write CD in Track-at-Once</summary>
CDTAO = 0x002D,
/// <summary>Ability to write CD in Session-at-Once or RAW</summary>
CDMastering = 0x002E,
/// <summary>Ability to write DVD structures</summary>
DVDRWrite = 0x002F,
/// <summary>Ability to read DDCD</summary>
DDCD = 0x0030,
/// <summary>Ability to write DDCD-R</summary>
DDCDR = 0x0031,
/// <summary>Ability to write DDCD-RW</summary>
DDCDRW = 0x0032,
/// <summary>Ability to record in layer jump mode</summary>
LayerJump = 0x0033,
/// <summary>Ability to perform Layer Jump recording on Rigid Restricted Overwrite</summary>
LJRigid = 0x0034,
/// <summary>Ability to stop the long immediate operation</summary>
StopLong = 0x0035,
/// <summary>Ability to report CD-RW media sub-types supported for write</summary>
CDRWMediaWrite = 0x0037,
/// <summary>Logical block overwrite service on BD-R formatted as SRM+POW</summary>
BDRPOW = 0x0038,
/// <summary>Ability to read DVD+RW DL</summary>
DVDRWDLPlus = 0x003A,
/// <summary>Ability to read DVD+R DL</summary>
DVDRDLPlus = 0x003B,
/// <summary>Ability to read BD discs</summary>
BDRead = 0x0040,
/// <summary>Ability to write BD discs</summary>
BDWrite = 0x0041,
/// <summary>Timely, Safe Recording</summary>
TSR = 0x0042,
/// <summary>Ability to read HD DVD</summary>
HDDVDRead = 0x0050,
/// <summary>Ability to write HD DVD</summary>
HDDVDWrite = 0x0051,
/// <summary>Ability to write HD DVD-RW fragmented</summary>
HDDVDRWFragment = 0x0052,
/// <summary>Supports some Hybrid Discs</summary>
Hybrid = 0x0080,
/// <summary>Host and device directed power management</summary>
PowerMgmt = 0x0100,
/// <summary>Supports S.M.A.R.T.</summary>
SMART = 0x0101,
/// <summary>Single machanism multiple disc changer</summary>
Changer = 0x0102,
/// <summary>Ability to play CD audio to an analogue output</summary>
CDAudioExt = 0x0103,
/// <summary>Ability to accept new microcode</summary>
MicrocodeUpgrade = 0x0104,
/// <summary>Ability to respond to all commands within a specific time</summary>
Timeout = 0x0105,
/// <summary>Supports DVD CSS/CPPM</summary>
CSS = 0x0106,
/// <summary>Ability to read and write using host requested performance parameters</summary>
RTS = 0x0107,
/// <summary>Drive has a unique identifier</summary>
DriveSerial = 0x0108,
/// <summary>Ability to return unique Media Serial Number</summary>
MediaSerial = 0x0109,
/// <summary>Ability to read and/or write DCBs</summary>
DCBs = 0x010A,
/// <summary>Supports DVD CPRM</summary>
CPRM = 0x010B,
/// <summary>Firmware creation date report</summary>
FirmwareInfo = 0x010C,
/// <summary>Ability to decode and optionally encode AACS</summary>
AACS = 0x010D,
/// <summary>Ability to perform DVD CSS managed recording</summary>
CSSManagedRec = 0x010E,
/// <summary>Ability to decode and optionally encode VCPS</summary>
VCPS = 0x0110,
/// <summary>Supports SecurDisc</summary>
SecurDisc = 0x0113,
/// <summary>TCG Optical Security Subsystem Class</summary>
OSSC = 0x0142
}
@@ -110,63 +169,85 @@ namespace DiscImageChef.Decoders.SCSI.MMC
public enum ProfileNumber : ushort
{
/// <summary>Not to use</summary>
Reserved = 0x0000, /// <summary>Non-removable disk profile</summary>
NonRemovable = 0x0001, /// <summary>Rewritable with removable media</summary>
Removable = 0x0002, /// <summary>Magneto-Optical with sector erase</summary>
MOErasable = 0x0003, /// <summary>Optical write once</summary>
OpticalWORM = 0x0004, /// <summary>Advance Storage - Magneto-Optical</summary>
ASMO = 0x0005, /// <summary>Read-only Compact Disc</summary>
CDROM = 0x0008, /// <summary>Write-once Compact Disc</summary>
CDR = 0x0009, /// <summary>Re-writable Compact Disc</summary>
CDRW = 0x000A, /// <summary>Read-only DVD</summary>
DVDROM = 0x0010, /// <summary>Write-once sequentially recorded DVD-R</summary>
DVDRSeq = 0x0011, /// <summary>DVD-RAM</summary>
DVDRAM = 0x0012, /// <summary>Restricted overwrite DVD-RW</summary>
DVDRWRes = 0x0013, /// <summary>Sequential recording DVD-RW</summary>
DVDRWSeq = 0x0014, /// <summary>Sequential recording DVD-R DL</summary>
DVDRDLSeq = 0x0015, /// <summary>Layer jump recording DVD-R DL</summary>
DVDRDLJump = 0x0016, /// <summary>DVD-RW DL</summary>
DVDRWDL = 0x0017, /// <summary>DVD-Download</summary>
DVDDownload = 0x0018, /// <summary>DVD+RW</summary>
DVDRWPlus = 0x001A, /// <summary>DVD+R</summary>
DVDRPlus = 0x001B, /// <summary>DDCD-ROM</summary>
DDCDROM = 0x0020, /// <summary>DDCD-R</summary>
DDCDR = 0x0021, /// <summary>DDCD-RW</summary>
DDCDRW = 0x0022, /// <summary>DVD+RW DL</summary>
DVDRWDLPlus = 0x002A, /// <summary>DVD+R DL</summary>
DVDRDLPlus = 0x002B, /// <summary>BD-ROM</summary>
BDROM = 0x0040, /// <summary>BD-R SRM</summary>
BDRSeq = 0x0041, /// <summary>BD-R RRM</summary>
BDRRdm = 0x0042, /// <summary>BD-RE</summary>
BDRE = 0x0043, /// <summary>HD DVD-ROM</summary>
HDDVDROM = 0x0050, /// <summary>HD DVD-R</summary>
HDDVDR = 0x0051, /// <summary>HD DVD-RAM</summary>
HDDVDRAM = 0x0052, /// <summary>HD DVD-RW</summary>
HDDVDRW = 0x0053, /// <summary>HD DVD-R DL</summary>
HDDVDRDL = 0x0058, /// <summary>HD DVD-RW DL</summary>
HDDVDRWDL = 0x005A, /// <summary>HDBurn CD-ROM</summary>
HDBURNROM = 0x0080, /// <summary>HDBurn CD-R</summary>
HDBURNR = 0x0081, /// <summary>HDBurn CD-RW</summary>
HDBURNRW = 0x0082, /// <summary>Drive does not conform to any profiles</summary>
Reserved = 0x0000,
/// <summary>Non-removable disk profile</summary>
NonRemovable = 0x0001,
/// <summary>Rewritable with removable media</summary>
Removable = 0x0002,
/// <summary>Magneto-Optical with sector erase</summary>
MOErasable = 0x0003,
/// <summary>Optical write once</summary>
OpticalWORM = 0x0004,
/// <summary>Advance Storage - Magneto-Optical</summary>
ASMO = 0x0005,
/// <summary>Read-only Compact Disc</summary>
CDROM = 0x0008,
/// <summary>Write-once Compact Disc</summary>
CDR = 0x0009,
/// <summary>Re-writable Compact Disc</summary>
CDRW = 0x000A,
/// <summary>Read-only DVD</summary>
DVDROM = 0x0010,
/// <summary>Write-once sequentially recorded DVD-R</summary>
DVDRSeq = 0x0011,
/// <summary>DVD-RAM</summary>
DVDRAM = 0x0012,
/// <summary>Restricted overwrite DVD-RW</summary>
DVDRWRes = 0x0013,
/// <summary>Sequential recording DVD-RW</summary>
DVDRWSeq = 0x0014,
/// <summary>Sequential recording DVD-R DL</summary>
DVDRDLSeq = 0x0015,
/// <summary>Layer jump recording DVD-R DL</summary>
DVDRDLJump = 0x0016,
/// <summary>DVD-RW DL</summary>
DVDRWDL = 0x0017,
/// <summary>DVD-Download</summary>
DVDDownload = 0x0018,
/// <summary>DVD+RW</summary>
DVDRWPlus = 0x001A,
/// <summary>DVD+R</summary>
DVDRPlus = 0x001B,
/// <summary>DDCD-ROM</summary>
DDCDROM = 0x0020,
/// <summary>DDCD-R</summary>
DDCDR = 0x0021,
/// <summary>DDCD-RW</summary>
DDCDRW = 0x0022,
/// <summary>DVD+RW DL</summary>
DVDRWDLPlus = 0x002A,
/// <summary>DVD+R DL</summary>
DVDRDLPlus = 0x002B,
/// <summary>BD-ROM</summary>
BDROM = 0x0040,
/// <summary>BD-R SRM</summary>
BDRSeq = 0x0041,
/// <summary>BD-R RRM</summary>
BDRRdm = 0x0042,
/// <summary>BD-RE</summary>
BDRE = 0x0043,
/// <summary>HD DVD-ROM</summary>
HDDVDROM = 0x0050,
/// <summary>HD DVD-R</summary>
HDDVDR = 0x0051,
/// <summary>HD DVD-RAM</summary>
HDDVDRAM = 0x0052,
/// <summary>HD DVD-RW</summary>
HDDVDRW = 0x0053,
/// <summary>HD DVD-R DL</summary>
HDDVDRDL = 0x0058,
/// <summary>HD DVD-RW DL</summary>
HDDVDRWDL = 0x005A,
/// <summary>HDBurn CD-ROM</summary>
HDBURNROM = 0x0080,
/// <summary>HDBurn CD-R</summary>
HDBURNR = 0x0081,
/// <summary>HDBurn CD-RW</summary>
HDBURNRW = 0x0082,
/// <summary>Drive does not conform to any profiles</summary>
Unconforming = 0xFFFF
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum PhysicalInterfaces : uint
{
/// <summary>Unspecified physical interface</summary>
Unspecified = 0, /// <summary>SCSI</summary>
SCSI = 1, /// <summary>ATAPI</summary>
ATAPI = 2, /// <summary>IEEE-1394/1995</summary>
IEEE1394 = 3, /// <summary>IEEE-1394A</summary>
IEEE1394A = 4, /// <summary>Fibre Channel</summary>
FC = 5, /// <summary>IEEE-1394B</summary>
IEEE1394B = 6, /// <summary>Serial ATAPI</summary>
SerialATAPI = 7, /// <summary>USB</summary>
USB = 8, /// <summary>Vendor unique</summary>
Vendor = 0xFFFF
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "NotAccessedField.Global")]
public struct Profile
@@ -1417,11 +1498,9 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
decoded.LogicalBlockSize =
(uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]);
decoded.LogicalBlockSize = (uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]);
decoded.Blocking =
(ushort)((feature[8] << 8) + feature[9]);
decoded.Blocking = (ushort)((feature[8] << 8) + feature[9]);
decoded.PP |= (feature[10] & 0x01) == 0x01;
@@ -1716,11 +1795,9 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.Persistent |= (feature[2] & 0x02) == 0x02;
decoded.Version = (byte)((feature[2] & 0x3C) >> 2);
decoded.LogicalBlockSize =
(uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]);
decoded.LogicalBlockSize = (uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]);
decoded.Blocking =
(ushort)((feature[8] << 8) + feature[9]);
decoded.Blocking = (ushort)((feature[8] << 8) + feature[9]);
decoded.PP |= (feature[10] & 0x01) == 0x01;
@@ -2781,8 +2858,8 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.DCBs = new uint[feature[3] / 4];
for(int i = 0; i < decoded.DCBs.Length; i++)
decoded.DCBs[i] = (uint)((feature[0 + 4 + i * 4] << 24) + (feature[1 + 4 + i * 4] << 16) +
(feature[2 + 4 + i * 4] << 8) + feature[3 + 4 + i * 4]);
decoded.DCBs[i] = (uint)((feature[0 + 4 + (i * 4)] << 24) + (feature[1 + 4 + (i * 4)] << 16) +
(feature[2 + 4 + (i * 4)] << 8) + feature[3 + 4 + (i * 4)]);
return decoded;
}
@@ -2989,11 +3066,11 @@ namespace DiscImageChef.Decoders.SCSI.MMC
decoded.ME |= (feature[4] & 0x01) == 0x01;
decoded.Profiles = new ushort[feature[5]];
if(feature[5] * 2 + 6 != feature.Length)
if((feature[5] * 2) + 6 != feature.Length)
return decoded;
for(int i = 0; i < feature[5]; i++)
decoded.Profiles[i] = (ushort)((feature[0 + 6 + 2 * i] << 8) + feature[1 + 6 + 2 * i]);
decoded.Profiles[i] = (ushort)((feature[0 + 6 + (2 * i)] << 8) + feature[1 + 6 + (2 * i)]);
return decoded;
}

View File

@@ -30,12 +30,10 @@
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using DiscImageChef.CommonTypes.Structs.Devices.SCSI.Modes;
namespace DiscImageChef.Decoders.SCSI
{
@@ -44,439 +42,8 @@ namespace DiscImageChef.Decoders.SCSI
public static partial class Modes
{
#region Mode Page 0x2A: CD-ROM capabilities page
/// <summary>
/// CD-ROM capabilities page Page code 0x2A 16 bytes in OB-U0077C 20 bytes in SFF-8020i 22 bytes in MMC-1 26 bytes
/// in MMC-2 Variable bytes in MMC-3
/// </summary>
public class ModePage_2A
{
public ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors;
/// <summary>Parameters can be saved</summary>
public bool PS { get; set; }
/// <summary>Drive supports multi-session and/or Photo-CD</summary>
public bool MultiSession { get; set; }
/// <summary>Drive is capable of reading sectors in Mode 2 Form 2 format</summary>
public bool Mode2Form2 { get; set; }
/// <summary>Drive is capable of reading sectors in Mode 2 Form 1 format</summary>
public bool Mode2Form1 { get; set; }
/// <summary>Drive is capable of playing audio</summary>
public bool AudioPlay { get; set; }
/// <summary>Drive can return the ISRC</summary>
public bool ISRC { get; set; }
/// <summary>Drive can return the media catalogue number</summary>
public bool UPC { get; set; }
/// <summary>Drive can return C2 pointers</summary>
public bool C2Pointer { get; set; }
/// <summary>Drive can read, deinterlave and correct R-W subchannels</summary>
public bool DeinterlaveSubchannel { get; set; }
/// <summary>Drive can read interleaved and uncorrected R-W subchannels</summary>
public bool Subchannel { get; set; }
/// <summary>Drive can continue from a loss of streaming on audio reading</summary>
public bool AccurateCDDA { get; set; }
/// <summary>Audio can be read as digital data</summary>
public bool CDDACommand { get; set; }
/// <summary>Loading Mechanism Type</summary>
public byte LoadingMechanism { get; set; }
/// <summary>Drive can eject discs</summary>
public bool Eject { get; set; }
/// <summary>Drive's optional prevent jumper status</summary>
public bool PreventJumper { get; set; }
/// <summary>Current lock status</summary>
public bool LockState { get; set; }
/// <summary>Drive can lock media</summary>
public bool Lock { get; set; }
/// <summary>Each channel can be muted independently</summary>
public bool SeparateChannelMute { get; set; }
/// <summary>Each channel's volume can be controlled independently</summary>
public bool SeparateChannelVolume { get; set; }
/// <summary>Maximum drive speed in Kbytes/second</summary>
public ushort MaximumSpeed { get; set; }
/// <summary>Supported volume levels</summary>
public ushort SupportedVolumeLevels { get; set; }
/// <summary>Buffer size in Kbytes</summary>
public ushort BufferSize { get; set; }
/// <summary>Current drive speed in Kbytes/second</summary>
public ushort CurrentSpeed { get; set; }
public bool Method2 { get; set; }
public bool ReadCDRW { get; set; }
public bool ReadCDR { get; set; }
public bool WriteCDRW { get; set; }
public bool WriteCDR { get; set; }
public bool DigitalPort2 { get; set; }
public bool DigitalPort1 { get; set; }
public bool Composite { get; set; }
public bool SSS { get; set; }
public bool SDP { get; set; }
public byte Length { get; set; }
public bool LSBF { get; set; }
public bool RCK { get; set; }
public bool BCK { get; set; }
public bool TestWrite { get; set; }
public ushort MaxWriteSpeed { get; set; }
public ushort CurrentWriteSpeed { get; set; }
public bool ReadBarcode { get; set; }
public bool ReadDVDRAM { get; set; }
public bool ReadDVDR { get; set; }
public bool ReadDVDROM { get; set; }
public bool WriteDVDRAM { get; set; }
public bool WriteDVDR { get; set; }
public bool LeadInPW { get; set; }
public bool SCC { get; set; }
public ushort CMRSupported { get; set; }
public bool BUF { get; set; }
public byte RotationControlSelected { get; set; }
public ushort CurrentWriteSpeedSelected { get; set; }
[JsonIgnore, Key]
public int Id { get; set; }
}
public struct ModePage_2A_WriteDescriptor
{
public byte RotationControl;
public ushort WriteSpeed;
}
public static ModePage_2A DecodeModePage_2A(byte[] pageResponse)
{
if((pageResponse?[0] & 0x40) == 0x40)
return null;
if((pageResponse?[0] & 0x3F) != 0x2A)
return null;
if(pageResponse[1] + 2 != pageResponse.Length)
return null;
if(pageResponse.Length < 16)
return null;
var decoded = new ModePage_2A();
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
decoded.AudioPlay |= (pageResponse[4] & 0x01) == 0x01;
decoded.Mode2Form1 |= (pageResponse[4] & 0x10) == 0x10;
decoded.Mode2Form2 |= (pageResponse[4] & 0x20) == 0x20;
decoded.MultiSession |= (pageResponse[4] & 0x40) == 0x40;
decoded.CDDACommand |= (pageResponse[5] & 0x01) == 0x01;
decoded.AccurateCDDA |= (pageResponse[5] & 0x02) == 0x02;
decoded.Subchannel |= (pageResponse[5] & 0x04) == 0x04;
decoded.DeinterlaveSubchannel |= (pageResponse[5] & 0x08) == 0x08;
decoded.C2Pointer |= (pageResponse[5] & 0x10) == 0x10;
decoded.UPC |= (pageResponse[5] & 0x20) == 0x20;
decoded.ISRC |= (pageResponse[5] & 0x40) == 0x40;
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
decoded.Lock |= (pageResponse[6] & 0x01) == 0x01;
decoded.LockState |= (pageResponse[6] & 0x02) == 0x02;
decoded.PreventJumper |= (pageResponse[6] & 0x04) == 0x04;
decoded.Eject |= (pageResponse[6] & 0x08) == 0x08;
decoded.SeparateChannelVolume |= (pageResponse[7] & 0x01) == 0x01;
decoded.SeparateChannelMute |= (pageResponse[7] & 0x02) == 0x02;
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
if(pageResponse.Length < 20)
return decoded;
decoded.Method2 |= (pageResponse[2] & 0x04) == 0x04;
decoded.ReadCDRW |= (pageResponse[2] & 0x02) == 0x02;
decoded.ReadCDR |= (pageResponse[2] & 0x01) == 0x01;
decoded.WriteCDRW |= (pageResponse[3] & 0x02) == 0x02;
decoded.WriteCDR |= (pageResponse[3] & 0x01) == 0x01;
decoded.Composite |= (pageResponse[4] & 0x02) == 0x02;
decoded.DigitalPort1 |= (pageResponse[4] & 0x04) == 0x04;
decoded.DigitalPort2 |= (pageResponse[4] & 0x08) == 0x08;
decoded.SDP |= (pageResponse[7] & 0x04) == 0x04;
decoded.SSS |= (pageResponse[7] & 0x08) == 0x08;
decoded.Length = (byte)((pageResponse[17] & 0x30) >> 4);
decoded.LSBF |= (pageResponse[17] & 0x08) == 0x08;
decoded.RCK |= (pageResponse[17] & 0x04) == 0x04;
decoded.BCK |= (pageResponse[17] & 0x02) == 0x02;
if(pageResponse.Length < 22)
return decoded;
decoded.TestWrite |= (pageResponse[3] & 0x04) == 0x04;
decoded.MaxWriteSpeed = (ushort)((pageResponse[18] << 8) + pageResponse[19]);
decoded.CurrentWriteSpeed = (ushort)((pageResponse[20] << 8) + pageResponse[21]);
decoded.ReadBarcode |= (pageResponse[5] & 0x80) == 0x80;
if(pageResponse.Length < 26)
return decoded;
decoded.ReadDVDRAM |= (pageResponse[2] & 0x20) == 0x20;
decoded.ReadDVDR |= (pageResponse[2] & 0x10) == 0x10;
decoded.ReadDVDROM |= (pageResponse[2] & 0x08) == 0x08;
decoded.WriteDVDRAM |= (pageResponse[3] & 0x20) == 0x20;
decoded.WriteDVDR |= (pageResponse[3] & 0x10) == 0x10;
decoded.LeadInPW |= (pageResponse[3] & 0x20) == 0x20;
decoded.SCC |= (pageResponse[3] & 0x10) == 0x10;
decoded.CMRSupported = (ushort)((pageResponse[22] << 8) + pageResponse[23]);
if(pageResponse.Length < 32)
return decoded;
decoded.BUF |= (pageResponse[4] & 0x80) == 0x80;
decoded.RotationControlSelected = (byte)(pageResponse[27] & 0x03);
decoded.CurrentWriteSpeedSelected = (ushort)((pageResponse[28] << 8) + pageResponse[29]);
ushort descriptors = (ushort)((pageResponse.Length - 32) / 4);
decoded.WriteSpeedPerformanceDescriptors = new ModePage_2A_WriteDescriptor[descriptors];
for(int i = 0; i < descriptors; i++)
decoded.WriteSpeedPerformanceDescriptors[i] = new ModePage_2A_WriteDescriptor
{
RotationControl =
(byte)(pageResponse[1 + 32 + i * 4] & 0x07),
WriteSpeed = (ushort)((pageResponse[2 + 32 + i * 4] << 8) + pageResponse[3 + 32 + i * 4])
};
return decoded;
}
public static byte[] EncodeModePage_2A(ModePage_2A decoded)
{
byte[] pageResponse = new byte[512];
byte length = 16;
pageResponse[0] = 0x2A;
if(decoded.PS)
pageResponse[0] += 0x80;
if(decoded.AudioPlay)
pageResponse[4] += 0x01;
if(decoded.Mode2Form1)
pageResponse[4] += 0x10;
if(decoded.Mode2Form2)
pageResponse[4] += 0x20;
if(decoded.MultiSession)
pageResponse[4] += 0x40;
if(decoded.CDDACommand)
pageResponse[5] += 0x01;
if(decoded.AccurateCDDA)
pageResponse[5] += 0x02;
if(decoded.Subchannel)
pageResponse[5] += 0x04;
if(decoded.DeinterlaveSubchannel)
pageResponse[5] += 0x08;
if(decoded.C2Pointer)
pageResponse[5] += 0x10;
if(decoded.UPC)
pageResponse[5] += 0x20;
if(decoded.ISRC)
pageResponse[5] += 0x40;
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
if(decoded.Lock)
pageResponse[6] += 0x01;
if(decoded.LockState)
pageResponse[6] += 0x02;
if(decoded.PreventJumper)
pageResponse[6] += 0x04;
if(decoded.Eject)
pageResponse[6] += 0x08;
if(decoded.SeparateChannelVolume)
pageResponse[7] += 0x01;
if(decoded.SeparateChannelMute)
pageResponse[7] += 0x02;
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
if(decoded.Method2 ||
decoded.ReadCDRW ||
decoded.ReadCDR ||
decoded.WriteCDRW ||
decoded.WriteCDR ||
decoded.Composite ||
decoded.DigitalPort1 ||
decoded.DigitalPort2 ||
decoded.SDP ||
decoded.SSS ||
decoded.Length > 0 ||
decoded.LSBF ||
decoded.RCK ||
decoded.BCK)
{
length = 20;
if(decoded.Method2)
pageResponse[2] += 0x04;
if(decoded.ReadCDRW)
pageResponse[2] += 0x02;
if(decoded.ReadCDR)
pageResponse[2] += 0x01;
if(decoded.WriteCDRW)
pageResponse[3] += 0x02;
if(decoded.WriteCDR)
pageResponse[3] += 0x01;
if(decoded.Composite)
pageResponse[4] += 0x02;
if(decoded.DigitalPort1)
pageResponse[4] += 0x04;
if(decoded.DigitalPort2)
pageResponse[4] += 0x08;
if(decoded.SDP)
pageResponse[7] += 0x04;
if(decoded.SSS)
pageResponse[7] += 0x08;
pageResponse[17] = (byte)(decoded.Length << 4);
if(decoded.LSBF)
pageResponse[17] += 0x08;
if(decoded.RCK)
pageResponse[17] += 0x04;
if(decoded.BCK)
pageResponse[17] += 0x02;
}
if(decoded.TestWrite ||
decoded.MaxWriteSpeed > 0 ||
decoded.CurrentWriteSpeed > 0 ||
decoded.ReadBarcode)
{
length = 22;
if(decoded.TestWrite)
pageResponse[3] += 0x04;
pageResponse[18] = (byte)((decoded.MaxWriteSpeed & 0xFF00) >> 8);
pageResponse[19] = (byte)(decoded.MaxWriteSpeed & 0xFF);
pageResponse[20] = (byte)((decoded.CurrentWriteSpeed & 0xFF00) >> 8);
pageResponse[21] = (byte)(decoded.CurrentWriteSpeed & 0xFF);
if(decoded.ReadBarcode)
pageResponse[5] += 0x80;
}
if(decoded.ReadDVDRAM ||
decoded.ReadDVDR ||
decoded.ReadDVDROM ||
decoded.WriteDVDRAM ||
decoded.WriteDVDR ||
decoded.LeadInPW ||
decoded.SCC ||
decoded.CMRSupported > 0)
{
length = 26;
if(decoded.ReadDVDRAM)
pageResponse[2] += 0x20;
if(decoded.ReadDVDR)
pageResponse[2] += 0x10;
if(decoded.ReadDVDROM)
pageResponse[2] += 0x08;
if(decoded.WriteDVDRAM)
pageResponse[3] += 0x20;
if(decoded.WriteDVDR)
pageResponse[3] += 0x10;
if(decoded.LeadInPW)
pageResponse[3] += 0x20;
if(decoded.SCC)
pageResponse[3] += 0x10;
pageResponse[22] = (byte)((decoded.CMRSupported & 0xFF00) >> 8);
pageResponse[23] = (byte)(decoded.CMRSupported & 0xFF);
}
if(decoded.BUF ||
decoded.RotationControlSelected > 0 ||
decoded.CurrentWriteSpeedSelected > 0)
{
length = 32;
if(decoded.BUF)
pageResponse[4] += 0x80;
pageResponse[27] += decoded.RotationControlSelected;
pageResponse[28] = (byte)((decoded.CurrentWriteSpeedSelected & 0xFF00) >> 8);
pageResponse[29] = (byte)(decoded.CurrentWriteSpeedSelected & 0xFF);
}
if(decoded.WriteSpeedPerformanceDescriptors != null)
{
length = 32;
for(int i = 0; i < decoded.WriteSpeedPerformanceDescriptors.Length; i++)
{
length += 4;
pageResponse[1 + 32 + i * 4] = decoded.WriteSpeedPerformanceDescriptors[i].RotationControl;
pageResponse[2 + 32 + i * 4] =
(byte)((decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF00) >> 8);
pageResponse[3 + 32 + i * 4] =
(byte)(decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF);
}
}
pageResponse[1] = (byte)(length - 2);
byte[] buf = new byte[length];
Array.Copy(pageResponse, 0, buf, 0, length);
return buf;
}
public static string PrettifyModePage_2A(byte[] pageResponse) =>
PrettifyModePage_2A(DecodeModePage_2A(pageResponse));
PrettifyModePage_2A(ModePage_2A.Decode(pageResponse));
public static string PrettifyModePage_2A(ModePage_2A modePage)
{

View File

@@ -33,6 +33,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
namespace DiscImageChef.Decoders.SCSI
{
@@ -44,8 +45,10 @@ namespace DiscImageChef.Decoders.SCSI
public enum Fujitsu_VerifyModes : byte
{
/// <summary>Always verify after writing</summary>
Always = 0, /// <summary>Never verify after writing</summary>
Never = 1, /// <summary>Verify after writing depending on condition</summary>
Always = 0,
/// <summary>Never verify after writing</summary>
Never = 1,
/// <summary>Verify after writing depending on condition</summary>
Depends = 2, Reserved = 4
}

View File

@@ -32,6 +32,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Text;
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
namespace DiscImageChef.Decoders.SCSI
{

View File

@@ -34,6 +34,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
namespace DiscImageChef.Decoders.SCSI
{
@@ -67,7 +68,7 @@ namespace DiscImageChef.Decoders.SCSI
for(int i = 0; i < header.BlockDescriptors.Length; i++)
{
if(12 + i * 16 + 8 >= modeResponse.Length)
if(12 + (i * 16) + 8 >= modeResponse.Length)
break;
header.BlockDescriptors[i] = new BlockDescriptor
@@ -76,19 +77,19 @@ namespace DiscImageChef.Decoders.SCSI
};
byte[] temp = new byte[8];
temp[0] = modeResponse[7 + i * 16 + 8];
temp[1] = modeResponse[6 + i * 16 + 8];
temp[2] = modeResponse[5 + i * 16 + 8];
temp[3] = modeResponse[4 + i * 16 + 8];
temp[4] = modeResponse[3 + i * 16 + 8];
temp[5] = modeResponse[2 + i * 16 + 8];
temp[6] = modeResponse[1 + i * 16 + 8];
temp[7] = modeResponse[0 + i * 16 + 8];
temp[0] = modeResponse[7 + (i * 16) + 8];
temp[1] = modeResponse[6 + (i * 16) + 8];
temp[2] = modeResponse[5 + (i * 16) + 8];
temp[3] = modeResponse[4 + (i * 16) + 8];
temp[4] = modeResponse[3 + (i * 16) + 8];
temp[5] = modeResponse[2 + (i * 16) + 8];
temp[6] = modeResponse[1 + (i * 16) + 8];
temp[7] = modeResponse[0 + (i * 16) + 8];
header.BlockDescriptors[i].Blocks = BitConverter.ToUInt64(temp, 0);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[15 + i * 16 + 8] << 24);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[14 + i * 16 + 8] << 16);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[13 + i * 16 + 8] << 8);
header.BlockDescriptors[i].BlockLength += modeResponse[12 + i * 16 + 8];
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[15 + (i * 16) + 8] << 24);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[14 + (i * 16) + 8] << 16);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[13 + (i * 16) + 8] << 8);
header.BlockDescriptors[i].BlockLength += modeResponse[12 + (i * 16) + 8];
}
}
else
@@ -97,25 +98,25 @@ namespace DiscImageChef.Decoders.SCSI
for(int i = 0; i < header.BlockDescriptors.Length; i++)
{
if(7 + i * 8 + 8 >= modeResponse.Length)
if(7 + (i * 8) + 8 >= modeResponse.Length)
break;
header.BlockDescriptors[i] = new BlockDescriptor();
if(deviceType != PeripheralDeviceTypes.DirectAccess)
header.BlockDescriptors[i].Density = (DensityType)modeResponse[0 + i * 8 + 8];
header.BlockDescriptors[i].Density = (DensityType)modeResponse[0 + (i * 8) + 8];
else
{
header.BlockDescriptors[i].Density = DensityType.Default;
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[0 + i * 8 + 8] << 24);
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[0 + (i * 8) + 8] << 24);
}
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[1 + i * 8 + 8] << 16);
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[2 + i * 8 + 8] << 8);
header.BlockDescriptors[i].Blocks += modeResponse[3 + i * 8 + 8];
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[5 + i * 8 + 8] << 16);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[6 + i * 8 + 8] << 8);
header.BlockDescriptors[i].BlockLength += modeResponse[7 + i * 8 + 8];
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[1 + (i * 8) + 8] << 16);
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[2 + (i * 8) + 8] << 8);
header.BlockDescriptors[i].Blocks += modeResponse[3 + (i * 8) + 8];
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[5 + (i * 8) + 8] << 16);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[6 + (i * 8) + 8] << 8);
header.BlockDescriptors[i].BlockLength += modeResponse[7 + (i * 8) + 8];
}
}
@@ -171,9 +172,9 @@ namespace DiscImageChef.Decoders.SCSI
blkDrLength = decoded.Header.BlockDescriptors.Length;
if(longlba)
offset = 8 + blkDrLength * 16;
offset = 8 + (blkDrLength * 16);
else
offset = 8 + blkDrLength * 8;
offset = 8 + (blkDrLength * 8);
int length = modeResponse[0] << 8;
length += modeResponse[1];
@@ -240,8 +241,8 @@ namespace DiscImageChef.Decoders.SCSI
byte[] hdr;
if(header.BlockDescriptors != null)
hdr = longLBA ? new byte[8 + header.BlockDescriptors.Length * 16]
: new byte[8 + header.BlockDescriptors.Length * 8];
hdr = longLBA ? new byte[8 + (header.BlockDescriptors.Length * 16)]
: new byte[8 + (header.BlockDescriptors.Length * 8)];
else
hdr = new byte[8];
@@ -293,33 +294,33 @@ namespace DiscImageChef.Decoders.SCSI
for(int i = 0; i < header.BlockDescriptors.Length; i++)
{
byte[] temp = BitConverter.GetBytes(header.BlockDescriptors[i].Blocks);
hdr[7 + i * 16 + 8] = temp[0];
hdr[6 + i * 16 + 8] = temp[1];
hdr[5 + i * 16 + 8] = temp[2];
hdr[4 + i * 16 + 8] = temp[3];
hdr[3 + i * 16 + 8] = temp[4];
hdr[2 + i * 16 + 8] = temp[5];
hdr[1 + i * 16 + 8] = temp[6];
hdr[0 + i * 16 + 8] = temp[7];
hdr[12 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF000000) >> 24);
hdr[13 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
hdr[14 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
hdr[15 + i * 16 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
hdr[7 + (i * 16) + 8] = temp[0];
hdr[6 + (i * 16) + 8] = temp[1];
hdr[5 + (i * 16) + 8] = temp[2];
hdr[4 + (i * 16) + 8] = temp[3];
hdr[3 + (i * 16) + 8] = temp[4];
hdr[2 + (i * 16) + 8] = temp[5];
hdr[1 + (i * 16) + 8] = temp[6];
hdr[0 + (i * 16) + 8] = temp[7];
hdr[12 + (i * 16) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF000000) >> 24);
hdr[13 + (i * 16) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
hdr[14 + (i * 16) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
hdr[15 + (i * 16) + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
}
else
for(int i = 0; i < header.BlockDescriptors.Length; i++)
{
if(deviceType != PeripheralDeviceTypes.DirectAccess)
hdr[0 + i * 8 + 8] = (byte)header.BlockDescriptors[i].Density;
hdr[0 + (i * 8) + 8] = (byte)header.BlockDescriptors[i].Density;
else
hdr[0 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF000000) >> 24);
hdr[0 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF000000) >> 24);
hdr[1 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
hdr[2 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
hdr[3 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
hdr[5 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
hdr[6 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
hdr[7 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
hdr[1 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
hdr[2 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
hdr[3 + (i * 8) + 8] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
hdr[5 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
hdr[6 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
hdr[7 + (i * 8) + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
}
return hdr;

View File

@@ -34,6 +34,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
namespace DiscImageChef.Decoders.SCSI
{
@@ -59,13 +60,13 @@ namespace DiscImageChef.Decoders.SCSI
for(int i = 0; i < header.BlockDescriptors.Length; i++)
{
header.BlockDescriptors[i].Density = (DensityType)modeResponse[0 + i * 8 + 4];
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[1 + i * 8 + 4] << 16);
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[2 + i * 8 + 4] << 8);
header.BlockDescriptors[i].Blocks += modeResponse[3 + i * 8 + 4];
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[5 + i * 8 + 4] << 16);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[6 + i * 8 + 4] << 8);
header.BlockDescriptors[i].BlockLength += modeResponse[7 + i * 8 + 4];
header.BlockDescriptors[i].Density = (DensityType)modeResponse[0 + (i * 8) + 4];
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[1 + (i * 8) + 4] << 16);
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[2 + (i * 8) + 4] << 8);
header.BlockDescriptors[i].Blocks += modeResponse[3 + (i * 8) + 4];
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[5 + (i * 8) + 4] << 16);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[6 + (i * 8) + 4] << 8);
header.BlockDescriptors[i].BlockLength += modeResponse[7 + (i * 8) + 4];
}
}
@@ -118,7 +119,7 @@ namespace DiscImageChef.Decoders.SCSI
if(decoded.Header.BlockDescriptors != null)
blkDrLength = decoded.Header.BlockDescriptors.Length;
int offset = 4 + blkDrLength * 8;
int offset = 4 + (blkDrLength * 8);
int length = modeResponse[0] + 1;
if(length != modeResponse.Length)
@@ -184,7 +185,7 @@ namespace DiscImageChef.Decoders.SCSI
public static byte[] EncodeModeHeader6(ModeHeader header, PeripheralDeviceTypes deviceType)
{
byte[] hdr = header.BlockDescriptors != null ? new byte[4 + header.BlockDescriptors.Length * 8]
byte[] hdr = header.BlockDescriptors != null ? new byte[4 + (header.BlockDescriptors.Length * 8)]
: new byte[4];
hdr[1] = (byte)header.MediumType;
@@ -232,13 +233,13 @@ namespace DiscImageChef.Decoders.SCSI
for(int i = 0; i < header.BlockDescriptors.Length; i++)
{
hdr[0 + i * 8 + 4] = (byte)header.BlockDescriptors[i].Density;
hdr[1 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
hdr[2 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
hdr[3 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
hdr[5 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
hdr[6 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
hdr[7 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
hdr[0 + (i * 8) + 4] = (byte)header.BlockDescriptors[i].Density;
hdr[1 + (i * 8) + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
hdr[2 + (i * 8) + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
hdr[3 + (i * 8) + 4] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
hdr[5 + (i * 8) + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
hdr[6 + (i * 8) + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
hdr[7 + (i * 8) + 4] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
}
return hdr;