-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathProgram.cs
More file actions
62 lines (56 loc) · 2.26 KB
/
Program.cs
File metadata and controls
62 lines (56 loc) · 2.26 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
54
55
56
57
58
59
60
61
62
using System;
using System.Windows.Forms;
using System.Threading;
using WindowTextExtractor.Forms;
using WindowTextExtractor.Utils;
using WindowTextExtractor.Settings;
using WindowTextExtractor.Native;
namespace WindowTextExtractor
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += OnCurrentDomainUnhandledException;
Application.ThreadException += OnThreadException;
#if WIN32
var settings = ApplicationSettingsFile.Read();
// Enable support of high DPI
if (settings.HighDpiSupport)
{
SystemUtils.EnableHighDpiSupport();
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm(settings));
#else
var hwndCaller = 0;
var hwndTarget = 0;
var messageId = 0;
if (args != null && args.Length > 2 && int.TryParse(args[0], out hwndCaller) && int.TryParse(args[1], out hwndTarget) && int.TryParse(args[2], out messageId))
{
var hwndCallerPtr = new IntPtr(hwndCaller);
var hwndTargetPtr = new IntPtr(hwndTarget);
Hook.SetHook64(hwndCallerPtr, hwndTargetPtr, messageId);
Hook.QueryPasswordEdit64();
Hook.UnsetHook64(hwndCallerPtr, hwndTargetPtr);
}
else
{
MessageBox.Show("WindowTextExtractor64.exe is not for a manual run.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
#endif
}
static void OnCurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var ex = e.ExceptionObject as Exception ?? new Exception("OnCurrentDomainUnhandledException");
OnThreadException(sender, new ThreadExceptionEventArgs(ex));
}
static void OnThreadException(object sender, ThreadExceptionEventArgs e) =>
MessageBox.Show(e.Exception.Message, AssemblyUtils.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}