mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Decode ATA and ATAPI IDENTIFY DEVICE from image info in GUI.
This commit is contained in:
2
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
2
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -1612,6 +1612,8 @@
|
||||
</e>
|
||||
<e p="ResourceHandler.cs" t="Include" />
|
||||
<e p="Tabs" t="Include">
|
||||
<e p="tabAtaInfo.xeto" t="Include" />
|
||||
<e p="tabAtaInfo.xeto.cs" t="Include" />
|
||||
<e p="tabScsiInfo.xeto" t="Include" />
|
||||
<e p="tabScsiInfo.xeto.cs" t="Include" />
|
||||
</e>
|
||||
|
||||
@@ -156,31 +156,6 @@
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</TabPage>
|
||||
<TabPage ID="tabAta" Text="ATA/ATAPI" Visible="False">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label ID="lblAtaIdentify" Text="ATA IDENTIFY DEVICE"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<TextArea ID="txtAtaIdentify" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Left">
|
||||
<StackLayout ID="stkAtaMcpt" Orientation="Vertical">
|
||||
<CheckBox ID="chkAtaMcpt" Text="Device is Media Card Pass Through" Enabled="False"/>
|
||||
<Label ID="lblAtaMcpt"/>
|
||||
<CheckBox ID="chkAtaMcptWriteProtection" Text="Media card is write protected"
|
||||
Enabled="False"/>
|
||||
<Label ID="lblAtaMcptSpecificData" Visible="False"/>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Right" VerticalAlignment="Bottom">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Button ID="btnSaveAtaBinary" Text="Save binary to file" Click="OnBtnSaveAtaBinary"/>
|
||||
<Button ID="btnSaveAtaText" Text="Save text to file" Click="OnBtnSaveAtaText"/>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</TabPage>
|
||||
<TabPage ID="tabPcmcia" Text="PCMCIA" Visible="False">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Decoders.ATA;
|
||||
using DiscImageChef.Decoders.PCMCIA;
|
||||
using DiscImageChef.Decoders.SCSI.SSC;
|
||||
using DiscImageChef.Devices;
|
||||
@@ -171,61 +170,10 @@ namespace DiscImageChef.Gui.Panels
|
||||
|
||||
if(devInfo.AtaIdentify != null || devInfo.AtapiIdentify != null)
|
||||
{
|
||||
tabAta.Visible = true;
|
||||
tabAtaInfo tabAtaInfo = new tabAtaInfo();
|
||||
tabAtaInfo.LoadData(devInfo.AtaIdentify, devInfo.AtapiIdentify, devInfo.AtaMcptError);
|
||||
|
||||
if(devInfo.AtaIdentify != null)
|
||||
{
|
||||
stkAtaMcpt.Visible = false;
|
||||
chkAtaMcpt.Checked = devInfo.AtaMcptError.HasValue;
|
||||
lblAtaMcpt.Visible = devInfo.AtaMcptError.HasValue;
|
||||
lblAtaIdentify.Text = "ATA IDENTIFY DEVICE";
|
||||
|
||||
if(devInfo.AtaMcptError.HasValue)
|
||||
{
|
||||
switch(devInfo.AtaMcptError.Value.DeviceHead & 0x7)
|
||||
{
|
||||
case 0:
|
||||
lblAtaMcpt.Text = "Device reports incorrect media card type";
|
||||
break;
|
||||
case 1:
|
||||
lblAtaMcpt.Text = "Device contains a Secure Digital card";
|
||||
break;
|
||||
case 2:
|
||||
lblAtaMcpt.Text = "Device contains a MultiMediaCard ";
|
||||
break;
|
||||
case 3:
|
||||
lblAtaMcpt.Text = "Device contains a Secure Digital I/O card";
|
||||
break;
|
||||
case 4:
|
||||
lblAtaMcpt.Text = "Device contains a Smart Media card";
|
||||
break;
|
||||
default:
|
||||
lblAtaMcpt.Text =
|
||||
$"Device contains unknown media card type {devInfo.AtaMcptError.Value.DeviceHead & 0x07}";
|
||||
break;
|
||||
}
|
||||
|
||||
chkAtaMcptWriteProtection.Checked = (devInfo.AtaMcptError.Value.DeviceHead & 0x08) == 0x08;
|
||||
|
||||
ushort specificData = (ushort)(devInfo.AtaMcptError.Value.CylinderHigh * 0x100 +
|
||||
devInfo.AtaMcptError.Value.CylinderLow);
|
||||
if(specificData != 0)
|
||||
{
|
||||
lblAtaMcptSpecificData.Visible = true;
|
||||
lblAtaMcptSpecificData.Text = $"Card specific data: 0x{specificData:X4}";
|
||||
}
|
||||
}
|
||||
|
||||
tabAta.Text = "ATA";
|
||||
txtAtaIdentify.Text = Identify.Prettify(this.devInfo.AtaIdentify);
|
||||
}
|
||||
else if(devInfo.AtapiIdentify != null)
|
||||
{
|
||||
lblAtaIdentify.Text = "ATA PACKET IDENTIFY DEVICE";
|
||||
stkAtaMcpt.Visible = false;
|
||||
tabAta.Text = "ATAPI";
|
||||
txtAtaIdentify.Text = Identify.Prettify(this.devInfo.AtapiIdentify);
|
||||
}
|
||||
tabInfos.Pages.Add(tabAtaInfo);
|
||||
}
|
||||
|
||||
if(devInfo.ScsiInquiryData != null)
|
||||
@@ -496,35 +444,6 @@ namespace DiscImageChef.Gui.Panels
|
||||
tabScr.Visible;
|
||||
}
|
||||
|
||||
protected void OnBtnSaveAtaBinary(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog dlgSaveBinary = new SaveFileDialog();
|
||||
dlgSaveBinary.Filters.Add(new FileFilter {Extensions = new[] {"*.bin"}, Name = "Binary"});
|
||||
DialogResult result = dlgSaveBinary.ShowDialog(this);
|
||||
|
||||
if(result != DialogResult.Ok) return;
|
||||
|
||||
FileStream saveFs = new FileStream(dlgSaveBinary.FileName, FileMode.Create);
|
||||
if(devInfo.AtaIdentify != null) saveFs.Write(devInfo.AtaIdentify, 0, devInfo.AtaIdentify.Length);
|
||||
else if(devInfo.AtapiIdentify != null) saveFs.Write(devInfo.AtapiIdentify, 0, devInfo.AtapiIdentify.Length);
|
||||
|
||||
saveFs.Close();
|
||||
}
|
||||
|
||||
protected void OnBtnSaveAtaText(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog dlgSaveText = new SaveFileDialog();
|
||||
dlgSaveText.Filters.Add(new FileFilter {Extensions = new[] {"*.txt"}, Name = "Text"});
|
||||
DialogResult result = dlgSaveText.ShowDialog(this);
|
||||
|
||||
if(result != DialogResult.Ok) return;
|
||||
|
||||
FileStream saveFs = new FileStream(dlgSaveText.FileName, FileMode.Create);
|
||||
StreamWriter saveSw = new StreamWriter(saveFs);
|
||||
saveSw.Write(txtAtaIdentify.Text);
|
||||
saveFs.Close();
|
||||
}
|
||||
|
||||
protected void OnBtnSaveUsbDescriptors(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog dlgSaveBinary = new SaveFileDialog();
|
||||
@@ -580,16 +499,6 @@ namespace DiscImageChef.Gui.Panels
|
||||
TextBox txtScsiType;
|
||||
CheckBox chkRemovable;
|
||||
CheckBox chkUsb;
|
||||
TabPage tabAta;
|
||||
Label lblAtaIdentify;
|
||||
TextArea txtAtaIdentify;
|
||||
Button btnSaveAtaBinary;
|
||||
Button btnSaveAtaText;
|
||||
StackLayout stkAtaMcpt;
|
||||
CheckBox chkAtaMcpt;
|
||||
Label lblAtaMcpt;
|
||||
CheckBox chkAtaMcptWriteProtection;
|
||||
Label lblAtaMcptSpecificData;
|
||||
TabPage tabKreon;
|
||||
CheckBox chkKreonChallengeResponse;
|
||||
CheckBox chkKreonDecryptSs;
|
||||
@@ -655,7 +564,6 @@ namespace DiscImageChef.Gui.Panels
|
||||
CheckBox chkPlextorBitSettingDl;
|
||||
CheckBox chkPlextorDvdPlusWriteTest;
|
||||
TabPage tabSsc;
|
||||
StackLayout Vertical;
|
||||
Label lblMinBlockSize;
|
||||
Label lblMaxBlockSize;
|
||||
Label lblBlockSizeGranularity;
|
||||
|
||||
@@ -212,8 +212,8 @@ namespace DiscImageChef.Gui.Panels
|
||||
|
||||
PeripheralDeviceTypes scsiDeviceType = PeripheralDeviceTypes.DirectAccess;
|
||||
byte[] scsiInquiryData = null;
|
||||
Inquiry.SCSIInquiry? scsiInquiry;
|
||||
Modes.DecodedMode? scsiMode;
|
||||
Inquiry.SCSIInquiry? scsiInquiry = null;
|
||||
Modes.DecodedMode? scsiMode = null;
|
||||
byte[] scsiModeSense6 = null;
|
||||
byte[] scsiModeSense10 = null;
|
||||
|
||||
@@ -244,8 +244,22 @@ namespace DiscImageChef.Gui.Panels
|
||||
tabScsiInfo tabScsiInfo = new tabScsiInfo();
|
||||
tabScsiInfo.LoadData(scsiInquiryData, scsiInquiry, null, scsiMode, scsiDeviceType, scsiModeSense6,
|
||||
scsiModeSense10, null);
|
||||
|
||||
tabInfos.Pages.Add(tabScsiInfo);
|
||||
|
||||
byte[] ataIdentify = null;
|
||||
byte[] atapiIdentify = null;
|
||||
|
||||
if(imageFormat.Info.ReadableMediaTags != null &&
|
||||
imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.ATA_IDENTIFY))
|
||||
ataIdentify = imageFormat.ReadDiskTag(MediaTagType.ATA_IDENTIFY);
|
||||
|
||||
if(imageFormat.Info.ReadableMediaTags != null &&
|
||||
imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.ATAPI_IDENTIFY))
|
||||
atapiIdentify = imageFormat.ReadDiskTag(MediaTagType.ATAPI_IDENTIFY);
|
||||
|
||||
tabAtaInfo tabAtaInfo = new tabAtaInfo();
|
||||
tabAtaInfo.LoadData(ataIdentify, atapiIdentify, null);
|
||||
tabInfos.Pages.Add(tabAtaInfo);
|
||||
}
|
||||
|
||||
#region XAML controls
|
||||
|
||||
58
DiscImageChef.Gui/Tabs/tabAtaInfo.xeto
Normal file
58
DiscImageChef.Gui/Tabs/tabAtaInfo.xeto
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!--
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ============================================================================
|
||||
//
|
||||
// Filename : pnlDeviceInfo.xeto
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Device information panel.
|
||||
//
|
||||
// ==[ Description ] ==========================================================
|
||||
//
|
||||
// Defines the structure for the device information panel.
|
||||
//
|
||||
// ==[ 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/>.
|
||||
//
|
||||
// ============================================================================
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
-->
|
||||
<TabPage Text="ATA/ATAPI" Visible="False" xmlns="http://schema.picoe.ca/eto.forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label ID="lblAtaIdentify" Text="ATA IDENTIFY DEVICE"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<TextArea ID="txtAtaIdentify" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Left">
|
||||
<StackLayout ID="stkAtaMcpt" Orientation="Vertical">
|
||||
<CheckBox ID="chkAtaMcpt" Text="Device is Media Card Pass Through" Enabled="False"/>
|
||||
<Label ID="lblAtaMcpt"/>
|
||||
<CheckBox ID="chkAtaMcptWriteProtection" Text="Media card is write protected" Enabled="False"/>
|
||||
<Label ID="lblAtaMcptSpecificData" Visible="False"/>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Right" VerticalAlignment="Bottom">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Button ID="btnSaveAtaBinary" Text="Save binary to file" Click="OnBtnSaveAtaBinary"/>
|
||||
<Button ID="btnSaveAtaText" Text="Save text to file" Click="OnBtnSaveAtaText"/>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</TabPage>
|
||||
160
DiscImageChef.Gui/Tabs/tabAtaInfo.xeto.cs
Normal file
160
DiscImageChef.Gui/Tabs/tabAtaInfo.xeto.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : pnlDeviceInfo.xeto.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Device information.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Implements the device information panel.
|
||||
//
|
||||
// --[ 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/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using DiscImageChef.Decoders.ATA;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
|
||||
namespace DiscImageChef.Gui.Tabs
|
||||
{
|
||||
public class tabAtaInfo : TabPage
|
||||
{
|
||||
byte[] ata;
|
||||
byte[] atapi;
|
||||
|
||||
public tabAtaInfo()
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
}
|
||||
|
||||
internal void LoadData(byte[] ataIdentify, byte[] atapiIdentify, AtaErrorRegistersChs? ataMcptError)
|
||||
{
|
||||
ata = ataIdentify;
|
||||
atapi = atapiIdentify;
|
||||
|
||||
if(ataIdentify == null && atapiIdentify == null) return;
|
||||
|
||||
Visible = true;
|
||||
|
||||
if(ataIdentify != null)
|
||||
{
|
||||
stkAtaMcpt.Visible = false;
|
||||
chkAtaMcpt.Checked = ataMcptError.HasValue;
|
||||
lblAtaMcpt.Visible = ataMcptError.HasValue;
|
||||
lblAtaIdentify.Text = "ATA IDENTIFY DEVICE";
|
||||
|
||||
if(ataMcptError.HasValue)
|
||||
{
|
||||
switch(ataMcptError.Value.DeviceHead & 0x7)
|
||||
{
|
||||
case 0:
|
||||
lblAtaMcpt.Text = "Device reports incorrect media card type";
|
||||
break;
|
||||
case 1:
|
||||
lblAtaMcpt.Text = "Device contains a Secure Digital card";
|
||||
break;
|
||||
case 2:
|
||||
lblAtaMcpt.Text = "Device contains a MultiMediaCard ";
|
||||
break;
|
||||
case 3:
|
||||
lblAtaMcpt.Text = "Device contains a Secure Digital I/O card";
|
||||
break;
|
||||
case 4:
|
||||
lblAtaMcpt.Text = "Device contains a Smart Media card";
|
||||
break;
|
||||
default:
|
||||
lblAtaMcpt.Text =
|
||||
$"Device contains unknown media card type {ataMcptError.Value.DeviceHead & 0x07}";
|
||||
break;
|
||||
}
|
||||
|
||||
chkAtaMcptWriteProtection.Checked = (ataMcptError.Value.DeviceHead & 0x08) == 0x08;
|
||||
|
||||
ushort specificData = (ushort)(ataMcptError.Value.CylinderHigh * 0x100 +
|
||||
ataMcptError.Value.CylinderLow);
|
||||
if(specificData != 0)
|
||||
{
|
||||
lblAtaMcptSpecificData.Visible = true;
|
||||
lblAtaMcptSpecificData.Text = $"Card specific data: 0x{specificData:X4}";
|
||||
}
|
||||
}
|
||||
|
||||
Text = "ATA";
|
||||
txtAtaIdentify.Text = Identify.Prettify(ata);
|
||||
}
|
||||
else
|
||||
{
|
||||
lblAtaIdentify.Text = "ATA PACKET IDENTIFY DEVICE";
|
||||
stkAtaMcpt.Visible = false;
|
||||
Text = "ATAPI";
|
||||
txtAtaIdentify.Text = Identify.Prettify(atapi);
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnBtnSaveAtaBinary(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog dlgSaveBinary = new SaveFileDialog();
|
||||
dlgSaveBinary.Filters.Add(new FileFilter {Extensions = new[] {"*.bin"}, Name = "Binary"});
|
||||
DialogResult result = dlgSaveBinary.ShowDialog(this);
|
||||
|
||||
if(result != DialogResult.Ok) return;
|
||||
|
||||
FileStream saveFs = new FileStream(dlgSaveBinary.FileName, FileMode.Create);
|
||||
if(ata != null) saveFs.Write(ata, 0, ata.Length);
|
||||
else if(atapi != null) saveFs.Write(atapi, 0, atapi.Length);
|
||||
|
||||
saveFs.Close();
|
||||
}
|
||||
|
||||
protected void OnBtnSaveAtaText(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog dlgSaveText = new SaveFileDialog();
|
||||
dlgSaveText.Filters.Add(new FileFilter {Extensions = new[] {"*.txt"}, Name = "Text"});
|
||||
DialogResult result = dlgSaveText.ShowDialog(this);
|
||||
|
||||
if(result != DialogResult.Ok) return;
|
||||
|
||||
FileStream saveFs = new FileStream(dlgSaveText.FileName, FileMode.Create);
|
||||
StreamWriter saveSw = new StreamWriter(saveFs);
|
||||
saveSw.Write(txtAtaIdentify.Text);
|
||||
saveFs.Close();
|
||||
}
|
||||
|
||||
#region XAML controls
|
||||
#pragma warning disable 169
|
||||
#pragma warning disable 649
|
||||
Label lblAtaIdentify;
|
||||
TextArea txtAtaIdentify;
|
||||
Button btnSaveAtaBinary;
|
||||
Button btnSaveAtaText;
|
||||
StackLayout stkAtaMcpt;
|
||||
CheckBox chkAtaMcpt;
|
||||
Label lblAtaMcpt;
|
||||
CheckBox chkAtaMcptWriteProtection;
|
||||
Label lblAtaMcptSpecificData;
|
||||
#pragma warning restore 169
|
||||
#pragma warning restore 649
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user