More robust detection of samsung nvme drives (#674)
Thanks to @bjarniivarsson
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
// All Rights Reserved.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibreHardwareMonitor.Interop;
|
||||
|
||||
@@ -237,15 +238,21 @@ namespace LibreHardwareMonitor.Hardware.Storage
|
||||
validTransfer = Kernel32.DeviceIoControl(handle, Kernel32.IOCTL.IOCTL_SCSI_PASS_THROUGH, buffer, length, buffer, length, out _, IntPtr.Zero);
|
||||
if (validTransfer)
|
||||
{
|
||||
Marshal.PtrToStructure<Kernel32.SCSI_PASS_THROUGH_WITH_BUFFERS>(buffer);
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
var result = Marshal.PtrToStructure<Kernel32.SCSI_PASS_THROUGH_WITH_BUFFERS>(buffer);
|
||||
|
||||
if (result.DataBuf.Sum(x => (long)x) == 0)
|
||||
{
|
||||
handle.Close();
|
||||
handle = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
handle.Close();
|
||||
handle = null;
|
||||
}
|
||||
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
}
|
||||
|
||||
return handle;
|
||||
|
||||
@@ -19,20 +19,10 @@ namespace LibreHardwareMonitor.Hardware.Storage
|
||||
{
|
||||
_driveNumber = storageInfo.Index;
|
||||
NVMeDrive = null;
|
||||
|
||||
// Test samsung protocol.
|
||||
|
||||
// Exclude Samsung 980 Pro and PM9A1, these use the NVMeWindows generic protocol.
|
||||
// Samsung 980 Pro can accessed via IdentifyDevice and IdentifyController but not by HealthInfoLog.
|
||||
string name = storageInfo.Name;
|
||||
|
||||
if (NVMeDrive == null &&
|
||||
name.IndexOf("Samsung", StringComparison.OrdinalIgnoreCase) > -1 &&
|
||||
name.IndexOf("980 Pro", StringComparison.OrdinalIgnoreCase) == -1 &&
|
||||
name.IndexOf("MZVL2256HCHQ", StringComparison.OrdinalIgnoreCase) == -1 &&
|
||||
name.IndexOf("MZVL2512HCJQ", StringComparison.OrdinalIgnoreCase) == -1 &&
|
||||
name.IndexOf("MZVL21T0HCLR", StringComparison.OrdinalIgnoreCase) == -1 &&
|
||||
name.IndexOf("MZVL22T0HBLB", StringComparison.OrdinalIgnoreCase) == -1)
|
||||
// Test Samsung protocol.
|
||||
if (NVMeDrive == null && name.IndexOf("Samsung", StringComparison.OrdinalIgnoreCase) > -1)
|
||||
{
|
||||
_handle = NVMeSamsung.IdentifyDevice(storageInfo);
|
||||
if (_handle != null)
|
||||
|
||||
Reference in New Issue
Block a user