Skip to content

Commit ea41576

Browse files
committed
Add names for running threads.
Skip / Exclude SD Card Readers. Avoids long timeouts when calling IOCTL_SCSI_PASS_THROUGH for identification purposes.
1 parent fb5b424 commit ea41576

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

DiskInfoToolkit/Storage.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ internal Storage(string storageController, StorageDevice sdi)
7373

7474
GetDiskGeometry(handle);
7575

76-
GetDiskInformation(handle);
76+
IsValid = GetDiskInformation(handle);
77+
78+
if (!IsValid)
79+
{
80+
return;
81+
}
7782

7883
UpdatePartitions(handle);
7984

@@ -520,7 +525,7 @@ void GetDiskGeometry(IntPtr handle)
520525
Marshal.FreeHGlobal(buffer);
521526
}
522527

523-
void GetDiskInformation(IntPtr handle)
528+
bool GetDiskInformation(IntPtr handle)
524529
{
525530
var query = new STORAGE_PROPERTY_QUERY()
526531
{
@@ -542,10 +547,27 @@ void GetDiskInformation(IntPtr handle)
542547
SerialNumber = Marshal.PtrToStringAnsi(outBuffer + descriptor.SerialNumberOffset );
543548
Firmware = Marshal.PtrToStringAnsi(outBuffer + descriptor.ProductRevisionOffset);
544549
BusType = descriptor.BusType;
550+
551+
//Is removable media ?
552+
if (BusType == StorageBusType.BusTypeUsb
553+
&& descriptor.RemovableMedia == 1)
554+
{
555+
//Is possibly a SD Card reader ?
556+
if (ModelContains(this, "SD Card"))
557+
{
558+
Marshal.FreeHGlobal(outBuffer);
559+
Marshal.FreeHGlobal(queryPtr);
560+
561+
//Skip that
562+
return false;
563+
}
564+
}
545565
}
546566

547567
Marshal.FreeHGlobal(outBuffer);
548568
Marshal.FreeHGlobal(queryPtr);
569+
570+
return true;
549571
}
550572

551573
#endregion

DiskInfoToolkit/StorageManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ static StorageManager()
4040

4141
//Start device changed listener
4242
_DevicesChangedThread = new Thread(DevicesChangedListener);
43+
_DevicesChangedThread.Name = $"{nameof(StorageManager)}.{nameof(DevicesChangedListener)}";
4344
_DevicesChangedThread.IsBackground = true;
4445
_DevicesChangedThread.Start();
4546

4647
//Start message loop
4748
_MessageLoopThread = new Thread(MessageLoop);
49+
_MessageLoopThread.Name = $"{nameof(StorageManager)}.{nameof(MessageLoop)}";
4850
_MessageLoopThread.IsBackground = true;
4951
_MessageLoopThread.Start();
5052
}

0 commit comments

Comments
 (0)