File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments