-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugConsole.cs
More file actions
280 lines (233 loc) · 9.29 KB
/
DebugConsole.cs
File metadata and controls
280 lines (233 loc) · 9.29 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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using XDevkit;
using JRPC_Client;
using System.Threading;
using System.Runtime.InteropServices;
namespace Classification_Tool_Recode
{
public partial class DebugConsole : Form
{
public DebugConsole()
{
InitializeComponent();
}
public IXboxConsole rgh;
public bool connected = false;
[DllImport("user32.dll", EntryPoint = "HideCaret")]
public static extern long HideCaret(IntPtr hwnd);
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NCHITTEST)
m.Result = (IntPtr)(HT_CAPTION);
if (richTextBox1.CanFocus)
HideCaret(richTextBox1.Handle);
}
private const int WM_NCHITTEST = 0x84;
private const int HT_CLIENT = 0x1;
private const int HT_CAPTION = 0x2;
private void ConsoleLine(string text)
{
richTextBox1.AppendText("> " + text + Environment.NewLine);
}
private void SelectTextColor(RichTextBox richText, string p, Color textColor)
{
string[] lines = richText.Lines;
int lengthAll = richTextBox1.TextLength;
int location = richTextBox1.Find(p);
int length = lengthAll - location;
foreach (string line in lines)
{
richTextBox1.Select(location, length);
richText.SelectionColor = textColor;
richTextBox1.DeselectAll();
}
}
string XamUserGetGamertag()
{
return Encoding.ASCII.GetString(rgh.GetMemory(0x81AA28FC, 30)).Replace("\0", string.Empty);
}
private void richTextBox2_KeyDown(object sender, KeyEventArgs e)
{
/*
if (e.KeyCode == Keys.Enter)
{
ask_console(sender, e);
richTextBox2.Clear();
}
*/
}
private void ask_console(object sender, EventArgs e)
{
if (rgh.Connect(out rgh))
{
if (richTextBox2.Text.Contains("/help"))
{
richTextBox1.Clear();
ConsoleLine("--- All avaliable commands ---");
ConsoleLine("/clear (clears the console)");
ConsoleLine("/ip (returns your xbox's ip)");
ConsoleLine("/kernal (returns your xbox's kernal version)");
ConsoleLine("/motherboard (returns your xbox motherboard)");
ConsoleLine("/profile (returns current signed in profile)");
ConsoleLine("/connected_name (returns xbox name)");
ConsoleLine("------------------------------");
}
else if (richTextBox2.Text.Contains("/clear"))
{
richTextBox1.Clear();
}
else if (richTextBox2.Text.Contains("/ip"))
{
ConsoleLine("Console IP -> " + rgh.XboxIP());
}
else if (richTextBox2.Text.Contains("/kernal"))
{
ConsoleLine("Kernal version -> " + rgh.GetKernalVersion());
if (rgh.GetKernalVersion().ToString() == "17559")
{
ConsoleLine("You are on the latest kernal version!");
SelectTextColor(richTextBox1, "You are on the latest kernal version!", Color.Green);
}
else
{
ConsoleLine("Your kernal version is outdated!");
SelectTextColor(richTextBox1, "Your kernal version is outdated!", Color.Red);
}
}
else if (richTextBox2.Text.Contains("/motherboard"))
{
ConsoleLine("Console motherboard -> " + rgh.ConsoleType());
}
else if (richTextBox2.Text.Contains("/profile"))
{
if (XamUserGetGamertag() != "")
ConsoleLine("Signed in as -> " + XamUserGetGamertag());
else
ConsoleLine("Not signed in");
}
else if (richTextBox2.Text.Contains("/connected_name"))
{
ConsoleLine("Connected to -> " + rgh.Name);
}
else
{
ConsoleLine("Invalid command. Type '/help' for a list of commands.");
}
}
}
private void DebugConsole_Load(object sender, EventArgs e)
{
richTextBox1.HideSelection = false;
Screen mainmonitor = Screen.AllScreens[0];
Screen screen = Screen.PrimaryScreen;
if (screen.WorkingArea.Right > mainmonitor.WorkingArea.Right)
mainmonitor = screen;
this.Left = mainmonitor.WorkingArea.Right - this.Width;
this.Top = mainmonitor.WorkingArea.Bottom - this.Height;
this.TopMost = true;
if (rgh.Connect(out rgh))
{
connected = true;
ConsoleLine("Connected to -> " + rgh.Name);
ConsoleLine("Console IP -> " + rgh.XboxIP());
ConsoleLine("Kernal version -> " + rgh.GetKernalVersion());
if (rgh.GetKernalVersion().ToString() == "17559")
{
ConsoleLine("You are on the latest kernal version!");
SelectTextColor(richTextBox1, "You are on the latest kernal version!", Color.Green);
}
else
{
ConsoleLine("Your kernal version is outdated!");
SelectTextColor(richTextBox1, "Your kernal version is outdated!", Color.Red);
}
ConsoleLine("Console motherboard -> " + rgh.ConsoleType());
ConsoleLine("CPU key -> " + rgh.GetCPUKey());
ConsoleLine("Current title -> " + rgh.XamGetCurrentTitleId());
if (XamUserGetGamertag() != "")
ConsoleLine("Signed in as -> " + XamUserGetGamertag());
else
ConsoleLine("Not signed in");
Thread thread1 = new Thread(currenttitle);
thread1.Start();
Thread thread2 = new Thread(currentsignedinaccount);
thread2.Start();
}
else
{
connected = false;
ConsoleLine("Failed to connect!");
SelectTextColor(richTextBox1, "Failed to connect!", Color.Red);
}
}
private void currenttitle()
{
if (connected)
{
uint current_title = rgh.XamGetCurrentTitleId();
while (true)
{
if (rgh.XamGetCurrentTitleId() != current_title)
{
if (current_title.ToString() != "0")
{
Thread.Sleep(3000);
richTextBox1.Invoke((MethodInvoker)(() =>
richTextBox1.AppendText("> Current title -> " + rgh.XamGetCurrentTitleId() + Environment.NewLine)));
}
current_title = rgh.XamGetCurrentTitleId();
}
}
}
}
private void currentsignedinaccount()
{
if (connected)
{
string current_gamertag = XamUserGetGamertag();
while (true)
{
if (XamUserGetGamertag() != current_gamertag)
{
if (XamUserGetGamertag() != "")
{
richTextBox1.Invoke((MethodInvoker)(() =>
richTextBox1.AppendText("> Signed in as -> " + XamUserGetGamertag() + Environment.NewLine)));
}
else
{
richTextBox1.Invoke((MethodInvoker)(() =>
richTextBox1.AppendText("> Signed out of -> " + current_gamertag + Environment.NewLine)));
}
current_gamertag = XamUserGetGamertag();
}
}
}
}
private void label5_Click(object sender, EventArgs e)
{
this.Close();
}
private void label7_Click(object sender, EventArgs e)
{
Screen mainmonitor = Screen.AllScreens[0];
Screen screen = Screen.PrimaryScreen;
if (screen.WorkingArea.Right > mainmonitor.WorkingArea.Right)
mainmonitor = screen;
this.Left = mainmonitor.WorkingArea.Right - this.Width;
this.Top = mainmonitor.WorkingArea.Bottom - this.Height;
this.TopMost = true;
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}