Skip to content

Commit

Permalink
v0.11: Added a crash reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
mdnpascual committed Feb 24, 2021
1 parent 182f81f commit dac319f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Match3Solver/GameHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void AttachProcess()
continue;
}

Direct3DVersion direct3DVersion = Direct3DVersion.Direct3D11;
Direct3DVersion direct3DVersion = Direct3DVersion.AutoDetect;

CaptureConfig cc = new CaptureConfig()
{
Expand Down
51 changes: 46 additions & 5 deletions Match3Solver/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Threading;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Documents;
//using System.Drawing;
using CrashReporterDotNET;
using System.Text;
using System.Linq;

namespace Match3Solver
{
Expand Down Expand Up @@ -90,6 +89,7 @@ public partial class MainWindow : Window, SolverInterface

private IntPtr _windowHandle;
private HwndSource _source;
private static ReportCrash _reportCrash;

public MainWindow()
{
Expand All @@ -105,6 +105,48 @@ public MainWindow()
board[6] = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
initBoardDisplay();
results = solver.loopBoard(board);
initCrashReporter();
}

private static void initCrashReporter()
{
AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
{
SendReport((Exception)args.ExceptionObject);
};
byte[] data = Convert.FromBase64String("enFhYy56cWh1K3puZ3B1M2ZieWlyZXBlbmZ1ZXJjYmVnQHR6bnZ5LnBieg==");
string decodedString = Encoding.UTF8.GetString(data);
byte[] data2 = Convert.FromBase64String("MnI1czM3NjctMG9xMC00NTFxLW4zcXEtcG9wcm44MzkwOHM5");
string decodedString2 = Encoding.UTF8.GetString(data2);
_reportCrash = new ReportCrash(String.Join("", decodedString.Select(x => char.IsLetter(x) ? (x >= 65 && x <= 77) || (x >= 97 && x <= 109) ? (char)(x + 13) : (char)(x - 13) : x)))
{
Silent = true,
ShowScreenshotTab = true,
IncludeScreenshot = false,
#region Optional Configuration
AnalyzeWithDoctorDump = true,
DoctorDumpSettings = new DoctorDumpSettings
{
ApplicationID = new Guid(String.Join("", decodedString2.Select(x => char.IsLetter(x) ? (x >= 65 && x <= 77) || (x >= 97 && x <= 109) ? (char)(x + 13) : (char)(x - 13) : x))),
OpenReportInBrowser = true
}
#endregion
};
_reportCrash.RetryFailedReports();
}

public static void SendReport(Exception exception, string developerMessage = "")
{
_reportCrash.DeveloperMessage = developerMessage;
_reportCrash.Silent = false;
_reportCrash.Send(exception);
}

public static void SendReportSilently(Exception exception, string developerMessage = "")
{
_reportCrash.DeveloperMessage = developerMessage;
_reportCrash.Silent = true;
_reportCrash.Send(exception);
}

protected override void OnSourceInitialized(EventArgs e)
Expand Down Expand Up @@ -196,7 +238,6 @@ private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref
break;
case VK_C:
statusText.Text = "Capturing Screenshot";

new Thread(() =>
{
board = solver.parseImage(captureBoard());
Expand Down
3 changes: 3 additions & 0 deletions Match3Solver/Match3Solver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="CrashReporter.NET, Version=1.6.0.0, Culture=neutral, PublicKeyToken=7828e0fd88cab698, processorArchitecture=MSIL">
<HintPath>..\packages\CrashReporter.NET.Official.1.6.0\lib\net40\CrashReporter.NET.dll</HintPath>
</Reference>
<Reference Include="EasyHook, Version=2.7.7097.0, Culture=neutral, PublicKeyToken=4b580fca19d0b0c5, processorArchitecture=MSIL">
<HintPath>..\packages\EasyHook.2.7.7097\lib\net40\EasyHook.dll</HintPath>
</Reference>
Expand Down
1 change: 1 addition & 0 deletions Match3Solver/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CrashReporter.NET.Official" version="1.6.0" targetFramework="net451" />
<package id="EasyHook" version="2.7.7097" targetFramework="net451" />
<package id="SharpDX" version="4.2.0" targetFramework="net451" />
<package id="SharpDX.D3DCompiler" version="4.2.0" targetFramework="net451" />
Expand Down

0 comments on commit dac319f

Please sign in to comment.