mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Removed deprecated Windows XP only code.
This commit is contained in:
@@ -441,146 +441,6 @@ namespace DiscImageChef.Devices.Windows
|
||||
return error;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA command in CHS mode using undocumented Windows XP ioctl
|
||||
/// </summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="fd">File handle</param>
|
||||
/// <param name="buffer">Buffer for SCSI command response</param>
|
||||
/// <param name="timeout">Timeout in seconds</param>
|
||||
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
||||
/// <param name="sense"><c>True</c> if ATA error returned non-OK status</param>
|
||||
/// <param name="registers">Registers to send to drive</param>
|
||||
/// <param name="errorRegisters">Registers returned by drive</param>
|
||||
/// <param name="protocol">ATA protocol to use</param>
|
||||
internal static int SendIdeCommand(SafeFileHandle fd, AtaRegistersChs registers,
|
||||
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
|
||||
ref byte[] buffer, uint timeout,
|
||||
out double duration, out bool sense)
|
||||
{
|
||||
duration = 0;
|
||||
sense = false;
|
||||
errorRegisters = new AtaErrorRegistersChs();
|
||||
|
||||
if(buffer == null || buffer.Length > 512) return -1;
|
||||
|
||||
IdePassThroughDirect iptd = new IdePassThroughDirect
|
||||
{
|
||||
CurrentTaskFile = new AtaTaskFile
|
||||
{
|
||||
Command = registers.Command,
|
||||
CylinderHigh = registers.CylinderHigh,
|
||||
CylinderLow = registers.CylinderLow,
|
||||
DeviceHead = registers.DeviceHead,
|
||||
Features = registers.Feature,
|
||||
SectorCount = registers.SectorCount,
|
||||
SectorNumber = registers.Sector
|
||||
},
|
||||
DataBufferSize = 512,
|
||||
DataBuffer = new byte[512]
|
||||
};
|
||||
|
||||
uint k = 0;
|
||||
int error = 0;
|
||||
|
||||
Array.Copy(buffer, 0, iptd.DataBuffer, 0, buffer.Length);
|
||||
|
||||
DateTime start = DateTime.Now;
|
||||
sense = !Extern.DeviceIoControlIde(fd, WindowsIoctl.IoctlIdePassThrough, ref iptd,
|
||||
(uint)Marshal.SizeOf(iptd), ref iptd, (uint)Marshal.SizeOf(iptd), ref k,
|
||||
IntPtr.Zero);
|
||||
DateTime end = DateTime.Now;
|
||||
|
||||
if(sense) error = Marshal.GetLastWin32Error();
|
||||
|
||||
buffer = new byte[k - 12];
|
||||
Array.Copy(iptd.DataBuffer, 0, buffer, 0, buffer.Length);
|
||||
|
||||
duration = (end - start).TotalMilliseconds;
|
||||
|
||||
errorRegisters.CylinderHigh = iptd.CurrentTaskFile.CylinderHigh;
|
||||
errorRegisters.CylinderLow = iptd.CurrentTaskFile.CylinderLow;
|
||||
errorRegisters.DeviceHead = iptd.CurrentTaskFile.DeviceHead;
|
||||
errorRegisters.Error = iptd.CurrentTaskFile.Error;
|
||||
errorRegisters.Sector = iptd.CurrentTaskFile.SectorNumber;
|
||||
errorRegisters.SectorCount = iptd.CurrentTaskFile.SectorCount;
|
||||
errorRegisters.Status = iptd.CurrentTaskFile.Status;
|
||||
|
||||
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA command in 28-bit LBA mode using undocumented Windows XP ioctl
|
||||
/// </summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="fd">File handle</param>
|
||||
/// <param name="buffer">Buffer for SCSI command response</param>
|
||||
/// <param name="timeout">Timeout in seconds</param>
|
||||
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
||||
/// <param name="sense"><c>True</c> if ATA error returned non-OK status</param>
|
||||
/// <param name="registers">Registers to send to drive</param>
|
||||
/// <param name="errorRegisters">Registers returned by drive</param>
|
||||
/// <param name="protocol">ATA protocol to use</param>
|
||||
internal static int SendIdeCommand(SafeFileHandle fd, AtaRegistersLba28 registers,
|
||||
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
|
||||
ref byte[] buffer, uint timeout,
|
||||
out double duration, out bool sense)
|
||||
{
|
||||
duration = 0;
|
||||
sense = false;
|
||||
errorRegisters = new AtaErrorRegistersLba28();
|
||||
|
||||
if(buffer == null) return -1;
|
||||
|
||||
IdePassThroughDirect iptd = new IdePassThroughDirect
|
||||
{
|
||||
CurrentTaskFile = new AtaTaskFile
|
||||
{
|
||||
Command = registers.Command,
|
||||
CylinderHigh = registers.LbaHigh,
|
||||
CylinderLow = registers.LbaMid,
|
||||
DeviceHead = registers.DeviceHead,
|
||||
Features = registers.Feature,
|
||||
SectorCount = registers.SectorCount,
|
||||
SectorNumber = registers.LbaLow
|
||||
},
|
||||
DataBufferSize = 512,
|
||||
DataBuffer = new byte[512]
|
||||
};
|
||||
|
||||
uint k = 0;
|
||||
int error = 0;
|
||||
|
||||
Array.Copy(buffer, 0, iptd.DataBuffer, 0, buffer.Length);
|
||||
|
||||
DateTime start = DateTime.Now;
|
||||
sense = !Extern.DeviceIoControlIde(fd, WindowsIoctl.IoctlIdePassThrough, ref iptd,
|
||||
(uint)Marshal.SizeOf(iptd), ref iptd, (uint)Marshal.SizeOf(iptd), ref k,
|
||||
IntPtr.Zero);
|
||||
DateTime end = DateTime.Now;
|
||||
|
||||
if(sense) error = Marshal.GetLastWin32Error();
|
||||
|
||||
buffer = new byte[k - 12];
|
||||
Array.Copy(iptd.DataBuffer, 0, buffer, 0, buffer.Length);
|
||||
|
||||
duration = (end - start).TotalMilliseconds;
|
||||
|
||||
errorRegisters.LbaHigh = iptd.CurrentTaskFile.CylinderHigh;
|
||||
errorRegisters.LbaMid = iptd.CurrentTaskFile.CylinderLow;
|
||||
errorRegisters.DeviceHead = iptd.CurrentTaskFile.DeviceHead;
|
||||
errorRegisters.Error = iptd.CurrentTaskFile.Error;
|
||||
errorRegisters.LbaLow = iptd.CurrentTaskFile.SectorNumber;
|
||||
errorRegisters.SectorCount = iptd.CurrentTaskFile.SectorCount;
|
||||
errorRegisters.Status = iptd.CurrentTaskFile.Status;
|
||||
|
||||
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device number for a specified handle
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user