Hardware/HDD/SMART.cs
changeset 218 194186efdde9
parent 195 0ee888c485d5
child 231 30f5a06f5d8a
     1.1 --- a/Hardware/HDD/SMART.cs	Thu Oct 07 19:34:36 2010 +0000
     1.2 +++ b/Hardware/HDD/SMART.cs	Fri Oct 08 12:18:32 2010 +0000
     1.3 @@ -19,7 +19,7 @@
     1.4    Portions created by the Initial Developer are Copyright (C) 2009-2010
     1.5    the Initial Developer. All Rights Reserved.
     1.6  
     1.7 -  Contributor(s):
     1.8 +  Contributor(s): Paul Werelds
     1.9  
    1.10    Alternatively, the contents of this file may be used under the terms of
    1.11    either the GNU General Public License Version 2 or later (the "GPL"), or
    1.12 @@ -36,6 +36,7 @@
    1.13  */
    1.14  
    1.15  using System;
    1.16 +using System.Collections.Generic;
    1.17  using System.Runtime.InteropServices;
    1.18  
    1.19  namespace OpenHardwareMonitor.Hardware.HDD {
    1.20 @@ -77,6 +78,14 @@
    1.21        DriveTemperature = 0xE7
    1.22      }
    1.23  
    1.24 +    public enum SSDLifeID {
    1.25 +      None = 0x00,
    1.26 +      Indilinx = 0xD1,
    1.27 +      Intel = 0xE8,
    1.28 +      Samsung = 0xB4,
    1.29 +      SandForce = 0xE7
    1.30 +    }
    1.31 +
    1.32      [StructLayout(LayoutKind.Sequential, Pack = 1)]
    1.33      public struct DriveAttribute {
    1.34        public AttributeID ID;
    1.35 @@ -257,7 +266,9 @@
    1.36          IntPtr.Zero);
    1.37      }
    1.38  
    1.39 -    public static DriveAttribute[] ReadSmart(IntPtr handle, int driveNumber) {
    1.40 +    public static List<DriveAttribute> ReadSmart(IntPtr handle,
    1.41 +      int driveNumber)
    1.42 +    {
    1.43        DriveCommandParameter parameter = new DriveCommandParameter();
    1.44        DriveSmartReadResult result;
    1.45        uint bytesReturned;
    1.46 @@ -268,15 +279,14 @@
    1.47        parameter.Registers.LBAHigh = SMART_LBA_HI;
    1.48        parameter.Registers.Command = SMART_CMD;
    1.49  
    1.50 -      bool valid = NativeMethods.DeviceIoControl(handle, 
    1.51 +      bool isValid = NativeMethods.DeviceIoControl(handle, 
    1.52          DriveCommand.ReceiveDriveData, ref parameter, Marshal.SizeOf(parameter), 
    1.53          out result, Marshal.SizeOf(typeof(DriveSmartReadResult)), 
    1.54          out bytesReturned, IntPtr.Zero);
    1.55  
    1.56 -      if (!valid)
    1.57 -        return null;
    1.58 -      else
    1.59 -        return result.Attributes;
    1.60 +      return (isValid)
    1.61 +        ? new List<DriveAttribute>(result.Attributes)
    1.62 +        : new List<DriveAttribute>();
    1.63      }
    1.64  
    1.65      public static string ReadName(IntPtr handle, int driveNumber) {