-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathProgram.cs
More file actions
executable file
·74 lines (59 loc) · 2.28 KB
/
Program.cs
File metadata and controls
executable file
·74 lines (59 loc) · 2.28 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
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Plus.Core;
using log4net.Config;
namespace Plus
{
public static class Program
{
private const int MF_BYCOMMAND = 0x00000000;
public const int SC_CLOSE = 0xF060;
[DllImport("Kernel32")]
private static extern bool SetConsoleCtrlHandler(EventHandler handler, bool add);
[DllImport("user32.dll")]
public static extern int DeleteMenu(IntPtr hMenu, int nPosition, int wFlags);
[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("kernel32.dll", ExactSpelling = true)]
private static extern IntPtr GetConsoleWindow();
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)]
public static void Main(string[] Args)
{
XmlConfigurator.Configure();
Console.ForegroundColor = ConsoleColor.White;
Console.CursorVisible = false;
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += MyHandler;
PlusEnvironment.Initialize();
while (true)
{
if (Console.ReadKey(true).Key == ConsoleKey.Enter)
{
Console.Write("plus> ");
string Input = Console.ReadLine();
if (Input.Length > 0)
{
string s = Input.Split(' ')[0];
ConsoleCommands.InvokeCommand(s);
}
}
}
}
private static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
var e = (Exception) args.ExceptionObject;
//Logger.LogCriticalException("SYSTEM CRITICAL EXCEPTION: " + e);
PlusEnvironment.PerformShutDown();
}
private enum CtrlType
{
CTRL_C_EVENT = 0,
CTRL_BREAK_EVENT = 1,
CTRL_CLOSE_EVENT = 2,
CTRL_LOGOFF_EVENT = 5,
CTRL_SHUTDOWN_EVENT = 6
}
private delegate bool EventHandler(CtrlType sig);
}
}