diff --git a/EnvyUpdate/Debug.cs b/EnvyUpdate/Debug.cs index 5d7e5fd..676384b 100644 --- a/EnvyUpdate/Debug.cs +++ b/EnvyUpdate/Debug.cs @@ -16,9 +16,9 @@ namespace EnvyUpdate switch (idType) { case "psid": - return 101; + return 127; case "pfid": - return 845; + return 999; case "osid": return 57; case "dtcid": @@ -36,7 +36,7 @@ namespace EnvyUpdate public static string GPUname() { - return "Nvidia GeForce GTX 1080ti (debug)"; + return "Nvidia GeForce RTX 4080 (debug)"; } } } diff --git a/EnvyUpdate/GlobalVars.cs b/EnvyUpdate/GlobalVars.cs index 57c5f1e..249bb54 100644 --- a/EnvyUpdate/GlobalVars.cs +++ b/EnvyUpdate/GlobalVars.cs @@ -7,7 +7,7 @@ namespace EnvyUpdate { public static bool isMobile = false; 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 exedirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; public static readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); public static readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs index 25c49dd..ecdb465 100644 --- a/EnvyUpdate/MainWindow.xaml.cs +++ b/EnvyUpdate/MainWindow.xaml.cs @@ -135,8 +135,8 @@ namespace EnvyUpdate else radioGRD.IsChecked = true; - if (File.Exists(GlobalVars.exepath + "skip.envy")) - skippedVer = File.ReadLines(GlobalVars.exepath + "skip.envy").First(); + if (File.Exists(GlobalVars.exedirectory + "skip.envy")) + skippedVer = File.ReadLines(GlobalVars.exedirectory + "skip.envy").First(); // This little bool check is necessary for debug mode on systems without an Nvidia GPU. if (Debug.isDebug) @@ -155,19 +155,19 @@ namespace EnvyUpdate try { // disable SD and try with GRD - if (File.Exists(GlobalVars.exepath + "sd.envy")) + if (File.Exists(GlobalVars.exedirectory + "sd.envy")) { - File.Delete(GlobalVars.exepath + "sd.envy"); + File.Delete(GlobalVars.exedirectory + "sd.envy"); } gpuURL = Util.GetGpuUrl(); //try again with GRD MessageBox.Show(Properties.Resources.ui_studionotsupported); radioGRD.IsChecked = true; } - catch (ArgumentException) + catch (ArgumentException e) { // Now we have a problem. - MessageBox.Show("ERROR: Invalid API response from Nvidia. Please file an issue on GitHub."); + MessageBox.Show("ERROR: Invalid API response from Nvidia. Please file an issue on GitHub.\nAttempted API call:\n" + e.Message); Environment.Exit(10); } } @@ -231,8 +231,8 @@ namespace EnvyUpdate if (skippedVer != onlineDriv) { skippedVer = null; - if (File.Exists(GlobalVars.exepath + "skip.envy")) - File.Delete(GlobalVars.exepath + "skip.envy"); + if (File.Exists(GlobalVars.exedirectory + "skip.envy")) + File.Delete(GlobalVars.exedirectory + "skip.envy"); buttonSkip.Content = Properties.Resources.ui_skipversion; buttonSkip.IsEnabled = true; } @@ -267,7 +267,7 @@ namespace EnvyUpdate { File.Delete(GlobalVars.startmenu + "\\EnvyUpdate.lnk"); } - if ((GlobalVars.exepath == GlobalVars.appdata) && File.Exists(GlobalVars.appdata + "EnvyUpdate.exe")) + if ((GlobalVars.exedirectory == GlobalVars.appdata) && File.Exists(GlobalVars.appdata + "EnvyUpdate.exe")) { MessageBox.Show(Properties.Resources.uninstall_legacy_message); Util.SelfDelete(); @@ -291,18 +291,18 @@ namespace EnvyUpdate private void radioGRD_Checked(object sender, RoutedEventArgs e) { - if (File.Exists(GlobalVars.exepath + "sd.envy")) + if (File.Exists(GlobalVars.exedirectory + "sd.envy")) { - File.Delete(GlobalVars.exepath + "sd.envy"); + File.Delete(GlobalVars.exedirectory + "sd.envy"); Load(); } } private void radioSD_Checked(object sender, RoutedEventArgs e) { - if (!File.Exists(GlobalVars.exepath + "sd.envy")) + if (!File.Exists(GlobalVars.exedirectory + "sd.envy")) { - File.Create(GlobalVars.exepath + "sd.envy").Close(); + File.Create(GlobalVars.exedirectory + "sd.envy").Close(); Load(); } } @@ -322,7 +322,7 @@ namespace EnvyUpdate private void buttonSkip_Click(object sender, RoutedEventArgs e) { skippedVer = onlineDriv; - File.WriteAllText(GlobalVars.exepath + "skip.envy", onlineDriv); + File.WriteAllText(GlobalVars.exedirectory + "skip.envy", onlineDriv); buttonSkip.IsEnabled = false; buttonSkip.Content = Properties.Resources.ui_skipped; MessageBox.Show(Properties.Resources.skip_confirm); diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index 572ae2d..7ad428b 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -384,7 +384,7 @@ namespace EnvyUpdate */ //TODO: find way to differentiate between driver types - if (System.IO.File.Exists(GlobalVars.exepath + "sd.envy")) + if (System.IO.File.Exists(GlobalVars.exedirectory + "sd.envy")) return 18; else return 1; @@ -414,39 +414,40 @@ namespace EnvyUpdate dtcid = GetDTCID(); dtid = GetDTID(); } - string gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString() + "&dtcid=" + dtcid.ToString() + "&dtid=" + dtid.ToString(); // + "&lid=" + langid.ToString(); + string gpuUrlBuild = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString() + "&dtcid=" + dtcid.ToString() + "&dtid=" + dtid.ToString(); + string gpuUrl; using (var c = new WebClient()) { - gpuURL = c.DownloadString(gpuURL); - if (gpuURL.Contains("https://") || gpuURL.Contains("http://")) + gpuUrl = c.DownloadString(gpuUrlBuild); + if (gpuUrl.Contains("https://") || gpuUrl.Contains("http://")) { //absolute url } - else if (gpuURL.Contains("//")) + else if (gpuUrl.Contains("//")) { //protocol agnostic url - gpuURL = "https:" + gpuURL; + gpuUrl = "https:" + gpuUrl; } - else if (gpuURL.StartsWith("driverResults.aspx")) + else if (gpuUrl.StartsWith("driverResults.aspx")) { //relative url - gpuURL = "https://www.nvidia.com/Download/" + gpuURL; + gpuUrl = "https://www.nvidia.com/Download/" + gpuUrl; } - else if (gpuURL.Contains("No certified downloads were found")) + else if (gpuUrl.Contains("No certified downloads were found")) { //configuration not supported - throw new ArgumentException(); + throw new ArgumentException(gpuUrlBuild); } else { //panic. - MessageBox.Show("ERROR: Invalid API response from Nvidia. Please file an issue on GitHub."); + MessageBox.Show("ERROR: Invalid API response from Nvidia - unexpected web response. Please file an issue on GitHub."); Environment.Exit(10); } } - return gpuURL; + return gpuUrl; } public static void DownloadFile(string fileURL, string savePath)