Skip to content

Commit 4b911d5

Browse files
committed
Do not cache AGESA version; Remove setting encryption
1 parent 242adad commit 4b911d5

3 files changed

Lines changed: 75 additions & 70 deletions

File tree

WPF/AppSettings.cs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22
using System;
33
using System.IO;
44
using System.Windows;
5-
using ZenTimings.Encryption;
65

76
namespace ZenTimings
87
{
98
[Serializable]
109
public sealed class AppSettings
1110
{
1211
public const int VersionMajor = 1;
13-
public const int VersionMinor = 8;
12+
public const int VersionMinor = 9;
1413

1514
private static readonly string Filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.xml");
16-
private static readonly string EncryptedFilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.enc");
15+
//private static readonly string EncryptedFilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.enc");
1716
public const string AGESA_UNKNOWN = "Unknown";
1817

1918
private static AppSettings _instance = null;
20-
private readonly AesEncryption aesEncryption = new AesEncryption();
19+
//private readonly AesEncryption aesEncryption = new AesEncryption();
2120

2221
private AppSettings() { }
2322

@@ -54,10 +53,10 @@ public enum ScreenshotType : int
5453

5554
public AppSettings Create(bool save = true)
5655
{
57-
if (File.Exists(EncryptedFilename))
58-
{
59-
AgesaVersion = aesEncryption.DecryptStringInMemory(EncryptedFilename);
60-
}
56+
//if (File.Exists(EncryptedFilename))
57+
//{
58+
// AgesaVersion = aesEncryption.DecryptStringInMemory(EncryptedFilename);
59+
//}
6160

6261
if (save) Save();
6362

@@ -70,24 +69,25 @@ public AppSettings Load()
7069
{
7170
try
7271
{
73-
var decryptedAgesa = String.Empty;
74-
if (File.Exists(EncryptedFilename))
75-
{
76-
try
77-
{
78-
decryptedAgesa = aesEncryption.DecryptStringInMemory(EncryptedFilename);
79-
}
80-
catch (Exception ex)
81-
{
82-
Console.WriteLine(ex.Message);
83-
}
84-
}
72+
//var decryptedAgesa = String.Empty;
73+
//if (File.Exists(EncryptedFilename))
74+
//{
75+
// try
76+
// {
77+
// decryptedAgesa = aesEncryption.DecryptStringInMemory(EncryptedFilename);
78+
// }
79+
// catch (Exception ex)
80+
// {
81+
// Console.WriteLine(ex.Message);
82+
// }
83+
//}
8584

8685
if (File.Exists(Filename))
8786
{
88-
var deserializedSettings = XmlUtils.DeserializeFromXml<AppSettings>(Filename);
89-
deserializedSettings.AgesaVersion = decryptedAgesa;
90-
return deserializedSettings;
87+
//var deserializedSettings = XmlUtils.DeserializeFromXml<AppSettings>(Filename);
88+
//deserializedSettings.AgesaVersion = decryptedAgesa;
89+
//return deserializedSettings;
90+
return XmlUtils.DeserializeFromXml<AppSettings>(Filename);
9191
}
9292
}
9393
catch (Exception ex)
@@ -112,18 +112,18 @@ public void Save()
112112

113113
Version = new Version(VersionMajor, VersionMinor).ToString();
114114

115-
if (CpuSingleton.Instance?.systemInfo != null)
116-
{
117-
MbName = CpuSingleton.Instance.systemInfo.MbName;
118-
BiosVersion = CpuSingleton.Instance.systemInfo.BiosVersion;
119-
SmuVersion = CpuSingleton.Instance.systemInfo.GetSmuVersionString();
120-
if (!string.IsNullOrEmpty(CpuSingleton.Instance.systemInfo.AgesaVersion))
121-
{
122-
AgesaVersion = CpuSingleton.Instance.systemInfo.AgesaVersion;
123-
}
124-
}
125-
126-
File.WriteAllBytes(EncryptedFilename, aesEncryption.EncryptString(this.AgesaVersion));
115+
//if (CpuSingleton.Instance?.systemInfo != null)
116+
//{
117+
// MbName = CpuSingleton.Instance.systemInfo.MbName;
118+
// BiosVersion = CpuSingleton.Instance.systemInfo.BiosVersion;
119+
// SmuVersion = CpuSingleton.Instance.systemInfo.GetSmuVersionString();
120+
// if (!string.IsNullOrEmpty(CpuSingleton.Instance.systemInfo.AgesaVersion))
121+
// {
122+
// AgesaVersion = CpuSingleton.Instance.systemInfo.AgesaVersion;
123+
// }
124+
//}
125+
126+
//File.WriteAllBytes(EncryptedFilename, aesEncryption.EncryptString(this.AgesaVersion));
127127
string xmlContent = XmlUtils.SerializeToXml<AppSettings>(this);
128128
File.WriteAllText(Filename, xmlContent);
129129
}
@@ -175,10 +175,10 @@ public void ChangeTheme()
175175
public double SysInfoWindowWidth { get; set; }
176176
public double SysInfoWindowHeight { get; set; }
177177
public string NotifiedChangelog { get; set; } = "";
178-
public string MbName { get; set; } = "";
179-
public string BiosVersion { get; set; } = "";
180-
public string SmuVersion { get; set; } = "";
181-
public string AgesaVersion { get; set; } = "";
178+
//public string MbName { get; set; } = "";
179+
//public string BiosVersion { get; set; } = "";
180+
//public string SmuVersion { get; set; } = "";
181+
//public string AgesaVersion { get; set; } = "";
182182
public bool SingleInstance { get; set; } = true;
183183
}
184184
}

WPF/MainWindow.xaml.cs

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ public MainWindow()
170170
compatMode,
171171
settings,
172172
plugins,
173-
motherboardLogoName
173+
motherboardLogoName,
174+
GetAgesaVersion()
174175
);
175176

176177
DataContext = mainViewModel;
@@ -883,10 +884,10 @@ private void AdonisWindow_Loaded(object sender, RoutedEventArgs e)
883884
//#endif
884885
MinimizeFootprint();
885886

886-
new Thread(() =>
887-
{
888-
mainViewModel.AgesaVersion = GetAgesaVersion();
889-
}).Start();
887+
//new Thread(() =>
888+
//{
889+
// mainViewModel.AgesaVersion = GetAgesaVersion();
890+
//}).Start();
890891
}
891892

892893
private void OptionsToolStripMenuItem_Click(object sender, RoutedEventArgs e)
@@ -1029,21 +1030,21 @@ private void MotherboardLinkButton_Click(object sender, RoutedEventArgs e)
10291030
Process.Start(link);
10301031
}
10311032

1032-
private bool IsAgesaVersionUpdateNeeded()
1033-
{
1034-
if (!settings.AdvancedMode)
1035-
return false;
1033+
//private bool IsAgesaVersionUpdateNeeded()
1034+
//{
1035+
// if (!settings.AdvancedMode)
1036+
// return false;
10361037

1037-
string smuVersion = cpu.systemInfo.GetSmuVersionString();
1038-
bool biosVersionMatches = !string.IsNullOrEmpty(cpu.systemInfo.BiosVersion)
1039-
&& string.Equals(cpu.systemInfo.BiosVersion, settings.BiosVersion, StringComparison.Ordinal);
1040-
bool mbNameMatches = !string.IsNullOrEmpty(cpu.systemInfo.MbName)
1041-
&& string.Equals(cpu.systemInfo.MbName, settings.MbName, StringComparison.Ordinal);
1042-
bool smuVersionMatches = !string.IsNullOrEmpty(smuVersion)
1043-
&& string.Equals(smuVersion, settings.SmuVersion, StringComparison.Ordinal);
1038+
// string smuVersion = cpu.systemInfo.GetSmuVersionString();
1039+
// bool biosVersionMatches = !string.IsNullOrEmpty(cpu.systemInfo.BiosVersion)
1040+
// && string.Equals(cpu.systemInfo.BiosVersion, settings.BiosVersion, StringComparison.Ordinal);
1041+
// bool mbNameMatches = !string.IsNullOrEmpty(cpu.systemInfo.MbName)
1042+
// && string.Equals(cpu.systemInfo.MbName, settings.MbName, StringComparison.Ordinal);
1043+
// bool smuVersionMatches = !string.IsNullOrEmpty(smuVersion)
1044+
// && string.Equals(smuVersion, settings.SmuVersion, StringComparison.Ordinal);
10441045

1045-
return string.IsNullOrEmpty(settings.AgesaVersion) || !biosVersionMatches || !mbNameMatches || !smuVersionMatches;
1046-
}
1046+
// return string.IsNullOrEmpty(settings.AgesaVersion) || !biosVersionMatches || !mbNameMatches || !smuVersionMatches;
1047+
//}
10471048

10481049
private string GetAgesaVersion()
10491050
{
@@ -1052,17 +1053,19 @@ private string GetAgesaVersion()
10521053
return cpu.systemInfo.AgesaVersion;
10531054
}
10541055

1055-
string version;
1056-
if (IsAgesaVersionUpdateNeeded())
1057-
{
1058-
//byte[] image = AgesaHelper.DumpImage();
1059-
//version = AgesaHelper.FindAgesaVersion(image);
1060-
version = AgesaHelper.FindAgesaVersionInMemory();
1061-
}
1062-
else
1063-
{
1064-
version = settings?.AgesaVersion ?? AppSettings.AGESA_UNKNOWN;
1065-
}
1056+
string version = AgesaHelper.FindAgesaVersionInMemory();
1057+
1058+
//string version;
1059+
//if (IsAgesaVersionUpdateNeeded())
1060+
//{
1061+
// //byte[] image = AgesaHelper.DumpImage();
1062+
// //version = AgesaHelper.FindAgesaVersion(image);
1063+
// version = AgesaHelper.FindAgesaVersionInMemory();
1064+
//}
1065+
//else
1066+
//{
1067+
// version = settings?.AgesaVersion ?? AppSettings.AGESA_UNKNOWN;
1068+
//}
10661069

10671070
if (!string.IsNullOrEmpty(version))
10681071
{

WPF/ViewModels/MainViewModel.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ public MainViewModel(
119119
bool compatMode,
120120
AppSettings settings,
121121
List<IPlugin> plugins,
122-
string motherboardLogoName)
122+
string motherboardLogoName,
123+
string agesaVersion)
123124
{
124125
Timings = timings;
125126
Settings = settings;
@@ -133,7 +134,8 @@ public MainViewModel(
133134

134135
PowerTable = CpuSingleton.Instance.powerTable;
135136
CodeName = CpuSingleton.Instance.info.codeName;
136-
AgesaVersion = AGESA_SEARCHING;
137+
//AgesaVersion = AGESA_SEARCHING;
138+
AgesaVersion = agesaVersion;
137139

138140
WMIPresent = (!compatMode && memoryType == MemType.DDR4)
139141
|| memoryType == MemType.LPDDR4;

0 commit comments

Comments
 (0)