mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: Remove unneeded code.
This commit is contained in:
@@ -136,19 +136,19 @@ namespace DiscImageChef.Devices.Windows
|
||||
|
||||
if(descriptor.VendorIdOffset > 0)
|
||||
info.Vendor =
|
||||
StringHandlers.CToString(descriptorB, Encoding.ASCII, start: (int)descriptor.VendorIdOffset);
|
||||
StringHandlers.CToString(descriptorB, Encoding.ASCII, start: descriptor.VendorIdOffset);
|
||||
if(descriptor.ProductIdOffset > 0)
|
||||
info.Model =
|
||||
StringHandlers.CToString(descriptorB, Encoding.ASCII, start: (int)descriptor.ProductIdOffset);
|
||||
StringHandlers.CToString(descriptorB, Encoding.ASCII, start: descriptor.ProductIdOffset);
|
||||
// TODO: Get serial number of SCSI and USB devices, probably also FireWire (untested)
|
||||
if(descriptor.SerialNumberOffset > 0)
|
||||
{
|
||||
info.Serial =
|
||||
StringHandlers.CToString(descriptorB, Encoding.ASCII,
|
||||
start: (int)descriptor.SerialNumberOffset);
|
||||
start: descriptor.SerialNumberOffset);
|
||||
|
||||
// fix any serial numbers that are returned as hex-strings
|
||||
if(Array.TrueForAll(info.Serial.ToCharArray(), (char c) => "0123456789abcdef".IndexOf(c) >= 0)
|
||||
if(Array.TrueForAll(info.Serial.ToCharArray(), c => "0123456789abcdef".IndexOf(c) >= 0)
|
||||
&& info.Serial.Length == 40) info.Serial = HexStringToString(info.Serial).Trim();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
@@ -486,7 +487,7 @@ namespace DiscImageChef.Devices.Windows
|
||||
//
|
||||
// Return a list of USB Host Controllers
|
||||
//
|
||||
static internal System.Collections.ObjectModel.ReadOnlyCollection<UsbController> GetHostControllers()
|
||||
static internal ReadOnlyCollection<UsbController> GetHostControllers()
|
||||
{
|
||||
List<UsbController> hostList = new List<UsbController>();
|
||||
Guid hostGuid = new Guid(GUID_DEVINTERFACE_HUBCONTROLLER);
|
||||
@@ -495,7 +496,7 @@ namespace DiscImageChef.Devices.Windows
|
||||
// devices that match the interface GUID of a Hub Controller
|
||||
IntPtr h = SetupDiGetClassDevs(ref hostGuid, 0, IntPtr.Zero, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
||||
if(h.ToInt32() == INVALID_HANDLE_VALUE)
|
||||
return new System.Collections.ObjectModel.ReadOnlyCollection<UsbController>(hostList);
|
||||
return new ReadOnlyCollection<UsbController>(hostList);
|
||||
|
||||
IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
|
||||
bool success;
|
||||
@@ -547,7 +548,7 @@ namespace DiscImageChef.Devices.Windows
|
||||
SetupDiDestroyDeviceInfoList(h);
|
||||
|
||||
// convert it into a Collection
|
||||
return new System.Collections.ObjectModel.ReadOnlyCollection<UsbController>(hostList);
|
||||
return new ReadOnlyCollection<UsbController>(hostList);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -732,7 +733,7 @@ namespace DiscImageChef.Devices.Windows
|
||||
}
|
||||
|
||||
// return a list of the down stream ports
|
||||
internal System.Collections.ObjectModel.ReadOnlyCollection<UsbPort> GetPorts()
|
||||
internal ReadOnlyCollection<UsbPort> GetPorts()
|
||||
{
|
||||
List<UsbPort> portList = new List<UsbPort>();
|
||||
|
||||
@@ -740,7 +741,7 @@ namespace DiscImageChef.Devices.Windows
|
||||
IntPtr h = CreateFile(HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
|
||||
IntPtr.Zero);
|
||||
if(h.ToInt32() == INVALID_HANDLE_VALUE)
|
||||
return new System.Collections.ObjectModel.ReadOnlyCollection<UsbPort>(portList);
|
||||
return new ReadOnlyCollection<UsbPort>(portList);
|
||||
|
||||
int nBytes = Marshal.SizeOf(typeof(UsbNodeConnectionInformationEx));
|
||||
IntPtr ptrNodeConnection = Marshal.AllocHGlobal(nBytes);
|
||||
@@ -783,7 +784,7 @@ namespace DiscImageChef.Devices.Windows
|
||||
Marshal.FreeHGlobal(ptrNodeConnection);
|
||||
CloseHandle(h);
|
||||
// convert it into a Collection
|
||||
return new System.Collections.ObjectModel.ReadOnlyCollection<UsbPort>(portList);
|
||||
return new ReadOnlyCollection<UsbPort>(portList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -956,7 +957,7 @@ namespace DiscImageChef.Devices.Windows
|
||||
// build a request for configuration descriptor
|
||||
UsbDescriptorRequest dcrRequest = new UsbDescriptorRequest();
|
||||
dcrRequest.ConnectionIndex = PortPortNumber;
|
||||
dcrRequest.SetupPacket.wValue = (short)(USB_CONFIGURATION_DESCRIPTOR_TYPE << 8);
|
||||
dcrRequest.SetupPacket.wValue = USB_CONFIGURATION_DESCRIPTOR_TYPE << 8;
|
||||
dcrRequest.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(dcrRequest));
|
||||
dcrRequest.SetupPacket.wIndex = 0;
|
||||
// Geez, I wish C# had a Marshal.MemSet() method
|
||||
|
||||
Reference in New Issue
Block a user