2017-09-07 20:30:23 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : Ata48.cs
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-09-07 20:30:23 +01:00
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : DiscImageChef device testing.
|
2017-09-07 20:30:23 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program 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 General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2017-09-07 20:30:23 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2017-09-07 20:30:23 +01:00
|
|
|
|
using DiscImageChef.Console;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
using DiscImageChef.Decoders.ATA;
|
2017-12-19 19:33:46 +00:00
|
|
|
|
using DiscImageChef.Devices;
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Tests.Devices.ATA
|
|
|
|
|
|
{
|
2017-12-20 02:08:37 +00:00
|
|
|
|
static class Ata48
|
2017-09-07 20:30:23 +01:00
|
|
|
|
{
|
2017-12-20 02:08:37 +00:00
|
|
|
|
internal static void Menu(string devPath, Device dev)
|
2017-09-07 20:30:23 +01:00
|
|
|
|
{
|
|
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Send a 48-bit ATA command to the device:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Send GET NATIVE MAX ADDRESS EXT command.");
|
|
|
|
|
|
DicConsole.WriteLine("2.- Send READ DMA EXT command.");
|
|
|
|
|
|
DicConsole.WriteLine("3.- Send READ LOG DMA EXT command.");
|
|
|
|
|
|
DicConsole.WriteLine("4.- Send READ LOG EXT command.");
|
|
|
|
|
|
DicConsole.WriteLine("5.- Send READ MATIVE MAX ADDRESS EXT command.");
|
|
|
|
|
|
DicConsole.WriteLine("6.- Send READ MULTIPLE EXT command.");
|
|
|
|
|
|
DicConsole.WriteLine("7.- Send READ SECTORS EXT command.");
|
|
|
|
|
|
DicConsole.WriteLine("0.- Return to ATA commands menu.");
|
|
|
|
|
|
DicConsole.Write("Choose: ");
|
|
|
|
|
|
|
|
|
|
|
|
string strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out int item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to ATA commands menu...");
|
|
|
|
|
|
return;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
case 1:
|
|
|
|
|
|
GetNativeMaxAddressExt(devPath, dev);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
ReadDmaExt(devPath, dev);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
ReadLogDmaExt(devPath, dev);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
ReadLogExt(devPath, dev);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
ReadNativeMaxAddressExt(devPath, dev);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
case 6:
|
|
|
|
|
|
ReadMultipleExt(devPath, dev);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
case 7:
|
|
|
|
|
|
ReadSectorsExt(devPath, dev);
|
|
|
|
|
|
continue;
|
2017-09-07 20:30:23 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-09-08 17:44:56 +01:00
|
|
|
|
|
2017-09-08 18:21:52 +01:00
|
|
|
|
static void GetNativeMaxAddressExt(string devPath, Device dev)
|
2017-09-08 17:44:56 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
start:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
System.Console.Clear();
|
2017-12-22 02:04:18 +00:00
|
|
|
|
bool sense = dev.GetNativeMaxAddressExt(out ulong lba, out AtaErrorRegistersLba48 errorRegisters,
|
2017-12-19 20:33:03 +00:00
|
|
|
|
dev.Timeout, out double duration);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
menu:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Sending GET NATIVE MAX ADDRESS EXT to the device:");
|
|
|
|
|
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
|
|
|
|
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
|
|
|
|
|
DicConsole.WriteLine("Max LBA is {0}.", lba);
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Decode error registers.");
|
|
|
|
|
|
DicConsole.WriteLine("2.- Send command again.");
|
|
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
DicConsole.Write("Choose: ");
|
|
|
|
|
|
|
|
|
|
|
|
string strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out int item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("GET NATIVE MAX ADDRESS EXT status registers:");
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.Write("{0}", MainClass.DecodeAtaRegisters(errorRegisters));
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 2: goto start;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 18:21:52 +01:00
|
|
|
|
static void ReadDmaExt(string devPath, Device dev)
|
2017-09-08 17:44:56 +01:00
|
|
|
|
{
|
|
|
|
|
|
ulong lba = 0;
|
|
|
|
|
|
ushort count = 1;
|
|
|
|
|
|
string strDev;
|
|
|
|
|
|
int item;
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
parameters:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Parameters for READ DMA EXT command:");
|
|
|
|
|
|
DicConsole.WriteLine("LBA: {0}", lba);
|
|
|
|
|
|
DicConsole.WriteLine("Count: {0}", count);
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Change parameters.");
|
|
|
|
|
|
DicConsole.WriteLine("2.- Send command with these parameters.");
|
|
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
DicConsole.Write("What logical block address?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!ulong.TryParse(strDev, out lba))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
lba = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
if(lba > 0xFFFFFFFFFFFF)
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole
|
|
|
|
|
|
.WriteLine("Logical block address cannot be bigger than {0}. Setting it to {0}...",
|
|
|
|
|
|
0xFFFFFFFFFFFF);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
lba = 0xFFFFFFFFFFFF;
|
|
|
|
|
|
}
|
|
|
|
|
|
DicConsole.Write("How many sectors?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!ushort.TryParse(strDev, out count))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
break;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 2: goto start;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
start:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
System.Console.Clear();
|
2017-12-22 02:04:18 +00:00
|
|
|
|
bool sense = dev.ReadDma(out byte[] buffer, out AtaErrorRegistersLba48 errorRegisters, lba, count,
|
2017-12-19 20:33:03 +00:00
|
|
|
|
dev.Timeout, out double duration);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
menu:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Sending READ DMA EXT to the device:");
|
|
|
|
|
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
|
|
|
|
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.WriteLine("Buffer is {0} bytes.", buffer?.Length.ToString() ?? "null");
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(buffer));
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Print buffer.");
|
2017-09-08 18:29:31 +01:00
|
|
|
|
DicConsole.WriteLine("2.- Decode error registers.");
|
|
|
|
|
|
DicConsole.WriteLine("3.- Send command again.");
|
|
|
|
|
|
DicConsole.WriteLine("4.- Change parameters.");
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
DicConsole.Write("Choose: ");
|
|
|
|
|
|
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ DMA EXT response:");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(buffer != null) PrintHex.PrintHexArray(buffer, 64);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ DMA EXT status registers:");
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.Write("{0}", MainClass.DecodeAtaRegisters(errorRegisters));
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 3: goto start;
|
|
|
|
|
|
case 4: goto parameters;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 18:21:52 +01:00
|
|
|
|
static void ReadLogExt(string devPath, Device dev)
|
2017-09-08 17:44:56 +01:00
|
|
|
|
{
|
|
|
|
|
|
byte address = 0;
|
|
|
|
|
|
ushort page = 0;
|
|
|
|
|
|
ushort count = 1;
|
|
|
|
|
|
string strDev;
|
|
|
|
|
|
int item;
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
parameters:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Parameters for READ LOG EXT command:");
|
|
|
|
|
|
DicConsole.WriteLine("Log address: {0}", address);
|
|
|
|
|
|
DicConsole.WriteLine("Page number: {0}", page);
|
|
|
|
|
|
DicConsole.WriteLine("Count: {0}", count);
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Change parameters.");
|
|
|
|
|
|
DicConsole.WriteLine("2.- Send command with these parameters.");
|
|
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
DicConsole.Write("What log address?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!byte.TryParse(strDev, out address))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
address = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.Write("What page number?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!ushort.TryParse(strDev, out page))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
page = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.Write("How many sectors?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!ushort.TryParse(strDev, out count))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
break;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 2: goto start;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
start:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
System.Console.Clear();
|
2017-12-22 02:04:18 +00:00
|
|
|
|
bool sense = dev.ReadLog(out byte[] buffer, out AtaErrorRegistersLba48 errorRegisters, address, page, count,
|
2017-12-19 20:33:03 +00:00
|
|
|
|
dev.Timeout, out double duration);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
menu:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Sending READ LOG EXT to the device:");
|
|
|
|
|
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
|
|
|
|
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.WriteLine("Buffer is {0} bytes.", buffer?.Length.ToString() ?? "null");
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(buffer));
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Print buffer.");
|
2017-09-08 18:29:31 +01:00
|
|
|
|
DicConsole.WriteLine("2.- Decode error registers.");
|
|
|
|
|
|
DicConsole.WriteLine("3.- Send command again.");
|
|
|
|
|
|
DicConsole.WriteLine("4.- Change parameters.");
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
DicConsole.Write("Choose: ");
|
|
|
|
|
|
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ LOG EXT response:");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(buffer != null) PrintHex.PrintHexArray(buffer, 64);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ LOG EXT status registers:");
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.Write("{0}", MainClass.DecodeAtaRegisters(errorRegisters));
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 3: goto start;
|
|
|
|
|
|
case 4: goto parameters;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 18:21:52 +01:00
|
|
|
|
static void ReadLogDmaExt(string devPath, Device dev)
|
2017-09-08 17:44:56 +01:00
|
|
|
|
{
|
|
|
|
|
|
byte address = 0;
|
|
|
|
|
|
ushort page = 0;
|
|
|
|
|
|
ushort count = 1;
|
|
|
|
|
|
string strDev;
|
|
|
|
|
|
int item;
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
parameters:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Parameters for READ LOG DMA EXT command:");
|
|
|
|
|
|
DicConsole.WriteLine("Log address: {0}", address);
|
|
|
|
|
|
DicConsole.WriteLine("Page number: {0}", page);
|
|
|
|
|
|
DicConsole.WriteLine("Count: {0}", count);
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Change parameters.");
|
|
|
|
|
|
DicConsole.WriteLine("2.- Send command with these parameters.");
|
|
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
DicConsole.Write("What log address?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!byte.TryParse(strDev, out address))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
address = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.Write("What page number?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!ushort.TryParse(strDev, out page))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
page = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.Write("How many sectors?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!ushort.TryParse(strDev, out count))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
break;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 2: goto start;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
start:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
System.Console.Clear();
|
2017-12-22 02:04:18 +00:00
|
|
|
|
bool sense = dev.ReadLogDma(out byte[] buffer, out AtaErrorRegistersLba48 errorRegisters, address, page,
|
2017-12-19 20:33:03 +00:00
|
|
|
|
count, dev.Timeout, out double duration);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
menu:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Sending READ LOG DMA EXT to the device:");
|
|
|
|
|
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
|
|
|
|
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.WriteLine("Buffer is {0} bytes.", buffer?.Length.ToString() ?? "null");
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(buffer));
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Print buffer.");
|
2017-09-08 18:29:31 +01:00
|
|
|
|
DicConsole.WriteLine("2.- Decode error registers.");
|
|
|
|
|
|
DicConsole.WriteLine("3.- Send command again.");
|
|
|
|
|
|
DicConsole.WriteLine("4.- Change parameters.");
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
DicConsole.Write("Choose: ");
|
|
|
|
|
|
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ LOG DMA EXT response:");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(buffer != null) PrintHex.PrintHexArray(buffer, 64);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ LOG DMA EXT status registers:");
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.Write("{0}", MainClass.DecodeAtaRegisters(errorRegisters));
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 3: goto start;
|
|
|
|
|
|
case 4: goto parameters;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 18:21:52 +01:00
|
|
|
|
static void ReadMultipleExt(string devPath, Device dev)
|
2017-09-08 17:44:56 +01:00
|
|
|
|
{
|
|
|
|
|
|
ulong lba = 0;
|
|
|
|
|
|
ushort count = 1;
|
|
|
|
|
|
string strDev;
|
|
|
|
|
|
int item;
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
parameters:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Parameters for READ MULTIPLE EXT command:");
|
|
|
|
|
|
DicConsole.WriteLine("LBA: {0}", lba);
|
|
|
|
|
|
DicConsole.WriteLine("Count: {0}", count);
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Change parameters.");
|
|
|
|
|
|
DicConsole.WriteLine("2.- Send command with these parameters.");
|
|
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
DicConsole.Write("What logical block address?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!ulong.TryParse(strDev, out lba))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
lba = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
if(lba > 0xFFFFFFFFFFFF)
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole
|
|
|
|
|
|
.WriteLine("Logical block address cannot be bigger than {0}. Setting it to {0}...",
|
|
|
|
|
|
0xFFFFFFFFFFFF);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
lba = 0xFFFFFFFFFFFF;
|
|
|
|
|
|
}
|
|
|
|
|
|
DicConsole.Write("How many sectors?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!ushort.TryParse(strDev, out count))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
break;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 2: goto start;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
start:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
System.Console.Clear();
|
2017-12-22 02:04:18 +00:00
|
|
|
|
bool sense = dev.ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba48 errorRegisters, lba, count,
|
2017-12-19 20:33:03 +00:00
|
|
|
|
dev.Timeout, out double duration);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
menu:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Sending READ MULTIPLE EXT to the device:");
|
|
|
|
|
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
|
|
|
|
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.WriteLine("Buffer is {0} bytes.", buffer?.Length.ToString() ?? "null");
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(buffer));
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Print buffer.");
|
2017-09-08 18:29:31 +01:00
|
|
|
|
DicConsole.WriteLine("2.- Decode error registers.");
|
|
|
|
|
|
DicConsole.WriteLine("3.- Send command again.");
|
|
|
|
|
|
DicConsole.WriteLine("4.- Change parameters.");
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
DicConsole.Write("Choose: ");
|
|
|
|
|
|
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ MULTIPLE EXT response:");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(buffer != null) PrintHex.PrintHexArray(buffer, 64);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ MULTIPLE EXT status registers:");
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.Write("{0}", MainClass.DecodeAtaRegisters(errorRegisters));
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 3: goto start;
|
|
|
|
|
|
case 4: goto parameters;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 18:21:52 +01:00
|
|
|
|
static void ReadNativeMaxAddressExt(string devPath, Device dev)
|
2017-09-08 17:44:56 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
start:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
System.Console.Clear();
|
2017-12-22 02:04:18 +00:00
|
|
|
|
bool sense = dev.ReadNativeMaxAddress(out ulong lba, out AtaErrorRegistersLba48 errorRegisters, dev.Timeout,
|
2017-12-19 20:33:03 +00:00
|
|
|
|
out double duration);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
menu:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Sending READ NATIVE MAX ADDRESS EXT to the device:");
|
|
|
|
|
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
|
|
|
|
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
|
|
|
|
|
DicConsole.WriteLine("Max LBA is {0}.", lba);
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Decode error registers.");
|
|
|
|
|
|
DicConsole.WriteLine("2.- Send command again.");
|
|
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
DicConsole.Write("Choose: ");
|
|
|
|
|
|
|
|
|
|
|
|
string strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out int item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ NATIVE MAX ADDRESS status registers:");
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.Write("{0}", MainClass.DecodeAtaRegisters(errorRegisters));
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 2: goto start;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 18:21:52 +01:00
|
|
|
|
static void ReadSectorsExt(string devPath, Device dev)
|
2017-09-08 17:44:56 +01:00
|
|
|
|
{
|
|
|
|
|
|
ulong lba = 0;
|
|
|
|
|
|
ushort count = 1;
|
|
|
|
|
|
string strDev;
|
|
|
|
|
|
int item;
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
parameters:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Parameters for READ SECTORS EXT command:");
|
|
|
|
|
|
DicConsole.WriteLine("LBA: {0}", lba);
|
|
|
|
|
|
DicConsole.WriteLine("Count: {0}", count);
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Change parameters.");
|
|
|
|
|
|
DicConsole.WriteLine("2.- Send command with these parameters.");
|
|
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
DicConsole.Write("What logical block address?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!ulong.TryParse(strDev, out lba))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
lba = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
if(lba > 0xFFFFFFFFFFFF)
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole
|
|
|
|
|
|
.WriteLine("Logical block address cannot be bigger than {0}. Setting it to {0}...",
|
|
|
|
|
|
0xFFFFFFFFFFFF);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
lba = 0xFFFFFFFFFFFF;
|
|
|
|
|
|
}
|
|
|
|
|
|
DicConsole.Write("How many sectors?: ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!ushort.TryParse(strDev, out count))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-09-08 17:44:56 +01:00
|
|
|
|
break;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 2: goto start;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
start:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
System.Console.Clear();
|
2017-12-22 02:04:18 +00:00
|
|
|
|
bool sense = dev.Read(out byte[] buffer, out AtaErrorRegistersLba48 errorRegisters, lba, count, dev.Timeout,
|
2017-12-19 20:33:03 +00:00
|
|
|
|
out double duration);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
menu:
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Sending READ SECTORS EXT to the device:");
|
|
|
|
|
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
|
|
|
|
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.WriteLine("Buffer is {0} bytes.", buffer?.Length.ToString() ?? "null");
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(buffer));
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
|
DicConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
DicConsole.WriteLine("1.- Print buffer.");
|
2017-09-08 18:29:31 +01:00
|
|
|
|
DicConsole.WriteLine("2.- Decode error registers.");
|
|
|
|
|
|
DicConsole.WriteLine("3.- Send command again.");
|
|
|
|
|
|
DicConsole.WriteLine("4.- Change parameters.");
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("0.- Return to 48-bit ATA commands menu.");
|
|
|
|
|
|
DicConsole.Write("Choose: ");
|
|
|
|
|
|
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to 48-bit ATA commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ SECTORS EXT response:");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(buffer != null) PrintHex.PrintHexArray(buffer, 64);
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("READ SECTORS EXT status registers:");
|
2017-12-22 22:31:01 +00:00
|
|
|
|
DicConsole.Write("{0}", MainClass.DecodeAtaRegisters(errorRegisters));
|
2017-09-08 17:44:56 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 3: goto start;
|
|
|
|
|
|
case 4: goto parameters;
|
2017-09-08 17:44:56 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-09-07 20:30:23 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|