diff options
author | sr55 <[email protected]> | 2011-01-12 19:43:35 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2011-01-12 19:43:35 +0000 |
commit | 6d44f4db6459a4cec248130438319aa18b86ac1c (patch) | |
tree | 98942352b17ad4d312b89d80f8e113e3ec22e8df /win/C#/Functions | |
parent | 0b05e9e8f2c85651da0c1098d3a8278e91482fbd (diff) |
WinGui:
- Switch to using a SHA1 hash of the cli executable to make cli exe version validation more reliable.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3741 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Functions')
-rw-r--r-- | win/C#/Functions/Main.cs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index 2edfd1568..8f7cea326 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -10,6 +10,7 @@ namespace Handbrake.Functions using System.Diagnostics;
using System.IO;
using System.Linq;
+ using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
@@ -291,15 +292,22 @@ namespace Handbrake.Functions // 0 = SVN Build / Version
// 1 = Build Date
- DateTime lastModified = File.GetLastWriteTime("HandBrakeCLI.exe");
- if (Properties.Settings.Default.hb_build != 0 && Properties.Settings.Default.cliLastModified == lastModified)
+ // Get the SHA1 Hash of HandBrakeCLI
+ byte[] hash;
+ using (Stream stream = File.OpenRead("HandBrakeCLI.exe"))
+ {
+ hash = SHA1.Create().ComputeHash(stream);
+ }
+ string base64Hash = Convert.ToBase64String(hash);
+
+ // Compare the hash with the last known hash. If it's the same, return.
+ if (Properties.Settings.Default.CliExeHash == base64Hash)
{
return;
}
- Properties.Settings.Default.cliLastModified = lastModified;
-
+ // It's not the same, so start the CLI to get it's version data.
Process cliProcess = new Process();
ProcessStartInfo handBrakeCli = new ProcessStartInfo("HandBrakeCLI.exe", " -u -v0")
{
@@ -350,11 +358,14 @@ namespace Handbrake.Functions }
}
+ Properties.Settings.Default.CliExeHash = base64Hash;
+
Properties.Settings.Default.Save();
}
catch (Exception e)
{
Properties.Settings.Default.hb_build = 0;
+ Properties.Settings.Default.CliExeHash = null;
Properties.Settings.Default.Save();
ShowExceptiowWindow("Unable to retrieve version information from the CLI.", e.ToString());
|