From 362a00d4492ba9a6341f2d58c05d2c157e22d53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20G=C3=B3mez?= <72423267+Haruki1707@users.noreply.github.com> Date: Thu, 10 Feb 2022 12:46:00 -0600 Subject: [PATCH] Merge of Master Patches PATCH v2.6.7 (Added more logging specifically for app crashes.) PATCH v2.6.8 (Updated NuGet EZ_Updater; Crashing problem fixed) PATCH v2.6.9 (Unauthorized Access error handled; 2.6.8's Crash fix.) --- README.md | 9 ++-- ValorantCC/App.xaml.cs | 50 +++++++++++++++++++++- ValorantCC/MainWindow.xaml.cs | 14 ++++++ ValorantCC/SubWindow/MessageWindow.xaml.cs | 4 +- ValorantCC/ValorantCC.csproj | 2 +- ValorantCC/app.manifest | 2 +- ValorantCC/src/Utils.cs | 3 -- 7 files changed, 72 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e7ea2a7..32c31ec 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@
-# ValorantCC (Valorant Crosshair Changer) +# ValorantCC (Valorant Crosshair Changer) [Download Here](https://github.com/weedeej/ValorantCC/releases/latest/download/ValorantCC.exe) Change your Crosshair's color to **ANY** color you want for style and/or visiblity. - - + ## Usage - Either Open this first or Riot client or Valorant it doesn't matter. diff --git a/ValorantCC/App.xaml.cs b/ValorantCC/App.xaml.cs index 9d5e776..547525f 100644 --- a/ValorantCC/App.xaml.cs +++ b/ValorantCC/App.xaml.cs @@ -1,4 +1,11 @@ -using System.Windows; +using System; +using System.Runtime.ExceptionServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Interop; +using System.Windows.Media; +using System.Windows.Threading; +using Utilities; namespace ValorantCC { @@ -7,6 +14,47 @@ namespace ValorantCC /// public partial class App : Application { + protected override void OnStartup(StartupEventArgs e) + { + //Copy pasta for logging :V + Startup += new StartupEventHandler(AppEventHandler); + DispatcherUnhandledException += LogDispatcherUnhandled; + + TaskScheduler.UnobservedTaskException += LogUnobservedTaskException; + RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; + } + + private void AppEventHandler(object sender, StartupEventArgs e) + { + AppDomain.CurrentDomain.FirstChanceException += LogFirstChanceException; + AppDomain.CurrentDomain.UnhandledException += LogUnhandled; + } + + private void LogFirstChanceException(object sender, FirstChanceExceptionEventArgs e) + { + Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); + } + + private void LogDispatcherUnhandled(object sender, DispatcherUnhandledExceptionEventArgs e) + { + Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); + e.Handled = false; + } + + private void LogUnhandled(object sender, UnhandledExceptionEventArgs e) + { + var ex = e.ExceptionObject as Exception; + if (e.IsTerminating) + { + Utils.Log($"{ex.Message}: {ex.StackTrace}"); + } + } + + private void LogUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) + { + Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); + e.SetObserved(); + } } } diff --git a/ValorantCC/MainWindow.xaml.cs b/ValorantCC/MainWindow.xaml.cs index 32e80b4..135dd5a 100644 --- a/ValorantCC/MainWindow.xaml.cs +++ b/ValorantCC/MainWindow.xaml.cs @@ -10,6 +10,7 @@ using System.Windows.Media; using Utilities; using ValorantCC.src; +using ValorantCC.SubWindow; namespace ValorantCC { @@ -42,8 +43,21 @@ public MainWindow() private async void Grid_Loaded(object sender, RoutedEventArgs e) { Updater.CustomLogger = Utils.Log; + Updater.OriginalFileName = "ValorantCC"; + Updater.LogInterfix = " | "; if (await Updater.CheckUpdateAsync("weedeej", "ValorantCC")) { + try + { + File.Create("./valccPermsTest.null").Close(); + File.Delete("./valccPermsTest.null"); + } + catch (UnauthorizedAccessException) + { + Utils.Log("User is not authorized to create a file on current valcc dir. Consider moving."); + MessageWindow.Show("There's an update available but you have no access to write on this folder.\nPlease consider moving the app to a folder created by you or running the app as administrator."); + this.Close(); + } var update = new UpdateWindow(); update.Owner = this; update.ShowDialog(); diff --git a/ValorantCC/SubWindow/MessageWindow.xaml.cs b/ValorantCC/SubWindow/MessageWindow.xaml.cs index 8a5b0ae..35e36ec 100644 --- a/ValorantCC/SubWindow/MessageWindow.xaml.cs +++ b/ValorantCC/SubWindow/MessageWindow.xaml.cs @@ -12,13 +12,15 @@ public static void Show(string Message) { MessageWindow MessageWin = new(Message); MessageWin.Owner = Application.Current.Windows.OfType