-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (50 loc) · 1.55 KB
/
Copy pathProgram.cs
File metadata and controls
53 lines (50 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
namespace SecureBootInspector;
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += (_, args) => WriteCrashLog(args.Exception);
AppDomain.CurrentDomain.UnhandledException += (_, args) =>
{
if (args.ExceptionObject is Exception exception)
{
WriteCrashLog(exception);
}
};
try
{
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
catch (Exception exception)
{
WriteCrashLog(exception);
MessageBox.Show(
"SecureBoot Inspector konnte nicht gestartet werden.\r\n\r\n" +
"Ein Fehlerprotokoll wurde neben der EXE gespeichert.",
"SecureBoot Inspector",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private static void WriteCrashLog(Exception exception)
{
try
{
var basePath = AppContext.BaseDirectory;
var path = Path.Combine(basePath, "SecureBootInspector-error.log");
File.AppendAllText(
path,
$"[{DateTimeOffset.Now:yyyy-MM-dd HH:mm:ss zzz}]\r\n{exception}\r\n\r\n");
}
catch
{
// Last-resort crash logging must never cause a second crash.
}
}
}