Advanced Settings Plugin downloader

This commit is contained in:
Serge
2024-01-26 15:01:14 +01:00
parent fbfbe8e730
commit 8a37520453
4 changed files with 158 additions and 35 deletions

View File

@@ -4,7 +4,9 @@
//
using GHelper.Helpers;
using System.Management;
using System.Net;
namespace Ryzen
{
@@ -52,7 +54,8 @@ namespace Ryzen
CPUName = obj["Name"].ToString();
CPUModel = obj["Caption"].ToString();
}
} catch (Exception ex)
}
catch (Exception ex)
{
Logger.WriteLine(ex.Message);
}
@@ -142,6 +145,52 @@ namespace Ryzen
return CPUName.Contains("6900H") || CPUName.Contains("7945H") || CPUName.Contains("7845H");
}
public static bool IsRingExsists()
{
string exeDir = Path.GetDirectoryName(Application.ExecutablePath);
return File.Exists(exeDir + "\\" + "WinRing0x64.dll");
}
public static void DownloadRing()
{
string requestUri = "https://github.com/seerge/g-helper/releases/latest/download/PluginAdvancedSettings.zip";
Uri uri = new Uri(requestUri);
string exeDir = Path.GetDirectoryName(Application.ExecutablePath);
string zipName = Path.GetFileName(uri.LocalPath);
string zipLocation = exeDir + "\\" + zipName;
using (WebClient client = new WebClient())
{
Logger.WriteLine(requestUri);
Logger.WriteLine(exeDir);
Logger.WriteLine(zipName);
try
{
client.DownloadFile(uri, zipLocation);
}
catch (Exception ex)
{
Logger.WriteLine(ex.Message);
Logger.WriteLine(ex.ToString());
if (!ProcessHelper.IsUserAdministrator()) ProcessHelper.RunAsAdmin("uv");
return;
}
try
{
System.IO.Compression.ZipFile.ExtractToDirectory(zipLocation, exeDir, overwriteFiles: true);
File.Delete(zipLocation);
}
catch (Exception ex)
{
Logger.WriteLine(ex.ToString());
}
}
}
public static void SetAddresses()
{