mirror of
https://github.com/ckaczor/SmartHDD.git
synced 2026-01-14 01:25:41 -05:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c51d48c4a | ||
|
|
064517894d | ||
| 4e78e0764f | |||
|
|
cad7150b9b | ||
|
|
6dbf1845ec | ||
|
|
a88c91f046 | ||
|
|
7b3ca4fb85 | ||
|
|
f1c98e8a4a |
@@ -1,7 +1,7 @@
|
|||||||
#define use_dotnetfx46
|
#define use_dotnetfx46
|
||||||
|
|
||||||
#define MyAppName "SmartHDD"
|
#define MyAppName "SmartHDD"
|
||||||
#define MyAppVersion "1.0.0.0"
|
#define MyAppVersion "1.1.0.0"
|
||||||
#define MyAppPublisher "DoogeJ"
|
#define MyAppPublisher "DoogeJ"
|
||||||
#define MyAppURL "https://github.com/DoogeJ/SmartHDD"
|
#define MyAppURL "https://github.com/DoogeJ/SmartHDD"
|
||||||
#define MyAppExeName "SmartHDD.exe"
|
#define MyAppExeName "SmartHDD.exe"
|
||||||
@@ -24,6 +24,8 @@ OutputBaseFilename=Install_{#MyAppName}_{#MyAppVersion}
|
|||||||
SetupIconFile=..\Visualpharm-Hardware-Hard-disk.ico
|
SetupIconFile=..\Visualpharm-Hardware-Hard-disk.ico
|
||||||
Compression=lzma
|
Compression=lzma
|
||||||
SolidCompression=yes
|
SolidCompression=yes
|
||||||
|
UsePreviousGroup=no
|
||||||
|
UsePreviousAppDir=no
|
||||||
|
|
||||||
; we will need administrator privileges to copy to program files and / or install prerequirements
|
; we will need administrator privileges to copy to program files and / or install prerequirements
|
||||||
PrivilegesRequired=admin
|
PrivilegesRequired=admin
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -14,6 +14,12 @@ Modifications by me:
|
|||||||
## License / Copyright:
|
## License / Copyright:
|
||||||
Please see the '**LICENSE**' file.
|
Please see the '**LICENSE**' file.
|
||||||
|
|
||||||
|
# Installing
|
||||||
|
Get the latest release here: [https://github.com/DoogeJ/SmartHDD/releases](https://github.com/DoogeJ/SmartHDD/releases).
|
||||||
|
|
||||||
|
## Reporting bugs or feature requests
|
||||||
|
Please use the GitHub issue-system for bugs or feature requests: [https://github.com/DoogeJ/SmartHDD/issues](https://github.com/DoogeJ/SmartHDD/issues).
|
||||||
|
|
||||||
## Note by the original author:
|
## Note by the original author:
|
||||||
> Tested against Crystal Disk Info 5.3.1 and HD Tune Pro 3.5 on 15 Feb 2013.
|
> Tested against Crystal Disk Info 5.3.1 and HD Tune Pro 3.5 on 15 Feb 2013.
|
||||||
> Findings; I do not trust the individual smart register "OK" status reported back frm the drives.
|
> Findings; I do not trust the individual smart register "OK" status reported back frm the drives.
|
||||||
@@ -25,12 +31,14 @@ Please see the '**LICENSE**' file.
|
|||||||
This section is focussed on development of SmartHDD, in case you want to build your own version(s).
|
This section is focussed on development of SmartHDD, in case you want to build your own version(s).
|
||||||
|
|
||||||
## Environment
|
## Environment
|
||||||
This application was written using Visual Studio 2015 and .NET Framework 4.5.2 on Windows 10 1511.
|
This application was written using Visual Studio 2017 and .NET Framework 4.5.2 on Windows 10 1803.
|
||||||
It will most likely build fine on different configurations, but might require some modifications.
|
It will most likely build fine on different configurations, but might require some modifications.
|
||||||
|
|
||||||
## Updating the version number
|
## Updating the version number
|
||||||
The version number is stored in two locations:
|
The version number is stored in four locations:
|
||||||
* In the projects assembly info file: **'SmartHDD\Properties\AssemblyInfo.cs'**
|
* In the projects assembly info file: **'SmartHDD\Properties\AssemblyInfo.cs'**
|
||||||
|
* In the program header: **'SmartHDD\Program.cs'**
|
||||||
|
* In the projects C# project file: **'SmartHDD\SmartHDD.csproj'**
|
||||||
* In the installer setup.iss file (only used for the installer): **'Installer\setup.iss'**
|
* In the installer setup.iss file (only used for the installer): **'Installer\setup.iss'**
|
||||||
|
|
||||||
## Building the installer
|
## Building the installer
|
||||||
@@ -45,4 +53,4 @@ To build the installer:
|
|||||||
* Make sure the project is compiled and there is a working executable named **'SmartHDD.exe'** in the **'SmartHDD\bin\Release'**-folder
|
* Make sure the project is compiled and there is a working executable named **'SmartHDD.exe'** in the **'SmartHDD\bin\Release'**-folder
|
||||||
* Open **'Installer\setup.iss'** in the [Inno Setup Compiler](http://www.jrsoftware.org/isinfo.php)
|
* Open **'Installer\setup.iss'** in the [Inno Setup Compiler](http://www.jrsoftware.org/isinfo.php)
|
||||||
* Hit *Build* -> *Compile* (Ctrl+F9)
|
* Hit *Build* -> *Compile* (Ctrl+F9)
|
||||||
* Done, the installer should be in the **'Installer\bin'**-folder
|
* Done, the installer should be in the **'Installer\bin'**-folder
|
||||||
|
|||||||
1
SmartHDD/.gitignore
vendored
Normal file
1
SmartHDD/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.csproj.user
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -35,6 +36,9 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*** END ORIGINAL COPYRIGHT NOTICE ***
|
*** END ORIGINAL COPYRIGHT NOTICE ***
|
||||||
|
|
||||||
|
Much thanks to:
|
||||||
|
- Chris Kaczor aka @ckaczor on GitHub
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace SmartHDD
|
namespace SmartHDD
|
||||||
@@ -44,6 +48,8 @@ namespace SmartHDD
|
|||||||
{
|
{
|
||||||
|
|
||||||
public int Index { get; set; }
|
public int Index { get; set; }
|
||||||
|
public string DeviceId { get; set; }
|
||||||
|
public string InstanceName { get; set; }
|
||||||
public bool IsOK { get; set; }
|
public bool IsOK { get; set; }
|
||||||
public string Model { get; set; }
|
public string Model { get; set; }
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
@@ -222,34 +228,32 @@ namespace SmartHDD
|
|||||||
{
|
{
|
||||||
|
|
||||||
// retrieve list of drives on computer (this will return both HDD's and CDROM's and Virtual CDROM's)
|
// retrieve list of drives on computer (this will return both HDD's and CDROM's and Virtual CDROM's)
|
||||||
var dicDrives = new Dictionary<int, HDD>();
|
var dicDrives = new List<HDD>();
|
||||||
|
|
||||||
var wdSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
|
var wdSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
|
||||||
|
|
||||||
// extract model and interface information
|
// extract model and interface information
|
||||||
int iDriveIndex = 0;
|
|
||||||
foreach (ManagementObject drive in wdSearcher.Get())
|
foreach (ManagementObject drive in wdSearcher.Get())
|
||||||
{
|
{
|
||||||
var hdd = new HDD();
|
var hdd = new HDD();
|
||||||
hdd.Model = drive["Model"].ToString().Trim();
|
hdd.Model = drive["Model"].ToString().Trim();
|
||||||
hdd.Type = drive["InterfaceType"].ToString().Trim();
|
hdd.Type = drive["InterfaceType"].ToString().Trim();
|
||||||
dicDrives.Add(iDriveIndex, hdd);
|
hdd.DeviceId = drive["DeviceID"].ToString().Trim();
|
||||||
iDriveIndex++;
|
hdd.InstanceName = drive["PNPDeviceID"].ToString().Trim();
|
||||||
|
dicDrives.Add(hdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pmsearcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
|
var pmsearcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
|
||||||
|
|
||||||
// retrieve hdd serial number
|
// retrieve hdd serial number
|
||||||
iDriveIndex = 0;
|
|
||||||
foreach (ManagementObject drive in pmsearcher.Get())
|
foreach (ManagementObject drive in pmsearcher.Get())
|
||||||
{
|
{
|
||||||
// because all physical media will be returned we need to exit
|
var tag = drive["Tag"].ToString().Trim();
|
||||||
// after the hard drives serial info is extracted
|
|
||||||
if (iDriveIndex >= dicDrives.Count)
|
|
||||||
break;
|
|
||||||
|
|
||||||
dicDrives[iDriveIndex].Serial = drive["SerialNumber"] == null ? "None" : drive["SerialNumber"].ToString().Trim();
|
var dicDrive = dicDrives.FirstOrDefault(d => d.DeviceId.Equals(tag, StringComparison.InvariantCultureIgnoreCase));
|
||||||
iDriveIndex++;
|
|
||||||
|
if (dicDrive != null)
|
||||||
|
dicDrive.Serial = drive["SerialNumber"] == null ? "None" : drive["SerialNumber"].ToString().Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
// get wmi access to hdd
|
// get wmi access to hdd
|
||||||
@@ -258,18 +262,27 @@ namespace SmartHDD
|
|||||||
|
|
||||||
// check if SMART reports the drive is failing
|
// check if SMART reports the drive is failing
|
||||||
searcher.Query = new ObjectQuery("Select * from MSStorageDriver_FailurePredictStatus");
|
searcher.Query = new ObjectQuery("Select * from MSStorageDriver_FailurePredictStatus");
|
||||||
iDriveIndex = 0;
|
|
||||||
foreach (ManagementObject drive in searcher.Get())
|
foreach (ManagementObject drive in searcher.Get())
|
||||||
{
|
{
|
||||||
dicDrives[iDriveIndex].IsOK = (bool)drive.Properties["PredictFailure"].Value == false;
|
var instanceName = drive["InstanceName"].ToString().Trim();
|
||||||
iDriveIndex++;
|
|
||||||
|
var dicDrive = dicDrives.FirstOrDefault(d => instanceName.StartsWith(d.InstanceName, StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
|
if (dicDrive != null)
|
||||||
|
dicDrive.IsOK = (bool)drive.Properties["PredictFailure"].Value == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrive attribute flags, value worste and vendor data information
|
// retrive attribute flags, value worste and vendor data information
|
||||||
searcher.Query = new ObjectQuery("Select * from MSStorageDriver_FailurePredictData");
|
searcher.Query = new ObjectQuery("Select * from MSStorageDriver_FailurePredictData");
|
||||||
iDriveIndex = 0;
|
|
||||||
foreach (ManagementObject data in searcher.Get())
|
foreach (ManagementObject data in searcher.Get())
|
||||||
{
|
{
|
||||||
|
var instanceName = data["InstanceName"].ToString().Trim();
|
||||||
|
|
||||||
|
var dicDrive = dicDrives.FirstOrDefault(d => instanceName.StartsWith(d.InstanceName, StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
|
if (dicDrive == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
Byte[] bytes = (Byte[])data.Properties["VendorSpecific"].Value;
|
Byte[] bytes = (Byte[])data.Properties["VendorSpecific"].Value;
|
||||||
for (int i = 0; i < 30; ++i)
|
for (int i = 0; i < 30; ++i)
|
||||||
{
|
{
|
||||||
@@ -287,7 +300,7 @@ namespace SmartHDD
|
|||||||
int vendordata = BitConverter.ToInt32(bytes, i * 12 + 7);
|
int vendordata = BitConverter.ToInt32(bytes, i * 12 + 7);
|
||||||
if (id == 0) continue;
|
if (id == 0) continue;
|
||||||
|
|
||||||
var attr = dicDrives[iDriveIndex].Attributes[id];
|
var attr = dicDrive.Attributes[id];
|
||||||
attr.Current = value;
|
attr.Current = value;
|
||||||
attr.Worst = worst;
|
attr.Worst = worst;
|
||||||
attr.Data = vendordata;
|
attr.Data = vendordata;
|
||||||
@@ -298,15 +311,20 @@ namespace SmartHDD
|
|||||||
// given key does not exist in attribute collection (attribute not in the dictionary of attributes)
|
// given key does not exist in attribute collection (attribute not in the dictionary of attributes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iDriveIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// retreive threshold values foreach attribute
|
// retreive threshold values foreach attribute
|
||||||
searcher.Query = new ObjectQuery("Select * from MSStorageDriver_FailurePredictThresholds");
|
searcher.Query = new ObjectQuery("Select * from MSStorageDriver_FailurePredictThresholds");
|
||||||
iDriveIndex = 0;
|
|
||||||
|
|
||||||
foreach (ManagementObject data in searcher.Get())
|
foreach (ManagementObject data in searcher.Get())
|
||||||
{
|
{
|
||||||
|
var instanceName = data["InstanceName"].ToString().Trim();
|
||||||
|
|
||||||
|
var dicDrive = dicDrives.FirstOrDefault(d => instanceName.StartsWith(d.InstanceName, StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
|
if (dicDrive == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
Byte[] bytes = (Byte[])data.Properties["VendorSpecific"].Value;
|
Byte[] bytes = (Byte[])data.Properties["VendorSpecific"].Value;
|
||||||
for (int i = 0; i < 30; ++i)
|
for (int i = 0; i < 30; ++i)
|
||||||
{
|
{
|
||||||
@@ -317,7 +335,7 @@ namespace SmartHDD
|
|||||||
int thresh = bytes[i * 12 + 3];
|
int thresh = bytes[i * 12 + 3];
|
||||||
if (id == 0) continue;
|
if (id == 0) continue;
|
||||||
|
|
||||||
var attr = dicDrives[iDriveIndex].Attributes[id];
|
var attr = dicDrive.Attributes[id];
|
||||||
attr.Threshold = thresh;
|
attr.Threshold = thresh;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -325,12 +343,10 @@ namespace SmartHDD
|
|||||||
// given key does not exist in attribute collection (attribute not in the dictionary of attributes)
|
// given key does not exist in attribute collection (attribute not in the dictionary of attributes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iDriveIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteFullLine("┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐");
|
WriteFullLine("┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐");
|
||||||
WriteFullLine("│ SmartHDD by DoogeJ - https://github.com/DoogeJ/SmartHDD - (c) 2016 Jaap-Willem Dooge, 2013 Llewellyn Kruger version 1.0.0.0 │");
|
WriteFullLine("│ SmartHDD by DoogeJ - https://github.com/DoogeJ/SmartHDD - (c) 2016 Jaap-Willem Dooge, 2013 Llewellyn Kruger version 1.1.0.0 │");
|
||||||
WriteFullLine("└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘");
|
WriteFullLine("└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|
||||||
@@ -338,14 +354,14 @@ namespace SmartHDD
|
|||||||
{
|
{
|
||||||
|
|
||||||
WriteFullLine("┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐");
|
WriteFullLine("┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐");
|
||||||
WriteFullLine(string.Format("{0, -155}", string.Format("│ DRIVE ({0}): " + drive.Value.Model + " (S/N: " + drive.Value.Serial + ") - " + drive.Value.Type, ((drive.Value.IsOK) ? "OK" : "BAD"))) + "│");
|
WriteFullLine(string.Format("{0, -155}", string.Format("│ DRIVE ({0}): " + drive.Model + " (S/N: " + drive.Serial + ") - " + drive.Type, ((drive.IsOK) ? "OK" : "BAD"))) + "│");
|
||||||
WriteFullLine("├──────────────────────────────────────────────────────────────────────────────────────────────┬───────────┬───────────┬───────────┬──────────────┬────────┤");
|
WriteFullLine("├──────────────────────────────────────────────────────────────────────────────────────────────┬───────────┬───────────┬───────────┬──────────────┬────────┤");
|
||||||
WriteFullLine("│ ID │ Current │ Worst │ Threshold │ Data │ Status │");
|
WriteFullLine("│ ID │ Current │ Worst │ Threshold │ Data │ Status │");
|
||||||
|
|
||||||
bool oddLine = false;
|
bool oddLine = false;
|
||||||
ConsoleColor rowColor = ConsoleColor.DarkBlue;
|
ConsoleColor rowColor = ConsoleColor.DarkBlue;
|
||||||
|
|
||||||
foreach (var attr in drive.Value.Attributes)
|
foreach (var attr in drive.Attributes)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (attr.Value.HasData)
|
if (attr.Value.HasData)
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.1.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>1</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@@ -63,6 +78,18 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Visualpharm-Hardware-Hard-disk.ico" />
|
<Content Include="Visualpharm-Hardware-Hard-disk.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
Reference in New Issue
Block a user