diff --git a/ValorantCC/SubWindow/ProfilesWindow.xaml.cs b/ValorantCC/SubWindow/ProfilesWindow.xaml.cs index f0eef67..7d3d23b 100644 --- a/ValorantCC/SubWindow/ProfilesWindow.xaml.cs +++ b/ValorantCC/SubWindow/ProfilesWindow.xaml.cs @@ -32,7 +32,7 @@ public partial class ProfilesWindow : Window public ProfilesWindow(CrosshairProfile current, API ValCCAPI) { InitializeComponent(); - main = (MainWindow)Application.Current.MainWindow; + main = (MainWindow)this.Owner; selected = current; ValCCApi = ValCCAPI; } @@ -97,7 +97,6 @@ private async Task RenderProfiles() PublicProfile profile = PublicProfiles[i]; shareablesElement.Add(await this.GenerateRender(profile)); } - await Task.Delay(1); return true; } private async void btnSearchCode_Click(object sender, RoutedEventArgs e) diff --git a/ValorantCC/ValorantCC.csproj b/ValorantCC/ValorantCC.csproj index 6fcb22e..7a315b6 100644 --- a/ValorantCC/ValorantCC.csproj +++ b/ValorantCC/ValorantCC.csproj @@ -14,7 +14,7 @@ false - 3.0 + 3.0.0 false @@ -102,4 +102,10 @@ <_DeploymentManifestIconFile Remove="Resources\vtools-colored.ico" /> + + + PreserveNewest + + + diff --git a/ValorantCC/src/Auth.cs b/ValorantCC/src/Auth.cs index ef75fd2..6e45b45 100644 --- a/ValorantCC/src/Auth.cs +++ b/ValorantCC/src/Auth.cs @@ -78,11 +78,15 @@ public static LockfileData ObtainLockfileData(string LockfilePath) try { Utils.Log("Trying to open Lockfile"); - FileStream File = new FileStream(LockfilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - StreamReader Reader = new StreamReader(File, Encoding.UTF8); - LockfileRaw = Reader.ReadToEnd(); - File.Close(); - Reader.Close(); + using (FileStream File = new FileStream(LockfilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + using (StreamReader Reader = new StreamReader(File, Encoding.UTF8)) + { + LockfileRaw = (String)Reader.ReadToEnd().Clone(); + File.Close(); + Reader.Close(); + } + } } catch (FileNotFoundException) { diff --git a/ValorantCC/src/BackgroundAuth.cs b/ValorantCC/src/BackgroundAuth.cs index 7a70e92..85b4bfe 100644 --- a/ValorantCC/src/BackgroundAuth.cs +++ b/ValorantCC/src/BackgroundAuth.cs @@ -81,7 +81,7 @@ public async static Task LoginFlagExists() { using (StreamReader sr = new StreamReader(fileStream)) { - content = sr.ReadToEnd(); + content = (String)sr.ReadToEnd().Clone(); } } bool t = false; diff --git a/ValorantCC/src/Utils.cs b/ValorantCC/src/Utils.cs index 3fca4e9..e73794f 100644 --- a/ValorantCC/src/Utils.cs +++ b/ValorantCC/src/Utils.cs @@ -7,6 +7,8 @@ using System.Net; using System.Text; using System.Text.RegularExpressions; +using System.Windows; +using System.Windows.Interop; using System.Windows.Media; using ValorantCC; @@ -21,11 +23,16 @@ public static Data Decompress(string value) { Log("Decompressing Response Data"); byte[] byteArray = Convert.FromBase64String(value); - var outputStream = new MemoryStream(); - DeflateStream deflateStream = new DeflateStream(new MemoryStream(byteArray), CompressionMode.Decompress); - deflateStream.CopyTo(outputStream); - - return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(outputStream.ToArray())); + byte[] decompressed; + using (MemoryStream outputStream = new MemoryStream()) + { + using (DeflateStream deflateStream = new DeflateStream(new MemoryStream(byteArray), CompressionMode.Decompress)) + { + deflateStream.CopyTo(outputStream); + } + decompressed = (byte[])outputStream.ToArray().Clone(); + } + return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(decompressed)); } public static string Compress(Object data) @@ -33,22 +40,27 @@ public static string Compress(Object data) Log("Compressing New Data"); string jsonString = JsonConvert.SerializeObject(data); byte[] byteArray = Encoding.UTF8.GetBytes(jsonString); - MemoryStream output = new MemoryStream(); - //Create stream from bytes of the json data and copy it to deflateStream as it only has write access - try + byte[] compressed; + using (MemoryStream output = new MemoryStream()) { - using (MemoryStream memoryStream = new MemoryStream(byteArray)) + //Create stream from bytes of the json data and copy it to deflateStream as it only has write access + try { - DeflateStream deflateStream = new DeflateStream(output, CompressionMode.Compress); - memoryStream.CopyTo(deflateStream); - deflateStream.Close(); + using (MemoryStream memoryStream = new MemoryStream(byteArray)) + { + using (DeflateStream deflateStream = new DeflateStream(output, CompressionMode.Compress)) + { + memoryStream.CopyTo(deflateStream); + } + } } + catch (Exception e) + { + Log(e.ToString()); + } + compressed = (byte[])output.ToArray().Clone(); } - catch (Exception e) - { - Log(e.ToString()); - } - return Convert.ToBase64String(output.ToArray()); + return Convert.ToBase64String(compressed); } public static CrosshairColor parseCrosshairColor(string input)