You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.3 KiB
76 lines
2.3 KiB
2 weeks ago
|
using System;
|
||
|
using System.Diagnostics;
|
||
|
using System.Runtime.InteropServices;
|
||
|
using System.Threading;
|
||
|
using System.Windows.Forms;
|
||
|
using _4ELogger;
|
||
|
|
||
|
namespace iMonitorApp
|
||
|
{
|
||
|
// Token: 0x0200001D RID: 29
|
||
|
internal static class Program
|
||
|
{
|
||
|
// Token: 0x060000DF RID: 223 RVA: 0x0000A094 File Offset: 0x00008294
|
||
|
[STAThread]
|
||
|
private static void Main()
|
||
|
{
|
||
|
Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
||
|
Debug.AutoFlush = true;
|
||
|
bool flag = Program.PriorProcess() != null;
|
||
|
if (flag)
|
||
|
{
|
||
|
MessageBox.Show("Another instance of the app is already running.");
|
||
|
Program.SetForegroundWindow(Program.PriorProcess().MainWindowHandle);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Application.EnableVisualStyles();
|
||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||
|
Application.ThreadException += Program.Application_ThreadException;
|
||
|
AppDomain.CurrentDomain.UnhandledException += Program.CurrentDomain_UnhandledException;
|
||
|
Application.Run(new ParentForm());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Token: 0x060000E0 RID: 224 RVA: 0x0000A110 File Offset: 0x00008310
|
||
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||
|
{
|
||
|
Exception ex = (Exception)e.ExceptionObject;
|
||
|
Logger.Log(string.Concat(new string[]
|
||
|
{
|
||
|
"CurrentDomain_Unhandled: Terminating: ",
|
||
|
e.IsTerminating.ToString(),
|
||
|
"Exception:",
|
||
|
ex.Message,
|
||
|
ex.StackTrace
|
||
|
}), "iMonitorApp", "iMonitor");
|
||
|
}
|
||
|
|
||
|
// Token: 0x060000E1 RID: 225 RVA: 0x0000A178 File Offset: 0x00008378
|
||
|
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
||
|
{
|
||
|
Logger.Log(e.Exception.Message + e.Exception.StackTrace, "iMonitorApp", "iMonitor");
|
||
|
}
|
||
|
|
||
|
// Token: 0x060000E2 RID: 226
|
||
|
[DllImport("user32.dll")]
|
||
|
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||
|
|
||
|
// Token: 0x060000E3 RID: 227 RVA: 0x0000A1A8 File Offset: 0x000083A8
|
||
|
public static Process PriorProcess()
|
||
|
{
|
||
|
Process currentProcess = Process.GetCurrentProcess();
|
||
|
Process[] processesByName = Process.GetProcessesByName(currentProcess.ProcessName);
|
||
|
foreach (Process process in processesByName)
|
||
|
{
|
||
|
bool flag = process.Id != currentProcess.Id && process.MainModule.FileName == currentProcess.MainModule.FileName;
|
||
|
if (flag)
|
||
|
{
|
||
|
return process;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
}
|