-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathProgram.cs
138 lines (112 loc) · 4.2 KB
/
Program.cs
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Win32;
namespace RobloxApiDumpTool
{
static class Program
{
public const string LIVE = "LIVE";
public static RegistryKey MainRegistry => GetRegistryKey(Registry.CurrentUser, "SOFTWARE", "Roblox API Dump Tool");
public static readonly NumberFormatInfo NumberFormat = NumberFormatInfo.InvariantInfo;
public const StringComparison StringFormat = StringComparison.InvariantCulture;
public static RegistryKey GetRegistryKey(RegistryKey root, params string[] subKeys)
{
string path = string.Join("\\", subKeys);
return root.CreateSubKey(path, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryOptions.None);
}
public static RegistryKey GetMainRegistryKey(params string[] subKeys)
{
return GetRegistryKey(MainRegistry, subKeys);
}
public static string GetRegistryString(RegistryKey key, string name)
{
return key.GetValue(name, "") as string;
}
public static RegistryKey GetRegistryKey(params string[] subKeys)
{
return GetRegistryKey(MainRegistry, subKeys);
}
public static string GetRegistryString(string name)
{
return GetRegistryString(MainRegistry, name);
}
public static bool GetRegistryBool(RegistryKey key, string name)
{
string value = GetRegistryString(key, name);
if (bool.TryParse(value, out bool result))
return result;
return false;
}
public static bool GetRegistryBool(string name)
{
return GetRegistryBool(MainRegistry, name);
}
static Dictionary<string, string> ReadArgs(params string[] args)
{
if (args.Length < 2)
return null;
var argMap = new Dictionary<string, string>();
string currentArg = "";
foreach (string arg in args)
{
if (arg.StartsWith("-"))
{
if (!string.IsNullOrEmpty(currentArg))
argMap.Add(currentArg, "");
currentArg = arg;
}
else if (!string.IsNullOrEmpty(currentArg))
{
argMap.Add(currentArg, arg);
currentArg = "";
}
}
if (!string.IsNullOrEmpty(currentArg))
argMap.Add(currentArg, "");
return argMap;
}
[STAThread]
static void Main(string[] args)
{
// Set the security protocol to be used for HTTPS.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Set the browser emulation mode for
// rendering generated html as an image.
var browserEmulation = GetRegistryKey
(
Registry.CurrentUser,
"Software", "Microsoft",
"Internet Explorer",
"Main", "FeatureControl",
"FEATURE_BROWSER_EMULATION"
);
Process exe = Process.GetCurrentProcess();
ProcessModule main = exe.MainModule;
string exeName = Path.GetFileName(main.FileName);
browserEmulation.SetValue(exeName, 11000);
// Check the launch arguments.
if (args.Length > 0)
{
var argMap = ReadArgs(args);
if (argMap != null)
{
var processArgsTask = Task.Run(() => ArgProcessor.Run(argMap));
processArgsTask.Wait();
if (processArgsTask.Result)
Environment.Exit(0);
Environment.Exit(1);
}
}
// Start the application window.
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ApiDumpTool());
}
}
}