mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 11:14:25 +00:00
General cleanup and refactor.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
@@ -30,11 +29,11 @@ dotnet_naming_rule.unity_serialized_field_rule_1.style = lower_camel_case_style
|
||||
dotnet_naming_rule.unity_serialized_field_rule_1.symbols = unity_serialized_field_symbols_1
|
||||
dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
|
||||
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = *
|
||||
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
|
||||
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
|
||||
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field
|
||||
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance
|
||||
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_accessibilities = *
|
||||
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds =
|
||||
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds =
|
||||
dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_applicable_kinds = unity_serialised_field
|
||||
dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_required_modifiers = instance
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:warning
|
||||
|
||||
4
.github/CODE_OF_CONDUCT.md
vendored
4
.github/CODE_OF_CONDUCT.md
vendored
@@ -54,7 +54,7 @@ repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][https://www.contributor-covenant.org], version 1.4, available
|
||||
at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][https://www.contributor-covenant.org], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
@@ -1,91 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{282271D0-CCC2-4ED7-BA38-EC06A84BB974}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Aaru.Archives</RootNamespace>
|
||||
<AssemblyName>Aaru.Archives</AssemblyName>
|
||||
<ReleaseVersion>$(Version)</ReleaseVersion>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>6.0.0-alpha8</Version>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>Copyright © 2011-2022 Natalia Portillo</Copyright>
|
||||
<Product>Aaru Data Preservation Suite</Product>
|
||||
<Title>Aaru.Archives</Title>
|
||||
<ApplicationVersion>$(Version)</ApplicationVersion>
|
||||
<TargetFramework>net6</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<Description>Archive implementations used by the Aaru Data Preservation Suite.</Description>
|
||||
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
|
||||
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
|
||||
<RepositoryUrl>https://github.com/aaru-dps/Aaru.Archives</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Authors>Natalia Portillo <claunia@claunia.com></Authors>
|
||||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
|
||||
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\net6</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\net6</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Register.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\LICENSE.LGPL">
|
||||
<Link>LICENSE.LGPL</Link>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj">
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpCompress" Version="0.30.1" />
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp" />
|
||||
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************
Aaru Data Preservation Suite
----------------------------------------------------------------------------
 
Filename : ${FileName}
Author(s) : ${AuthorName} <${AuthorEmail}>

Component : Component
 
--[ Description ] ----------------------------------------------------------
 
 Description
 
--[ 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-${Year} ${CopyrightHolder}
****************************************************************************/" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{282271D0-CCC2-4ED7-BA38-EC06A84BB974}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Aaru.Archives</RootNamespace>
|
||||
<AssemblyName>Aaru.Archives</AssemblyName>
|
||||
<ReleaseVersion>$(Version)</ReleaseVersion>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>6.0.0-alpha8</Version>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>Copyright © 2011-2022 Natalia Portillo</Copyright>
|
||||
<Product>Aaru Data Preservation Suite</Product>
|
||||
<Title>Aaru.Archives</Title>
|
||||
<ApplicationVersion>$(Version)</ApplicationVersion>
|
||||
<TargetFramework>net6</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<Description>Archive implementations used by the Aaru Data Preservation Suite.</Description>
|
||||
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
|
||||
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
|
||||
<RepositoryUrl>https://github.com/aaru-dps/Aaru.Archives</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Authors>Natalia Portillo <claunia@claunia.com></Authors>
|
||||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
|
||||
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\net6</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\net6</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Register.cs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\LICENSE.LGPL">
|
||||
<Link>LICENSE.LGPL</Link>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj"/>
|
||||
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj"></ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpCompress" Version="0.30.1"/>
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp"/>
|
||||
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp"/>
|
||||
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************
Aaru Data Preservation Suite
----------------------------------------------------------------------------
 
Filename : ${FileName}
Author(s) : ${AuthorName} <${AuthorEmail}>

Component : Component
 
--[ Description ] ----------------------------------------------------------
 
 Description
 
--[ 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-${Year} ${CopyrightHolder}
****************************************************************************/"/>
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">
|
||||
<!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
|
||||
<!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
|
||||
|
||||
@@ -38,14 +38,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Archives;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Archives;
|
||||
|
||||
/// <inheritdoc />
|
||||
public sealed class Register : IPluginRegister
|
||||
{
|
||||
|
||||
Submodule Aaru.Checksums updated: db8c5c6a53...19c7f3d4ff
Submodule Aaru.CommonTypes updated: 27900ec144...8d40f3e395
@@ -35,27 +35,24 @@
|
||||
// Copyright © 2016-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
/// <summary>Implements the Apple version of RLE</summary>
|
||||
public static class ADC
|
||||
{
|
||||
/// <summary>
|
||||
/// Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.
|
||||
/// </summary>
|
||||
const int PLAIN = 1;
|
||||
const int TWO_BYTE = 2;
|
||||
const int THREE_BYTE = 3;
|
||||
/// <summary>Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.</summary>
|
||||
public static bool IsSupported => true;
|
||||
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
static extern int AARU_adc_decode_buffer(byte[] dst_buffer, int dst_size, byte[] src_buffer, int src_size);
|
||||
|
||||
const int PLAIN = 1;
|
||||
const int TWO_BYTE = 2;
|
||||
const int THREE_BYTE = 3;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static int GetChunkType(byte byt) => (byt & 0x80) == 0x80
|
||||
? PLAIN
|
||||
@@ -65,21 +62,21 @@ public static class ADC
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static int GetChunkSize(byte byt) => GetChunkType(byt) switch
|
||||
{
|
||||
PLAIN => (byt & 0x7F) + 1,
|
||||
TWO_BYTE => ((byt & 0x3F) >> 2) + 3,
|
||||
THREE_BYTE => (byt & 0x3F) + 4,
|
||||
_ => -1
|
||||
};
|
||||
{
|
||||
PLAIN => (byt & 0x7F) + 1,
|
||||
TWO_BYTE => ((byt & 0x3F) >> 2) + 3,
|
||||
THREE_BYTE => (byt & 0x3F) + 4,
|
||||
_ => -1
|
||||
};
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static int GetOffset(ReadOnlySpan<byte> chunk) => GetChunkType(chunk[0]) switch
|
||||
{
|
||||
PLAIN => 0,
|
||||
TWO_BYTE => ((chunk[0] & 0x03) << 8) + chunk[1],
|
||||
THREE_BYTE => (chunk[1] << 8) + chunk[2],
|
||||
_ => -1
|
||||
};
|
||||
{
|
||||
PLAIN => 0,
|
||||
TWO_BYTE => ((chunk[0] & 0x03) << 8) + chunk[1],
|
||||
THREE_BYTE => (chunk[1] << 8) + chunk[2],
|
||||
_ => -1
|
||||
};
|
||||
|
||||
/// <summary>Decompresses a byte buffer that's compressed with ADC</summary>
|
||||
/// <param name="source">Compressed buffer</param>
|
||||
@@ -91,11 +88,11 @@ public static class ADC
|
||||
if(Native.IsSupported)
|
||||
return AARU_adc_decode_buffer(destination, destination.Length, source, source.Length);
|
||||
|
||||
int inputPosition = 0;
|
||||
var inputPosition = 0;
|
||||
int chunkSize;
|
||||
int offset;
|
||||
int chunkType;
|
||||
int outPosition = 0;
|
||||
var outPosition = 0;
|
||||
Span<byte> temp = stackalloc byte[3];
|
||||
|
||||
while(inputPosition < source.Length)
|
||||
@@ -130,20 +127,18 @@ public static class ADC
|
||||
{
|
||||
byte lastByte = destination[outPosition - 1];
|
||||
|
||||
for(int i = 0; i < chunkSize; i++)
|
||||
for(var i = 0; i < chunkSize; i++)
|
||||
{
|
||||
destination[outPosition] = lastByte;
|
||||
outPosition++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < chunkSize; i++)
|
||||
for(var i = 0; i < chunkSize; i++)
|
||||
{
|
||||
destination[outPosition] = destination[outPosition - offset - 1];
|
||||
outPosition++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case THREE_BYTE:
|
||||
@@ -160,26 +155,24 @@ public static class ADC
|
||||
{
|
||||
byte lastByte = destination[outPosition - 1];
|
||||
|
||||
for(int i = 0; i < chunkSize; i++)
|
||||
for(var i = 0; i < chunkSize; i++)
|
||||
{
|
||||
destination[outPosition] = lastByte;
|
||||
outPosition++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < chunkSize; i++)
|
||||
for(var i = 0; i < chunkSize; i++)
|
||||
{
|
||||
destination[outPosition] = destination[outPosition - offset - 1];
|
||||
outPosition++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
finished:
|
||||
finished:
|
||||
|
||||
return outPosition;
|
||||
}
|
||||
|
||||
@@ -1,127 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{858398D1-7321-4763-8BAB-56BBFEC74E29}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Aaru.Compression</RootNamespace>
|
||||
<AssemblyName>Aaru.Compression</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ReleaseVersion>$(Version)</ReleaseVersion>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>6.0.0-alpha8</Version>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>Copyright © 2011-2022 Natalia Portillo</Copyright>
|
||||
<Product>Aaru Data Preservation Suite</Product>
|
||||
<Title>Aaru Data Preservation Suite</Title>
|
||||
<ApplicationVersion>$(Version)</ApplicationVersion>
|
||||
<TargetFramework>net6</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<Description>Compression algorithms used by the Aaru Data Preservation Suite.</Description>
|
||||
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
|
||||
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
|
||||
<RepositoryUrl>https://github.com/aaru-dps/Aaru</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Authors>Natalia Portillo <claunia@claunia.com></Authors>
|
||||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
|
||||
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\net6</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\net6</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<DefaultItemExcludes>
|
||||
$(DefaultItemExcludes);cuetools.net/**/*
|
||||
</DefaultItemExcludes>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ADC.cs" />
|
||||
<Compile Include="AppleRle.cs" />
|
||||
<Compile Include="BZip2.cs" />
|
||||
<Compile Include="FLAC.cs" />
|
||||
<Compile Include="LZFSE.cs" />
|
||||
<Compile Include="LZIP.cs" />
|
||||
<Compile Include="LZMA.cs" />
|
||||
<Compile Include="Native.cs" />
|
||||
<Compile Include="TeleDiskLzh.cs" />
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/*.cs" />
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/CommandLine/*.cs" />
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/CRC/*.cs" />
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/NULL/*.cs" />
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/ViewModel/*.cs" />
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/WAV/*.cs" />
|
||||
<Compile Include="cuetools.net/CUETools.Codecs.Flake/*.cs" />
|
||||
<Compile Include="cuetools.net/CUETools.Codecs.Flake/Properties/*.cs" />
|
||||
<Compile Include="ZSTD.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\LICENSE.LGPL">
|
||||
<Link>LICENSE.LGPL</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aaru.Compression.Native" Version="6.0.0-alpha8" />
|
||||
<PackageReference Include="DotNetZip" Version="1.16.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="SharpCompress" Version="0.30.1" />
|
||||
<PackageReference Include="System.Resources.Extensions" Version="6.0.0" />
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.2" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">
|
||||
<!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
|
||||
<!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
|
||||
<!-- Look in the standard install locations -->
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<!-- If we found Mono reference assemblies, then use them -->
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net40'">$(BaseFrameworkPathOverrideForMono)/4.0-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
|
||||
<EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
|
||||
<!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
|
||||
<AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{858398D1-7321-4763-8BAB-56BBFEC74E29}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Aaru.Compression</RootNamespace>
|
||||
<AssemblyName>Aaru.Compression</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ReleaseVersion>$(Version)</ReleaseVersion>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>6.0.0-alpha8</Version>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>Copyright © 2011-2022 Natalia Portillo</Copyright>
|
||||
<Product>Aaru Data Preservation Suite</Product>
|
||||
<Title>Aaru Data Preservation Suite</Title>
|
||||
<ApplicationVersion>$(Version)</ApplicationVersion>
|
||||
<TargetFramework>net6</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<Description>Compression algorithms used by the Aaru Data Preservation Suite.</Description>
|
||||
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
|
||||
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
|
||||
<RepositoryUrl>https://github.com/aaru-dps/Aaru</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Authors>Natalia Portillo <claunia@claunia.com></Authors>
|
||||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
|
||||
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\net6</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\net6</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<DefaultItemExcludes>
|
||||
$(DefaultItemExcludes);cuetools.net/**/*
|
||||
</DefaultItemExcludes>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ADC.cs"/>
|
||||
<Compile Include="AppleRle.cs"/>
|
||||
<Compile Include="BZip2.cs"/>
|
||||
<Compile Include="FLAC.cs"/>
|
||||
<Compile Include="LZFSE.cs"/>
|
||||
<Compile Include="LZIP.cs"/>
|
||||
<Compile Include="LZMA.cs"/>
|
||||
<Compile Include="Native.cs"/>
|
||||
<Compile Include="TeleDiskLzh.cs"/>
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/*.cs"/>
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/CommandLine/*.cs"/>
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/CRC/*.cs"/>
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/NULL/*.cs"/>
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/ViewModel/*.cs"/>
|
||||
<Compile Include="cuetools.net/CUETools.Codecs/WAV/*.cs"/>
|
||||
<Compile Include="cuetools.net/CUETools.Codecs.Flake/*.cs"/>
|
||||
<Compile Include="cuetools.net/CUETools.Codecs.Flake/Properties/*.cs"/>
|
||||
<Compile Include="ZSTD.cs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\LICENSE.LGPL">
|
||||
<Link>LICENSE.LGPL</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aaru.Compression.Native" Version="6.0.0-alpha8"/>
|
||||
<PackageReference Include="DotNetZip" Version="1.16.0"/>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
|
||||
<PackageReference Include="SharpCompress" Version="0.30.1"/>
|
||||
<PackageReference Include="System.Resources.Extensions" Version="6.0.0"/>
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.2" PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">
|
||||
<!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
|
||||
<!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
|
||||
<!-- Look in the standard install locations -->
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<!-- If we found Mono reference assemblies, then use them -->
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net40'">$(BaseFrameworkPathOverrideForMono)/4.0-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
|
||||
<EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
|
||||
<!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
|
||||
<AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -31,23 +31,20 @@
|
||||
// Copyright © 2018-2019 David Ryskalczyk
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>Implements the Apple version of RLE</summary>
|
||||
public static class AppleRle
|
||||
{
|
||||
/// <summary>
|
||||
/// Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.
|
||||
/// </summary>
|
||||
const uint DART_CHUNK = 20960;
|
||||
/// <summary>Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.</summary>
|
||||
public static bool IsSupported => true;
|
||||
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
static extern int AARU_apple_rle_decode_buffer(byte[] dst_buffer, int dst_size, byte[] src_buffer, int src_size);
|
||||
|
||||
const uint DART_CHUNK = 20960;
|
||||
|
||||
/// <summary>Decodes a buffer compressed with Apple RLE</summary>
|
||||
/// <param name="source">Encoded buffer</param>
|
||||
/// <param name="destination">Buffer where to write the decoded data</param>
|
||||
@@ -57,10 +54,10 @@ public static class AppleRle
|
||||
if(Native.IsSupported)
|
||||
return AARU_apple_rle_decode_buffer(destination, destination.Length, source, source.Length);
|
||||
|
||||
int count = 0;
|
||||
bool nextA = true; // true if A, false if B
|
||||
var count = 0;
|
||||
var nextA = true; // true if A, false if B
|
||||
byte repeatedByteA = 0, repeatedByteB = 0;
|
||||
bool repeatMode = false; // true if we're repeating, false if we're just copying
|
||||
var repeatMode = false; // true if we're repeating, false if we're just copying
|
||||
int inPosition = 0, outPosition = 0;
|
||||
|
||||
while(inPosition <= source.Length &&
|
||||
@@ -100,9 +97,9 @@ public static class AppleRle
|
||||
|
||||
while(true)
|
||||
{
|
||||
byte b1 = source[inPosition++];
|
||||
byte b2 = source[inPosition++];
|
||||
short s = (short)((b1 << 8) | b2);
|
||||
byte b1 = source[inPosition++];
|
||||
byte b2 = source[inPosition++];
|
||||
var s = (short)((b1 << 8) | b2);
|
||||
|
||||
if(s == 0 ||
|
||||
s >= DART_CHUNK ||
|
||||
@@ -114,7 +111,7 @@ public static class AppleRle
|
||||
repeatMode = true;
|
||||
repeatedByteA = source[inPosition++];
|
||||
repeatedByteB = source[inPosition++];
|
||||
count = (-s * 2) - 1;
|
||||
count = -s * 2 - 1;
|
||||
nextA = false;
|
||||
|
||||
destination[outPosition++] = repeatedByteA;
|
||||
@@ -123,7 +120,7 @@ public static class AppleRle
|
||||
}
|
||||
|
||||
repeatMode = false;
|
||||
count = (s * 2) - 1;
|
||||
count = s * 2 - 1;
|
||||
|
||||
destination[outPosition++] = source[inPosition++];
|
||||
|
||||
|
||||
@@ -26,17 +26,15 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Ionic.BZip2;
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
public class BZip2
|
||||
{
|
||||
/// <summary>
|
||||
/// Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.
|
||||
/// </summary>
|
||||
/// <summary>Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.</summary>
|
||||
public static bool IsSupported => true;
|
||||
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
@@ -52,7 +50,7 @@ public class BZip2
|
||||
/// <returns>The number of decoded bytes</returns>
|
||||
public static int DecodeBuffer(byte[] source, byte[] destination)
|
||||
{
|
||||
uint destinationSize = (uint)destination.Length;
|
||||
var destinationSize = (uint)destination.Length;
|
||||
|
||||
if(Native.IsSupported)
|
||||
{
|
||||
@@ -74,7 +72,7 @@ public class BZip2
|
||||
/// <returns></returns>
|
||||
public static int EncodeBuffer(byte[] source, byte[] destination, int blockSize100k)
|
||||
{
|
||||
uint destinationSize = (uint)destination.Length;
|
||||
var destinationSize = (uint)destination.Length;
|
||||
|
||||
if(Native.IsSupported)
|
||||
{
|
||||
|
||||
@@ -26,18 +26,16 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using CUETools.Codecs;
|
||||
using CUETools.Codecs.Flake;
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
public class FLAC
|
||||
{
|
||||
/// <summary>
|
||||
/// Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.
|
||||
/// </summary>
|
||||
/// <summary>Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.</summary>
|
||||
public static bool IsSupported => true;
|
||||
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
@@ -48,9 +46,8 @@ public class FLAC
|
||||
static extern nuint AARU_flac_encode_redbook_buffer(byte[] dst_buffer, nuint dst_size, byte[] src_buffer,
|
||||
nuint src_size, uint blocksize, int do_mid_side_stereo,
|
||||
int loose_mid_side_stereo, string apodization,
|
||||
uint max_lpc_order,
|
||||
uint qlp_coeff_precision, int do_qlp_coeff_prec_search,
|
||||
int do_exhaustive_model_search,
|
||||
uint max_lpc_order, uint qlp_coeff_precision,
|
||||
int do_qlp_coeff_prec_search, int do_exhaustive_model_search,
|
||||
uint min_residual_partition_order,
|
||||
uint max_residual_partition_order, string application_id,
|
||||
uint application_id_len);
|
||||
@@ -81,19 +78,18 @@ public class FLAC
|
||||
/// <param name="destination">Buffer to store the compressed data</param>
|
||||
/// <returns></returns>
|
||||
public static int EncodeBuffer(byte[] source, byte[] destination, uint blockSize, bool doMidSideStereo,
|
||||
bool looseMidSideStereo, string apodization, uint max_lpc_order, uint qlpCoeffPrecision,
|
||||
bool doQlpCoeffPrecSearch, bool doExhaustiveModelSearch,
|
||||
uint minResidualPartitionOrder, uint maxResidualPartitionOrder,
|
||||
string applicationID)
|
||||
bool looseMidSideStereo, string apodization, uint max_lpc_order,
|
||||
uint qlpCoeffPrecision, bool doQlpCoeffPrecSearch, bool doExhaustiveModelSearch,
|
||||
uint minResidualPartitionOrder, uint maxResidualPartitionOrder, string applicationID)
|
||||
{
|
||||
if(Native.IsSupported)
|
||||
return (int)AARU_flac_encode_redbook_buffer(destination, (nuint)destination.Length, source,
|
||||
(nuint)source.Length, blockSize, doMidSideStereo ? 1 : 0,
|
||||
looseMidSideStereo ? 1 : 0, apodization, max_lpc_order, qlpCoeffPrecision,
|
||||
doQlpCoeffPrecSearch ? 1 : 0,
|
||||
doExhaustiveModelSearch ? 1 : 0,
|
||||
minResidualPartitionOrder, maxResidualPartitionOrder,
|
||||
applicationID, (uint)applicationID.Length);
|
||||
looseMidSideStereo ? 1 : 0, apodization, max_lpc_order,
|
||||
qlpCoeffPrecision, doQlpCoeffPrecSearch ? 1 : 0,
|
||||
doExhaustiveModelSearch ? 1 : 0, minResidualPartitionOrder,
|
||||
maxResidualPartitionOrder, applicationID,
|
||||
(uint)applicationID.Length);
|
||||
|
||||
var flakeWriterSettings = new EncoderSettings
|
||||
{
|
||||
|
||||
@@ -26,15 +26,13 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class LZFSE
|
||||
{
|
||||
/// <summary>
|
||||
/// Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.
|
||||
/// </summary>
|
||||
/// <summary>Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.</summary>
|
||||
public static bool IsSupported => Native.IsSupported;
|
||||
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
|
||||
@@ -26,15 +26,13 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class LZIP
|
||||
{
|
||||
/// <summary>
|
||||
/// Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.
|
||||
/// </summary>
|
||||
/// <summary>Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.</summary>
|
||||
public static bool IsSupported => Native.IsSupported;
|
||||
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
|
||||
@@ -26,17 +26,15 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using SharpCompress.Compressors.LZMA;
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
public class LZMA
|
||||
{
|
||||
/// <summary>
|
||||
/// Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.
|
||||
/// </summary>
|
||||
/// <summary>Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.</summary>
|
||||
public static bool IsSupported => true;
|
||||
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public static class Native
|
||||
{
|
||||
static bool _checked;
|
||||
|
||||
@@ -42,11 +42,11 @@
|
||||
// Copyright © 1988 Kenji RIKITAKE
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
/*
|
||||
* Based on Japanese version 29-NOV-1988
|
||||
* LZSS coded by Haruhiko OKUMURA
|
||||
@@ -56,11 +56,6 @@ namespace Aaru.Compression;
|
||||
/// <summary>Implements the TeleDisk version of LZH</summary>
|
||||
public class TeleDiskLzh
|
||||
{
|
||||
/// <summary>
|
||||
/// Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.
|
||||
/// </summary>
|
||||
public static bool IsSupported => true;
|
||||
|
||||
const int BUFSZ = 512;
|
||||
|
||||
/* LZSS Parameters */
|
||||
@@ -73,8 +68,8 @@ public class TeleDiskLzh
|
||||
|
||||
const int N_CHAR = 256 - THRESHOLD + F;
|
||||
/* character code (= 0..N_CHAR-1) */
|
||||
const int T = (N_CHAR * 2) - 1; /* Size of table */
|
||||
const int ROOT = T - 1; /* root position */
|
||||
const int T = N_CHAR * 2 - 1; /* Size of table */
|
||||
const int ROOT = T - 1; /* root position */
|
||||
const int MAX_FREQ = 0x8000;
|
||||
|
||||
/*
|
||||
@@ -158,6 +153,9 @@ public class TeleDiskLzh
|
||||
_inStream = dataStream;
|
||||
}
|
||||
|
||||
/// <summary>Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.</summary>
|
||||
public static bool IsSupported => true;
|
||||
|
||||
/* DeCompression
|
||||
|
||||
split out initialization code to init_Decode()
|
||||
@@ -258,7 +256,7 @@ public class TeleDiskLzh
|
||||
if(NextWord() < 0)
|
||||
return -1;
|
||||
|
||||
short i = (short)_getbuf;
|
||||
var i = (short)_getbuf;
|
||||
_getbuf <<= 1;
|
||||
_getlen--;
|
||||
|
||||
@@ -333,7 +331,7 @@ public class TeleDiskLzh
|
||||
for(k = (short)(j - 1); f < _freq[k]; k--) {}
|
||||
|
||||
k++;
|
||||
ushort l = (ushort)((j - k) * 2);
|
||||
var l = (ushort)((j - k) * 2);
|
||||
|
||||
Array.ConstrainedCopy(_freq, k, _freq, k + 1, l);
|
||||
_freq[k] = f;
|
||||
@@ -396,7 +394,7 @@ public class TeleDiskLzh
|
||||
|
||||
short DecodeChar()
|
||||
{
|
||||
ushort c = (ushort)_son[ROOT];
|
||||
var c = (ushort)_son[ROOT];
|
||||
|
||||
/*
|
||||
* start searching tree from the root to leaves.
|
||||
@@ -428,8 +426,8 @@ public class TeleDiskLzh
|
||||
if((bit = (short)GetByte()) < 0)
|
||||
return -1;
|
||||
|
||||
ushort i = (ushort)bit;
|
||||
ushort c = (ushort)(_dCode[i] << 6);
|
||||
var i = (ushort)bit;
|
||||
var c = (ushort)(_dCode[i] << 6);
|
||||
ushort j = _dLen[i];
|
||||
|
||||
/* input lower 6 bits directly */
|
||||
|
||||
@@ -26,15 +26,13 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.Compression;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class ZSTD
|
||||
{
|
||||
/// <summary>
|
||||
/// Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.
|
||||
/// </summary>
|
||||
/// <summary>Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.</summary>
|
||||
public static bool IsSupported => Native.IsSupported;
|
||||
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
|
||||
Submodule Aaru.Console updated: 2deb65967a...b9a1ad4cb1
@@ -1,230 +1,219 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{679659B8-25D0-4279-B632-56EF8F94ADC0}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Aaru.Core</RootNamespace>
|
||||
<AssemblyName>Aaru.Core</AssemblyName>
|
||||
<ReleaseVersion>$(Version)</ReleaseVersion>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>6.0.0-alpha8</Version>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>Copyright © 2011-2022 Natalia Portillo</Copyright>
|
||||
<Product>Aaru Data Preservation Suite</Product>
|
||||
<Title>Aaru.Core</Title>
|
||||
<ApplicationVersion>$(Version)</ApplicationVersion>
|
||||
<TargetFramework>net6</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<Description>Contains core algorithms used by the Aaru Data Preservation Suite.</Description>
|
||||
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
|
||||
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
|
||||
<RepositoryUrl>https://github.com/aaru-dps/Aaru</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Authors>Natalia Portillo <claunia@claunia.com></Authors>
|
||||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
|
||||
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\net6</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\net6</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\CdiReady.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Data.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Dump.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Error.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\LeadOuts.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Offset.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Plextor.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Pregap.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Subchannel.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Tags.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Tracks.cs" />
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Trim.cs" />
|
||||
<Compile Include="Devices\Dumping\Dump.cs" />
|
||||
<Compile Include="Devices\Dumping\LinearMemory\Retrode.cs" />
|
||||
<Compile Include="Devices\Dumping\Metadata.cs" />
|
||||
<Compile Include="Devices\Dumping\MiniDisc.cs" />
|
||||
<Compile Include="Devices\Dumping\PlayStationPortable\MemoryStick.cs" />
|
||||
<Compile Include="Devices\Dumping\PlayStationPortable\PlayStationPortable.cs" />
|
||||
<Compile Include="Devices\Dumping\PlayStationPortable\UMD.cs" />
|
||||
<Compile Include="Devices\Dumping\Sbc\Data.cs" />
|
||||
<Compile Include="Devices\Dumping\Sbc\Error.cs" />
|
||||
<Compile Include="Devices\Dumping\Sbc\Dump.cs" />
|
||||
<Compile Include="Devices\Dumping\Sbc\Optical.cs" />
|
||||
<Compile Include="Devices\Dumping\Sbc\Trim.cs" />
|
||||
<Compile Include="Devices\Info\DeviceInfo.cs" />
|
||||
<Compile Include="Devices\Info\Plextor.cs" />
|
||||
<Compile Include="Devices\Info\Properties.cs" />
|
||||
<Compile Include="Devices\Report\DeviceReport.cs" />
|
||||
<Compile Include="Devices\Report\GdRomSwapTrick.cs" />
|
||||
<Compile Include="Devices\Report\Scsi.cs" />
|
||||
<Compile Include="Devices\Report\MMC.cs" />
|
||||
<Compile Include="Devices\Report\SSC.cs" />
|
||||
<Compile Include="Devices\Scanning\MediaScan.cs" />
|
||||
<Compile Include="Entropy.cs" />
|
||||
<Compile Include="GetPluginBase.cs" />
|
||||
<Compile Include="ImageInfo.cs" />
|
||||
<Compile Include="Logging\ErrorLog.cs" />
|
||||
<Compile Include="Logging\SubchannelLog.cs" />
|
||||
<Compile Include="Media\CompactDisc.cs" />
|
||||
<Compile Include="Media\Detection\MMC.cs" />
|
||||
<Compile Include="Media\Info\CompactDisc.cs" />
|
||||
<Compile Include="Media\Info\ScsiInfo.cs" />
|
||||
<Compile Include="Media\Info\XgdInfo.cs" />
|
||||
<Compile Include="Options.cs" />
|
||||
<Compile Include="ImageFormat.cs" />
|
||||
<Compile Include="Error.cs" />
|
||||
<Compile Include="PrintScsiModePages.cs" />
|
||||
<Compile Include="Sidecar\Files.cs" />
|
||||
<Compile Include="Spectre.cs" />
|
||||
<Compile Include="Statistics.cs" />
|
||||
<Compile Include="Checksum.cs" />
|
||||
<Compile Include="Logging\IBGLog.cs" />
|
||||
<Compile Include="Logging\MHDDLog.cs" />
|
||||
<Compile Include="Devices\Scanning\ATA.cs" />
|
||||
<Compile Include="Devices\Scanning\SecureDigital.cs" />
|
||||
<Compile Include="Devices\Scanning\NVMe.cs" />
|
||||
<Compile Include="Devices\Scanning\SCSI.cs" />
|
||||
<Compile Include="Devices\Dumping\ATA.cs" />
|
||||
<Compile Include="Devices\Dumping\NVMe.cs" />
|
||||
<Compile Include="Devices\Dumping\SCSI.cs" />
|
||||
<Compile Include="Devices\Dumping\SecureDigital.cs" />
|
||||
<Compile Include="DataFile.cs" />
|
||||
<Compile Include="Filesystems.cs" />
|
||||
<Compile Include="Devices\Scanning\ScanResults.cs" />
|
||||
<Compile Include="Devices\Report\ATA.cs" />
|
||||
<Compile Include="Devices\Report\FireWire.cs" />
|
||||
<Compile Include="Devices\Report\USB.cs" />
|
||||
<Compile Include="Devices\Report\SecureDigital.cs" />
|
||||
<Compile Include="Remote.cs" />
|
||||
<Compile Include="Devices\Report\PCMCIA.cs" />
|
||||
<Compile Include="Devices\Reader.cs" />
|
||||
<Compile Include="Devices\ReaderATA.cs" />
|
||||
<Compile Include="Devices\ReaderSCSI.cs" />
|
||||
<Compile Include="Devices\Dumping\SSC.cs" />
|
||||
<Compile Include="Devices\Dumping\MMC.cs" />
|
||||
<Compile Include="Devices\Dumping\XGD.cs" />
|
||||
<Compile Include="Devices\Dumping\ResumeSupport.cs" />
|
||||
<Compile Include="Partitions.cs" />
|
||||
<Compile Include="Sidecar\Events.cs" />
|
||||
<Compile Include="Sidecar\Helpers.cs" />
|
||||
<Compile Include="Sidecar\Sidecar.cs" />
|
||||
<Compile Include="Sidecar\OpticalDisc.cs" />
|
||||
<Compile Include="Sidecar\BlockMedia.cs" />
|
||||
<Compile Include="Sidecar\LinearMedia.cs" />
|
||||
<Compile Include="Sidecar\AudioMedia.cs" />
|
||||
<Compile Include="Sidecar\BlockTape.cs" />
|
||||
<Compile Include="Logging\DumpLog.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.Archives\Aaru.Archives.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Database\Aaru.Database.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Decryption\Aaru.Decryption.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Dto\Aaru.Dto.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Filesystems\Aaru.Filesystems.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Partitions\Aaru.Partitions.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Filters\Aaru.Filters.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Settings\Aaru.Settings.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Devices\Aaru.Devices.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Decoders\Aaru.Decoders.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj">
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Logging\" />
|
||||
<Folder Include="Devices\" />
|
||||
<Folder Include="Devices\Scanning\" />
|
||||
<Folder Include="Devices\Dumping\" />
|
||||
<Folder Include="Devices\Report\" />
|
||||
<Folder Include="Sidecar\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup></ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\LICENSE">
|
||||
<Link>LICENSE</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Spectre.Console" Version="0.43.0" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.2" PrivateAssets="all" />
|
||||
<PackageReference Include="System.Collections" Version="4.3.0" />
|
||||
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
|
||||
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
|
||||
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
|
||||
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
|
||||
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" NewLineForMembersInObjectInit="False" NewLineForMembersInAnonymousTypes="False" NewLineForClausesInQuery="False" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp" />
|
||||
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">
|
||||
<!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
|
||||
<!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
|
||||
<!-- Look in the standard install locations -->
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<!-- If we found Mono reference assemblies, then use them -->
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net40'">$(BaseFrameworkPathOverrideForMono)/4.0-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
|
||||
<EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
|
||||
<!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
|
||||
<AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{679659B8-25D0-4279-B632-56EF8F94ADC0}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Aaru.Core</RootNamespace>
|
||||
<AssemblyName>Aaru.Core</AssemblyName>
|
||||
<ReleaseVersion>$(Version)</ReleaseVersion>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>6.0.0-alpha8</Version>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>Copyright © 2011-2022 Natalia Portillo</Copyright>
|
||||
<Product>Aaru Data Preservation Suite</Product>
|
||||
<Title>Aaru.Core</Title>
|
||||
<ApplicationVersion>$(Version)</ApplicationVersion>
|
||||
<TargetFramework>net6</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<Description>Contains core algorithms used by the Aaru Data Preservation Suite.</Description>
|
||||
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
|
||||
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
|
||||
<RepositoryUrl>https://github.com/aaru-dps/Aaru</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Authors>Natalia Portillo <claunia@claunia.com></Authors>
|
||||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
|
||||
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\net6</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\net6</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\CdiReady.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Data.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Dump.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Error.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\LeadOuts.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Offset.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Plextor.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Pregap.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Subchannel.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Tags.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Tracks.cs"/>
|
||||
<Compile Include="Devices\Dumping\CompactDisc\Trim.cs"/>
|
||||
<Compile Include="Devices\Dumping\Dump.cs"/>
|
||||
<Compile Include="Devices\Dumping\LinearMemory\Retrode.cs"/>
|
||||
<Compile Include="Devices\Dumping\Metadata.cs"/>
|
||||
<Compile Include="Devices\Dumping\MiniDisc.cs"/>
|
||||
<Compile Include="Devices\Dumping\PlayStationPortable\MemoryStick.cs"/>
|
||||
<Compile Include="Devices\Dumping\PlayStationPortable\PlayStationPortable.cs"/>
|
||||
<Compile Include="Devices\Dumping\PlayStationPortable\UMD.cs"/>
|
||||
<Compile Include="Devices\Dumping\Sbc\Data.cs"/>
|
||||
<Compile Include="Devices\Dumping\Sbc\Error.cs"/>
|
||||
<Compile Include="Devices\Dumping\Sbc\Dump.cs"/>
|
||||
<Compile Include="Devices\Dumping\Sbc\Optical.cs"/>
|
||||
<Compile Include="Devices\Dumping\Sbc\Trim.cs"/>
|
||||
<Compile Include="Devices\Info\DeviceInfo.cs"/>
|
||||
<Compile Include="Devices\Info\Plextor.cs"/>
|
||||
<Compile Include="Devices\Info\Properties.cs"/>
|
||||
<Compile Include="Devices\Report\DeviceReport.cs"/>
|
||||
<Compile Include="Devices\Report\GdRomSwapTrick.cs"/>
|
||||
<Compile Include="Devices\Report\Scsi.cs"/>
|
||||
<Compile Include="Devices\Report\MMC.cs"/>
|
||||
<Compile Include="Devices\Report\SSC.cs"/>
|
||||
<Compile Include="Devices\Scanning\MediaScan.cs"/>
|
||||
<Compile Include="Entropy.cs"/>
|
||||
<Compile Include="GetPluginBase.cs"/>
|
||||
<Compile Include="ImageInfo.cs"/>
|
||||
<Compile Include="Logging\ErrorLog.cs"/>
|
||||
<Compile Include="Logging\SubchannelLog.cs"/>
|
||||
<Compile Include="Media\CompactDisc.cs"/>
|
||||
<Compile Include="Media\Detection\MMC.cs"/>
|
||||
<Compile Include="Media\Info\CompactDisc.cs"/>
|
||||
<Compile Include="Media\Info\ScsiInfo.cs"/>
|
||||
<Compile Include="Media\Info\XgdInfo.cs"/>
|
||||
<Compile Include="Options.cs"/>
|
||||
<Compile Include="ImageFormat.cs"/>
|
||||
<Compile Include="Error.cs"/>
|
||||
<Compile Include="PrintScsiModePages.cs"/>
|
||||
<Compile Include="Sidecar\Files.cs"/>
|
||||
<Compile Include="Spectre.cs"/>
|
||||
<Compile Include="Statistics.cs"/>
|
||||
<Compile Include="Checksum.cs"/>
|
||||
<Compile Include="Logging\IBGLog.cs"/>
|
||||
<Compile Include="Logging\MHDDLog.cs"/>
|
||||
<Compile Include="Devices\Scanning\ATA.cs"/>
|
||||
<Compile Include="Devices\Scanning\SecureDigital.cs"/>
|
||||
<Compile Include="Devices\Scanning\NVMe.cs"/>
|
||||
<Compile Include="Devices\Scanning\SCSI.cs"/>
|
||||
<Compile Include="Devices\Dumping\ATA.cs"/>
|
||||
<Compile Include="Devices\Dumping\NVMe.cs"/>
|
||||
<Compile Include="Devices\Dumping\SCSI.cs"/>
|
||||
<Compile Include="Devices\Dumping\SecureDigital.cs"/>
|
||||
<Compile Include="DataFile.cs"/>
|
||||
<Compile Include="Filesystems.cs"/>
|
||||
<Compile Include="Devices\Scanning\ScanResults.cs"/>
|
||||
<Compile Include="Devices\Report\ATA.cs"/>
|
||||
<Compile Include="Devices\Report\FireWire.cs"/>
|
||||
<Compile Include="Devices\Report\USB.cs"/>
|
||||
<Compile Include="Devices\Report\SecureDigital.cs"/>
|
||||
<Compile Include="Remote.cs"/>
|
||||
<Compile Include="Devices\Report\PCMCIA.cs"/>
|
||||
<Compile Include="Devices\Reader.cs"/>
|
||||
<Compile Include="Devices\ReaderATA.cs"/>
|
||||
<Compile Include="Devices\ReaderSCSI.cs"/>
|
||||
<Compile Include="Devices\Dumping\SSC.cs"/>
|
||||
<Compile Include="Devices\Dumping\MMC.cs"/>
|
||||
<Compile Include="Devices\Dumping\XGD.cs"/>
|
||||
<Compile Include="Devices\Dumping\ResumeSupport.cs"/>
|
||||
<Compile Include="Partitions.cs"/>
|
||||
<Compile Include="Sidecar\Events.cs"/>
|
||||
<Compile Include="Sidecar\Helpers.cs"/>
|
||||
<Compile Include="Sidecar\Sidecar.cs"/>
|
||||
<Compile Include="Sidecar\OpticalDisc.cs"/>
|
||||
<Compile Include="Sidecar\BlockMedia.cs"/>
|
||||
<Compile Include="Sidecar\LinearMedia.cs"/>
|
||||
<Compile Include="Sidecar\AudioMedia.cs"/>
|
||||
<Compile Include="Sidecar\BlockTape.cs"/>
|
||||
<Compile Include="Logging\DumpLog.cs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.Archives\Aaru.Archives.csproj"/>
|
||||
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Database\Aaru.Database.csproj"/>
|
||||
<ProjectReference Include="..\Aaru.Decryption\Aaru.Decryption.csproj"/>
|
||||
<ProjectReference Include="..\Aaru.Dto\Aaru.Dto.csproj"/>
|
||||
<ProjectReference Include="..\Aaru.Filesystems\Aaru.Filesystems.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Partitions\Aaru.Partitions.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Filters\Aaru.Filters.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Settings\Aaru.Settings.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Devices\Aaru.Devices.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Decoders\Aaru.Decoders.csproj"></ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj"></ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Logging\"/>
|
||||
<Folder Include="Devices\"/>
|
||||
<Folder Include="Devices\Scanning\"/>
|
||||
<Folder Include="Devices\Dumping\"/>
|
||||
<Folder Include="Devices\Report\"/>
|
||||
<Folder Include="Sidecar\"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup></ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\LICENSE">
|
||||
<Link>LICENSE</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Spectre.Console" Version="0.43.0"/>
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0"/>
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.2" PrivateAssets="all"/>
|
||||
<PackageReference Include="System.Collections" Version="4.3.0"/>
|
||||
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0"/>
|
||||
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0"/>
|
||||
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1"/>
|
||||
<PackageReference Include="System.Runtime.Handles" Version="4.3.0"/>
|
||||
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0"/>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp"/>
|
||||
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" NewLineForMembersInObjectInit="False" NewLineForMembersInAnonymousTypes="False" NewLineForClausesInQuery="False" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp"/>
|
||||
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild"/>
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">
|
||||
<!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
|
||||
<!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
|
||||
<!-- Look in the standard install locations -->
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
|
||||
<!-- If we found Mono reference assemblies, then use them -->
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net40'">$(BaseFrameworkPathOverrideForMono)/4.0-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
|
||||
<EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
|
||||
<!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
|
||||
<AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
@@ -37,8 +39,6 @@ using Aaru.Checksums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Enabled checksums</summary>
|
||||
[Flags]
|
||||
public enum EnableChecksum
|
||||
@@ -68,8 +68,7 @@ public enum EnableChecksum
|
||||
/// <summary>Enables Fletcher-32</summary>
|
||||
Fletcher32 = 4096,
|
||||
/// <summary>Enables all known checksums</summary>
|
||||
All = Adler32 | Crc16 | Crc32 | Crc64 | Md5 | Sha1 | Sha256 | Sha384 | Sha512 | SpamSum | Fletcher16 |
|
||||
Fletcher32
|
||||
All = Adler32 | Crc16 | Crc32 | Crc64 | Md5 | Sha1 | Sha256 | Sha384 | Sha512 | SpamSum | Fletcher16 | Fletcher32
|
||||
}
|
||||
|
||||
/// <summary>Checksums and hashes data, with different algorithms, multithreaded</summary>
|
||||
@@ -383,7 +382,7 @@ public sealed class Checksum
|
||||
/// <returns>Returns the checksum results</returns>
|
||||
public List<ChecksumType> End()
|
||||
{
|
||||
List<ChecksumType> chks = new List<ChecksumType>();
|
||||
var chks = new List<ChecksumType>();
|
||||
|
||||
ChecksumType chk;
|
||||
|
||||
@@ -719,8 +718,8 @@ public sealed class Checksum
|
||||
f16ThreadData.IsAlive ||
|
||||
f32ThreadData.IsAlive) {}
|
||||
|
||||
List<ChecksumType> dataChecksums = new List<ChecksumType>();
|
||||
ChecksumType chk;
|
||||
var dataChecksums = new List<ChecksumType>();
|
||||
ChecksumType chk;
|
||||
|
||||
if(enabled.HasFlag(EnableChecksum.Adler32))
|
||||
{
|
||||
|
||||
@@ -30,15 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Abstracts a datafile with a block based interface</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global"),
|
||||
SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
[SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global"), SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public sealed class DataFile
|
||||
{
|
||||
readonly FileStream _dataFs;
|
||||
@@ -90,8 +89,7 @@ public sealed class DataFile
|
||||
/// <param name="data">Data</param>
|
||||
/// <param name="block">Block</param>
|
||||
/// <param name="blockSize">Bytes per block</param>
|
||||
public void WriteAt(byte[] data, ulong block, uint blockSize) =>
|
||||
WriteAt(data, block, blockSize, 0, data.Length);
|
||||
public void WriteAt(byte[] data, ulong block, uint blockSize) => WriteAt(data, block, blockSize, 0, data.Length);
|
||||
|
||||
/// <summary>Writes data at specified block</summary>
|
||||
/// <param name="data">Data</param>
|
||||
@@ -114,8 +112,7 @@ public sealed class DataFile
|
||||
/// <param name="outputPrefix">First part of the file name</param>
|
||||
/// <param name="outputSuffix">Last part of the file name</param>
|
||||
/// <param name="whatWriting">What is the data about?</param>
|
||||
public static void WriteTo(string who, string outputPrefix, string outputSuffix, string whatWriting,
|
||||
byte[] data)
|
||||
public static void WriteTo(string who, string outputPrefix, string outputSuffix, string whatWriting, byte[] data)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(outputPrefix) &&
|
||||
!string.IsNullOrEmpty(outputSuffix))
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -39,6 +41,7 @@ using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Core.Devices.Report;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.ATA;
|
||||
@@ -48,8 +51,6 @@ using Identify = Aaru.CommonTypes.Structs.Devices.ATA.Identify;
|
||||
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
/// <summary>Implements dumping ATA devices</summary>
|
||||
public partial class Dump
|
||||
{
|
||||
@@ -151,8 +152,8 @@ public partial class Dump
|
||||
UpdateStatus?.Invoke($"Device reports {physicalSectorSize} bytes per physical block.");
|
||||
_dumpLog.WriteLine("Device reports {0} blocks ({1} bytes).", blocks, blocks * blockSize);
|
||||
|
||||
_dumpLog.WriteLine("Device reports {0} cylinders {1} heads {2} sectors per track.", cylinders,
|
||||
heads, sectors);
|
||||
_dumpLog.WriteLine("Device reports {0} cylinders {1} heads {2} sectors per track.", cylinders, heads,
|
||||
sectors);
|
||||
|
||||
_dumpLog.WriteLine("Device can read {0} blocks at a time.", blocksToRead);
|
||||
_dumpLog.WriteLine("Device reports {0} bytes per logical block.", blockSize);
|
||||
@@ -164,9 +165,9 @@ public partial class Dump
|
||||
DumpHardwareType currentTry = null;
|
||||
ExtentsULong extents = null;
|
||||
|
||||
ResumeSupport.Process(ataReader.IsLba, removable, blocks, _dev.Manufacturer, _dev.Model,
|
||||
_dev.Serial, _dev.PlatformId, ref _resume, ref currentTry, ref extents,
|
||||
_dev.FirmwareRevision, _private, _force);
|
||||
ResumeSupport.Process(ataReader.IsLba, removable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
|
||||
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
|
||||
_private, _force);
|
||||
|
||||
if(currentTry == null ||
|
||||
extents == null)
|
||||
@@ -180,7 +181,7 @@ public partial class Dump
|
||||
IbgLog ibgLog;
|
||||
double duration;
|
||||
|
||||
bool ret = true;
|
||||
var ret = true;
|
||||
|
||||
if(_dev.IsUsb &&
|
||||
_dev.UsbDescriptors != null &&
|
||||
@@ -232,8 +233,8 @@ public partial class Dump
|
||||
_dumpLog.WriteLine("Error creating output image, not continuing.");
|
||||
_dumpLog.WriteLine(outputFormat.ErrorMessage);
|
||||
|
||||
StoppingErrorMessage?.Invoke("Error creating output image, not continuing." +
|
||||
Environment.NewLine + outputFormat.ErrorMessage);
|
||||
StoppingErrorMessage?.Invoke("Error creating output image, not continuing." + Environment.NewLine +
|
||||
outputFormat.ErrorMessage);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -259,7 +260,7 @@ public partial class Dump
|
||||
_dumpLog.WriteLine("Resuming from block {0}.", _resume.NextBlock);
|
||||
}
|
||||
|
||||
bool newTrim = false;
|
||||
var newTrim = false;
|
||||
|
||||
start = DateTime.UtcNow;
|
||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||
@@ -288,8 +289,8 @@ public partial class Dump
|
||||
currentSpeed > 0)
|
||||
minSpeed = currentSpeed;
|
||||
|
||||
UpdateProgress?.Invoke($"Reading sector {i} of {blocks} ({currentSpeed:F3} MiB/sec.)",
|
||||
(long)i, (long)blocks);
|
||||
UpdateProgress?.Invoke($"Reading sector {i} of {blocks} ({currentSpeed:F3} MiB/sec.)", (long)i,
|
||||
(long)blocks);
|
||||
|
||||
bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _);
|
||||
|
||||
@@ -410,11 +411,11 @@ public partial class Dump
|
||||
!_aborted &&
|
||||
_retryPasses > 0)
|
||||
{
|
||||
int pass = 1;
|
||||
bool forward = true;
|
||||
var pass = 1;
|
||||
var forward = true;
|
||||
|
||||
InitProgress?.Invoke();
|
||||
repeatRetryLba:
|
||||
repeatRetryLba:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
|
||||
foreach(ulong badSector in tmpArray)
|
||||
@@ -520,14 +521,12 @@ public partial class Dump
|
||||
ibgLog.Write(currentBlock, currentSpeed * 1024);
|
||||
DateTime writeStart = DateTime.Now;
|
||||
|
||||
outputFormat.WriteSector(cmdBuf,
|
||||
(ulong)((((cy * heads) + hd) * sectors) + (sc - 1)));
|
||||
outputFormat.WriteSector(cmdBuf, (ulong)((cy * heads + hd) * sectors + (sc - 1)));
|
||||
|
||||
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
||||
extents.Add(currentBlock);
|
||||
|
||||
_dumpLog.WriteLine("Error reading cylinder {0} head {1} sector {2}.", cy, hd,
|
||||
sc);
|
||||
_dumpLog.WriteLine("Error reading cylinder {0} head {1} sector {2}.", cy, hd, sc);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -538,7 +537,7 @@ public partial class Dump
|
||||
DateTime writeStart = DateTime.Now;
|
||||
|
||||
outputFormat.WriteSector(new byte[blockSize],
|
||||
(ulong)((((cy * heads) + hd) * sectors) + (sc - 1)));
|
||||
(ulong)((cy * heads + hd) * sectors + (sc - 1)));
|
||||
|
||||
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
||||
}
|
||||
@@ -590,7 +589,7 @@ public partial class Dump
|
||||
outputFormat.SetDumpHardware(_resume.Tries);
|
||||
|
||||
// TODO: Non-removable
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
var metadata = new ImageInfo
|
||||
{
|
||||
Application = "Aaru",
|
||||
ApplicationVersion = Version.GetVersion()
|
||||
@@ -637,7 +636,7 @@ public partial class Dump
|
||||
UpdateStatus?.Invoke("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
var inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -41,12 +49,6 @@ using Aaru.Decoders.CD;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Detects if a sector contains data</summary>
|
||||
@@ -62,7 +64,7 @@ partial class Dump
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00
|
||||
};
|
||||
|
||||
byte[] testMark = new byte[12];
|
||||
var testMark = new byte[12];
|
||||
Array.Copy(sector, 0, testMark, 0, 12);
|
||||
|
||||
return syncMark.SequenceEqual(testMark) && (sector[0xF] == 0 || sector[0xF] == 1 || sector[0xF] == 2);
|
||||
@@ -85,14 +87,14 @@ partial class Dump
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00
|
||||
};
|
||||
|
||||
byte[] testMark = new byte[12];
|
||||
var testMark = new byte[12];
|
||||
|
||||
for(int i = 0; i <= 2336; i++)
|
||||
for(var i = 0; i <= 2336; i++)
|
||||
{
|
||||
Array.Copy(sector, i, testMark, 0, 12);
|
||||
|
||||
if(!syncMark.SequenceEqual(testMark) ||
|
||||
(sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62))
|
||||
sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62)
|
||||
continue;
|
||||
|
||||
// De-scramble M and S
|
||||
@@ -101,17 +103,17 @@ partial class Dump
|
||||
int frame = sector[i + 14];
|
||||
|
||||
// Convert to binary
|
||||
minute = (minute / 16 * 10) + (minute & 0x0F);
|
||||
second = (second / 16 * 10) + (second & 0x0F);
|
||||
frame = (frame / 16 * 10) + (frame & 0x0F);
|
||||
minute = minute / 16 * 10 + (minute & 0x0F);
|
||||
second = second / 16 * 10 + (second & 0x0F);
|
||||
frame = frame / 16 * 10 + (frame & 0x0F);
|
||||
|
||||
// Calculate the first found LBA
|
||||
int lba = (minute * 60 * 75) + (second * 75) + frame - 150;
|
||||
int lba = minute * 60 * 75 + second * 75 + frame - 150;
|
||||
|
||||
// Calculate the difference between the found LBA and the requested one
|
||||
int diff = wantedLba - lba;
|
||||
|
||||
offset = i + (2352 * diff);
|
||||
offset = i + 2352 * diff;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -147,12 +149,12 @@ partial class Dump
|
||||
/// <param name="subchannelExtents">List of subchannels not yet dumped correctly</param>
|
||||
/// <param name="smallestPregapLbaPerTrack">List of smallest pregap relative address per track</param>
|
||||
void ReadCdiReady(uint blockSize, ref double currentSpeed, DumpHardwareType currentTry, ExtentsULong extents,
|
||||
IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents,
|
||||
ref double maxSpeed, MhddLog mhddLog, ref double minSpeed, uint subSize,
|
||||
MmcSubchannel supportedSubchannel, ref double totalDuration, Track[] tracks,
|
||||
SubchannelLog subLog, MmcSubchannel desiredSubchannel, Dictionary<byte, string> isrcs,
|
||||
ref string mcn, HashSet<int> subchannelExtents, ulong blocks, bool cdiReadyReadAsAudio,
|
||||
int offsetBytes, int sectorsForOffset, Dictionary<byte, int> smallestPregapLbaPerTrack)
|
||||
IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, ref double maxSpeed,
|
||||
MhddLog mhddLog, ref double minSpeed, uint subSize, MmcSubchannel supportedSubchannel,
|
||||
ref double totalDuration, Track[] tracks, SubchannelLog subLog, MmcSubchannel desiredSubchannel,
|
||||
Dictionary<byte, string> isrcs, ref string mcn, HashSet<int> subchannelExtents, ulong blocks,
|
||||
bool cdiReadyReadAsAudio, int offsetBytes, int sectorsForOffset,
|
||||
Dictionary<byte, int> smallestPregapLbaPerTrack)
|
||||
{
|
||||
ulong sectorSpeedStart = 0; // Used to calculate correct speed
|
||||
DateTime timeSpeedStart = DateTime.UtcNow; // Time of start for speed calculation
|
||||
@@ -189,7 +191,7 @@ partial class Dump
|
||||
break;
|
||||
}
|
||||
|
||||
uint firstSectorToRead = (uint)i;
|
||||
var firstSectorToRead = (uint)i;
|
||||
|
||||
blocksToRead = _maximumReadable;
|
||||
|
||||
@@ -197,7 +199,6 @@ partial class Dump
|
||||
blocksToRead += (uint)sectorsForOffset;
|
||||
|
||||
if(cdiReadyReadAsAudio)
|
||||
{
|
||||
if(offsetBytes < 0)
|
||||
{
|
||||
if(i == 0)
|
||||
@@ -205,7 +206,6 @@ partial class Dump
|
||||
else
|
||||
firstSectorToRead -= (uint)sectorsForOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if(currentSpeed > maxSpeed &&
|
||||
currentSpeed > 0)
|
||||
@@ -228,16 +228,14 @@ partial class Dump
|
||||
|
||||
// Overcome the track mode change drive error
|
||||
if(sense)
|
||||
{
|
||||
for(uint r = 0; r < _maximumReadable; r++)
|
||||
{
|
||||
UpdateProgress?.Invoke($"Reading sector {i + r} of {blocks} ({currentSpeed:F3} MiB/sec.)",
|
||||
(long)i + r, (long)blocks);
|
||||
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(i + r), blockSize,
|
||||
(uint)sectorsForOffset + 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(i + r), blockSize, (uint)sectorsForOffset + 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
|
||||
@@ -255,8 +253,8 @@ partial class Dump
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
byte[] data = new byte[sectorSize];
|
||||
byte[] sub = new byte[subSize];
|
||||
var data = new byte[sectorSize];
|
||||
var sub = new byte[subSize];
|
||||
|
||||
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
|
||||
|
||||
@@ -275,16 +273,14 @@ partial class Dump
|
||||
// Set tracks and go back
|
||||
if(indexesChanged)
|
||||
{
|
||||
(outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList());
|
||||
outputOptical.SetTracks(tracks.ToList());
|
||||
i -= _maximumReadable;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outputOptical.WriteSectorsLong(cmdBuf, i + r, 1);
|
||||
}
|
||||
|
||||
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
||||
}
|
||||
@@ -316,7 +312,6 @@ partial class Dump
|
||||
sectorSpeedStart = 0;
|
||||
timeSpeedStart = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
@@ -332,22 +327,22 @@ partial class Dump
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
byte[] data = new byte[sectorSize * blocksToRead];
|
||||
byte[] sub = new byte[subSize * blocksToRead];
|
||||
byte[] tmpData = new byte[sectorSize];
|
||||
var data = new byte[sectorSize * blocksToRead];
|
||||
var sub = new byte[subSize * blocksToRead];
|
||||
var tmpData = new byte[sectorSize];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
if(cdiReadyReadAsAudio)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), tmpData, 0, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), tmpData, 0, sectorSize);
|
||||
tmpData = Sector.Scramble(tmpData);
|
||||
Array.Copy(tmpData, 0, data, sectorSize * b, sectorSize);
|
||||
}
|
||||
else
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize);
|
||||
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize);
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize);
|
||||
}
|
||||
|
||||
outputOptical.WriteSectorsLong(data, i, blocksToRead);
|
||||
@@ -360,7 +355,7 @@ partial class Dump
|
||||
// Set tracks and go back
|
||||
if(indexesChanged)
|
||||
{
|
||||
(outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList());
|
||||
outputOptical.SetTracks(tracks.ToList());
|
||||
i -= blocksToRead;
|
||||
|
||||
continue;
|
||||
@@ -370,10 +365,10 @@ partial class Dump
|
||||
{
|
||||
if(cdiReadyReadAsAudio)
|
||||
{
|
||||
byte[] tmpData = new byte[sectorSize];
|
||||
byte[] data = new byte[sectorSize * blocksToRead];
|
||||
var tmpData = new byte[sectorSize];
|
||||
var data = new byte[sectorSize * blocksToRead];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(b * sectorSize), tmpData, 0, sectorSize);
|
||||
tmpData = Sector.Scramble(tmpData);
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -45,12 +53,6 @@ using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Reads all CD user data</summary>
|
||||
@@ -100,7 +102,7 @@ partial class Dump
|
||||
ulong sectorSpeedStart = 0; // Used to calculate correct speed
|
||||
DateTime timeSpeedStart = DateTime.UtcNow; // Time of start for speed calculation
|
||||
uint blocksToRead; // How many sectors to read at once
|
||||
bool sense = true; // Sense indicator
|
||||
var sense = true; // Sense indicator
|
||||
byte[] cmdBuf = null; // Data buffer
|
||||
byte[] senseBuf = null; // Sense buffer
|
||||
double cmdDuration = 0; // Command execution time
|
||||
@@ -131,10 +133,10 @@ partial class Dump
|
||||
|
||||
InitProgress?.Invoke();
|
||||
|
||||
int currentReadSpeed = _speed;
|
||||
bool crossingLeadOut = false;
|
||||
bool failedCrossingLeadOut = false;
|
||||
bool skippingLead = false;
|
||||
int currentReadSpeed = _speed;
|
||||
var crossingLeadOut = false;
|
||||
var failedCrossingLeadOut = false;
|
||||
var skippingLead = false;
|
||||
|
||||
for(ulong i = _resume.NextBlock; (long)i <= lastSector; i += blocksToRead)
|
||||
{
|
||||
@@ -156,7 +158,7 @@ partial class Dump
|
||||
if((long)i > lastSector)
|
||||
break;
|
||||
|
||||
uint firstSectorToRead = (uint)i;
|
||||
var firstSectorToRead = (uint)i;
|
||||
|
||||
Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => i >= t.StartSector);
|
||||
|
||||
@@ -221,7 +223,6 @@ partial class Dump
|
||||
}
|
||||
|
||||
if(_fixOffset && !inData)
|
||||
{
|
||||
if(offsetBytes < 0)
|
||||
{
|
||||
if(i == 0)
|
||||
@@ -232,7 +233,6 @@ partial class Dump
|
||||
if(blocksToRead <= sectorsForOffset)
|
||||
blocksToRead += (uint)sectorsForOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if(!inData &&
|
||||
currentReadSpeed == 0xFFFF)
|
||||
@@ -249,8 +249,7 @@ partial class Dump
|
||||
{
|
||||
_dumpLog.WriteLine($"Setting speed to {(_speed == 0xFFFF ? "MAX for data reading" : $"{_speed}x")}.");
|
||||
|
||||
UpdateStatus?.
|
||||
Invoke($"Setting speed to {(_speed == 0xFFFF ? "MAX for data reading" : $"{_speed}x")}.");
|
||||
UpdateStatus?.Invoke($"Setting speed to {(_speed == 0xFFFF ? "MAX for data reading" : $"{_speed}x")}.");
|
||||
|
||||
_speed *= _speedMultiplier;
|
||||
|
||||
@@ -288,8 +287,8 @@ partial class Dump
|
||||
|
||||
if(_supportsPlextorD8 && !inData)
|
||||
{
|
||||
sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, firstSectorToRead, blockSize,
|
||||
blocksToRead, supportedPlextorSubchannel, out cmdDuration);
|
||||
sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead,
|
||||
supportedPlextorSubchannel, out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
}
|
||||
@@ -298,9 +297,8 @@ partial class Dump
|
||||
if(inData)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout,
|
||||
out cmdDuration);
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
@@ -309,13 +307,13 @@ partial class Dump
|
||||
// Try to workaround firmware
|
||||
if(decSense?.ASC == 0x64)
|
||||
{
|
||||
bool goBackTrackTypeChange = false;
|
||||
var goBackTrackTypeChange = false;
|
||||
|
||||
// Go one for one as the drive does not tell us which one failed
|
||||
for(int bi = 0; bi < blocksToRead; bi++)
|
||||
for(var bi = 0; bi < blocksToRead; bi++)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(firstSectorToRead + bi),
|
||||
blockSize, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(firstSectorToRead + bi), blockSize,
|
||||
1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out double cmdDuration2);
|
||||
|
||||
@@ -367,13 +365,13 @@ partial class Dump
|
||||
DecodedSense? decSense = Sense.Decode(senseBuf);
|
||||
|
||||
// Try to workaround firmware
|
||||
if((decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05) ||
|
||||
if(decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05 ||
|
||||
decSense?.ASC == 0x64)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out _, firstSectorToRead, blockSize, blocksToRead,
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out double cmdDuration2);
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout,
|
||||
out double cmdDuration2);
|
||||
|
||||
cmdDuration += cmdDuration2;
|
||||
}
|
||||
@@ -383,25 +381,17 @@ partial class Dump
|
||||
totalDuration += cmdDuration;
|
||||
}
|
||||
else if(read16)
|
||||
{
|
||||
sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, false, false, firstSectorToRead, blockSize,
|
||||
0, blocksToRead, false, _dev.Timeout, out cmdDuration);
|
||||
}
|
||||
sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, false, false, firstSectorToRead, blockSize, 0,
|
||||
blocksToRead, false, _dev.Timeout, out cmdDuration);
|
||||
else if(read12)
|
||||
{
|
||||
sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, false, false, false, firstSectorToRead,
|
||||
blockSize, 0, blocksToRead, false, _dev.Timeout, out cmdDuration);
|
||||
}
|
||||
else if(read10)
|
||||
{
|
||||
sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, false, false, false, firstSectorToRead,
|
||||
blockSize, 0, (ushort)blocksToRead, _dev.Timeout, out cmdDuration);
|
||||
}
|
||||
else if(read6)
|
||||
{
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, (byte)blocksToRead,
|
||||
_dev.Timeout, out cmdDuration);
|
||||
}
|
||||
|
||||
double elapsed;
|
||||
|
||||
@@ -417,7 +407,7 @@ partial class Dump
|
||||
|
||||
if(_supportsPlextorD8)
|
||||
{
|
||||
int adjustment = 0;
|
||||
var adjustment = 0;
|
||||
|
||||
if(offsetBytes < 0)
|
||||
adjustment = -sectorsForOffset;
|
||||
@@ -431,7 +421,7 @@ partial class Dump
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
uint sectorsForFix = (uint)(1 + sectorsForOffset);
|
||||
var sectorsForFix = (uint)(1 + sectorsForOffset);
|
||||
|
||||
FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel,
|
||||
ref sectorsForFix, subSize, ref cmdBuf, blockSize, false);
|
||||
@@ -450,25 +440,17 @@ partial class Dump
|
||||
totalDuration += cmdDuration;
|
||||
}
|
||||
else if(read16)
|
||||
{
|
||||
sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, true, false, i + r, blockSize, 0, 1,
|
||||
false, _dev.Timeout, out cmdDuration);
|
||||
}
|
||||
else if(read12)
|
||||
{
|
||||
sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)(i + r),
|
||||
blockSize, 0, 1, false, _dev.Timeout, out cmdDuration);
|
||||
}
|
||||
else if(read10)
|
||||
{
|
||||
sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)(i + r),
|
||||
blockSize, 0, 1, _dev.Timeout, out cmdDuration);
|
||||
}
|
||||
else if(read6)
|
||||
{
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)(i + r), blockSize, 1, _dev.Timeout,
|
||||
out cmdDuration);
|
||||
}
|
||||
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
@@ -480,8 +462,8 @@ partial class Dump
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
byte[] data = new byte[sectorSize];
|
||||
byte[] sub = new byte[subSize];
|
||||
var data = new byte[sectorSize];
|
||||
var sub = new byte[subSize];
|
||||
|
||||
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
|
||||
|
||||
@@ -491,12 +473,12 @@ partial class Dump
|
||||
outputFormat.WriteSectorsLong(data, i + r, 1);
|
||||
else
|
||||
{
|
||||
var cooked = new MemoryStream();
|
||||
byte[] sector = new byte[sectorSize];
|
||||
var cooked = new MemoryStream();
|
||||
var sector = new byte[sectorSize];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), sector, 0, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), sector, 0, sectorSize);
|
||||
byte[] cookedSector = Sector.GetUserData(sector);
|
||||
cooked.Write(cookedSector, 0, cookedSector.Length);
|
||||
}
|
||||
@@ -505,10 +487,10 @@ partial class Dump
|
||||
}
|
||||
|
||||
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
|
||||
desiredSubchannel, sub, i + r, 1, subLog, isrcs, (byte)track.Sequence,
|
||||
ref mcn, tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage,
|
||||
_fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus,
|
||||
smallestPregapLbaPerTrack, true);
|
||||
desiredSubchannel, sub, i + r, 1, subLog, isrcs, (byte)track.Sequence, ref mcn,
|
||||
tracks, subchannelExtents, _fixSubchannelPosition,
|
||||
outputFormat as IWritableOpticalImage, _fixSubchannel, _fixSubchannelCrc, _dumpLog,
|
||||
UpdateStatus, smallestPregapLbaPerTrack, true);
|
||||
|
||||
// Set tracks and go back
|
||||
if(indexesChanged)
|
||||
@@ -525,10 +507,10 @@ partial class Dump
|
||||
outputFormat.WriteSectorsLong(cmdBuf, i + r, 1);
|
||||
else
|
||||
{
|
||||
var cooked = new MemoryStream();
|
||||
byte[] sector = new byte[sectorSize];
|
||||
var cooked = new MemoryStream();
|
||||
var sector = new byte[sectorSize];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(b * sectorSize), sector, 0, sectorSize);
|
||||
byte[] cookedSector = Sector.GetUserData(sector);
|
||||
@@ -603,7 +585,7 @@ partial class Dump
|
||||
{
|
||||
if(crossingLeadOut && failedCrossingLeadOut)
|
||||
{
|
||||
byte[] tmp = new byte[cmdBuf.Length + blockSize];
|
||||
var tmp = new byte[cmdBuf.Length + blockSize];
|
||||
Array.Copy(cmdBuf, 0, tmp, 0, cmdBuf.Length);
|
||||
}
|
||||
|
||||
@@ -621,26 +603,26 @@ partial class Dump
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
byte[] data = new byte[sectorSize * blocksToRead];
|
||||
byte[] sub = new byte[subSize * blocksToRead];
|
||||
var data = new byte[sectorSize * blocksToRead];
|
||||
var sub = new byte[subSize * blocksToRead];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize);
|
||||
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize);
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize);
|
||||
}
|
||||
|
||||
if(supportsLongSectors)
|
||||
outputFormat.WriteSectorsLong(data, i, blocksToRead);
|
||||
else
|
||||
{
|
||||
var cooked = new MemoryStream();
|
||||
byte[] sector = new byte[sectorSize];
|
||||
var cooked = new MemoryStream();
|
||||
var sector = new byte[sectorSize];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), sector, 0, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), sector, 0, sectorSize);
|
||||
byte[] cookedSector = Sector.GetUserData(sector);
|
||||
cooked.Write(cookedSector, 0, cookedSector.Length);
|
||||
}
|
||||
@@ -649,8 +631,8 @@ partial class Dump
|
||||
}
|
||||
|
||||
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
|
||||
desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, (byte)track.Sequence,
|
||||
ref mcn, tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage,
|
||||
desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, (byte)track.Sequence, ref mcn,
|
||||
tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage,
|
||||
_fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack,
|
||||
true);
|
||||
|
||||
@@ -669,10 +651,10 @@ partial class Dump
|
||||
outputFormat.WriteSectorsLong(cmdBuf, i, blocksToRead);
|
||||
else
|
||||
{
|
||||
var cooked = new MemoryStream();
|
||||
byte[] sector = new byte[sectorSize];
|
||||
var cooked = new MemoryStream();
|
||||
var sector = new byte[sectorSize];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(b * sectorSize), sector, 0, sectorSize);
|
||||
byte[] cookedSector = Sector.GetUserData(sector);
|
||||
@@ -721,9 +703,7 @@ partial class Dump
|
||||
else
|
||||
{
|
||||
if(supportsLongSectors)
|
||||
{
|
||||
outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, _skip);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cmdBuf.Length % sectorSize == 0)
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -49,12 +57,6 @@ using Schemas;
|
||||
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
/// <summary>Implement dumping Compact Discs</summary>
|
||||
|
||||
// TODO: Barcode
|
||||
@@ -84,22 +86,22 @@ sealed partial class Dump
|
||||
MhddLog mhddLog; // MHDD log
|
||||
double minSpeed = double.MaxValue; // Minimum speed
|
||||
bool newTrim; // Is trim a new one?
|
||||
int offsetBytes = 0; // Read offset
|
||||
bool read6 = false; // Device supports READ(6)
|
||||
bool read10 = false; // Device supports READ(10)
|
||||
bool read12 = false; // Device supports READ(12)
|
||||
bool read16 = false; // Device supports READ(16)
|
||||
var offsetBytes = 0; // Read offset
|
||||
var read6 = false; // Device supports READ(6)
|
||||
var read10 = false; // Device supports READ(10)
|
||||
var read12 = false; // Device supports READ(12)
|
||||
var read16 = false; // Device supports READ(16)
|
||||
bool readcd; // Device supports READ CD
|
||||
bool ret; // Image writing return status
|
||||
const uint sectorSize = 2352; // Full sector size
|
||||
int sectorsForOffset = 0; // Sectors needed to fix offset
|
||||
bool sense = true; // Sense indicator
|
||||
var sectorsForOffset = 0; // Sectors needed to fix offset
|
||||
var sense = true; // Sense indicator
|
||||
int sessions; // Number of sessions in disc
|
||||
DateTime start; // Start of operation
|
||||
SubchannelLog subLog = null; // Subchannel log
|
||||
uint subSize; // Subchannel size in bytes
|
||||
TrackSubchannelType subType; // Track subchannel type
|
||||
bool supportsLongSectors = true; // Supports reading EDC and ECC
|
||||
var supportsLongSectors = true; // Supports reading EDC and ECC
|
||||
bool supportsPqSubchannel; // Supports reading PQ subchannel
|
||||
bool supportsRwSubchannel; // Supports reading RW subchannel
|
||||
byte[] tmpBuf; // Temporary buffer
|
||||
@@ -111,11 +113,11 @@ sealed partial class Dump
|
||||
bool hiddenTrack; // Disc has a hidden track before track 1
|
||||
MmcSubchannel supportedSubchannel; // Drive's maximum supported subchannel
|
||||
MmcSubchannel desiredSubchannel; // User requested subchannel
|
||||
bool bcdSubchannel = false; // Subchannel positioning is in BCD
|
||||
var bcdSubchannel = false; // Subchannel positioning is in BCD
|
||||
Dictionary<byte, string> isrcs = new();
|
||||
string mcn = null;
|
||||
HashSet<int> subchannelExtents = new();
|
||||
bool cdiReadyReadAsAudio = false;
|
||||
var cdiReadyReadAsAudio = false;
|
||||
uint firstLba;
|
||||
var outputOptical = _outputPlugin as IWritableOpticalImage;
|
||||
|
||||
@@ -247,8 +249,8 @@ sealed partial class Dump
|
||||
_dumpLog.WriteLine("Checking if drive supports reading without subchannel...");
|
||||
UpdateStatus?.Invoke("Checking if drive supports reading without subchannel...");
|
||||
|
||||
readcd = !_dev.ReadCd(out cmdBuf, out _, firstLba, sectorSize, 1, MmcSectorTypes.AllTypes, false,
|
||||
false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
readcd = !_dev.ReadCd(out cmdBuf, out _, firstLba, sectorSize, 1, MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out _);
|
||||
|
||||
if(!readcd)
|
||||
@@ -268,8 +270,8 @@ sealed partial class Dump
|
||||
_dumpLog.WriteLine("Checking if drive supports READ(12)...");
|
||||
UpdateStatus?.Invoke("Checking if drive supports READ(12)...");
|
||||
|
||||
read12 = !_dev.Read12(out cmdBuf, out _, 0, false, true, false, false, firstLba, 2048, 0, 1,
|
||||
false, _dev.Timeout, out _);
|
||||
read12 = !_dev.Read12(out cmdBuf, out _, 0, false, true, false, false, firstLba, 2048, 0, 1, false,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
_dumpLog.WriteLine("Checking if drive supports READ(16)...");
|
||||
UpdateStatus?.Invoke("Checking if drive supports READ(16)...");
|
||||
@@ -368,9 +370,9 @@ sealed partial class Dump
|
||||
// Check if subchannel is BCD
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out _, (((firstLba / 75) + 1) * 75) + 35, blockSize, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, supportedSubchannel, _dev.Timeout, out _);
|
||||
sense = _dev.ReadCd(out cmdBuf, out _, (firstLba / 75 + 1) * 75 + 35, blockSize, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
@@ -417,8 +419,7 @@ sealed partial class Dump
|
||||
Invoke("WARNING: The drive has returned incorrect Q positioning when calculating pregaps. A best effort has been tried but they may be incorrect.");
|
||||
}
|
||||
|
||||
if(!(outputOptical as IWritableOpticalImage).OpticalCapabilities.HasFlag(OpticalImageCapabilities.
|
||||
CanStoreRawData))
|
||||
if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreRawData))
|
||||
{
|
||||
if(!_force)
|
||||
{
|
||||
@@ -436,8 +437,7 @@ sealed partial class Dump
|
||||
Invoke("Output format does not support storing raw data, this may end in a loss of data, continuing...");
|
||||
}
|
||||
|
||||
if(!(outputOptical as IWritableOpticalImage).OpticalCapabilities.HasFlag(OpticalImageCapabilities.
|
||||
CanStoreAudioTracks) &&
|
||||
if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreAudioTracks) &&
|
||||
tracks.Any(track => track.Type == TrackType.Audio))
|
||||
{
|
||||
_dumpLog.WriteLine("Output format does not support audio tracks, cannot continue...");
|
||||
@@ -447,8 +447,7 @@ sealed partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(outputOptical as IWritableOpticalImage).OpticalCapabilities.HasFlag(OpticalImageCapabilities.
|
||||
CanStorePregaps) &&
|
||||
if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStorePregaps) &&
|
||||
tracks.Where(track => track.Sequence != tracks.First(t => t.Session == track.Session).Sequence).
|
||||
Any(track => track.Pregap > 0))
|
||||
{
|
||||
@@ -468,7 +467,7 @@ sealed partial class Dump
|
||||
Invoke("Output format does not support pregaps, this may end in a loss of data, continuing...");
|
||||
}
|
||||
|
||||
for(int t = 1; t < tracks.Length; t++)
|
||||
for(var t = 1; t < tracks.Length; t++)
|
||||
tracks[t - 1].EndSector = tracks[t].StartSector - 1;
|
||||
|
||||
tracks[^1].EndSector = (ulong)lastSector;
|
||||
@@ -495,8 +494,7 @@ sealed partial class Dump
|
||||
// Read media tags
|
||||
ReadCdTags(ref dskType, mediaTags, out sessions, out firstTrackLastSession);
|
||||
|
||||
if(!(outputOptical as IWritableOpticalImage).OpticalCapabilities.HasFlag(OpticalImageCapabilities.
|
||||
CanStoreSessions) &&
|
||||
if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreSessions) &&
|
||||
sessions > 1)
|
||||
{
|
||||
// TODO: Disabled until 6.0
|
||||
@@ -518,7 +516,6 @@ sealed partial class Dump
|
||||
|
||||
// Check if output format supports all disc tags we have retrieved so far
|
||||
foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputOptical.SupportedMediaTags.Contains(tag)))
|
||||
{
|
||||
if(_force)
|
||||
{
|
||||
_dumpLog.WriteLine("Output format does not support {0}, continuing...", tag);
|
||||
@@ -531,7 +528,6 @@ sealed partial class Dump
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(leadOutStarts.Any())
|
||||
{
|
||||
@@ -549,7 +545,7 @@ sealed partial class Dump
|
||||
|
||||
Tuple<ulong, ulong>[] dataExtentsArray = dataExtents.ToArray();
|
||||
|
||||
for(int i = 0; i < dataExtentsArray.Length - 1; i++)
|
||||
for(var i = 0; i < dataExtentsArray.Length - 1; i++)
|
||||
leadOutExtents.Add(dataExtentsArray[i].Item2 + 1, dataExtentsArray[i + 1].Item1 - 1);
|
||||
}
|
||||
|
||||
@@ -618,7 +614,7 @@ sealed partial class Dump
|
||||
continue;
|
||||
}
|
||||
|
||||
int bufOffset = 0;
|
||||
var bufOffset = 0;
|
||||
|
||||
while(cmdBuf[0 + bufOffset] != 0x00 ||
|
||||
cmdBuf[1 + bufOffset] != 0xFF ||
|
||||
@@ -719,7 +715,6 @@ sealed partial class Dump
|
||||
|
||||
// Check if something prevents from dumping the first track pregap
|
||||
if(_dumpFirstTrackPregap && readcd)
|
||||
{
|
||||
if(!outputOptical.SupportedMediaTags.Contains(MediaTagType.CD_FirstTrackPregap))
|
||||
{
|
||||
if(_force)
|
||||
@@ -739,24 +734,23 @@ sealed partial class Dump
|
||||
|
||||
_dumpFirstTrackPregap = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Try how many blocks are readable at once
|
||||
while(true)
|
||||
{
|
||||
if(readcd)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out _, firstLba, blockSize, _maximumReadable,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out _);
|
||||
sense = _dev.ReadCd(out cmdBuf, out _, firstLba, blockSize, _maximumReadable, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out _);
|
||||
|
||||
if(_dev.Error || sense)
|
||||
_maximumReadable /= 2;
|
||||
}
|
||||
else if(read16)
|
||||
{
|
||||
sense = _dev.Read16(out cmdBuf, out _, 0, false, true, false, firstLba, blockSize, 0,
|
||||
_maximumReadable, false, _dev.Timeout, out _);
|
||||
sense = _dev.Read16(out cmdBuf, out _, 0, false, true, false, firstLba, blockSize, 0, _maximumReadable,
|
||||
false, _dev.Timeout, out _);
|
||||
|
||||
if(_dev.Error || sense)
|
||||
_maximumReadable /= 2;
|
||||
@@ -779,8 +773,7 @@ sealed partial class Dump
|
||||
}
|
||||
else if(read6)
|
||||
{
|
||||
sense = _dev.Read6(out cmdBuf, out _, firstLba, blockSize, (byte)_maximumReadable, _dev.Timeout,
|
||||
out _);
|
||||
sense = _dev.Read6(out cmdBuf, out _, firstLba, blockSize, (byte)_maximumReadable, _dev.Timeout, out _);
|
||||
|
||||
if(_dev.Error || sense)
|
||||
_maximumReadable /= 2;
|
||||
@@ -835,11 +828,10 @@ sealed partial class Dump
|
||||
if(errno == ErrorNumber.NoError)
|
||||
mcn = Encoding.ASCII.GetString(mcnBytes);
|
||||
|
||||
if((outputOptical as IWritableOpticalImage).Tracks != null)
|
||||
foreach(Track imgTrack in (outputOptical as IWritableOpticalImage).Tracks)
|
||||
if(outputOptical.Tracks != null)
|
||||
foreach(Track imgTrack in outputOptical.Tracks)
|
||||
{
|
||||
errno = (outputOptical as IWritableOpticalImage).ReadSectorTag(imgTrack.Sequence,
|
||||
SectorTagType.CdTrackIsrc, out byte[] isrcBytes);
|
||||
errno = outputOptical.ReadSectorTag(imgTrack.Sequence, SectorTagType.CdTrackIsrc, out byte[] isrcBytes);
|
||||
|
||||
if(errno == ErrorNumber.NoError)
|
||||
isrcs[(byte)imgTrack.Sequence] = Encoding.ASCII.GetString(isrcBytes);
|
||||
@@ -858,7 +850,7 @@ sealed partial class Dump
|
||||
}
|
||||
|
||||
// Send track list to output plugin. This may fail if subchannel is set but unsupported.
|
||||
ret = (outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList());
|
||||
ret = outputOptical.SetTracks(tracks.ToList());
|
||||
|
||||
if(!ret &&
|
||||
desiredSubchannel == MmcSubchannel.None)
|
||||
@@ -866,16 +858,15 @@ sealed partial class Dump
|
||||
_dumpLog.WriteLine("Error sending tracks to output image, not continuing.");
|
||||
_dumpLog.WriteLine(outputOptical.ErrorMessage);
|
||||
|
||||
StoppingErrorMessage?.Invoke("Error sending tracks to output image, not continuing." +
|
||||
Environment.NewLine + outputOptical.ErrorMessage);
|
||||
StoppingErrorMessage?.Invoke("Error sending tracks to output image, not continuing." + Environment.NewLine +
|
||||
outputOptical.ErrorMessage);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If a subchannel is supported, check if output plugin allows us to write it.
|
||||
if(desiredSubchannel != MmcSubchannel.None &&
|
||||
!(outputOptical as IWritableOpticalImage).OpticalCapabilities.HasFlag(OpticalImageCapabilities.
|
||||
CanStoreSubchannelRw))
|
||||
!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreSubchannelRw))
|
||||
{
|
||||
_dumpLog.WriteLine("Output image does not support subchannels, {0}continuing...", _force ? "" : "not ");
|
||||
|
||||
@@ -1009,8 +1000,8 @@ sealed partial class Dump
|
||||
d.Manufacturer == _dev.Manufacturer.Replace('/', '-')) &&
|
||||
(d.Model == _dev.Model || d.Model == _dev.Model.Replace('/', '-')));
|
||||
|
||||
Media.Info.CompactDisc.GetOffset(cdOffset, _dbDev, _debug, _dev, dskType, _dumpLog, tracks, UpdateStatus,
|
||||
out int? driveOffset, out int? combinedOffset, out _supportsPlextorD8);
|
||||
Core.Media.Info.CompactDisc.GetOffset(cdOffset, _dbDev, _debug, _dev, dskType, _dumpLog, tracks, UpdateStatus,
|
||||
out int? driveOffset, out int? combinedOffset, out _supportsPlextorD8);
|
||||
|
||||
if(combinedOffset is null)
|
||||
{
|
||||
@@ -1096,9 +1087,7 @@ sealed partial class Dump
|
||||
audioExtents = new ExtentsULong();
|
||||
|
||||
foreach(Track audioTrack in tracks.Where(t => t.Type == TrackType.Audio))
|
||||
{
|
||||
audioExtents.Add(audioTrack.StartSector, audioTrack.EndSector);
|
||||
}
|
||||
|
||||
// Set speed
|
||||
if(_speedMultiplier >= 0)
|
||||
@@ -1138,8 +1127,7 @@ sealed partial class Dump
|
||||
{
|
||||
_dumpLog.WriteLine("Dumping CD-i Ready requires the drive to support the READ CD command.");
|
||||
|
||||
StoppingErrorMessage?.
|
||||
Invoke("Dumping CD-i Ready requires the drive to support the READ CD command.");
|
||||
StoppingErrorMessage?.Invoke("Dumping CD-i Ready requires the drive to support the READ CD command.");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1184,8 +1172,7 @@ sealed partial class Dump
|
||||
}
|
||||
else
|
||||
{
|
||||
_dumpLog.
|
||||
WriteLine($"Drive reading offset is {driveOffset} bytes ({driveOffset / 4} samples).");
|
||||
_dumpLog.WriteLine($"Drive reading offset is {driveOffset} bytes ({driveOffset / 4} samples).");
|
||||
|
||||
UpdateStatus?.
|
||||
Invoke($"Drive reading offset is {driveOffset} bytes ({driveOffset / 4} samples).");
|
||||
@@ -1210,16 +1197,15 @@ sealed partial class Dump
|
||||
if(_skipCdireadyHole)
|
||||
ReadCdiReady(blockSize, ref currentSpeed, currentTry, extents, ibgLog, ref imageWriteDuration,
|
||||
leadOutExtents, ref maxSpeed, mhddLog, ref minSpeed, subSize, supportedSubchannel,
|
||||
ref totalDuration, tracks, subLog, desiredSubchannel, isrcs, ref mcn,
|
||||
subchannelExtents, blocks, cdiReadyReadAsAudio, offsetBytes, sectorsForOffset,
|
||||
smallestPregapLbaPerTrack);
|
||||
ref totalDuration, tracks, subLog, desiredSubchannel, isrcs, ref mcn, subchannelExtents,
|
||||
blocks, cdiReadyReadAsAudio, offsetBytes, sectorsForOffset, smallestPregapLbaPerTrack);
|
||||
}
|
||||
|
||||
ReadCdData(audioExtents, blocks, blockSize, ref currentSpeed, currentTry, extents, ibgLog,
|
||||
ref imageWriteDuration, lastSector, leadOutExtents, ref maxSpeed, mhddLog, ref minSpeed,
|
||||
out newTrim, tracks[0].Type != TrackType.Audio, offsetBytes, read6, read10, read12, read16,
|
||||
readcd, sectorsForOffset, subSize, supportedSubchannel, supportsLongSectors, ref totalDuration,
|
||||
tracks, subLog, desiredSubchannel, isrcs, ref mcn, subchannelExtents, smallestPregapLbaPerTrack);
|
||||
ref imageWriteDuration, lastSector, leadOutExtents, ref maxSpeed, mhddLog, ref minSpeed, out newTrim,
|
||||
tracks[0].Type != TrackType.Audio, offsetBytes, read6, read10, read12, read16, readcd,
|
||||
sectorsForOffset, subSize, supportedSubchannel, supportsLongSectors, ref totalDuration, tracks,
|
||||
subLog, desiredSubchannel, isrcs, ref mcn, subchannelExtents, smallestPregapLbaPerTrack);
|
||||
|
||||
// TODO: Enable when underlying images support lead-outs
|
||||
/*
|
||||
@@ -1256,21 +1242,19 @@ sealed partial class Dump
|
||||
ref totalDuration, subLog, desiredSubchannel, tracks, isrcs, ref mcn, subchannelExtents,
|
||||
smallestPregapLbaPerTrack);
|
||||
|
||||
RetryCdUserData(audioExtents, blockSize, currentTry, extents, offsetBytes, readcd, sectorsForOffset,
|
||||
subSize, supportedSubchannel, ref totalDuration, subLog, desiredSubchannel, tracks, isrcs,
|
||||
ref mcn, subchannelExtents, smallestPregapLbaPerTrack, supportsLongSectors);
|
||||
RetryCdUserData(audioExtents, blockSize, currentTry, extents, offsetBytes, readcd, sectorsForOffset, subSize,
|
||||
supportedSubchannel, ref totalDuration, subLog, desiredSubchannel, tracks, isrcs, ref mcn,
|
||||
subchannelExtents, smallestPregapLbaPerTrack, supportsLongSectors);
|
||||
|
||||
foreach(Tuple<ulong, ulong> leadoutExtent in leadOutExtents.ToArray())
|
||||
{
|
||||
for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++)
|
||||
subchannelExtents.Remove((int)e);
|
||||
}
|
||||
|
||||
if(subchannelExtents.Count > 0 &&
|
||||
_retryPasses > 0 &&
|
||||
_retrySubchannel)
|
||||
RetrySubchannel(readcd, subSize, supportedSubchannel, ref totalDuration, subLog, desiredSubchannel,
|
||||
tracks, isrcs, ref mcn, subchannelExtents, smallestPregapLbaPerTrack);
|
||||
RetrySubchannel(readcd, subSize, supportedSubchannel, ref totalDuration, subLog, desiredSubchannel, tracks,
|
||||
isrcs, ref mcn, subchannelExtents, smallestPregapLbaPerTrack);
|
||||
|
||||
// Write media tags to image
|
||||
if(!_aborted)
|
||||
@@ -1309,11 +1293,11 @@ sealed partial class Dump
|
||||
if(_generateSubchannels &&
|
||||
outputOptical.SupportedSectorTags.Contains(SectorTagType.CdSectorSubchannel) &&
|
||||
!_aborted)
|
||||
Media.CompactDisc.GenerateSubchannels(subchannelExtents, tracks, trackFlags, blocks, subLog, _dumpLog,
|
||||
InitProgress, UpdateProgress, EndProgress, outputOptical);
|
||||
Core.Media.CompactDisc.GenerateSubchannels(subchannelExtents, tracks, trackFlags, blocks, subLog, _dumpLog,
|
||||
InitProgress, UpdateProgress, EndProgress, outputOptical);
|
||||
|
||||
// TODO: Disc ID
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
var metadata = new ImageInfo
|
||||
{
|
||||
Application = "Aaru",
|
||||
ApplicationVersion = Version.GetVersion()
|
||||
@@ -1331,8 +1315,7 @@ sealed partial class Dump
|
||||
foreach(KeyValuePair<byte, string> isrc in isrcs)
|
||||
{
|
||||
// TODO: Track tags
|
||||
if(!outputOptical.WriteSectorTag(Encoding.ASCII.GetBytes(isrc.Value), isrc.Key,
|
||||
SectorTagType.CdTrackIsrc))
|
||||
if(!outputOptical.WriteSectorTag(Encoding.ASCII.GetBytes(isrc.Value), isrc.Key, SectorTagType.CdTrackIsrc))
|
||||
continue;
|
||||
|
||||
UpdateStatus?.Invoke($"Setting ISRC for track {isrc.Key} to {isrc.Value}");
|
||||
@@ -1367,7 +1350,7 @@ sealed partial class Dump
|
||||
trk.Indexes.Remove(0);
|
||||
}
|
||||
|
||||
(outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList());
|
||||
outputOptical.SetTracks(tracks.ToList());
|
||||
|
||||
_dumpLog.WriteLine("Closing output file.");
|
||||
UpdateStatus?.Invoke("Closing output file.");
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -45,12 +53,6 @@ using Aaru.Devices;
|
||||
using Schemas;
|
||||
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Retried errored sectors in CompactDisc</summary>
|
||||
@@ -72,14 +74,14 @@ partial class Dump
|
||||
/// <param name="mcn">Disc media catalogue number</param>
|
||||
/// <param name="subchannelExtents">List of subchannels not yet dumped correctly</param>
|
||||
/// <param name="smallestPregapLbaPerTrack">List of smallest pregap relative address per track</param>
|
||||
void RetryCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry,
|
||||
ExtentsULong extents, int offsetBytes, bool readcd, int sectorsForOffset, uint subSize,
|
||||
void RetryCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry, ExtentsULong extents,
|
||||
int offsetBytes, bool readcd, int sectorsForOffset, uint subSize,
|
||||
MmcSubchannel supportedSubchannel, ref double totalDuration, SubchannelLog subLog,
|
||||
MmcSubchannel desiredSubchannel, Track[] tracks, Dictionary<byte, string> isrcs,
|
||||
ref string mcn, HashSet<int> subchannelExtents,
|
||||
Dictionary<byte, int> smallestPregapLbaPerTrack, bool supportsLongSectors)
|
||||
{
|
||||
bool sense = true; // Sense indicator
|
||||
var sense = true; // Sense indicator
|
||||
byte[] cmdBuf = null; // Data buffer
|
||||
double cmdDuration; // Command execution time
|
||||
const uint sectorSize = 2352; // Full sector size
|
||||
@@ -112,9 +114,9 @@ partial class Dump
|
||||
_retryPasses <= 0)
|
||||
return;
|
||||
|
||||
int pass = 1;
|
||||
bool forward = true;
|
||||
bool runningPersistent = false;
|
||||
var pass = 1;
|
||||
var forward = true;
|
||||
var runningPersistent = false;
|
||||
|
||||
Modes.ModePage? currentModePage = null;
|
||||
byte[] md6;
|
||||
@@ -129,13 +131,12 @@ partial class Dump
|
||||
|
||||
if(sense)
|
||||
{
|
||||
sense = _dev.ModeSense10(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x01,
|
||||
_dev.Timeout, out _);
|
||||
sense = _dev.ModeSense10(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x01, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
Modes.DecodedMode? dcMode10 =
|
||||
Modes.DecodeMode10(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice);
|
||||
Modes.DecodedMode? dcMode10 = Modes.DecodeMode10(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice);
|
||||
|
||||
if(dcMode10?.Pages != null)
|
||||
foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage =>
|
||||
@@ -148,8 +149,8 @@ partial class Dump
|
||||
Modes.DecodedMode? dcMode6 = Modes.DecodeMode6(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice);
|
||||
|
||||
if(dcMode6?.Pages != null)
|
||||
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
|
||||
modePage.Page == 0x01 && modePage.Subpage == 0x00))
|
||||
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage.Page == 0x01 &&
|
||||
modePage.Subpage == 0x00))
|
||||
currentModePage = modePage;
|
||||
}
|
||||
|
||||
@@ -211,17 +212,15 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
|
||||
}
|
||||
else
|
||||
{
|
||||
runningPersistent = true;
|
||||
}
|
||||
}
|
||||
|
||||
InitProgress?.Invoke();
|
||||
cdRepeatRetry:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
List<ulong> sectorsNotEvenPartial = new List<ulong>();
|
||||
cdRepeatRetry:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
var sectorsNotEvenPartial = new List<ulong>();
|
||||
|
||||
for(int i = 0; i < tmpArray.Length; i++)
|
||||
for(var i = 0; i < tmpArray.Length; i++)
|
||||
{
|
||||
ulong badSector = tmpArray[i];
|
||||
|
||||
@@ -237,20 +236,17 @@ partial class Dump
|
||||
forward ? "forward" : "reverse",
|
||||
runningPersistent ? "recovering partial data, " : ""));
|
||||
|
||||
Track track = tracks.OrderBy(t => t.StartSector).
|
||||
LastOrDefault(t => badSector >= t.StartSector);
|
||||
Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector);
|
||||
|
||||
byte sectorsToReRead = 1;
|
||||
uint badSectorToReRead = (uint)badSector;
|
||||
var badSectorToReRead = (uint)badSector;
|
||||
|
||||
if(_fixOffset &&
|
||||
audioExtents.Contains(badSector) &&
|
||||
offsetBytes != 0)
|
||||
{
|
||||
if(offsetBytes > 0)
|
||||
{
|
||||
badSectorToReRead -= (uint)sectorsForOffset;
|
||||
}
|
||||
|
||||
sectorsToReRead = (byte)(sectorsForOffset + 1);
|
||||
}
|
||||
@@ -275,13 +271,13 @@ partial class Dump
|
||||
DecodedSense? decSense = Sense.Decode(senseBuf);
|
||||
|
||||
// Try to workaround firmware
|
||||
if((decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05) ||
|
||||
if(decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05 ||
|
||||
decSense?.ASC == 0x64)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out _, badSectorToReRead, blockSize, sectorsToReRead,
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out double cmdDuration2);
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout,
|
||||
out double cmdDuration2);
|
||||
|
||||
cmdDuration += cmdDuration2;
|
||||
}
|
||||
@@ -290,16 +286,15 @@ partial class Dump
|
||||
else
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, badSectorToReRead, blockSize, sectorsToReRead,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout,
|
||||
out cmdDuration);
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
DecodedSense? decSense = Sense.Decode(senseBuf);
|
||||
|
||||
// Try to workaround firmware
|
||||
if((decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05) ||
|
||||
if(decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05 ||
|
||||
decSense?.ASC == 0x64)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out _, badSectorToReRead, blockSize, sectorsToReRead,
|
||||
@@ -337,8 +332,8 @@ partial class Dump
|
||||
{
|
||||
uint blocksToRead = sectorsToReRead;
|
||||
|
||||
FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead,
|
||||
subSize, ref cmdBuf, blockSize, false);
|
||||
FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead, subSize,
|
||||
ref cmdBuf, blockSize, false);
|
||||
}
|
||||
|
||||
if(!sense &&
|
||||
@@ -355,8 +350,8 @@ partial class Dump
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
byte[] data = new byte[sectorSize];
|
||||
byte[] sub = new byte[subSize];
|
||||
var data = new byte[sectorSize];
|
||||
var sub = new byte[subSize];
|
||||
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
|
||||
Array.Copy(cmdBuf, sectorSize, sub, 0, subSize);
|
||||
|
||||
@@ -365,16 +360,20 @@ partial class Dump
|
||||
else
|
||||
outputOptical.WriteSector(Sector.GetUserData(data), badSector);
|
||||
|
||||
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
|
||||
desiredSubchannel, sub, badSector, 1, subLog, isrcs, (byte)track.Sequence, ref mcn,
|
||||
tracks, subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel,
|
||||
_fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true);
|
||||
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel,
|
||||
sub, badSector, 1, subLog, isrcs,
|
||||
(byte)track.Sequence, ref mcn, tracks,
|
||||
subchannelExtents,
|
||||
_fixSubchannelPosition, outputOptical,
|
||||
_fixSubchannel, _fixSubchannelCrc,
|
||||
_dumpLog, UpdateStatus,
|
||||
smallestPregapLbaPerTrack, true);
|
||||
|
||||
// Set tracks and go back
|
||||
if(!indexesChanged)
|
||||
continue;
|
||||
|
||||
(outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList());
|
||||
outputOptical.SetTracks(tracks.ToList());
|
||||
i--;
|
||||
}
|
||||
else
|
||||
@@ -448,7 +447,7 @@ partial class Dump
|
||||
|
||||
InitProgress?.Invoke();
|
||||
|
||||
for(int i = 0; i < sectorsNotEvenPartial.Count; i++)
|
||||
for(var i = 0; i < sectorsNotEvenPartial.Count; i++)
|
||||
{
|
||||
ulong badSector = sectorsNotEvenPartial[i];
|
||||
|
||||
@@ -462,8 +461,7 @@ partial class Dump
|
||||
|
||||
PulseProgress?.Invoke($"Trying to get partial data for sector {badSector}");
|
||||
|
||||
Track track = tracks.OrderBy(t => t.StartSector).
|
||||
LastOrDefault(t => badSector >= t.StartSector);
|
||||
Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector);
|
||||
|
||||
if(readcd)
|
||||
{
|
||||
@@ -486,8 +484,8 @@ partial class Dump
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
byte[] data = new byte[sectorSize];
|
||||
byte[] sub = new byte[subSize];
|
||||
var data = new byte[sectorSize];
|
||||
var sub = new byte[subSize];
|
||||
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
|
||||
Array.Copy(cmdBuf, sectorSize, sub, 0, subSize);
|
||||
|
||||
@@ -497,15 +495,14 @@ partial class Dump
|
||||
outputOptical.WriteSector(Sector.GetUserData(data), badSector);
|
||||
|
||||
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
|
||||
desiredSubchannel, sub, badSector, 1, subLog, isrcs, (byte)track.Sequence,
|
||||
ref mcn, tracks, subchannelExtents, _fixSubchannelPosition, outputOptical,
|
||||
_fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus,
|
||||
smallestPregapLbaPerTrack, true);
|
||||
desiredSubchannel, sub, badSector, 1, subLog, isrcs, (byte)track.Sequence, ref mcn,
|
||||
tracks, subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel,
|
||||
_fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true);
|
||||
|
||||
// Set tracks and go back
|
||||
if(indexesChanged)
|
||||
{
|
||||
(outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList());
|
||||
outputOptical.SetTracks(tracks.ToList());
|
||||
i--;
|
||||
}
|
||||
}
|
||||
@@ -563,7 +560,7 @@ partial class Dump
|
||||
Dictionary<byte, string> isrcs, ref string mcn, HashSet<int> subchannelExtents,
|
||||
Dictionary<byte, int> smallestPregapLbaPerTrack)
|
||||
{
|
||||
bool sense = true; // Sense indicator
|
||||
var sense = true; // Sense indicator
|
||||
byte[] cmdBuf = null; // Data buffer
|
||||
double cmdDuration; // Command execution time
|
||||
byte[] senseBuf = null; // Sense buffer
|
||||
@@ -601,12 +598,12 @@ partial class Dump
|
||||
if(_aborted)
|
||||
return;
|
||||
|
||||
int pass = 1;
|
||||
bool forward = true;
|
||||
var pass = 1;
|
||||
var forward = true;
|
||||
|
||||
InitProgress?.Invoke();
|
||||
|
||||
cdRepeatRetry:
|
||||
cdRepeatRetry:
|
||||
|
||||
_resume.BadSubchannels = new List<int>();
|
||||
_resume.BadSubchannels.AddRange(subchannelExtents);
|
||||
@@ -619,10 +616,9 @@ partial class Dump
|
||||
|
||||
foreach(int bs in tmpArray)
|
||||
{
|
||||
uint badSector = (uint)bs;
|
||||
var badSector = (uint)bs;
|
||||
|
||||
Track track = tracks.OrderBy(t => t.StartSector).
|
||||
LastOrDefault(t => badSector >= t.StartSector);
|
||||
Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector);
|
||||
|
||||
if(_aborted)
|
||||
{
|
||||
@@ -646,9 +642,9 @@ partial class Dump
|
||||
else if(readcd)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, startSector, subSize, 5,
|
||||
track.Type == TrackType.Audio ? MmcSectorTypes.Cdda
|
||||
: MmcSectorTypes.AllTypes, false, false, false, MmcHeaderCodes.None, false,
|
||||
false, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
track.Type == TrackType.Audio ? MmcSectorTypes.Cdda : MmcSectorTypes.AllTypes,
|
||||
false, false, false, MmcHeaderCodes.None, false, false, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -41,12 +49,6 @@ using Aaru.Core.Logging;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Dumps inter-session lead-outs</summary>
|
||||
@@ -76,16 +78,16 @@ partial class Dump
|
||||
/// <param name="subchannelExtents">List of subchannels not yet dumped correctly</param>
|
||||
/// <param name="smallestPregapLbaPerTrack">List of smallest pregap relative address per track</param>
|
||||
void DumpCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardwareType currentTry, ExtentsULong extents,
|
||||
IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents,
|
||||
ref double maxSpeed, MhddLog mhddLog, ref double minSpeed, bool read6, bool read10,
|
||||
bool read12, bool read16, bool readcd, MmcSubchannel supportedSubchannel, uint subSize,
|
||||
ref double totalDuration, SubchannelLog subLog, MmcSubchannel desiredSubchannel,
|
||||
Dictionary<byte, string> isrcs, ref string mcn, Track[] tracks,
|
||||
HashSet<int> subchannelExtents, Dictionary<byte, int> smallestPregapLbaPerTrack)
|
||||
IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, ref double maxSpeed,
|
||||
MhddLog mhddLog, ref double minSpeed, bool read6, bool read10, bool read12, bool read16,
|
||||
bool readcd, MmcSubchannel supportedSubchannel, uint subSize, ref double totalDuration,
|
||||
SubchannelLog subLog, MmcSubchannel desiredSubchannel, Dictionary<byte, string> isrcs,
|
||||
ref string mcn, Track[] tracks, HashSet<int> subchannelExtents,
|
||||
Dictionary<byte, int> smallestPregapLbaPerTrack)
|
||||
{
|
||||
byte[] cmdBuf = null; // Data buffer
|
||||
const uint sectorSize = 2352; // Full sector size
|
||||
bool sense = true; // Sense indicator
|
||||
var sense = true; // Sense indicator
|
||||
byte[] senseBuf = null;
|
||||
var outputOptical = _outputPlugin as IWritableOpticalImage;
|
||||
|
||||
@@ -119,9 +121,9 @@ partial class Dump
|
||||
|
||||
if(readcd)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, MmcSectorTypes.AllTypes, false,
|
||||
false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
}
|
||||
@@ -129,14 +131,13 @@ partial class Dump
|
||||
sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, true, false, i, blockSize, 0, 1, false,
|
||||
_dev.Timeout, out cmdDuration);
|
||||
else if(read12)
|
||||
sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize,
|
||||
0, 1, false, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0,
|
||||
1, false, _dev.Timeout, out cmdDuration);
|
||||
else if(read10)
|
||||
sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize,
|
||||
0, 1, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0,
|
||||
1, _dev.Timeout, out cmdDuration);
|
||||
else if(read6)
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, _dev.Timeout,
|
||||
out cmdDuration);
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, _dev.Timeout, out cmdDuration);
|
||||
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
@@ -149,14 +150,14 @@ partial class Dump
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
byte[] data = new byte[sectorSize * _maximumReadable];
|
||||
byte[] sub = new byte[subSize * _maximumReadable];
|
||||
var data = new byte[sectorSize * _maximumReadable];
|
||||
var sub = new byte[subSize * _maximumReadable];
|
||||
|
||||
for(int b = 0; b < _maximumReadable; b++)
|
||||
for(var b = 0; b < _maximumReadable; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize);
|
||||
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize);
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize);
|
||||
}
|
||||
|
||||
outputOptical.WriteSectorsLong(data, i, _maximumReadable);
|
||||
@@ -169,7 +170,7 @@ partial class Dump
|
||||
// Set tracks and go back
|
||||
if(indexesChanged)
|
||||
{
|
||||
(outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList());
|
||||
outputOptical.SetTracks(tracks.ToList());
|
||||
i--;
|
||||
|
||||
continue;
|
||||
@@ -246,16 +247,16 @@ partial class Dump
|
||||
/// <param name="subchannelExtents">List of subchannels not yet dumped correctly</param>
|
||||
/// <param name="smallestPregapLbaPerTrack">List of smallest pregap relative address per track</param>
|
||||
void RetryCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardwareType currentTry, ExtentsULong extents,
|
||||
IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents,
|
||||
ref double maxSpeed, MhddLog mhddLog, ref double minSpeed, bool read6, bool read10,
|
||||
bool read12, bool read16, bool readcd, MmcSubchannel supportedSubchannel, uint subSize,
|
||||
ref double totalDuration, SubchannelLog subLog, MmcSubchannel desiredSubchannel,
|
||||
Dictionary<byte, string> isrcs, ref string mcn, Track[] tracks,
|
||||
HashSet<int> subchannelExtents, Dictionary<byte, int> smallestPregapLbaPerTrack)
|
||||
IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, ref double maxSpeed,
|
||||
MhddLog mhddLog, ref double minSpeed, bool read6, bool read10, bool read12, bool read16,
|
||||
bool readcd, MmcSubchannel supportedSubchannel, uint subSize, ref double totalDuration,
|
||||
SubchannelLog subLog, MmcSubchannel desiredSubchannel, Dictionary<byte, string> isrcs,
|
||||
ref string mcn, Track[] tracks, HashSet<int> subchannelExtents,
|
||||
Dictionary<byte, int> smallestPregapLbaPerTrack)
|
||||
{
|
||||
byte[] cmdBuf = null; // Data buffer
|
||||
const uint sectorSize = 2352; // Full sector size
|
||||
bool sense = true; // Sense indicator
|
||||
var sense = true; // Sense indicator
|
||||
byte[] senseBuf = null;
|
||||
var outputOptical = _outputPlugin as IWritableOpticalImage;
|
||||
|
||||
@@ -288,9 +289,9 @@ partial class Dump
|
||||
|
||||
if(readcd)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, MmcSectorTypes.AllTypes, false,
|
||||
false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
}
|
||||
@@ -298,14 +299,13 @@ partial class Dump
|
||||
sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, true, false, i, blockSize, 0, 1, false,
|
||||
_dev.Timeout, out cmdDuration);
|
||||
else if(read12)
|
||||
sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize,
|
||||
0, 1, false, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0,
|
||||
1, false, _dev.Timeout, out cmdDuration);
|
||||
else if(read10)
|
||||
sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize,
|
||||
0, 1, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0,
|
||||
1, _dev.Timeout, out cmdDuration);
|
||||
else if(read6)
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, _dev.Timeout,
|
||||
out cmdDuration);
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, _dev.Timeout, out cmdDuration);
|
||||
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
@@ -318,14 +318,14 @@ partial class Dump
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
byte[] data = new byte[sectorSize * _maximumReadable];
|
||||
byte[] sub = new byte[subSize * _maximumReadable];
|
||||
var data = new byte[sectorSize * _maximumReadable];
|
||||
var sub = new byte[subSize * _maximumReadable];
|
||||
|
||||
for(int b = 0; b < _maximumReadable; b++)
|
||||
for(var b = 0; b < _maximumReadable; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize);
|
||||
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize);
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize);
|
||||
}
|
||||
|
||||
outputOptical.WriteSectorsLong(data, i, _maximumReadable);
|
||||
@@ -338,7 +338,7 @@ partial class Dump
|
||||
// Set tracks and go back
|
||||
if(indexesChanged)
|
||||
{
|
||||
(outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList());
|
||||
outputOptical.SetTracks(tracks.ToList());
|
||||
i--;
|
||||
|
||||
continue;
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using Aaru.Devices;
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
@@ -39,6 +38,9 @@ using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using Aaru.Devices;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Fix offset in audio/scrambled sectors</summary>
|
||||
@@ -51,27 +53,27 @@ partial class Dump
|
||||
/// <param name="cmdBuf">Data buffer</param>
|
||||
/// <param name="blockSize">Block size in bytes</param>
|
||||
/// <param name="failedCrossingLeadOut">Set if we failed to cross into the Lead-Out</param>
|
||||
static void FixOffsetData(int offsetBytes, uint sectorSize, int sectorsForOffset,
|
||||
MmcSubchannel supportedSubchannel, ref uint blocksToRead, uint subSize,
|
||||
ref byte[] cmdBuf, uint blockSize, bool failedCrossingLeadOut)
|
||||
static void FixOffsetData(int offsetBytes, uint sectorSize, int sectorsForOffset, MmcSubchannel supportedSubchannel,
|
||||
ref uint blocksToRead, uint subSize, ref byte[] cmdBuf, uint blockSize,
|
||||
bool failedCrossingLeadOut)
|
||||
{
|
||||
if(cmdBuf.Length == 0)
|
||||
return;
|
||||
|
||||
int offsetFix = offsetBytes < 0 ? (int)((sectorSize * sectorsForOffset) + offsetBytes) : offsetBytes;
|
||||
int offsetFix = offsetBytes < 0 ? (int)(sectorSize * sectorsForOffset + offsetBytes) : offsetBytes;
|
||||
|
||||
byte[] tmpBuf;
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
// De-interleave subchannel
|
||||
byte[] data = new byte[sectorSize * blocksToRead];
|
||||
byte[] sub = new byte[subSize * blocksToRead];
|
||||
var data = new byte[sectorSize * blocksToRead];
|
||||
var sub = new byte[subSize * blocksToRead];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize);
|
||||
}
|
||||
|
||||
if(failedCrossingLeadOut)
|
||||
@@ -95,10 +97,10 @@ partial class Dump
|
||||
// Re-interleave subchannel
|
||||
cmdBuf = new byte[blockSize * blocksToRead];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(data, sectorSize * b, cmdBuf, (int)(0 + (b * blockSize)), sectorSize);
|
||||
Array.Copy(sub, subSize * b, cmdBuf, (int)(sectorSize + (b * blockSize)), subSize);
|
||||
Array.Copy(data, sectorSize * b, cmdBuf, (int)(0 + b * blockSize), sectorSize);
|
||||
Array.Copy(sub, subSize * b, cmdBuf, (int)(sectorSize + b * blockSize), subSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Reads a sector using Plextor's D8h READ CDDA command with subchannel</summary>
|
||||
@@ -102,12 +102,12 @@ partial class Dump
|
||||
if(sense)
|
||||
return true;
|
||||
|
||||
cmdBuf = new byte[(2352 * blocksToRead) + (subSize * blocksToRead)];
|
||||
cmdBuf = new byte[2352 * blocksToRead + subSize * blocksToRead];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(dataBuf, 2352 * b, cmdBuf, (2352 + subSize) * b, 2352);
|
||||
Array.Copy(subBuf, subSize * b, cmdBuf, ((2352 + subSize) * b) + 2352, subSize);
|
||||
Array.Copy(subBuf, subSize * b, cmdBuf, (2352 + subSize) * b + 2352, subSize);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -42,12 +50,6 @@ using Aaru.Console;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Devices;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
// TODO: Fix offset
|
||||
@@ -65,8 +67,8 @@ partial class Dump
|
||||
double cmdDuration; // Command execution time
|
||||
DateTime timeSpeedStart; // Time of start for speed calculation
|
||||
ulong sectorSpeedStart = 0; // Used to calculate correct speed
|
||||
bool gotFirstTrackPregap = false;
|
||||
int firstTrackPregapSectorsGood = 0;
|
||||
var gotFirstTrackPregap = false;
|
||||
var firstTrackPregapSectorsGood = 0;
|
||||
var firstTrackPregapMs = new MemoryStream();
|
||||
|
||||
_dumpLog.WriteLine("Reading first track pregap");
|
||||
@@ -89,9 +91,9 @@ partial class Dump
|
||||
Invoke($"Trying to read first track pregap sector {firstTrackPregapBlock} ({currentSpeed:F3} MiB/sec.)");
|
||||
|
||||
// ReSharper disable IntVariableOverflowInUncheckedContext
|
||||
sense = _dev.ReadCd(out cmdBuf, out _, (uint)firstTrackPregapBlock, blockSize, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.ReadCd(out cmdBuf, out _, (uint)firstTrackPregapBlock, blockSize, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
|
||||
// ReSharper restore IntVariableOverflowInUncheckedContext
|
||||
|
||||
@@ -142,17 +144,17 @@ partial class Dump
|
||||
/// <param name="dbDev">Database entry for device</param>
|
||||
/// <param name="inexactPositioning">Set if we found the drive does not return the exact subchannel we requested</param>
|
||||
/// <param name="dumping">Set if dumping, otherwise media info</param>
|
||||
public static void SolveTrackPregaps(Device dev, DumpLog dumpLog, UpdateStatusHandler updateStatus,
|
||||
Track[] tracks, bool supportsPqSubchannel, bool supportsRwSubchannel,
|
||||
public static void SolveTrackPregaps(Device dev, DumpLog dumpLog, UpdateStatusHandler updateStatus, Track[] tracks,
|
||||
bool supportsPqSubchannel, bool supportsRwSubchannel,
|
||||
Database.Models.Device dbDev, out bool inexactPositioning, bool dumping)
|
||||
{
|
||||
bool sense = true; // Sense indicator
|
||||
byte[] subBuf = null;
|
||||
int posQ;
|
||||
uint retries;
|
||||
bool? bcd = null;
|
||||
byte[] crc;
|
||||
Dictionary<uint, int> pregaps = new Dictionary<uint, int>();
|
||||
var sense = true; // Sense indicator
|
||||
byte[] subBuf = null;
|
||||
int posQ;
|
||||
uint retries;
|
||||
bool? bcd = null;
|
||||
byte[] crc;
|
||||
var pregaps = new Dictionary<uint, int>();
|
||||
inexactPositioning = false;
|
||||
|
||||
if(!supportsPqSubchannel &&
|
||||
@@ -193,14 +195,14 @@ partial class Dump
|
||||
foreach(Track t in tracks)
|
||||
pregaps[t.Sequence] = 0;
|
||||
|
||||
for(int t = 0; t < tracks.Length; t++)
|
||||
for(var t = 0; t < tracks.Length; t++)
|
||||
{
|
||||
Track track = tracks[t];
|
||||
int trackRetries = 0;
|
||||
var trackRetries = 0;
|
||||
|
||||
// First track of each session has at least 150 sectors of pregap and is not always readable
|
||||
if(tracks.Where(trk => trk.Session == track.Session).OrderBy(trk => trk.Sequence).
|
||||
FirstOrDefault().Sequence == track.Sequence)
|
||||
if(tracks.Where(trk => trk.Session == track.Session).OrderBy(trk => trk.Sequence).FirstOrDefault().
|
||||
Sequence == track.Sequence)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", "Skipping track {0}", track.Sequence);
|
||||
|
||||
@@ -230,27 +232,26 @@ partial class Dump
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", "Track {0}", track.Sequence);
|
||||
|
||||
int lba = (int)track.StartSector - 1;
|
||||
bool pregapFound = false;
|
||||
var pregapFound = false;
|
||||
Track previousTrack = tracks.FirstOrDefault(trk => trk.Sequence == track.Sequence - 1);
|
||||
|
||||
bool goneBack = false;
|
||||
bool goFront = false;
|
||||
bool forward = false;
|
||||
bool crcOk = false;
|
||||
bool previousPregapIsPreviousTrack = false;
|
||||
var goneBack = false;
|
||||
var goFront = false;
|
||||
var forward = false;
|
||||
var crcOk = false;
|
||||
var previousPregapIsPreviousTrack = false;
|
||||
|
||||
// Check if pregap is 0
|
||||
for(retries = 0; retries < 10 && !pregapFound; retries++)
|
||||
{
|
||||
sense = supportsRwSubchannel
|
||||
? GetSectorForPregapRaw(dev, (uint)lba, dbDev, out subBuf,
|
||||
track.Type == TrackType.Audio)
|
||||
: GetSectorForPregapQ16(dev, (uint)lba, out subBuf, track.Type == TrackType.Audio);
|
||||
? GetSectorForPregapRaw(dev, (uint)lba, dbDev, out subBuf, track.Type == TrackType.Audio)
|
||||
: GetSectorForPregapQ16(dev, (uint)lba, out subBuf, track.Type == TrackType.Audio);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", "LBA: {0}, Try {1}, Sense {2}", lba,
|
||||
retries + 1, sense);
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", "LBA: {0}, Try {1}, Sense {2}", lba, retries + 1,
|
||||
sense);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -263,8 +264,8 @@ partial class Dump
|
||||
AaruConsole.DebugWriteLine("Pregap calculator",
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q: {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2], subBuf[3],
|
||||
subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], subBuf[9],
|
||||
subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], subBuf[9], subBuf[10],
|
||||
subBuf[11], crc[0], crc[1]);
|
||||
|
||||
crcOk = crc[0] == subBuf[10] && crc[1] == subBuf[11];
|
||||
|
||||
@@ -285,7 +286,7 @@ partial class Dump
|
||||
subBuf[6] = 0;
|
||||
|
||||
// Fix BCD numbering
|
||||
for(int i = 1; i < 10; i++)
|
||||
for(var i = 1; i < 10; i++)
|
||||
{
|
||||
if((subBuf[i] & 0xF0) > 0xA0)
|
||||
subBuf[i] &= 0x7F;
|
||||
@@ -300,13 +301,11 @@ partial class Dump
|
||||
crcOk = crc[0] == subBuf[10] && crc[1] == subBuf[11];
|
||||
|
||||
if(crcOk)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Pregap calculator",
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q (FIXED): {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2],
|
||||
subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8],
|
||||
subBuf[9], subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
}
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2], subBuf[3],
|
||||
subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], subBuf[9],
|
||||
subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
@@ -317,7 +316,7 @@ partial class Dump
|
||||
if((subBuf[0] & 0xF) != 1)
|
||||
continue;
|
||||
|
||||
posQ = (subBuf[7] * 60 * 75) + (subBuf[8] * 75) + subBuf[9] - 150;
|
||||
posQ = subBuf[7] * 60 * 75 + subBuf[8] * 75 + subBuf[9] - 150;
|
||||
|
||||
if(subBuf[1] != track.Sequence - 1 ||
|
||||
subBuf[2] == 0 ||
|
||||
@@ -343,16 +342,14 @@ partial class Dump
|
||||
sense = supportsRwSubchannel
|
||||
? GetSectorForPregapRaw(dev, (uint)lba - 10, dbDev, out subBuf,
|
||||
track.Type == TrackType.Audio)
|
||||
: GetSectorForPregapQ16(dev, (uint)lba - 10, out subBuf,
|
||||
track.Type == TrackType.Audio);
|
||||
: GetSectorForPregapQ16(dev, (uint)lba - 10, out subBuf, track.Type == TrackType.Audio);
|
||||
|
||||
for(retries = 0; retries < 10; retries++)
|
||||
{
|
||||
sense = supportsRwSubchannel
|
||||
? GetSectorForPregapRaw(dev, (uint)lba, dbDev, out subBuf,
|
||||
track.Type == TrackType.Audio)
|
||||
: GetSectorForPregapQ16(dev, (uint)lba, out subBuf,
|
||||
track.Type == TrackType.Audio);
|
||||
: GetSectorForPregapQ16(dev, (uint)lba, out subBuf, track.Type == TrackType.Audio);
|
||||
|
||||
if(sense)
|
||||
continue;
|
||||
@@ -387,7 +384,7 @@ partial class Dump
|
||||
subBuf[6] = 0;
|
||||
|
||||
// Fix BCD numbering
|
||||
for(int i = 1; i < 10; i++)
|
||||
for(var i = 1; i < 10; i++)
|
||||
{
|
||||
if((subBuf[i] & 0xF0) > 0xA0)
|
||||
subBuf[i] &= 0x7F;
|
||||
@@ -406,9 +403,8 @@ partial class Dump
|
||||
AaruConsole.DebugWriteLine("Pregap calculator",
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q (FIXED): {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2],
|
||||
subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7],
|
||||
subBuf[8], subBuf[9], subBuf[10], subBuf[11], crc[0],
|
||||
crc[1]);
|
||||
subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8],
|
||||
subBuf[9], subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -428,10 +424,8 @@ partial class Dump
|
||||
{
|
||||
if(pregaps[track.Sequence] == 0)
|
||||
{
|
||||
if((previousTrack.Type == TrackType.Audio &&
|
||||
track.Type != TrackType.Audio) ||
|
||||
(previousTrack.Type != TrackType.Audio &&
|
||||
track.Type == TrackType.Audio))
|
||||
if(previousTrack.Type == TrackType.Audio && track.Type != TrackType.Audio ||
|
||||
previousTrack.Type != TrackType.Audio && track.Type == TrackType.Audio)
|
||||
{
|
||||
dumpLog?.
|
||||
WriteLine("Could not read subchannel for this track, supposing 150 sectors.");
|
||||
@@ -537,7 +531,7 @@ partial class Dump
|
||||
previousPregapIsPreviousTrack = false;
|
||||
|
||||
// Pregap according to Q position
|
||||
posQ = (subBuf[7] * 60 * 75) + (subBuf[8] * 75) + subBuf[9] - 150;
|
||||
posQ = subBuf[7] * 60 * 75 + subBuf[8] * 75 + subBuf[9] - 150;
|
||||
int diff = posQ - lba;
|
||||
int pregapQ = (int)track.StartSector - lba;
|
||||
|
||||
@@ -566,8 +560,8 @@ partial class Dump
|
||||
// If CRC is not OK, only accept pregaps less than 10 sectors longer than previously now
|
||||
if(crcOk || pregapQ - pregaps[track.Sequence] < 10)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", "Pregap for track {0}: {1}",
|
||||
track.Sequence, pregapQ);
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", "Pregap for track {0}: {1}", track.Sequence,
|
||||
pregapQ);
|
||||
|
||||
pregaps[track.Sequence] = pregapQ;
|
||||
}
|
||||
@@ -593,14 +587,14 @@ partial class Dump
|
||||
trk.Pregap = (ulong)pregaps[trk.Sequence];
|
||||
|
||||
// Do not reduce pregap, or starting position of session's first track
|
||||
if(tracks.Where(t => t.Session == trk.Session).OrderBy(t => t.Sequence).FirstOrDefault().
|
||||
Sequence == trk.Sequence)
|
||||
if(tracks.Where(t => t.Session == trk.Session).OrderBy(t => t.Sequence).FirstOrDefault().Sequence ==
|
||||
trk.Sequence)
|
||||
continue;
|
||||
|
||||
if(dumping)
|
||||
{
|
||||
// Minus five, to ensure dumping will fix if there is a pregap LBA 0
|
||||
int red = 5;
|
||||
var red = 5;
|
||||
|
||||
while(trk.Pregap > 0 &&
|
||||
red > 0)
|
||||
@@ -652,21 +646,21 @@ partial class Dump
|
||||
|
||||
if(sense)
|
||||
sense = dev.ReadCd(out cmdBuf, out _, lba, 2448, 1, MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Raw,
|
||||
dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout,
|
||||
out _);
|
||||
}
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
byte[] tmpBuf = new byte[96];
|
||||
var tmpBuf = new byte[96];
|
||||
Array.Copy(cmdBuf, 2352, tmpBuf, 0, 96);
|
||||
subBuf = DeinterleaveQ(tmpBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, lba, 96, 1, MmcSectorTypes.AllTypes, false, false, false,
|
||||
MmcHeaderCodes.None, false, false, MmcErrorField.None, MmcSubchannel.Raw,
|
||||
dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, false, false, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(sense)
|
||||
sense = dev.ReadCd(out cmdBuf, out _, lba, 96, 1, MmcSectorTypes.Cdda, false, false, false,
|
||||
@@ -674,14 +668,11 @@ partial class Dump
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
subBuf = DeinterleaveQ(cmdBuf);
|
||||
}
|
||||
else if(dbDev?.ATAPI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true ||
|
||||
dbDev?.SCSI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true ||
|
||||
dev.Manufacturer.ToLowerInvariant() == "plextor")
|
||||
sense = dev.PlextorReadCdDa(out cmdBuf, out _, lba, 96, 1, PlextorSubchannel.All, dev.Timeout,
|
||||
out _);
|
||||
sense = dev.PlextorReadCdDa(out cmdBuf, out _, lba, 96, 1, PlextorSubchannel.All, dev.Timeout, out _);
|
||||
|
||||
{
|
||||
if(!sense)
|
||||
@@ -723,8 +714,8 @@ partial class Dump
|
||||
|
||||
if(sense)
|
||||
sense = dev.ReadCd(out cmdBuf, out _, lba, 2368, 1, MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Q16,
|
||||
dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Q16, dev.Timeout,
|
||||
out _);
|
||||
}
|
||||
|
||||
if(!sense)
|
||||
@@ -735,8 +726,8 @@ partial class Dump
|
||||
else
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, lba, 16, 1, MmcSectorTypes.AllTypes, false, false, false,
|
||||
MmcHeaderCodes.None, false, false, MmcErrorField.None, MmcSubchannel.Q16,
|
||||
dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, false, false, MmcErrorField.None, MmcSubchannel.Q16, dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(sense)
|
||||
sense = dev.ReadCd(out cmdBuf, out _, lba, 16, 1, MmcSectorTypes.Cdda, false, false, false,
|
||||
@@ -755,10 +746,10 @@ partial class Dump
|
||||
/// <returns>De-interleaved Q subchannel</returns>
|
||||
static byte[] DeinterleaveQ(byte[] subchannel)
|
||||
{
|
||||
int[] q = new int[subchannel.Length / 8];
|
||||
var q = new int[subchannel.Length / 8];
|
||||
|
||||
// De-interlace Q subchannel
|
||||
for(int iq = 0; iq < subchannel.Length; iq += 8)
|
||||
for(var iq = 0; iq < subchannel.Length; iq += 8)
|
||||
{
|
||||
q[iq / 8] = (subchannel[iq] & 0x40) << 1;
|
||||
q[iq / 8] += subchannel[iq + 1] & 0x40;
|
||||
@@ -770,12 +761,10 @@ partial class Dump
|
||||
q[iq / 8] += (subchannel[iq + 7] & 0x40) >> 6;
|
||||
}
|
||||
|
||||
byte[] deQ = new byte[q.Length];
|
||||
var deQ = new byte[q.Length];
|
||||
|
||||
for(int iq = 0; iq < q.Length; iq++)
|
||||
{
|
||||
for(var iq = 0; iq < q.Length; iq++)
|
||||
deQ[iq] = (byte)q[iq];
|
||||
}
|
||||
|
||||
return deQ;
|
||||
}
|
||||
@@ -784,29 +773,29 @@ partial class Dump
|
||||
/// <param name="q">Q subchannel</param>
|
||||
static void BinaryToBcdQ(byte[] q)
|
||||
{
|
||||
q[1] = (byte)(((q[1] / 10) << 4) + (q[1] % 10));
|
||||
q[2] = (byte)(((q[2] / 10) << 4) + (q[2] % 10));
|
||||
q[3] = (byte)(((q[3] / 10) << 4) + (q[3] % 10));
|
||||
q[4] = (byte)(((q[4] / 10) << 4) + (q[4] % 10));
|
||||
q[5] = (byte)(((q[5] / 10) << 4) + (q[5] % 10));
|
||||
q[6] = (byte)(((q[6] / 10) << 4) + (q[6] % 10));
|
||||
q[7] = (byte)(((q[7] / 10) << 4) + (q[7] % 10));
|
||||
q[8] = (byte)(((q[8] / 10) << 4) + (q[8] % 10));
|
||||
q[9] = (byte)(((q[9] / 10) << 4) + (q[9] % 10));
|
||||
q[1] = (byte)(((q[1] / 10) << 4) + q[1] % 10);
|
||||
q[2] = (byte)(((q[2] / 10) << 4) + q[2] % 10);
|
||||
q[3] = (byte)(((q[3] / 10) << 4) + q[3] % 10);
|
||||
q[4] = (byte)(((q[4] / 10) << 4) + q[4] % 10);
|
||||
q[5] = (byte)(((q[5] / 10) << 4) + q[5] % 10);
|
||||
q[6] = (byte)(((q[6] / 10) << 4) + q[6] % 10);
|
||||
q[7] = (byte)(((q[7] / 10) << 4) + q[7] % 10);
|
||||
q[8] = (byte)(((q[8] / 10) << 4) + q[8] % 10);
|
||||
q[9] = (byte)(((q[9] / 10) << 4) + q[9] % 10);
|
||||
}
|
||||
|
||||
/// <summary>In place converts Q subchannel from BCD to binary numbering</summary>
|
||||
/// <param name="q">Q subchannel</param>
|
||||
static void BcdToBinaryQ(byte[] q)
|
||||
{
|
||||
q[1] = (byte)((q[1] / 16 * 10) + (q[1] & 0x0F));
|
||||
q[2] = (byte)((q[2] / 16 * 10) + (q[2] & 0x0F));
|
||||
q[3] = (byte)((q[3] / 16 * 10) + (q[3] & 0x0F));
|
||||
q[4] = (byte)((q[4] / 16 * 10) + (q[4] & 0x0F));
|
||||
q[5] = (byte)((q[5] / 16 * 10) + (q[5] & 0x0F));
|
||||
q[6] = (byte)((q[6] / 16 * 10) + (q[6] & 0x0F));
|
||||
q[7] = (byte)((q[7] / 16 * 10) + (q[7] & 0x0F));
|
||||
q[8] = (byte)((q[8] / 16 * 10) + (q[8] & 0x0F));
|
||||
q[9] = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F));
|
||||
q[1] = (byte)(q[1] / 16 * 10 + (q[1] & 0x0F));
|
||||
q[2] = (byte)(q[2] / 16 * 10 + (q[2] & 0x0F));
|
||||
q[3] = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F));
|
||||
q[4] = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F));
|
||||
q[5] = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F));
|
||||
q[6] = (byte)(q[6] / 16 * 10 + (q[6] & 0x0F));
|
||||
q[7] = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F));
|
||||
q[8] = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F));
|
||||
q[9] = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
}
|
||||
}
|
||||
@@ -30,9 +30,7 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Devices;
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
@@ -40,6 +38,10 @@ using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Devices;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Check if the drive can read RW raw subchannel</summary>
|
||||
@@ -54,8 +56,8 @@ partial class Dump
|
||||
updateStatus?.Invoke("Checking if drive supports full raw subchannel reading...");
|
||||
|
||||
return !dev.ReadCd(out _, out _, lba, 2352 + 96, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Raw,
|
||||
dev.Timeout, out _);
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout,
|
||||
out _);
|
||||
}
|
||||
|
||||
/// <summary>Check if the drive can read RW raw subchannel</summary>
|
||||
@@ -70,7 +72,7 @@ partial class Dump
|
||||
updateStatus?.Invoke("Checking if drive supports PQ subchannel reading...");
|
||||
|
||||
return !dev.ReadCd(out _, out _, lba, 2352 + 16, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Q16,
|
||||
dev.Timeout, out _);
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Q16, dev.Timeout,
|
||||
out _);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes;
|
||||
@@ -38,12 +46,6 @@ using Aaru.Decoders.CD;
|
||||
using Aaru.Decoders.SCSI.MMC;
|
||||
using Aaru.Devices;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Reads media tags from Compact Disc media</summary>
|
||||
@@ -83,8 +85,8 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Reading Disc Information");
|
||||
UpdateStatus?.Invoke("Reading Disc Information");
|
||||
|
||||
sense = _dev.ReadDiscInformation(out cmdBuf, out _, MmcDiscInformationDataTypes.DiscInformation,
|
||||
_dev.Timeout, out _);
|
||||
sense = _dev.ReadDiscInformation(out cmdBuf, out _, MmcDiscInformationDataTypes.DiscInformation, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -40,12 +48,6 @@ using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.CD;
|
||||
using Aaru.Devices;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Reads the TOC, processes it, returns the track list and last sector</summary>
|
||||
@@ -61,16 +63,15 @@ partial class Dump
|
||||
/// <param name="updateStatus">Update status handler</param>
|
||||
/// <returns>List of tracks</returns>
|
||||
public static Track[] GetCdTracks(Device dev, DumpLog dumpLog, bool force, out long lastSector,
|
||||
Dictionary<int, long> leadOutStarts,
|
||||
Dictionary<MediaTagType, byte[]> mediaTags,
|
||||
Dictionary<int, long> leadOutStarts, Dictionary<MediaTagType, byte[]> mediaTags,
|
||||
ErrorMessageHandler stoppingErrorMessage, out FullTOC.CDFullTOC? toc,
|
||||
Dictionary<byte, byte> trackFlags, UpdateStatusHandler updateStatus)
|
||||
{
|
||||
byte[] cmdBuf; // Data buffer
|
||||
const uint sectorSize = 2352; // Full sector size
|
||||
bool sense; // Sense indicator
|
||||
List<Track> trackList = new List<Track>(); // Tracks in disc
|
||||
byte[] tmpBuf; // Temporary buffer
|
||||
byte[] cmdBuf; // Data buffer
|
||||
const uint sectorSize = 2352; // Full sector size
|
||||
bool sense; // Sense indicator
|
||||
var trackList = new List<Track>(); // Tracks in disc
|
||||
byte[] tmpBuf; // Temporary buffer
|
||||
toc = null;
|
||||
lastSector = 0;
|
||||
TrackType leadoutTrackType = TrackType.Audio;
|
||||
@@ -110,11 +111,10 @@ partial class Dump
|
||||
Sequence = trk.POINT,
|
||||
Session = trk.SessionNumber,
|
||||
Type = (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrack ||
|
||||
(TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental
|
||||
? TrackType.Data : TrackType.Audio,
|
||||
(TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental ? TrackType.Data
|
||||
: TrackType.Audio,
|
||||
StartSector =
|
||||
(ulong)((trk.PHOUR * 3600 * 75) + (trk.PMIN * 60 * 75) + (trk.PSEC * 75) + trk.PFRAME -
|
||||
150),
|
||||
(ulong)(trk.PHOUR * 3600 * 75 + trk.PMIN * 60 * 75 + trk.PSEC * 75 + trk.PFRAME - 150),
|
||||
BytesPerSector = (int)sectorSize,
|
||||
RawBytesPerSector = (int)sectorSize
|
||||
});
|
||||
@@ -159,17 +159,15 @@ partial class Dump
|
||||
phour = trk.PHOUR;
|
||||
}
|
||||
|
||||
lastSector = (phour * 3600 * 75) + (pmin * 60 * 75) + (psec * 75) + pframe - 150;
|
||||
lastSector = phour * 3600 * 75 + pmin * 60 * 75 + psec * 75 + pframe - 150;
|
||||
leadOutStarts?.Add(trk.SessionNumber, lastSector + 1);
|
||||
}
|
||||
else if(trk.POINT == 0xA0 &&
|
||||
trk.ADR == 1)
|
||||
{
|
||||
leadoutTrackType =
|
||||
(TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrack ||
|
||||
(TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental ? TrackType.Data
|
||||
: TrackType.Audio;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -191,8 +189,7 @@ partial class Dump
|
||||
}
|
||||
|
||||
if(oldToc.HasValue)
|
||||
foreach(TOC.CDTOCTrackDataDescriptor trk in oldToc.Value.TrackDescriptors.
|
||||
OrderBy(t => t.TrackNumber).
|
||||
foreach(TOC.CDTOCTrackDataDescriptor trk in oldToc.Value.TrackDescriptors.OrderBy(t => t.TrackNumber).
|
||||
Where(trk => trk.ADR == 1 || trk.ADR == 4))
|
||||
if(trk.TrackNumber >= 0x01 &&
|
||||
trk.TrackNumber <= 0x63)
|
||||
@@ -202,8 +199,8 @@ partial class Dump
|
||||
Sequence = trk.TrackNumber,
|
||||
Session = 1,
|
||||
Type = (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrack ||
|
||||
(TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental
|
||||
? TrackType.Data : TrackType.Audio,
|
||||
(TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental ? TrackType.Data
|
||||
: TrackType.Audio,
|
||||
StartSector = trk.TrackStartAddress,
|
||||
BytesPerSector = (int)sectorSize,
|
||||
RawBytesPerSector = (int)sectorSize
|
||||
@@ -247,7 +244,7 @@ partial class Dump
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
byte[] temp = new byte[8];
|
||||
var temp = new byte[8];
|
||||
|
||||
Array.Copy(cmdBuf, 0, temp, 0, 8);
|
||||
Array.Reverse(temp);
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -42,12 +50,6 @@ using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Trims errored sectors in a CompactDisc</summary>
|
||||
@@ -74,17 +76,16 @@ partial class Dump
|
||||
/// <param name="mcn">Disc media catalogue number</param>
|
||||
/// <param name="subchannelExtents">List of subchannels not yet dumped correctly</param>
|
||||
/// <param name="smallestPregapLbaPerTrack">List of smallest pregap relative address per track</param>
|
||||
void TrimCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry,
|
||||
ExtentsULong extents, bool newTrim, int offsetBytes, bool read6, bool read10, bool read12,
|
||||
bool read16, bool readcd, int sectorsForOffset, uint subSize,
|
||||
MmcSubchannel supportedSubchannel, bool supportsLongSectors, ref double totalDuration,
|
||||
SubchannelLog subLog, MmcSubchannel desiredSubchannel, Track[] tracks,
|
||||
void TrimCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry, ExtentsULong extents,
|
||||
bool newTrim, int offsetBytes, bool read6, bool read10, bool read12, bool read16, bool readcd,
|
||||
int sectorsForOffset, uint subSize, MmcSubchannel supportedSubchannel, bool supportsLongSectors,
|
||||
ref double totalDuration, SubchannelLog subLog, MmcSubchannel desiredSubchannel, Track[] tracks,
|
||||
Dictionary<byte, string> isrcs, ref string mcn, HashSet<int> subchannelExtents,
|
||||
Dictionary<byte, int> smallestPregapLbaPerTrack)
|
||||
{
|
||||
DateTime start;
|
||||
DateTime end;
|
||||
bool sense = true; // Sense indicator
|
||||
var sense = true; // Sense indicator
|
||||
byte[] cmdBuf = null; // Data buffer
|
||||
double cmdDuration = 0; // Command execution time
|
||||
const uint sectorSize = 2352; // Full sector size
|
||||
@@ -123,10 +124,10 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Trimming skipped sectors");
|
||||
InitProgress?.Invoke();
|
||||
|
||||
trimStart:
|
||||
trimStart:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
|
||||
for(int b = 0; b < tmpArray.Length; b++)
|
||||
for(var b = 0; b < tmpArray.Length; b++)
|
||||
{
|
||||
ulong badSector = tmpArray[b];
|
||||
|
||||
@@ -141,29 +142,26 @@ partial class Dump
|
||||
|
||||
PulseProgress?.Invoke($"Trimming sector {badSector}");
|
||||
|
||||
Track track = tracks.OrderBy(t => t.StartSector).
|
||||
LastOrDefault(t => badSector >= t.StartSector);
|
||||
Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector);
|
||||
|
||||
byte sectorsToTrim = 1;
|
||||
uint badSectorToRead = (uint)badSector;
|
||||
var badSectorToRead = (uint)badSector;
|
||||
|
||||
if(_fixOffset &&
|
||||
audioExtents.Contains(badSector) &&
|
||||
offsetBytes != 0)
|
||||
{
|
||||
if(offsetBytes > 0)
|
||||
{
|
||||
badSectorToRead -= (uint)sectorsForOffset;
|
||||
}
|
||||
|
||||
sectorsToTrim = (byte)(sectorsForOffset + 1);
|
||||
}
|
||||
|
||||
bool forceFixOffset = false;
|
||||
var forceFixOffset = false;
|
||||
|
||||
if(_supportsPlextorD8 && audioExtents.Contains(badSector))
|
||||
sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, badSectorToRead, blockSize,
|
||||
sectorsToTrim, supportedPlextorSubchannel, out cmdDuration);
|
||||
sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, badSectorToRead, blockSize, sectorsToTrim,
|
||||
supportedPlextorSubchannel, out cmdDuration);
|
||||
else if(readcd)
|
||||
{
|
||||
if(audioExtents.Contains(badSector))
|
||||
@@ -177,13 +175,13 @@ partial class Dump
|
||||
DecodedSense? decSense = Sense.Decode(senseBuf);
|
||||
|
||||
// Try to workaround firmware
|
||||
if((decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05) ||
|
||||
if(decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05 ||
|
||||
decSense?.ASC == 0x64)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out _, badSectorToRead, blockSize, sectorsToTrim,
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
supportedSubchannel, _dev.Timeout, out double cmdDuration2);
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout,
|
||||
out double cmdDuration2);
|
||||
|
||||
cmdDuration += cmdDuration2;
|
||||
}
|
||||
@@ -192,9 +190,8 @@ partial class Dump
|
||||
else
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, badSectorToRead, blockSize, sectorsToTrim,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout,
|
||||
out cmdDuration);
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
@@ -219,14 +216,14 @@ partial class Dump
|
||||
sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, true, false, badSectorToRead, blockSize, 0,
|
||||
sectorsToTrim, false, _dev.Timeout, out cmdDuration);
|
||||
else if(read12)
|
||||
sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, badSectorToRead,
|
||||
blockSize, 0, sectorsToTrim, false, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, badSectorToRead, blockSize,
|
||||
0, sectorsToTrim, false, _dev.Timeout, out cmdDuration);
|
||||
else if(read10)
|
||||
sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, badSectorToRead,
|
||||
blockSize, 0, sectorsToTrim, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, badSectorToRead, blockSize,
|
||||
0, sectorsToTrim, _dev.Timeout, out cmdDuration);
|
||||
else if(read6)
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, badSectorToRead, blockSize, sectorsToTrim,
|
||||
_dev.Timeout, out cmdDuration);
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, badSectorToRead, blockSize, sectorsToTrim, _dev.Timeout,
|
||||
out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
|
||||
@@ -251,14 +248,14 @@ partial class Dump
|
||||
{
|
||||
uint blocksToRead = sectorsToTrim;
|
||||
|
||||
FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead,
|
||||
subSize, ref cmdBuf, blockSize, false);
|
||||
FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead, subSize,
|
||||
ref cmdBuf, blockSize, false);
|
||||
}
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
byte[] data = new byte[sectorSize];
|
||||
byte[] sub = new byte[subSize];
|
||||
var data = new byte[sectorSize];
|
||||
var sub = new byte[subSize];
|
||||
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
|
||||
Array.Copy(cmdBuf, sectorSize, sub, 0, subSize);
|
||||
|
||||
@@ -269,16 +266,20 @@ partial class Dump
|
||||
|
||||
ulong trkStartBefore = track.StartSector;
|
||||
|
||||
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
|
||||
desiredSubchannel, sub, badSector, 1, subLog, isrcs, (byte)track.Sequence, ref mcn,
|
||||
tracks, subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel,
|
||||
_fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true);
|
||||
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel,
|
||||
sub, badSector, 1, subLog, isrcs,
|
||||
(byte)track.Sequence, ref mcn, tracks,
|
||||
subchannelExtents,
|
||||
_fixSubchannelPosition, outputOptical,
|
||||
_fixSubchannel, _fixSubchannelCrc,
|
||||
_dumpLog, UpdateStatus,
|
||||
smallestPregapLbaPerTrack, true);
|
||||
|
||||
// Set tracks and go back
|
||||
if(!indexesChanged)
|
||||
continue;
|
||||
|
||||
(outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList());
|
||||
outputOptical.SetTracks(tracks.ToList());
|
||||
|
||||
if(track.StartSector != trkStartBefore &&
|
||||
!_resume.BadBlocks.Contains(track.StartSector))
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
// Copyright © 2020-2022 Rebecca Wallander
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -44,10 +46,9 @@ using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Database;
|
||||
using Aaru.Devices;
|
||||
using Aaru.Settings;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
/// <summary>Subchannel requested to dump</summary>
|
||||
public enum DumpSubchannel
|
||||
{
|
||||
@@ -93,7 +94,6 @@ public partial class Dump
|
||||
readonly DumpSubchannel _subchannel;
|
||||
readonly bool _titleKeys;
|
||||
readonly bool _trim;
|
||||
bool _useBufferedReads;
|
||||
bool _aborted;
|
||||
AaruContext _ctx; // Main database context
|
||||
Database.Models.Device _dbDev; // Device database entry
|
||||
@@ -107,6 +107,7 @@ public partial class Dump
|
||||
int _speed;
|
||||
int _speedMultiplier;
|
||||
bool _supportsPlextorD8;
|
||||
bool _useBufferedReads;
|
||||
|
||||
/// <summary>Initializes dumpers</summary>
|
||||
/// <param name="doResume">Should resume?</param>
|
||||
@@ -201,7 +202,7 @@ public partial class Dump
|
||||
public void Start()
|
||||
{
|
||||
// Open main database
|
||||
_ctx = AaruContext.Create(Settings.Settings.MainDbPath);
|
||||
_ctx = AaruContext.Create(Settings.MainDbPath);
|
||||
|
||||
// Search for device in main database
|
||||
_dbDev = _ctx.Devices.FirstOrDefault(d => d.Manufacturer == _dev.Manufacturer && d.Model == _dev.Model &&
|
||||
@@ -225,10 +226,12 @@ public partial class Dump
|
||||
|
||||
switch(_dev.IsUsb)
|
||||
{
|
||||
case true when _dev.UsbVendorId == 0x054C && _dev.UsbProductId is 0x01C8 or 0x01C9 or 0x02D2: PlayStationPortable();
|
||||
case true when _dev.UsbVendorId == 0x054C && _dev.UsbProductId is 0x01C8 or 0x01C9 or 0x02D2:
|
||||
PlayStationPortable();
|
||||
|
||||
break;
|
||||
case true when _dev.UsbVendorId ==0x0403 && _dev.UsbProductId ==0x97C1: Retrode();
|
||||
case true when _dev.UsbVendorId == 0x0403 && _dev.UsbProductId == 0x97C1:
|
||||
Retrode();
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -30,15 +30,16 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
public partial class Dump
|
||||
{
|
||||
static readonly byte[] _sfcExtension =
|
||||
@@ -90,7 +91,7 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] tmp = new byte[8];
|
||||
var tmp = new byte[8];
|
||||
|
||||
Array.Copy(buffer, 0x36, tmp, 0, 8);
|
||||
|
||||
@@ -103,11 +104,11 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
ushort fatStart = (ushort)((buffer[0x0F] << 8) + buffer[0x0E]);
|
||||
ushort sectorsPerFat = (ushort)((buffer[0x17] << 8) + buffer[0x16]);
|
||||
ushort rootStart = (ushort)((sectorsPerFat * 2) + fatStart);
|
||||
ushort rootSize = (ushort)(((buffer[0x12] << 8) + buffer[0x11]) * 32 / 512);
|
||||
byte sectorsPerCluster = buffer[0x0D];
|
||||
var fatStart = (ushort)((buffer[0x0F] << 8) + buffer[0x0E]);
|
||||
var sectorsPerFat = (ushort)((buffer[0x17] << 8) + buffer[0x16]);
|
||||
var rootStart = (ushort)(sectorsPerFat * 2 + fatStart);
|
||||
var rootSize = (ushort)(((buffer[0x12] << 8) + buffer[0x11]) * 32 / 512);
|
||||
byte sectorsPerCluster = buffer[0x0D];
|
||||
|
||||
UpdateStatus?.Invoke($"Reading root directory in sector {rootStart}...");
|
||||
_dumpLog.WriteLine("Reading root directory in sector {0}...", rootStart);
|
||||
@@ -122,14 +123,14 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
int romPos;
|
||||
bool sfcFound = false;
|
||||
bool genesisFound = false;
|
||||
bool smsFound = false;
|
||||
bool n64Found = false;
|
||||
bool gbFound = false;
|
||||
bool gbcFound = false;
|
||||
bool gbaFound = false;
|
||||
int romPos;
|
||||
var sfcFound = false;
|
||||
var genesisFound = false;
|
||||
var smsFound = false;
|
||||
var n64Found = false;
|
||||
var gbFound = false;
|
||||
var gbcFound = false;
|
||||
var gbaFound = false;
|
||||
tmp = new byte[3];
|
||||
|
||||
for(romPos = 0; romPos < buffer.Length; romPos += 0x20)
|
||||
@@ -197,8 +198,8 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
ushort cluster = BitConverter.ToUInt16(buffer, romPos + 0x1A);
|
||||
uint romSize = BitConverter.ToUInt32(buffer, romPos + 0x1C);
|
||||
var cluster = BitConverter.ToUInt16(buffer, romPos + 0x1A);
|
||||
var romSize = BitConverter.ToUInt32(buffer, romPos + 0x1C);
|
||||
|
||||
MediaType mediaType = gbaFound
|
||||
? MediaType.GameBoyAdvanceGamePak
|
||||
@@ -239,7 +240,7 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
uint startSector = (uint)(rootStart + rootSize + ((cluster - 2) * sectorsPerCluster));
|
||||
var startSector = (uint)(rootStart + rootSize + (cluster - 2) * sectorsPerCluster);
|
||||
uint romSectors = romSize / 512;
|
||||
uint romRemaining = romSize % 512;
|
||||
|
||||
@@ -393,7 +394,7 @@ public partial class Dump
|
||||
_dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.",
|
||||
512 * (double)(romSectors + 1) / 1024 / imageWriteDuration);
|
||||
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
var metadata = new ImageInfo
|
||||
{
|
||||
Application = "Aaru",
|
||||
ApplicationVersion = Version.GetVersion()
|
||||
|
||||
@@ -31,6 +31,12 @@
|
||||
// Copyright © 2020-2022 Rebecca Wallander
|
||||
// ****************************************************************************/
|
||||
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes;
|
||||
@@ -43,17 +49,13 @@ using Aaru.Decoders.SCSI.MMC;
|
||||
using Aaru.Decryption;
|
||||
using Aaru.Decryption.DVD;
|
||||
using Aaru.Devices;
|
||||
using Aaru.Settings;
|
||||
using Schemas;
|
||||
using DDS = Aaru.Decoders.DVD.DDS;
|
||||
using DMI = Aaru.Decoders.Xbox.DMI;
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
||||
using Spare = Aaru.Decoders.DVD.Spare;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
/// <summary>Implement dumping optical discs from MultiMedia devices</summary>
|
||||
partial class Dump
|
||||
{
|
||||
@@ -63,15 +65,14 @@ partial class Dump
|
||||
MediaType dskType = MediaType.Unknown;
|
||||
bool sense;
|
||||
byte[] tmpBuf;
|
||||
bool compactDisc = true;
|
||||
bool gotConfiguration = false;
|
||||
bool isXbox = false;
|
||||
var compactDisc = true;
|
||||
var gotConfiguration = false;
|
||||
var isXbox = false;
|
||||
DVDDecryption dvdDecrypt = null;
|
||||
_speedMultiplier = 1;
|
||||
|
||||
// TODO: Log not only what is it reading, but if it was read correctly or not.
|
||||
sense = _dev.GetConfiguration(out byte[] cmdBuf, out _, 0, MmcGetConfigurationRt.Current, _dev.Timeout,
|
||||
out _);
|
||||
sense = _dev.GetConfiguration(out byte[] cmdBuf, out _, 0, MmcGetConfigurationRt.Current, _dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
@@ -206,8 +207,7 @@ partial class Dump
|
||||
|
||||
Modes.DecodedMode? decMode = null;
|
||||
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, true, ScsiModeSensePageControl.Current, 0x00, _dev.Timeout,
|
||||
out _);
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, true, ScsiModeSensePageControl.Current, 0x00, _dev.Timeout, out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
{
|
||||
@@ -228,8 +228,8 @@ partial class Dump
|
||||
|
||||
if(sense || _dev.Error)
|
||||
{
|
||||
sense = _dev.ModeSense10(out cmdBuf, out _, false, false, ScsiModeSensePageControl.Current, 0x3F,
|
||||
0x00, _dev.Timeout, out _);
|
||||
sense = _dev.ModeSense10(out cmdBuf, out _, false, false, ScsiModeSensePageControl.Current, 0x3F, 0x00,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
{
|
||||
@@ -281,7 +281,7 @@ partial class Dump
|
||||
var scsiReader = new Reader(_dev, _dev.Timeout, null, _errorLog, _dumpRaw);
|
||||
ulong blocks = scsiReader.GetDeviceBlocks();
|
||||
_dumpLog.WriteLine("Device reports disc has {0} blocks", blocks);
|
||||
Dictionary<MediaTagType, byte[]> mediaTags = new Dictionary<MediaTagType, byte[]>();
|
||||
var mediaTags = new Dictionary<MediaTagType, byte[]>();
|
||||
|
||||
if(dskType == MediaType.PD650)
|
||||
switch(blocks + 1)
|
||||
@@ -323,8 +323,7 @@ partial class Dump
|
||||
{
|
||||
_dumpLog.WriteLine("Dumping Nintendo GameCube or Wii discs is not yet implemented.");
|
||||
|
||||
StoppingErrorMessage?.
|
||||
Invoke("Dumping Nintendo GameCube or Wii discs is not yet implemented.");
|
||||
StoppingErrorMessage?.Invoke("Dumping Nintendo GameCube or Wii discs is not yet implemented.");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -441,9 +440,7 @@ partial class Dump
|
||||
DMI.IsXbox360(cmdBuf))
|
||||
{
|
||||
if(DMI.IsXbox(cmdBuf))
|
||||
{
|
||||
dskType = MediaType.XGD;
|
||||
}
|
||||
else if(DMI.IsXbox360(cmdBuf))
|
||||
{
|
||||
dskType = MediaType.XGD2;
|
||||
@@ -519,7 +516,7 @@ partial class Dump
|
||||
UpdateStatus?.Invoke("Drive reports no copy protection on disc.");
|
||||
else
|
||||
{
|
||||
if(!Settings.Settings.Current.EnableDecryption)
|
||||
if(!Settings.Current.EnableDecryption)
|
||||
UpdateStatus?.Invoke("Drive reports the disc uses copy protection. " +
|
||||
"The dump will be incorrect unless decryption is enabled.");
|
||||
else
|
||||
@@ -531,9 +528,8 @@ partial class Dump
|
||||
dvdDecrypt = new DVDDecryption(_dev);
|
||||
|
||||
sense = dvdDecrypt.ReadBusKey(out cmdBuf, out _,
|
||||
CSS_CPRM.DecodeLeadInCopyright(cmdBuf)?.
|
||||
CopyrightType ?? CopyrightType.NoProtection,
|
||||
_dev.Timeout, out _);
|
||||
CSS_CPRM.DecodeLeadInCopyright(cmdBuf)?.CopyrightType ??
|
||||
CopyrightType.NoProtection, _dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
@@ -546,12 +542,10 @@ partial class Dump
|
||||
{
|
||||
CSS_CPRM.DiscKey? decodedDiscKey = CSS.DecodeDiscKey(cmdBuf, busKey);
|
||||
|
||||
sense = dvdDecrypt.ReadAsf(out cmdBuf, out _,
|
||||
DvdCssKeyClass.DvdCssCppmOrCprm, _dev.Timeout,
|
||||
out _);
|
||||
sense = dvdDecrypt.ReadAsf(out cmdBuf, out _, DvdCssKeyClass.DvdCssCppmOrCprm,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
if(cmdBuf[7] == 1)
|
||||
{
|
||||
UpdateStatus?.Invoke("Disc and drive authentication succeeded.");
|
||||
@@ -566,22 +560,18 @@ partial class Dump
|
||||
CSS_CPRM.DecodeRegionalPlaybackControlState(cmdBuf);
|
||||
|
||||
if(rpc.HasValue)
|
||||
{
|
||||
UpdateStatus?.Invoke(CSS.CheckRegion(rpc.Value, cmi.Value)
|
||||
? "Disc and drive regions match."
|
||||
: "Disc and drive regions do not match. The dump will be incorrect");
|
||||
}
|
||||
}
|
||||
|
||||
if(decodedDiscKey.HasValue)
|
||||
{
|
||||
mediaTags.Add(MediaTagType.DVD_DiscKey,
|
||||
decodedDiscKey.Value.Key);
|
||||
mediaTags.Add(MediaTagType.DVD_DiscKey, decodedDiscKey.Value.Key);
|
||||
|
||||
UpdateStatus?.Invoke("Decrypting disc key.");
|
||||
|
||||
CSS.DecryptDiscKey(decodedDiscKey.Value.Key,
|
||||
out byte[] discKey);
|
||||
CSS.DecryptDiscKey(decodedDiscKey.Value.Key, out byte[] discKey);
|
||||
|
||||
if(discKey != null)
|
||||
{
|
||||
@@ -592,16 +582,13 @@ partial class Dump
|
||||
UpdateStatus?.Invoke("Decryption of disc key failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatus?.
|
||||
Invoke($"Drive reports disc uses {(CSS_CPRM.DecodeLeadInCopyright(cmdBuf)?.CopyrightType ?? CopyrightType.NoProtection).ToString()} copy protection. " +
|
||||
"This is not yet supported and the dump will be incorrect.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -702,8 +689,7 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Reading Recordable Physical Information.");
|
||||
|
||||
sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdrPhysicalInformation, 0, _dev.Timeout,
|
||||
out _);
|
||||
MmcDiscStructureFormat.DvdrPhysicalInformation, 0, _dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
@@ -840,8 +826,7 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Reading Spare Area Information.");
|
||||
|
||||
sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
|
||||
MmcDiscStructureFormat.BdSpareAreaInformation, 0, _dev.Timeout,
|
||||
out _);
|
||||
MmcDiscStructureFormat.BdSpareAreaInformation, 0, _dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
@@ -897,7 +882,7 @@ partial class Dump
|
||||
Checksums = Checksum.GetChecksums(tag).ToArray()
|
||||
};
|
||||
|
||||
byte[] tmp = new byte[tag.Length + 4];
|
||||
var tmp = new byte[tag.Length + 4];
|
||||
Array.Copy(tag, 0, tmp, 4, tag.Length);
|
||||
tmp[0] = (byte)((tag.Length & 0xFF00) >> 8);
|
||||
tmp[1] = (byte)(tag.Length & 0xFF);
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -42,8 +44,6 @@ using Aaru.CommonTypes.Metadata;
|
||||
using Schemas;
|
||||
using MediaType = Aaru.CommonTypes.MediaType;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Creates optical metadata sidecar</summary>
|
||||
@@ -60,9 +60,9 @@ partial class Dump
|
||||
int? discOffset)
|
||||
{
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
var inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
totalChkDuration = 0;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
@@ -106,9 +106,9 @@ partial class Dump
|
||||
|
||||
if(sidecar.OpticalDisc[0].Track != null)
|
||||
filesystems.AddRange(from xmlTrack in sidecar.OpticalDisc[0].Track
|
||||
where xmlTrack.FileSystemInformation != null
|
||||
from partition in xmlTrack.FileSystemInformation
|
||||
where partition.FileSystems != null from fileSystem in partition.FileSystems
|
||||
where xmlTrack.FileSystemInformation != null
|
||||
from partition in xmlTrack.FileSystemInformation where partition.FileSystems != null
|
||||
from fileSystem in partition.FileSystems
|
||||
select (partition.StartSector, fileSystem.Type));
|
||||
|
||||
if(filesystems.Count > 0)
|
||||
@@ -134,8 +134,8 @@ partial class Dump
|
||||
}
|
||||
|
||||
if(mediaTags != null)
|
||||
foreach(KeyValuePair<MediaTagType, byte[]> tag in mediaTags.Where(tag => _outputPlugin.
|
||||
SupportedMediaTags.Contains(tag.Key)))
|
||||
foreach(KeyValuePair<MediaTagType, byte[]> tag in mediaTags.Where(tag => _outputPlugin.SupportedMediaTags.
|
||||
Contains(tag.Key)))
|
||||
AddMediaTagToSidecar(_outputPath, tag.Key, tag.Value, ref sidecar);
|
||||
|
||||
UpdateStatus?.Invoke("Writing metadata sidecar");
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -40,6 +46,7 @@ using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.SCSI;
|
||||
@@ -48,10 +55,6 @@ using Schemas;
|
||||
using MediaType = Aaru.CommonTypes.MediaType;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
/// <summary>Implements dumping MiniDisc Data devices</summary>
|
||||
partial class Dump
|
||||
{
|
||||
@@ -256,7 +259,7 @@ partial class Dump
|
||||
|
||||
if(decMode?.Pages != null)
|
||||
{
|
||||
bool setGeometry = false;
|
||||
var setGeometry = false;
|
||||
|
||||
foreach(Modes.ModePage page in decMode.Value.Pages)
|
||||
if(page.Page == 0x04 &&
|
||||
@@ -322,7 +325,7 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Resuming from block {0}.", _resume.NextBlock);
|
||||
}
|
||||
|
||||
bool newTrim = false;
|
||||
var newTrim = false;
|
||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||
ulong sectorSpeedStart = 0;
|
||||
InitProgress?.Invoke();
|
||||
@@ -456,8 +459,7 @@ partial class Dump
|
||||
|
||||
PulseProgress?.Invoke($"Trimming sector {badSector}");
|
||||
|
||||
sense = _dev.Read6(out readBuffer, out _, (uint)badSector, blockSize, 1, _dev.Timeout,
|
||||
out double _);
|
||||
sense = _dev.Read6(out readBuffer, out _, (uint)badSector, blockSize, 1, _dev.Timeout, out double _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
continue;
|
||||
@@ -479,9 +481,9 @@ partial class Dump
|
||||
!_aborted &&
|
||||
_retryPasses > 0)
|
||||
{
|
||||
int pass = 1;
|
||||
bool forward = true;
|
||||
bool runningPersistent = false;
|
||||
var pass = 1;
|
||||
var forward = true;
|
||||
var runningPersistent = false;
|
||||
|
||||
Modes.ModePage? currentModePage = null;
|
||||
byte[] md6;
|
||||
@@ -568,15 +570,14 @@ partial class Dump
|
||||
|
||||
AaruConsole.DebugWriteLine("Error: {0}", Sense.PrettifySense(senseBuf));
|
||||
|
||||
_dumpLog.
|
||||
WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
|
||||
_dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
|
||||
}
|
||||
else
|
||||
runningPersistent = true;
|
||||
}
|
||||
|
||||
InitProgress?.Invoke();
|
||||
repeatRetry:
|
||||
repeatRetry:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
|
||||
foreach(ulong badSector in tmpArray)
|
||||
@@ -657,7 +658,7 @@ partial class Dump
|
||||
|
||||
outputFormat.SetDumpHardware(_resume.Tries);
|
||||
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
var metadata = new ImageInfo
|
||||
{
|
||||
Application = "Aaru",
|
||||
ApplicationVersion = Version.GetVersion()
|
||||
@@ -694,7 +695,7 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
var inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
@@ -739,8 +740,7 @@ partial class Dump
|
||||
|
||||
if(sidecar.BlockMedia[0].FileSystemInformation != null)
|
||||
filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation
|
||||
where partition.FileSystems != null
|
||||
from fileSystem in partition.FileSystems
|
||||
where partition.FileSystems != null from fileSystem in partition.FileSystems
|
||||
select (partition.StartSector, fileSystem.Type));
|
||||
|
||||
if(filesystems.Count > 0)
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -42,6 +44,7 @@ using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.SCSI;
|
||||
@@ -50,8 +53,6 @@ using Schemas;
|
||||
using MediaType = Aaru.CommonTypes.MediaType;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
public partial class Dump
|
||||
{
|
||||
[SuppressMessage("ReSharper", "JoinDeclarationAndInitializer")]
|
||||
@@ -81,7 +82,7 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
uint blocks = (uint)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]);
|
||||
var blocks = (uint)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]);
|
||||
|
||||
blocks++;
|
||||
|
||||
@@ -168,7 +169,7 @@ public partial class Dump
|
||||
if(_resume.NextBlock > 0)
|
||||
_dumpLog.WriteLine("Resuming from block {0}.", _resume.NextBlock);
|
||||
|
||||
bool newTrim = false;
|
||||
var newTrim = false;
|
||||
|
||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||
ulong sectorSpeedStart = 0;
|
||||
@@ -330,9 +331,9 @@ public partial class Dump
|
||||
!_aborted &&
|
||||
_retryPasses > 0)
|
||||
{
|
||||
int pass = 1;
|
||||
bool forward = true;
|
||||
bool runningPersistent = false;
|
||||
var pass = 1;
|
||||
var forward = true;
|
||||
var runningPersistent = false;
|
||||
|
||||
Modes.ModePage? currentModePage = null;
|
||||
byte[] md6;
|
||||
@@ -434,15 +435,14 @@ public partial class Dump
|
||||
|
||||
AaruConsole.DebugWriteLine("Error: {0}", Sense.PrettifySense(senseBuf));
|
||||
|
||||
_dumpLog.
|
||||
WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
|
||||
_dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
|
||||
}
|
||||
else
|
||||
runningPersistent = true;
|
||||
}
|
||||
|
||||
InitProgress?.Invoke();
|
||||
repeatRetry:
|
||||
repeatRetry:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
|
||||
foreach(ulong badSector in tmpArray)
|
||||
@@ -523,7 +523,7 @@ public partial class Dump
|
||||
|
||||
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
|
||||
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
var metadata = new ImageInfo
|
||||
{
|
||||
Application = "Aaru",
|
||||
ApplicationVersion = Version.GetVersion()
|
||||
@@ -562,7 +562,7 @@ public partial class Dump
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
var inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
@@ -607,8 +607,7 @@ public partial class Dump
|
||||
|
||||
if(sidecar.BlockMedia[0].FileSystemInformation != null)
|
||||
filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation
|
||||
where partition.FileSystems != null
|
||||
from fileSystem in partition.FileSystems
|
||||
where partition.FileSystems != null from fileSystem in partition.FileSystems
|
||||
select (partition.StartSector, fileSystem.Type));
|
||||
|
||||
if(filesystems.Count > 0)
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes;
|
||||
@@ -38,8 +40,6 @@ using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
public partial class Dump
|
||||
{
|
||||
static readonly byte[] _fatSignature =
|
||||
@@ -69,8 +69,8 @@ public partial class Dump
|
||||
UpdateStatus?.Invoke("Checking if media is UMD or MemoryStick...");
|
||||
_dumpLog.WriteLine("Checking if media is UMD or MemoryStick...");
|
||||
|
||||
bool sense = _dev.ModeSense6(out byte[] buffer, out _, false, ScsiModeSensePageControl.Current, 0,
|
||||
_dev.Timeout, out _);
|
||||
bool sense = _dev.ModeSense6(out byte[] buffer, out _, false, ScsiModeSensePageControl.Current, 0, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
@@ -98,8 +98,7 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, 0, 512, 0, 1, false, _dev.Timeout,
|
||||
out _);
|
||||
sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, 0, 512, 0, 1, false, _dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
@@ -109,7 +108,7 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] tmp = new byte[8];
|
||||
var tmp = new byte[8];
|
||||
|
||||
Array.Copy(buffer, 0x36, tmp, 0, 8);
|
||||
|
||||
@@ -121,15 +120,15 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
ushort fatStart = (ushort)((buffer[0x0F] << 8) + buffer[0x0E]);
|
||||
ushort sectorsPerFat = (ushort)((buffer[0x17] << 8) + buffer[0x16]);
|
||||
ushort rootStart = (ushort)((sectorsPerFat * 2) + fatStart);
|
||||
var fatStart = (ushort)((buffer[0x0F] << 8) + buffer[0x0E]);
|
||||
var sectorsPerFat = (ushort)((buffer[0x17] << 8) + buffer[0x16]);
|
||||
var rootStart = (ushort)(sectorsPerFat * 2 + fatStart);
|
||||
|
||||
UpdateStatus?.Invoke($"Reading root directory in sector {rootStart}...");
|
||||
_dumpLog.WriteLine("Reading root directory in sector {0}...", rootStart);
|
||||
|
||||
sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, rootStart, 512, 0, 1, false,
|
||||
_dev.Timeout, out _);
|
||||
sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, rootStart, 512, 0, 1, false, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
@@ -155,7 +154,7 @@ public partial class Dump
|
||||
UpdateStatus?.Invoke("Reading FAT...");
|
||||
_dumpLog.WriteLine("Reading FAT...");
|
||||
|
||||
byte[] fat = new byte[sectorsPerFat * 512];
|
||||
var fat = new byte[sectorsPerFat * 512];
|
||||
|
||||
uint position = 0;
|
||||
|
||||
@@ -166,8 +165,8 @@ public partial class Dump
|
||||
if(transfer + position > sectorsPerFat)
|
||||
transfer = sectorsPerFat - position;
|
||||
|
||||
sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, position + fatStart, 512, 0,
|
||||
transfer, false, _dev.Timeout, out _);
|
||||
sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, position + fatStart, 512, 0, transfer,
|
||||
false, _dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
@@ -185,11 +184,11 @@ public partial class Dump
|
||||
UpdateStatus?.Invoke("Traversing FAT...");
|
||||
_dumpLog.WriteLine("Traversing FAT...");
|
||||
|
||||
ushort previousCluster = BitConverter.ToUInt16(fat, 4);
|
||||
var previousCluster = BitConverter.ToUInt16(fat, 4);
|
||||
|
||||
for(int i = 3; i < fat.Length / 2; i++)
|
||||
for(var i = 3; i < fat.Length / 2; i++)
|
||||
{
|
||||
ushort nextCluster = BitConverter.ToUInt16(fat, i * 2);
|
||||
var nextCluster = BitConverter.ToUInt16(fat, i * 2);
|
||||
|
||||
if(nextCluster == previousCluster + 1)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -48,8 +50,6 @@ using Schemas;
|
||||
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
public partial class Dump
|
||||
{
|
||||
[SuppressMessage("ReSharper", "JoinDeclarationAndInitializer")]
|
||||
@@ -78,11 +78,11 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
ushort fatStart = (ushort)((readBuffer[0x0F] << 8) + readBuffer[0x0E]);
|
||||
ushort sectorsPerFat = (ushort)((readBuffer[0x17] << 8) + readBuffer[0x16]);
|
||||
ushort rootStart = (ushort)((sectorsPerFat * 2) + fatStart);
|
||||
ushort rootSize = (ushort)(((readBuffer[0x12] << 8) + readBuffer[0x11]) * 32 / 512);
|
||||
ushort umdStart = (ushort)(rootStart + rootSize);
|
||||
var fatStart = (ushort)((readBuffer[0x0F] << 8) + readBuffer[0x0E]);
|
||||
var sectorsPerFat = (ushort)((readBuffer[0x17] << 8) + readBuffer[0x16]);
|
||||
var rootStart = (ushort)(sectorsPerFat * 2 + fatStart);
|
||||
var rootSize = (ushort)(((readBuffer[0x12] << 8) + readBuffer[0x11]) * 32 / 512);
|
||||
var umdStart = (ushort)(rootStart + rootSize);
|
||||
|
||||
UpdateStatus?.Invoke($"Reading root directory in sector {rootStart}...");
|
||||
_dumpLog.WriteLine("Reading root directory in sector {0}...", rootStart);
|
||||
@@ -98,7 +98,7 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
uint umdSizeInBytes = BitConverter.ToUInt32(readBuffer, 0x3C);
|
||||
var umdSizeInBytes = BitConverter.ToUInt32(readBuffer, 0x3C);
|
||||
ulong blocks = umdSizeInBytes / blockSize;
|
||||
string mediaPartNumber = Encoding.ASCII.GetString(readBuffer, 0, 11).Trim();
|
||||
|
||||
@@ -156,9 +156,9 @@ public partial class Dump
|
||||
start = DateTime.UtcNow;
|
||||
double imageWriteDuration = 0;
|
||||
|
||||
(outputOptical as IWritableOpticalImage)?.SetTracks(new List<Track>
|
||||
outputOptical?.SetTracks(new List<Track>
|
||||
{
|
||||
new Track
|
||||
new()
|
||||
{
|
||||
BytesPerSector = (int)blockSize,
|
||||
EndSector = blocks - 1,
|
||||
@@ -188,7 +188,7 @@ public partial class Dump
|
||||
if(_resume.NextBlock > 0)
|
||||
_dumpLog.WriteLine("Resuming from block {0}.", _resume.NextBlock);
|
||||
|
||||
bool newTrim = false;
|
||||
var newTrim = false;
|
||||
|
||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||
ulong sectorSpeedStart = 0;
|
||||
@@ -219,9 +219,8 @@ public partial class Dump
|
||||
UpdateProgress?.Invoke($"Reading sector {i} of {blocks} ({currentSpeed:F3} MiB/sec.)", (long)i,
|
||||
(long)blocks);
|
||||
|
||||
sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false,
|
||||
(uint)(umdStart + (i * 4)), 512, 0, blocksToRead * 4, false, _dev.Timeout,
|
||||
out double cmdDuration);
|
||||
sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)(umdStart + i * 4),
|
||||
512, 0, blocksToRead * 4, false, _dev.Timeout, out double cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
|
||||
@@ -325,8 +324,7 @@ public partial class Dump
|
||||
PulseProgress?.Invoke($"Trimming sector {badSector}");
|
||||
|
||||
sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false,
|
||||
(uint)(umdStart + (badSector * 4)), 512, 0, 4, false, _dev.Timeout,
|
||||
out double _);
|
||||
(uint)(umdStart + badSector * 4), 512, 0, 4, false, _dev.Timeout, out double _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
{
|
||||
@@ -351,9 +349,9 @@ public partial class Dump
|
||||
!_aborted &&
|
||||
_retryPasses > 0)
|
||||
{
|
||||
int pass = 1;
|
||||
bool forward = true;
|
||||
bool runningPersistent = false;
|
||||
var pass = 1;
|
||||
var forward = true;
|
||||
var runningPersistent = false;
|
||||
|
||||
Modes.ModePage? currentModePage = null;
|
||||
byte[] md6;
|
||||
@@ -439,15 +437,14 @@ public partial class Dump
|
||||
|
||||
AaruConsole.DebugWriteLine("Error: {0}", Sense.PrettifySense(senseBuf));
|
||||
|
||||
_dumpLog.
|
||||
WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
|
||||
_dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
|
||||
}
|
||||
else
|
||||
runningPersistent = true;
|
||||
}
|
||||
|
||||
InitProgress?.Invoke();
|
||||
repeatRetry:
|
||||
repeatRetry:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
|
||||
foreach(ulong badSector in tmpArray)
|
||||
@@ -464,7 +461,7 @@ public partial class Dump
|
||||
Invoke($"Retrying sector {badSector}, pass {pass}, {(runningPersistent ? "recovering partial data, " : "")}{(forward ? "forward" : "reverse")}");
|
||||
|
||||
sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false,
|
||||
(uint)(umdStart + (badSector * 4)), 512, 0, 4, false, _dev.Timeout,
|
||||
(uint)(umdStart + badSector * 4), 512, 0, 4, false, _dev.Timeout,
|
||||
out double cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
@@ -530,7 +527,7 @@ public partial class Dump
|
||||
|
||||
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
|
||||
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
var metadata = new ImageInfo
|
||||
{
|
||||
Application = "Aaru",
|
||||
ApplicationVersion = Version.GetVersion(),
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
@@ -38,10 +40,8 @@ using Schemas;
|
||||
using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
/// <summary>Implements resume support</summary>
|
||||
internal static class ResumeSupport
|
||||
static class ResumeSupport
|
||||
{
|
||||
/// <summary>Process resume</summary>
|
||||
/// <param name="isLba">If drive is LBA</param>
|
||||
@@ -64,9 +64,9 @@ internal static class ResumeSupport
|
||||
/// progress dump
|
||||
/// </exception>
|
||||
internal static void Process(bool isLba, bool removable, ulong blocks, string manufacturer, string model,
|
||||
string serial, PlatformID platform, ref Resume resume,
|
||||
ref DumpHardwareType currentTry, ref ExtentsULong extents, string firmware,
|
||||
bool @private, bool force, bool isTape = false)
|
||||
string serial, PlatformID platform, ref Resume resume, ref DumpHardwareType currentTry,
|
||||
ref ExtentsULong extents, string firmware, bool @private, bool force,
|
||||
bool isTape = false)
|
||||
{
|
||||
if(@private)
|
||||
serial = null;
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Aaru.CommonTypes;
|
||||
@@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Decoders.SCSI;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
/// <summary>Implements dumping SCSI and ATAPI devices</summary>
|
||||
public partial class Dump
|
||||
{
|
||||
@@ -46,12 +46,12 @@ public partial class Dump
|
||||
/// <summary>Dumps a SCSI Block Commands device or a Reduced Block Commands devices</summary>
|
||||
void Scsi()
|
||||
{
|
||||
int resets = 0;
|
||||
var resets = 0;
|
||||
|
||||
if(_dev.IsRemovable)
|
||||
{
|
||||
InitProgress?.Invoke();
|
||||
deviceGotReset:
|
||||
deviceGotReset:
|
||||
bool sense = _dev.ScsiTestUnitReady(out byte[] senseBuf, _dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
@@ -63,8 +63,8 @@ public partial class Dump
|
||||
ErrorMessage?.
|
||||
Invoke($"Device not ready. Sense {decSense.Value.SenseKey} ASC {decSense.Value.ASC:X2}h ASCQ {decSense.Value.ASCQ:X2}h");
|
||||
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h",
|
||||
decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h", decSense.Value.SenseKey,
|
||||
decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
|
||||
// Just retry, for 5 times
|
||||
if(decSense.Value.ASC == 0x29)
|
||||
@@ -77,7 +77,7 @@ public partial class Dump
|
||||
|
||||
if(decSense.Value.ASC == 0x3A)
|
||||
{
|
||||
int leftRetries = 5;
|
||||
var leftRetries = 5;
|
||||
|
||||
while(leftRetries > 0)
|
||||
{
|
||||
@@ -96,8 +96,7 @@ public partial class Dump
|
||||
Invoke($"Device not ready. Sense {decSense.Value.SenseKey} ASC {decSense.Value.ASC:X2}h ASCQ {decSense.Value.ASCQ:X2}h");
|
||||
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h",
|
||||
decSense.Value.SenseKey, decSense.Value.ASC,
|
||||
decSense.Value.ASCQ);
|
||||
decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
}
|
||||
|
||||
leftRetries--;
|
||||
@@ -113,7 +112,7 @@ public partial class Dump
|
||||
else if(decSense.Value.ASC == 0x04 &&
|
||||
decSense.Value.ASCQ == 0x01)
|
||||
{
|
||||
int leftRetries = 50;
|
||||
var leftRetries = 50;
|
||||
|
||||
while(leftRetries > 0)
|
||||
{
|
||||
@@ -132,8 +131,7 @@ public partial class Dump
|
||||
Invoke($"Device not ready. Sense {decSense.Value.SenseKey} ASC {decSense.Value.ASC:X2}h ASCQ {decSense.Value.ASCQ:X2}h");
|
||||
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h",
|
||||
decSense.Value.SenseKey, decSense.Value.ASC,
|
||||
decSense.Value.ASCQ);
|
||||
decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
}
|
||||
|
||||
leftRetries--;
|
||||
@@ -163,7 +161,7 @@ public partial class Dump
|
||||
// These should be trapped by the OS but seems in some cases they're not
|
||||
else if(decSense.Value.ASC == 0x28)
|
||||
{
|
||||
int leftRetries = 10;
|
||||
var leftRetries = 10;
|
||||
|
||||
while(leftRetries > 0)
|
||||
{
|
||||
@@ -182,8 +180,7 @@ public partial class Dump
|
||||
Invoke($"Device not ready. Sense {decSense.Value.SenseKey} ASC {decSense.Value.ASC:X2}h ASCQ {decSense.Value.ASCQ:X2}h");
|
||||
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h",
|
||||
decSense.Value.SenseKey, decSense.Value.ASC,
|
||||
decSense.Value.ASCQ);
|
||||
decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
}
|
||||
|
||||
leftRetries--;
|
||||
@@ -199,8 +196,7 @@ public partial class Dump
|
||||
}
|
||||
else
|
||||
{
|
||||
StoppingErrorMessage?.
|
||||
Invoke($"Error testing unit was ready:\n{Sense.PrettifySense(senseBuf)}");
|
||||
StoppingErrorMessage?.Invoke($"Error testing unit was ready:\n{Sense.PrettifySense(senseBuf)}");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -237,8 +233,7 @@ public partial class Dump
|
||||
if(_outputPlugin is IWritableOpticalImage)
|
||||
Mmc();
|
||||
else
|
||||
StoppingErrorMessage?.
|
||||
Invoke("The specified plugin does not support storing optical disc images.");
|
||||
StoppingErrorMessage?.Invoke("The specified plugin does not support storing optical disc images.");
|
||||
|
||||
return;
|
||||
case PeripheralDeviceTypes.BridgingExpander
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -51,10 +57,6 @@ using Schemas;
|
||||
using MediaType = Aaru.CommonTypes.MediaType;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Dumps the tape from a SCSI Streaming device</summary>
|
||||
@@ -117,7 +119,7 @@ partial class Dump
|
||||
|
||||
// And yet, did not rewind!
|
||||
if(decSense.HasValue &&
|
||||
((decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x04 && decSense.Value.ASCQ != 0x00) ||
|
||||
(decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x04 && decSense.Value.ASCQ != 0x00 ||
|
||||
decSense.Value.ASC != 0x00))
|
||||
{
|
||||
StoppingErrorMessage?.Invoke("Drive could not rewind, please correct. Sense follows..." +
|
||||
@@ -133,8 +135,7 @@ partial class Dump
|
||||
}
|
||||
|
||||
// Check position
|
||||
sense = _dev.ReadPosition(out byte[] cmdBuf, out senseBuf, SscPositionForms.Short, _dev.Timeout,
|
||||
out duration);
|
||||
sense = _dev.ReadPosition(out byte[] cmdBuf, out senseBuf, SscPositionForms.Short, _dev.Timeout, out duration);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
@@ -143,8 +144,8 @@ partial class Dump
|
||||
decSense = Sense.Decode(senseBuf);
|
||||
|
||||
if(decSense.HasValue &&
|
||||
((decSense.Value.ASC == 0x20 && decSense.Value.ASCQ != 0x00) ||
|
||||
(decSense.Value.ASC != 0x20 && decSense.Value.SenseKey != SenseKeys.IllegalRequest)))
|
||||
(decSense.Value.ASC == 0x20 && decSense.Value.ASCQ != 0x00 || decSense.Value.ASC != 0x20 &&
|
||||
decSense.Value.SenseKey != SenseKeys.IllegalRequest))
|
||||
{
|
||||
StoppingErrorMessage?.Invoke("Could not get position. Sense follows..." + Environment.NewLine +
|
||||
decSense.Value.Description);
|
||||
@@ -194,7 +195,7 @@ partial class Dump
|
||||
|
||||
// And yet, did not rewind!
|
||||
if(decSense.HasValue &&
|
||||
((decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x04 && decSense.Value.ASCQ != 0x00) ||
|
||||
(decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x04 && decSense.Value.ASCQ != 0x00 ||
|
||||
decSense.Value.ASC != 0x00))
|
||||
{
|
||||
StoppingErrorMessage?.Invoke("Drive could not rewind, please correct. Sense follows..." +
|
||||
@@ -202,14 +203,13 @@ partial class Dump
|
||||
|
||||
_dumpLog.WriteLine("Drive could not rewind, please correct. Sense follows...");
|
||||
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h",
|
||||
decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h", decSense.Value.SenseKey,
|
||||
decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sense = _dev.ReadPosition(out cmdBuf, out senseBuf, SscPositionForms.Short, _dev.Timeout,
|
||||
out duration);
|
||||
sense = _dev.ReadPosition(out cmdBuf, out senseBuf, SscPositionForms.Short, _dev.Timeout, out duration);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
@@ -246,8 +246,8 @@ partial class Dump
|
||||
|
||||
UpdateStatus?.Invoke("Requesting MODE SENSE (10).");
|
||||
|
||||
sense = _dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F,
|
||||
0xFF, 5, out duration);
|
||||
sense = _dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5,
|
||||
out duration);
|
||||
|
||||
if(!sense ||
|
||||
_dev.Error)
|
||||
@@ -267,8 +267,8 @@ partial class Dump
|
||||
out duration);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
sense = _dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00,
|
||||
5, out duration);
|
||||
sense = _dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5,
|
||||
out duration);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
sense = _dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration);
|
||||
@@ -322,15 +322,15 @@ partial class Dump
|
||||
_dumpLog.WriteLine("SCSI density type: {0}.", scsiDensityCodeTape);
|
||||
_dumpLog.WriteLine("Media identified as {0}.", dskType);
|
||||
|
||||
bool endOfMedia = false;
|
||||
var endOfMedia = false;
|
||||
ulong currentBlock = 0;
|
||||
uint currentFile = 0;
|
||||
byte currentPartition = 0;
|
||||
byte totalPartitions = 1; // TODO: Handle partitions.
|
||||
bool fixedLen = false;
|
||||
var fixedLen = false;
|
||||
uint transferLen = blockSize;
|
||||
|
||||
firstRead:
|
||||
firstRead:
|
||||
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, _dev.Timeout,
|
||||
out duration);
|
||||
@@ -371,15 +371,15 @@ partial class Dump
|
||||
fixedLen = true;
|
||||
transferLen = 1;
|
||||
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize,
|
||||
_dev.Timeout, out duration);
|
||||
sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, _dev.Timeout,
|
||||
out duration);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
decSense = Sense.Decode(senseBuf);
|
||||
|
||||
StoppingErrorMessage?.Invoke("Drive could not read. Sense follows..." +
|
||||
Environment.NewLine + decSense.Value.Description);
|
||||
StoppingErrorMessage?.Invoke("Drive could not read. Sense follows..." + Environment.NewLine +
|
||||
decSense.Value.Description);
|
||||
|
||||
_dumpLog.WriteLine("Drive could not read. Sense follows...");
|
||||
|
||||
@@ -417,8 +417,7 @@ partial class Dump
|
||||
UpdateStatus?.Invoke($"Blocksize changed to {blockSize} bytes at block {currentBlock}");
|
||||
_dumpLog.WriteLine("Blocksize changed to {0} bytes at block {1}", blockSize, currentBlock);
|
||||
|
||||
sense = _dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, _dev.Timeout,
|
||||
out duration);
|
||||
sense = _dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, _dev.Timeout, out duration);
|
||||
|
||||
totalDuration += duration;
|
||||
|
||||
@@ -445,8 +444,8 @@ partial class Dump
|
||||
|
||||
_dumpLog.WriteLine("Drive could not read. Sense follows...");
|
||||
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h",
|
||||
decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h", decSense.Value.SenseKey,
|
||||
decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -457,8 +456,8 @@ partial class Dump
|
||||
|
||||
_dumpLog.WriteLine("Drive could not read. Sense follows...");
|
||||
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h",
|
||||
decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h", decSense.Value.SenseKey,
|
||||
decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -512,8 +511,8 @@ partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
bool canLocateLong = false;
|
||||
bool canLocate = false;
|
||||
var canLocateLong = false;
|
||||
var canLocate = false;
|
||||
|
||||
UpdateStatus?.Invoke("Positioning tape to block 1.");
|
||||
_dumpLog.WriteLine("Positioning tape to block 1");
|
||||
@@ -713,8 +712,7 @@ partial class Dump
|
||||
{
|
||||
if(!_force)
|
||||
{
|
||||
_dumpLog.
|
||||
WriteLine("Cannot reposition tape, unable to resume. If you want to continue use force.");
|
||||
_dumpLog.WriteLine("Cannot reposition tape, unable to resume. If you want to continue use force.");
|
||||
|
||||
StoppingErrorMessage?.
|
||||
Invoke("Cannot reposition tape, unable to resume. If you want to continue use force.");
|
||||
@@ -743,7 +741,7 @@ partial class Dump
|
||||
|
||||
// And yet, did not rewind!
|
||||
if(decSense.HasValue &&
|
||||
((decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x00 && decSense.Value.ASCQ != 0x04) ||
|
||||
(decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x00 && decSense.Value.ASCQ != 0x04 ||
|
||||
decSense.Value.ASC != 0x00))
|
||||
{
|
||||
StoppingErrorMessage?.Invoke("Drive could not rewind, please correct. Sense follows..." +
|
||||
@@ -809,9 +807,7 @@ partial class Dump
|
||||
currentBlock = _resume.NextBlock;
|
||||
|
||||
currentTapeFile =
|
||||
outputTape.Files.FirstOrDefault(f => f.LastBlock ==
|
||||
outputTape?.
|
||||
Files.Max(g => g.LastBlock));
|
||||
outputTape.Files.FirstOrDefault(f => f.LastBlock == outputTape?.Files.Max(g => g.LastBlock));
|
||||
|
||||
currentTapePartition =
|
||||
outputTape.TapePartitions.FirstOrDefault(p => p.LastBlock ==
|
||||
@@ -925,8 +921,7 @@ partial class Dump
|
||||
ili &&
|
||||
valid)
|
||||
{
|
||||
blockSize = (uint)((int)blockSize -
|
||||
BitConverter.ToInt32(BitConverter.GetBytes(information), 0));
|
||||
blockSize = (uint)((int)blockSize - BitConverter.ToInt32(BitConverter.GetBytes(information), 0));
|
||||
|
||||
if(!fixedLen)
|
||||
transferLen = blockSize;
|
||||
@@ -968,8 +963,7 @@ partial class Dump
|
||||
|
||||
// For sure this is an end-of-tape/partition
|
||||
case SenseKeys.BlankCheck when decSense.Value.ASC == 0x00 &&
|
||||
(decSense.Value.ASCQ == 0x02 || decSense.Value.ASCQ == 0x05 ||
|
||||
eom):
|
||||
(decSense.Value.ASCQ == 0x02 || decSense.Value.ASCQ == 0x05 || eom):
|
||||
// TODO: Detect end of partition
|
||||
endOfMedia = true;
|
||||
UpdateStatus?.Invoke("Found end-of-tape/partition...");
|
||||
@@ -1033,8 +1027,8 @@ partial class Dump
|
||||
|
||||
_dumpLog.WriteLine($"Drive could not read block ${currentBlock}. Sense follows...");
|
||||
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h",
|
||||
decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
_dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h", decSense.Value.SenseKey,
|
||||
decSense.Value.ASC, decSense.Value.ASCQ);
|
||||
}
|
||||
|
||||
// TODO: Reset device after X errors
|
||||
@@ -1116,9 +1110,9 @@ partial class Dump
|
||||
_retryPasses > 0 &&
|
||||
(canLocate || canLocateLong))
|
||||
{
|
||||
int pass = 1;
|
||||
bool forward = false;
|
||||
bool runningPersistent = false;
|
||||
var pass = 1;
|
||||
var forward = false;
|
||||
var runningPersistent = false;
|
||||
|
||||
Modes.ModePage? currentModePage = null;
|
||||
|
||||
@@ -1128,7 +1122,7 @@ partial class Dump
|
||||
}
|
||||
|
||||
InitProgress?.Invoke();
|
||||
repeatRetry:
|
||||
repeatRetry:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
|
||||
foreach(ulong badBlock in tmpArray)
|
||||
@@ -1269,7 +1263,7 @@ partial class Dump
|
||||
outputTape.SetDumpHardware(_resume.Tries);
|
||||
|
||||
// TODO: Media Serial Number
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
var metadata = new ImageInfo
|
||||
{
|
||||
Application = "Aaru",
|
||||
ApplicationVersion = Version.GetVersion()
|
||||
@@ -1314,7 +1308,7 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
var inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
@@ -1359,8 +1353,7 @@ partial class Dump
|
||||
|
||||
if(sidecar.BlockMedia[0].FileSystemInformation != null)
|
||||
filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation
|
||||
where partition.FileSystems != null
|
||||
from fileSystem in partition.FileSystems
|
||||
where partition.FileSystems != null from fileSystem in partition.FileSystems
|
||||
select (partition.StartSector, fileSystem.Type));
|
||||
|
||||
if(filesystems.Count > 0)
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
// Copyright © 2020-2022 Rebecca Wallander
|
||||
// ****************************************************************************/
|
||||
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
@@ -34,14 +42,8 @@ using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.DVD;
|
||||
using Aaru.Decryption;
|
||||
using Aaru.Decryption.DVD;
|
||||
using Aaru.Settings;
|
||||
using Schemas;
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
@@ -107,8 +109,8 @@ partial class Dump
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
{
|
||||
if(Settings.Settings.Current.EnableDecryption &&
|
||||
discKey != null &&
|
||||
if(Settings.Current.EnableDecryption &&
|
||||
discKey != null &&
|
||||
_titleKeys)
|
||||
{
|
||||
for(ulong j = 0; j < blocksToRead; j++)
|
||||
@@ -195,8 +197,7 @@ partial class Dump
|
||||
ErrorMessage?.Invoke($"Error retrieving CMI for sector {i}");
|
||||
else
|
||||
{
|
||||
errno = outputFormat.ReadSectorsTag(i, blocksToRead,
|
||||
SectorTagType.DvdTitleKeyDecrypted,
|
||||
errno = outputFormat.ReadSectorsTag(i, blocksToRead, SectorTagType.DvdTitleKeyDecrypted,
|
||||
out byte[] titleKey);
|
||||
|
||||
if(errno != ErrorNumber.NoError)
|
||||
|
||||
@@ -31,6 +31,12 @@
|
||||
// Copyright © 2020-2022 Rebecca Wallander
|
||||
// ****************************************************************************/
|
||||
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -50,17 +56,13 @@ using Aaru.Decoders.DVD;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SCSI.MMC;
|
||||
using Aaru.Devices;
|
||||
using Aaru.Settings;
|
||||
using Schemas;
|
||||
using DeviceReport = Aaru.Core.Devices.Report.DeviceReport;
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
using MediaType = Aaru.CommonTypes.MediaType;
|
||||
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
/// <summary>Implements dumping SCSI Block Commands and Reduced Block Commands devices</summary>
|
||||
partial class Dump
|
||||
{
|
||||
@@ -75,7 +77,7 @@ partial class Dump
|
||||
bool sense;
|
||||
byte scsiMediumType = 0;
|
||||
byte scsiDensityCode = 0;
|
||||
bool containsFloppyPage = false;
|
||||
var containsFloppyPage = false;
|
||||
const ushort sbcProfile = 0x0001;
|
||||
DateTime start;
|
||||
DateTime end;
|
||||
@@ -132,8 +134,8 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Requesting MODE SENSE (10).");
|
||||
UpdateStatus?.Invoke("Requesting MODE SENSE (10).");
|
||||
|
||||
sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F,
|
||||
0xFF, 5, out _);
|
||||
sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF,
|
||||
5, out _);
|
||||
|
||||
if(!sense ||
|
||||
_dev.Error)
|
||||
@@ -155,8 +157,8 @@ partial class Dump
|
||||
out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00,
|
||||
5, out _);
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5,
|
||||
out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
sense = _dev.ModeSense(out cmdBuf, out _, 5, out _);
|
||||
@@ -179,8 +181,7 @@ partial class Dump
|
||||
// TODO: Fix this
|
||||
containsFloppyPage = decMode.Value.Pages?.Aggregate(containsFloppyPage,
|
||||
(current, modePage) =>
|
||||
current | (modePage.Page == 0x05)) ==
|
||||
true;
|
||||
current | (modePage.Page == 0x05)) == true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,9 +345,9 @@ partial class Dump
|
||||
UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");
|
||||
_dumpLog.WriteLine("Reading {0} sectors at a time.", blocksToRead);
|
||||
|
||||
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private);
|
||||
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile);
|
||||
bool imageCreated = false;
|
||||
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private);
|
||||
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile);
|
||||
var imageCreated = false;
|
||||
|
||||
if(!opticalDisc)
|
||||
{
|
||||
@@ -369,7 +370,7 @@ partial class Dump
|
||||
|
||||
start = DateTime.UtcNow;
|
||||
double imageWriteDuration = 0;
|
||||
bool writeSingleOpticalTrack = true;
|
||||
var writeSingleOpticalTrack = true;
|
||||
|
||||
if(opticalDisc)
|
||||
{
|
||||
@@ -380,8 +381,7 @@ partial class Dump
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
DiscInformation.StandardDiscInformation? discInformation =
|
||||
DiscInformation.Decode000b(readBuffer);
|
||||
DiscInformation.StandardDiscInformation? discInformation = DiscInformation.Decode000b(readBuffer);
|
||||
|
||||
// This means the output image can store sessions that are not on a CD, like on a DVD or Blu-ray
|
||||
bool canStoreNotCdSessions =
|
||||
@@ -537,9 +537,8 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Error sending tracks to output image, not continuing.");
|
||||
_dumpLog.WriteLine(opticalPlugin.ErrorMessage);
|
||||
|
||||
StoppingErrorMessage?.
|
||||
Invoke("Error sending tracks to output image, not continuing." +
|
||||
Environment.NewLine + opticalPlugin.ErrorMessage);
|
||||
StoppingErrorMessage?.Invoke("Error sending tracks to output image, not continuing." +
|
||||
Environment.NewLine + opticalPlugin.ErrorMessage);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -571,7 +570,7 @@ partial class Dump
|
||||
}
|
||||
else if(decMode?.Pages != null)
|
||||
{
|
||||
bool setGeometry = false;
|
||||
var setGeometry = false;
|
||||
|
||||
foreach(Modes.ModePage page in decMode.Value.Pages)
|
||||
if(page.Page == 0x04 &&
|
||||
@@ -693,10 +692,10 @@ partial class Dump
|
||||
if(_resume?.BlankExtents != null)
|
||||
blankExtents = ExtentsConverter.FromMetadata(_resume.BlankExtents);
|
||||
|
||||
bool newTrim = false;
|
||||
var newTrim = false;
|
||||
|
||||
if(mediaTags.TryGetValue(MediaTagType.DVD_CMI, out byte[] cmi) &&
|
||||
Settings.Settings.Current.EnableDecryption &&
|
||||
Settings.Current.EnableDecryption &&
|
||||
_titleKeys &&
|
||||
dskType == MediaType.DVDROM &&
|
||||
(CopyrightType)cmi[0] == CopyrightType.CSS)
|
||||
@@ -765,17 +764,16 @@ partial class Dump
|
||||
_retryPasses > 0)
|
||||
RetrySbcData(scsiReader, currentTry, extents, ref totalDuration, blankExtents);
|
||||
|
||||
if(_resume.MissingTitleKeys?.Count > 0 &&
|
||||
!_aborted &&
|
||||
_retryPasses > 0 &&
|
||||
Settings.Settings.Current.EnableDecryption &&
|
||||
_titleKeys &&
|
||||
if(_resume.MissingTitleKeys?.Count > 0 &&
|
||||
!_aborted &&
|
||||
_retryPasses > 0 &&
|
||||
Settings.Current.EnableDecryption &&
|
||||
_titleKeys &&
|
||||
mediaTags.ContainsKey(MediaTagType.DVD_DiscKey_Decrypted))
|
||||
RetryTitleKeys(dvdDecrypt, mediaTags[MediaTagType.DVD_DiscKey_Decrypted], ref totalDuration);
|
||||
#endregion Error handling
|
||||
|
||||
if(opticalDisc)
|
||||
{
|
||||
foreach(KeyValuePair<MediaTagType, byte[]> tag in mediaTags)
|
||||
{
|
||||
if(tag.Value is null)
|
||||
@@ -793,12 +791,10 @@ partial class Dump
|
||||
// Cannot write tag to image
|
||||
StoppingErrorMessage?.Invoke($"Cannot write tag {tag.Key}.");
|
||||
|
||||
_dumpLog.WriteLine($"Cannot write tag {tag.Key}." + Environment.NewLine +
|
||||
outputFormat.ErrorMessage);
|
||||
_dumpLog.WriteLine($"Cannot write tag {tag.Key}." + Environment.NewLine + outputFormat.ErrorMessage);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!_dev.IsRemovable ||
|
||||
@@ -878,8 +874,8 @@ partial class Dump
|
||||
|
||||
if(!sense ||
|
||||
_dev.Error)
|
||||
sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current,
|
||||
0x3F, 0x00, 5, out _);
|
||||
sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F,
|
||||
0x00, 5, out _);
|
||||
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
@@ -902,12 +898,12 @@ partial class Dump
|
||||
UpdateStatus?.Invoke("Requesting MODE SENSE (6).");
|
||||
_dumpLog.WriteLine("Requesting MODE SENSE (6).");
|
||||
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00,
|
||||
5, out _);
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5,
|
||||
out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F,
|
||||
0x00, 5, out _);
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00,
|
||||
5, out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
sense = _dev.ModeSense(out cmdBuf, out _, 5, out _);
|
||||
@@ -923,8 +919,8 @@ partial class Dump
|
||||
{
|
||||
_dumpLog.WriteLine("Cannot write SCSI MODE SENSE (6).");
|
||||
|
||||
StoppingErrorMessage?.Invoke("Cannot write SCSI MODE SENSE (6)." +
|
||||
Environment.NewLine + outputFormat.ErrorMessage);
|
||||
StoppingErrorMessage?.Invoke("Cannot write SCSI MODE SENSE (6)." + Environment.NewLine +
|
||||
outputFormat.ErrorMessage);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -944,7 +940,7 @@ partial class Dump
|
||||
|
||||
// TODO: Media Serial Number
|
||||
// TODO: Non-removable drive information
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
var metadata = new ImageInfo
|
||||
{
|
||||
Application = "Aaru",
|
||||
ApplicationVersion = Version.GetVersion()
|
||||
@@ -986,7 +982,7 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
var inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
@@ -1117,8 +1113,8 @@ partial class Dump
|
||||
UpdateStatus?.Invoke("Requesting MODE SENSE (10).");
|
||||
_dumpLog.WriteLine("Requesting MODE SENSE (10).");
|
||||
|
||||
sense = _dev.ModeSense10(out cmdBuf, out _, false, true,
|
||||
ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, out _);
|
||||
sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current,
|
||||
0x3F, 0xFF, 5, out _);
|
||||
|
||||
if(!sense ||
|
||||
_dev.Error)
|
||||
@@ -1139,8 +1135,8 @@ partial class Dump
|
||||
UpdateStatus?.Invoke("Requesting MODE SENSE (6).");
|
||||
_dumpLog.WriteLine("Requesting MODE SENSE (6).");
|
||||
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current,
|
||||
0x3F, 0x00, 5, out _);
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F,
|
||||
0x00, 5, out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current,
|
||||
@@ -1177,17 +1173,14 @@ partial class Dump
|
||||
o.type
|
||||
}).Distinct())
|
||||
{
|
||||
UpdateStatus?.
|
||||
Invoke($"Found filesystem {filesystem.type} at sector {filesystem.start}");
|
||||
UpdateStatus?.Invoke($"Found filesystem {filesystem.type} at sector {filesystem.start}");
|
||||
|
||||
_dumpLog.WriteLine("Found filesystem {0} at sector {1}", filesystem.type,
|
||||
filesystem.start);
|
||||
_dumpLog.WriteLine("Found filesystem {0} at sector {1}", filesystem.type, filesystem.start);
|
||||
}
|
||||
|
||||
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
|
||||
|
||||
(string type, string subType) xmlType =
|
||||
CommonTypes.Metadata.MediaType.MediaTypeToString(dskType);
|
||||
(string type, string subType) xmlType = CommonTypes.Metadata.MediaType.MediaTypeToString(dskType);
|
||||
|
||||
sidecar.BlockMedia[0].DiskType = xmlType.type;
|
||||
sidecar.BlockMedia[0].DiskSubType = xmlType.subType;
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
// Copyright © 2020-2022 Rebecca Wallander
|
||||
// ****************************************************************************/
|
||||
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
@@ -37,13 +45,6 @@ using Aaru.Decryption;
|
||||
using Aaru.Decryption.DVD;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
@@ -53,12 +54,12 @@ partial class Dump
|
||||
/// <param name="totalDuration">Total time spent in commands</param>
|
||||
/// <param name="scsiReader">SCSI reader</param>
|
||||
/// <param name="blankExtents">Blank extents</param>
|
||||
void RetrySbcData(Reader scsiReader, DumpHardwareType currentTry, ExtentsULong extents,
|
||||
ref double totalDuration, ExtentsULong blankExtents)
|
||||
void RetrySbcData(Reader scsiReader, DumpHardwareType currentTry, ExtentsULong extents, ref double totalDuration,
|
||||
ExtentsULong blankExtents)
|
||||
{
|
||||
int pass = 1;
|
||||
bool forward = true;
|
||||
bool runningPersistent = false;
|
||||
var pass = 1;
|
||||
var forward = true;
|
||||
var runningPersistent = false;
|
||||
bool sense;
|
||||
byte[] buffer;
|
||||
bool recoveredError;
|
||||
@@ -66,7 +67,7 @@ partial class Dump
|
||||
byte[] md6;
|
||||
byte[] md10;
|
||||
bool blankCheck;
|
||||
bool newBlank = false;
|
||||
var newBlank = false;
|
||||
var outputFormat = _outputPlugin as IWritableImage;
|
||||
|
||||
if(_persistent)
|
||||
@@ -79,8 +80,8 @@ partial class Dump
|
||||
|
||||
if(sense)
|
||||
{
|
||||
sense = _dev.ModeSense10(out buffer, out _, false, ScsiModeSensePageControl.Current, 0x01,
|
||||
_dev.Timeout, out _);
|
||||
sense = _dev.ModeSense10(out buffer, out _, false, ScsiModeSensePageControl.Current, 0x01, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
@@ -97,8 +98,8 @@ partial class Dump
|
||||
Modes.DecodedMode? dcMode6 = Modes.DecodeMode6(buffer, _dev.ScsiType);
|
||||
|
||||
if(dcMode6?.Pages != null)
|
||||
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
|
||||
modePage.Page == 0x01 && modePage.Subpage == 0x00))
|
||||
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage.Page == 0x01 &&
|
||||
modePage.Subpage == 0x00))
|
||||
currentModePage = modePage;
|
||||
}
|
||||
|
||||
@@ -222,13 +223,11 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
|
||||
}
|
||||
else
|
||||
{
|
||||
runningPersistent = true;
|
||||
}
|
||||
}
|
||||
|
||||
InitProgress?.Invoke();
|
||||
repeatRetry:
|
||||
repeatRetry:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
|
||||
foreach(ulong badSector in tmpArray)
|
||||
@@ -263,7 +262,7 @@ partial class Dump
|
||||
continue;
|
||||
}
|
||||
|
||||
if((!sense && !_dev.Error) || recoveredError)
|
||||
if(!sense && !_dev.Error || recoveredError)
|
||||
{
|
||||
_resume.BadBlocks.Remove(badSector);
|
||||
extents.Add(badSector);
|
||||
@@ -272,9 +271,7 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Correctly retried block {0} in pass {1}.", badSector, pass);
|
||||
}
|
||||
else if(runningPersistent)
|
||||
{
|
||||
outputFormat.WriteSector(buffer, badSector);
|
||||
}
|
||||
}
|
||||
|
||||
if(pass < _retryPasses &&
|
||||
@@ -321,15 +318,15 @@ partial class Dump
|
||||
|
||||
void RetryTitleKeys(DVDDecryption dvdDecrypt, byte[] discKey, ref double totalDuration)
|
||||
{
|
||||
int pass = 1;
|
||||
bool forward = true;
|
||||
var pass = 1;
|
||||
var forward = true;
|
||||
bool sense;
|
||||
byte[] buffer;
|
||||
var outputFormat = _outputPlugin as IWritableImage;
|
||||
|
||||
InitProgress?.Invoke();
|
||||
|
||||
repeatRetry:
|
||||
repeatRetry:
|
||||
ulong[] tmpArray = _resume.MissingTitleKeys.ToArray();
|
||||
|
||||
foreach(ulong missingKey in tmpArray)
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
@@ -8,12 +16,6 @@ using Aaru.Decoders.SCSI;
|
||||
using Aaru.Helpers;
|
||||
using Schemas;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>
|
||||
@@ -52,7 +54,7 @@ partial class Dump
|
||||
byte[] buffer;
|
||||
ulong sectorSpeedStart = 0;
|
||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||
bool canMediumScan = true;
|
||||
var canMediumScan = true;
|
||||
var outputFormat = _outputPlugin as IWritableImage;
|
||||
|
||||
InitProgress?.Invoke();
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
@@ -34,6 +32,10 @@ using Schemas;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Trims data when dumping from a SCSI Block Commands compliant device</summary>
|
||||
@@ -41,15 +43,14 @@ partial class Dump
|
||||
/// <param name="extents">Correctly dump extents</param>
|
||||
/// <param name="currentTry">Resume information</param>
|
||||
/// <param name="blankExtents">Blank extents</param>
|
||||
void TrimSbcData(Reader scsiReader, ExtentsULong extents, DumpHardwareType currentTry,
|
||||
ExtentsULong blankExtents)
|
||||
void TrimSbcData(Reader scsiReader, ExtentsULong extents, DumpHardwareType currentTry, ExtentsULong blankExtents)
|
||||
{
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
bool sense;
|
||||
bool recoveredError;
|
||||
bool blankCheck;
|
||||
byte[] buffer;
|
||||
bool newBlank = false;
|
||||
var newBlank = false;
|
||||
var outputFormat = _outputPlugin as IWritableImage;
|
||||
|
||||
foreach(ulong badSector in tmpArray)
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -40,19 +46,17 @@ using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.MMC;
|
||||
using Aaru.Decoders.SecureDigital;
|
||||
using Schemas;
|
||||
using CSD = Aaru.Decoders.MMC.CSD;
|
||||
using Decoders = Aaru.Decoders.MMC.Decoders;
|
||||
using DeviceType = Aaru.CommonTypes.Enums.DeviceType;
|
||||
using MediaType = Aaru.CommonTypes.MediaType;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
/// <summary>Implements dumping a MultiMediaCard or SecureDigital flash card</summary>
|
||||
public partial class Dump
|
||||
{
|
||||
@@ -85,9 +89,9 @@ public partial class Dump
|
||||
byte[] ecsd = null;
|
||||
byte[] scr = null;
|
||||
uint physicalBlockSize = 0;
|
||||
bool byteAddressed = true;
|
||||
var byteAddressed = true;
|
||||
uint[] response;
|
||||
bool supportsCmd23 = false;
|
||||
var supportsCmd23 = false;
|
||||
var outputFormat = _outputPlugin as IWritableImage;
|
||||
|
||||
Dictionary<MediaTagType, byte[]> mediaTags = new();
|
||||
@@ -102,7 +106,7 @@ public partial class Dump
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
CSD csdDecoded = Decoders.MMC.Decoders.DecodeCSD(csd);
|
||||
CSD csdDecoded = Decoders.DecodeCSD(csd);
|
||||
blocks = (ulong)((csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2));
|
||||
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
|
||||
|
||||
@@ -119,7 +123,7 @@ public partial class Dump
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
ExtendedCSD ecsdDecoded = Decoders.MMC.Decoders.DecodeExtendedCSD(ecsd);
|
||||
ExtendedCSD ecsdDecoded = Decoders.DecodeExtendedCSD(ecsd);
|
||||
blocks = ecsdDecoded.SectorCount;
|
||||
blockSize = (uint)(ecsdDecoded.SectorSize == 1 ? 4096 : 512);
|
||||
|
||||
@@ -173,7 +177,7 @@ public partial class Dump
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
Decoders.SecureDigital.CSD csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd);
|
||||
Aaru.Decoders.SecureDigital.CSD csdDecoded = Aaru.Decoders.SecureDigital.Decoders.DecodeCSD(csd);
|
||||
|
||||
blocks = (ulong)(csdDecoded.Structure == 0
|
||||
? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2)
|
||||
@@ -223,8 +227,8 @@ public partial class Dump
|
||||
}
|
||||
else
|
||||
{
|
||||
supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(scr)?.CommandSupport.
|
||||
HasFlag(CommandSupport.SetBlockCount) ?? false;
|
||||
supportsCmd23 = Aaru.Decoders.SecureDigital.Decoders.DecodeSCR(scr)?.CommandSupport.
|
||||
HasFlag(CommandSupport.SetBlockCount) ?? false;
|
||||
|
||||
mediaTags.Add(MediaTagType.SD_SCR, null);
|
||||
}
|
||||
@@ -271,8 +275,7 @@ public partial class Dump
|
||||
|
||||
if(supportsCmd23 && blocksToRead > 1)
|
||||
{
|
||||
sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, 1, byteAddressed, timeout,
|
||||
out duration);
|
||||
sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, 1, byteAddressed, timeout, out duration);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
supportsCmd23 = false;
|
||||
@@ -292,8 +295,8 @@ public partial class Dump
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
error = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed,
|
||||
timeout, out duration);
|
||||
error = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, timeout,
|
||||
out duration);
|
||||
|
||||
if(error)
|
||||
blocksToRead /= 2;
|
||||
@@ -307,19 +310,19 @@ public partial class Dump
|
||||
{
|
||||
_dumpLog.WriteLine("ERROR: Cannot get blocks to read, device error {0}.", _dev.LastError);
|
||||
|
||||
StoppingErrorMessage?.
|
||||
Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length.");
|
||||
StoppingErrorMessage?.Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length.");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(_useBufferedReads && blocksToRead > 1 && !supportsCmd23)
|
||||
if(_useBufferedReads &&
|
||||
blocksToRead > 1 &&
|
||||
!supportsCmd23)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
error = _dev.BufferedOsRead(out cmdBuf, 0, blockSize * blocksToRead,
|
||||
out duration);
|
||||
error = _dev.BufferedOsRead(out cmdBuf, 0, blockSize * blocksToRead, out duration);
|
||||
|
||||
if(error)
|
||||
blocksToRead /= 2;
|
||||
@@ -342,12 +345,14 @@ public partial class Dump
|
||||
}
|
||||
}
|
||||
|
||||
if(!_useBufferedReads && blocksToRead > 1 && !supportsCmd23)
|
||||
if(!_useBufferedReads &&
|
||||
blocksToRead > 1 &&
|
||||
!supportsCmd23)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
error = _dev.ReadMultipleUsingSingle(out cmdBuf, out _, 0, blockSize, blocksToRead,
|
||||
byteAddressed, timeout, out duration);
|
||||
error = _dev.ReadMultipleUsingSingle(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed,
|
||||
timeout, out duration);
|
||||
|
||||
if(error)
|
||||
blocksToRead /= 2;
|
||||
@@ -365,8 +370,7 @@ public partial class Dump
|
||||
{
|
||||
_dumpLog.WriteLine("ERROR: Cannot get blocks to read, device error {0}.", _dev.LastError);
|
||||
|
||||
StoppingErrorMessage?.
|
||||
Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length.");
|
||||
StoppingErrorMessage?.Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length.");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -374,15 +378,13 @@ public partial class Dump
|
||||
|
||||
if(blocksToRead == 1)
|
||||
{
|
||||
error = _dev.ReadSingleBlock(out cmdBuf, out _, 0, blockSize, byteAddressed, timeout,
|
||||
out duration);
|
||||
error = _dev.ReadSingleBlock(out cmdBuf, out _, 0, blockSize, byteAddressed, timeout, out duration);
|
||||
|
||||
if(error)
|
||||
{
|
||||
_dumpLog.WriteLine("ERROR: Could not read from device, device error {0}.", _dev.LastError);
|
||||
|
||||
StoppingErrorMessage?.
|
||||
Invoke($"Device error {_dev.LastError} trying to read from device.");
|
||||
StoppingErrorMessage?.Invoke($"Device error {_dev.LastError} trying to read from device.");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -421,7 +423,7 @@ public partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
var ret = true;
|
||||
|
||||
foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputFormat.SupportedMediaTags.Contains(tag)))
|
||||
{
|
||||
@@ -587,7 +589,7 @@ public partial class Dump
|
||||
|
||||
start = DateTime.UtcNow;
|
||||
double imageWriteDuration = 0;
|
||||
bool newTrim = false;
|
||||
var newTrim = false;
|
||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||
ulong sectorSpeedStart = 0;
|
||||
|
||||
@@ -625,11 +627,10 @@ public partial class Dump
|
||||
error = _dev.ReadWithBlockCount(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed,
|
||||
timeout, out duration);
|
||||
else if(_useBufferedReads)
|
||||
error = _dev.BufferedOsRead(out cmdBuf, (long)(i * blockSize), blockSize * blocksToRead,
|
||||
out duration);
|
||||
error = _dev.BufferedOsRead(out cmdBuf, (long)(i * blockSize), blockSize * blocksToRead, out duration);
|
||||
else
|
||||
error = _dev.ReadMultipleUsingSingle(out cmdBuf, out _, (uint)i, blockSize, blocksToRead,
|
||||
byteAddressed, timeout, out duration);
|
||||
error = _dev.ReadMultipleUsingSingle(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed,
|
||||
timeout, out duration);
|
||||
|
||||
if(!error)
|
||||
{
|
||||
@@ -754,12 +755,12 @@ public partial class Dump
|
||||
!_aborted &&
|
||||
_retryPasses > 0)
|
||||
{
|
||||
int pass = 1;
|
||||
bool forward = true;
|
||||
bool runningPersistent = false;
|
||||
var pass = 1;
|
||||
var forward = true;
|
||||
var runningPersistent = false;
|
||||
|
||||
InitProgress?.Invoke();
|
||||
repeatRetryLba:
|
||||
repeatRetryLba:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
|
||||
foreach(ulong badSector in tmpArray)
|
||||
@@ -820,7 +821,7 @@ public partial class Dump
|
||||
outputFormat.SetDumpHardware(_resume.Tries);
|
||||
|
||||
// TODO: Drive info
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
var metadata = new ImageInfo
|
||||
{
|
||||
Application = "Aaru",
|
||||
ApplicationVersion = Version.GetVersion()
|
||||
@@ -857,7 +858,7 @@ public partial class Dump
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
var inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
@@ -908,8 +909,7 @@ public partial class Dump
|
||||
case DeviceType.SecureDigital:
|
||||
CommonTypes.Metadata.MediaType.MediaTypeToString(MediaType.SecureDigital);
|
||||
|
||||
sidecar.BlockMedia[0].Dimensions =
|
||||
Dimensions.DimensionsFromMediaType(MediaType.SecureDigital);
|
||||
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(MediaType.SecureDigital);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -51,10 +57,6 @@ using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
|
||||
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
/// <summary>Implements dumping an Xbox Game Disc using a Kreon drive</summary>
|
||||
partial class Dump
|
||||
{
|
||||
@@ -142,7 +144,7 @@ partial class Dump
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] tmpBuf = new byte[ssBuf.Length - 4];
|
||||
var tmpBuf = new byte[ssBuf.Length - 4];
|
||||
Array.Copy(ssBuf, 4, tmpBuf, 0, ssBuf.Length - 4);
|
||||
mediaTags.Add(MediaTagType.Xbox_SecuritySector, tmpBuf);
|
||||
|
||||
@@ -175,8 +177,7 @@ partial class Dump
|
||||
}
|
||||
|
||||
ulong totalSize =
|
||||
(ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]) &
|
||||
0xFFFFFFFF;
|
||||
(ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]) & 0xFFFFFFFF;
|
||||
|
||||
UpdateStatus?.Invoke("Reading Physical Format Information.");
|
||||
_dumpLog.WriteLine("Reading Physical Format Information.");
|
||||
@@ -225,8 +226,8 @@ partial class Dump
|
||||
UpdateStatus?.Invoke("Video partition is too big, did lock work? Trying cold values.");
|
||||
_dumpLog.WriteLine("Video partition is too big, did lock work? Trying cold values.");
|
||||
|
||||
totalSize = (ulong)((coldReadCapacity[0] << 24) + (coldReadCapacity[1] << 16) +
|
||||
(coldReadCapacity[2] << 8) + coldReadCapacity[3]) & 0xFFFFFFFF;
|
||||
totalSize = (ulong)((coldReadCapacity[0] << 24) + (coldReadCapacity[1] << 16) + (coldReadCapacity[2] << 8) +
|
||||
coldReadCapacity[3]) & 0xFFFFFFFF;
|
||||
|
||||
tmpBuf = new byte[coldPfi.Length - 4];
|
||||
Array.Copy(coldPfi, 4, tmpBuf, 0, coldPfi.Length - 4);
|
||||
@@ -371,8 +372,8 @@ partial class Dump
|
||||
Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.Length - 4);
|
||||
mediaTags.Add(MediaTagType.Xbox_DMI, tmpBuf);
|
||||
|
||||
totalSize = l0Video + l1Video + (middleZone * 2) + gameSize;
|
||||
ulong layerBreak = l0Video + middleZone + (gameSize / 2);
|
||||
totalSize = l0Video + l1Video + middleZone * 2 + gameSize;
|
||||
ulong layerBreak = l0Video + middleZone + gameSize / 2;
|
||||
|
||||
UpdateStatus?.Invoke($"Video layer 0 size: {l0Video} sectors");
|
||||
UpdateStatus?.Invoke($"Video layer 1 size: {l1Video} sectors");
|
||||
@@ -442,7 +443,7 @@ partial class Dump
|
||||
if(_skip < blocksToRead)
|
||||
_skip = blocksToRead;
|
||||
|
||||
bool ret = true;
|
||||
var ret = true;
|
||||
|
||||
foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputFormat.SupportedMediaTags.Contains(tag)))
|
||||
{
|
||||
@@ -503,7 +504,7 @@ partial class Dump
|
||||
|
||||
(outputFormat as IWritableOpticalImage).SetTracks(new List<Track>
|
||||
{
|
||||
new Track
|
||||
new()
|
||||
{
|
||||
BytesPerSector = (int)blockSize,
|
||||
EndSector = blocks - 1,
|
||||
@@ -523,7 +524,7 @@ partial class Dump
|
||||
_dumpLog.WriteLine("Resuming from block {0}.", _resume.NextBlock);
|
||||
}
|
||||
|
||||
bool newTrim = false;
|
||||
var newTrim = false;
|
||||
|
||||
_dumpLog.WriteLine("Reading game partition.");
|
||||
UpdateStatus?.Invoke("Reading game partition.");
|
||||
@@ -531,7 +532,7 @@ partial class Dump
|
||||
ulong sectorSpeedStart = 0;
|
||||
InitProgress?.Invoke();
|
||||
|
||||
for(int e = 0; e <= 16; e++)
|
||||
for(var e = 0; e <= 16; e++)
|
||||
{
|
||||
if(_aborted)
|
||||
{
|
||||
@@ -554,13 +555,13 @@ partial class Dump
|
||||
if(xboxSs.Value.Extents[e].StartPSN <= xboxSs.Value.Layer0EndPSN)
|
||||
extentStart = xboxSs.Value.Extents[e].StartPSN - 0x30000;
|
||||
else
|
||||
extentStart = ((xboxSs.Value.Layer0EndPSN + 1) * 2) -
|
||||
extentStart = (xboxSs.Value.Layer0EndPSN + 1) * 2 -
|
||||
((xboxSs.Value.Extents[e].StartPSN ^ 0xFFFFFF) + 1) - 0x30000;
|
||||
|
||||
if(xboxSs.Value.Extents[e].EndPSN <= xboxSs.Value.Layer0EndPSN)
|
||||
extentEnd = xboxSs.Value.Extents[e].EndPSN - 0x30000;
|
||||
else
|
||||
extentEnd = ((xboxSs.Value.Layer0EndPSN + 1) * 2) -
|
||||
extentEnd = (xboxSs.Value.Layer0EndPSN + 1) * 2 -
|
||||
((xboxSs.Value.Extents[e].EndPSN ^ 0xFFFFFF) + 1) - 0x30000;
|
||||
}
|
||||
|
||||
@@ -601,8 +602,8 @@ partial class Dump
|
||||
UpdateProgress?.Invoke($"Reading sector {i} of {totalSize} ({currentSpeed:F3} MiB/sec.)", (long)i,
|
||||
(long)totalSize);
|
||||
|
||||
sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)i, blockSize,
|
||||
0, blocksToRead, false, _dev.Timeout, out cmdDuration);
|
||||
sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)i, blockSize, 0,
|
||||
blocksToRead, false, _dev.Timeout, out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
|
||||
@@ -959,7 +960,7 @@ partial class Dump
|
||||
!_aborted &&
|
||||
_retryPasses > 0)
|
||||
{
|
||||
List<ulong> tmpList = new List<ulong>();
|
||||
var tmpList = new List<ulong>();
|
||||
|
||||
foreach(ulong ur in _resume.BadBlocks)
|
||||
for(ulong i = ur; i < ur + blocksToRead; i++)
|
||||
@@ -967,9 +968,9 @@ partial class Dump
|
||||
|
||||
tmpList.Sort();
|
||||
|
||||
int pass = 1;
|
||||
bool forward = true;
|
||||
bool runningPersistent = false;
|
||||
var pass = 1;
|
||||
var forward = true;
|
||||
var runningPersistent = false;
|
||||
|
||||
_resume.BadBlocks = tmpList;
|
||||
Modes.ModePage? currentModePage = null;
|
||||
@@ -1001,8 +1002,7 @@ partial class Dump
|
||||
}
|
||||
else
|
||||
{
|
||||
Modes.DecodedMode? dcMode6 =
|
||||
Modes.DecodeMode6(readBuffer, PeripheralDeviceTypes.MultiMediaDevice);
|
||||
Modes.DecodedMode? dcMode6 = Modes.DecodeMode6(readBuffer, PeripheralDeviceTypes.MultiMediaDevice);
|
||||
|
||||
if(dcMode6.HasValue)
|
||||
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
|
||||
@@ -1065,15 +1065,14 @@ partial class Dump
|
||||
|
||||
AaruConsole.DebugWriteLine("Error: {0}", Sense.PrettifySense(senseBuf));
|
||||
|
||||
_dumpLog.
|
||||
WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
|
||||
_dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
|
||||
}
|
||||
else
|
||||
runningPersistent = true;
|
||||
}
|
||||
|
||||
InitProgress?.Invoke();
|
||||
repeatRetry:
|
||||
repeatRetry:
|
||||
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
||||
|
||||
foreach(ulong badSector in tmpArray)
|
||||
@@ -1187,7 +1186,7 @@ partial class Dump
|
||||
|
||||
outputFormat.SetDumpHardware(_resume.Tries);
|
||||
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
var metadata = new ImageInfo
|
||||
{
|
||||
Application = "Aaru",
|
||||
ApplicationVersion = Version.GetVersion()
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
// Copyright © 2021-2022 Rebecca Wallander
|
||||
// ****************************************************************************/
|
||||
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
|
||||
namespace Aaru.Core.Devices.Info;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
@@ -42,11 +46,8 @@ using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decryption;
|
||||
using Aaru.Devices;
|
||||
using Aaru.Helpers;
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
||||
|
||||
namespace Aaru.Core.Devices.Info;
|
||||
|
||||
/// <summary>Obtains and contains information about a device</summary>
|
||||
public partial class DeviceInfo
|
||||
{
|
||||
@@ -89,19 +90,16 @@ public partial class DeviceInfo
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "STATUS = 0x{0:X2}", errorRegisters.Status);
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.Error);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}",
|
||||
errorRegisters.SectorCount);
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", errorRegisters.SectorCount);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.Sector);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}",
|
||||
errorRegisters.CylinderHigh);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}",
|
||||
errorRegisters.CylinderLow);
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", errorRegisters.CylinderLow);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}",
|
||||
errorRegisters.DeviceHead);
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", errorRegisters.DeviceHead);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError);
|
||||
|
||||
@@ -135,19 +133,16 @@ public partial class DeviceInfo
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "STATUS = 0x{0:X2}", errorRegisters.Status);
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.Error);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}",
|
||||
errorRegisters.SectorCount);
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", errorRegisters.SectorCount);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.Sector);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}",
|
||||
errorRegisters.CylinderHigh);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}",
|
||||
errorRegisters.CylinderLow);
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", errorRegisters.CylinderLow);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}",
|
||||
errorRegisters.DeviceHead);
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", errorRegisters.DeviceHead);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError);
|
||||
|
||||
@@ -199,8 +194,8 @@ public partial class DeviceInfo
|
||||
|
||||
var devType = (PeripheralDeviceTypes)ScsiInquiry.Value.PeripheralDeviceType;
|
||||
|
||||
sense = dev.ModeSense10(out byte[] modeBuf, out senseBuf, false, true,
|
||||
ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, out _);
|
||||
sense = dev.ModeSense10(out byte[] modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current,
|
||||
0x3F, 0xFF, 5, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -208,8 +203,8 @@ public partial class DeviceInfo
|
||||
|
||||
if(sense || dev.Error)
|
||||
{
|
||||
sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true,
|
||||
ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _);
|
||||
sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current,
|
||||
0x3F, 0x00, 5, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -222,8 +217,8 @@ public partial class DeviceInfo
|
||||
|
||||
bool useMode10 = !(sense || dev.Error || !ScsiMode.HasValue);
|
||||
|
||||
sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F,
|
||||
0xFF, 5, out _);
|
||||
sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0xFF,
|
||||
5, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -324,8 +319,8 @@ public partial class DeviceInfo
|
||||
#region Plextor
|
||||
if(dev.Manufacturer == "PLEXTOR")
|
||||
{
|
||||
bool plxtSense = true;
|
||||
bool plxtDvd = false;
|
||||
var plxtSense = true;
|
||||
var plxtDvd = false;
|
||||
byte[] plxtBuf = null;
|
||||
|
||||
switch(dev.Model)
|
||||
@@ -335,8 +330,7 @@ public partial class DeviceInfo
|
||||
case "DVDR PX-712A":
|
||||
plxtDvd = true;
|
||||
|
||||
plxtSense = dev.PlextorReadEeprom(out plxtBuf, out senseBuf, dev.Timeout,
|
||||
out _);
|
||||
plxtSense = dev.PlextorReadEeprom(out plxtBuf, out senseBuf, dev.Timeout, out _);
|
||||
|
||||
break;
|
||||
case "DVDR PX-714A":
|
||||
@@ -349,8 +343,8 @@ public partial class DeviceInfo
|
||||
|
||||
for(byte i = 0; i < 4; i++)
|
||||
{
|
||||
plxtSense = dev.PlextorReadEepromBlock(out byte[] plxtBufSmall,
|
||||
out senseBuf, i, 256, dev.Timeout, out _);
|
||||
plxtSense = dev.PlextorReadEepromBlock(out byte[] plxtBufSmall, out senseBuf, i,
|
||||
256, dev.Timeout, out _);
|
||||
|
||||
if(plxtSense)
|
||||
break;
|
||||
@@ -487,8 +481,7 @@ public partial class DeviceInfo
|
||||
|
||||
if(plxtDvd)
|
||||
{
|
||||
plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, true, dev.Timeout,
|
||||
out _);
|
||||
plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, true, dev.Timeout, out _);
|
||||
|
||||
if(!plxtSense)
|
||||
PlextorFeatures.VariRecDvd = true;
|
||||
@@ -515,8 +508,7 @@ public partial class DeviceInfo
|
||||
#endregion Plextor
|
||||
|
||||
if(ScsiInquiry.Value.KreonPresent)
|
||||
if(!dev.KreonGetFeatureList(out senseBuf, out KreonFeatures krFeatures, dev.Timeout,
|
||||
out _))
|
||||
if(!dev.KreonGetFeatureList(out senseBuf, out KreonFeatures krFeatures, dev.Timeout, out _))
|
||||
KreonFeatures = krFeatures;
|
||||
|
||||
break;
|
||||
@@ -534,8 +526,7 @@ public partial class DeviceInfo
|
||||
sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.ErrorWriteLine("REPORT DENSITY SUPPORT:\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
AaruConsole.ErrorWriteLine("REPORT DENSITY SUPPORT:\n{0}", Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
{
|
||||
DensitySupport = seqBuf;
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Info;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
@@ -40,8 +42,6 @@ using Aaru.Decoders.SCSI.SSC;
|
||||
using Aaru.Devices;
|
||||
using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
||||
|
||||
namespace Aaru.Core.Devices.Info;
|
||||
|
||||
public partial class DeviceInfo
|
||||
{
|
||||
/// <summary>Raw IDENTIFY DEVICE response</summary>
|
||||
|
||||
@@ -30,16 +30,16 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices;
|
||||
|
||||
using System;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs.Devices.ATA;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Devices;
|
||||
|
||||
/// <summary>Reduces common code used for scanning and dumping</summary>
|
||||
internal sealed partial class Reader
|
||||
sealed partial class Reader
|
||||
{
|
||||
readonly Device _dev;
|
||||
readonly ErrorLog _errorLog;
|
||||
@@ -140,8 +140,8 @@ internal sealed partial class Reader
|
||||
out bool blankCheck) => ReadBlocks(out buffer, block, BlocksToRead, out duration,
|
||||
out recoveredError, out blankCheck);
|
||||
|
||||
internal bool ReadBlocks(out byte[] buffer, ulong block, uint count, out double duration,
|
||||
out bool recoveredError, out bool blankCheck)
|
||||
internal bool ReadBlocks(out byte[] buffer, ulong block, uint count, out double duration, out bool recoveredError,
|
||||
out bool blankCheck)
|
||||
{
|
||||
switch(_dev.Type)
|
||||
{
|
||||
|
||||
@@ -30,15 +30,15 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices;
|
||||
|
||||
using System;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.Console;
|
||||
using Aaru.Decoders.ATA;
|
||||
using Identify = Aaru.CommonTypes.Structs.Devices.ATA.Identify;
|
||||
|
||||
namespace Aaru.Core.Devices;
|
||||
|
||||
internal sealed partial class Reader
|
||||
sealed partial class Reader
|
||||
{
|
||||
Identify.IdentifyDevice _ataId;
|
||||
bool _ataRead;
|
||||
@@ -74,9 +74,9 @@ internal sealed partial class Reader
|
||||
Blocks = (ulong)(Cylinders * Heads * Sectors);
|
||||
}
|
||||
|
||||
if((_ataId.CurrentCylinders != 0 && _ataId.CurrentHeads != 0 && _ataId.CurrentSectorsPerTrack != 0) ||
|
||||
_ataId.Cylinders <= 0 ||
|
||||
_ataId.Heads <= 0 ||
|
||||
if(_ataId.CurrentCylinders != 0 && _ataId.CurrentHeads != 0 && _ataId.CurrentSectorsPerTrack != 0 ||
|
||||
_ataId.Cylinders <= 0 ||
|
||||
_ataId.Heads <= 0 ||
|
||||
_ataId.SectorsPerTrack <= 0)
|
||||
return;
|
||||
|
||||
@@ -111,7 +111,7 @@ internal sealed partial class Reader
|
||||
GetDeviceBlocks();
|
||||
|
||||
bool sense;
|
||||
int tries = 0;
|
||||
var tries = 0;
|
||||
uint lba = 0;
|
||||
ushort cyl = 0;
|
||||
byte head = 0;
|
||||
@@ -139,15 +139,13 @@ internal sealed partial class Reader
|
||||
_ataReadDmaLba = !sense && (errorLba.Status & 0x27) == 0 && errorLba.Error == 0 && cmdBuf.Length > 0;
|
||||
sense = _dev.ReadDma(out cmdBuf, out errorLba, true, lba, 1, _timeout, out _);
|
||||
|
||||
_ataReadDmaRetryLba =
|
||||
!sense && (errorLba.Status & 0x27) == 0 && errorLba.Error == 0 && cmdBuf.Length > 0;
|
||||
_ataReadDmaRetryLba = !sense && (errorLba.Status & 0x27) == 0 && errorLba.Error == 0 && cmdBuf.Length > 0;
|
||||
|
||||
sense = _dev.Read(out cmdBuf, out AtaErrorRegistersLba48 errorLba48, lba, 1, _timeout, out _);
|
||||
_ataReadLba48 = !sense && (errorLba48.Status & 0x27) == 0 && errorLba48.Error == 0 && cmdBuf.Length > 0;
|
||||
sense = _dev.ReadDma(out cmdBuf, out errorLba48, lba, 1, _timeout, out _);
|
||||
|
||||
_ataReadDmaLba48 = !sense && (errorLba48.Status & 0x27) == 0 && errorLba48.Error == 0 &&
|
||||
cmdBuf.Length > 0;
|
||||
_ataReadDmaLba48 = !sense && (errorLba48.Status & 0x27) == 0 && errorLba48.Error == 0 && cmdBuf.Length > 0;
|
||||
|
||||
if(_ataRead ||
|
||||
_ataReadRetry ||
|
||||
@@ -159,9 +157,7 @@ internal sealed partial class Reader
|
||||
_ataReadDmaRetryLba ||
|
||||
_ataReadLba48 ||
|
||||
_ataReadDmaLba48)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
lba = (uint)rnd.Next(1, (int)Blocks);
|
||||
cyl = (ushort)rnd.Next(0, Cylinders);
|
||||
@@ -281,7 +277,7 @@ internal sealed partial class Reader
|
||||
return false;
|
||||
}
|
||||
|
||||
bool error = true;
|
||||
var error = true;
|
||||
|
||||
while(IsLba)
|
||||
{
|
||||
@@ -345,7 +341,7 @@ internal sealed partial class Reader
|
||||
|
||||
bool AtaReadBlocks(out byte[] buffer, ulong block, uint count, out double duration, out bool recoveredError)
|
||||
{
|
||||
bool error = true;
|
||||
var error = true;
|
||||
bool sense;
|
||||
AtaErrorRegistersLba28 errorLba;
|
||||
AtaErrorRegistersLba48 errorLba48;
|
||||
@@ -431,7 +427,7 @@ internal sealed partial class Reader
|
||||
bool AtaReadChs(out byte[] buffer, ushort cylinder, byte head, byte sector, out double duration,
|
||||
out bool recoveredError)
|
||||
{
|
||||
bool error = true;
|
||||
var error = true;
|
||||
bool sense;
|
||||
AtaErrorRegistersChs errorChs;
|
||||
byte status = 0, errorByte = 0;
|
||||
@@ -452,8 +448,7 @@ internal sealed partial class Reader
|
||||
}
|
||||
else if(_ataReadDma)
|
||||
{
|
||||
sense = _dev.ReadDma(out buffer, out errorChs, false, cylinder, head, sector, 1, _timeout,
|
||||
out duration);
|
||||
sense = _dev.ReadDma(out buffer, out errorChs, false, cylinder, head, sector, 1, _timeout, out duration);
|
||||
|
||||
error = !(!sense && (errorChs.Status & 0x27) == 0 && errorChs.Error == 0 && buffer.Length > 0);
|
||||
status = errorChs.Status;
|
||||
|
||||
@@ -30,14 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices;
|
||||
|
||||
using System;
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Console;
|
||||
using Aaru.Decoders.SCSI;
|
||||
|
||||
namespace Aaru.Core.Devices;
|
||||
|
||||
internal sealed partial class Reader
|
||||
sealed partial class Reader
|
||||
{
|
||||
// TODO: Raw reading
|
||||
bool _hldtstReadRaw;
|
||||
@@ -65,9 +65,9 @@ internal sealed partial class Reader
|
||||
return true;
|
||||
|
||||
byte[] senseBuf;
|
||||
int tries = 0;
|
||||
var tries = 0;
|
||||
uint lba = 0;
|
||||
bool mediumScan = false;
|
||||
var mediumScan = false;
|
||||
|
||||
if(_dev.ScsiType == PeripheralDeviceTypes.OpticalDevice)
|
||||
{
|
||||
@@ -97,9 +97,7 @@ internal sealed partial class Reader
|
||||
_read10 ||
|
||||
_read12 ||
|
||||
_read16)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
lba = (uint)rnd.Next(1, (int)Blocks);
|
||||
|
||||
@@ -226,8 +224,8 @@ internal sealed partial class Reader
|
||||
{
|
||||
LongBlockSize = 0xFFFF - (information & 0xFFFF);
|
||||
|
||||
_readLong10 = !_dev.ReadLong10(out _, out senseBuf, false, false, 0,
|
||||
(ushort)LongBlockSize, _timeout, out _);
|
||||
_readLong10 = !_dev.ReadLong10(out _, out senseBuf, false, false, 0, (ushort)LongBlockSize,
|
||||
_timeout, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,8 +247,7 @@ internal sealed partial class Reader
|
||||
600, 610, 630
|
||||
})
|
||||
{
|
||||
testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout,
|
||||
out _);
|
||||
testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, out _);
|
||||
|
||||
if(!testSense &&
|
||||
!_dev.Error)
|
||||
@@ -262,8 +259,8 @@ internal sealed partial class Reader
|
||||
break;
|
||||
}
|
||||
|
||||
testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize,
|
||||
_timeout, out _);
|
||||
testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, _timeout,
|
||||
out _);
|
||||
|
||||
if(testSense || _dev.Error)
|
||||
continue;
|
||||
@@ -288,8 +285,7 @@ internal sealed partial class Reader
|
||||
1200
|
||||
})
|
||||
{
|
||||
testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout,
|
||||
out _);
|
||||
testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, out _);
|
||||
|
||||
if(!testSense &&
|
||||
!_dev.Error)
|
||||
@@ -301,8 +297,8 @@ internal sealed partial class Reader
|
||||
break;
|
||||
}
|
||||
|
||||
testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize,
|
||||
_timeout, out _);
|
||||
testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, _timeout,
|
||||
out _);
|
||||
|
||||
if(testSense || _dev.Error)
|
||||
continue;
|
||||
@@ -426,8 +422,7 @@ internal sealed partial class Reader
|
||||
ili = true;
|
||||
information = (uint)Sense.DecodeDescriptor00(desc00);
|
||||
|
||||
if(decSense.Value.Descriptor.Value.Descriptors.
|
||||
TryGetValue(4, out byte[] desc04))
|
||||
if(decSense.Value.Descriptor.Value.Descriptors.TryGetValue(4, out byte[] desc04))
|
||||
Sense.DecodeDescriptor04(desc04, out _, out _, out ili);
|
||||
}
|
||||
|
||||
@@ -436,8 +431,7 @@ internal sealed partial class Reader
|
||||
LongBlockSize = 0xFFFF - (information & 0xFFFF);
|
||||
|
||||
_syqReadLong10 =
|
||||
!_dev.SyQuestReadLong10(out _, out senseBuf, 0, LongBlockSize, _timeout,
|
||||
out _);
|
||||
!_dev.SyQuestReadLong10(out _, out senseBuf, 0, LongBlockSize, _timeout, out _);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -476,8 +470,8 @@ internal sealed partial class Reader
|
||||
LongBlockSize = 0xFFFF - (information & 0xFFFF);
|
||||
|
||||
_syqReadLong6 =
|
||||
!_dev.SyQuestReadLong6(out _, out senseBuf, 0, LongBlockSize,
|
||||
_timeout, out _);
|
||||
!_dev.SyQuestReadLong6(out _, out senseBuf, 0, LongBlockSize, _timeout,
|
||||
out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -589,7 +583,7 @@ internal sealed partial class Reader
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
byte[] temp = new byte[8];
|
||||
var temp = new byte[8];
|
||||
|
||||
Array.Copy(cmdBuf, 0, temp, 0, 8);
|
||||
Array.Reverse(temp);
|
||||
@@ -619,24 +613,24 @@ internal sealed partial class Reader
|
||||
}
|
||||
else if(_read10)
|
||||
{
|
||||
_dev.Read10(out _, out _, 0, false, true, false, false, 0, LogicalBlockSize, 0,
|
||||
(ushort)BlocksToRead, _timeout, out _);
|
||||
_dev.Read10(out _, out _, 0, false, true, false, false, 0, LogicalBlockSize, 0, (ushort)BlocksToRead,
|
||||
_timeout, out _);
|
||||
|
||||
if(_dev.Error)
|
||||
BlocksToRead /= 2;
|
||||
}
|
||||
else if(_read12)
|
||||
{
|
||||
_dev.Read12(out _, out _, 0, false, false, false, false, 0, LogicalBlockSize, 0, BlocksToRead,
|
||||
false, _timeout, out _);
|
||||
_dev.Read12(out _, out _, 0, false, false, false, false, 0, LogicalBlockSize, 0, BlocksToRead, false,
|
||||
_timeout, out _);
|
||||
|
||||
if(_dev.Error)
|
||||
BlocksToRead /= 2;
|
||||
}
|
||||
else if(_read16)
|
||||
{
|
||||
_dev.Read16(out _, out _, 0, false, true, false, 0, LogicalBlockSize, 0, BlocksToRead, false,
|
||||
_timeout, out _);
|
||||
_dev.Read16(out _, out _, 0, false, true, false, 0, LogicalBlockSize, 0, BlocksToRead, false, _timeout,
|
||||
out _);
|
||||
|
||||
if(_dev.Error)
|
||||
BlocksToRead /= 2;
|
||||
@@ -676,8 +670,7 @@ internal sealed partial class Reader
|
||||
|
||||
if(CanReadRaw)
|
||||
if(_readLong16)
|
||||
sense = _dev.ReadLong16(out buffer, out senseBuf, false, block, LongBlockSize, _timeout,
|
||||
out duration);
|
||||
sense = _dev.ReadLong16(out buffer, out senseBuf, false, block, LongBlockSize, _timeout, out duration);
|
||||
else if(_readLong10)
|
||||
sense = _dev.ReadLong10(out buffer, out senseBuf, false, false, (uint)block, (ushort)LongBlockSize,
|
||||
_timeout, out duration);
|
||||
@@ -707,8 +700,8 @@ internal sealed partial class Reader
|
||||
sense = _dev.Read12(out buffer, out senseBuf, 0, false, false, false, false, (uint)block,
|
||||
LogicalBlockSize, 0, count, false, _timeout, out duration);
|
||||
else if(_read16)
|
||||
sense = _dev.Read16(out buffer, out senseBuf, 0, false, false, false, block, LogicalBlockSize, 0,
|
||||
count, false, _timeout, out duration);
|
||||
sense = _dev.Read16(out buffer, out senseBuf, 0, false, false, false, block, LogicalBlockSize, 0, count,
|
||||
false, _timeout, out duration);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
@@ -731,7 +724,7 @@ internal sealed partial class Reader
|
||||
|
||||
bool ScsiSeek(ulong block, out double duration)
|
||||
{
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
duration = 0;
|
||||
|
||||
if(_seek6)
|
||||
|
||||
@@ -30,23 +30,23 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
using System;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Console;
|
||||
using Aaru.Decoders.ATA;
|
||||
using Aaru.Devices;
|
||||
using Spectre.Console;
|
||||
using global::Spectre.Console;
|
||||
using Identify = Aaru.CommonTypes.Structs.Devices.ATA.Identify;
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
public sealed partial class DeviceReport
|
||||
{
|
||||
/// <summary>Creates a report for media inserted into an ATA device</summary>
|
||||
/// <returns>Media report</returns>
|
||||
public TestedMedia ReportAtaMedia()
|
||||
{
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
AtaErrorRegistersChs errorChs = new();
|
||||
AtaErrorRegistersLba28 errorLba = new();
|
||||
AtaErrorRegistersLba48 errorLba48 = new();
|
||||
@@ -55,9 +55,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
var mediaTest = new TestedMedia
|
||||
{
|
||||
MediumTypeName =
|
||||
AnsiConsole.Ask<string>("Please write a description of the media type and press enter: "),
|
||||
Model = AnsiConsole.Ask<string>("Please write the media model and press enter: "),
|
||||
MediumTypeName = AnsiConsole.Ask<string>("Please write a description of the media type and press enter: "),
|
||||
Model = AnsiConsole.Ask<string>("Please write the media model and press enter: "),
|
||||
MediaIsRecognized = true
|
||||
};
|
||||
|
||||
@@ -187,7 +186,7 @@ public sealed partial class DeviceReport
|
||||
mediaTest.Manufacturer = ataId.MediaManufacturer;
|
||||
}
|
||||
|
||||
ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
|
||||
var checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
|
||||
|
||||
Spectre.ProgressSingleSpinner(ctx =>
|
||||
{
|
||||
@@ -198,9 +197,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.SupportsReadSectors = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadSectorsData = readBuf;
|
||||
|
||||
@@ -213,9 +211,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.SupportsReadRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadSectorsRetryData = readBuf;
|
||||
|
||||
@@ -228,9 +225,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.SupportsReadDma = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadDmaData = readBuf;
|
||||
|
||||
@@ -243,9 +239,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.SupportsReadDmaRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadDmaRetryData = readBuf;
|
||||
|
||||
@@ -269,9 +264,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.SupportsReadLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLbaData = readBuf;
|
||||
|
||||
@@ -284,9 +278,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.SupportsReadRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadRetryLbaData = readBuf;
|
||||
|
||||
@@ -299,9 +292,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.SupportsReadDmaLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadDmaLbaData = readBuf;
|
||||
|
||||
@@ -314,9 +306,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.SupportsReadDmaRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadDmaRetryLbaData = readBuf;
|
||||
|
||||
@@ -340,9 +331,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.SupportsReadLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 &&
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLba48Data = readBuf;
|
||||
|
||||
@@ -352,12 +342,11 @@ public sealed partial class DeviceReport
|
||||
sense = _dev.ReadDma(out readBuf, out errorLba48, 0, 1, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
mediaTest.SupportsReadDmaLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 &&
|
||||
errorLba48.Error == 0 && readBuf.Length > 0;
|
||||
mediaTest.SupportsReadDmaLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 &&
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadDmaLba48Data = readBuf;
|
||||
|
||||
@@ -390,12 +379,10 @@ public sealed partial class DeviceReport
|
||||
});
|
||||
|
||||
mediaTest.SupportsReadLong = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
|
||||
readBuf.Length > 0 &&
|
||||
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLongData = readBuf;
|
||||
|
||||
@@ -411,9 +398,8 @@ public sealed partial class DeviceReport
|
||||
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) !=
|
||||
checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLongRetryData = readBuf;
|
||||
|
||||
@@ -421,17 +407,15 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying READ LONG in LBA mode...").IsIndeterminate();
|
||||
|
||||
sense = _dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize ?? 0,
|
||||
_dev.Timeout, out _);
|
||||
sense = _dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize ?? 0, _dev.Timeout,
|
||||
out _);
|
||||
});
|
||||
|
||||
mediaTest.SupportsReadLongLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
|
||||
readBuf.Length > 0 &&
|
||||
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLongLbaData = readBuf;
|
||||
|
||||
@@ -439,17 +423,16 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying READ LONG RETRY in LBA mode...").IsIndeterminate();
|
||||
|
||||
sense = _dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize ?? 0,
|
||||
_dev.Timeout, out _);
|
||||
sense = _dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize ?? 0, _dev.Timeout,
|
||||
out _);
|
||||
});
|
||||
|
||||
mediaTest.SupportsReadLongRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 &&
|
||||
errorLba.Error == 0 && readBuf.Length > 0 &&
|
||||
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
mediaTest.SupportsReadLongRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
|
||||
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) !=
|
||||
checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLongRetryLbaData = readBuf;
|
||||
}
|
||||
@@ -462,7 +445,7 @@ public sealed partial class DeviceReport
|
||||
/// <summary>Creates a report of an ATA device</summary>
|
||||
public TestedMedia ReportAta(Identify.IdentifyDevice ataId)
|
||||
{
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
byte[] readBuf = Array.Empty<byte>();
|
||||
AtaErrorRegistersChs errorChs = new();
|
||||
AtaErrorRegistersLba28 errorLba = new();
|
||||
@@ -500,8 +483,7 @@ public sealed partial class DeviceReport
|
||||
Sectors = ataId.CurrentSectorsPerTrack
|
||||
};
|
||||
|
||||
capabilities.Blocks =
|
||||
(ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack);
|
||||
capabilities.Blocks = (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack);
|
||||
}
|
||||
|
||||
if(ataId.Capabilities.HasFlag(Identify.CapabilitiesBit.LBASupport))
|
||||
@@ -790,8 +772,8 @@ public sealed partial class DeviceReport
|
||||
});
|
||||
|
||||
capabilities.SupportsReadLongRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
|
||||
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) !=
|
||||
checkCorrectRead;
|
||||
readBuf.Length > 0 &&
|
||||
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
@@ -802,13 +784,12 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying READ LONG in LBA mode...").IsIndeterminate();
|
||||
|
||||
sense = _dev.ReadLong(out readBuf, out errorLba, false, 0, capabilities.LongBlockSize ?? 0,
|
||||
_dev.Timeout, out _);
|
||||
sense = _dev.ReadLong(out readBuf, out errorLba, false, 0, capabilities.LongBlockSize ?? 0, _dev.Timeout,
|
||||
out _);
|
||||
});
|
||||
|
||||
capabilities.SupportsReadLongLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
|
||||
readBuf.Length > 0 &&
|
||||
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
@@ -840,7 +821,7 @@ public sealed partial class DeviceReport
|
||||
/// <returns>IDENTIFY ATA DEVICE response without the private fields</returns>
|
||||
public static byte[] ClearIdentify(byte[] buffer)
|
||||
{
|
||||
byte[] empty = new byte[512];
|
||||
var empty = new byte[512];
|
||||
|
||||
Array.Copy(empty, 0, buffer, 20, 20);
|
||||
Array.Copy(empty, 0, buffer, 216, 8);
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
using Aaru.Devices;
|
||||
|
||||
public sealed partial class DeviceReport
|
||||
{
|
||||
readonly Device _dev;
|
||||
|
||||
@@ -30,15 +30,15 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
|
||||
/// <summary>Implements creating a report for a FireWire device</summary>
|
||||
public sealed partial class DeviceReport
|
||||
{
|
||||
/// <summary>Fills a device report with parameters specific to a FireWire device</summary>
|
||||
public FireWire FireWireReport() => new FireWire
|
||||
public FireWire FireWireReport() => new()
|
||||
{
|
||||
Manufacturer = _dev.FireWireVendorName,
|
||||
Product = _dev.FireWireModelName,
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -39,10 +45,6 @@ using Aaru.Decoders.CD;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
public sealed partial class DeviceReport
|
||||
{
|
||||
/// <summary>Tries and checks reading a GD-ROM disc using the swap disc trick and adds the result to a device report</summary>
|
||||
@@ -59,7 +61,7 @@ public sealed partial class DeviceReport
|
||||
AaruConsole.
|
||||
Write("Have you previously tried with a GD-ROM disc and did the computer hang or crash? (Y/N): ");
|
||||
|
||||
pressedKey = System.Console.ReadKey();
|
||||
pressedKey = Console.ReadKey();
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -77,11 +79,11 @@ public sealed partial class DeviceReport
|
||||
|
||||
AaruConsole.WriteLine("Please insert trap disc inside...");
|
||||
AaruConsole.WriteLine("Press any key to continue...");
|
||||
System.Console.ReadLine();
|
||||
Console.ReadLine();
|
||||
|
||||
AaruConsole.WriteLine("Sending READ FULL TOC to the device...");
|
||||
|
||||
int retries = 0;
|
||||
var retries = 0;
|
||||
bool sense;
|
||||
byte[] buffer;
|
||||
byte[] senseBuffer;
|
||||
@@ -144,8 +146,8 @@ public sealed partial class DeviceReport
|
||||
return;
|
||||
}
|
||||
|
||||
int min = 0, sec, frame;
|
||||
bool tocIsNotBcd = false;
|
||||
int min = 0, sec, frame;
|
||||
var tocIsNotBcd = false;
|
||||
|
||||
report.GdRomSwapDiscCapabilities.SwapDiscLeadOutPMIN = leadOutTrack.PMIN;
|
||||
report.GdRomSwapDiscCapabilities.SwapDiscLeadOutPSEC = leadOutTrack.PSEC;
|
||||
@@ -169,12 +171,12 @@ public sealed partial class DeviceReport
|
||||
}
|
||||
else
|
||||
{
|
||||
min += ((leadOutTrack.PMIN >> 4) * 10) + (leadOutTrack.PMIN & 0x0F);
|
||||
sec = ((leadOutTrack.PSEC >> 4) * 10) + (leadOutTrack.PSEC & 0x0F);
|
||||
frame = ((leadOutTrack.PFRAME >> 4) * 10) + (leadOutTrack.PFRAME & 0x0F);
|
||||
min += (leadOutTrack.PMIN >> 4) * 10 + (leadOutTrack.PMIN & 0x0F);
|
||||
sec = (leadOutTrack.PSEC >> 4) * 10 + (leadOutTrack.PSEC & 0x0F);
|
||||
frame = (leadOutTrack.PFRAME >> 4) * 10 + (leadOutTrack.PFRAME & 0x0F);
|
||||
}
|
||||
|
||||
int sectors = (min * 60 * 75) + (sec * 75) + frame - 150;
|
||||
int sectors = min * 60 * 75 + sec * 75 + frame - 150;
|
||||
|
||||
AaruConsole.WriteLine("Trap disc shows {0} sectors...", sectors);
|
||||
|
||||
@@ -196,7 +198,7 @@ public sealed partial class DeviceReport
|
||||
|
||||
AaruConsole.WriteLine("Please MANUALLY get the trap disc out and put the GD-ROM disc inside...");
|
||||
AaruConsole.WriteLine("Press any key to continue...");
|
||||
System.Console.ReadLine();
|
||||
Console.ReadLine();
|
||||
|
||||
AaruConsole.WriteLine("Waiting 5 seconds...");
|
||||
Thread.Sleep(5000);
|
||||
@@ -314,11 +316,10 @@ public sealed partial class DeviceReport
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioReadable = !_dev.ReadCd(out byte[] lba100000AudioBuffer,
|
||||
out byte[] lba100000AudioSenseBuffer,
|
||||
100000, 2352, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout,
|
||||
out _);
|
||||
MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioData = lba100000AudioBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioSense = lba100000AudioSenseBuffer;
|
||||
@@ -346,18 +347,15 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioReadable = !_dev.ReadCd(out byte[] lba50000AudioBuffer,
|
||||
out byte[] lba50000AudioSenseBuffer,
|
||||
50000, 2352, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout,
|
||||
out _);
|
||||
50000, 2352, cluster, MmcSectorTypes.Cdda,
|
||||
false, false, false, MmcHeaderCodes.None,
|
||||
true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioData = lba50000AudioBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioSense = lba50000AudioSenseBuffer;
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioDecodedSense =
|
||||
Sense.PrettifySense(lba50000AudioSenseBuffer);
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioDecodedSense = Sense.PrettifySense(lba50000AudioSenseBuffer);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioReadableCluster = (int)cluster;
|
||||
|
||||
@@ -380,11 +378,10 @@ public sealed partial class DeviceReport
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioReadable = !_dev.ReadCd(out byte[] lba450000AudioBuffer,
|
||||
out byte[] lba450000AudioSenseBuffer,
|
||||
450000, 2352, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout,
|
||||
out _);
|
||||
MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioData = lba450000AudioBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioSense = lba450000AudioSenseBuffer;
|
||||
@@ -413,11 +410,10 @@ public sealed partial class DeviceReport
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioReadable = !_dev.ReadCd(out byte[] lba400000AudioBuffer,
|
||||
out byte[] lba400000AudioSenseBuffer,
|
||||
400000, 2352, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout,
|
||||
out _);
|
||||
MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioData = lba400000AudioBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioSense = lba400000AudioSenseBuffer;
|
||||
@@ -445,18 +441,15 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioReadable = !_dev.ReadCd(out byte[] lba45000AudioBuffer,
|
||||
out byte[] lba45000AudioSenseBuffer,
|
||||
45000, 2352, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout,
|
||||
out _);
|
||||
45000, 2352, cluster, MmcSectorTypes.Cdda,
|
||||
false, false, false, MmcHeaderCodes.None,
|
||||
true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioData = lba45000AudioBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioSense = lba45000AudioSenseBuffer;
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioDecodedSense =
|
||||
Sense.PrettifySense(lba45000AudioSenseBuffer);
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioDecodedSense = Sense.PrettifySense(lba45000AudioSenseBuffer);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioReadableCluster = (int)cluster;
|
||||
|
||||
@@ -478,18 +471,15 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioReadable = !_dev.ReadCd(out byte[] lba44990AudioBuffer,
|
||||
out byte[] lba44990AudioSenseBuffer,
|
||||
44990, 2352, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout,
|
||||
out _);
|
||||
44990, 2352, cluster, MmcSectorTypes.Cdda,
|
||||
false, false, false, MmcHeaderCodes.None,
|
||||
true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioData = lba44990AudioBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioSense = lba44990AudioSenseBuffer;
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioDecodedSense =
|
||||
Sense.PrettifySense(lba44990AudioSenseBuffer);
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioDecodedSense = Sense.PrettifySense(lba44990AudioSenseBuffer);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioReadableCluster = (int)cluster;
|
||||
|
||||
@@ -509,10 +499,14 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioPqReadable =
|
||||
!_dev.ReadCd(out byte[] lba100000AudioPqBuffer, out byte[] lba100000AudioPqSenseBuffer, 100000,
|
||||
2368, cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None, MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioPqReadable = !_dev.ReadCd(out byte[] lba100000AudioPqBuffer,
|
||||
out byte[] lba100000AudioPqSenseBuffer,
|
||||
100000, 2368, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioPqData = lba100000AudioPqBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioPqSense = lba100000AudioPqSenseBuffer;
|
||||
@@ -538,10 +532,13 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioPqReadable =
|
||||
!_dev.ReadCd(out byte[] lba50000AudioPqBuffer, out byte[] lba50000AudioPqSenseBuffer, 50000, 2368,
|
||||
cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioPqReadable = !_dev.ReadCd(out byte[] lba50000AudioPqBuffer,
|
||||
out byte[] lba50000AudioPqSenseBuffer,
|
||||
50000, 2368, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Q16,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioPqData = lba50000AudioPqBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioPqSense = lba50000AudioPqSenseBuffer;
|
||||
@@ -567,10 +564,14 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioPqReadable =
|
||||
!_dev.ReadCd(out byte[] lba450000AudioPqBuffer, out byte[] lba450000AudioPqSenseBuffer, 450000,
|
||||
2368, cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None, MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioPqReadable = !_dev.ReadCd(out byte[] lba450000AudioPqBuffer,
|
||||
out byte[] lba450000AudioPqSenseBuffer,
|
||||
450000, 2368, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioPqData = lba450000AudioPqBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioPqSense = lba450000AudioPqSenseBuffer;
|
||||
@@ -596,10 +597,14 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioPqReadable =
|
||||
!_dev.ReadCd(out byte[] lba400000AudioPqBuffer, out byte[] lba400000AudioPqSenseBuffer, 400000,
|
||||
2368, cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None, MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioPqReadable = !_dev.ReadCd(out byte[] lba400000AudioPqBuffer,
|
||||
out byte[] lba400000AudioPqSenseBuffer,
|
||||
400000, 2368, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioPqData = lba400000AudioPqBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioPqSense = lba400000AudioPqSenseBuffer;
|
||||
@@ -625,10 +630,13 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioPqReadable =
|
||||
!_dev.ReadCd(out byte[] lba45000AudioPqBuffer, out byte[] lba45000AudioPqSenseBuffer, 45000, 2368,
|
||||
cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioPqReadable = !_dev.ReadCd(out byte[] lba45000AudioPqBuffer,
|
||||
out byte[] lba45000AudioPqSenseBuffer,
|
||||
45000, 2368, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Q16,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioPqData = lba45000AudioPqBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioPqSense = lba45000AudioPqSenseBuffer;
|
||||
@@ -654,10 +662,13 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioPqReadable =
|
||||
!_dev.ReadCd(out byte[] lba44990AudioPqBuffer, out byte[] lba44990AudioPqSenseBuffer, 44990, 2368,
|
||||
cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioPqReadable = !_dev.ReadCd(out byte[] lba44990AudioPqBuffer,
|
||||
out byte[] lba44990AudioPqSenseBuffer,
|
||||
44990, 2368, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Q16,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioPqData = lba44990AudioPqBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioPqSense = lba44990AudioPqSenseBuffer;
|
||||
@@ -683,10 +694,14 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioRwReadable =
|
||||
!_dev.ReadCd(out byte[] lba100000AudioRwBuffer, out byte[] lba100000AudioRwSenseBuffer, 100000,
|
||||
2448, cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None, MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioRwReadable = !_dev.ReadCd(out byte[] lba100000AudioRwBuffer,
|
||||
out byte[] lba100000AudioRwSenseBuffer,
|
||||
100000, 2448, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.Raw, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioRwData = lba100000AudioRwBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba100000AudioRwSense = lba100000AudioRwSenseBuffer;
|
||||
@@ -712,10 +727,13 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioRwReadable =
|
||||
!_dev.ReadCd(out byte[] lba50000AudioRwBuffer, out byte[] lba50000AudioRwSenseBuffer, 50000, 2448,
|
||||
cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioRwReadable = !_dev.ReadCd(out byte[] lba50000AudioRwBuffer,
|
||||
out byte[] lba50000AudioRwSenseBuffer,
|
||||
50000, 2448, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Raw,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioRwData = lba50000AudioRwBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba50000AudioRwSense = lba50000AudioRwSenseBuffer;
|
||||
@@ -741,10 +759,14 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioRwReadable =
|
||||
!_dev.ReadCd(out byte[] lba450000AudioRwBuffer, out byte[] lba450000AudioRwSenseBuffer, 450000,
|
||||
2448, cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None, MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioRwReadable = !_dev.ReadCd(out byte[] lba450000AudioRwBuffer,
|
||||
out byte[] lba450000AudioRwSenseBuffer,
|
||||
450000, 2448, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.Raw, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioRwData = lba450000AudioRwBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba450000AudioRwSense = lba450000AudioRwSenseBuffer;
|
||||
@@ -770,10 +792,14 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioRwReadable =
|
||||
!_dev.ReadCd(out byte[] lba400000AudioRwBuffer, out byte[] lba400000AudioRwSenseBuffer, 400000,
|
||||
2448, cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None, MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioRwReadable = !_dev.ReadCd(out byte[] lba400000AudioRwBuffer,
|
||||
out byte[] lba400000AudioRwSenseBuffer,
|
||||
400000, 2448, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.Raw, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioRwData = lba400000AudioRwBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba400000AudioRwSense = lba400000AudioRwSenseBuffer;
|
||||
@@ -799,10 +825,13 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioRwReadable =
|
||||
!_dev.ReadCd(out byte[] lba45000AudioRwBuffer, out byte[] lba45000AudioRwSenseBuffer, 45000, 2448,
|
||||
cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioRwReadable = !_dev.ReadCd(out byte[] lba45000AudioRwBuffer,
|
||||
out byte[] lba45000AudioRwSenseBuffer,
|
||||
45000, 2448, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Raw,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioRwData = lba45000AudioRwBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba45000AudioRwSense = lba45000AudioRwSenseBuffer;
|
||||
@@ -828,10 +857,13 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(true)
|
||||
{
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioRwReadable =
|
||||
!_dev.ReadCd(out byte[] lba44990AudioRwBuffer, out byte[] lba44990AudioRwSenseBuffer, 44990, 2448,
|
||||
cluster, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioRwReadable = !_dev.ReadCd(out byte[] lba44990AudioRwBuffer,
|
||||
out byte[] lba44990AudioRwSenseBuffer,
|
||||
44990, 2448, cluster,
|
||||
MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Raw,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioRwData = lba44990AudioRwBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba44990AudioRwSense = lba44990AudioRwSenseBuffer;
|
||||
@@ -1034,10 +1066,12 @@ public sealed partial class DeviceReport
|
||||
report.GdRomSwapDiscCapabilities.Lba100000PqReadable = !_dev.ReadCd(out byte[] lba100000PqBuffer,
|
||||
out byte[] lba100000PqSenseBuffer,
|
||||
100000, 2368, cluster,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
MmcSectorTypes.AllTypes, false,
|
||||
false, true,
|
||||
MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
MmcSubchannel.Q16, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba100000PqData = lba100000PqBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba100000PqSense = lba100000PqSenseBuffer;
|
||||
@@ -1092,10 +1126,12 @@ public sealed partial class DeviceReport
|
||||
report.GdRomSwapDiscCapabilities.Lba450000PqReadable = !_dev.ReadCd(out byte[] lba450000PqBuffer,
|
||||
out byte[] lba450000PqSenseBuffer,
|
||||
450000, 2368, cluster,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
MmcSectorTypes.AllTypes, false,
|
||||
false, true,
|
||||
MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
MmcSubchannel.Q16, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba450000PqData = lba450000PqBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba450000PqSense = lba450000PqSenseBuffer;
|
||||
@@ -1121,10 +1157,12 @@ public sealed partial class DeviceReport
|
||||
report.GdRomSwapDiscCapabilities.Lba400000PqReadable = !_dev.ReadCd(out byte[] lba400000PqBuffer,
|
||||
out byte[] lba400000PqSenseBuffer,
|
||||
400000, 2368, cluster,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
MmcSectorTypes.AllTypes, false,
|
||||
false, true,
|
||||
MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
MmcSubchannel.Q16, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba400000PqData = lba400000PqBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba400000PqSense = lba400000PqSenseBuffer;
|
||||
@@ -1208,10 +1246,12 @@ public sealed partial class DeviceReport
|
||||
report.GdRomSwapDiscCapabilities.Lba100000RwReadable = !_dev.ReadCd(out byte[] lba100000RwBuffer,
|
||||
out byte[] lba100000RwSenseBuffer,
|
||||
100000, 2448, cluster,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
MmcSectorTypes.AllTypes, false,
|
||||
false, true,
|
||||
MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
MmcSubchannel.Raw, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba100000RwData = lba100000RwBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba100000RwSense = lba100000RwSenseBuffer;
|
||||
@@ -1266,10 +1306,12 @@ public sealed partial class DeviceReport
|
||||
report.GdRomSwapDiscCapabilities.Lba450000RwReadable = !_dev.ReadCd(out byte[] lba450000RwBuffer,
|
||||
out byte[] lba450000RwSenseBuffer,
|
||||
450000, 2448, cluster,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
MmcSectorTypes.AllTypes, false,
|
||||
false, true,
|
||||
MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
MmcSubchannel.Raw, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba450000RwData = lba450000RwBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba450000RwSense = lba450000RwSenseBuffer;
|
||||
@@ -1295,10 +1337,12 @@ public sealed partial class DeviceReport
|
||||
report.GdRomSwapDiscCapabilities.Lba400000RwReadable = !_dev.ReadCd(out byte[] lba400000RwBuffer,
|
||||
out byte[] lba400000RwSenseBuffer,
|
||||
400000, 2448, cluster,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
MmcSectorTypes.AllTypes, false,
|
||||
false, true,
|
||||
MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
MmcSubchannel.Raw, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
report.GdRomSwapDiscCapabilities.Lba400000RwData = lba400000RwBuffer;
|
||||
report.GdRomSwapDiscCapabilities.Lba400000RwSense = lba400000RwSenseBuffer;
|
||||
@@ -1395,7 +1439,7 @@ public sealed partial class DeviceReport
|
||||
Write("The next part of the test will read the whole high density area of a GD-ROM from the smallest known readable sector until the first error happens\n" +
|
||||
"Do you want to proceed? (Y/N): ");
|
||||
|
||||
pressedKey = System.Console.ReadKey();
|
||||
pressedKey = Console.ReadKey();
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -1403,8 +1447,8 @@ public sealed partial class DeviceReport
|
||||
return;
|
||||
|
||||
uint startingSector = 45000;
|
||||
bool readAsAudio = false;
|
||||
bool aborted = false;
|
||||
var readAsAudio = false;
|
||||
var aborted = false;
|
||||
MmcSubchannel subchannel = MmcSubchannel.None;
|
||||
uint blockSize = 2352;
|
||||
|
||||
@@ -1519,7 +1563,7 @@ public sealed partial class DeviceReport
|
||||
subchannel = MmcSubchannel.Q16;
|
||||
}
|
||||
|
||||
System.Console.CancelKeyPress += (sender, e) =>
|
||||
Console.CancelKeyPress += (sender, e) =>
|
||||
{
|
||||
e.Cancel = true;
|
||||
aborted = true;
|
||||
@@ -1541,7 +1585,7 @@ public sealed partial class DeviceReport
|
||||
|
||||
byte[] lastSuccessfulPq = null;
|
||||
byte[] lastSuccessfulRw = null;
|
||||
bool trackModeChange = false;
|
||||
var trackModeChange = false;
|
||||
|
||||
AaruConsole.WriteLine();
|
||||
|
||||
@@ -1558,12 +1602,13 @@ public sealed partial class DeviceReport
|
||||
AaruConsole.Write("\rReading LBA {0} of {1}", lba, sectors);
|
||||
|
||||
sense = readAsAudio
|
||||
? _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize, cluster, MmcSectorTypes.Cdda,
|
||||
false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
subchannel, _dev.Timeout, out _) : _dev.ReadCd(out buffer, out senseBuffer,
|
||||
lba, blockSize, cluster, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, subchannel,
|
||||
_dev.Timeout, out _);
|
||||
? _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize, cluster, MmcSectorTypes.Cdda, false,
|
||||
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, subchannel,
|
||||
_dev.Timeout, out _) : _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize,
|
||||
cluster, MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, subchannel, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -40,9 +42,7 @@ using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SCSI.MMC;
|
||||
using Aaru.Devices;
|
||||
using Aaru.Helpers;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
using global::Spectre.Console;
|
||||
|
||||
public sealed partial class DeviceReport
|
||||
{
|
||||
@@ -52,8 +52,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
while(offset + 4 < response.Length)
|
||||
{
|
||||
ushort code = (ushort)((response[offset + 0] << 8) + response[offset + 1]);
|
||||
byte[] data = new byte[response[offset + 3] + 4];
|
||||
var code = (ushort)((response[offset + 0] << 8) + response[offset + 1]);
|
||||
var data = new byte[response[offset + 3] + 4];
|
||||
|
||||
if(code != 0x0108)
|
||||
{
|
||||
@@ -76,7 +76,7 @@ public sealed partial class DeviceReport
|
||||
/// <returns>MMC features report</returns>
|
||||
public MmcFeatures ReportMmcFeatures()
|
||||
{
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
|
||||
Spectre.ProgressSingleSpinner(ctx =>
|
||||
@@ -490,7 +490,7 @@ public sealed partial class DeviceReport
|
||||
|
||||
if(ftr010C.HasValue)
|
||||
{
|
||||
byte[] temp = new byte[4];
|
||||
var temp = new byte[4];
|
||||
temp[0] = (byte)((ftr010C.Value.Century & 0xFF00) >> 8);
|
||||
temp[1] = (byte)(ftr010C.Value.Century & 0xFF);
|
||||
temp[2] = (byte)((ftr010C.Value.Year & 0xFF00) >> 8);
|
||||
@@ -520,8 +520,8 @@ public sealed partial class DeviceReport
|
||||
try
|
||||
{
|
||||
report.FirmwareDate = new DateTime(int.Parse(syear), int.Parse(smonth), int.Parse(sday),
|
||||
int.Parse(shour), int.Parse(sminute),
|
||||
int.Parse(ssecond), DateTimeKind.Utc);
|
||||
int.Parse(shour), int.Parse(sminute), int.Parse(ssecond),
|
||||
DateTimeKind.Utc);
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
catch
|
||||
@@ -587,10 +587,10 @@ public sealed partial class DeviceReport
|
||||
/// <param name="tryHldtst">Try HL-DT-ST vendor commands</param>
|
||||
/// <param name="tryMediaTekF106">Try MediaTek vendor commands</param>
|
||||
/// <returns></returns>
|
||||
public TestedMedia ReportMmcMedia(string mediaType, bool tryPlextor, bool tryPioneer, bool tryNec,
|
||||
bool tryHldtst, bool tryMediaTekF106)
|
||||
public TestedMedia ReportMmcMedia(string mediaType, bool tryPlextor, bool tryPioneer, bool tryNec, bool tryHldtst,
|
||||
bool tryMediaTekF106)
|
||||
{
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
byte[] senseBuffer = Array.Empty<byte>();
|
||||
var mediaTest = new TestedMedia();
|
||||
@@ -622,7 +622,7 @@ public sealed partial class DeviceReport
|
||||
!_dev.Error)
|
||||
{
|
||||
mediaTest.SupportsReadCapacity16 = true;
|
||||
byte[] temp = new byte[8];
|
||||
var temp = new byte[8];
|
||||
Array.Copy(buffer, 0, temp, 0, 8);
|
||||
Array.Reverse(temp);
|
||||
mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1;
|
||||
@@ -635,8 +635,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Querying SCSI MODE SENSE (10)...").IsIndeterminate();
|
||||
|
||||
sense = _dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current,
|
||||
0x3F, 0x00, _dev.Timeout, out _);
|
||||
sense = _dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current, 0x3F,
|
||||
0x00, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
if(!sense &&
|
||||
@@ -743,8 +743,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadDMI = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DiscManufacturingInformation,
|
||||
0, _dev.Timeout, out _);
|
||||
MmcDiscStructureFormat.DiscManufacturingInformation, 0,
|
||||
_dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDMI);
|
||||
@@ -879,8 +879,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadDDS = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdramDds, 0,
|
||||
_dev.Timeout, out _);
|
||||
MmcDiscStructureFormat.DvdramDds, 0, _dev.Timeout,
|
||||
out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS);
|
||||
@@ -913,8 +913,7 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadDDS = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
MmcDiscStructureMediaType.Bd, 0, 0,
|
||||
MmcDiscStructureFormat.BdDds, 0, _dev.Timeout,
|
||||
out _);
|
||||
MmcDiscStructureFormat.BdDds, 0, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS);
|
||||
@@ -944,8 +943,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadPRI = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.PreRecordedInfo, 0,
|
||||
_dev.Timeout, out _);
|
||||
MmcDiscStructureFormat.PreRecordedInfo, 0, _dev.Timeout,
|
||||
out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPRI);
|
||||
@@ -975,9 +974,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadRecordablePFI = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.
|
||||
DvdrPhysicalInformation, 0,
|
||||
_dev.Timeout, out _);
|
||||
MmcDiscStructureFormat.DvdrPhysicalInformation,
|
||||
0, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRecordablePFI);
|
||||
@@ -994,8 +992,7 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadADIP = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.Adip, 0, _dev.Timeout,
|
||||
out _);
|
||||
MmcDiscStructureFormat.Adip, 0, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadADIP);
|
||||
@@ -1024,8 +1021,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadHDCMI = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.HddvdCopyrightInformation,
|
||||
0, _dev.Timeout, out _);
|
||||
MmcDiscStructureFormat.HddvdCopyrightInformation, 0,
|
||||
_dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadHDCMI);
|
||||
@@ -1041,8 +1038,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadLayerCapacity = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdrLayerCapacity,
|
||||
0, _dev.Timeout, out _);
|
||||
MmcDiscStructureFormat.DvdrLayerCapacity, 0,
|
||||
_dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadLayerCapacity);
|
||||
@@ -1064,8 +1061,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadDiscInformation = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
MmcDiscStructureMediaType.Bd, 0, 0,
|
||||
MmcDiscStructureFormat.DiscInformation,
|
||||
0, _dev.Timeout, out _);
|
||||
MmcDiscStructureFormat.DiscInformation, 0,
|
||||
_dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDiscInformation);
|
||||
@@ -1117,8 +1114,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying SCSI READ (10)...").IsIndeterminate();
|
||||
|
||||
mediaTest.SupportsRead10 = !_dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false,
|
||||
16, 512, 0, 1, _dev.Timeout, out _);
|
||||
mediaTest.SupportsRead10 = !_dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 16,
|
||||
512, 0, 1, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10);
|
||||
@@ -1129,8 +1126,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying SCSI READ (12)...").IsIndeterminate();
|
||||
|
||||
mediaTest.SupportsRead12 = !_dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false,
|
||||
16, 512, 0, 1, false, _dev.Timeout, out _);
|
||||
mediaTest.SupportsRead12 = !_dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 16,
|
||||
512, 0, 1, false, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12);
|
||||
@@ -1141,8 +1138,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying SCSI READ (16)...").IsIndeterminate();
|
||||
|
||||
mediaTest.SupportsRead16 = !_dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 16, 512,
|
||||
0, 1, false, _dev.Timeout, out _);
|
||||
mediaTest.SupportsRead16 = !_dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 16, 512, 0,
|
||||
1, false, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16);
|
||||
@@ -1165,8 +1162,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying SCSI READ (10)...").IsIndeterminate();
|
||||
|
||||
mediaTest.SupportsRead10 = !_dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false,
|
||||
16, 2048, 0, 1, _dev.Timeout, out _);
|
||||
mediaTest.SupportsRead10 = !_dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 16,
|
||||
2048, 0, 1, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10);
|
||||
@@ -1177,8 +1174,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying SCSI READ (12)...").IsIndeterminate();
|
||||
|
||||
mediaTest.SupportsRead12 = !_dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false,
|
||||
16, 2048, 0, 1, false, _dev.Timeout, out _);
|
||||
mediaTest.SupportsRead12 = !_dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 16,
|
||||
2048, 0, 1, false, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12);
|
||||
@@ -1189,8 +1186,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying SCSI READ (16)...").IsIndeterminate();
|
||||
|
||||
mediaTest.SupportsRead16 = !_dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 16,
|
||||
2048, 0, 1, false, _dev.Timeout, out _);
|
||||
mediaTest.SupportsRead16 = !_dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 16, 2048, 0,
|
||||
1, false, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16);
|
||||
@@ -1222,11 +1219,10 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying SCSI READ CD MSF...").IsIndeterminate();
|
||||
|
||||
mediaTest.SupportsReadCdMsf = !_dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000210,
|
||||
0x00000211, 2352, MmcSectorTypes.Cdda, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out _);
|
||||
mediaTest.SupportsReadCdMsf = !_dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000210, 0x00000211,
|
||||
2352, MmcSectorTypes.Cdda, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdMsf);
|
||||
@@ -1253,11 +1249,10 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying SCSI READ CD MSF...").IsIndeterminate();
|
||||
|
||||
mediaTest.SupportsReadCdMsf = !_dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000210,
|
||||
0x00000211, 2048, MmcSectorTypes.AllTypes, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out _);
|
||||
mediaTest.SupportsReadCdMsf = !_dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000210, 0x00000211,
|
||||
2048, MmcSectorTypes.AllTypes, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdMsf);
|
||||
@@ -1284,9 +1279,9 @@ public sealed partial class DeviceReport
|
||||
ctx.AddTask("Trying SCSI READ CD MSF full sector...").IsIndeterminate();
|
||||
|
||||
mediaTest.SupportsReadCdMsfRaw = !_dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000210,
|
||||
0x00000211, 2352, MmcSectorTypes.AllTypes,
|
||||
false, false, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None, MmcSubchannel.None,
|
||||
0x00000211, 2352, MmcSectorTypes.AllTypes, false,
|
||||
false, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out _);
|
||||
});
|
||||
|
||||
@@ -1310,10 +1305,9 @@ public sealed partial class DeviceReport
|
||||
false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _);
|
||||
else
|
||||
sense = _dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out _);
|
||||
sense = _dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _);
|
||||
|
||||
// ReSharper restore IntVariableOverflowInUncheckedContext
|
||||
|
||||
@@ -1346,10 +1340,9 @@ public sealed partial class DeviceReport
|
||||
false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _);
|
||||
else
|
||||
sense = _dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out _);
|
||||
sense = _dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", sense);
|
||||
|
||||
@@ -1374,16 +1367,15 @@ public sealed partial class DeviceReport
|
||||
mediaTest.CanReadLeadOut = !_dev.ReadCd(out buffer, out senseBuffer,
|
||||
(uint)(mediaTest.Blocks + 1), 2352, 1,
|
||||
MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out _);
|
||||
else
|
||||
mediaTest.CanReadLeadOut = !_dev.ReadCd(out buffer, out senseBuffer,
|
||||
(uint)(mediaTest.Blocks + 1), 2352, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out _);
|
||||
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout,
|
||||
out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadLeadOut);
|
||||
@@ -1428,9 +1420,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadPQSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2368, 1,
|
||||
MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Q16,
|
||||
_dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel);
|
||||
|
||||
@@ -1438,9 +1429,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadRWSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2448, 1,
|
||||
MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Raw,
|
||||
_dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel);
|
||||
|
||||
@@ -1474,51 +1464,48 @@ public sealed partial class DeviceReport
|
||||
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2662, 1,
|
||||
MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
MmcErrorField.C2Pointers, MmcSubchannel.Q16,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadPQSubchannelWithC2 == false)
|
||||
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11,
|
||||
2664, 1, MmcSectorTypes.Cdda, false,
|
||||
false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.C2PointersAndBlock,
|
||||
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2664, 1,
|
||||
MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2PointersAndBlock,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadPQSubchannelWithC2);
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannelWithC2);
|
||||
|
||||
mediaTest.PQSubchannelWithC2Data = buffer;
|
||||
|
||||
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2712, 1,
|
||||
MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
MmcErrorField.C2Pointers, MmcSubchannel.Raw,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadRWSubchannelWithC2 == false)
|
||||
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11,
|
||||
2714, 1, MmcSectorTypes.Cdda, false,
|
||||
false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.C2PointersAndBlock,
|
||||
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2714, 1,
|
||||
MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2PointersAndBlock,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadRWSubchannelWithC2);
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannelWithC2);
|
||||
|
||||
mediaTest.RWSubchannelWithC2Data = buffer;
|
||||
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11,
|
||||
2712, 1, MmcSectorTypes.Cdda, false,
|
||||
false, false, MmcHeaderCodes.None,
|
||||
true, false, MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Rw, _dev.Timeout,
|
||||
out _);
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2712,
|
||||
1, MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Rw, _dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadCorrectedSubchannelWithC2 == false)
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer,
|
||||
11, 2714, 1, MmcSectorTypes.Cdda,
|
||||
false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11,
|
||||
2714, 1, MmcSectorTypes.Cdda, false,
|
||||
false, false, MmcHeaderCodes.None,
|
||||
true, false,
|
||||
MmcErrorField.C2PointersAndBlock,
|
||||
MmcSubchannel.Rw, _dev.Timeout,
|
||||
out _);
|
||||
@@ -1567,8 +1554,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.CanReadPQSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2368, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.Q16,
|
||||
_dev.Timeout, out _);
|
||||
MmcErrorField.None, MmcSubchannel.Q16, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel);
|
||||
|
||||
@@ -1577,8 +1564,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.CanReadRWSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2448, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.Raw,
|
||||
_dev.Timeout, out _);
|
||||
MmcErrorField.None, MmcSubchannel.Raw, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel);
|
||||
|
||||
@@ -1608,58 +1595,50 @@ public sealed partial class DeviceReport
|
||||
else
|
||||
{
|
||||
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2662, 1,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.C2Pointers, MmcSubchannel.Q16,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadPQSubchannelWithC2 == false)
|
||||
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16,
|
||||
2664, 1, MmcSectorTypes.AllTypes, false,
|
||||
false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true,
|
||||
MmcErrorField.C2PointersAndBlock,
|
||||
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2664, 1,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.C2PointersAndBlock,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadPQSubchannelWithC2);
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannelWithC2);
|
||||
|
||||
mediaTest.PQSubchannelWithC2Data = buffer;
|
||||
|
||||
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2712, 1,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.C2Pointers, MmcSubchannel.Raw,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadRWSubchannelWithC2 == false)
|
||||
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16,
|
||||
2714, 1, MmcSectorTypes.AllTypes, false,
|
||||
false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true,
|
||||
MmcErrorField.C2PointersAndBlock,
|
||||
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2714, 1,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.C2PointersAndBlock,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadRWSubchannelWithC2);
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannelWithC2);
|
||||
|
||||
mediaTest.RWSubchannelWithC2Data = buffer;
|
||||
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16,
|
||||
2712, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Rw, _dev.Timeout,
|
||||
out _);
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2712,
|
||||
1, MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Rw, _dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadCorrectedSubchannelWithC2 == false)
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer,
|
||||
16, 2714, 1,
|
||||
MmcSectorTypes.AllTypes, false,
|
||||
false, true,
|
||||
MmcHeaderCodes.AllHeaders, true,
|
||||
true,
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16,
|
||||
2714, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.C2PointersAndBlock,
|
||||
MmcSubchannel.Rw, _dev.Timeout,
|
||||
out _);
|
||||
@@ -1707,9 +1686,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadPQSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2064, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Q16,
|
||||
_dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel);
|
||||
|
||||
@@ -1717,17 +1695,16 @@ public sealed partial class DeviceReport
|
||||
|
||||
mediaTest.CanReadRWSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2144, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Raw,
|
||||
_dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel);
|
||||
|
||||
mediaTest.RWSubchannelData = buffer;
|
||||
|
||||
mediaTest.CanReadCorrectedSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2144, 1,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcSectorTypes.AllTypes, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.Rw,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
@@ -1749,55 +1726,50 @@ public sealed partial class DeviceReport
|
||||
else
|
||||
{
|
||||
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2358, 1,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
MmcSectorTypes.AllTypes, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2Pointers, MmcSubchannel.Q16,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadPQSubchannelWithC2 == false)
|
||||
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16,
|
||||
2360, 1, MmcSectorTypes.AllTypes, false,
|
||||
false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.C2PointersAndBlock,
|
||||
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2360, 1,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2PointersAndBlock,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadPQSubchannelWithC2);
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannelWithC2);
|
||||
|
||||
mediaTest.PQSubchannelWithC2Data = buffer;
|
||||
|
||||
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2438, 1,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
MmcSectorTypes.AllTypes, false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2Pointers, MmcSubchannel.Raw,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadRWSubchannelWithC2 == false)
|
||||
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16,
|
||||
2440, 1, MmcSectorTypes.AllTypes, false,
|
||||
false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.C2PointersAndBlock,
|
||||
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2440, 1,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2PointersAndBlock,
|
||||
MmcSubchannel.Raw, _dev.Timeout, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadRWSubchannelWithC2);
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannelWithC2);
|
||||
|
||||
mediaTest.RWSubchannelWithC2Data = buffer;
|
||||
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16,
|
||||
2438, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2438,
|
||||
1, MmcSectorTypes.AllTypes, false, false,
|
||||
false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2Pointers,
|
||||
MmcSubchannel.Rw, _dev.Timeout,
|
||||
out _);
|
||||
MmcSubchannel.Rw, _dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadCorrectedSubchannelWithC2 == false)
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer,
|
||||
16, 2440, 1,
|
||||
MmcSectorTypes.AllTypes, false,
|
||||
false, false, MmcHeaderCodes.None,
|
||||
true, false,
|
||||
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16,
|
||||
2440, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, false,
|
||||
MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.C2PointersAndBlock,
|
||||
MmcSubchannel.Rw, _dev.Timeout,
|
||||
out _);
|
||||
@@ -1961,8 +1933,8 @@ public sealed partial class DeviceReport
|
||||
|
||||
if(tryMediaTekF106)
|
||||
{
|
||||
bool triedLba0 = false;
|
||||
bool triedLeadOut = false;
|
||||
var triedLba0 = false;
|
||||
var triedLeadOut = false;
|
||||
|
||||
Spectre.ProgressSingleSpinner(ctx =>
|
||||
{
|
||||
@@ -1971,9 +1943,8 @@ public sealed partial class DeviceReport
|
||||
if(mediaType == "Audio CD" &&
|
||||
mediaTest.SupportsReadCd == true)
|
||||
{
|
||||
_dev.ReadCd(out _, out _, 0, 2352, 1, MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out _);
|
||||
_dev.ReadCd(out _, out _, 0, 2352, 1, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None,
|
||||
true, false, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _);
|
||||
|
||||
triedLba0 = true;
|
||||
}
|
||||
@@ -1992,8 +1963,8 @@ public sealed partial class DeviceReport
|
||||
mediaTest.SupportsReadCd == true)
|
||||
{
|
||||
_dev.ReadCd(out _, out _, 0, 2048, 1, MmcSectorTypes.AllTypes, false, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
triedLba0 = true;
|
||||
}
|
||||
@@ -2009,8 +1980,7 @@ public sealed partial class DeviceReport
|
||||
}
|
||||
else if(mediaTest.SupportsRead12 == true)
|
||||
{
|
||||
_dev.Read12(out _, out _, 0, false, true, false, false, 0, 2048, 0, 1, false, _dev.Timeout,
|
||||
out _);
|
||||
_dev.Read12(out _, out _, 0, false, true, false, false, 0, 2048, 0, 1, false, _dev.Timeout, out _);
|
||||
|
||||
triedLba0 = true;
|
||||
}
|
||||
@@ -2050,8 +2020,8 @@ public sealed partial class DeviceReport
|
||||
mediaType == "Enhanced CD (aka E-CD, CD-Plus or CD+)") &&
|
||||
mediaTest.SupportsReadCdRaw == true)
|
||||
{
|
||||
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.AllTypes, false,
|
||||
false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out _);
|
||||
|
||||
triedLeadOut = true;
|
||||
@@ -2060,8 +2030,8 @@ public sealed partial class DeviceReport
|
||||
mediaType == "Enhanced CD (aka E-CD, CD-Plus or CD+)") &&
|
||||
mediaTest.SupportsReadCd == true)
|
||||
{
|
||||
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2048, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2048, 1, MmcSectorTypes.AllTypes, false,
|
||||
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out _);
|
||||
|
||||
triedLeadOut = true;
|
||||
@@ -2073,15 +2043,15 @@ public sealed partial class DeviceReport
|
||||
}
|
||||
else if(mediaTest.SupportsRead10 == true)
|
||||
{
|
||||
_dev.Read10(out _, out _, 0, false, true, false, false, (uint)(mediaTest.Blocks + 1), 2048,
|
||||
0, 1, _dev.Timeout, out _);
|
||||
_dev.Read10(out _, out _, 0, false, true, false, false, (uint)(mediaTest.Blocks + 1), 2048, 0,
|
||||
1, _dev.Timeout, out _);
|
||||
|
||||
triedLeadOut = true;
|
||||
}
|
||||
else if(mediaTest.SupportsRead12 == true)
|
||||
{
|
||||
_dev.Read12(out _, out _, 0, false, true, false, false, (uint)(mediaTest.Blocks + 1), 2048,
|
||||
0, 1, false, _dev.Timeout, out _);
|
||||
_dev.Read12(out _, out _, 0, false, true, false, false, (uint)(mediaTest.Blocks + 1), 2048, 0,
|
||||
1, false, _dev.Timeout, out _);
|
||||
|
||||
triedLeadOut = true;
|
||||
}
|
||||
@@ -2098,8 +2068,7 @@ public sealed partial class DeviceReport
|
||||
mediaTest.CanReadF1_06LeadOut =
|
||||
!_dev.MediaTekReadDram(out buffer, out senseBuffer, 0, 0xB00, _dev.Timeout, out _);
|
||||
|
||||
mediaTest.ReadF1_06LeadOutData =
|
||||
mediaTest.CanReadF1_06LeadOut == true ? buffer : senseBuffer;
|
||||
mediaTest.ReadF1_06LeadOutData = mediaTest.CanReadF1_06LeadOut == true ? buffer : senseBuffer;
|
||||
|
||||
// This means it has returned the same as previous read, so not really lead-out.
|
||||
if(mediaTest.CanReadF1_06 == true &&
|
||||
@@ -2162,8 +2131,7 @@ public sealed partial class DeviceReport
|
||||
return null;
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report",
|
||||
"First session Lead-Out starts at {0:D2}:{1:D2}:{2:D2}",
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "First session Lead-Out starts at {0:D2}:{1:D2}:{2:D2}",
|
||||
firstSessionLeadOutTrack.PMIN, firstSessionLeadOutTrack.PSEC,
|
||||
firstSessionLeadOutTrack.PFRAME);
|
||||
|
||||
@@ -2172,14 +2140,14 @@ public sealed partial class DeviceReport
|
||||
secondSessionFirstTrack.PFRAME);
|
||||
|
||||
// Skip Lead-Out pre-gap
|
||||
uint firstSessionLeadOutLba = (uint)((firstSessionLeadOutTrack.PMIN * 60 * 75) +
|
||||
(firstSessionLeadOutTrack.PSEC * 75) +
|
||||
firstSessionLeadOutTrack.PFRAME + 150);
|
||||
var firstSessionLeadOutLba = (uint)(firstSessionLeadOutTrack.PMIN * 60 * 75 +
|
||||
firstSessionLeadOutTrack.PSEC * 75 +
|
||||
firstSessionLeadOutTrack.PFRAME + 150);
|
||||
|
||||
// Skip second session track pre-gap
|
||||
uint secondSessionLeadInLba = (uint)((secondSessionFirstTrack.PMIN * 60 * 75) +
|
||||
(secondSessionFirstTrack.PSEC * 75) +
|
||||
secondSessionFirstTrack.PFRAME - 300);
|
||||
var secondSessionLeadInLba = (uint)(secondSessionFirstTrack.PMIN * 60 * 75 +
|
||||
secondSessionFirstTrack.PSEC * 75 +
|
||||
secondSessionFirstTrack.PFRAME - 300);
|
||||
|
||||
Spectre.ProgressSingleSpinner(ctx =>
|
||||
{
|
||||
@@ -2196,12 +2164,10 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer,
|
||||
firstSessionLeadOutLba, 2368, 1,
|
||||
MmcSectorTypes.AllTypes, false,
|
||||
false, false,
|
||||
MmcHeaderCodes.AllHeaders, true,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
false, MmcHeaderCodes.AllHeaders, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout,
|
||||
out _);
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadingIntersessionLeadOut == false)
|
||||
mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer,
|
||||
@@ -2215,8 +2181,7 @@ public sealed partial class DeviceReport
|
||||
}
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadingIntersessionLeadOut);
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadingIntersessionLeadOut);
|
||||
|
||||
mediaTest.IntersessionLeadOutData = buffer;
|
||||
|
||||
@@ -2236,25 +2201,22 @@ public sealed partial class DeviceReport
|
||||
mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer,
|
||||
secondSessionLeadInLba, 2368, 1,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
false, MmcHeaderCodes.AllHeaders,
|
||||
true, false, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout,
|
||||
out _);
|
||||
false, MmcHeaderCodes.AllHeaders, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSubchannel.Q16, _dev.Timeout, out _);
|
||||
|
||||
if(mediaTest.CanReadingIntersessionLeadIn == false)
|
||||
mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer,
|
||||
secondSessionLeadInLba, 2352, 1,
|
||||
MmcSectorTypes.AllTypes, false,
|
||||
false, false,
|
||||
MmcHeaderCodes.AllHeaders, true,
|
||||
false, MmcErrorField.None,
|
||||
MmcSectorTypes.AllTypes, false, false,
|
||||
false, MmcHeaderCodes.AllHeaders,
|
||||
true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout,
|
||||
out _);
|
||||
}
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadingIntersessionLeadIn);
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadingIntersessionLeadIn);
|
||||
|
||||
mediaTest.IntersessionLeadInData = buffer;
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Decoders.PCMCIA;
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
/// <summary>Implements creating a report for a PCMCIA device</summary>
|
||||
public sealed partial class DeviceReport
|
||||
{
|
||||
|
||||
@@ -30,15 +30,15 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SCSI.SSC;
|
||||
using Aaru.Devices;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
using global::Spectre.Console;
|
||||
|
||||
public sealed partial class DeviceReport
|
||||
{
|
||||
@@ -47,7 +47,7 @@ public sealed partial class DeviceReport
|
||||
public Ssc ReportScsiSsc()
|
||||
{
|
||||
var report = new Ssc();
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
|
||||
Spectre.ProgressSingleSpinner(ctx =>
|
||||
@@ -82,9 +82,9 @@ public sealed partial class DeviceReport
|
||||
|
||||
if(dsh.HasValue)
|
||||
{
|
||||
SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length];
|
||||
var array = new SupportedDensity[dsh.Value.descriptors.Length];
|
||||
|
||||
for(int i = 0; i < dsh.Value.descriptors.Length; i++)
|
||||
for(var i = 0; i < dsh.Value.descriptors.Length; i++)
|
||||
array[i] = new SupportedDensity
|
||||
{
|
||||
BitsPerMm = dsh.Value.descriptors[i].bpmm,
|
||||
@@ -119,9 +119,9 @@ public sealed partial class DeviceReport
|
||||
if(!mtsh.HasValue)
|
||||
return report;
|
||||
|
||||
SscSupportedMedia[] array2 = new SscSupportedMedia[mtsh.Value.descriptors.Length];
|
||||
var array2 = new SscSupportedMedia[mtsh.Value.descriptors.Length];
|
||||
|
||||
for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
|
||||
for(var i = 0; i < mtsh.Value.descriptors.Length; i++)
|
||||
{
|
||||
array2[i] = new SscSupportedMedia
|
||||
{
|
||||
@@ -136,9 +136,9 @@ public sealed partial class DeviceReport
|
||||
if(mtsh.Value.descriptors[i].densityCodes == null)
|
||||
continue;
|
||||
|
||||
DensityCode[] array3 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
|
||||
var array3 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
|
||||
|
||||
for(int j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++)
|
||||
for(var j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++)
|
||||
array3[j] = new DensityCode
|
||||
{
|
||||
Code = mtsh.Value.descriptors[i].densityCodes[j]
|
||||
@@ -157,7 +157,7 @@ public sealed partial class DeviceReport
|
||||
public TestedSequentialMedia ReportSscMedia()
|
||||
{
|
||||
var seqTest = new TestedSequentialMedia();
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
|
||||
Modes.DecodedMode? decMode = null;
|
||||
@@ -211,9 +211,9 @@ public sealed partial class DeviceReport
|
||||
|
||||
if(dsh.HasValue)
|
||||
{
|
||||
SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length];
|
||||
var array = new SupportedDensity[dsh.Value.descriptors.Length];
|
||||
|
||||
for(int i = 0; i < dsh.Value.descriptors.Length; i++)
|
||||
for(var i = 0; i < dsh.Value.descriptors.Length; i++)
|
||||
array[i] = new SupportedDensity
|
||||
{
|
||||
BitsPerMm = dsh.Value.descriptors[i].bpmm,
|
||||
@@ -236,8 +236,7 @@ public sealed partial class DeviceReport
|
||||
|
||||
Spectre.ProgressSingleSpinner(ctx =>
|
||||
{
|
||||
ctx.AddTask("Querying SCSI REPORT DENSITY SUPPORT for medium types for current media...").
|
||||
IsIndeterminate();
|
||||
ctx.AddTask("Querying SCSI REPORT DENSITY SUPPORT for medium types for current media...").IsIndeterminate();
|
||||
|
||||
sense = _dev.ReportDensitySupport(out buffer, out _, true, true, _dev.Timeout, out _);
|
||||
});
|
||||
@@ -248,9 +247,9 @@ public sealed partial class DeviceReport
|
||||
|
||||
if(mtsh.HasValue)
|
||||
{
|
||||
SscSupportedMedia[] array = new SscSupportedMedia[mtsh.Value.descriptors.Length];
|
||||
var array = new SscSupportedMedia[mtsh.Value.descriptors.Length];
|
||||
|
||||
for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
|
||||
for(var i = 0; i < mtsh.Value.descriptors.Length; i++)
|
||||
{
|
||||
array[i] = new SscSupportedMedia
|
||||
{
|
||||
@@ -265,9 +264,9 @@ public sealed partial class DeviceReport
|
||||
if(mtsh.Value.descriptors[i].densityCodes == null)
|
||||
continue;
|
||||
|
||||
DensityCode[] array2 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
|
||||
var array2 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
|
||||
|
||||
for(int j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++)
|
||||
for(var j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++)
|
||||
array2[j] = new DensityCode
|
||||
{
|
||||
Code = mtsh.Value.descriptors[i].densityCodes[j]
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -39,18 +41,16 @@ using Aaru.Console;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
using Aaru.Helpers;
|
||||
using Spectre.Console;
|
||||
using global::Spectre.Console;
|
||||
using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
public sealed partial class DeviceReport
|
||||
{
|
||||
/// <summary>Creates a report for the SCSI INQUIRY response</summary>
|
||||
/// <returns>SCSI report</returns>
|
||||
public Scsi ReportScsiInquiry()
|
||||
{
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
|
||||
Spectre.ProgressSingleSpinner(ctx =>
|
||||
@@ -88,7 +88,7 @@ public sealed partial class DeviceReport
|
||||
return inquiry;
|
||||
|
||||
// Clear Seagate serial number
|
||||
for(int i = 36; i <= 43; i++)
|
||||
for(var i = 36; i <= 43; i++)
|
||||
inquiry[i] = 0;
|
||||
|
||||
return inquiry;
|
||||
@@ -99,7 +99,7 @@ public sealed partial class DeviceReport
|
||||
/// <returns>List of decoded SCSI EVPD pages</returns>
|
||||
public List<ScsiPage> ReportEvpdPages(string vendor)
|
||||
{
|
||||
bool sense = false;
|
||||
var sense = false;
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
|
||||
Spectre.ProgressSingleSpinner(ctx =>
|
||||
@@ -122,8 +122,8 @@ public sealed partial class DeviceReport
|
||||
Spectre.ProgressSingleSpinner(ctx =>
|
||||
{
|
||||
ProgressTask task = ctx.
|
||||
AddTask("Querying SCSI EVPD pages...",
|
||||
maxValue: evpdPages.Count(page => page != 0x80)).IsIndeterminate();
|
||||
AddTask("Querying SCSI EVPD pages...", maxValue: evpdPages.Count(page => page != 0x80)).
|
||||
IsIndeterminate();
|
||||
|
||||
foreach(byte page in evpdPages.Where(page => page != 0x80))
|
||||
{
|
||||
@@ -143,7 +143,7 @@ public sealed partial class DeviceReport
|
||||
|
||||
break;
|
||||
case 0x80:
|
||||
byte[] identify = new byte[512];
|
||||
var identify = new byte[512];
|
||||
Array.Copy(buffer, 60, identify, 0, 512);
|
||||
identify = ClearIdentify(identify);
|
||||
Array.Copy(identify, 0, buffer, 60, 512);
|
||||
@@ -195,7 +195,7 @@ public sealed partial class DeviceReport
|
||||
if(pageResponse.Length < 6)
|
||||
return null;
|
||||
|
||||
int position = 4;
|
||||
var position = 4;
|
||||
|
||||
while(position < pageResponse.Length)
|
||||
{
|
||||
@@ -204,7 +204,7 @@ public sealed partial class DeviceReport
|
||||
if(length + position + 4 >= pageResponse.Length)
|
||||
length = (byte)(pageResponse.Length - position - 4);
|
||||
|
||||
byte[] empty = new byte[length];
|
||||
var empty = new byte[length];
|
||||
Array.Copy(empty, 0, pageResponse, position + 4, length);
|
||||
|
||||
position += 4 + length;
|
||||
@@ -238,10 +238,10 @@ public sealed partial class DeviceReport
|
||||
ScsiModeSensePageControl.Changeable
|
||||
})
|
||||
{
|
||||
bool saveBuffer = false;
|
||||
var saveBuffer = false;
|
||||
|
||||
sense = _dev.ModeSense10(out mode10Buffer, out _, false, true, pageControl, 0x3F, 0xFF,
|
||||
_dev.Timeout, out _);
|
||||
sense = _dev.ModeSense10(out mode10Buffer, out _, false, true, pageControl, 0x3F, 0xFF, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
{
|
||||
@@ -320,7 +320,7 @@ public sealed partial class DeviceReport
|
||||
ScsiModeSensePageControl.Changeable
|
||||
})
|
||||
{
|
||||
bool saveBuffer = false;
|
||||
var saveBuffer = false;
|
||||
sense = _dev.ModeSense6(out mode6Buffer, out _, true, pageControl, 0x3F, 0xFF, _dev.Timeout, out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
@@ -466,7 +466,7 @@ public sealed partial class DeviceReport
|
||||
public TestedMedia ReportScsiMedia()
|
||||
{
|
||||
var mediaTest = new TestedMedia();
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
byte[] senseBuffer = Array.Empty<byte>();
|
||||
|
||||
@@ -497,7 +497,7 @@ public sealed partial class DeviceReport
|
||||
!_dev.Error)
|
||||
{
|
||||
mediaTest.SupportsReadCapacity16 = true;
|
||||
byte[] temp = new byte[8];
|
||||
var temp = new byte[8];
|
||||
Array.Copy(buffer, 0, temp, 0, 8);
|
||||
Array.Reverse(temp);
|
||||
mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1;
|
||||
@@ -510,8 +510,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Querying SCSI MODE SENSE (10)...").IsIndeterminate();
|
||||
|
||||
sense = _dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current,
|
||||
0x3F, 0x00, _dev.Timeout, out _);
|
||||
sense = _dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current, 0x3F,
|
||||
0x00, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
if(!sense &&
|
||||
@@ -673,10 +673,9 @@ public sealed partial class DeviceReport
|
||||
})
|
||||
{
|
||||
sense = mediaTest.SupportsReadLong16 == true
|
||||
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize,
|
||||
_dev.Timeout, out _)
|
||||
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize,
|
||||
_dev.Timeout, out _);
|
||||
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
|
||||
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
|
||||
false, 0, testSize, _dev.Timeout, out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
continue;
|
||||
@@ -700,10 +699,9 @@ public sealed partial class DeviceReport
|
||||
})
|
||||
{
|
||||
sense = mediaTest.SupportsReadLong16 == true
|
||||
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize,
|
||||
_dev.Timeout, out _)
|
||||
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize,
|
||||
_dev.Timeout, out _);
|
||||
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
|
||||
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
|
||||
false, 0, testSize, _dev.Timeout, out _);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
continue;
|
||||
@@ -718,9 +716,9 @@ public sealed partial class DeviceReport
|
||||
case 2048:
|
||||
{
|
||||
sense = mediaTest.SupportsReadLong16 == true
|
||||
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 2380, _dev.Timeout,
|
||||
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
|
||||
false, 0, 2380, _dev.Timeout, out _);
|
||||
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 2380, _dev.Timeout, out _)
|
||||
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
@@ -731,9 +729,9 @@ public sealed partial class DeviceReport
|
||||
case 4096:
|
||||
{
|
||||
sense = mediaTest.SupportsReadLong16 == true
|
||||
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 4760, _dev.Timeout,
|
||||
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
|
||||
false, 0, 4760, _dev.Timeout, out _);
|
||||
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 4760, _dev.Timeout, out _)
|
||||
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
@@ -744,9 +742,9 @@ public sealed partial class DeviceReport
|
||||
case 8192:
|
||||
{
|
||||
sense = mediaTest.SupportsReadLong16 == true
|
||||
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 9424, _dev.Timeout,
|
||||
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
|
||||
false, 0, 9424, _dev.Timeout, out _);
|
||||
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 9424, _dev.Timeout, out _)
|
||||
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
@@ -772,7 +770,7 @@ public sealed partial class DeviceReport
|
||||
/// <returns>Media report</returns>
|
||||
public TestedMedia ReportScsi()
|
||||
{
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
byte[] senseBuffer = Array.Empty<byte>();
|
||||
|
||||
@@ -808,7 +806,7 @@ public sealed partial class DeviceReport
|
||||
!_dev.Error)
|
||||
{
|
||||
capabilities.SupportsReadCapacity16 = true;
|
||||
byte[] temp = new byte[8];
|
||||
var temp = new byte[8];
|
||||
Array.Copy(buffer, 0, temp, 0, 8);
|
||||
Array.Reverse(temp);
|
||||
capabilities.Blocks = BitConverter.ToUInt64(temp, 0) + 1;
|
||||
@@ -821,8 +819,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Querying SCSI MODE SENSE (10)...").IsIndeterminate();
|
||||
|
||||
sense = _dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current,
|
||||
0x3F, 0x00, _dev.Timeout, out _);
|
||||
sense = _dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current, 0x3F,
|
||||
0x00, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
if(!sense &&
|
||||
@@ -869,8 +867,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying SCSI READ (10)...").IsIndeterminate();
|
||||
|
||||
capabilities.SupportsRead10 = !_dev.Read10(out buffer, out senseBuffer, 0, false, false, false, false,
|
||||
0, capabilities.BlockSize ?? 512, 0, 1, _dev.Timeout, out _);
|
||||
capabilities.SupportsRead10 = !_dev.Read10(out buffer, out senseBuffer, 0, false, false, false, false, 0,
|
||||
capabilities.BlockSize ?? 512, 0, 1, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !capabilities.SupportsRead10);
|
||||
@@ -880,9 +878,8 @@ public sealed partial class DeviceReport
|
||||
{
|
||||
ctx.AddTask("Trying SCSI READ (12)...").IsIndeterminate();
|
||||
|
||||
capabilities.SupportsRead12 = !_dev.Read12(out buffer, out senseBuffer, 0, false, false, false, false,
|
||||
0, capabilities.BlockSize ?? 512, 0, 1, false, _dev.Timeout,
|
||||
out _);
|
||||
capabilities.SupportsRead12 = !_dev.Read12(out buffer, out senseBuffer, 0, false, false, false, false, 0,
|
||||
capabilities.BlockSize ?? 512, 0, 1, false, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !capabilities.SupportsRead12);
|
||||
@@ -893,8 +890,7 @@ public sealed partial class DeviceReport
|
||||
ctx.AddTask("Trying SCSI READ (16)...").IsIndeterminate();
|
||||
|
||||
capabilities.SupportsRead16 = !_dev.Read16(out buffer, out senseBuffer, 0, false, false, false, 0,
|
||||
capabilities.BlockSize ?? 512, 0, 1, false, _dev.Timeout,
|
||||
out _);
|
||||
capabilities.BlockSize ?? 512, 0, 1, false, _dev.Timeout, out _);
|
||||
});
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !capabilities.SupportsRead16);
|
||||
@@ -969,7 +965,7 @@ public sealed partial class DeviceReport
|
||||
}
|
||||
}
|
||||
|
||||
if((capabilities.SupportsReadLong != true && capabilities.SupportsReadLong16 != true) ||
|
||||
if(capabilities.SupportsReadLong != true && capabilities.SupportsReadLong16 != true ||
|
||||
capabilities.LongBlockSize != capabilities.BlockSize)
|
||||
return capabilities;
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
using System;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Console;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
using global::Spectre.Console;
|
||||
|
||||
/// <summary>Implements creating a device report for a SecureDigital or MultiMediaCard flash card</summary>
|
||||
public sealed partial class DeviceReport
|
||||
@@ -45,7 +45,7 @@ public sealed partial class DeviceReport
|
||||
public MmcSd MmcSdReport()
|
||||
{
|
||||
var report = new MmcSd();
|
||||
bool sense = true;
|
||||
var sense = true;
|
||||
byte[] cid = Array.Empty<byte>();
|
||||
byte[] csd = Array.Empty<byte>();
|
||||
byte[] ecsd = Array.Empty<byte>();
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
|
||||
namespace Aaru.Core.Devices.Report;
|
||||
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
|
||||
/// <summary>Implements creating a report for a USB device</summary>
|
||||
public sealed partial class DeviceReport
|
||||
{
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Structs.Devices.ATA;
|
||||
using Aaru.Core.Logging;
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning;
|
||||
|
||||
/// <summary>Implements scanning the media from an ATA device</summary>
|
||||
public sealed partial class MediaScan
|
||||
{
|
||||
@@ -210,12 +210,12 @@ public sealed partial class MediaScan
|
||||
InitProgress?.Invoke();
|
||||
|
||||
if(ataReader.CanSeekLba && _seekTest)
|
||||
for(int i = 0; i < seekTimes; i++)
|
||||
for(var i = 0; i < seekTimes; i++)
|
||||
{
|
||||
if(_aborted)
|
||||
break;
|
||||
|
||||
uint seekPos = (uint)rnd.Next((int)results.Blocks);
|
||||
var seekPos = (uint)rnd.Next((int)results.Blocks);
|
||||
|
||||
PulseProgress?.Invoke($"Seeking to sector {seekPos}...\t\t");
|
||||
|
||||
@@ -326,17 +326,16 @@ public sealed partial class MediaScan
|
||||
InitProgress?.Invoke();
|
||||
|
||||
if(ataReader.CanSeek)
|
||||
for(int i = 0; i < seekTimes; i++)
|
||||
for(var i = 0; i < seekTimes; i++)
|
||||
{
|
||||
if(_aborted)
|
||||
break;
|
||||
|
||||
ushort seekCy = (ushort)rnd.Next(cylinders);
|
||||
byte seekHd = (byte)rnd.Next(heads);
|
||||
byte seekSc = (byte)rnd.Next(sectors);
|
||||
var seekCy = (ushort)rnd.Next(cylinders);
|
||||
var seekHd = (byte)rnd.Next(heads);
|
||||
var seekSc = (byte)rnd.Next(sectors);
|
||||
|
||||
PulseProgress?.
|
||||
Invoke($"\rSeeking to cylinder {seekCy}, head {seekHd}, sector {seekSc}...\t\t");
|
||||
PulseProgress?.Invoke($"\rSeeking to cylinder {seekCy}, head {seekHd}, sector {seekSc}...\t\t");
|
||||
|
||||
ataReader.SeekChs(seekCy, seekHd, seekSc, out seekCur);
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning;
|
||||
|
||||
using System;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning;
|
||||
|
||||
public sealed partial class MediaScan
|
||||
{
|
||||
readonly Device _dev;
|
||||
|
||||
@@ -38,6 +38,6 @@ public sealed partial class MediaScan
|
||||
{
|
||||
StoppingErrorMessage?.Invoke("NVMe devices not yet supported.");
|
||||
|
||||
return default;
|
||||
return default(ScanResults);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
@@ -41,8 +43,6 @@ using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SCSI.MMC;
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning;
|
||||
|
||||
/// <summary>Implements scanning the media from an SCSI device</summary>
|
||||
public sealed partial class MediaScan
|
||||
{
|
||||
@@ -55,8 +55,8 @@ public sealed partial class MediaScan
|
||||
bool sense;
|
||||
uint blockSize = 0;
|
||||
ushort currentProfile = 0x0001;
|
||||
bool foundReadCommand = false;
|
||||
bool readcd = false;
|
||||
var foundReadCommand = false;
|
||||
var readcd = false;
|
||||
|
||||
results.Blocks = 0;
|
||||
|
||||
@@ -74,7 +74,7 @@ public sealed partial class MediaScan
|
||||
{
|
||||
case 0x3A:
|
||||
{
|
||||
int leftRetries = 5;
|
||||
var leftRetries = 5;
|
||||
|
||||
while(leftRetries > 0)
|
||||
{
|
||||
@@ -99,7 +99,7 @@ public sealed partial class MediaScan
|
||||
}
|
||||
case 0x04 when decSense.Value.ASCQ == 0x01:
|
||||
{
|
||||
int leftRetries = 10;
|
||||
var leftRetries = 10;
|
||||
|
||||
while(leftRetries > 0)
|
||||
{
|
||||
@@ -127,7 +127,7 @@ public sealed partial class MediaScan
|
||||
// These should be trapped by the OS but seems in some cases they're not
|
||||
case 0x28:
|
||||
{
|
||||
int leftRetries = 10;
|
||||
var leftRetries = 10;
|
||||
|
||||
while(leftRetries > 0)
|
||||
{
|
||||
@@ -232,7 +232,7 @@ public sealed partial class MediaScan
|
||||
return results;
|
||||
}
|
||||
|
||||
bool compactDisc = true;
|
||||
var compactDisc = true;
|
||||
FullTOC.CDFullTOC? toc = null;
|
||||
|
||||
if(_dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
|
||||
@@ -339,8 +339,7 @@ public sealed partial class MediaScan
|
||||
|
||||
if(_dev.Error)
|
||||
{
|
||||
StoppingErrorMessage?.
|
||||
Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length.");
|
||||
StoppingErrorMessage?.Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length.");
|
||||
|
||||
return results;
|
||||
}
|
||||
@@ -373,19 +372,15 @@ public sealed partial class MediaScan
|
||||
currentSpeed > 0)
|
||||
results.MinSpeed = currentSpeed;
|
||||
|
||||
UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)",
|
||||
(long)i, (long)results.Blocks);
|
||||
UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)", (long)i,
|
||||
(long)results.Blocks);
|
||||
|
||||
if(readcd)
|
||||
{
|
||||
sense = _dev.ReadCd(out _, out senseBuf, (uint)i, 2352, blocksToRead, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out cmdDuration);
|
||||
}
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, _dev.Timeout, out cmdDuration);
|
||||
else
|
||||
{
|
||||
sense = scsiReader.ReadBlocks(out _, i, blocksToRead, out cmdDuration, out _, out _);
|
||||
}
|
||||
|
||||
results.ProcessingTime += cmdDuration;
|
||||
|
||||
@@ -414,13 +409,12 @@ public sealed partial class MediaScan
|
||||
|
||||
if(readcd)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Scan", "READ CD error:\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
AaruConsole.DebugWriteLine("Media-Scan", "READ CD error:\n{0}", Sense.PrettifySense(senseBuf));
|
||||
|
||||
senseDecoded = Sense.Decode(senseBuf);
|
||||
|
||||
if(senseDecoded.HasValue)
|
||||
{
|
||||
|
||||
// TODO: This error happens when changing from track type afaik. Need to solve that more cleanly
|
||||
// LOGICAL BLOCK ADDRESS OUT OF RANGE
|
||||
if((senseDecoded.Value.ASC != 0x21 || senseDecoded.Value.ASCQ != 0x00) &&
|
||||
@@ -439,7 +433,6 @@ public sealed partial class MediaScan
|
||||
|
||||
ibgLog.Write(i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!senseDecoded.HasValue)
|
||||
@@ -519,8 +512,8 @@ public sealed partial class MediaScan
|
||||
currentSpeed > 0)
|
||||
results.MinSpeed = currentSpeed;
|
||||
|
||||
UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)",
|
||||
(long)i, (long)results.Blocks);
|
||||
UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)", (long)i,
|
||||
(long)results.Blocks);
|
||||
|
||||
sense = scsiReader.ReadBlocks(out _, i, blocksToRead, out double cmdDuration, out _, out _);
|
||||
results.ProcessingTime += cmdDuration;
|
||||
@@ -590,12 +583,12 @@ public sealed partial class MediaScan
|
||||
|
||||
InitProgress?.Invoke();
|
||||
|
||||
for(int i = 0; i < seekTimes; i++)
|
||||
for(var i = 0; i < seekTimes; i++)
|
||||
{
|
||||
if(_aborted || !_seekTest)
|
||||
break;
|
||||
|
||||
uint seekPos = (uint)rnd.Next((int)results.Blocks);
|
||||
var seekPos = (uint)rnd.Next((int)results.Blocks);
|
||||
|
||||
PulseProgress?.Invoke($"Seeking to sector {seekPos}...\t\t");
|
||||
|
||||
@@ -605,8 +598,8 @@ public sealed partial class MediaScan
|
||||
scsiReader.Seek(seekPos, out seekCur);
|
||||
else if(readcd)
|
||||
_dev.ReadCd(out _, out _, seekPos, 2352, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
|
||||
_dev.Timeout, out seekCur);
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout,
|
||||
out seekCur);
|
||||
else
|
||||
scsiReader.ReadBlock(out _, seekPos, out seekCur, out _, out _);
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>Contains the results of a media scan</summary>
|
||||
public struct ScanResults
|
||||
{
|
||||
|
||||
@@ -30,18 +30,21 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.MMC;
|
||||
using Aaru.Decoders.SecureDigital;
|
||||
using CSD = Aaru.Decoders.MMC.CSD;
|
||||
using Decoders = Aaru.Decoders.MMC.Decoders;
|
||||
using DeviceType = Aaru.CommonTypes.Enums.DeviceType;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning;
|
||||
|
||||
/// <summary>Implements scanning a SecureDigital or MultiMediaCard flash card</summary>
|
||||
public sealed partial class MediaScan
|
||||
{
|
||||
@@ -56,8 +59,8 @@ public sealed partial class MediaScan
|
||||
const ushort sdProfile = 0x0001;
|
||||
ushort blocksToRead = 128;
|
||||
uint blockSize = 512;
|
||||
bool byteAddressed = true;
|
||||
bool supportsCmd23 = false;
|
||||
var byteAddressed = true;
|
||||
var supportsCmd23 = false;
|
||||
|
||||
switch(_dev.Type)
|
||||
{
|
||||
@@ -67,7 +70,7 @@ public sealed partial class MediaScan
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
CSD csd = Decoders.MMC.Decoders.DecodeCSD(cmdBuf);
|
||||
CSD csd = Decoders.DecodeCSD(cmdBuf);
|
||||
results.Blocks = (ulong)((csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2));
|
||||
blockSize = (uint)Math.Pow(2, csd.ReadBlockLength);
|
||||
|
||||
@@ -80,7 +83,7 @@ public sealed partial class MediaScan
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
ExtendedCSD ecsd = Decoders.MMC.Decoders.DecodeExtendedCSD(cmdBuf);
|
||||
ExtendedCSD ecsd = Decoders.DecodeExtendedCSD(cmdBuf);
|
||||
results.Blocks = ecsd.SectorCount;
|
||||
blockSize = (uint)(ecsd.SectorSize == 1 ? 4096 : 512);
|
||||
|
||||
@@ -104,11 +107,10 @@ public sealed partial class MediaScan
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
Decoders.SecureDigital.CSD csd = Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf);
|
||||
Aaru.Decoders.SecureDigital.CSD csd = Aaru.Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf);
|
||||
|
||||
results.Blocks = (ulong)(csd.Structure == 0
|
||||
? (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2)
|
||||
: (csd.Size + 1) * 1024);
|
||||
results.Blocks = (ulong)(csd.Structure == 0 ? (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2)
|
||||
: (csd.Size + 1) * 1024);
|
||||
|
||||
blockSize = (uint)Math.Pow(2, csd.ReadBlockLength);
|
||||
|
||||
@@ -125,8 +127,8 @@ public sealed partial class MediaScan
|
||||
sense = _dev.ReadScr(out cmdBuf, out _, timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(cmdBuf)?.CommandSupport.
|
||||
HasFlag(CommandSupport.SetBlockCount) ?? false;
|
||||
supportsCmd23 = Aaru.Decoders.SecureDigital.Decoders.DecodeSCR(cmdBuf)?.CommandSupport.
|
||||
HasFlag(CommandSupport.SetBlockCount) ?? false;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -142,13 +144,11 @@ public sealed partial class MediaScan
|
||||
|
||||
if(supportsCmd23)
|
||||
{
|
||||
sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, 1, byteAddressed, timeout,
|
||||
out duration);
|
||||
sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, 1, byteAddressed, timeout, out duration);
|
||||
|
||||
if(sense || _dev.Error)
|
||||
{
|
||||
UpdateStatus?.
|
||||
Invoke("Environment does not support setting block count, downgrading to OS reading.");
|
||||
UpdateStatus?.Invoke("Environment does not support setting block count, downgrading to OS reading.");
|
||||
|
||||
supportsCmd23 = false;
|
||||
}
|
||||
@@ -168,8 +168,8 @@ public sealed partial class MediaScan
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed,
|
||||
timeout, out duration);
|
||||
sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, timeout,
|
||||
out duration);
|
||||
|
||||
if(sense)
|
||||
blocksToRead /= 2;
|
||||
@@ -181,8 +181,7 @@ public sealed partial class MediaScan
|
||||
|
||||
if(sense)
|
||||
{
|
||||
StoppingErrorMessage?.
|
||||
Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length.");
|
||||
StoppingErrorMessage?.Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length.");
|
||||
|
||||
return results;
|
||||
}
|
||||
@@ -253,11 +252,10 @@ public sealed partial class MediaScan
|
||||
error = _dev.ReadWithBlockCount(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed,
|
||||
timeout, out duration);
|
||||
else if(_useBufferedReads)
|
||||
error = _dev.BufferedOsRead(out cmdBuf, (long)(i * blockSize), blockSize * blocksToRead,
|
||||
out duration);
|
||||
error = _dev.BufferedOsRead(out cmdBuf, (long)(i * blockSize), blockSize * blocksToRead, out duration);
|
||||
else
|
||||
error = _dev.ReadMultipleUsingSingle(out cmdBuf, out _, (uint)i, blockSize, blocksToRead,
|
||||
byteAddressed, timeout, out duration);
|
||||
error = _dev.ReadMultipleUsingSingle(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed,
|
||||
timeout, out duration);
|
||||
|
||||
if(!error)
|
||||
{
|
||||
@@ -309,17 +307,16 @@ public sealed partial class MediaScan
|
||||
mhddLog.Close();
|
||||
|
||||
ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
|
||||
blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000),
|
||||
_devicePath);
|
||||
blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), _devicePath);
|
||||
|
||||
InitProgress?.Invoke();
|
||||
|
||||
for(int i = 0; i < seekTimes; i++)
|
||||
for(var i = 0; i < seekTimes; i++)
|
||||
{
|
||||
if(_aborted || !_seekTest)
|
||||
break;
|
||||
|
||||
uint seekPos = (uint)rnd.Next((int)results.Blocks);
|
||||
var seekPos = (uint)rnd.Next((int)results.Blocks);
|
||||
|
||||
PulseProgress?.Invoke($"Seeking to sector {seekPos}...\t\t");
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Media image entropy operations</summary>
|
||||
public sealed class Entropy
|
||||
{
|
||||
@@ -102,7 +102,7 @@ public sealed class Entropy
|
||||
Invoke($"Entropying track {currentTrack.Sequence} of {inputTracks.Max(t => t.Sequence)}",
|
||||
currentTrack.Sequence, inputTracks.Max(t => t.Sequence));
|
||||
|
||||
ulong[] entTable = new ulong[256];
|
||||
var entTable = new ulong[256];
|
||||
ulong trackSize = 0;
|
||||
List<string> uniqueSectorsPerTrack = new();
|
||||
|
||||
@@ -177,7 +177,7 @@ public sealed class Entropy
|
||||
if(_inputFormat is not IMediaImage mediaImage)
|
||||
return entropy;
|
||||
|
||||
ulong[] entTable = new ulong[256];
|
||||
var entTable = new ulong[256];
|
||||
ulong diskSize = 0;
|
||||
List<string> uniqueSectors = new();
|
||||
|
||||
@@ -234,8 +234,8 @@ public sealed class Entropy
|
||||
if(_inputFormat is not IByteAddressableImage byteAddressableImage)
|
||||
return entropy;
|
||||
|
||||
ulong[] entTable = new ulong[256];
|
||||
byte[] data = new byte[byteAddressableImage.Info.Sectors];
|
||||
var entTable = new ulong[256];
|
||||
var data = new byte[byteAddressableImage.Info.Sectors];
|
||||
|
||||
entropy.Sectors = _inputFormat.Info.Sectors;
|
||||
AaruConsole.WriteLine("{0} bytes", entropy.Sectors);
|
||||
@@ -252,7 +252,7 @@ public sealed class Entropy
|
||||
|
||||
if(bytesRead != data.Length)
|
||||
{
|
||||
byte[] tmp = new byte[bytesRead];
|
||||
var tmp = new byte[bytesRead];
|
||||
Array.Copy(data, 0, tmp, 0, bytesRead);
|
||||
data = tmp;
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Interop;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using Aaru.CommonTypes.Interop;
|
||||
|
||||
/// <summary>Prints the description of a system error number.</summary>
|
||||
public static class Error
|
||||
{
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Core filesystem operations</summary>
|
||||
public static class Filesystems
|
||||
{
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using Aaru.Checksums;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Plugin base operations</summary>
|
||||
public static class GetPluginBase
|
||||
{
|
||||
|
||||
@@ -30,14 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Core media image format operations</summary>
|
||||
public static class ImageFormat
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -47,18 +49,17 @@ using Aaru.Decoders.CD;
|
||||
using Aaru.Decoders.DVD;
|
||||
using Aaru.Decoders.PCMCIA;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SecureDigital;
|
||||
using Aaru.Decoders.Xbox;
|
||||
using Aaru.Helpers;
|
||||
using global::Spectre.Console;
|
||||
using Schemas;
|
||||
using Spectre.Console;
|
||||
using DDS = Aaru.Decoders.DVD.DDS;
|
||||
using DMI = Aaru.Decoders.Xbox.DMI;
|
||||
using Inquiry = Aaru.Decoders.SCSI.Inquiry;
|
||||
using Session = Aaru.CommonTypes.Structs.Session;
|
||||
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Image information operations</summary>
|
||||
public static class ImageInfo
|
||||
{
|
||||
@@ -394,7 +395,7 @@ public static class ImageInfo
|
||||
|
||||
if(dataLen + 2 != toc.Length)
|
||||
{
|
||||
byte[] tmp = new byte[toc.Length + 2];
|
||||
var tmp = new byte[toc.Length + 2];
|
||||
Array.Copy(toc, 0, tmp, 2, toc.Length);
|
||||
tmp[0] = (byte)((toc.Length & 0xFF00) >> 8);
|
||||
tmp[1] = (byte)(toc.Length & 0xFF);
|
||||
@@ -418,7 +419,7 @@ public static class ImageInfo
|
||||
|
||||
if(dataLen + 2 != pma.Length)
|
||||
{
|
||||
byte[] tmp = new byte[pma.Length + 2];
|
||||
var tmp = new byte[pma.Length + 2];
|
||||
Array.Copy(pma, 0, tmp, 2, pma.Length);
|
||||
tmp[0] = (byte)((pma.Length & 0xFF00) >> 8);
|
||||
tmp[1] = (byte)(pma.Length & 0xFF);
|
||||
@@ -441,7 +442,7 @@ public static class ImageInfo
|
||||
|
||||
if(dataLen + 4 != atip.Length)
|
||||
{
|
||||
byte[] tmp = new byte[atip.Length + 4];
|
||||
var tmp = new byte[atip.Length + 4];
|
||||
Array.Copy(atip, 0, tmp, 4, atip.Length);
|
||||
tmp[0] = (byte)((atip.Length & 0xFF000000) >> 24);
|
||||
tmp[1] = (byte)((atip.Length & 0xFF0000) >> 16);
|
||||
@@ -466,7 +467,7 @@ public static class ImageInfo
|
||||
|
||||
if(dataLen + 4 != cdtext.Length)
|
||||
{
|
||||
byte[] tmp = new byte[cdtext.Length + 4];
|
||||
var tmp = new byte[cdtext.Length + 4];
|
||||
Array.Copy(cdtext, 0, tmp, 4, cdtext.Length);
|
||||
tmp[0] = (byte)((cdtext.Length & 0xFF000000) >> 24);
|
||||
tmp[1] = (byte)((cdtext.Length & 0xFF0000) >> 16);
|
||||
@@ -561,7 +562,7 @@ public static class ImageInfo
|
||||
if(errno == ErrorNumber.NoError)
|
||||
{
|
||||
AaruConsole.WriteLine("[bold]Bluray Disc Definition Structure contained in image:[/]");
|
||||
AaruConsole.Write("{0}", Decoders.Bluray.DDS.Prettify(dds));
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.Bluray.DDS.Prettify(dds));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -650,7 +651,7 @@ public static class ImageInfo
|
||||
if(errno == ErrorNumber.NoError)
|
||||
{
|
||||
AaruConsole.WriteLine("[bold]SecureDigital CID contained in image:[/]");
|
||||
AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyCID(cid));
|
||||
AaruConsole.Write("{0}", Decoders.PrettifyCID(cid));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -662,7 +663,7 @@ public static class ImageInfo
|
||||
if(errno == ErrorNumber.NoError)
|
||||
{
|
||||
AaruConsole.WriteLine("[bold]SecureDigital CSD contained in image:[/]");
|
||||
AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyCSD(csd));
|
||||
AaruConsole.Write("{0}", Decoders.PrettifyCSD(csd));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -674,7 +675,7 @@ public static class ImageInfo
|
||||
if(errno == ErrorNumber.NoError)
|
||||
{
|
||||
AaruConsole.WriteLine("[bold]SecureDigital SCR contained in image:[/]");
|
||||
AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifySCR(scr));
|
||||
AaruConsole.Write("{0}", Decoders.PrettifySCR(scr));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -686,7 +687,7 @@ public static class ImageInfo
|
||||
if(errno == ErrorNumber.NoError)
|
||||
{
|
||||
AaruConsole.WriteLine("[bold]SecureDigital OCR contained in image:[/]");
|
||||
AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyOCR(ocr));
|
||||
AaruConsole.Write("{0}", Decoders.PrettifyOCR(ocr));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -698,7 +699,7 @@ public static class ImageInfo
|
||||
if(errno == ErrorNumber.NoError)
|
||||
{
|
||||
AaruConsole.WriteLine("[bold]MultiMediaCard CID contained in image:[/]");
|
||||
AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyCID(cid));
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyCID(cid));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -710,7 +711,7 @@ public static class ImageInfo
|
||||
if(errno == ErrorNumber.NoError)
|
||||
{
|
||||
AaruConsole.WriteLine("[bold]MultiMediaCard CSD contained in image:[/]");
|
||||
AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyCSD(csd));
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyCSD(csd));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -722,7 +723,7 @@ public static class ImageInfo
|
||||
if(errno == ErrorNumber.NoError)
|
||||
{
|
||||
AaruConsole.WriteLine("[bold]MultiMediaCard ExtendedCSD contained in image:[/]");
|
||||
AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyExtendedCSD(ecsd));
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyExtendedCSD(ecsd));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -734,7 +735,7 @@ public static class ImageInfo
|
||||
if(errno == ErrorNumber.NoError)
|
||||
{
|
||||
AaruConsole.WriteLine("[bold]MultiMediaCard OCR contained in image:[/]");
|
||||
AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyOCR(ocr));
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyOCR(ocr));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Logging;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
@@ -39,8 +41,6 @@ using Aaru.Devices;
|
||||
using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
namespace Aaru.Core.Logging;
|
||||
|
||||
/// <summary>Creates a dump log</summary>
|
||||
public sealed class DumpLog
|
||||
{
|
||||
@@ -91,7 +91,7 @@ public sealed class DumpLog
|
||||
{
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
|
||||
for(int i = 0; i < args.Length; i++)
|
||||
for(var i = 0; i < args.Length; i++)
|
||||
{
|
||||
if(args[i].StartsWith("/dev", StringComparison.OrdinalIgnoreCase) ||
|
||||
args[i].StartsWith("aaru://", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -120,8 +120,7 @@ public sealed class DumpLog
|
||||
_logSw.WriteLine("Server: {0}", dev.RemoteApplication);
|
||||
_logSw.WriteLine("Version: {0}", dev.RemoteVersion);
|
||||
|
||||
_logSw.WriteLine("Operating system: {0} {1}", dev.RemoteOperatingSystem,
|
||||
dev.RemoteOperatingSystemVersion);
|
||||
_logSw.WriteLine("Operating system: {0} {1}", dev.RemoteOperatingSystem, dev.RemoteOperatingSystemVersion);
|
||||
|
||||
_logSw.WriteLine("Architecture: {0}", dev.RemoteArchitecture);
|
||||
_logSw.WriteLine("Protocol version: {0}", dev.RemoteProtocolVersion);
|
||||
@@ -184,7 +183,7 @@ public sealed class DumpLog
|
||||
if(_logSw == null)
|
||||
return;
|
||||
|
||||
string text = string.Format(format, args);
|
||||
var text = string.Format(format, args);
|
||||
_logSw.WriteLine("{0:s} {1}", DateTime.Now, text);
|
||||
_logSw.Flush();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Logging;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -33,8 +35,6 @@ using System.Linq;
|
||||
using Aaru.Decoders.ATA;
|
||||
using Aaru.Decoders.SCSI;
|
||||
|
||||
namespace Aaru.Core.Logging;
|
||||
|
||||
/// <summary>Logs errors</summary>
|
||||
public sealed class ErrorLog
|
||||
{
|
||||
@@ -76,8 +76,8 @@ public sealed class ErrorLog
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> error = new List<string>();
|
||||
List<string> status = new List<string>();
|
||||
var error = new List<string>();
|
||||
var status = new List<string>();
|
||||
|
||||
if((registers.Status & 0x01) == 0x01)
|
||||
status.Add("ERR");
|
||||
@@ -153,8 +153,8 @@ public sealed class ErrorLog
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> error = new List<string>();
|
||||
List<string> status = new List<string>();
|
||||
var error = new List<string>();
|
||||
var status = new List<string>();
|
||||
|
||||
if((registers.Status & 0x01) == 0x01)
|
||||
status.Add("ERR");
|
||||
@@ -204,8 +204,8 @@ public sealed class ErrorLog
|
||||
if((registers.Error & 0x80) == 0x80)
|
||||
error.Add("BBK");
|
||||
|
||||
_logSw.WriteLine("ATA reading C/H/S {0}/{1}/{2} error: status = {3}, error = {4}.", cylinder, head,
|
||||
sector, string.Join(' ', status), string.Join(' ', error));
|
||||
_logSw.WriteLine("ATA reading C/H/S {0}/{1}/{2} error: status = {3}, error = {4}.", cylinder, head, sector,
|
||||
string.Join(' ', status), string.Join(' ', error));
|
||||
|
||||
_logSw.Flush();
|
||||
}
|
||||
@@ -225,8 +225,8 @@ public sealed class ErrorLog
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> error = new List<string>();
|
||||
List<string> status = new List<string>();
|
||||
var error = new List<string>();
|
||||
var status = new List<string>();
|
||||
|
||||
if((registers.Status & 0x01) == 0x01)
|
||||
status.Add("ERR");
|
||||
@@ -276,8 +276,8 @@ public sealed class ErrorLog
|
||||
if((registers.Error & 0x80) == 0x80)
|
||||
error.Add("BBK");
|
||||
|
||||
_logSw.WriteLine("ATA reading LBA {0} error: status = {1}, error = {2}.", block,
|
||||
string.Join(' ', status), string.Join(' ', error));
|
||||
_logSw.WriteLine("ATA reading LBA {0} error: status = {1}, error = {2}.", block, string.Join(' ', status),
|
||||
string.Join(' ', error));
|
||||
|
||||
_logSw.Flush();
|
||||
}
|
||||
@@ -297,8 +297,8 @@ public sealed class ErrorLog
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> error = new List<string>();
|
||||
List<string> status = new List<string>();
|
||||
var error = new List<string>();
|
||||
var status = new List<string>();
|
||||
|
||||
if((registers.Status & 0x01) == 0x01)
|
||||
status.Add("ERR");
|
||||
@@ -348,8 +348,8 @@ public sealed class ErrorLog
|
||||
if((registers.Error & 0x80) == 0x80)
|
||||
error.Add("BBK");
|
||||
|
||||
_logSw.WriteLine("ATA reading LBA {0} error: status = {1}, error = {2}.", block,
|
||||
string.Join(' ', status), string.Join(' ', error));
|
||||
_logSw.WriteLine("ATA reading LBA {0} error: status = {1}, error = {2}.", block, string.Join(' ', status),
|
||||
string.Join(' ', error));
|
||||
|
||||
_logSw.Flush();
|
||||
}
|
||||
@@ -372,7 +372,7 @@ public sealed class ErrorLog
|
||||
|
||||
DecodedSense? decodedSense = Sense.Decode(senseBuffer);
|
||||
string prettySense = Sense.PrettifySense(senseBuffer);
|
||||
string hexSense = string.Join(' ', senseBuffer.Select(b => $"{b:X2}"));
|
||||
var hexSense = string.Join(' ', senseBuffer.Select(b => $"{b:X2}"));
|
||||
|
||||
if(decodedSense.HasValue)
|
||||
{
|
||||
@@ -387,15 +387,13 @@ public sealed class ErrorLog
|
||||
prettySense = prettySense.Replace("\n", " - ");
|
||||
|
||||
_logSw.WriteLine("SCSI command {0} error: SENSE {1} ASC {2:X2}h ASCQ {3:X2}h, {4}, {5}.", command,
|
||||
decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ,
|
||||
hexSense, prettySense);
|
||||
decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, hexSense,
|
||||
prettySense);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logSw.WriteLine("SCSI command {0} error: SENSE {1} ASC {2:X2}h ASCQ {3:X2}h, {4}.", command,
|
||||
decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ,
|
||||
hexSense);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -412,9 +410,7 @@ public sealed class ErrorLog
|
||||
_logSw.WriteLine("SCSI command {0} error: {1}, {2}.", command, hexSense, prettySense);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logSw.WriteLine("SCSI command {0} error: {1}", command, hexSense);
|
||||
}
|
||||
}
|
||||
|
||||
_logSw.Flush();
|
||||
@@ -440,7 +436,7 @@ public sealed class ErrorLog
|
||||
|
||||
DecodedSense? decodedSense = Sense.Decode(senseBuffer);
|
||||
string prettySense = Sense.PrettifySense(senseBuffer);
|
||||
string hexSense = string.Join(' ', senseBuffer.Select(b => $"{b:X2}"));
|
||||
var hexSense = string.Join(' ', senseBuffer.Select(b => $"{b:X2}"));
|
||||
|
||||
if(decodedSense.HasValue)
|
||||
{
|
||||
@@ -455,15 +451,13 @@ public sealed class ErrorLog
|
||||
prettySense = prettySense.Replace("\n", " - ");
|
||||
|
||||
_logSw.WriteLine("SCSI reading LBA {0} error: SENSE {1} ASC {2:X2}h ASCQ {3:X2}h, {4}, {5}.", block,
|
||||
decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ,
|
||||
hexSense, prettySense);
|
||||
decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, hexSense,
|
||||
prettySense);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logSw.WriteLine("SCSI reading LBA {0} error: SENSE {1} ASC {2:X2}h ASCQ {3:X2}h, {4}.", block,
|
||||
decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ,
|
||||
hexSense);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -480,9 +474,7 @@ public sealed class ErrorLog
|
||||
_logSw.WriteLine("SCSI reading LBA {0} error: {1}, {2}.", block, hexSense, prettySense);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logSw.WriteLine("SCSI reading LBA {0} error: {1}", block, hexSense);
|
||||
}
|
||||
}
|
||||
|
||||
_logSw.Flush();
|
||||
@@ -529,8 +521,8 @@ public sealed class ErrorLog
|
||||
return;
|
||||
}
|
||||
|
||||
_logSw.WriteLine("SD/MMC reading LBA {0} ({1}-addressed) error: {2}", block,
|
||||
byteAddressed ? "byte" : "block", string.Join(" - ", response.Select(r => $"0x{r:X8}")));
|
||||
_logSw.WriteLine("SD/MMC reading LBA {0} ({1}-addressed) error: {2}", block, byteAddressed ? "byte" : "block",
|
||||
string.Join(" - ", response.Select(r => $"0x{r:X8}")));
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -30,16 +30,16 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Logging;
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Logging;
|
||||
|
||||
/// <summary>Implements a log in the format used by IMGBurn</summary>
|
||||
internal sealed class IbgLog
|
||||
sealed class IbgLog
|
||||
{
|
||||
readonly CultureInfo _ibgCulture;
|
||||
readonly double _ibgDivider;
|
||||
@@ -328,8 +328,7 @@ internal sealed class IbgLog
|
||||
ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_START={0:0.00}", _ibgStartSpeed).AppendLine();
|
||||
ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_END={0:0.00}", currentSpeed / _ibgDivider).AppendLine();
|
||||
|
||||
ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_AVERAGE={0:0.00}", averageSpeed / _ibgDivider).
|
||||
AppendLine();
|
||||
ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_AVERAGE={0:0.00}", averageSpeed / _ibgDivider).AppendLine();
|
||||
|
||||
ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_MAX={0:0.00}", _ibgMaxSpeed).AppendLine();
|
||||
ibgHeader.AppendFormat(_ibgCulture, "VERIFY_TIME_TAKEN={0:0}", Math.Floor(totalSeconds)).AppendLine();
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Logging;
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
@@ -37,10 +39,8 @@ using System.Text;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Logging;
|
||||
|
||||
/// <summary>Implements a log in the format used by MHDD</summary>
|
||||
internal sealed class MhddLog
|
||||
sealed class MhddLog
|
||||
{
|
||||
const string MHDD_VER = "VER:2 ";
|
||||
readonly string _logFile;
|
||||
@@ -53,8 +53,7 @@ internal sealed class MhddLog
|
||||
/// <param name="blockSize">Bytes per block</param>
|
||||
/// <param name="blocksToRead">How many blocks read at once</param>
|
||||
/// <param name="private">Disable saving paths or serial numbers in log</param>
|
||||
internal MhddLog(string outputFile, Device dev, ulong blocks, ulong blockSize, ulong blocksToRead,
|
||||
bool @private)
|
||||
internal MhddLog(string outputFile, Device dev, ulong blocks, ulong blockSize, ulong blocksToRead, bool @private)
|
||||
{
|
||||
if(dev == null ||
|
||||
string.IsNullOrEmpty(outputFile))
|
||||
@@ -94,14 +93,13 @@ internal sealed class MhddLog
|
||||
break;
|
||||
}
|
||||
|
||||
string device = $"DEVICE: {dev.Manufacturer} {dev.Model}";
|
||||
string fw = $"F/W: {dev.FirmwareRevision}";
|
||||
string sn = $"S/N: {(@private ? "" : dev.Serial)}";
|
||||
string sectors = string.Format(new CultureInfo("en-US"), "SECTORS: {0:n0}", blocks);
|
||||
string sectorSize = string.Format(new CultureInfo("en-US"), "SECTOR SIZE: {0:n0} bytes", blockSize);
|
||||
var device = $"DEVICE: {dev.Manufacturer} {dev.Model}";
|
||||
var fw = $"F/W: {dev.FirmwareRevision}";
|
||||
var sn = $"S/N: {(@private ? "" : dev.Serial)}";
|
||||
var sectors = string.Format(new CultureInfo("en-US"), "SECTORS: {0:n0}", blocks);
|
||||
var sectorSize = string.Format(new CultureInfo("en-US"), "SECTOR SIZE: {0:n0} bytes", blockSize);
|
||||
|
||||
string scanBlockSize =
|
||||
string.Format(new CultureInfo("en-US"), "SCAN BLOCK SIZE: {0:n0} sectors", blocksToRead);
|
||||
var scanBlockSize = string.Format(new CultureInfo("en-US"), "SCAN BLOCK SIZE: {0:n0} sectors", blocksToRead);
|
||||
|
||||
byte[] deviceBytes = Encoding.ASCII.GetBytes(device);
|
||||
byte[] modeBytes = Encoding.ASCII.GetBytes(mode);
|
||||
@@ -112,12 +110,12 @@ internal sealed class MhddLog
|
||||
byte[] scanBlockSizeBytes = Encoding.ASCII.GetBytes(scanBlockSize);
|
||||
byte[] verBytes = Encoding.ASCII.GetBytes(MHDD_VER);
|
||||
|
||||
uint pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length + snBytes.Length +
|
||||
sectorsBytes.Length + sectorSizeBytes.Length + scanBlockSizeBytes.Length +
|
||||
verBytes.Length + (2 * 9) + // New lines
|
||||
4); // Pointer
|
||||
var pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length + snBytes.Length +
|
||||
sectorsBytes.Length + sectorSizeBytes.Length + scanBlockSizeBytes.Length +
|
||||
verBytes.Length + 2 * 9 + // New lines
|
||||
4); // Pointer
|
||||
|
||||
byte[] newLine = new byte[2];
|
||||
var newLine = new byte[2];
|
||||
newLine[0] = 0x0D;
|
||||
newLine[1] = 0x0A;
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Logging;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Aaru.Decoders.CD;
|
||||
|
||||
namespace Aaru.Core.Logging;
|
||||
|
||||
/// <summary>Logs subchannel data</summary>
|
||||
public class SubchannelLog
|
||||
{
|
||||
@@ -81,16 +81,16 @@ public class SubchannelLog
|
||||
return;
|
||||
}
|
||||
|
||||
int[] p = new int[subchannel.Length / 8];
|
||||
int[] q = new int[subchannel.Length / 8];
|
||||
int[] r = new int[subchannel.Length / 8];
|
||||
int[] s = new int[subchannel.Length / 8];
|
||||
int[] t = new int[subchannel.Length / 8];
|
||||
int[] u = new int[subchannel.Length / 8];
|
||||
int[] v = new int[subchannel.Length / 8];
|
||||
int[] w = new int[subchannel.Length / 8];
|
||||
var p = new int[subchannel.Length / 8];
|
||||
var q = new int[subchannel.Length / 8];
|
||||
var r = new int[subchannel.Length / 8];
|
||||
var s = new int[subchannel.Length / 8];
|
||||
var t = new int[subchannel.Length / 8];
|
||||
var u = new int[subchannel.Length / 8];
|
||||
var v = new int[subchannel.Length / 8];
|
||||
var w = new int[subchannel.Length / 8];
|
||||
|
||||
for(int i = 0; i < subchannel.Length; i += 8)
|
||||
for(var i = 0; i < subchannel.Length; i += 8)
|
||||
{
|
||||
p[i / 8] = subchannel[i] & 0x80;
|
||||
p[i / 8] += (subchannel[i + 1] & 0x80) >> 1;
|
||||
@@ -167,14 +167,13 @@ public class SubchannelLog
|
||||
|
||||
for(uint block = 0; block < blocks; block++)
|
||||
{
|
||||
bool rwEmpty = true;
|
||||
var rwEmpty = true;
|
||||
|
||||
if(raw)
|
||||
for(uint i = 12 * block; i < (12 * block) + 12; i++)
|
||||
for(uint i = 12 * block; i < 12 * block + 12; i++)
|
||||
{
|
||||
if((r[i] == 0 && s[i] == 0 && t[i] == 0 && u[i] == 0 && v[i] == 0 && w[i] == 0) ||
|
||||
(r[i] == 0xFF && s[i] == 0xFF && t[i] == 0xFF && u[i] == 0xFF && v[i] == 0xFF &&
|
||||
w[i] == 0xFF))
|
||||
if(r[i] == 0 && s[i] == 0 && t[i] == 0 && u[i] == 0 && v[i] == 0 && w[i] == 0 ||
|
||||
r[i] == 0xFF && s[i] == 0xFF && t[i] == 0xFF && u[i] == 0xFF && v[i] == 0xFF && w[i] == 0xFF)
|
||||
continue;
|
||||
|
||||
rwEmpty = false;
|
||||
@@ -182,10 +181,10 @@ public class SubchannelLog
|
||||
break;
|
||||
}
|
||||
|
||||
bool corruptedPause = false;
|
||||
bool pause = false;
|
||||
var corruptedPause = false;
|
||||
var pause = false;
|
||||
|
||||
for(int i = 0; i < 12; i++)
|
||||
for(var i = 0; i < 12; i++)
|
||||
{
|
||||
if(p[i] == 0 ||
|
||||
p[i] == 0xFF)
|
||||
@@ -199,22 +198,22 @@ public class SubchannelLog
|
||||
if(!corruptedPause)
|
||||
pause = p[0] == 1;
|
||||
|
||||
byte[] subBuf = new byte[12];
|
||||
subBuf[0] = (byte)q[0 + (block * 12)];
|
||||
subBuf[1] = (byte)q[1 + (block * 12)];
|
||||
subBuf[2] = (byte)q[2 + (block * 12)];
|
||||
subBuf[3] = (byte)q[3 + (block * 12)];
|
||||
subBuf[4] = (byte)q[4 + (block * 12)];
|
||||
subBuf[5] = (byte)q[5 + (block * 12)];
|
||||
subBuf[6] = (byte)q[6 + (block * 12)];
|
||||
subBuf[7] = (byte)q[7 + (block * 12)];
|
||||
subBuf[8] = (byte)q[8 + (block * 12)];
|
||||
subBuf[9] = (byte)q[9 + (block * 12)];
|
||||
subBuf[10] = (byte)q[10 + (block * 12)];
|
||||
subBuf[11] = (byte)q[11 + (block * 12)];
|
||||
var subBuf = new byte[12];
|
||||
subBuf[0] = (byte)q[0 + block * 12];
|
||||
subBuf[1] = (byte)q[1 + block * 12];
|
||||
subBuf[2] = (byte)q[2 + block * 12];
|
||||
subBuf[3] = (byte)q[3 + block * 12];
|
||||
subBuf[4] = (byte)q[4 + block * 12];
|
||||
subBuf[5] = (byte)q[5 + block * 12];
|
||||
subBuf[6] = (byte)q[6 + block * 12];
|
||||
subBuf[7] = (byte)q[7 + block * 12];
|
||||
subBuf[8] = (byte)q[8 + block * 12];
|
||||
subBuf[9] = (byte)q[9 + block * 12];
|
||||
subBuf[10] = (byte)q[10 + block * 12];
|
||||
subBuf[11] = (byte)q[11 + block * 12];
|
||||
|
||||
string prettyQ = Subchannel.PrettifyQ(subBuf, generated || _bcd, startingLba + block, corruptedPause,
|
||||
pause, rwEmpty);
|
||||
string prettyQ = Subchannel.PrettifyQ(subBuf, generated || _bcd, startingLba + block, corruptedPause, pause,
|
||||
rwEmpty);
|
||||
|
||||
if(generated)
|
||||
prettyQ += " (GENERATED)";
|
||||
@@ -241,8 +240,7 @@ public class SubchannelLog
|
||||
|
||||
/// <summary>Logs message indicating the CONTROL field of the Q subchannel has been fixed</summary>
|
||||
/// <param name="lba">LBA fix belongs to</param>
|
||||
public void WriteQCtrlFix(long lba) =>
|
||||
WriteMessageWithPosition(lba, "fixed Q subchannel with correct CONTROL.");
|
||||
public void WriteQCtrlFix(long lba) => WriteMessageWithPosition(lba, "fixed Q subchannel with correct CONTROL.");
|
||||
|
||||
/// <summary>Logs message indicating the ZERO field of the Q subchannel has been fixed</summary>
|
||||
/// <param name="lba">LBA fix belongs to</param>
|
||||
@@ -276,8 +274,7 @@ public class SubchannelLog
|
||||
|
||||
/// <summary>Logs message indicating the the Q subchannel has been fixed with a known good ISRC</summary>
|
||||
/// <param name="lba">LBA fix belongs to</param>
|
||||
public void WriteQIsrcFix(long lba) =>
|
||||
WriteMessageWithPosition(lba, "fixed Q subchannel with known good ISRC.");
|
||||
public void WriteQIsrcFix(long lba) => WriteMessageWithPosition(lba, "fixed Q subchannel with known good ISRC.");
|
||||
|
||||
/// <summary>Logs a message with a specified position</summary>
|
||||
/// <param name="lba">LBA position</param>
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Media;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -39,8 +41,6 @@ using Aaru.Decoders.CD;
|
||||
using Aaru.Devices;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.Core.Media;
|
||||
|
||||
/// <summary>Operations over CD based media</summary>
|
||||
public static class CompactDisc
|
||||
{
|
||||
@@ -83,8 +83,7 @@ public static class CompactDisc
|
||||
desiredSubchannel != MmcSubchannel.None)
|
||||
outputPlugin.WriteSectorsTag(sub, sectorAddress, length, SectorTagType.CdSectorSubchannel);
|
||||
|
||||
subLog?.WriteEntry(sub, supportedSubchannel == MmcSubchannel.Raw, (long)sectorAddress, length, false,
|
||||
false);
|
||||
subLog?.WriteEntry(sub, supportedSubchannel == MmcSubchannel.Raw, (long)sectorAddress, length, false, false);
|
||||
|
||||
byte[] deSub = Subchannel.Deinterleave(sub);
|
||||
|
||||
@@ -98,15 +97,15 @@ public static class CompactDisc
|
||||
int prePos = int.MinValue;
|
||||
|
||||
// Check subchannel
|
||||
for(int subPos = 0; subPos < deSub.Length; subPos += 96)
|
||||
for(var subPos = 0; subPos < deSub.Length; subPos += 96)
|
||||
{
|
||||
// Expected LBA
|
||||
long lba = (long)sectorAddress + (subPos / 96);
|
||||
long lba = (long)sectorAddress + subPos / 96;
|
||||
|
||||
// We fixed the subchannel
|
||||
bool @fixed = false;
|
||||
var @fixed = false;
|
||||
|
||||
byte[] q = new byte[12];
|
||||
var q = new byte[12];
|
||||
Array.Copy(deSub, subPos + 12, q, 0, 12);
|
||||
|
||||
// Check Q CRC
|
||||
@@ -114,8 +113,8 @@ public static class CompactDisc
|
||||
bool crcOk = crc[0] == q[10] && crc[1] == q[11];
|
||||
|
||||
// Start considering P to be OK
|
||||
bool pOk = true;
|
||||
int pWeight = 0;
|
||||
var pOk = true;
|
||||
var pWeight = 0;
|
||||
|
||||
// Check P and weight
|
||||
for(int p = subPos; p < subPos + 12; p++)
|
||||
@@ -124,7 +123,7 @@ public static class CompactDisc
|
||||
deSub[p] != 255)
|
||||
pOk = false;
|
||||
|
||||
for(int w = 0; w < 8; w++)
|
||||
for(var w = 0; w < 8; w++)
|
||||
if(((deSub[p] >> w) & 1) > 0)
|
||||
pWeight++;
|
||||
}
|
||||
@@ -149,13 +148,13 @@ public static class CompactDisc
|
||||
deSub.Skip(subPos + 84).Take(12).All(w => w == 0xFF);
|
||||
|
||||
bool rwOk = rOk && sOk && tOk && uOk && vOk && wOk;
|
||||
bool rwPacket = false;
|
||||
bool cdtextPacket = false;
|
||||
var rwPacket = false;
|
||||
var cdtextPacket = false;
|
||||
|
||||
// Check RW contents
|
||||
if(!rwOk)
|
||||
{
|
||||
byte[] sectorSub = new byte[96];
|
||||
var sectorSub = new byte[96];
|
||||
Array.Copy(sub, subPos, sectorSub, 0, 96);
|
||||
|
||||
DetectRwPackets(sectorSub, out _, out rwPacket, out cdtextPacket);
|
||||
@@ -211,9 +210,9 @@ public static class CompactDisc
|
||||
isrcs.TryGetValue(currentTrack, out string knownGoodIsrc);
|
||||
|
||||
crcOk = FixQSubchannel(deSub, q, subPos, mcn, knownGoodIsrc, fixSubchannelCrc, out bool fixedAdr,
|
||||
out bool controlFix, out bool fixedZero, out bool fixedTno,
|
||||
out bool fixedIndex, out bool fixedRelPos, out bool fixedAbsPos,
|
||||
out bool fixedCrc, out bool fixedMcn, out bool fixedIsrc);
|
||||
out bool controlFix, out bool fixedZero, out bool fixedTno, out bool fixedIndex,
|
||||
out bool fixedRelPos, out bool fixedAbsPos, out bool fixedCrc, out bool fixedMcn,
|
||||
out bool fixedIsrc);
|
||||
|
||||
if(crcOk)
|
||||
{
|
||||
@@ -257,13 +256,13 @@ public static class CompactDisc
|
||||
!rwOk)
|
||||
continue;
|
||||
|
||||
aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F));
|
||||
aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
|
||||
if((q[0] & 0x3) == 1)
|
||||
{
|
||||
amin = (byte)((q[7] / 16 * 10) + (q[7] & 0x0F));
|
||||
asec = (byte)((q[8] / 16 * 10) + (q[8] & 0x0F));
|
||||
aPos = (amin * 60 * 75) + (asec * 75) + aframe - 150;
|
||||
amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F));
|
||||
asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F));
|
||||
aPos = amin * 60 * 75 + asec * 75 + aframe - 150;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -272,7 +271,7 @@ public static class CompactDisc
|
||||
expectedSectorAddress -= (ulong)(smin * 60 * 75);
|
||||
ssec = (byte)(expectedSectorAddress / 75);
|
||||
|
||||
aPos = (smin * 60 * 75) + (ssec * 75) + aframe - 150;
|
||||
aPos = smin * 60 * 75 + ssec * 75 + aframe - 150;
|
||||
|
||||
// Next second
|
||||
if(aPos < prePos)
|
||||
@@ -285,7 +284,7 @@ public static class CompactDisc
|
||||
|
||||
prePos = aPos;
|
||||
|
||||
byte[] posSub = new byte[96];
|
||||
var posSub = new byte[96];
|
||||
Array.Copy(deSub, subPos, posSub, 0, 96);
|
||||
posSub = Subchannel.Interleave(posSub);
|
||||
outputPlugin.WriteSectorTag(posSub, (ulong)aPos, SectorTagType.CdSectorSubchannel);
|
||||
@@ -315,12 +314,12 @@ public static class CompactDisc
|
||||
UpdateStatusHandler updateStatus,
|
||||
Dictionary<byte, int> smallestPregapLbaPerTrack, bool dumping)
|
||||
{
|
||||
bool status = false;
|
||||
var status = false;
|
||||
|
||||
// Check subchannel
|
||||
for(int subPos = 0; subPos < deSub.Length; subPos += 96)
|
||||
for(var subPos = 0; subPos < deSub.Length; subPos += 96)
|
||||
{
|
||||
byte[] q = new byte[12];
|
||||
var q = new byte[12];
|
||||
Array.Copy(deSub, subPos + 12, q, 0, 12);
|
||||
|
||||
CRC16CCITTContext.Data(q, 10, out byte[] crc);
|
||||
@@ -391,9 +390,9 @@ public static class CompactDisc
|
||||
case 1 when !crcOk: continue;
|
||||
case 1:
|
||||
{
|
||||
byte trackNo = (byte)((q[1] / 16 * 10) + (q[1] & 0x0F));
|
||||
var trackNo = (byte)(q[1] / 16 * 10 + (q[1] & 0x0F));
|
||||
|
||||
for(int i = 0; i < tracks.Length; i++)
|
||||
for(var i = 0; i < tracks.Length; i++)
|
||||
{
|
||||
if(tracks[i].Sequence != trackNo)
|
||||
continue;
|
||||
@@ -402,10 +401,10 @@ public static class CompactDisc
|
||||
if(q[2] == 0 &&
|
||||
trackNo > 1)
|
||||
{
|
||||
byte pmin = (byte)((q[3] / 16 * 10) + (q[3] & 0x0F));
|
||||
byte psec = (byte)((q[4] / 16 * 10) + (q[4] & 0x0F));
|
||||
byte pframe = (byte)((q[5] / 16 * 10) + (q[5] & 0x0F));
|
||||
int qPos = (pmin * 60 * 75) + (psec * 75) + pframe;
|
||||
var pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F));
|
||||
var psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F));
|
||||
var pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F));
|
||||
int qPos = pmin * 60 * 75 + psec * 75 + pframe;
|
||||
|
||||
// When we are dumping we calculate the pregap in reverse from index 1 back.
|
||||
// When we are not, we go from index 0.
|
||||
@@ -413,8 +412,7 @@ public static class CompactDisc
|
||||
smallestPregapLbaPerTrack[trackNo] = dumping ? 1 : 0;
|
||||
|
||||
uint firstTrackNumberInSameSession = tracks.
|
||||
Where(t => t.Session ==
|
||||
tracks[i].Session).
|
||||
Where(t => t.Session == tracks[i].Session).
|
||||
Min(t => t.Sequence);
|
||||
|
||||
if(tracks[i].Sequence == firstTrackNumberInSameSession)
|
||||
@@ -431,11 +429,9 @@ public static class CompactDisc
|
||||
tracks[i - 1].EndSector >= tracks[i].StartSector)
|
||||
tracks[i - 1].EndSector = tracks[i].StartSector - 1;
|
||||
|
||||
dumpLog?.
|
||||
WriteLine($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors.");
|
||||
dumpLog?.WriteLine($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors.");
|
||||
|
||||
updateStatus?.
|
||||
Invoke($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors.");
|
||||
updateStatus?.Invoke($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors.");
|
||||
|
||||
status = true;
|
||||
}
|
||||
@@ -452,11 +448,9 @@ public static class CompactDisc
|
||||
tracks[i - 1].EndSector >= tracks[i].StartSector)
|
||||
tracks[i - 1].EndSector = tracks[i].StartSector - 1;
|
||||
|
||||
dumpLog?.
|
||||
WriteLine($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors.");
|
||||
dumpLog?.WriteLine($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors.");
|
||||
|
||||
updateStatus?.
|
||||
Invoke($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors.");
|
||||
updateStatus?.Invoke($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors.");
|
||||
|
||||
status = true;
|
||||
|
||||
@@ -466,10 +460,10 @@ public static class CompactDisc
|
||||
if(q[2] == 0)
|
||||
continue;
|
||||
|
||||
byte amin = (byte)((q[7] / 16 * 10) + (q[7] & 0x0F));
|
||||
byte asec = (byte)((q[8] / 16 * 10) + (q[8] & 0x0F));
|
||||
byte aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F));
|
||||
int aPos = (amin * 60 * 75) + (asec * 75) + aframe - 150;
|
||||
var amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F));
|
||||
var asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F));
|
||||
var aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
int aPos = amin * 60 * 75 + asec * 75 + aframe - 150;
|
||||
|
||||
if(tracks[i].Indexes.ContainsKey(q[2]) &&
|
||||
aPos >= tracks[i].Indexes[q[2]])
|
||||
@@ -502,18 +496,18 @@ public static class CompactDisc
|
||||
rwPacket = false;
|
||||
cdtextPacket = false;
|
||||
|
||||
byte[] cdTextPack1 = new byte[18];
|
||||
byte[] cdTextPack2 = new byte[18];
|
||||
byte[] cdTextPack3 = new byte[18];
|
||||
byte[] cdTextPack4 = new byte[18];
|
||||
byte[] cdSubRwPack1 = new byte[24];
|
||||
byte[] cdSubRwPack2 = new byte[24];
|
||||
byte[] cdSubRwPack3 = new byte[24];
|
||||
byte[] cdSubRwPack4 = new byte[24];
|
||||
var cdTextPack1 = new byte[18];
|
||||
var cdTextPack2 = new byte[18];
|
||||
var cdTextPack3 = new byte[18];
|
||||
var cdTextPack4 = new byte[18];
|
||||
var cdSubRwPack1 = new byte[24];
|
||||
var cdSubRwPack2 = new byte[24];
|
||||
var cdSubRwPack3 = new byte[24];
|
||||
var cdSubRwPack4 = new byte[24];
|
||||
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
for(var j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
@@ -532,7 +526,7 @@ public static class CompactDisc
|
||||
cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
for(var j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
@@ -551,7 +545,7 @@ public static class CompactDisc
|
||||
cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
for(var j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
@@ -570,7 +564,7 @@ public static class CompactDisc
|
||||
cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
for(var j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
@@ -591,16 +585,16 @@ public static class CompactDisc
|
||||
|
||||
i = 0;
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
switch(cdSubRwPack1[0])
|
||||
@@ -701,14 +695,14 @@ public static class CompactDisc
|
||||
/// <returns><c>true</c> if subchannel contains a TEXT packet, <c>false</c> otherwise</returns>
|
||||
static bool CheckCdTextPackets(byte[] subchannel)
|
||||
{
|
||||
byte[] cdTextPack1 = new byte[18];
|
||||
byte[] cdTextPack2 = new byte[18];
|
||||
byte[] cdTextPack3 = new byte[18];
|
||||
byte[] cdTextPack4 = new byte[18];
|
||||
var cdTextPack1 = new byte[18];
|
||||
var cdTextPack2 = new byte[18];
|
||||
var cdTextPack3 = new byte[18];
|
||||
var cdTextPack4 = new byte[18];
|
||||
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
for(var j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
@@ -727,7 +721,7 @@ public static class CompactDisc
|
||||
cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
for(var j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
@@ -746,7 +740,7 @@ public static class CompactDisc
|
||||
cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
for(var j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
@@ -765,7 +759,7 @@ public static class CompactDisc
|
||||
cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
for(int j = 0; j < 18; j++)
|
||||
for(var j = 0; j < 18; j++)
|
||||
{
|
||||
cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x3F) << 2));
|
||||
|
||||
@@ -784,12 +778,12 @@ public static class CompactDisc
|
||||
cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F));
|
||||
}
|
||||
|
||||
bool status = true;
|
||||
var status = true;
|
||||
|
||||
if((cdTextPack1[0] & 0x80) == 0x80)
|
||||
{
|
||||
ushort cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16);
|
||||
byte[] cdTextPack1ForCrc = new byte[16];
|
||||
var cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16);
|
||||
var cdTextPack1ForCrc = new byte[16];
|
||||
Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16);
|
||||
ushort calculatedCdtp1Crc = CRC16CCITTContext.Calculate(cdTextPack1ForCrc);
|
||||
|
||||
@@ -800,8 +794,8 @@ public static class CompactDisc
|
||||
|
||||
if((cdTextPack2[0] & 0x80) == 0x80)
|
||||
{
|
||||
ushort cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16);
|
||||
byte[] cdTextPack2ForCrc = new byte[16];
|
||||
var cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16);
|
||||
var cdTextPack2ForCrc = new byte[16];
|
||||
Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16);
|
||||
ushort calculatedCdtp2Crc = CRC16CCITTContext.Calculate(cdTextPack2ForCrc);
|
||||
|
||||
@@ -812,8 +806,8 @@ public static class CompactDisc
|
||||
|
||||
if((cdTextPack3[0] & 0x80) == 0x80)
|
||||
{
|
||||
ushort cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16);
|
||||
byte[] cdTextPack3ForCrc = new byte[16];
|
||||
var cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16);
|
||||
var cdTextPack3ForCrc = new byte[16];
|
||||
Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16);
|
||||
ushort calculatedCdtp3Crc = CRC16CCITTContext.Calculate(cdTextPack3ForCrc);
|
||||
|
||||
@@ -825,8 +819,8 @@ public static class CompactDisc
|
||||
if((cdTextPack4[0] & 0x80) != 0x80)
|
||||
return status;
|
||||
|
||||
ushort cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16);
|
||||
byte[] cdTextPack4ForCrc = new byte[16];
|
||||
var cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16);
|
||||
var cdTextPack4ForCrc = new byte[16];
|
||||
Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16);
|
||||
ushort calculatedCdtp4Crc = CRC16CCITTContext.Calculate(cdTextPack4ForCrc);
|
||||
|
||||
@@ -873,8 +867,8 @@ public static class CompactDisc
|
||||
fixedMcn = false;
|
||||
fixedIsrc = false;
|
||||
|
||||
byte[] preQ = new byte[12];
|
||||
byte[] nextQ = new byte[12];
|
||||
var preQ = new byte[12];
|
||||
var nextQ = new byte[12];
|
||||
Array.Copy(deSub, subPos + 12 - 96, preQ, 0, 12);
|
||||
Array.Copy(deSub, subPos + 12 + 96, nextQ, 0, 12);
|
||||
bool status;
|
||||
@@ -1007,7 +1001,6 @@ public static class CompactDisc
|
||||
}
|
||||
|
||||
if(preCrcOk && nextCrcOk)
|
||||
{
|
||||
if(preQ[1] == nextQ[1] &&
|
||||
preQ[1] != q[1])
|
||||
{
|
||||
@@ -1020,10 +1013,8 @@ public static class CompactDisc
|
||||
if(status)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(preCrcOk && nextCrcOk)
|
||||
{
|
||||
if(preQ[2] == nextQ[2] &&
|
||||
preQ[2] != q[2])
|
||||
{
|
||||
@@ -1036,17 +1027,16 @@ public static class CompactDisc
|
||||
if(status)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
amin = (byte)((q[7] / 16 * 10) + (q[7] & 0x0F));
|
||||
asec = (byte)((q[8] / 16 * 10) + (q[8] & 0x0F));
|
||||
aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F));
|
||||
aPos = (amin * 60 * 75) + (asec * 75) + aframe - 150;
|
||||
amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F));
|
||||
asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F));
|
||||
aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
aPos = amin * 60 * 75 + asec * 75 + aframe - 150;
|
||||
|
||||
pmin = (byte)((q[3] / 16 * 10) + (q[3] & 0x0F));
|
||||
psec = (byte)((q[4] / 16 * 10) + (q[4] & 0x0F));
|
||||
pframe = (byte)((q[5] / 16 * 10) + (q[5] & 0x0F));
|
||||
pPos = (pmin * 60 * 75) + (psec * 75) + pframe;
|
||||
pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F));
|
||||
psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F));
|
||||
pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F));
|
||||
pPos = pmin * 60 * 75 + psec * 75 + pframe;
|
||||
|
||||
// TODO: pregap
|
||||
// Not pregap
|
||||
@@ -1055,10 +1045,10 @@ public static class CompactDisc
|
||||
// Previous was not pregap either
|
||||
if(preQ[2] > 0 && preCrcOk)
|
||||
{
|
||||
rmin = (byte)((preQ[3] / 16 * 10) + (preQ[3] & 0x0F));
|
||||
rsec = (byte)((preQ[4] / 16 * 10) + (preQ[4] & 0x0F));
|
||||
rframe = (byte)((preQ[5] / 16 * 10) + (preQ[5] & 0x0F));
|
||||
rPos = (rmin * 60 * 75) + (rsec * 75) + rframe;
|
||||
rmin = (byte)(preQ[3] / 16 * 10 + (preQ[3] & 0x0F));
|
||||
rsec = (byte)(preQ[4] / 16 * 10 + (preQ[4] & 0x0F));
|
||||
rframe = (byte)(preQ[5] / 16 * 10 + (preQ[5] & 0x0F));
|
||||
rPos = rmin * 60 * 75 + rsec * 75 + rframe;
|
||||
|
||||
dPos = pPos - rPos;
|
||||
|
||||
@@ -1112,10 +1102,10 @@ public static class CompactDisc
|
||||
nextCrcOk &&
|
||||
!fixedRelPos)
|
||||
{
|
||||
rmin = (byte)((nextQ[3] / 16 * 10) + (nextQ[3] & 0x0F));
|
||||
rsec = (byte)((nextQ[4] / 16 * 10) + (nextQ[4] & 0x0F));
|
||||
rframe = (byte)((nextQ[5] / 16 * 10) + (nextQ[5] & 0x0F));
|
||||
rPos = (rmin * 60 * 75) + (rsec * 75) + rframe;
|
||||
rmin = (byte)(nextQ[3] / 16 * 10 + (nextQ[3] & 0x0F));
|
||||
rsec = (byte)(nextQ[4] / 16 * 10 + (nextQ[4] & 0x0F));
|
||||
rframe = (byte)(nextQ[5] / 16 * 10 + (nextQ[5] & 0x0F));
|
||||
rPos = rmin * 60 * 75 + rsec * 75 + rframe;
|
||||
|
||||
dPos = rPos - pPos;
|
||||
|
||||
@@ -1172,10 +1162,10 @@ public static class CompactDisc
|
||||
// Previous Q's CRC is correct
|
||||
if(preCrcOk)
|
||||
{
|
||||
rmin = (byte)((preQ[7] / 16 * 10) + (preQ[7] & 0x0F));
|
||||
rsec = (byte)((preQ[8] / 16 * 10) + (preQ[8] & 0x0F));
|
||||
rframe = (byte)((preQ[9] / 16 * 10) + (preQ[9] & 0x0F));
|
||||
rPos = (rmin * 60 * 75) + (rsec * 75) + rframe - 150;
|
||||
rmin = (byte)(preQ[7] / 16 * 10 + (preQ[7] & 0x0F));
|
||||
rsec = (byte)(preQ[8] / 16 * 10 + (preQ[8] & 0x0F));
|
||||
rframe = (byte)(preQ[9] / 16 * 10 + (preQ[9] & 0x0F));
|
||||
rPos = rmin * 60 * 75 + rsec * 75 + rframe - 150;
|
||||
|
||||
dPos = aPos - rPos;
|
||||
|
||||
@@ -1229,10 +1219,10 @@ public static class CompactDisc
|
||||
nextCrcOk &&
|
||||
!fixedAbsPos)
|
||||
{
|
||||
rmin = (byte)((nextQ[7] / 16 * 10) + (nextQ[7] & 0x0F));
|
||||
rsec = (byte)((nextQ[8] / 16 * 10) + (nextQ[8] & 0x0F));
|
||||
rframe = (byte)((nextQ[9] / 16 * 10) + (nextQ[9] & 0x0F));
|
||||
rPos = (rmin * 60 * 75) + (rsec * 75) + rframe - 150;
|
||||
rmin = (byte)(nextQ[7] / 16 * 10 + (nextQ[7] & 0x0F));
|
||||
rsec = (byte)(nextQ[8] / 16 * 10 + (nextQ[8] & 0x0F));
|
||||
rframe = (byte)(nextQ[9] / 16 * 10 + (nextQ[9] & 0x0F));
|
||||
rPos = rmin * 60 * 75 + rsec * 75 + rframe - 150;
|
||||
|
||||
dPos = rPos - pPos;
|
||||
|
||||
@@ -1295,19 +1285,19 @@ public static class CompactDisc
|
||||
// Previous Q's CRC is correct
|
||||
if(preCrcOk)
|
||||
{
|
||||
rmin = (byte)((preQ[7] / 16 * 10) + (preQ[7] & 0x0F));
|
||||
rsec = (byte)((preQ[8] / 16 * 10) + (preQ[8] & 0x0F));
|
||||
rframe = (byte)((preQ[9] / 16 * 10) + (preQ[9] & 0x0F));
|
||||
rPos = (rmin * 60 * 75) + (rsec * 75) + rframe - 150;
|
||||
rmin = (byte)(preQ[7] / 16 * 10 + (preQ[7] & 0x0F));
|
||||
rsec = (byte)(preQ[8] / 16 * 10 + (preQ[8] & 0x0F));
|
||||
rframe = (byte)(preQ[9] / 16 * 10 + (preQ[9] & 0x0F));
|
||||
rPos = rmin * 60 * 75 + rsec * 75 + rframe - 150;
|
||||
|
||||
dPos = aPos - rPos;
|
||||
|
||||
bool absOk = dPos == 1;
|
||||
|
||||
rmin = (byte)((preQ[3] / 16 * 10) + (preQ[3] & 0x0F));
|
||||
rsec = (byte)((preQ[4] / 16 * 10) + (preQ[4] & 0x0F));
|
||||
rframe = (byte)((preQ[5] / 16 * 10) + (preQ[5] & 0x0F));
|
||||
rPos = (rmin * 60 * 75) + (rsec * 75) + rframe;
|
||||
rmin = (byte)(preQ[3] / 16 * 10 + (preQ[3] & 0x0F));
|
||||
rsec = (byte)(preQ[4] / 16 * 10 + (preQ[4] & 0x0F));
|
||||
rframe = (byte)(preQ[5] / 16 * 10 + (preQ[5] & 0x0F));
|
||||
rPos = rmin * 60 * 75 + rsec * 75 + rframe;
|
||||
|
||||
dPos = pPos - rPos;
|
||||
|
||||
@@ -1333,19 +1323,19 @@ public static class CompactDisc
|
||||
// Next Q's CRC is correct
|
||||
if(nextCrcOk)
|
||||
{
|
||||
rmin = (byte)((nextQ[7] / 16 * 10) + (nextQ[7] & 0x0F));
|
||||
rsec = (byte)((nextQ[8] / 16 * 10) + (nextQ[8] & 0x0F));
|
||||
rframe = (byte)((nextQ[9] / 16 * 10) + (nextQ[9] & 0x0F));
|
||||
rPos = (rmin * 60 * 75) + (rsec * 75) + rframe - 150;
|
||||
rmin = (byte)(nextQ[7] / 16 * 10 + (nextQ[7] & 0x0F));
|
||||
rsec = (byte)(nextQ[8] / 16 * 10 + (nextQ[8] & 0x0F));
|
||||
rframe = (byte)(nextQ[9] / 16 * 10 + (nextQ[9] & 0x0F));
|
||||
rPos = rmin * 60 * 75 + rsec * 75 + rframe - 150;
|
||||
|
||||
dPos = rPos - aPos;
|
||||
|
||||
bool absOk = dPos == 1;
|
||||
|
||||
rmin = (byte)((nextQ[3] / 16 * 10) + (nextQ[3] & 0x0F));
|
||||
rsec = (byte)((nextQ[4] / 16 * 10) + (nextQ[4] & 0x0F));
|
||||
rframe = (byte)((nextQ[5] / 16 * 10) + (nextQ[5] & 0x0F));
|
||||
rPos = (rmin * 60 * 75) + (rsec * 75) + rframe;
|
||||
rmin = (byte)(nextQ[3] / 16 * 10 + (nextQ[3] & 0x0F));
|
||||
rsec = (byte)(nextQ[4] / 16 * 10 + (nextQ[4] & 0x0F));
|
||||
rframe = (byte)(nextQ[5] / 16 * 10 + (nextQ[5] & 0x0F));
|
||||
rPos = rmin * 60 * 75 + rsec * 75 + rframe;
|
||||
|
||||
dPos = rPos - pPos;
|
||||
|
||||
@@ -1378,8 +1368,8 @@ public static class CompactDisc
|
||||
// Previous Q's CRC is correct
|
||||
if(preCrcOk)
|
||||
{
|
||||
rframe = (byte)((preQ[9] / 16 * 10) + (preQ[9] & 0x0F));
|
||||
aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F));
|
||||
rframe = (byte)(preQ[9] / 16 * 10 + (preQ[9] & 0x0F));
|
||||
aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
|
||||
if(aframe - rframe != 1)
|
||||
{
|
||||
@@ -1406,8 +1396,8 @@ public static class CompactDisc
|
||||
// Next Q's CRC is correct
|
||||
else if(nextCrcOk)
|
||||
{
|
||||
rframe = (byte)((nextQ[9] / 16 * 10) + (nextQ[9] & 0x0F));
|
||||
aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F));
|
||||
rframe = (byte)(nextQ[9] / 16 * 10 + (nextQ[9] & 0x0F));
|
||||
aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
|
||||
if(aframe - rframe != 1)
|
||||
{
|
||||
@@ -1433,13 +1423,13 @@ public static class CompactDisc
|
||||
// We know the MCN
|
||||
if(mcn != null)
|
||||
{
|
||||
q[1] = (byte)((((mcn[0] - 0x30) & 0x0F) * 16) + ((mcn[1] - 0x30) & 0x0F));
|
||||
q[2] = (byte)((((mcn[2] - 0x30) & 0x0F) * 16) + ((mcn[3] - 0x30) & 0x0F));
|
||||
q[3] = (byte)((((mcn[4] - 0x30) & 0x0F) * 16) + ((mcn[5] - 0x30) & 0x0F));
|
||||
q[4] = (byte)((((mcn[6] - 0x30) & 0x0F) * 16) + ((mcn[7] - 0x30) & 0x0F));
|
||||
q[5] = (byte)((((mcn[8] - 0x30) & 0x0F) * 16) + ((mcn[9] - 0x30) & 0x0F));
|
||||
q[6] = (byte)((((mcn[10] - 0x30) & 0x0F) * 16) + ((mcn[11] - 0x30) & 0x0F));
|
||||
q[7] = (byte)(((mcn[12] - 0x30) & 0x0F) * 8);
|
||||
q[1] = (byte)(((mcn[0] - 0x30) & 0x0F) * 16 + ((mcn[1] - 0x30) & 0x0F));
|
||||
q[2] = (byte)(((mcn[2] - 0x30) & 0x0F) * 16 + ((mcn[3] - 0x30) & 0x0F));
|
||||
q[3] = (byte)(((mcn[4] - 0x30) & 0x0F) * 16 + ((mcn[5] - 0x30) & 0x0F));
|
||||
q[4] = (byte)(((mcn[6] - 0x30) & 0x0F) * 16 + ((mcn[7] - 0x30) & 0x0F));
|
||||
q[5] = (byte)(((mcn[8] - 0x30) & 0x0F) * 16 + ((mcn[9] - 0x30) & 0x0F));
|
||||
q[6] = (byte)(((mcn[10] - 0x30) & 0x0F) * 16 + ((mcn[11] - 0x30) & 0x0F));
|
||||
q[7] = (byte)(((mcn[12] - 0x30) & 0x0F) * 8);
|
||||
q[8] = 0;
|
||||
|
||||
fixedMcn = true;
|
||||
@@ -1471,8 +1461,8 @@ public static class CompactDisc
|
||||
// Previous Q's CRC is correct
|
||||
if(preCrcOk)
|
||||
{
|
||||
rframe = (byte)((preQ[9] / 16 * 10) + (preQ[9] & 0x0F));
|
||||
aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F));
|
||||
rframe = (byte)(preQ[9] / 16 * 10 + (preQ[9] & 0x0F));
|
||||
aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
|
||||
if(aframe - rframe != 1)
|
||||
{
|
||||
@@ -1499,8 +1489,8 @@ public static class CompactDisc
|
||||
// Next Q's CRC is correct
|
||||
else if(nextCrcOk)
|
||||
{
|
||||
rframe = (byte)((nextQ[9] / 16 * 10) + (nextQ[9] & 0x0F));
|
||||
aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F));
|
||||
rframe = (byte)(nextQ[9] / 16 * 10 + (nextQ[9] & 0x0F));
|
||||
aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
|
||||
if(aframe - rframe != 1)
|
||||
{
|
||||
@@ -1536,10 +1526,10 @@ public static class CompactDisc
|
||||
q[2] = (byte)(((i2 & 0xF) << 4) + (i3 >> 2));
|
||||
q[3] = (byte)(((i3 & 0x3) << 6) + i4);
|
||||
q[4] = (byte)(i5 << 2);
|
||||
q[5] = (byte)((((isrc[5] - 0x30) & 0x0F) * 16) + ((isrc[6] - 0x30) & 0x0F));
|
||||
q[6] = (byte)((((isrc[7] - 0x30) & 0x0F) * 16) + ((isrc[8] - 0x30) & 0x0F));
|
||||
q[7] = (byte)((((isrc[9] - 0x30) & 0x0F) * 16) + ((isrc[10] - 0x30) & 0x0F));
|
||||
q[8] = (byte)(((isrc[11] - 0x30) & 0x0F) * 16);
|
||||
q[5] = (byte)(((isrc[5] - 0x30) & 0x0F) * 16 + ((isrc[6] - 0x30) & 0x0F));
|
||||
q[6] = (byte)(((isrc[7] - 0x30) & 0x0F) * 16 + ((isrc[8] - 0x30) & 0x0F));
|
||||
q[7] = (byte)(((isrc[9] - 0x30) & 0x0F) * 16 + ((isrc[10] - 0x30) & 0x0F));
|
||||
q[8] = (byte)(((isrc[11] - 0x30) & 0x0F) * 16);
|
||||
|
||||
fixedIsrc = true;
|
||||
|
||||
@@ -1627,8 +1617,7 @@ public static class CompactDisc
|
||||
updateProgress?.Invoke($"Generating subchannel for sector {sector}...", sector, (long)blocks);
|
||||
dumpLog?.WriteLine($"Generating subchannel for sector {sector}.");
|
||||
|
||||
byte[] sub = Subchannel.Generate(sector, track?.Sequence ?? 0, (int)pregap, (int)trackStart, flags,
|
||||
index);
|
||||
byte[] sub = Subchannel.Generate(sector, track?.Sequence ?? 0, (int)pregap, (int)trackStart, flags, index);
|
||||
|
||||
outputPlugin.WriteSectorsTag(sub, (ulong)sector, 1, SectorTagType.CdSectorSubchannel);
|
||||
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Media.Detection;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -47,10 +53,6 @@ using Aaru.Devices;
|
||||
using Aaru.Helpers;
|
||||
using DMI = Aaru.Decoders.Xbox.DMI;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
namespace Aaru.Core.Media.Detection;
|
||||
|
||||
/// <summary>Detects media type for MMC class devices</summary>
|
||||
public static class MMC
|
||||
{
|
||||
@@ -154,7 +156,7 @@ public static class MMC
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00
|
||||
};
|
||||
|
||||
byte[] testMark = new byte[12];
|
||||
var testMark = new byte[12];
|
||||
Array.Copy(sector, 0, testMark, 0, 12);
|
||||
|
||||
return syncMark.SequenceEqual(testMark) && (sector[0xF] == 0 || sector[0xF] == 1 || sector[0xF] == 2);
|
||||
@@ -172,14 +174,14 @@ public static class MMC
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00
|
||||
};
|
||||
|
||||
byte[] testMark = new byte[12];
|
||||
var testMark = new byte[12];
|
||||
|
||||
for(int i = 0; i <= 2336; i++)
|
||||
for(var i = 0; i <= 2336; i++)
|
||||
{
|
||||
Array.Copy(sector, i, testMark, 0, 12);
|
||||
|
||||
if(!syncMark.SequenceEqual(testMark) ||
|
||||
(sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62))
|
||||
sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62)
|
||||
continue;
|
||||
|
||||
// De-scramble M and S
|
||||
@@ -188,17 +190,17 @@ public static class MMC
|
||||
int frame = sector[i + 14];
|
||||
|
||||
// Convert to binary
|
||||
minute = (minute / 16 * 10) + (minute & 0x0F);
|
||||
second = (second / 16 * 10) + (second & 0x0F);
|
||||
frame = (frame / 16 * 10) + (frame & 0x0F);
|
||||
minute = minute / 16 * 10 + (minute & 0x0F);
|
||||
second = second / 16 * 10 + (second & 0x0F);
|
||||
frame = frame / 16 * 10 + (frame & 0x0F);
|
||||
|
||||
// Calculate the first found LBA
|
||||
int lba = (minute * 60 * 75) + (second * 75) + frame - 150;
|
||||
int lba = minute * 60 * 75 + second * 75 + frame - 150;
|
||||
|
||||
// Calculate the difference between the found LBA and the requested one
|
||||
int diff = wantedLba - lba;
|
||||
|
||||
offset = i + (2352 * diff);
|
||||
offset = i + 2352 * diff;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -208,9 +210,9 @@ public static class MMC
|
||||
|
||||
static byte[] DescrambleAndFixOffset(byte[] sector, int offsetBytes, int sectorsForOffset)
|
||||
{
|
||||
byte[] descrambled = new byte[2352];
|
||||
var descrambled = new byte[2352];
|
||||
|
||||
int offsetFix = offsetBytes < 0 ? (2352 * sectorsForOffset) + offsetBytes : offsetBytes;
|
||||
int offsetFix = offsetBytes < 0 ? 2352 * sectorsForOffset + offsetBytes : offsetBytes;
|
||||
|
||||
Array.Copy(sector, offsetFix, descrambled, 0, 2352);
|
||||
|
||||
@@ -234,10 +236,10 @@ public static class MMC
|
||||
bool isData = IsData(sector0);
|
||||
|
||||
if(!isData ||
|
||||
(sector0[0xF] != 2 && sector0[0xF] != 1))
|
||||
sector0[0xF] != 2 && sector0[0xF] != 1)
|
||||
return false;
|
||||
|
||||
byte[] testMark = new byte[4];
|
||||
var testMark = new byte[4];
|
||||
Array.Copy(sector16, 24, testMark, 0, 4);
|
||||
|
||||
return cdiMark.SequenceEqual(testMark);
|
||||
@@ -249,13 +251,13 @@ public static class MMC
|
||||
videoFrame.Length < _videoNowColorFrameMarker.Length)
|
||||
return false;
|
||||
|
||||
byte[] buffer = new byte[_videoNowColorFrameMarker.Length];
|
||||
var buffer = new byte[_videoNowColorFrameMarker.Length];
|
||||
|
||||
for(int framePosition = 0; framePosition + buffer.Length < videoFrame.Length; framePosition++)
|
||||
for(var framePosition = 0; framePosition + buffer.Length < videoFrame.Length; framePosition++)
|
||||
{
|
||||
Array.Copy(videoFrame, framePosition, buffer, 0, buffer.Length);
|
||||
|
||||
for(int ab = 9; ab < buffer.Length; ab += 10)
|
||||
for(var ab = 9; ab < buffer.Length; ab += 10)
|
||||
buffer[ab] = 0;
|
||||
|
||||
if(!_videoNowColorFrameMarker.SequenceEqual(buffer))
|
||||
@@ -269,13 +271,13 @@ public static class MMC
|
||||
|
||||
internal static int GetVideoNowColorOffset(byte[] data)
|
||||
{
|
||||
byte[] buffer = new byte[_videoNowColorFrameMarker.Length];
|
||||
var buffer = new byte[_videoNowColorFrameMarker.Length];
|
||||
|
||||
for(int framePosition = 0; framePosition + buffer.Length < data.Length; framePosition++)
|
||||
for(var framePosition = 0; framePosition + buffer.Length < data.Length; framePosition++)
|
||||
{
|
||||
Array.Copy(data, framePosition, buffer, 0, buffer.Length);
|
||||
|
||||
for(int ab = 9; ab < buffer.Length; ab += 10)
|
||||
for(var ab = 9; ab < buffer.Length; ab += 10)
|
||||
buffer[ab] = 0;
|
||||
|
||||
if(!_videoNowColorFrameMarker.SequenceEqual(buffer))
|
||||
@@ -462,10 +464,10 @@ public static class MMC
|
||||
if(mediaType == MediaType.CD ||
|
||||
mediaType == MediaType.CDROMXA)
|
||||
{
|
||||
bool hasDataTrack = false;
|
||||
bool hasAudioTrack = false;
|
||||
bool allFirstSessionTracksAreAudio = true;
|
||||
bool hasVideoTrack = false;
|
||||
var hasDataTrack = false;
|
||||
var hasAudioTrack = false;
|
||||
var allFirstSessionTracksAreAudio = true;
|
||||
var hasVideoTrack = false;
|
||||
|
||||
if(decodedToc.HasValue)
|
||||
{
|
||||
@@ -498,8 +500,8 @@ public static class MMC
|
||||
if((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack ||
|
||||
(TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrackIncremental)
|
||||
{
|
||||
uint startAddress = (uint)((track.PHOUR * 3600 * 75) + (track.PMIN * 60 * 75) +
|
||||
(track.PSEC * 75) + track.PFRAME - 150);
|
||||
var startAddress = (uint)(track.PHOUR * 3600 * 75 + track.PMIN * 60 * 75 + track.PSEC * 75 +
|
||||
track.PFRAME - 150);
|
||||
|
||||
if(startAddress < startOfFirstDataTrack)
|
||||
startOfFirstDataTrack = startAddress;
|
||||
@@ -508,9 +510,7 @@ public static class MMC
|
||||
allFirstSessionTracksAreAudio &= track.POINT >= firstTrackLastSession;
|
||||
}
|
||||
else
|
||||
{
|
||||
hasAudioTrack = true;
|
||||
}
|
||||
|
||||
hasVideoTrack |= track.ADR == 4;
|
||||
}
|
||||
@@ -561,20 +561,18 @@ public static class MMC
|
||||
}
|
||||
|
||||
if((mediaType == MediaType.CD || mediaType == MediaType.CDROM) && hasDataTrack)
|
||||
{
|
||||
foreach(uint startAddress in decodedToc.Value.TrackDescriptors.
|
||||
Where(t => t.POINT > 0 && t.POINT <= 0x99 &&
|
||||
((TocControl)(t.CONTROL & 0x0D) ==
|
||||
TocControl.DataTrack ||
|
||||
(TocControl)(t.CONTROL & 0x0D) ==
|
||||
TocControl.DataTrackIncremental)).
|
||||
Select(track => (uint)((track.PHOUR * 3600 * 75) +
|
||||
(track.PMIN * 60 * 75) +
|
||||
(track.PSEC * 75) +
|
||||
Select(track => (uint)(track.PHOUR * 3600 * 75 +
|
||||
track.PMIN * 60 * 75 + track.PSEC * 75 +
|
||||
track.PFRAME - 150) + 16))
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, startAddress, 2352, 1, MmcSectorTypes.AllTypes, false,
|
||||
false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
sense = dev.ReadCd(out cmdBuf, out _, startAddress, 2352, 1, MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(sense || dev.Error)
|
||||
@@ -602,7 +600,6 @@ public static class MMC
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(secondSessionFirstTrack != 0 &&
|
||||
@@ -611,25 +608,23 @@ public static class MMC
|
||||
FullTOC.TrackDataDescriptor secondSessionFirstTrackTrack =
|
||||
decodedToc.Value.TrackDescriptors.First(t => t.POINT == secondSessionFirstTrack);
|
||||
|
||||
uint firstSectorSecondSessionFirstTrack =
|
||||
(uint)((secondSessionFirstTrackTrack.PHOUR * 3600 * 75) +
|
||||
(secondSessionFirstTrackTrack.PMIN * 60 * 75) + (secondSessionFirstTrackTrack.PSEC * 75) +
|
||||
secondSessionFirstTrackTrack.PFRAME - 150);
|
||||
var firstSectorSecondSessionFirstTrack = (uint)(secondSessionFirstTrackTrack.PHOUR * 3600 * 75 +
|
||||
secondSessionFirstTrackTrack.PMIN * 60 * 75 +
|
||||
secondSessionFirstTrackTrack.PSEC * 75 +
|
||||
secondSessionFirstTrackTrack.PFRAME - 150);
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack, 2352, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack, 2352, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
{
|
||||
firstTrackSecondSession = cmdBuf;
|
||||
}
|
||||
else
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack, 2352, 1,
|
||||
MmcSectorTypes.Cdda, false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack, 2352, 1, MmcSectorTypes.Cdda,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -642,9 +637,7 @@ public static class MMC
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
{
|
||||
firstTrackSecondSessionAudio = cmdBuf;
|
||||
}
|
||||
else
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack - 1, 2352, 3,
|
||||
@@ -659,7 +652,7 @@ public static class MMC
|
||||
|
||||
videoNowColorFrame = new byte[9 * 2352];
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
for(var i = 0; i < 9; i++)
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, (uint)i, 2352, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
|
||||
@@ -686,9 +679,8 @@ public static class MMC
|
||||
|
||||
if(firstTrack?.POINT == 1)
|
||||
{
|
||||
uint firstTrackSector = (uint)((firstTrack.Value.PHOUR * 3600 * 75) +
|
||||
(firstTrack.Value.PMIN * 60 * 75) + (firstTrack.Value.PSEC * 75) +
|
||||
firstTrack.Value.PFRAME - 150);
|
||||
var firstTrackSector = (uint)(firstTrack.Value.PHOUR * 3600 * 75 + firstTrack.Value.PMIN * 60 * 75 +
|
||||
firstTrack.Value.PSEC * 75 + firstTrack.Value.PFRAME - 150);
|
||||
|
||||
// Check for hidden data before start of track 1
|
||||
if(firstTrackSector > 0)
|
||||
@@ -735,8 +727,8 @@ public static class MMC
|
||||
if(combinedOffset % 2352 != 0)
|
||||
sectorsForOffset++;
|
||||
|
||||
int lba0 = 0;
|
||||
int lba16 = 16;
|
||||
var lba0 = 0;
|
||||
var lba16 = 16;
|
||||
|
||||
if(combinedOffset < 0)
|
||||
{
|
||||
@@ -745,15 +737,14 @@ public static class MMC
|
||||
}
|
||||
|
||||
sense = dev.ReadCd(out sector0, out _, (uint)lba0, 2352, (uint)sectorsForOffset + 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
// Drive does not support reading negative sectors?
|
||||
if(sense && lba0 < 0)
|
||||
{
|
||||
dev.ReadCd(out sector0, out _, 0, 2352, 2, MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
dev.ReadCd(out sector0, out _, 0, 2352, 2, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
sector0 = DescrambleAndFixOffset(sector0, combinedOffset, sectorsForOffset);
|
||||
@@ -803,8 +794,8 @@ public static class MMC
|
||||
Array.Copy(cmdBuf, 16, sector0, 0, 2048);
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 1, 2352, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -813,9 +804,9 @@ public static class MMC
|
||||
Array.Copy(cmdBuf, 16, sector1, 0, 2048);
|
||||
}
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 4200, 2352, 1, MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 4200, 2352, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -824,9 +815,9 @@ public static class MMC
|
||||
Array.Copy(cmdBuf, 24, playdia1, 0, 2048);
|
||||
}
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 4201, 2352, 1, MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 4201, 2352, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -837,9 +828,9 @@ public static class MMC
|
||||
|
||||
if(startOfFirstDataTrack != uint.MaxValue)
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2352, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2352, 1, MmcSectorTypes.AllTypes,
|
||||
false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -849,8 +840,8 @@ public static class MMC
|
||||
}
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack + 1, 2352, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
|
||||
true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -864,8 +855,8 @@ public static class MMC
|
||||
|
||||
for(uint p = 0; p < 12; p++)
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, p, 2352, 1, MmcSectorTypes.AllTypes, false, false,
|
||||
true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
sense = dev.ReadCd(out cmdBuf, out _, p, 2352, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(sense || dev.Error)
|
||||
@@ -900,9 +891,9 @@ public static class MMC
|
||||
Array.Copy(cmdBuf, 1, sector0, 0, 2048);
|
||||
}
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 4200, 2324, 1, MmcSectorTypes.Mode2, false, false,
|
||||
false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 4200, 2324, 1, MmcSectorTypes.Mode2, false, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -911,9 +902,9 @@ public static class MMC
|
||||
Array.Copy(cmdBuf, 0, playdia1, 0, 2048);
|
||||
}
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 4201, 2324, 1, MmcSectorTypes.Mode2, false, false,
|
||||
false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 4201, 2324, 1, MmcSectorTypes.Mode2, false, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -924,9 +915,9 @@ public static class MMC
|
||||
|
||||
if(startOfFirstDataTrack != uint.MaxValue)
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2324, 1,
|
||||
MmcSectorTypes.Mode2, false, false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2324, 1, MmcSectorTypes.Mode2,
|
||||
false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -951,9 +942,9 @@ public static class MMC
|
||||
|
||||
for(uint p = 0; p < 12; p++)
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, p, 2324, 1, MmcSectorTypes.Mode2, false, false,
|
||||
false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, p, 2324, 1, MmcSectorTypes.Mode2, false, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(sense || dev.Error)
|
||||
break;
|
||||
@@ -975,9 +966,9 @@ public static class MMC
|
||||
{
|
||||
sector0 = cmdBuf;
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 0, 2048, 1, MmcSectorTypes.Mode1, false, false,
|
||||
false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 0, 2048, 1, MmcSectorTypes.Mode1, false, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -994,18 +985,16 @@ public static class MMC
|
||||
if(startOfFirstDataTrack != uint.MaxValue)
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2048, 1,
|
||||
MmcSectorTypes.Mode1, false, false, false, MmcHeaderCodes.None,
|
||||
true, false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout,
|
||||
out _);
|
||||
MmcSectorTypes.Mode1, false, false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
firstDataSectorNotZero = cmdBuf;
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack + 1, 2048, 1,
|
||||
MmcSectorTypes.Mode1, false, false, false, MmcHeaderCodes.None,
|
||||
true, false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout,
|
||||
out _);
|
||||
MmcSectorTypes.Mode1, false, false, false, MmcHeaderCodes.None, true,
|
||||
false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -1013,9 +1002,7 @@ public static class MMC
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goto case MediaType.DVDROM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1039,8 +1026,7 @@ public static class MMC
|
||||
blurayDi = DI.Decode(cmdBuf);
|
||||
}
|
||||
|
||||
sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 1, false, dev.Timeout,
|
||||
out _);
|
||||
sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 1, false, dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -1054,8 +1040,8 @@ public static class MMC
|
||||
!dev.Error)
|
||||
sector1 = cmdBuf;
|
||||
|
||||
sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 12, false,
|
||||
dev.Timeout, out _);
|
||||
sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 12, false, dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error &&
|
||||
@@ -1089,8 +1075,8 @@ public static class MMC
|
||||
}
|
||||
else
|
||||
{
|
||||
sense = dev.Read10(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 1,
|
||||
dev.Timeout, out _);
|
||||
sense = dev.Read10(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 1, dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
@@ -1141,15 +1127,13 @@ public static class MMC
|
||||
if(mediaType == MediaType.DVDROM)
|
||||
{
|
||||
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout,
|
||||
out _);
|
||||
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
PFI.PhysicalFormatInformation? pfi = PFI.Decode(cmdBuf, mediaType);
|
||||
|
||||
if(pfi != null)
|
||||
{
|
||||
switch(pfi.Value.DiskCategory)
|
||||
{
|
||||
case DiskCategory.DVDPR:
|
||||
@@ -1197,8 +1181,7 @@ public static class MMC
|
||||
|
||||
break;
|
||||
case DiskCategory.Nintendo:
|
||||
mediaType = pfi.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD
|
||||
: MediaType.WOD;
|
||||
mediaType = pfi.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD;
|
||||
|
||||
break;
|
||||
case DiskCategory.UMD:
|
||||
@@ -1206,12 +1189,11 @@ public static class MMC
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DiscManufacturingInformation, 0,
|
||||
dev.Timeout, out _);
|
||||
MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
@@ -1255,8 +1237,8 @@ public static class MMC
|
||||
// Recordables will be checked for PhotoCD only
|
||||
case MediaType.CDR:
|
||||
// Check if ISO9660
|
||||
sense = dev.Read12(out byte[] isoSector, out _, 0, false, false, false, false, 16, 2048, 0, 1,
|
||||
false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out byte[] isoSector, out _, 0, false, false, false, false, 16, 2048, 0, 1, false,
|
||||
dev.Timeout, out _);
|
||||
|
||||
// Sector 16 reads, and contains "CD001" magic?
|
||||
if(sense ||
|
||||
@@ -1272,8 +1254,8 @@ public static class MMC
|
||||
|
||||
while(isoSectorPosition < 32)
|
||||
{
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, isoSectorPosition, 2048,
|
||||
0, 1, false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, isoSectorPosition, 2048, 0,
|
||||
1, false, dev.Timeout, out _);
|
||||
|
||||
// If sector cannot be read, break here
|
||||
if(sense)
|
||||
@@ -1304,8 +1286,8 @@ public static class MMC
|
||||
isoSector[5] != 0x31)
|
||||
return;
|
||||
|
||||
uint rootStart = BitConverter.ToUInt32(isoSector, 158);
|
||||
uint rootLength = BitConverter.ToUInt32(isoSector, 166);
|
||||
var rootStart = BitConverter.ToUInt32(isoSector, 158);
|
||||
var rootLength = BitConverter.ToUInt32(isoSector, 166);
|
||||
|
||||
if(rootStart == 0 ||
|
||||
rootLength == 0)
|
||||
@@ -1319,8 +1301,8 @@ public static class MMC
|
||||
|
||||
for(uint i = 0; i < rootLength; i++)
|
||||
{
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, rootStart + i, 2048,
|
||||
0, 1, false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, rootStart + i, 2048, 0,
|
||||
1, false, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
break;
|
||||
@@ -1338,7 +1320,7 @@ public static class MMC
|
||||
if(isoSector.Length < 2048)
|
||||
return;
|
||||
|
||||
int rootPos = 0;
|
||||
var rootPos = 0;
|
||||
uint pcdStart = 0;
|
||||
uint pcdLength = 0;
|
||||
|
||||
@@ -1346,8 +1328,8 @@ public static class MMC
|
||||
rootPos < isoSector.Length &&
|
||||
rootPos + isoSector[rootPos] <= isoSector.Length)
|
||||
{
|
||||
int nameLen = isoSector[rootPos + 32];
|
||||
byte[] tmpName = new byte[nameLen];
|
||||
int nameLen = isoSector[rootPos + 32];
|
||||
var tmpName = new byte[nameLen];
|
||||
Array.Copy(isoSector, rootPos + 33, tmpName, 0, nameLen);
|
||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||
|
||||
@@ -1372,8 +1354,8 @@ public static class MMC
|
||||
|
||||
for(uint i = 0; i < pcdLength; i++)
|
||||
{
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, pcdStart + i,
|
||||
2048, 0, 1, false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, pcdStart + i, 2048,
|
||||
0, 1, false, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
break;
|
||||
@@ -1391,7 +1373,7 @@ public static class MMC
|
||||
if(isoSector.Length < 2048)
|
||||
return;
|
||||
|
||||
for(int pi = 0; pi < pcdLength; pi++)
|
||||
for(var pi = 0; pi < pcdLength; pi++)
|
||||
{
|
||||
int pcdPos = pi * 2048;
|
||||
uint infoPos = 0;
|
||||
@@ -1400,8 +1382,8 @@ public static class MMC
|
||||
pcdPos < isoSector.Length &&
|
||||
pcdPos + isoSector[pcdPos] <= isoSector.Length)
|
||||
{
|
||||
int nameLen = isoSector[pcdPos + 32];
|
||||
byte[] tmpName = new byte[nameLen];
|
||||
int nameLen = isoSector[pcdPos + 32];
|
||||
var tmpName = new byte[nameLen];
|
||||
Array.Copy(isoSector, pcdPos + 33, tmpName, 0, nameLen);
|
||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||
|
||||
@@ -1420,13 +1402,13 @@ public static class MMC
|
||||
|
||||
if(infoPos > 0)
|
||||
{
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, infoPos, 2048,
|
||||
0, 1, false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, infoPos, 2048, 0, 1,
|
||||
false, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
break;
|
||||
|
||||
byte[] systemId = new byte[8];
|
||||
var systemId = new byte[8];
|
||||
Array.Copy(isoSector, 0, systemId, 0, 8);
|
||||
|
||||
string id = StringHandlers.CToString(systemId).TrimEnd();
|
||||
@@ -1521,7 +1503,7 @@ public static class MMC
|
||||
// The decryption key is applied as XOR. As first byte is originally always NULL, it gives us the key :)
|
||||
byte decryptByte = ps2BootSectors[0];
|
||||
|
||||
for(int i = 0; i < 0x6000; i++)
|
||||
for(var i = 0; i < 0x6000; i++)
|
||||
ps2BootSectors[i] ^= decryptByte;
|
||||
|
||||
string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _);
|
||||
@@ -1544,7 +1526,7 @@ public static class MMC
|
||||
|
||||
if(sector0 != null)
|
||||
{
|
||||
byte[] syncBytes = new byte[7];
|
||||
var syncBytes = new byte[7];
|
||||
Array.Copy(sector0, 0, syncBytes, 0, 7);
|
||||
|
||||
if(_operaId.SequenceEqual(syncBytes))
|
||||
@@ -1571,8 +1553,8 @@ public static class MMC
|
||||
if(playdia1 != null &&
|
||||
playdia2 != null)
|
||||
{
|
||||
byte[] pd1 = new byte[_playdiaCopyright.Length];
|
||||
byte[] pd2 = new byte[_playdiaCopyright.Length];
|
||||
var pd1 = new byte[_playdiaCopyright.Length];
|
||||
var pd2 = new byte[_playdiaCopyright.Length];
|
||||
|
||||
Array.Copy(playdia1, 38, pd1, 0, pd1.Length);
|
||||
Array.Copy(playdia2, 0, pd2, 0, pd1.Length);
|
||||
@@ -1591,7 +1573,7 @@ public static class MMC
|
||||
|
||||
if(secondDataSectorNotZero != null)
|
||||
{
|
||||
byte[] pce = new byte[_pcEngineSignature.Length];
|
||||
var pce = new byte[_pcEngineSignature.Length];
|
||||
Array.Copy(secondDataSectorNotZero, 32, pce, 0, pce.Length);
|
||||
|
||||
if(_pcEngineSignature.SequenceEqual(pce))
|
||||
@@ -1607,7 +1589,7 @@ public static class MMC
|
||||
|
||||
if(firstDataSectorNotZero != null)
|
||||
{
|
||||
byte[] pcfx = new byte[_pcFxSignature.Length];
|
||||
var pcfx = new byte[_pcFxSignature.Length];
|
||||
Array.Copy(firstDataSectorNotZero, 0, pcfx, 0, pcfx.Length);
|
||||
|
||||
if(_pcFxSignature.SequenceEqual(pcfx))
|
||||
@@ -1623,9 +1605,9 @@ public static class MMC
|
||||
|
||||
if(firstTrackSecondSessionAudio != null)
|
||||
{
|
||||
byte[] jaguar = new byte[_atariSignature.Length];
|
||||
var jaguar = new byte[_atariSignature.Length];
|
||||
|
||||
for(int i = 0; i + jaguar.Length <= firstTrackSecondSessionAudio.Length; i += 2)
|
||||
for(var i = 0; i + jaguar.Length <= firstTrackSecondSessionAudio.Length; i += 2)
|
||||
{
|
||||
Array.Copy(firstTrackSecondSessionAudio, i, jaguar, 0, jaguar.Length);
|
||||
|
||||
@@ -1643,7 +1625,7 @@ public static class MMC
|
||||
|
||||
if(firstTrackSecondSession?.Length >= 2336)
|
||||
{
|
||||
byte[] milcd = new byte[2048];
|
||||
var milcd = new byte[2048];
|
||||
Array.Copy(firstTrackSecondSession, 24, milcd, 0, 2048);
|
||||
|
||||
if(Dreamcast.DecodeIPBin(milcd).HasValue)
|
||||
@@ -1672,19 +1654,19 @@ public static class MMC
|
||||
// Check CD+G, CD+EG and CD+MIDI
|
||||
if(mediaType == MediaType.CDDA)
|
||||
{
|
||||
sense = dev.ReadCd(out byte[] subBuf, out _, 150, 96, 8, MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, false, false, MmcErrorField.None,
|
||||
MmcSubchannel.Raw, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out byte[] subBuf, out _, 150, 96, 8, MmcSectorTypes.Cdda, false, false, false,
|
||||
MmcHeaderCodes.None, false, false, MmcErrorField.None, MmcSubchannel.Raw,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
bool cdg = false;
|
||||
bool cdeg = false;
|
||||
bool cdmidi = false;
|
||||
var cdg = false;
|
||||
var cdeg = false;
|
||||
var cdmidi = false;
|
||||
|
||||
for(int i = 0; i < 8; i++)
|
||||
for(var i = 0; i < 8; i++)
|
||||
{
|
||||
byte[] tmpSub = new byte[96];
|
||||
var tmpSub = new byte[96];
|
||||
Array.Copy(subBuf, i * 96, tmpSub, 0, 96);
|
||||
DetectRwPackets(tmpSub, out bool cdgPacket, out bool cdegPacket, out bool cdmidiPacket);
|
||||
|
||||
@@ -1731,11 +1713,11 @@ public static class MMC
|
||||
}
|
||||
|
||||
// If it has a PS2 boot area it can still be PS1, so check for SYSTEM.CNF below
|
||||
hasPs2CdBoot:
|
||||
hasPs2CdBoot:
|
||||
|
||||
// Check if ISO9660
|
||||
sense = dev.Read12(out byte[] isoSector, out _, 0, false, false, false, false, 16, 2048, 0, 1,
|
||||
false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out byte[] isoSector, out _, 0, false, false, false, false, 16, 2048, 0, 1, false,
|
||||
dev.Timeout, out _);
|
||||
|
||||
// Sector 16 reads, and contains "CD001" magic?
|
||||
if(sense ||
|
||||
@@ -1751,8 +1733,8 @@ public static class MMC
|
||||
|
||||
while(isoSectorPosition < 32)
|
||||
{
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, isoSectorPosition, 2048,
|
||||
0, 1, false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, isoSectorPosition, 2048, 0,
|
||||
1, false, dev.Timeout, out _);
|
||||
|
||||
// If sector cannot be read, break here
|
||||
if(sense)
|
||||
@@ -1783,8 +1765,8 @@ public static class MMC
|
||||
isoSector[5] != 0x31)
|
||||
return;
|
||||
|
||||
uint rootStart = BitConverter.ToUInt32(isoSector, 158);
|
||||
uint rootLength = BitConverter.ToUInt32(isoSector, 166);
|
||||
var rootStart = BitConverter.ToUInt32(isoSector, 158);
|
||||
var rootLength = BitConverter.ToUInt32(isoSector, 166);
|
||||
|
||||
if(rootStart == 0 ||
|
||||
rootLength == 0)
|
||||
@@ -1798,8 +1780,8 @@ public static class MMC
|
||||
|
||||
for(uint i = 0; i < rootLength; i++)
|
||||
{
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, rootStart + i, 2048,
|
||||
0, 1, false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, rootStart + i, 2048, 0,
|
||||
1, false, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
break;
|
||||
@@ -1817,17 +1799,17 @@ public static class MMC
|
||||
if(isoSector.Length < 2048)
|
||||
return;
|
||||
|
||||
List<string> rootEntries = new List<string>();
|
||||
uint ngcdIplStart = 0;
|
||||
uint ngcdIplLength = 0;
|
||||
uint vcdStart = 0;
|
||||
uint vcdLength = 0;
|
||||
uint pcdStart = 0;
|
||||
uint pcdLength = 0;
|
||||
uint ps1Start = 0;
|
||||
uint ps1Length = 0;
|
||||
var rootEntries = new List<string>();
|
||||
uint ngcdIplStart = 0;
|
||||
uint ngcdIplLength = 0;
|
||||
uint vcdStart = 0;
|
||||
uint vcdLength = 0;
|
||||
uint pcdStart = 0;
|
||||
uint pcdLength = 0;
|
||||
uint ps1Start = 0;
|
||||
uint ps1Length = 0;
|
||||
|
||||
for(int ri = 0; ri < rootLength; ri++)
|
||||
for(var ri = 0; ri < rootLength; ri++)
|
||||
{
|
||||
int rootPos = ri * 2048;
|
||||
|
||||
@@ -1835,8 +1817,8 @@ public static class MMC
|
||||
isoSector[rootPos] > 0 &&
|
||||
rootPos + isoSector[rootPos] <= isoSector.Length)
|
||||
{
|
||||
int nameLen = isoSector[rootPos + 32];
|
||||
byte[] tmpName = new byte[nameLen];
|
||||
int nameLen = isoSector[rootPos + 32];
|
||||
var tmpName = new byte[nameLen];
|
||||
Array.Copy(isoSector, rootPos + 33, tmpName, 0, nameLen);
|
||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||
|
||||
@@ -1916,8 +1898,8 @@ public static class MMC
|
||||
|
||||
for(uint i = 0; i < ngcdSectors; i++)
|
||||
{
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false,
|
||||
ngcdIplStart + i, 2048, 0, 1, false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, ngcdIplStart + i,
|
||||
2048, 0, 1, false, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
break;
|
||||
@@ -1938,8 +1920,8 @@ public static class MMC
|
||||
{
|
||||
using var sr = new StringReader(iplTxt);
|
||||
|
||||
bool correctNeoGeoCd = true;
|
||||
int lineNumber = 0;
|
||||
var correctNeoGeoCd = true;
|
||||
var lineNumber = 0;
|
||||
|
||||
while(sr.Peek() > 0)
|
||||
{
|
||||
@@ -2052,8 +2034,8 @@ public static class MMC
|
||||
|
||||
for(uint i = 0; i < vcdLength; i++)
|
||||
{
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, vcdStart + i,
|
||||
2048, 0, 1, false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, vcdStart + i, 2048,
|
||||
0, 1, false, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
break;
|
||||
@@ -2073,7 +2055,7 @@ public static class MMC
|
||||
|
||||
uint infoPos = 0;
|
||||
|
||||
for(int vi = 0; vi < vcdLength; vi++)
|
||||
for(var vi = 0; vi < vcdLength; vi++)
|
||||
{
|
||||
int vcdPos = vi * 2048;
|
||||
|
||||
@@ -2081,8 +2063,8 @@ public static class MMC
|
||||
isoSector[vcdPos] > 0 &&
|
||||
vcdPos + isoSector[vcdPos] <= isoSector.Length)
|
||||
{
|
||||
int nameLen = isoSector[vcdPos + 32];
|
||||
byte[] tmpName = new byte[nameLen];
|
||||
int nameLen = isoSector[vcdPos + 32];
|
||||
var tmpName = new byte[nameLen];
|
||||
Array.Copy(isoSector, vcdPos + 33, tmpName, 0, nameLen);
|
||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||
|
||||
@@ -2109,7 +2091,7 @@ public static class MMC
|
||||
if(sense)
|
||||
break;
|
||||
|
||||
byte[] systemId = new byte[8];
|
||||
var systemId = new byte[8];
|
||||
Array.Copy(isoSector, 0, systemId, 0, 8);
|
||||
|
||||
string id = StringHandlers.CToString(systemId).TrimEnd();
|
||||
@@ -2149,8 +2131,8 @@ public static class MMC
|
||||
|
||||
for(uint i = 0; i < pcdLength; i++)
|
||||
{
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, pcdStart + i,
|
||||
2048, 0, 1, false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, pcdStart + i, 2048,
|
||||
0, 1, false, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
break;
|
||||
@@ -2170,7 +2152,7 @@ public static class MMC
|
||||
|
||||
uint infoPos = 0;
|
||||
|
||||
for(int pi = 0; pi < pcdLength; pi++)
|
||||
for(var pi = 0; pi < pcdLength; pi++)
|
||||
{
|
||||
int pcdPos = pi * 2048;
|
||||
|
||||
@@ -2178,8 +2160,8 @@ public static class MMC
|
||||
isoSector[pcdPos] > 0 &&
|
||||
pcdPos + isoSector[pcdPos] <= isoSector.Length)
|
||||
{
|
||||
int nameLen = isoSector[pcdPos + 32];
|
||||
byte[] tmpName = new byte[nameLen];
|
||||
int nameLen = isoSector[pcdPos + 32];
|
||||
var tmpName = new byte[nameLen];
|
||||
Array.Copy(isoSector, pcdPos + 33, tmpName, 0, nameLen);
|
||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||
|
||||
@@ -2205,7 +2187,7 @@ public static class MMC
|
||||
if(sense)
|
||||
break;
|
||||
|
||||
byte[] systemId = new byte[8];
|
||||
var systemId = new byte[8];
|
||||
Array.Copy(isoSector, 0, systemId, 0, 8);
|
||||
|
||||
string id = StringHandlers.CToString(systemId).TrimEnd();
|
||||
@@ -2240,8 +2222,8 @@ public static class MMC
|
||||
|
||||
for(uint i = 0; i < ps1Sectors; i++)
|
||||
{
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, ps1Start + i,
|
||||
2048, 0, 1, false, dev.Timeout, out _);
|
||||
sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, ps1Start + i, 2048,
|
||||
0, 1, false, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
break;
|
||||
@@ -2339,7 +2321,7 @@ public static class MMC
|
||||
// The decryption key is applied as XOR. As first byte is originally always NULL, it gives us the key :)
|
||||
byte decryptByte = ps2BootSectors[0];
|
||||
|
||||
for(int i = 0; i < 0x6000; i++)
|
||||
for(var i = 0; i < 0x6000; i++)
|
||||
ps2BootSectors[i] ^= decryptByte;
|
||||
|
||||
string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _);
|
||||
@@ -2360,7 +2342,7 @@ public static class MMC
|
||||
|
||||
if(sector1 != null)
|
||||
{
|
||||
byte[] tmp = new byte[_ps3Id.Length];
|
||||
var tmp = new byte[_ps3Id.Length];
|
||||
Array.Copy(sector1, 0, tmp, 0, tmp.Length);
|
||||
|
||||
if(tmp.SequenceEqual(_ps3Id))
|
||||
@@ -2415,7 +2397,7 @@ public static class MMC
|
||||
case "BDU":
|
||||
if(sector1 != null)
|
||||
{
|
||||
byte[] tmp = new byte[_ps5Id.Length];
|
||||
var tmp = new byte[_ps5Id.Length];
|
||||
Array.Copy(sector1, 1024, tmp, 0, tmp.Length);
|
||||
|
||||
if(tmp.SequenceEqual(_ps5Id))
|
||||
@@ -2448,23 +2430,23 @@ public static class MMC
|
||||
cdegPacket = false;
|
||||
cdmidiPacket = false;
|
||||
|
||||
byte[] cdSubRwPack1 = new byte[24];
|
||||
byte[] cdSubRwPack2 = new byte[24];
|
||||
byte[] cdSubRwPack3 = new byte[24];
|
||||
byte[] cdSubRwPack4 = new byte[24];
|
||||
var cdSubRwPack1 = new byte[24];
|
||||
var cdSubRwPack2 = new byte[24];
|
||||
var cdSubRwPack3 = new byte[24];
|
||||
var cdSubRwPack4 = new byte[24];
|
||||
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
for(int j = 0; j < 24; j++)
|
||||
for(var j = 0; j < 24; j++)
|
||||
cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F);
|
||||
|
||||
switch(cdSubRwPack1[0])
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core.Media.Info;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
@@ -43,8 +45,6 @@ using Aaru.Decoders.CD;
|
||||
using Aaru.Devices;
|
||||
using Device = Aaru.Database.Models.Device;
|
||||
|
||||
namespace Aaru.Core.Media.Info;
|
||||
|
||||
/// <summary>Core operations for retrieving information about CD based media</summary>
|
||||
public static class CompactDisc
|
||||
{
|
||||
@@ -63,9 +63,8 @@ public static class CompactDisc
|
||||
/// <returns><c>true</c> if offset could be found, <c>false</c> otherwise</returns>
|
||||
[SuppressMessage("ReSharper", "TooWideLocalVariableScope")]
|
||||
public static void GetOffset(CdOffset cdOffset, Device dbDev, bool debug, Aaru.Devices.Device dev,
|
||||
MediaType dskType, DumpLog dumpLog, Track[] tracks,
|
||||
UpdateStatusHandler updateStatus, out int? driveOffset, out int? combinedOffset,
|
||||
out bool supportsPlextorReadCdDa)
|
||||
MediaType dskType, DumpLog dumpLog, Track[] tracks, UpdateStatusHandler updateStatus,
|
||||
out int? driveOffset, out int? combinedOffset, out bool supportsPlextorReadCdDa)
|
||||
{
|
||||
byte[] cmdBuf;
|
||||
bool sense;
|
||||
@@ -78,7 +77,7 @@ public static class CompactDisc
|
||||
int diff;
|
||||
Track dataTrack = default;
|
||||
Track audioTrack = default;
|
||||
bool offsetFound = false;
|
||||
var offsetFound = false;
|
||||
const uint sectorSize = 2352;
|
||||
driveOffset = cdOffset?.Offset * 4;
|
||||
combinedOffset = null;
|
||||
@@ -101,22 +100,22 @@ public static class CompactDisc
|
||||
tmpBuf = new byte[sectorSync.Length];
|
||||
|
||||
// Ensure to be out of the pregap, or multi-session discs give funny values
|
||||
uint wantedLba = (uint)(dataTrack.StartSector + 151);
|
||||
var wantedLba = (uint)(dataTrack.StartSector + 151);
|
||||
|
||||
// Plextor READ CDDA
|
||||
if(dbDev?.ATAPI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true ||
|
||||
dbDev?.SCSI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true ||
|
||||
dev.Manufacturer.ToLowerInvariant() == "plextor")
|
||||
{
|
||||
sense = dev.PlextorReadCdDa(out cmdBuf, out _, wantedLba, sectorSize, 3,
|
||||
PlextorSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.PlextorReadCdDa(out cmdBuf, out _, wantedLba, sectorSize, 3, PlextorSubchannel.None,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(!sense &&
|
||||
!dev.Error)
|
||||
{
|
||||
supportsPlextorReadCdDa = true;
|
||||
|
||||
for(int i = 0; i < cmdBuf.Length - sectorSync.Length; i++)
|
||||
for(var i = 0; i < cmdBuf.Length - sectorSync.Length; i++)
|
||||
{
|
||||
Array.Copy(cmdBuf, i, tmpBuf, 0, sectorSync.Length);
|
||||
|
||||
@@ -129,17 +128,17 @@ public static class CompactDisc
|
||||
frame = cmdBuf[i + 14];
|
||||
|
||||
// Convert to binary
|
||||
minute = (minute / 16 * 10) + (minute & 0x0F);
|
||||
second = (second / 16 * 10) + (second & 0x0F);
|
||||
frame = (frame / 16 * 10) + (frame & 0x0F);
|
||||
minute = minute / 16 * 10 + (minute & 0x0F);
|
||||
second = second / 16 * 10 + (second & 0x0F);
|
||||
frame = frame / 16 * 10 + (frame & 0x0F);
|
||||
|
||||
// Calculate the first found LBA
|
||||
lba = (minute * 60 * 75) + (second * 75) + frame - 150;
|
||||
lba = minute * 60 * 75 + second * 75 + frame - 150;
|
||||
|
||||
// Calculate the difference between the found LBA and the requested one
|
||||
diff = (int)wantedLba - lba;
|
||||
|
||||
combinedOffset = i + (2352 * diff);
|
||||
combinedOffset = i + 2352 * diff;
|
||||
offsetFound = true;
|
||||
|
||||
break;
|
||||
@@ -148,10 +147,10 @@ public static class CompactDisc
|
||||
}
|
||||
|
||||
if(!offsetFound &&
|
||||
(debug || dbDev?.ATAPI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true ||
|
||||
dbDev?.SCSI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true ||
|
||||
dbDev?.SCSI?.MultiMediaDevice?.TestedMedia?.Any(d => d.CanReadCdScrambled == true) ==
|
||||
true || dev.Manufacturer.ToLowerInvariant() == "hl-dt-st"))
|
||||
(debug || dbDev?.ATAPI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true ||
|
||||
dbDev?.SCSI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true ||
|
||||
dbDev?.SCSI?.MultiMediaDevice?.TestedMedia?.Any(d => d.CanReadCdScrambled == true) == true ||
|
||||
dev.Manufacturer.ToLowerInvariant() == "hl-dt-st"))
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, wantedLba, sectorSize, 3, MmcSectorTypes.Cdda, false,
|
||||
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
@@ -161,22 +160,22 @@ public static class CompactDisc
|
||||
!dev.Error)
|
||||
{
|
||||
// Clear cache
|
||||
for(int i = 0; i < 63; i++)
|
||||
for(var i = 0; i < 63; i++)
|
||||
{
|
||||
sense = dev.ReadCd(out _, out _, (uint)(wantedLba + 3 + (16 * i)), sectorSize, 16,
|
||||
MmcSectorTypes.AllTypes, false, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out _, out _, (uint)(wantedLba + 3 + 16 * i), sectorSize, 16,
|
||||
MmcSectorTypes.AllTypes, false, false, false, MmcHeaderCodes.None,
|
||||
true, false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(sense || dev.Error)
|
||||
break;
|
||||
}
|
||||
|
||||
dev.ReadCd(out cmdBuf, out _, wantedLba, sectorSize, 3, MmcSectorTypes.Cdda, false,
|
||||
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
dev.ReadCd(out cmdBuf, out _, wantedLba, sectorSize, 3, MmcSectorTypes.Cdda, false, false,
|
||||
false, MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
|
||||
dev.Timeout, out _);
|
||||
|
||||
for(int i = 0; i < cmdBuf.Length - sectorSync.Length; i++)
|
||||
for(var i = 0; i < cmdBuf.Length - sectorSync.Length; i++)
|
||||
{
|
||||
Array.Copy(cmdBuf, i, tmpBuf, 0, sectorSync.Length);
|
||||
|
||||
@@ -189,17 +188,17 @@ public static class CompactDisc
|
||||
frame = cmdBuf[i + 14];
|
||||
|
||||
// Convert to binary
|
||||
minute = (minute / 16 * 10) + (minute & 0x0F);
|
||||
second = (second / 16 * 10) + (second & 0x0F);
|
||||
frame = (frame / 16 * 10) + (frame & 0x0F);
|
||||
minute = minute / 16 * 10 + (minute & 0x0F);
|
||||
second = second / 16 * 10 + (second & 0x0F);
|
||||
frame = frame / 16 * 10 + (frame & 0x0F);
|
||||
|
||||
// Calculate the first found LBA
|
||||
lba = (minute * 60 * 75) + (second * 75) + frame - 150;
|
||||
lba = minute * 60 * 75 + second * 75 + frame - 150;
|
||||
|
||||
// Calculate the difference between the found LBA and the requested one
|
||||
diff = (int)wantedLba - lba;
|
||||
|
||||
combinedOffset = i + (2352 * diff);
|
||||
combinedOffset = i + 2352 * diff;
|
||||
offsetFound = true;
|
||||
|
||||
break;
|
||||
@@ -214,7 +213,7 @@ public static class CompactDisc
|
||||
|
||||
// Try to get another the offset some other way, we need an audio track just after a data track, same session
|
||||
|
||||
for(int i = 1; i < tracks.Length; i++)
|
||||
for(var i = 1; i < tracks.Length; i++)
|
||||
{
|
||||
if(tracks[i - 1].Type == TrackType.Audio ||
|
||||
tracks[i].Type != TrackType.Audio)
|
||||
@@ -231,9 +230,9 @@ public static class CompactDisc
|
||||
return;
|
||||
|
||||
// Found them
|
||||
sense = dev.ReadCd(out cmdBuf, out _, (uint)audioTrack.StartSector, sectorSize, 3,
|
||||
MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, (uint)audioTrack.StartSector, sectorSize, 3, MmcSectorTypes.Cdda,
|
||||
false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(sense || dev.Error)
|
||||
return;
|
||||
@@ -241,16 +240,16 @@ public static class CompactDisc
|
||||
dataTrack.EndSector += 150;
|
||||
|
||||
// Calculate MSF
|
||||
minute = (int)dataTrack.EndSector / 4500;
|
||||
second = ((int)dataTrack.EndSector - (minute * 4500)) / 75;
|
||||
frame = (int)dataTrack.EndSector - (minute * 4500) - (second * 75);
|
||||
minute = (int)dataTrack.EndSector / 4500;
|
||||
second = ((int)dataTrack.EndSector - minute * 4500) / 75;
|
||||
frame = (int)dataTrack.EndSector - minute * 4500 - second * 75;
|
||||
|
||||
dataTrack.EndSector -= 150;
|
||||
|
||||
// Convert to BCD
|
||||
minute = ((minute / 10) << 4) + (minute % 10);
|
||||
second = ((second / 10) << 4) + (second % 10);
|
||||
frame = ((frame / 10) << 4) + (frame % 10);
|
||||
minute = ((minute / 10) << 4) + minute % 10;
|
||||
second = ((second / 10) << 4) + second % 10;
|
||||
frame = ((frame / 10) << 4) + frame % 10;
|
||||
|
||||
// Scramble M and S
|
||||
minute ^= 0x01;
|
||||
@@ -265,7 +264,7 @@ public static class CompactDisc
|
||||
|
||||
tmpBuf = new byte[sectorSync.Length];
|
||||
|
||||
for(int i = 0; i < cmdBuf.Length - sectorSync.Length; i++)
|
||||
for(var i = 0; i < cmdBuf.Length - sectorSync.Length; i++)
|
||||
{
|
||||
Array.Copy(cmdBuf, i, tmpBuf, 0, sectorSync.Length);
|
||||
|
||||
@@ -288,13 +287,13 @@ public static class CompactDisc
|
||||
if(sense || dev.Error)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < dataBuf.Length; i++)
|
||||
for(var i = 0; i < dataBuf.Length; i++)
|
||||
dataBuf[i] ^= Sector.ScrambleTable[i];
|
||||
|
||||
for(int i = 0; i < 2352; i++)
|
||||
for(var i = 0; i < 2352; i++)
|
||||
{
|
||||
byte[] dataSide = new byte[2352 - i];
|
||||
byte[] audioSide = new byte[2352 - i];
|
||||
var dataSide = new byte[2352 - i];
|
||||
var audioSide = new byte[2352 - i];
|
||||
|
||||
Array.Copy(dataBuf, i, dataSide, 0, dataSide.Length);
|
||||
Array.Copy(cmdBuf, 0, audioSide, 0, audioSide.Length);
|
||||
@@ -309,7 +308,7 @@ public static class CompactDisc
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] videoNowColorFrame = new byte[9 * sectorSize];
|
||||
var videoNowColorFrame = new byte[9 * sectorSize];
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 0, sectorSize, 9, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
|
||||
@@ -318,13 +317,11 @@ public static class CompactDisc
|
||||
if(sense || dev.Error)
|
||||
{
|
||||
sense = dev.ReadCd(out cmdBuf, out _, 0, sectorSize, 9, MmcSectorTypes.Cdda, false, false, true,
|
||||
MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None,
|
||||
dev.Timeout, out _);
|
||||
MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(sense || dev.Error)
|
||||
{
|
||||
videoNowColorFrame = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(videoNowColorFrame is null)
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
|
||||
namespace Aaru.Core.Media.Info;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -48,11 +52,8 @@ using Aaru.Decoders.Xbox;
|
||||
using Aaru.Devices;
|
||||
using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo;
|
||||
using DMI = Aaru.Decoders.Xbox.DMI;
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
||||
|
||||
namespace Aaru.Core.Media.Info;
|
||||
|
||||
/// <summary>Retrieves information from a SCSI device</summary>
|
||||
public sealed class ScsiInfo
|
||||
{
|
||||
@@ -66,17 +67,17 @@ public sealed class ScsiInfo
|
||||
|
||||
MediaType = MediaType.Unknown;
|
||||
MediaInserted = false;
|
||||
int resets = 0;
|
||||
var resets = 0;
|
||||
bool sense;
|
||||
byte[] cmdBuf;
|
||||
byte[] senseBuf;
|
||||
bool containsFloppyPage = false;
|
||||
int sessions = 1;
|
||||
int firstTrackLastSession = 1;
|
||||
var containsFloppyPage = false;
|
||||
var sessions = 1;
|
||||
var firstTrackLastSession = 1;
|
||||
|
||||
if(dev.IsRemovable)
|
||||
{
|
||||
deviceGotReset:
|
||||
deviceGotReset:
|
||||
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
@@ -96,7 +97,7 @@ public sealed class ScsiInfo
|
||||
|
||||
if(decSense?.ASC == 0x3A)
|
||||
{
|
||||
int leftRetries = 5;
|
||||
var leftRetries = 5;
|
||||
|
||||
while(leftRetries > 0)
|
||||
{
|
||||
@@ -120,7 +121,7 @@ public sealed class ScsiInfo
|
||||
else if(decSense?.ASC == 0x04 &&
|
||||
decSense?.ASCQ == 0x01)
|
||||
{
|
||||
int leftRetries = 10;
|
||||
var leftRetries = 10;
|
||||
|
||||
while(leftRetries > 0)
|
||||
{
|
||||
@@ -144,8 +145,7 @@ public sealed class ScsiInfo
|
||||
}
|
||||
else
|
||||
{
|
||||
AaruConsole.ErrorWriteLine("Error testing unit was ready:\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
AaruConsole.ErrorWriteLine("Error testing unit was ready:\n{0}", Sense.PrettifySense(senseBuf));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -194,8 +194,7 @@ public sealed class ScsiInfo
|
||||
{
|
||||
ReadCapacity = cmdBuf;
|
||||
|
||||
Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) &
|
||||
0xFFFFFFFF;
|
||||
Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) & 0xFFFFFFFF;
|
||||
|
||||
BlockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]);
|
||||
}
|
||||
@@ -219,7 +218,7 @@ public sealed class ScsiInfo
|
||||
|
||||
if(ReadCapacity16 != null)
|
||||
{
|
||||
byte[] temp = new byte[8];
|
||||
var temp = new byte[8];
|
||||
|
||||
Array.Copy(cmdBuf, 0, temp, 0, 8);
|
||||
Array.Reverse(temp);
|
||||
@@ -275,17 +274,15 @@ public sealed class ScsiInfo
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case PeripheralDeviceTypes.BridgingExpander
|
||||
when dev.Model.StartsWith("MDM", StringComparison.Ordinal) ||
|
||||
dev.Model.StartsWith("MDH", StringComparison.Ordinal):
|
||||
case PeripheralDeviceTypes.BridgingExpander when dev.Model.StartsWith("MDM", StringComparison.Ordinal) ||
|
||||
dev.Model.StartsWith("MDH", StringComparison.Ordinal):
|
||||
sense = dev.ReadCapacity(out cmdBuf, out senseBuf, dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
ReadCapacity = cmdBuf;
|
||||
|
||||
Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) &
|
||||
0xFFFFFFFF;
|
||||
Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) & 0xFFFFFFFF;
|
||||
|
||||
BlockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]);
|
||||
}
|
||||
@@ -475,8 +472,7 @@ public sealed class ScsiInfo
|
||||
MmcDiscStructureFormat.RecognizedFormatLayers, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Recognized Format Layers\n{0}",
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Recognized Format Layers\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
RecognizedFormatLayers = cmdBuf;
|
||||
@@ -485,8 +481,7 @@ public sealed class ScsiInfo
|
||||
MmcDiscStructureFormat.WriteProtectionStatus, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Write Protection Status\n{0}",
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Write Protection Status\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
WriteProtectionStatus = cmdBuf;
|
||||
@@ -523,10 +518,8 @@ public sealed class ScsiInfo
|
||||
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PFI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
DvdPfi = cmdBuf;
|
||||
@@ -553,8 +546,7 @@ public sealed class ScsiInfo
|
||||
|
||||
break;
|
||||
case DiskCategory.DVDR:
|
||||
MediaType = DecodedPfi.Value.PartVersion >= 6 ? MediaType.DVDRDL
|
||||
: MediaType.DVDR;
|
||||
MediaType = DecodedPfi.Value.PartVersion >= 6 ? MediaType.DVDRDL : MediaType.DVDR;
|
||||
|
||||
break;
|
||||
case DiskCategory.DVDRAM:
|
||||
@@ -603,18 +595,14 @@ public sealed class ScsiInfo
|
||||
out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DMI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
DvdDmi = cmdBuf;
|
||||
|
||||
if(DMI.IsXbox(cmdBuf))
|
||||
{
|
||||
MediaType = MediaType.XGD;
|
||||
}
|
||||
else if(DMI.IsXbox360(cmdBuf))
|
||||
{
|
||||
MediaType = MediaType.XGD2;
|
||||
@@ -827,8 +815,7 @@ public sealed class ScsiInfo
|
||||
case MediaType.DVDRWDL:
|
||||
case MediaType.HDDVDR:
|
||||
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout,
|
||||
out _);
|
||||
MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DVD-R Media ID\n{0}",
|
||||
@@ -902,8 +889,7 @@ public sealed class ScsiInfo
|
||||
MmcDiscStructureFormat.HddvdrMediumStatus, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: HD DVD-R Medium Status\n{0}",
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: HD DVD-R Medium Status\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
HddvdrMediumStatus = cmdBuf;
|
||||
@@ -944,8 +930,7 @@ public sealed class ScsiInfo
|
||||
MmcDiscStructureFormat.MiddleZoneStart, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Middle Zone Start\n{0}",
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Middle Zone Start\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdrDlMiddleZoneStart = cmdBuf;
|
||||
@@ -954,8 +939,7 @@ public sealed class ScsiInfo
|
||||
MmcDiscStructureFormat.JumpIntervalSize, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Jump Interval Size\n{0}",
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Jump Interval Size\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdrDlJumpIntervalSize = cmdBuf;
|
||||
@@ -975,8 +959,7 @@ public sealed class ScsiInfo
|
||||
MmcDiscStructureFormat.RemapAnchorPoint, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Remap Anchor Point\n{0}",
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Remap Anchor Point\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdrDlRemapAnchorPoint = cmdBuf;
|
||||
@@ -1048,15 +1031,13 @@ public sealed class ScsiInfo
|
||||
MmcDiscStructureFormat.CartridgeStatus, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Cartridge Status\n{0}",
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Cartridge Status\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
BlurayCartridgeStatus = cmdBuf;
|
||||
|
||||
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
|
||||
MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout,
|
||||
out _);
|
||||
MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
@@ -1083,8 +1064,8 @@ public sealed class ScsiInfo
|
||||
else
|
||||
BlurayTrackResources = cmdBuf;
|
||||
|
||||
sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf,
|
||||
MmcDiscInformationDataTypes.PowResources, dev.Timeout, out _);
|
||||
sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, MmcDiscInformationDataTypes.PowResources,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 010b\n{0}",
|
||||
@@ -1106,10 +1087,8 @@ public sealed class ScsiInfo
|
||||
bool tocSense = dev.ReadTocPmaAtip(out cmdBuf, out senseBuf, false, 0, 0, dev.Timeout, out _);
|
||||
|
||||
if(tocSense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: TOC\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
Toc = cmdBuf;
|
||||
@@ -1124,10 +1103,8 @@ public sealed class ScsiInfo
|
||||
sense = dev.ReadAtip(out cmdBuf, out senseBuf, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: ATIP\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
Atip = cmdBuf;
|
||||
@@ -1147,10 +1124,8 @@ public sealed class ScsiInfo
|
||||
sense = dev.ReadSessionInfo(out cmdBuf, out senseBuf, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: Session info\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else if(cmdBuf.Length > 4)
|
||||
{
|
||||
Session = cmdBuf;
|
||||
@@ -1166,10 +1141,8 @@ public sealed class ScsiInfo
|
||||
sense = dev.ReadRawToc(out cmdBuf, out senseBuf, 1, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: Raw TOC\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else if(cmdBuf.Length > 4)
|
||||
{
|
||||
RawToc = cmdBuf;
|
||||
@@ -1188,10 +1161,8 @@ public sealed class ScsiInfo
|
||||
sense = dev.ReadCdText(out cmdBuf, out senseBuf, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: CD-TEXT\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else if(cmdBuf.Length > 4)
|
||||
{
|
||||
CdTextLeadIn = cmdBuf;
|
||||
@@ -1233,10 +1204,8 @@ public sealed class ScsiInfo
|
||||
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PFI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
DvdPfi = cmdBuf;
|
||||
@@ -1278,10 +1247,8 @@ public sealed class ScsiInfo
|
||||
sense = dev.ReadMediaSerialNumber(out cmdBuf, out senseBuf, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ MEDIA SERIAL NUMBER\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cmdBuf.Length >= 4)
|
||||
@@ -1334,8 +1301,7 @@ public sealed class ScsiInfo
|
||||
}
|
||||
|
||||
ulong totalSize =
|
||||
(ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) &
|
||||
0xFFFFFFFF;
|
||||
(ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) & 0xFFFFFFFF;
|
||||
|
||||
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _);
|
||||
@@ -1415,15 +1381,14 @@ public sealed class ScsiInfo
|
||||
break;
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors",
|
||||
totalSize);
|
||||
AaruConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors", totalSize);
|
||||
|
||||
ulong middleZone =
|
||||
totalSize - (PFI.Decode(cmdBuf, MediaType).Value.Layer0EndPSN -
|
||||
PFI.Decode(cmdBuf, MediaType).Value.DataAreaStartPSN + 1) - gameSize + 1;
|
||||
|
||||
totalSize = l0Video + l1Video + (middleZone * 2) + gameSize;
|
||||
ulong layerBreak = l0Video + middleZone + (gameSize / 2);
|
||||
totalSize = l0Video + l1Video + middleZone * 2 + gameSize;
|
||||
ulong layerBreak = l0Video + middleZone + gameSize / 2;
|
||||
|
||||
XgdInfo = new XgdInfo
|
||||
{
|
||||
@@ -1458,17 +1423,15 @@ public sealed class ScsiInfo
|
||||
MediaType = MediaType.GENERIC_HDD;
|
||||
|
||||
if(DeviceInfo.ScsiType != PeripheralDeviceTypes.MultiMediaDevice ||
|
||||
(dev.IsUsb && (scsiMediumType == 0x40 || scsiMediumType == 0x41 || scsiMediumType == 0x42)))
|
||||
dev.IsUsb && (scsiMediumType == 0x40 || scsiMediumType == 0x41 || scsiMediumType == 0x42))
|
||||
return;
|
||||
|
||||
sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, MmcDiscInformationDataTypes.DiscInformation,
|
||||
dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 000b\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
DiscInformation = cmdBuf;
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Option parsing</summary>
|
||||
public static class Options
|
||||
{
|
||||
@@ -44,18 +44,18 @@ public static class Options
|
||||
/// <returns>Options name-value dictionary</returns>
|
||||
public static Dictionary<string, string> Parse(string options)
|
||||
{
|
||||
Dictionary<string, string> parsed = new Dictionary<string, string>();
|
||||
bool escaped = false;
|
||||
bool quoted = false;
|
||||
bool inValue = false;
|
||||
string name = null;
|
||||
string value;
|
||||
var sb = new StringBuilder();
|
||||
var parsed = new Dictionary<string, string>();
|
||||
var escaped = false;
|
||||
var quoted = false;
|
||||
var inValue = false;
|
||||
string name = null;
|
||||
string value;
|
||||
var sb = new StringBuilder();
|
||||
|
||||
if(options == null)
|
||||
return parsed;
|
||||
|
||||
for(int index = 0; index < options.Length; index++)
|
||||
for(var index = 0; index < options.Length; index++)
|
||||
{
|
||||
char c = options[index];
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes;
|
||||
@@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Implements methods for handling partitions</summary>
|
||||
public static class Partitions
|
||||
{
|
||||
@@ -47,10 +47,10 @@ public static class Partitions
|
||||
/// <returns>List of found partitions</returns>
|
||||
public static List<Partition> GetAll(IMediaImage image)
|
||||
{
|
||||
PluginBase plugins = GetPluginBase.Instance;
|
||||
List<Partition> foundPartitions = new List<Partition>();
|
||||
List<Partition> childPartitions = new List<Partition>();
|
||||
List<ulong> checkedLocations = new List<ulong>();
|
||||
PluginBase plugins = GetPluginBase.Instance;
|
||||
var foundPartitions = new List<Partition>();
|
||||
var childPartitions = new List<Partition>();
|
||||
var checkedLocations = new List<ulong>();
|
||||
|
||||
var tapeImage = image as ITapeImage;
|
||||
var partitionableImage = image as IPartitionableMediaImage;
|
||||
@@ -110,7 +110,7 @@ public static class Partitions
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Partition> children = new List<Partition>();
|
||||
var children = new List<Partition>();
|
||||
|
||||
foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values)
|
||||
{
|
||||
@@ -153,8 +153,7 @@ public static class Partitions
|
||||
// Be sure that device partitions are not excluded if not mapped by any scheme...
|
||||
if(!(tapeImage is null))
|
||||
{
|
||||
List<ulong> startLocations =
|
||||
childPartitions.Select(detectedPartition => detectedPartition.Start).ToList();
|
||||
var startLocations = childPartitions.Select(detectedPartition => detectedPartition.Start).ToList();
|
||||
|
||||
if(tapeImage.Files != null)
|
||||
childPartitions.AddRange(tapeImage.Files.Where(f => !startLocations.Contains(f.FirstBlock)).
|
||||
@@ -168,12 +167,12 @@ public static class Partitions
|
||||
|
||||
if(!(partitionableImage is null))
|
||||
{
|
||||
List<ulong> startLocations =
|
||||
childPartitions.Select(detectedPartition => detectedPartition.Start).ToList();
|
||||
var startLocations = childPartitions.Select(detectedPartition => detectedPartition.Start).ToList();
|
||||
|
||||
if(partitionableImage.Partitions != null)
|
||||
childPartitions.AddRange(partitionableImage.Partitions.Where(imagePartition =>
|
||||
!startLocations.Contains(imagePartition.Start)));
|
||||
!startLocations.
|
||||
Contains(imagePartition.Start)));
|
||||
}
|
||||
|
||||
Partition[] childArray = childPartitions.OrderBy(part => part.Start).ThenBy(part => part.Length).
|
||||
@@ -193,7 +192,7 @@ public static class Partitions
|
||||
partitions.Count == 0)
|
||||
return;
|
||||
|
||||
List<string> schemes = new List<string>();
|
||||
var schemes = new List<string>();
|
||||
|
||||
foreach(Partition part in partitions.Where(part => !schemes.Contains(part.Scheme)))
|
||||
schemes.Add(part.Scheme);
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Console;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Prints all SCSI MODE pages</summary>
|
||||
public static class PrintScsiModePages
|
||||
{
|
||||
@@ -64,8 +64,8 @@ public static class PrintScsiModePages
|
||||
else
|
||||
{
|
||||
if(page.Subpage != 0)
|
||||
AaruConsole.WriteLine("Found unknown vendor mode page {0:X2}h subpage {1:X2}h",
|
||||
page.Page, page.Subpage);
|
||||
AaruConsole.WriteLine("Found unknown vendor mode page {0:X2}h subpage {1:X2}h", page.Page,
|
||||
page.Subpage);
|
||||
else
|
||||
AaruConsole.WriteLine("Found unknown vendor mode page {0:X2}h", page.Page);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -43,14 +45,13 @@ using Aaru.Console;
|
||||
using Aaru.Database;
|
||||
using Aaru.Database.Models;
|
||||
using Aaru.Dto;
|
||||
using Aaru.Settings;
|
||||
using global::Spectre.Console;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Spectre.Console;
|
||||
using CdOffset = Aaru.Database.Models.CdOffset;
|
||||
using Version = Aaru.CommonTypes.Metadata.Version;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Handles connections to Aaru.Server</summary>
|
||||
public static class Remote
|
||||
{
|
||||
@@ -66,11 +67,10 @@ public static class Remote
|
||||
|
||||
try
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(report, Formatting.Indented,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
string json = JsonConvert.SerializeObject(report, Formatting.Indented, new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
|
||||
byte[] jsonBytes = Encoding.UTF8.GetBytes(json);
|
||||
var request = WebRequest.Create("https://www.aaru.app/api/uploadreportv2");
|
||||
@@ -116,7 +116,7 @@ public static class Remote
|
||||
/// <param name="create">If <c>true</c> creates the database from scratch, otherwise updates an existing database</param>
|
||||
public static void UpdateMainDatabase(bool create)
|
||||
{
|
||||
var mctx = AaruContext.Create(Settings.Settings.MainDbPath);
|
||||
var mctx = AaruContext.Create(Settings.MainDbPath);
|
||||
|
||||
if(create)
|
||||
{
|
||||
@@ -126,10 +126,8 @@ public static class Remote
|
||||
ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)");
|
||||
|
||||
foreach(string migration in mctx.Database.GetPendingMigrations())
|
||||
{
|
||||
mctx.Database.
|
||||
ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{migration}', '0.0.0')");
|
||||
}
|
||||
}
|
||||
else
|
||||
mctx.Database.Migrate();
|
||||
@@ -330,8 +328,7 @@ public static class Remote
|
||||
{
|
||||
task.Increment(1);
|
||||
|
||||
UsbVendor existing =
|
||||
mctx.UsbVendors.FirstOrDefault(v => v.Id == vendor.VendorId);
|
||||
UsbVendor existing = mctx.UsbVendors.FirstOrDefault(v => v.Id == vendor.VendorId);
|
||||
|
||||
if(existing != null)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -38,8 +40,6 @@ using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
public sealed partial class Sidecar
|
||||
{
|
||||
// TODO: Complete it
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -49,8 +51,6 @@ using Schemas;
|
||||
using MediaType = Aaru.CommonTypes.Metadata.MediaType;
|
||||
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
public sealed partial class Sidecar
|
||||
{
|
||||
/// <summary>Creates a metadata sidecar for a block media (e.g. floppy, hard disk, flash card, usb stick)</summary>
|
||||
@@ -189,8 +189,7 @@ public sealed partial class Sidecar
|
||||
sidecar.BlockMedia[0].PCMCIA.Compliance =
|
||||
$"{vers.MajorVersion}.{vers.MinorVersion}";
|
||||
|
||||
sidecar.BlockMedia[0].PCMCIA.AdditionalInformation =
|
||||
vers.AdditionalInformation;
|
||||
sidecar.BlockMedia[0].PCMCIA.AdditionalInformation = vers.AdditionalInformation;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -615,8 +614,7 @@ public sealed partial class Sidecar
|
||||
|
||||
if(sectors - doneSectors >= sectorsToRead)
|
||||
{
|
||||
errno = image.ReadSectors(tapeFile.FirstBlock + doneSectors, sectorsToRead,
|
||||
out sector);
|
||||
errno = image.ReadSectors(tapeFile.FirstBlock + doneSectors, sectorsToRead, out sector);
|
||||
|
||||
if(errno != ErrorNumber.NoError)
|
||||
{
|
||||
@@ -692,7 +690,7 @@ public sealed partial class Sidecar
|
||||
{
|
||||
sidecar.BlockMedia[0].FileSystemInformation = new PartitionType[partitions.Count];
|
||||
|
||||
for(int i = 0; i < partitions.Count; i++)
|
||||
for(var i = 0; i < partitions.Count; i++)
|
||||
{
|
||||
if(_aborted)
|
||||
return;
|
||||
@@ -1001,8 +999,8 @@ public sealed partial class Sidecar
|
||||
}
|
||||
catch(NotImplementedException) {}
|
||||
|
||||
if((image.Info.Heads == 2 && scpImage.Header.heads == 0) ||
|
||||
(image.Info.Heads == 1 && (scpImage.Header.heads == 1 || scpImage.Header.heads == 2)))
|
||||
if(image.Info.Heads == 2 && scpImage.Header.heads == 0 ||
|
||||
image.Info.Heads == 1 && (scpImage.Header.heads == 1 || scpImage.Header.heads == 2))
|
||||
if(scpImage.Header.end + 1 >= image.Info.Cylinders)
|
||||
{
|
||||
List<BlockTrackType> scpBlockTrackTypes = new();
|
||||
@@ -1038,9 +1036,9 @@ public sealed partial class Sidecar
|
||||
|
||||
if(scpImage.ScpTracks.TryGetValue(t, out SuperCardPro.TrackHeader scpTrack))
|
||||
{
|
||||
byte[] trackContents =
|
||||
new byte[scpTrack.Entries.Last().dataOffset +
|
||||
scpTrack.Entries.Last().trackLength - scpImage.Header.offsets[t] + 1];
|
||||
var trackContents =
|
||||
new byte[scpTrack.Entries.Last().dataOffset + scpTrack.Entries.Last().trackLength -
|
||||
scpImage.Header.offsets[t] + 1];
|
||||
|
||||
scpStream.Position = scpImage.Header.offsets[t];
|
||||
scpStream.Read(trackContents, 0, trackContents.Length);
|
||||
@@ -1069,10 +1067,9 @@ public sealed partial class Sidecar
|
||||
#region KryoFlux
|
||||
string kfFile = null;
|
||||
|
||||
string basename = Path.Combine(Path.GetDirectoryName(imagePath),
|
||||
Path.GetFileNameWithoutExtension(imagePath));
|
||||
string basename = Path.Combine(Path.GetDirectoryName(imagePath), Path.GetFileNameWithoutExtension(imagePath));
|
||||
|
||||
bool kfDir = false;
|
||||
var kfDir = false;
|
||||
|
||||
if(_aborted)
|
||||
return;
|
||||
@@ -1147,7 +1144,7 @@ public sealed partial class Sidecar
|
||||
}
|
||||
|
||||
Stream kfStream = kvp.Value.GetDataForkStream();
|
||||
byte[] trackContents = new byte[kfStream.Length];
|
||||
var trackContents = new byte[kfStream.Length];
|
||||
kfStream.Position = 0;
|
||||
kfStream.Read(trackContents, 0, trackContents.Length);
|
||||
kfBlockTrackType.Size = (ulong)trackContents.Length;
|
||||
@@ -1233,7 +1230,7 @@ public sealed partial class Sidecar
|
||||
dfiImage.TrackLengths.TryGetValue(t, out long length))
|
||||
{
|
||||
dfiBlockTrackType.Image.offset = (ulong)offset;
|
||||
byte[] trackContents = new byte[length];
|
||||
var trackContents = new byte[length];
|
||||
dfiStream.Position = offset;
|
||||
dfiStream.Read(trackContents, 0, trackContents.Length);
|
||||
dfiBlockTrackType.Size = (ulong)trackContents.Length;
|
||||
@@ -1243,8 +1240,7 @@ public sealed partial class Sidecar
|
||||
dfiBlockTrackTypes.Add(dfiBlockTrackType);
|
||||
}
|
||||
|
||||
sidecar.BlockMedia[0].Track =
|
||||
dfiBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray();
|
||||
sidecar.BlockMedia[0].Track = dfiBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray();
|
||||
}
|
||||
else
|
||||
AaruConsole.
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Sidecar operations</summary>
|
||||
public sealed partial class Sidecar
|
||||
{
|
||||
@@ -84,14 +84,14 @@ public sealed partial class Sidecar
|
||||
if(_aborted)
|
||||
return _sidecar;
|
||||
|
||||
ulong currentBlock = 0;
|
||||
ulong totalSize = 0;
|
||||
var tapeWorker = new Checksum();
|
||||
List<TapeFileType> tapeFiles = new List<TapeFileType>();
|
||||
ulong currentBlock = 0;
|
||||
ulong totalSize = 0;
|
||||
var tapeWorker = new Checksum();
|
||||
var tapeFiles = new List<TapeFileType>();
|
||||
|
||||
UpdateStatus("Hashing files...");
|
||||
|
||||
for(int i = 0; i < files.Count; i++)
|
||||
for(var i = 0; i < files.Count; i++)
|
||||
{
|
||||
if(_aborted)
|
||||
return _sidecar;
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using Aaru.CommonTypes;
|
||||
|
||||
public sealed partial class Sidecar
|
||||
{
|
||||
/// <summary>Initializes a progress indicator (e.g. makes a progress bar visible)</summary>
|
||||
@@ -72,6 +72,5 @@ public sealed partial class Sidecar
|
||||
public void EndProgress2() => EndProgressEvent2?.Invoke();
|
||||
|
||||
/// <summary>Updates a status indicator</summary>
|
||||
public void UpdateStatus(string text, params object[] args) =>
|
||||
UpdateStatusEvent?.Invoke(string.Format(text, args));
|
||||
public void UpdateStatus(string text, params object[] args) => UpdateStatusEvent?.Invoke(string.Format(text, args));
|
||||
}
|
||||
@@ -31,6 +31,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -40,8 +42,6 @@ using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Console;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
public sealed partial class Sidecar
|
||||
{
|
||||
FilesystemContentsType Files(IReadOnlyFilesystem filesystem)
|
||||
|
||||
@@ -80,13 +80,13 @@ public sealed partial class Sidecar
|
||||
}
|
||||
else
|
||||
{
|
||||
h = (lba + (450150 * 2)) / (75 * 60 * 60);
|
||||
lba -= h * (75 * 60 * 60);
|
||||
m = (lba + (450150 * 2)) / (75 * 60);
|
||||
lba -= m * (75 * 60);
|
||||
s = (lba + (450150 * 2)) / 75;
|
||||
lba -= s * 75;
|
||||
f = lba + (450150 * 2);
|
||||
h = (lba + 450150 * 2) / (75 * 60 * 60);
|
||||
lba -= h * (75 * 60 * 60);
|
||||
m = (lba + 450150 * 2) / (75 * 60);
|
||||
lba -= m * (75 * 60);
|
||||
s = (lba + 450150 * 2) / 75;
|
||||
lba -= s * 75;
|
||||
f = lba + 450150 * 2;
|
||||
}
|
||||
|
||||
return string.Format("{3}:{0:D2}:{1:D2}:{2:D2}", m, s, f, h);
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -38,8 +40,6 @@ using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
public sealed partial class Sidecar
|
||||
{
|
||||
// TODO: Complete it
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -49,8 +51,6 @@ using MediaType = Aaru.CommonTypes.MediaType;
|
||||
using Session = Aaru.CommonTypes.Structs.Session;
|
||||
using TrackType = Schemas.TrackType;
|
||||
|
||||
namespace Aaru.Core;
|
||||
|
||||
public sealed partial class Sidecar
|
||||
{
|
||||
/// <summary>Creates a metadata sidecar for an optical disc (e.g. CD, DVD, GD, BD, XGD, GOD)</summary>
|
||||
@@ -600,9 +600,7 @@ public sealed partial class Sidecar
|
||||
// For fast debugging, skip checksum
|
||||
//skipChecksum:
|
||||
|
||||
List<Partition> trkPartitions = partitions.
|
||||
Where(p => p.Start >= trk.StartSector && p.End <= trk.EndSector).
|
||||
ToList();
|
||||
var trkPartitions = partitions.Where(p => p.Start >= trk.StartSector && p.End <= trk.EndSector).ToList();
|
||||
|
||||
xmlTrk.FileSystemInformation = new PartitionType[1];
|
||||
|
||||
@@ -610,7 +608,7 @@ public sealed partial class Sidecar
|
||||
{
|
||||
xmlTrk.FileSystemInformation = new PartitionType[trkPartitions.Count];
|
||||
|
||||
for(int i = 0; i < trkPartitions.Count; i++)
|
||||
for(var i = 0; i < trkPartitions.Count; i++)
|
||||
{
|
||||
xmlTrk.FileSystemInformation[i] = new PartitionType
|
||||
{
|
||||
@@ -760,13 +758,11 @@ public sealed partial class Sidecar
|
||||
}
|
||||
|
||||
if(trk.Indexes?.Count > 0)
|
||||
{
|
||||
xmlTrk.Indexes = trk.Indexes?.OrderBy(i => i.Key).Select(i => new TrackIndexType
|
||||
{
|
||||
index = i.Key,
|
||||
Value = i.Value
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
trksLst.Add(xmlTrk);
|
||||
}
|
||||
@@ -780,8 +776,7 @@ public sealed partial class Sidecar
|
||||
if(dskType == MediaType.XGD2 &&
|
||||
sidecar.OpticalDisc[0].Track.Length == 1)
|
||||
{
|
||||
ulong blocks = sidecar.OpticalDisc[0].Track[0].EndSector - sidecar.OpticalDisc[0].Track[0].StartSector +
|
||||
1;
|
||||
ulong blocks = sidecar.OpticalDisc[0].Track[0].EndSector - sidecar.OpticalDisc[0].Track[0].StartSector + 1;
|
||||
|
||||
if(blocks == 25063 || // Locked (or non compatible drive)
|
||||
blocks == 4229664 || // Xtreme unlock
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user