1 |
william |
817 |
#define FORCE_DISABLE_PROFILER_LOGLEVEL // when define will forcibly disable the profiler loglevel |
2 |
william |
816 |
//#region Logging Defines |
3 |
william |
814 |
//// include this any class or method that required logging, and comment-out what is not needed |
4 |
william |
415 |
|
5 |
william |
814 |
//#region Enabled logging levels |
6 |
|
|
//#define LOGGING_ENABLE_INFO |
7 |
|
|
//#define LOGGING_ENABLE_WARN |
8 |
|
|
//#define LOGGING_ENABLE_DEBUG |
9 |
|
|
//#define LOGGING_ENABLE_VERBOSEDEBUG |
10 |
|
|
//#define LOGGING_ENABLE_ERROR |
11 |
|
|
//#define LOGGING_ENABLE_VERBOSEERROR |
12 |
|
|
//#define LOGGING_ENABLE_PROFILER |
13 |
|
|
//#endregion |
14 |
|
|
//#endregion |
15 |
william |
692 |
//#define FORCE_ALL_LOGGING_FLAGS // when defined will force logging flags to ALL |
16 |
william |
158 |
#define SHOW_DEBUG_MENU // when defined will show the debug menu or else it will be hidden |
17 |
william |
99 |
using System; |
18 |
william |
5 |
using System.Collections.Generic; |
19 |
|
|
using System.ComponentModel; |
20 |
|
|
using System.Data; |
21 |
|
|
using System.Drawing; |
22 |
|
|
using System.Linq; |
23 |
|
|
using System.Text; |
24 |
|
|
using System.Windows.Forms; |
25 |
william |
17 |
using RomCheater.Logging; |
26 |
william |
34 |
using RomCheater.Properties; |
27 |
|
|
using RomCheater.UserSettingsSupport; |
28 |
william |
83 |
using RomCheater.PluginFramework.Core; |
29 |
william |
86 |
using System.Diagnostics; |
30 |
william |
686 |
|
31 |
william |
144 |
using WeifenLuo.WinFormsUI.Docking; |
32 |
william |
889 |
using RomCheater.Core.Docking; |
33 |
william |
152 |
using System.IO; |
34 |
william |
159 |
using Sojaner.MemoryScanner; |
35 |
william |
889 |
using Sojaner.MemoryScanner.Events; |
36 |
william |
449 |
using RomCheater.Serialization; |
37 |
william |
889 |
using RomCheater.Interfaces; |
38 |
william |
813 |
using Enterprise.Logging; |
39 |
william |
5 |
|
40 |
|
|
namespace RomCheater |
41 |
|
|
{ |
42 |
william |
13 |
public partial class Main : Form |
43 |
william |
5 |
{ |
44 |
william |
816 |
//private ushort Logger_flags = 0; |
45 |
william |
814 |
private LogLevel logging_level = LogLevel.kLogLevel_All; |
46 |
william |
755 |
const string DockPanelConfig = "RomCheater-DockPanel.conf"; |
47 |
william |
722 |
private SettingSubscriber SettingsSubscriber; |
48 |
william |
152 |
private bool m_bSaveLayout = true; |
49 |
william |
477 |
private Process SelectedProcess = null; |
50 |
william |
144 |
private DeserializeDockContent m_deserializeDockContent; |
51 |
|
|
private FloatingLogWindow m_LogWindow = new FloatingLogWindow(); |
52 |
william |
147 |
private FloatingAboutBox m_AboutBox = new FloatingAboutBox(); |
53 |
william |
148 |
private FloatingRamDumperDialog m_RamDump = new FloatingRamDumperDialog(); |
54 |
william |
366 |
private FloatingPIDSelector m_PIDSelector = new FloatingPIDSelector(); |
55 |
william |
196 |
private FloatingMemoryView m_memoryview = new FloatingMemoryView(); |
56 |
william |
218 |
private FloatingDataTypeConverter m_typeconverter = new FloatingDataTypeConverter(); |
57 |
william |
227 |
private FloatingMemorySearcher m_memsearcher = new FloatingMemorySearcher(); |
58 |
william |
318 |
private FloatingPEViewer m_peviewer = new FloatingPEViewer(); |
59 |
william |
366 |
private FloatingRVACalculator m_rvacalc = new FloatingRVACalculator(); |
60 |
william |
439 |
|
61 |
william |
596 |
private FloatingMemorySectionViewer m_msv = new FloatingMemorySectionViewer(); |
62 |
|
|
|
63 |
william |
439 |
private FloatingUserControlDock m_ucd = new FloatingUserControlDock(); |
64 |
|
|
|
65 |
william |
695 |
private FloatingWebBrowser m_wb = new FloatingWebBrowser(); |
66 |
|
|
|
67 |
william |
144 |
//private bool log_window_expanded = false; |
68 |
|
|
//private double log_window_splitter_default_position = 1.4045; |
69 |
william |
86 |
PluginLoader loader = null; |
70 |
william |
87 |
IConfigPlugin ConfigPlugin = null; |
71 |
|
|
IInputPlugin InputPlugin = null; |
72 |
|
|
IWindowPlugin WindowPlugin = null; |
73 |
william |
437 |
List<IUserControlPlugin> UserControlPlugins = null; |
74 |
william |
639 |
//static Main() { SettingSubscriber.AddSubscriber(new Main(), Settings.Default); } |
75 |
william |
438 |
//private const string t = "RomCheater"; |
76 |
william |
17 |
#region LogWriterSupport |
77 |
william |
814 |
static LogWriter _LoggerInstance; |
78 |
|
|
static LogWriter LoggerInstance |
79 |
|
|
{ |
80 |
|
|
get { return _LoggerInstance; } |
81 |
|
|
set { _LoggerInstance = value; } |
82 |
|
|
} |
83 |
william |
17 |
#endregion |
84 |
|
|
|
85 |
|
|
|
86 |
william |
696 |
public IWebBrowserProvider WebBrowserProvider |
87 |
|
|
{ |
88 |
william |
699 |
get { return new WebBrowserProvider(m_wb); } |
89 |
william |
696 |
} |
90 |
|
|
|
91 |
william |
196 |
private void OnProcessChanged(ProcessChangedEventArgs e) |
92 |
william |
151 |
{ |
93 |
william |
696 |
ConfigPlugin.WebBrowserProvider = this.WebBrowserProvider; |
94 |
william |
228 |
if (m_memsearcher.SearchInProgess) |
95 |
|
|
{ |
96 |
|
|
DialogResult result = MessageBox.Show("Do you want to start a new search with the selected process?", "A memory search is currently in progress", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); |
97 |
|
|
if (result != DialogResult.Yes || result != DialogResult.OK) { return; } |
98 |
|
|
m_memsearcher = null; //free memory used by the memory searcher |
99 |
|
|
m_memsearcher = new FloatingMemorySearcher(); |
100 |
|
|
} |
101 |
william |
477 |
SelectedProcess = Process.GetProcessById(e.ProcessID); |
102 |
william |
196 |
m_RamDump.AcceptedPlugin = this.ConfigPlugin; |
103 |
william |
477 |
m_RamDump.AcceptedProcess = SelectedProcess; |
104 |
william |
196 |
|
105 |
william |
360 |
m_peviewer.AcceptedPlugin = this.ConfigPlugin; |
106 |
william |
477 |
m_peviewer.AcceptedProcess = SelectedProcess; |
107 |
william |
408 |
m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated); |
108 |
william |
360 |
|
109 |
william |
244 |
m_memoryview.AcceptedPlugin = this.ConfigPlugin; |
110 |
william |
477 |
m_memoryview.AcceptedProcess = SelectedProcess; |
111 |
william |
227 |
|
112 |
william |
244 |
m_memsearcher.AcceptedPlugin = this.ConfigPlugin; |
113 |
william |
477 |
m_memsearcher.AcceptedProcess = SelectedProcess; |
114 |
william |
275 |
m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
115 |
william |
318 |
|
116 |
william |
596 |
m_msv.AcceptedPlugin = this.ConfigPlugin; |
117 |
|
|
m_msv.AcceptedProcess = SelectedProcess; |
118 |
william |
605 |
m_msv.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
119 |
william |
596 |
|
120 |
|
|
|
121 |
william |
680 |
AcceptedProcessAndConfig iapc = new AcceptedProcessAndConfig(this.ConfigPlugin, SelectedProcess); |
122 |
|
|
|
123 |
|
|
this.ConfigPlugin.SetAcceptedProcessAndConfig(iapc); |
124 |
|
|
this.WindowPlugin.SetAcceptedProcessAndConfig(iapc); |
125 |
|
|
this.InputPlugin.SetAcceptedProcessAndConfig(iapc); |
126 |
|
|
for (int i = 0; i < UserControlPlugins.Count; i++) |
127 |
|
|
{ |
128 |
|
|
UserControlPlugins[i].SetAcceptedProcessAndConfig(iapc); |
129 |
|
|
} |
130 |
william |
151 |
} |
131 |
william |
323 |
|
132 |
william |
408 |
void OnPEDataUpdated(PEViewerDataUpdatedEventArgs e) |
133 |
william |
612 |
{ |
134 |
|
|
m_memoryview.SetPEViewerData(e.peData); |
135 |
|
|
m_memsearcher.SetPEViewerData(e.peData); |
136 |
|
|
m_rvacalc.SetPEViewerData(e.peData); |
137 |
|
|
m_RamDump.SetPEViewerData(e.peData); |
138 |
|
|
m_msv.SetPEViewerData(e.peData); |
139 |
|
|
|
140 |
william |
680 |
ConfigPlugin.SetPEViewerData(e.peData); |
141 |
|
|
WindowPlugin.SetPEViewerData(e.peData); |
142 |
|
|
InputPlugin.SetPEViewerData(e.peData); |
143 |
|
|
|
144 |
|
|
for (int i = 0; i < UserControlPlugins.Count; i++) |
145 |
|
|
{ |
146 |
|
|
UserControlPlugins[i].SetPEViewerData(e.peData); |
147 |
|
|
} |
148 |
|
|
|
149 |
william |
323 |
} |
150 |
william |
275 |
private void OnBrowseMemoryRegion(BrowseMemoryRegionEvent e) |
151 |
|
|
{ |
152 |
william |
276 |
m_memoryview.BrowseMemoryRegion(e.MemoryRegion); |
153 |
william |
275 |
} |
154 |
william |
151 |
|
155 |
william |
144 |
#region Dock Support |
156 |
william |
313 |
void AddDockToWindowList(object sender, EventArgs e) |
157 |
|
|
{ |
158 |
|
|
DockContent dc; |
159 |
william |
315 |
TypeBinder.Bind(sender, out dc); |
160 |
william |
314 |
ToolStripMenuItem tsmi = new ToolStripMenuItem(dc.Text); |
161 |
|
|
tsmi.Name = dc.Name; |
162 |
|
|
tsmi.Tag = dc; |
163 |
william |
315 |
tsmi.Click += new EventHandler(tsmi_Click); |
164 |
william |
314 |
mnuWindows.DropDownItems.Add(tsmi); |
165 |
william |
313 |
} |
166 |
william |
314 |
void tsmi_Click(object sender, EventArgs e) |
167 |
|
|
{ |
168 |
|
|
ToolStripMenuItem tsmi; |
169 |
william |
315 |
TypeBinder.Bind(sender, out tsmi); |
170 |
william |
314 |
DockContent dc; |
171 |
william |
315 |
TypeBinder.Bind(tsmi.Tag, out dc); |
172 |
william |
314 |
dc.Activate(); |
173 |
|
|
} |
174 |
william |
313 |
void RemoveDockFromWindowList(object sender, FormClosedEventArgs e) |
175 |
|
|
{ |
176 |
|
|
DockContent dc; |
177 |
william |
315 |
TypeBinder.Bind(sender, out dc); |
178 |
william |
314 |
mnuWindows.DropDownItems.RemoveByKey(dc.Name); |
179 |
william |
313 |
} |
180 |
william |
144 |
private IDockContent GetContentFromPersistString(string persistString) |
181 |
|
|
{ |
182 |
william |
228 |
if (persistString == typeof(FloatingLogWindow).ToString()) { return m_LogWindow; } |
183 |
|
|
if (persistString == typeof(FloatingRamDumperDialog).ToString()) { return m_RamDump; } |
184 |
william |
366 |
if (persistString == typeof(FloatingPIDSelector).ToString()) { return m_PIDSelector; } |
185 |
william |
228 |
if (persistString == typeof(FloatingMemoryView).ToString()) { return m_memoryview; } |
186 |
|
|
if (persistString == typeof(FloatingDataTypeConverter).ToString()) { return m_typeconverter; } |
187 |
|
|
if (persistString == typeof(FloatingMemorySearcher).ToString()) { return m_memsearcher; } |
188 |
william |
318 |
if (persistString == typeof(FloatingPEViewer).ToString()) { return m_peviewer; } |
189 |
william |
636 |
if (persistString == typeof(FloatingRVACalculator).ToString()) { return m_rvacalc; } |
190 |
|
|
if (persistString == typeof(FloatingMemorySectionViewer).ToString()) { return m_msv; } |
191 |
william |
439 |
if (persistString == typeof(FloatingUserControlDock).ToString()) { return m_ucd; } |
192 |
william |
695 |
if (persistString == typeof(FloatingWebBrowser).ToString()) { return m_wb; } |
193 |
william |
228 |
else { return null; } |
194 |
william |
144 |
} |
195 |
william |
892 |
private void SetDockIcon(DockContent c) |
196 |
|
|
{ |
197 |
|
|
if (c == null) |
198 |
|
|
{ |
199 |
|
|
throw new NullReferenceException(""); |
200 |
|
|
} |
201 |
|
|
c.ShowIcon = true; |
202 |
william |
893 |
//c.DockHandler.CloseButton = false; |
203 |
|
|
//c.DockHandler.CloseButtonVisible = false; |
204 |
|
|
//c.DockHandler.AllowEndUserDocking = false; |
205 |
william |
892 |
//c.Icon = (Icon)Core.Properties.Resources.romcheater_icon.Clone(); |
206 |
|
|
c.Icon = Core.Properties.Resources.romcheater_icon; |
207 |
william |
905 |
//c.Activate(); |
208 |
william |
892 |
} |
209 |
william |
891 |
private void SetDockIcons() |
210 |
|
|
{ |
211 |
william |
892 |
SetDockIcon(m_LogWindow); |
212 |
william |
891 |
SetDockIcon(m_RamDump); |
213 |
|
|
SetDockIcon(m_PIDSelector); |
214 |
|
|
SetDockIcon(m_memoryview); |
215 |
|
|
SetDockIcon(m_typeconverter); |
216 |
|
|
SetDockIcon(m_memsearcher); |
217 |
|
|
SetDockIcon(m_peviewer); |
218 |
|
|
SetDockIcon(m_rvacalc); |
219 |
|
|
SetDockIcon(m_ucd); |
220 |
|
|
SetDockIcon(m_msv); |
221 |
|
|
SetDockIcon(m_wb); |
222 |
|
|
} |
223 |
william |
144 |
public void SetupDocks() |
224 |
|
|
{ |
225 |
|
|
m_LogWindow = new FloatingLogWindow(); |
226 |
william |
814 |
LoggerInstance = m_LogWindow.Logwriter; |
227 |
william |
147 |
m_AboutBox = new FloatingAboutBox(); |
228 |
william |
148 |
m_RamDump = new FloatingRamDumperDialog(); |
229 |
william |
366 |
m_PIDSelector = new FloatingPIDSelector(); |
230 |
william |
196 |
m_PIDSelector.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(OnProcessChanged); |
231 |
|
|
m_memoryview = new FloatingMemoryView(); |
232 |
william |
218 |
m_typeconverter = new FloatingDataTypeConverter(); |
233 |
william |
227 |
m_memsearcher = new FloatingMemorySearcher(); |
234 |
william |
275 |
m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
235 |
william |
318 |
m_peviewer = new FloatingPEViewer(); |
236 |
william |
408 |
m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated); |
237 |
william |
366 |
m_rvacalc = new FloatingRVACalculator(); |
238 |
william |
439 |
m_ucd = new FloatingUserControlDock(); |
239 |
william |
596 |
m_msv = new FloatingMemorySectionViewer(); |
240 |
william |
695 |
m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString); |
241 |
william |
893 |
m_wb = new FloatingWebBrowser(); |
242 |
william |
144 |
} |
243 |
william |
313 |
#region SetupDockWindowHandler support |
244 |
|
|
public void SetupDockWindowHandler() |
245 |
|
|
{ |
246 |
|
|
SetupLogWindowHandler(); |
247 |
|
|
SetupRamDumpWindowHandler(); |
248 |
|
|
SetupMemoryViewWindowHandler(); |
249 |
|
|
SetupPIDSelectorWindowHandler(); |
250 |
|
|
SetupDataTypeConverterWindowHandler(); |
251 |
|
|
SetupMemorySearchWindowHandler(); |
252 |
william |
318 |
SetupPEViewerWindowHandler(); |
253 |
william |
636 |
SetupRVACalculatorWindowHandler(); |
254 |
|
|
SetupMemorySectionViewerWindowHandler(); |
255 |
william |
439 |
SetupUserControlDockWindowHandler(); |
256 |
william |
893 |
SetupWebBrowserWindowHandler(); |
257 |
william |
313 |
} |
258 |
|
|
private void SetupLogWindowHandler() |
259 |
|
|
{ |
260 |
|
|
if (m_LogWindow == null) return; |
261 |
|
|
m_LogWindow.Shown += new EventHandler(AddDockToWindowList); |
262 |
william |
335 |
m_LogWindow.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
263 |
william |
905 |
//m_LogWindow.Activate(); |
264 |
william |
313 |
} |
265 |
|
|
private void SetupRamDumpWindowHandler() |
266 |
|
|
{ |
267 |
|
|
if (m_RamDump == null) return; |
268 |
|
|
m_RamDump.Shown += new EventHandler(AddDockToWindowList); |
269 |
|
|
m_RamDump.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
270 |
william |
335 |
m_RamDump.AcceptedPlugin = ConfigPlugin; |
271 |
william |
905 |
//m_RamDump.Activate(); |
272 |
william |
313 |
} |
273 |
|
|
private void SetupMemoryViewWindowHandler() |
274 |
|
|
{ |
275 |
|
|
if (m_memoryview == null) return; |
276 |
|
|
m_memoryview.Shown += new EventHandler(AddDockToWindowList); |
277 |
|
|
m_memoryview.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
278 |
william |
335 |
m_memoryview.AcceptedPlugin = ConfigPlugin; |
279 |
william |
905 |
//m_memoryview.Activate(); |
280 |
william |
313 |
} |
281 |
|
|
private void SetupPIDSelectorWindowHandler() |
282 |
|
|
{ |
283 |
|
|
if (m_PIDSelector == null) return; |
284 |
|
|
m_PIDSelector.Shown += new EventHandler(AddDockToWindowList); |
285 |
|
|
m_PIDSelector.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
286 |
william |
335 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
287 |
william |
905 |
//m_PIDSelector.Activate(); |
288 |
william |
313 |
} |
289 |
|
|
private void SetupDataTypeConverterWindowHandler() |
290 |
|
|
{ |
291 |
|
|
if (m_typeconverter == null) return; |
292 |
|
|
m_typeconverter.Shown += new EventHandler(AddDockToWindowList); |
293 |
|
|
m_typeconverter.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
294 |
william |
905 |
//m_typeconverter.Activate(); |
295 |
william |
313 |
} |
296 |
|
|
private void SetupMemorySearchWindowHandler() |
297 |
|
|
{ |
298 |
|
|
if (m_memsearcher == null) return; |
299 |
|
|
m_memsearcher.Shown += new EventHandler(AddDockToWindowList); |
300 |
|
|
m_memsearcher.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
301 |
william |
905 |
//m_memsearcher.Activate(); |
302 |
william |
313 |
} |
303 |
william |
318 |
private void SetupPEViewerWindowHandler() |
304 |
|
|
{ |
305 |
|
|
if (m_peviewer == null) return; |
306 |
|
|
m_peviewer.Shown += new EventHandler(AddDockToWindowList); |
307 |
|
|
m_peviewer.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
308 |
william |
335 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
309 |
william |
905 |
//m_peviewer.Activate(); |
310 |
william |
318 |
} |
311 |
william |
366 |
private void SetupRVACalculatorWindowHandler() |
312 |
|
|
{ |
313 |
|
|
if (m_rvacalc == null) return; |
314 |
|
|
m_rvacalc.Shown += new EventHandler(AddDockToWindowList); |
315 |
|
|
m_rvacalc.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
316 |
|
|
m_rvacalc.AcceptedPlugin = ConfigPlugin; |
317 |
william |
905 |
//m_rvacalc.Activate(); |
318 |
william |
366 |
} |
319 |
william |
439 |
private void SetupUserControlDockWindowHandler() |
320 |
|
|
{ |
321 |
|
|
if (m_ucd == null) return; |
322 |
|
|
m_ucd.Shown += new EventHandler(AddDockToWindowList); |
323 |
|
|
m_ucd.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
324 |
william |
905 |
//m_ucd.Activate(); |
325 |
william |
439 |
} |
326 |
william |
596 |
private void SetupMemorySectionViewerWindowHandler() |
327 |
|
|
{ |
328 |
|
|
if (m_msv == null) return; |
329 |
|
|
m_msv.Shown += new EventHandler(AddDockToWindowList); |
330 |
|
|
m_msv.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
331 |
|
|
m_msv.AcceptedPlugin = ConfigPlugin; |
332 |
william |
905 |
//m_msv.Activate(); |
333 |
william |
596 |
} |
334 |
william |
695 |
private void SetupWebBrowserWindowHandler() |
335 |
|
|
{ |
336 |
|
|
if (m_wb == null) return; |
337 |
|
|
m_wb.Shown += new EventHandler(AddDockToWindowList); |
338 |
|
|
m_wb.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList); |
339 |
william |
905 |
//m_wb.Activate(); |
340 |
william |
695 |
} |
341 |
william |
313 |
#endregion |
342 |
william |
144 |
public void ShowDocks() |
343 |
|
|
{ |
344 |
|
|
ShowLogWindow(); |
345 |
william |
313 |
SetupLogWindowHandler(); |
346 |
william |
152 |
//ShowAboutBox(); |
347 |
william |
148 |
ShowRamDump(); |
348 |
william |
313 |
SetupRamDumpWindowHandler(); |
349 |
william |
196 |
ShowMemoryView(); |
350 |
william |
313 |
SetupMemoryViewWindowHandler(); |
351 |
william |
148 |
ShowPidSelector(); |
352 |
william |
313 |
SetupPIDSelectorWindowHandler(); |
353 |
william |
218 |
ShowDataTypeConverter(); |
354 |
william |
313 |
SetupDataTypeConverterWindowHandler(); |
355 |
william |
440 |
|
356 |
william |
438 |
ShowRVACalculator(); |
357 |
|
|
SetupRVACalculatorWindowHandler(); |
358 |
|
|
|
359 |
william |
596 |
ShowMemorySectionViewer(); |
360 |
|
|
SetupMemorySectionViewerWindowHandler(); |
361 |
|
|
|
362 |
william |
439 |
|
363 |
william |
639 |
|
364 |
|
|
ShowUserControlDock(); |
365 |
|
|
SetupUserControlDockWindowHandler(); |
366 |
|
|
|
367 |
william |
227 |
ShowMemorySearch(); |
368 |
william |
313 |
SetupMemorySearchWindowHandler(); |
369 |
william |
318 |
ShowPEViewer(); |
370 |
|
|
SetupPEViewerWindowHandler(); |
371 |
william |
695 |
|
372 |
|
|
ShowWebBrowser(); |
373 |
|
|
SetupWebBrowserWindowHandler(); |
374 |
william |
144 |
} |
375 |
|
|
public void ShowLogWindow() |
376 |
william |
218 |
{ |
377 |
|
|
if (m_LogWindow == null || m_LogWindow.IsDisposed) { m_LogWindow = new FloatingLogWindow(); } |
378 |
william |
814 |
LoggerInstance = m_LogWindow.Logwriter; |
379 |
william |
813 |
//LoggerInstance.CreateNewLog(false); |
380 |
william |
313 |
m_LogWindow.Show(dockPanel, DockState.DockBottom); |
381 |
william |
144 |
} |
382 |
william |
147 |
public void ShowAboutBox() |
383 |
|
|
{ |
384 |
william |
218 |
if (m_AboutBox == null || m_AboutBox.IsDisposed) { m_AboutBox = new FloatingAboutBox(); } |
385 |
william |
148 |
m_AboutBox.ShowDialog(); |
386 |
william |
147 |
} |
387 |
william |
148 |
public void ShowRamDump() |
388 |
|
|
{ |
389 |
william |
637 |
//load_plugins_silent(); |
390 |
william |
153 |
m_RamDump = new FloatingRamDumperDialog(ConfigPlugin); |
391 |
william |
477 |
m_RamDump.AcceptedProcess = SelectedProcess; |
392 |
william |
313 |
m_RamDump.Show(dockPanel); |
393 |
|
|
} |
394 |
william |
196 |
public void ShowMemoryView() |
395 |
|
|
{ |
396 |
william |
637 |
//load_plugins_silent(); |
397 |
william |
196 |
m_memoryview = new FloatingMemoryView(ConfigPlugin); |
398 |
william |
477 |
m_memoryview.AcceptedProcess = SelectedProcess; |
399 |
william |
196 |
m_memoryview.Show(dockPanel); |
400 |
|
|
} |
401 |
william |
148 |
public void ShowPidSelector() |
402 |
|
|
{ |
403 |
william |
637 |
//load_plugins_silent(); |
404 |
william |
148 |
//List<Process> procs = ConfigPlugin.ValidProcessesForPlugin; |
405 |
william |
366 |
m_PIDSelector = new FloatingPIDSelector(ConfigPlugin); |
406 |
william |
196 |
m_PIDSelector.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(OnProcessChanged); |
407 |
william |
148 |
m_PIDSelector.Show(dockPanel); |
408 |
|
|
} |
409 |
william |
218 |
public void ShowDataTypeConverter() |
410 |
|
|
{ |
411 |
|
|
if (m_typeconverter == null || m_typeconverter.IsDisposed) { m_typeconverter = new FloatingDataTypeConverter(); } |
412 |
william |
313 |
m_typeconverter.Show(dockPanel, DockState.DockRightAutoHide); |
413 |
william |
218 |
} |
414 |
william |
227 |
public void ShowMemorySearch() |
415 |
|
|
{ |
416 |
william |
637 |
//load_plugins_silent(); |
417 |
william |
227 |
m_memsearcher = new FloatingMemorySearcher(ConfigPlugin); |
418 |
william |
477 |
m_memsearcher.AcceptedProcess = SelectedProcess; |
419 |
william |
275 |
m_memsearcher.OnBrowseMemoryRegion += new BaseEventHandler<BrowseMemoryRegionEvent>(OnBrowseMemoryRegion); |
420 |
william |
227 |
m_memsearcher.Show(dockPanel); |
421 |
|
|
} |
422 |
william |
318 |
public void ShowPEViewer() |
423 |
|
|
{ |
424 |
william |
637 |
//load_plugins_silent(); |
425 |
william |
318 |
m_peviewer = new FloatingPEViewer(ConfigPlugin); |
426 |
william |
477 |
m_peviewer.AcceptedProcess = SelectedProcess; |
427 |
william |
408 |
m_peviewer.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(OnPEDataUpdated); |
428 |
william |
318 |
m_peviewer.Show(dockPanel); |
429 |
|
|
} |
430 |
william |
366 |
public void ShowRVACalculator() |
431 |
|
|
{ |
432 |
william |
637 |
//load_plugins_silent(); |
433 |
william |
366 |
m_rvacalc = new FloatingRVACalculator(ConfigPlugin); |
434 |
william |
477 |
m_rvacalc.AcceptedProcess = SelectedProcess; |
435 |
william |
366 |
m_rvacalc.Show(dockPanel, DockState.DockRightAutoHide); |
436 |
|
|
} |
437 |
william |
596 |
public void ShowMemorySectionViewer() |
438 |
|
|
{ |
439 |
william |
637 |
//load_plugins_silent(); |
440 |
william |
596 |
m_msv = new FloatingMemorySectionViewer(ConfigPlugin); |
441 |
|
|
m_msv.AcceptedProcess = SelectedProcess; |
442 |
|
|
m_msv.Show(dockPanel); |
443 |
|
|
} |
444 |
william |
439 |
public void ShowUserControlDock() |
445 |
|
|
{ |
446 |
william |
637 |
//load_plugins_silent(); |
447 |
william |
639 |
if (m_ucd == null) |
448 |
|
|
{ |
449 |
|
|
m_ucd = new FloatingUserControlDock(); |
450 |
|
|
} |
451 |
|
|
if (this.UserControlPlugins.Count > 0) |
452 |
|
|
{ |
453 |
|
|
m_ucd.UserPlugins = this.UserControlPlugins; |
454 |
|
|
} |
455 |
william |
439 |
m_ucd.Show(dockPanel, DockState.DockRightAutoHide); |
456 |
|
|
} |
457 |
william |
695 |
public void ShowWebBrowser() |
458 |
|
|
{ |
459 |
|
|
//load_plugins_silent(); |
460 |
|
|
m_wb = new FloatingWebBrowser(); |
461 |
|
|
m_wb.Show(dockPanel); |
462 |
|
|
} |
463 |
william |
144 |
#endregion |
464 |
|
|
|
465 |
|
|
|
466 |
william |
117 |
public Main() : this(false) { } |
467 |
|
|
public Main(bool no_console_redirect) |
468 |
william |
5 |
{ |
469 |
william |
892 |
InitializeComponent(); |
470 |
william |
158 |
#if SHOW_DEBUG_MENU |
471 |
|
|
mnuDebug.Visible = true; |
472 |
|
|
#else |
473 |
|
|
mnuDebug.Visible = false; |
474 |
|
|
#endif |
475 |
william |
722 |
SettingsSubscriber = new SettingSubscriber(); |
476 |
william |
814 |
SettingsSubscriber.AddSubscriber(this, Settings.Default); |
477 |
|
|
SetupDocks(); |
478 |
|
|
LoggerInstance = m_LogWindow.Logwriter; |
479 |
william |
83 |
load_loggerflags(); |
480 |
william |
814 |
load_plugins(); |
481 |
william |
5 |
} |
482 |
william |
83 |
private void load_loggerflags() |
483 |
|
|
{ |
484 |
william |
815 |
bool upgraded_flags = Logging.Properties.Settings.Default.UpgradedLogLevel; |
485 |
|
|
if (!upgraded_flags) |
486 |
|
|
{ |
487 |
|
|
logging_level = new LoggingFlagsConverter(Logging.Properties.Settings.Default.LoggingFlags).ConvertFlags(); |
488 |
|
|
Logging.Properties.Settings.Default.UpgradedLogLevel = true; |
489 |
|
|
Logging.Properties.Settings.Default.gLogLoggingFlags = (uint)logging_level; |
490 |
|
|
Logging.Properties.Settings.Default.Save(); |
491 |
|
|
} |
492 |
|
|
logging_level = (LogLevel)Logging.Properties.Settings.Default.gLogLoggingFlags; |
493 |
william |
99 |
#if FORCE_ALL_LOGGING_FLAGS |
494 |
william |
816 |
logging_level = LogLevel.kLogLevel_All; |
495 |
|
|
#endif |
496 |
william |
817 |
#if FORCE_DISABLE_PROFILER_LOGLEVEL |
497 |
|
|
logging_level = logging_level & ~LogLevel.kLogLevel_Profiler; |
498 |
|
|
logging_level = logging_level & ~LogLevel.kLogLevel_VerboseProfiler; |
499 |
william |
816 |
#endif |
500 |
|
|
gLog.CreateLog(LoggingConstants.AppFullLogPath, true, logging_level, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush), LoggerInstance.Log); |
501 |
william |
83 |
} |
502 |
william |
814 |
|
503 |
|
|
private void Log_OnFlush(object sender, LoggerOnFlushEventArgs e) |
504 |
|
|
{ |
505 |
|
|
} |
506 |
william |
366 |
private void load_plugins() { load_plugins(false); } |
507 |
|
|
private void load_plugins_silent() { load_plugins(true); } |
508 |
|
|
private void load_plugins(bool silent) |
509 |
william |
87 |
{ |
510 |
|
|
loader = new PluginLoader(); |
511 |
william |
366 |
loader.LoadPlugins(silent); |
512 |
william |
83 |
|
513 |
william |
87 |
ConfigPlugin = loader.GetConfigPlugin(RomCheater.Properties.Settings.Default.LastConfigPlugin); |
514 |
william |
366 |
if (ConfigPlugin != null && !silent) |
515 |
william |
813 |
gLog.Info.WriteLine("Loaded Config Plugin: {0}", ConfigPlugin.ToString()); |
516 |
william |
87 |
InputPlugin = loader.GetInputPlugin(RomCheater.Properties.Settings.Default.LastInputPlugin); |
517 |
william |
366 |
if (InputPlugin != null && !silent) |
518 |
william |
813 |
gLog.Info.WriteLine("Loaded Input Plugin: {0}", InputPlugin.ToString()); |
519 |
william |
87 |
WindowPlugin = loader.GetWindowPlugin(RomCheater.Properties.Settings.Default.LastWindowPlugin); |
520 |
william |
366 |
if (WindowPlugin != null && !silent) |
521 |
william |
813 |
gLog.Info.WriteLine("Loaded Window Plugin: {0}", WindowPlugin.ToString()); |
522 |
william |
87 |
|
523 |
william |
437 |
|
524 |
|
|
UserControlPlugins = new List<IUserControlPlugin>(loader.LoadedUserControlPlugins); |
525 |
william |
639 |
if (UserControlPlugins != null) |
526 |
william |
437 |
{ |
527 |
|
|
foreach (var t in UserControlPlugins) |
528 |
|
|
{ |
529 |
william |
639 |
if (!silent) |
530 |
william |
813 |
gLog.Info.WriteLine("Loaded UserControl Plugin: {0}", t.ToString()); |
531 |
william |
437 |
} |
532 |
william |
639 |
|
533 |
|
|
string stacktrace = System.Environment.StackTrace; |
534 |
|
|
|
535 |
|
|
if (UserControlPlugins.Count > 0) |
536 |
|
|
{ |
537 |
william |
696 |
m_ucd.UserPlugins = UserControlPlugins; |
538 |
william |
639 |
} |
539 |
william |
437 |
} |
540 |
|
|
|
541 |
william |
696 |
ConfigPlugin.WebBrowserProvider = this.WebBrowserProvider; |
542 |
william |
437 |
|
543 |
william |
696 |
|
544 |
william |
153 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
545 |
|
|
m_RamDump.AcceptedPlugin = ConfigPlugin; |
546 |
william |
267 |
m_memoryview.AcceptedPlugin = ConfigPlugin; |
547 |
|
|
m_memsearcher.AcceptedPlugin = ConfigPlugin; |
548 |
william |
335 |
m_PIDSelector.AcceptedPlugin = ConfigPlugin; |
549 |
william |
477 |
if (this.SelectedProcess != null) |
550 |
william |
267 |
{ |
551 |
william |
477 |
m_RamDump.AcceptedProcess = SelectedProcess; |
552 |
|
|
m_memoryview.AcceptedProcess = SelectedProcess; |
553 |
|
|
m_memsearcher.AcceptedProcess = SelectedProcess; |
554 |
william |
267 |
} |
555 |
william |
152 |
|
556 |
william |
639 |
|
557 |
william |
87 |
} |
558 |
|
|
|
559 |
william |
14 |
private void mnuItemExit_Click(object sender, EventArgs e) |
560 |
|
|
{ |
561 |
|
|
this.Close(); |
562 |
|
|
} |
563 |
william |
16 |
|
564 |
william |
17 |
|
565 |
|
|
private void Main_Load(object sender, EventArgs e) |
566 |
william |
144 |
{ |
567 |
william |
722 |
SettingsSubscriber.SaveSettings(); |
568 |
william |
17 |
} |
569 |
william |
63 |
|
570 |
|
|
private void mnuItemConfig_Click(object sender, EventArgs e) |
571 |
|
|
{ |
572 |
william |
86 |
RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader); |
573 |
william |
63 |
dlg.ShowDialog(); |
574 |
william |
813 |
//logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name); |
575 |
william |
92 |
// reload plugins |
576 |
william |
366 |
load_plugins(true); |
577 |
william |
63 |
} |
578 |
william |
69 |
|
579 |
|
|
private void mnuItemOpenProcess_Click(object sender, EventArgs e) |
580 |
|
|
{ |
581 |
william |
148 |
////List<Process> procs = ConfigPlugin.ValidProcessesForPlugin; |
582 |
|
|
//PIDSelector selector = new PIDSelector(ConfigPlugin); |
583 |
|
|
//selector.ShowDialog(); |
584 |
william |
69 |
} |
585 |
william |
104 |
|
586 |
william |
144 |
private void Main_Shown(object sender, EventArgs e) |
587 |
william |
104 |
{ |
588 |
william |
853 |
dockPanel.SuspendLayout(true); |
589 |
william |
152 |
//ShowDocks(); |
590 |
william |
755 |
string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig); |
591 |
william |
152 |
if (File.Exists(configFile)) |
592 |
|
|
{ |
593 |
|
|
try |
594 |
|
|
{ |
595 |
|
|
dockPanel.LoadFromXml(configFile, m_deserializeDockContent); |
596 |
william |
313 |
SetupDockWindowHandler(); |
597 |
william |
893 |
SetDockIcons(); |
598 |
william |
152 |
} |
599 |
william |
177 |
catch (Exception) |
600 |
william |
152 |
{ |
601 |
|
|
ShowDocks(); |
602 |
william |
893 |
SetDockIcons(); |
603 |
william |
152 |
} |
604 |
|
|
} |
605 |
|
|
else |
606 |
|
|
{ |
607 |
william |
852 |
ShowDocks(); |
608 |
william |
893 |
SetDockIcons(); |
609 |
william |
152 |
} |
610 |
|
|
|
611 |
william |
853 |
if(m_PIDSelector != null) |
612 |
|
|
m_PIDSelector.Activate(); |
613 |
|
|
dockPanel.ResumeLayout(true, true); |
614 |
william |
104 |
} |
615 |
william |
144 |
|
616 |
|
|
private void mnuItemShowLogWindow_Click(object sender, EventArgs e) |
617 |
|
|
{ |
618 |
|
|
ShowLogWindow(); |
619 |
|
|
} |
620 |
william |
147 |
|
621 |
|
|
private void mnuItemHelpAbout_Click(object sender, EventArgs e) |
622 |
|
|
{ |
623 |
|
|
ShowAboutBox(); |
624 |
|
|
} |
625 |
william |
148 |
|
626 |
|
|
private void mnuItemShowRamDumpDialog_Click(object sender, EventArgs e) |
627 |
|
|
{ |
628 |
|
|
ShowRamDump(); |
629 |
|
|
} |
630 |
|
|
|
631 |
|
|
private void mnuItemShowPIDSelector_Click(object sender, EventArgs e) |
632 |
|
|
{ |
633 |
|
|
ShowPidSelector(); |
634 |
|
|
} |
635 |
william |
201 |
private void mnuItemShowMemoryView_Click(object sender, EventArgs e) |
636 |
|
|
{ |
637 |
|
|
ShowMemoryView(); |
638 |
|
|
} |
639 |
william |
152 |
private void Main_FormClosing(object sender, FormClosingEventArgs e) |
640 |
|
|
{ |
641 |
william |
722 |
SettingsSubscriber.SaveSettings(); |
642 |
william |
755 |
string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig); |
643 |
william |
152 |
if (m_bSaveLayout) |
644 |
|
|
dockPanel.SaveAsXml(configFile); |
645 |
|
|
else if (File.Exists(configFile)) |
646 |
|
|
File.Delete(configFile); |
647 |
william |
449 |
|
648 |
|
|
SearchResultWriter.CleanupTemporarySearchResultFiles(); |
649 |
|
|
|
650 |
william |
678 |
|
651 |
|
|
// notify any docked windows of formclosing |
652 |
|
|
|
653 |
|
|
foreach (var t in this.dockPanel.Contents) |
654 |
|
|
{ |
655 |
|
|
t.OnDeactivate<FormClosingEventArgs>(e); |
656 |
|
|
} |
657 |
|
|
|
658 |
william |
152 |
} |
659 |
william |
158 |
|
660 |
|
|
private void mnuTestExeParse_Click(object sender, EventArgs e) |
661 |
|
|
{ |
662 |
william |
607 |
IPEDData peData = new PEData((IAcceptsProcessAndConfig)this); |
663 |
william |
158 |
} |
664 |
william |
201 |
|
665 |
|
|
private void mnuItemFindMaxNonNegativeHexValue_Click(object sender, EventArgs e) |
666 |
|
|
{ |
667 |
|
|
|
668 |
|
|
//uint start = 0xf0000000; |
669 |
|
|
uint end = uint.MaxValue; |
670 |
|
|
//for (uint i = start; i < end; i++) |
671 |
|
|
//{ |
672 |
|
|
ulong value = Convert.ToUInt64(end.ToString(), 16); |
673 |
|
|
//} |
674 |
|
|
} |
675 |
william |
218 |
|
676 |
|
|
private void mnuItemShowDataTypeConverter_Click(object sender, EventArgs e) |
677 |
|
|
{ |
678 |
|
|
ShowDataTypeConverter(); |
679 |
|
|
} |
680 |
william |
227 |
|
681 |
|
|
private void mnuItemShowMemorySearch_Click(object sender, EventArgs e) |
682 |
|
|
{ |
683 |
|
|
ShowMemorySearch(); |
684 |
|
|
} |
685 |
william |
260 |
|
686 |
|
|
private void mnuItemDateShift_Click(object sender, EventArgs e) |
687 |
|
|
{ |
688 |
|
|
DateTime t = DateTime.Now; |
689 |
|
|
int year = Convert.ToInt32(t.ToString("yy")); |
690 |
|
|
int y = year << 9; |
691 |
|
|
int m = t.Month << 5; |
692 |
|
|
int d = t.Day; |
693 |
|
|
|
694 |
|
|
ushort v1 = (ushort)(y | m | d); |
695 |
|
|
|
696 |
|
|
t = t.AddDays(1); |
697 |
|
|
year = Convert.ToInt32(t.ToString("yy")); |
698 |
|
|
y = year << 9; |
699 |
|
|
m = t.Month << 5; |
700 |
|
|
d = t.Day; |
701 |
|
|
ushort v2 = (ushort)(y | m | d); |
702 |
|
|
|
703 |
|
|
t = t.AddDays(1); |
704 |
|
|
year = Convert.ToInt32(t.ToString("yy")); |
705 |
|
|
y = year << 9; |
706 |
|
|
m = t.Month << 5; |
707 |
|
|
d = t.Day; |
708 |
|
|
ushort v3 = (ushort)(y | m | d); |
709 |
|
|
|
710 |
|
|
t = new DateTime(9999,12,31); |
711 |
|
|
year = Convert.ToInt32(t.ToString("yy")); |
712 |
|
|
y = year << 9; |
713 |
|
|
m = t.Month << 5; |
714 |
|
|
d = t.Day; |
715 |
|
|
ushort v4 = (ushort)(y | m | d); |
716 |
|
|
} |
717 |
william |
318 |
|
718 |
|
|
private void mnuItemShowPEViewer_Click(object sender, EventArgs e) |
719 |
|
|
{ |
720 |
|
|
ShowPEViewer(); |
721 |
|
|
} |
722 |
|
|
|
723 |
william |
366 |
private void mnuItemShowRVACalculator_Click(object sender, EventArgs e) |
724 |
|
|
{ |
725 |
|
|
ShowRVACalculator(); |
726 |
william |
439 |
} |
727 |
|
|
|
728 |
|
|
private void mnuItemShowUserControlDock_Click(object sender, EventArgs e) |
729 |
|
|
{ |
730 |
|
|
ShowUserControlDock(); |
731 |
william |
596 |
} |
732 |
|
|
|
733 |
|
|
private void mnuItemShowMemorySectionViewer_Click(object sender, EventArgs e) |
734 |
|
|
{ |
735 |
|
|
ShowMemorySectionViewer(); |
736 |
william |
695 |
} |
737 |
|
|
|
738 |
|
|
private void mnuItemShowWebBrowser_Click(object sender, EventArgs e) |
739 |
|
|
{ |
740 |
|
|
ShowWebBrowser(); |
741 |
william |
366 |
} |
742 |
william |
5 |
} |
743 |
|
|
} |