From 4e58a588f12565c171320236e66903d89fe8eb38 Mon Sep 17 00:00:00 2001 From: fyr77 Date: Wed, 19 Aug 2020 19:35:21 +0200 Subject: [PATCH 001/139] add IsDCH function --- EnvyUpdate/Util.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index 6f2be10..015b6fd 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -11,6 +11,7 @@ using System.Xml; using System.Xml.Linq; using System.Text.RegularExpressions; using System.Runtime.InteropServices; +using Microsoft.Win32; namespace EnvyUpdate { @@ -368,5 +369,10 @@ namespace EnvyUpdate return result; } + public static bool IsDCH() + { + RegistryKey nvlddmkm = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\services\nvlddmkm", true); + return nvlddmkm.GetValueNames().Contains("DCHUVen"); + } } } \ No newline at end of file From 58631d5d8a30d82f5b75241bfdd6a39b549da7dc Mon Sep 17 00:00:00 2001 From: fyr77 Date: Thu, 3 Sep 2020 22:24:22 +0200 Subject: [PATCH 002/139] fix potential memory leak --- EnvyUpdate/Util.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index 015b6fd..2d0cdfc 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -108,12 +108,15 @@ namespace EnvyUpdate { // This will fetch the most recent version's tag on GitHub. string updPath = "https://api.github.com/repos/fyr77/envyupdate/releases/latest"; + dynamic data = null; - WebClient wc = new WebClient(); - // Use some user agent to not get 403'd by GitHub. - wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko"); - string webData = wc.DownloadString(updPath); - dynamic data = JsonConvert.DeserializeObject(webData); + using (var wc = new WebClient()) + { + // Use some user agent to not get 403'd by GitHub. + wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko"); + string webData = wc.DownloadString(updPath); + data = JsonConvert.DeserializeObject(webData); + } // I am not catching a possible parsing exception, because I cannot think of any way it could happen. // If there is no internet connection, it should already throw when using the web client. From a42641fdcef695554b2ae70546665a3e552fe2c0 Mon Sep 17 00:00:00 2001 From: fyr77 Date: Sun, 6 Sep 2020 11:03:04 +0200 Subject: [PATCH 003/139] add DCH compat, better debug --- EnvyUpdate/Debug.cs | 49 ++++++++++++ EnvyUpdate/EnvyUpdate.csproj | 1 + EnvyUpdate/GlobalVars.cs | 2 +- EnvyUpdate/InfoWindow.xaml | 22 +++--- EnvyUpdate/InfoWindow.xaml.cs | 5 +- EnvyUpdate/MainWindow.xaml | 2 +- EnvyUpdate/MainWindow.xaml.cs | 82 ++++++++++++--------- EnvyUpdate/Properties/AssemblyInfo.cs | 4 +- EnvyUpdate/Properties/Resources.Designer.cs | 9 +++ EnvyUpdate/Properties/Resources.de.resx | 3 + EnvyUpdate/Properties/Resources.resx | 3 + EnvyUpdate/Util.cs | 29 +++++++- 12 files changed, 157 insertions(+), 54 deletions(-) create mode 100644 EnvyUpdate/Debug.cs diff --git a/EnvyUpdate/Debug.cs b/EnvyUpdate/Debug.cs new file mode 100644 index 0000000..3b4d7f0 --- /dev/null +++ b/EnvyUpdate/Debug.cs @@ -0,0 +1,49 @@ +using System; +using System.Linq; + +namespace EnvyUpdate +{ + class Debug + { + readonly static string debugFilePath = GlobalVars.exepath + "debug.txt"; + public static int LoadFakeIDs(string idType) + { + /* + * Usage: + * Create debug.txt file. + * Fill in variables: + * Line 1: psid + * Line 2: pfid + * Line 3: osid + * Line 4: dtcid + * Line 5: Local driver version + * + * Supply /debug flag to exe. + */ + string line = null; + switch (idType) + { + case "psid": + line = File.ReadLines(debugFilePath).Take(1).First(); + break; + case "pfid": + line = File.ReadLines(debugFilePath).Skip(1).Take(1).First(); + break; + case "osid": + line = File.ReadLines(debugFilePath).Skip(2).Take(1).First(); + break; + case "dtcid": + line = File.ReadLines(debugFilePath).Skip(3).Take(1).First(); + break; + default: + break; + } + + return int.Parse(line); + } + public static string LocalDriv() + { + return File.ReadLines(debugFilePath).Skip(4).Take(1).First(); + } + } +} diff --git a/EnvyUpdate/EnvyUpdate.csproj b/EnvyUpdate/EnvyUpdate.csproj index edc0a08..4d0512f 100644 --- a/EnvyUpdate/EnvyUpdate.csproj +++ b/EnvyUpdate/EnvyUpdate.csproj @@ -95,6 +95,7 @@ MSBuild:Compile Designer + InfoWindow.xaml diff --git a/EnvyUpdate/GlobalVars.cs b/EnvyUpdate/GlobalVars.cs index 402384c..352f9cb 100644 --- a/EnvyUpdate/GlobalVars.cs +++ b/EnvyUpdate/GlobalVars.cs @@ -9,7 +9,7 @@ namespace EnvyUpdate public static readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location; public static readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; public static readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); - public static readonly float version = 2.3F; + public static readonly float version = 2.4F; public static readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); public static readonly string desktopOverride = exepath + "desktop.envy"; diff --git a/EnvyUpdate/InfoWindow.xaml b/EnvyUpdate/InfoWindow.xaml index 9987dc9..66d475f 100644 --- a/EnvyUpdate/InfoWindow.xaml +++ b/EnvyUpdate/InfoWindow.xaml @@ -6,19 +6,19 @@ xmlns:local="clr-namespace:EnvyUpdate" xmlns:p="clr-namespace:EnvyUpdate.Properties" mc:Ignorable="d" - Title="" Height="274" Width="286" ResizeMode="NoResize" WindowStyle="ToolWindow" SizeToContent="WidthAndHeight"> + Title="" Height="290" Width="286" ResizeMode="NoResize" WindowStyle="ToolWindow" SizeToContent="WidthAndHeight">