/[RomCheater]/trunk/RomCheater/Docking/FloatingMemorySearcher.cs
ViewVC logotype

Contents of /trunk/RomCheater/Docking/FloatingMemorySearcher.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 457 - (show annotations) (download)
Mon Jun 3 02:10:27 2013 UTC (7 years, 4 months ago) by william
File size: 139022 byte(s)

1 #region Logging Defines
2 // include this any class or method that required logging, and comment-out what is not needed
3
4 #region Enabled logging levels
5 #define LOGGING_ENABLE_INFO
6 #define LOGGING_ENABLE_WARN
7 #define LOGGING_ENABLE_DEBUG
8 #define LOGGING_ENABLE_VERBOSEDEBUG
9 #define LOGGING_ENABLE_ERROR
10 #define LOGGING_ENABLE_VERBOSEERROR
11 #define LOGGING_ENABLE_PROFILER
12 #endregion
13 #endregion
14 //#define USE_AUTOMATIC_MEMORY_SEARCH_RANGE // when defined will automatically choose the best starting address and size for memory search otherwise it will use the constants defined in MemorySizeConstants
15 #if !USE_AUTOMATIC_MEMORY_SEARCH_RANGE
16 #define FORCE_USE_OF_MEMORYSIZECONSTANTS // when defined wil force the use of the constants defined in MemorySizeConstants for memory search range
17 #endif
18 #define DONOT_HAVE_RANGED_SEARCH_SUPPORT // when defined, indicates that ranged searches have not been implemented
19 #define INCREASE_NUMBER_OF_RESULTS_BEFORE_DISPLAY // when defined will set MIN RESULTS to 0x2701 otherwise 0x03e8
20 //#define DO_NOT_SUSPEND_RESUME_THREAD_ON_FREEZE // when defined will not freeze/resume thread on freeze
21 using System;
22 using System.Collections.Generic;
23 using System.ComponentModel;
24 using System.Data;
25 using System.Drawing;
26 using System.Linq;
27 using System.Text;
28 using System.Windows.Forms;
29 using WeifenLuo.WinFormsUI.Docking;
30 using RomCheater.PluginFramework.Interfaces;
31 using System.Diagnostics;
32 using RomCheater.Docking.MemorySearch;
33 using libWin32.Win32.Threading;
34 using System.Threading;
35 using RomCheater.Logging;
36 using System.IO;
37 using Sojaner.MemoryScanner.MemoryProviers;
38 using RomCheater.PluginFramework.Events;
39 using System.Reflection;
40 using Sojaner.MemoryScanner;
41 using System.Collections;
42 using RomCheater.Serialization;
43
44 namespace RomCheater.Docking
45 {
46 public partial class FloatingMemorySearcher : DockContent,
47 IAcceptsPlugin<IConfigPlugin>,
48 IAcceptsProcess<Process>,
49 IAcceptsProcessAndConfig,
50 ISearchInProgress,
51 IAcceptsBrowseMemoryRegion,
52 IAcceptsMemoryRange
53 {
54 #if INCREASE_NUMBER_OF_RESULTS_BEFORE_DISPLAY
55 const int MIN_NUMBER_OF_RESULTS_BEFORE_DISPLAY = 0x2701; // 10,000 results
56 #else
57 const int MIN_NUMBER_OF_RESULTS_BEFORE_DISPLAY = 0x03e8; // 1,000 results
58 #endif
59
60 const bool USE_OLD_SEARCH_RESULTS_COMPRATOR_CODE = false;
61 const bool USE_NONRANGE_SEARCH_RESULT_READER = false;
62 private bool DefaultUnsignedState = true; // set unsigned to true
63 public FloatingMemorySearcher() { InitializeComponent(); this.AcceptedPlugin = null; OnBrowseMemoryRegion = null; this.AcceptedProcess = null; SearchInProgess = false; Reload(); }
64 public FloatingMemorySearcher(IConfigPlugin config) : this() { this.AcceptedPlugin = config; }
65 public FloatingMemorySearcher(IConfigPlugin config, Process process) : this() { this.AcceptedPlugin = config; this.AcceptedProcess = process; }
66
67 #region IAcceptsProcess<Process> Members
68 private Process _AcceptedProcess;
69 public Process AcceptedProcess { get { return _AcceptedProcess; } set { _AcceptedProcess = value; UpdateAcceptedProcess(value); } }
70 #endregion
71 #region IAcceptsPlugin<IConfigPlugin> Members
72 private IConfigPlugin _AcceptedPlugin;
73 public IConfigPlugin AcceptedPlugin { get { return _AcceptedPlugin; } set { _AcceptedPlugin = value; UpdateAcceptedPlugin(value); } }
74 #endregion
75 #region IAcceptsBrowseMemoryRegion members
76 public event BaseEventHandler<BrowseMemoryRegionEvent> OnBrowseMemoryRegion;
77 #endregion
78
79 private void UpdateAcceptedPlugin(IConfigPlugin config)
80 {
81 this.lstResults.AcceptedPlugin = config;
82 this.lstPatchList.AcceptedPlugin = config;
83 if (config != null)
84 {
85 MemoryRangeStart = AcceptedPlugin.MemoryRangeStart;
86 MemoryRangeSize = AcceptedPlugin.MemoryRangeStart + AcceptedPlugin.MemoryRangeSize;
87 }
88 }
89 private void UpdateAcceptedProcess(Process process)
90 {
91 this.lstResults.AcceptedProcess = process;
92 this.lstPatchList.AcceptedProcess = process;
93 #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && FORCE_USE_OF_MEMORYSIZECONSTANTS
94 logger.Warn.WriteLine("FloatingMemorySearcher.UpdateAcceptedProcessAndConfig(IConfigPlugin config, Process process):");
95 logger.Warn.WriteLine("Both USE_AUTOMATIC_MEMORY_SEARCH_RANGE and FORCE_USE_OF_MEMORYSIZECONSTANTS are defined");
96 logger.Warn.WriteLine("FORCE_USE_OF_MEMORYSIZECONSTANTS will take precedence and will ignore the values supplied in the memeory search range");
97 #endif
98 #if FORCE_USE_OF_MEMORYSIZECONSTANTS
99 // force use of MemorySizeConstants
100 txtMemoryRangeStart.Value = MemorySizeConstants.MinimumSearchAddress;
101 txtMemoryRangeSize.Value = MemorySizeConstants.MinimumSearchAddress + MemorySizeConstants.MaximumSearchSize;
102 #endif
103 #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && !FORCE_USE_OF_MEMORYSIZECONSTANTS
104 ////// code to automatically choose the best starting memory address and size
105 //if (process != null)
106 //{
107 // string filename = process.MainModule.FileName;
108 // //string filename = @"c:\Windows\notepad.exe";
109 // PEReader peReader = new PEReader(filename);
110 //}
111 //else
112 //{
113 //txtMemoryRangeStart.Value = MemorySizeConstants.MinimumSearchAddress;
114 //txtMemoryRangeSize.Value = MemorySizeConstants.MinimumSearchAddress + MemorySizeConstants.MaximumSearchSize;
115 //}
116 if (AcceptedPlugin != null)
117 {
118 MemoryRangeStart = AcceptedPlugin.MemoryRangeStart;
119 MemoryRangeSize = AcceptedPlugin.MemoryRangeStart + AcceptedPlugin.MemoryRangeSize;
120 }
121
122 #endif
123
124 }
125 #region ISearchInProgress members
126 private bool _SearchInProgess;
127 public bool SearchInProgess
128 {
129 get { return _SearchInProgess; }
130 private set
131 {
132 _SearchInProgess = value;
133 if (this.AcceptedPlugin != null)
134 this.AcceptedPlugin.SetMemorySearchReference(this);
135 }
136 }
137 private Guid _SearchGuid;
138 public Guid SearchGuid
139 {
140 get { return _SearchGuid; }
141 private set { _SearchGuid = value; }
142 }
143 #endregion
144
145 #region IAcceptsMemoryRange
146 #if !FORCE_USE_OF_MEMORYSIZECONSTANTS
147 private uint _MemoryRangeStart;
148 private uint _MemoryRangeSize;
149 #endif
150 public uint MemoryRangeStart
151 {
152 get
153 {
154 #if FORCE_USE_OF_MEMORYSIZECONSTANTS
155 return MemorySizeConstants.MinimumSearchAddress;
156 #else
157 return _MemoryRangeStart;
158 #endif
159 }
160 set
161 {
162 #if !FORCE_USE_OF_MEMORYSIZECONSTANTS
163 _MemoryRangeStart = value;
164 txtMemoryRangeStart.Value = value;
165 #endif
166 }
167 }
168 public uint MemoryRangeSize
169 {
170 get
171 {
172 #if FORCE_USE_OF_MEMORYSIZECONSTANTS
173 return MemorySizeConstants.MinimumSearchAddress + MemorySizeConstants.MaximumSearchSize;
174 #else
175 return _MemoryRangeSize;
176 #endif
177 }
178 set
179 {
180 #if !FORCE_USE_OF_MEMORYSIZECONSTANTS
181 _MemoryRangeSize = value;
182 txtMemoryRangeSize.Value = value;
183 #endif
184 }
185 }
186 #endregion
187
188 public void Reload()
189 {
190 chkUnsigned.Checked = DefaultUnsignedState;
191 radio_8bits.Checked = true;
192 radiocompare_equal.Checked = true;
193 radio_oldvalue.Checked = true;
194 chkRefreshResults.Checked = true;
195 }
196 public enum eListViewResults
197 {
198 SEARCH_RESULTS_LIST = 0x3000,
199 PATCH_RESULTS_LIST = 0x3001,
200 UKNOWN_RESULTS_LIST = 0x3001
201 }
202 bool IsFirstSearch = true;
203 SearchType SearchArgs;
204 static int col_Found_Address = 1;
205 static int col_Found_Value = 2;
206 //static int col_Found_Frozen = 3; /* unused */
207 static int col_Added_Address = 1;
208 static int col_Added_Value = 2;
209 //static int col_Added_Frozen = 3; /* unused */
210 List<ListViewItem> ResultItems = new List<ListViewItem>();
211 List<ListViewItem> AddedItems = new List<ListViewItem>();
212 private bool _PatchedValue_NeedsUpdate;
213 bool PatchedValue_NeedsUpdate
214 {
215 get { if (_PatchedValue_NeedsUpdate) this.ThawResultsUpdate(); return _PatchedValue_NeedsUpdate; }
216 set { _PatchedValue_NeedsUpdate = value; if (value) this.ThawResultsUpdate(); }
217 }
218 private delegate ListViewItem ThreadSafe_GetResultItem(int index, int lv_type);
219 private ListViewItem GetResultItem(int index, int lv_type)
220 {
221 try
222 {
223 AddressValuePairList lv = null;
224 switch (lv_type)
225 {
226 case (int)eListViewResults.SEARCH_RESULTS_LIST: lv = lstResults; break;
227 case (int)eListViewResults.PATCH_RESULTS_LIST: lv = lstPatchList; break;
228 default: throw new IndexOutOfRangeException("Detected: " + Enum.GetName(typeof(eListViewResults), eListViewResults.UKNOWN_RESULTS_LIST) + " with value: " + lv_type.ToString("x4"));
229 }
230 ListViewItem item = new ListViewItem();
231 item = (ListViewItem)lv.Items[index].Clone();
232 return item;
233 }
234 catch (Exception)
235 {
236 return null;
237 }
238 }
239 private void radiocompare_equal_CheckedChanged(object sender, EventArgs e)
240 {
241 //if (!radiocompare_between.Checked && !radiocompare_notbetween.Checked)
242 //{
243 if (radio_oldvalue.Checked)
244 {
245 txtStartAddr.ReadOnly = true;
246 txtEndAddr.ReadOnly = true;
247 }
248 if (radio_specificvalue.Checked)
249 {
250 txtStartAddr.ReadOnly = false;
251 txtEndAddr.ReadOnly = true;
252 }
253 //}
254 }
255
256 private void radiocompare_between_CheckedChanged(object sender, EventArgs e)
257 {
258 if (!radiocompare_equal.Checked &&
259 !radiocompare_greaterthan.Checked &&
260 !radiocompare_greaterthan.Checked &&
261 !radiocompare_lessthan.Checked &&
262 !radiocompare_greaterthan_orequal.Checked &&
263 !radiocompare_lessthan_orequal.Checked &&
264 !radiocompare_notequal.Checked)
265 if (radiocompare_between.Checked)
266 {
267 txtStartAddr.ReadOnly = false;
268 txtEndAddr.ReadOnly = false;
269 return;
270 }
271 if (!radiocompare_between.Checked && !radiocompare_notbetween.Checked)
272 {
273 if (radio_oldvalue.Checked)
274 {
275 txtStartAddr.ReadOnly = true;
276 txtEndAddr.ReadOnly = true;
277 }
278 if (radio_specificvalue.Checked)
279 {
280 txtStartAddr.ReadOnly = false;
281 txtEndAddr.ReadOnly = true;
282 }
283 }
284 }
285
286 private void radiocompare_notbetween_CheckedChanged(object sender, EventArgs e)
287 {
288 if (!radiocompare_equal.Checked &&
289 !radiocompare_greaterthan.Checked &&
290 !radiocompare_greaterthan.Checked &&
291 !radiocompare_lessthan.Checked &&
292 !radiocompare_greaterthan_orequal.Checked &&
293 !radiocompare_lessthan_orequal.Checked &&
294 !radiocompare_notequal.Checked)
295 if (radiocompare_notbetween.Checked)
296 {
297 txtStartAddr.ReadOnly = false;
298 txtEndAddr.ReadOnly = false;
299 return;
300 }
301 if (!radiocompare_between.Checked && !radiocompare_notbetween.Checked)
302 {
303 if (radio_oldvalue.Checked)
304 {
305 txtStartAddr.ReadOnly = true;
306 txtEndAddr.ReadOnly = true;
307 }
308 if (radio_specificvalue.Checked)
309 {
310 txtStartAddr.ReadOnly = false;
311 txtEndAddr.ReadOnly = true;
312 }
313 }
314 }
315
316 private void radio_8bits_CheckedChanged(object sender, EventArgs e)
317 {
318 if (chkUnsigned.Checked)
319 {
320 txtStartAddr.CreateTypeSize<byte>();
321 txtEndAddr.CreateTypeSize<byte>();
322 }
323 else
324 {
325 txtStartAddr.CreateTypeSize<sbyte>();
326 txtEndAddr.CreateTypeSize<sbyte>();
327 }
328 }
329
330 private void radio_16bits_CheckedChanged(object sender, EventArgs e)
331 {
332 if (chkUnsigned.Checked)
333 {
334 txtStartAddr.CreateTypeSize<ushort>();
335 txtEndAddr.CreateTypeSize<ushort>();
336 }
337 else
338 {
339 txtStartAddr.CreateTypeSize<short>();
340 txtEndAddr.CreateTypeSize<short>();
341 }
342 }
343
344 private void radio_32bits_CheckedChanged(object sender, EventArgs e)
345 {
346
347 if (chkUnsigned.Checked)
348 {
349 txtStartAddr.CreateTypeSize<uint>();
350 txtEndAddr.CreateTypeSize<uint>();
351 }
352 else
353 {
354 txtStartAddr.CreateTypeSize<int>();
355 txtEndAddr.CreateTypeSize<int>();
356 }
357 }
358
359 private void radio_64bits_CheckedChanged(object sender, EventArgs e)
360 {
361
362 if (chkUnsigned.Checked)
363 {
364 txtStartAddr.CreateTypeSize<ulong>();
365 txtEndAddr.CreateTypeSize<ulong>();
366 }
367 else
368 {
369 txtStartAddr.CreateTypeSize<long>();
370 txtEndAddr.CreateTypeSize<long>();
371 }
372 }
373
374 private void radio_oldvalue_CheckedChanged(object sender, EventArgs e)
375 {
376 if (!radiocompare_between.Checked && !radiocompare_notbetween.Checked)
377 {
378 txtStartAddr.ReadOnly = true;
379 txtEndAddr.ReadOnly = true;
380 }
381 }
382
383 private void radio_specificvalue_CheckedChanged(object sender, EventArgs e)
384 {
385 if (!radiocompare_between.Checked && !radiocompare_notbetween.Checked)
386 {
387 txtStartAddr.ReadOnly = false;
388 txtEndAddr.ReadOnly = true;
389 }
390 }
391
392 private void chkRefreshResults_CheckedChanged(object sender, EventArgs e)
393 {
394 if (chkRefreshResults.Checked)
395 {
396 timer_update_results.Enabled = true;
397 }
398 else
399 {
400 timer_update_results.Enabled = false;
401 ResultsUpdateWorkerThread.CancelAsync();
402 }
403 }
404
405 private void timer_update_results_Tick(object sender, EventArgs e)
406 {
407 if (chkRefreshResults.Checked && !ResultsUpdateWorkerThread.IsBusy)
408 {
409 ResultsUpdateWorkerThread.RunWorkerAsync();
410 }
411 }
412 private bool ShouldUpdateResults()
413 {
414 if (this.AcceptedProcess == null) return false;
415 if (SearchWorkerThread.IsBusy) return false;
416 //if (JokerSearchWorker.IsBusy) return false;
417 if (this.IsResultsUpdateFrozen) return false;
418 if (mnuAddedResults.Visible) return false;
419 if (mnuResults.Visible) return false;
420 if (Process.GetProcessById(this.AcceptedProcess.Id) == null) return false;
421 if (lstResults.Items.Count > 0) return true;
422 if (lstPatchList.Items.Count > 0) return true;
423 return false;
424 }
425 private void ResultsUpdateWorkerThread_DoWork(object sender, DoWorkEventArgs e)
426 {
427 Thread.Sleep(250); // keep thread from blocking
428 if (!this.ShouldUpdateResults()) return;
429 ////if (SearchArgs == null) return;
430 ////if (this.IsResultsUpdateFrozen) return;
431 ////// put thread to sleep for 500ms
432 ////System.Threading.Thread.Sleep(500);
433 //PCSX2MemoryProvider provider = new PCSX2MemoryProvider(this.SearchPCSX2ProcessPID, resultslog);
434 //byte[] buffered_mem = provider.GetMemory();
435 //MemoryStream ms = new MemoryStream(buffered_mem);
436 //BinaryReader r_ms = new BinaryReader(ms);
437
438 #region Update Results List
439 ResultItems = new List<ListViewItem>();
440 //r_ms.BaseStream.Seek(0, SeekOrigin.Begin);
441 for (int i = 0; i < lstResults.Items.Count; i++)
442 {
443 if (this.lstResults.InvokeRequired)
444 {
445 ThreadSafe_GetResultItem _get_item = new ThreadSafe_GetResultItem(GetResultItem);
446 object item = this.lstResults.Invoke(_get_item, new object[] { i, (int)eListViewResults.SEARCH_RESULTS_LIST });
447 if (item != null)
448 ResultItems.Add((ListViewItem)item);
449 }
450 else
451 {
452 ResultItems.Add(lstResults.Items[i]);
453 }
454
455 }
456 for (int i = 0; i < ResultItems.Count; i++)
457 {
458 if (ResultsUpdateWorkerThread.CancellationPending == true)
459 {
460 e.Cancel = true;
461 return;
462 }
463 int Address = 0;
464 ResultDataType _result = (ResultDataType)ResultItems[i].Tag;
465
466 Address = Convert.ToInt32(ResultItems[i].SubItems[col_Found_Address].Text, 16);
467 //r_ms.BaseStream.Seek(Address, SeekOrigin.Begin);
468 using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
469 {
470 provider.OpenProvider();
471 int bytesReadSize;
472 byte[] data;
473 uint bytesToRead = 0;
474 switch (_result.ValueType)
475 {
476 case SearchDataTypes._8bits:
477 bytesToRead = 1;
478 break;
479 case SearchDataTypes._16bits:
480 bytesToRead = 2;
481 break;
482 case SearchDataTypes._32bits:
483 bytesToRead = 4;
484 break;
485 case SearchDataTypes._64bits:
486 bytesToRead = 8;
487 break;
488 }
489 provider.ReadProcessMemory(Address, bytesToRead, out bytesReadSize, out data);
490 using (MemoryStream ms = new MemoryStream(data))
491 {
492 using (BinaryReader r_ms = new BinaryReader(ms))
493 {
494 switch (_result.ValueType)
495 {
496 case SearchDataTypes._8bits:
497 if (_result.IsUnsigned) { ResultItems[i].SubItems[col_Found_Value].Text = string.Format("0x{0:x2}", r_ms.ReadByte()); }
498 else { ResultItems[i].SubItems[col_Found_Value].Text = string.Format("0x{0:x2}", r_ms.ReadSByte()); }
499 break;
500 case SearchDataTypes._16bits:
501 if (_result.IsUnsigned) { ResultItems[i].SubItems[col_Found_Value].Text = string.Format("0x{0:x4}", r_ms.ReadUInt16()); }
502 else { ResultItems[i].SubItems[col_Found_Value].Text = string.Format("0x{0:x4}", r_ms.ReadInt16()); }
503 break;
504 case SearchDataTypes._32bits:
505 if (_result.IsUnsigned) { ResultItems[i].SubItems[col_Found_Value].Text = string.Format("0x{0:x8}", r_ms.ReadUInt32()); }
506 else { ResultItems[i].SubItems[col_Found_Value].Text = string.Format("0x{0:x8}", r_ms.ReadInt32()); }
507 break;
508 case SearchDataTypes._64bits:
509 if (_result.IsUnsigned) { ResultItems[i].SubItems[col_Found_Value].Text = string.Format("0x{0:x16}", r_ms.ReadUInt64()); }
510 else { ResultItems[i].SubItems[col_Found_Value].Text = string.Format("0x{0:x16}", r_ms.ReadInt64()); }
511 break;
512 }
513 r_ms.Close();
514 }
515 }
516 provider.CloseProvider();
517 }
518 //Application.DoEvents();
519 }
520 #endregion
521
522 #region Update Added Results List
523 AddedItems = new List<ListViewItem>();
524 //r_ms.BaseStream.Seek(0, SeekOrigin.Begin);
525 for (int i = 0; i < lstPatchList.Items.Count; i++)
526 {
527 if (this.lstResults.InvokeRequired)
528 {
529 ThreadSafe_GetResultItem _get_item = new ThreadSafe_GetResultItem(GetResultItem);
530 object item = this.lstResults.Invoke(_get_item, new object[] { i, (int)eListViewResults.PATCH_RESULTS_LIST });
531 if (item != null)
532 AddedItems.Add((ListViewItem)item);
533 }
534 else
535 {
536 AddedItems.Add(lstPatchList.Items[i]);
537 }
538
539 }
540 for (int i = 0; i < AddedItems.Count; i++)
541 {
542 if (ResultsUpdateWorkerThread.CancellationPending == true)
543 {
544 e.Cancel = true;
545 return;
546 }
547 int Address = 0;
548 ResultDataType _result = (ResultDataType)AddedItems[i].Tag;
549 Address = Convert.ToInt32(AddedItems[i].SubItems[col_Added_Address].Text, 16);
550 using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
551 {
552 provider.OpenProvider();
553 int bytesReadSize;
554 byte[] data;
555 uint bytesToRead = 0;
556 switch (_result.ValueType)
557 {
558 case SearchDataTypes._8bits:
559 bytesToRead = 1;
560 break;
561 case SearchDataTypes._16bits:
562 bytesToRead = 2;
563 break;
564 case SearchDataTypes._32bits:
565 bytesToRead = 4;
566 break;
567 case SearchDataTypes._64bits:
568 bytesToRead = 8;
569 break;
570 }
571 provider.ReadProcessMemory(Address, bytesToRead, out bytesReadSize, out data);
572 provider.CloseProvider();
573 using (MemoryStream ms = new MemoryStream(data))
574 {
575 using (BinaryReader r_ms = new BinaryReader(ms))
576 {
577 switch (_result.ValueType)
578 {
579 case SearchDataTypes._8bits:
580 if (_result.IsUnsigned) { AddedItems[i].SubItems[col_Added_Value].Text = string.Format("0x{0:x2}", r_ms.ReadByte()); }
581 else { AddedItems[i].SubItems[col_Added_Value].Text = string.Format("0x{0:x2}", r_ms.ReadSByte()); }
582 break;
583 case SearchDataTypes._16bits:
584 if (_result.IsUnsigned) { AddedItems[i].SubItems[col_Added_Value].Text = string.Format("0x{0:x4}", r_ms.ReadUInt16()); }
585 else { AddedItems[i].SubItems[col_Added_Value].Text = string.Format("0x{0:x4}", r_ms.ReadInt16()); }
586 break;
587 case SearchDataTypes._32bits:
588 if (_result.IsUnsigned) { AddedItems[i].SubItems[col_Added_Value].Text = string.Format("0x{0:x8}", r_ms.ReadUInt32()); }
589 else { AddedItems[i].SubItems[col_Added_Value].Text = string.Format("0x{0:x8}", r_ms.ReadInt32()); }
590 break;
591 case SearchDataTypes._64bits:
592 if (_result.IsUnsigned) { AddedItems[i].SubItems[col_Added_Value].Text = string.Format("0x{0:x16}", r_ms.ReadUInt64()); }
593 else { AddedItems[i].SubItems[col_Added_Value].Text = string.Format("0x{0:x16}", r_ms.ReadInt64()); }
594 break;
595 }
596 r_ms.Close();
597 }
598 }
599 }
600 //Application.DoEvents();
601 }
602 #endregion
603
604
605 }
606
607 private void ResultsUpdateWorkerThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
608 {
609 try
610 {
611 //if ((lstResults.SelectedItems.Count > 0) && !PatchedValue_NeedsUpdate ) return;
612 //if ((lstPatchList.SelectedItems.Count > 0) && !PatchedValue_NeedsUpdate) return;
613 if (!this.ShouldUpdateResults()) return;
614 if (ResultItems.Count > 0)
615 {
616 //lstResults.Items.Clear();
617 //lstResults.Items.AddRange(ResultItems.ToArray());
618
619 for (int i = 0; i < ResultItems.Count; i++)
620 {
621 lstResults.Items[i].SubItems[new AVPColumnText(AVPColumnType.VALUE).ColumnIndex].Text =
622 ResultItems[i].SubItems[new AVPColumnText(AVPColumnType.VALUE).ColumnIndex].Text;
623 }
624
625 }
626 if (AddedItems.Count > 0)
627 {
628 //lstPatchList.Items.Clear();
629 //lstPatchList.Items.AddRange(AddedItems.ToArray());
630
631 for (int i = 0; i < AddedItems.Count; i++)
632 {
633 lstPatchList.Items[i].SubItems[new AVPColumnText(AVPColumnType.VALUE).ColumnIndex].Text =
634 AddedItems[i].SubItems[new AVPColumnText(AVPColumnType.VALUE).ColumnIndex].Text;
635 }
636
637 }
638 PatchedValue_NeedsUpdate = false;
639 }
640 catch { }
641 }
642
643 private void btnImportFile_Click(object sender, EventArgs e)
644 {
645 this.FreezeResultsUpdate();
646 if (!lstPatchList.ImportFromFile())
647 {
648 MessageBox.Show("Failed to Import Patch List from File.", "Import Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
649 this.ThawResultsUpdate();
650 return;
651 }
652 else
653 {
654 MessageBox.Show("Succesfully Imported Patch List from File.", "Import Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
655 this.ThawResultsUpdate();
656 return;
657 }
658 }
659 bool g_isFrozen = false;
660 private bool IsResultsUpdateFrozen
661 {
662 get { return g_isFrozen; }
663 set { g_isFrozen = value; }
664 }
665 private void ThawResultsUpdate()
666 {
667 this.IsResultsUpdateFrozen = false;
668 if (this.AcceptedProcess != null)
669 {
670 #if !DO_NOT_SUSPEND_RESUME_THREAD_ON_FREEZE
671 ThreadControl.ResumeProcess(this.AcceptedProcess.Id);
672 #endif
673 }
674 }
675
676 private void FreezeResultsUpdate()
677 {
678 this.IsResultsUpdateFrozen = true;
679 //this.IsResultsUpdateFrozen = false;
680 if (this.AcceptedProcess != null)
681 {
682 #if !DO_NOT_SUSPEND_RESUME_THREAD_ON_FREEZE
683 ThreadControl.SuspendProcess(this.AcceptedProcess.Id);
684 #endif
685 }
686 }
687
688 private void btnExportFile_Click(object sender, EventArgs e)
689 {
690 this.FreezeResultsUpdate();
691 if (!lstPatchList.ExportToFile())
692 {
693 MessageBox.Show("Failed to Export Patch List to File.", "Export Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
694 this.ThawResultsUpdate();
695 return;
696 }
697 else
698 {
699 MessageBox.Show("Succesfully Exported Patch List to File.", "Export Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
700 this.ThawResultsUpdate();
701 return;
702 }
703 }
704
705 private void btnImportClipboard_Click(object sender, EventArgs e)
706 {
707 this.FreezeResultsUpdate();
708 if (!lstPatchList.ImportFromClipboard())
709 {
710 MessageBox.Show("Failed to Import Patch List from Clipboard.", "Import Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
711 this.ThawResultsUpdate();
712 return;
713 }
714 else
715 {
716 MessageBox.Show("Succesfully Import Patch List from Clipboard.", "Import Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
717 this.ThawResultsUpdate();
718 }
719 }
720
721 private void btnExportClipboard_Click(object sender, EventArgs e)
722 {
723 this.FreezeResultsUpdate();
724 if (!lstPatchList.ExportToClipboard())
725 {
726 MessageBox.Show("Failed to Export Patch List to Clipboard.", "Export Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
727 this.ThawResultsUpdate();
728 return;
729 }
730 else
731 {
732 MessageBox.Show("Succesfully Exported Patch List to Clipboard.", "Export Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
733 this.ThawResultsUpdate();
734 return;
735 }
736 }
737
738 private void btnAddPatchAddress_Click(object sender, EventArgs e)
739 {
740 PatchAdder adder = new PatchAdder((IAcceptsProcessAndConfig)this);
741 adder.ShowDialog();
742 if (adder.WasAPatchAdded) AddToPatchList(adder.AddedPatchValue);
743 }
744
745 private void btnAddAddressRange_Click(object sender, EventArgs e)
746 {
747 PatchRangeAdder adder = new PatchRangeAdder((IAcceptsProcessAndConfig)this);
748 adder.ShowDialog();
749 if (adder.WasAPatchAdded) AddToPatchList(adder.AddedPatchValue);
750 }
751 private void AddToPatchList(List<ResultDataType> item) { foreach (ResultDataType data in item) { AddToPatchList(data); } }
752 private void AddToPatchList(ResultDataType item)
753 {
754 ResultItem item2 = null;
755 switch (item.ValueType)
756 {
757 case SearchDataTypes._8bits:
758 if (item.IsUnsigned) { item2 = new ResultItem(item.Address, item.IsFrozen, Convert.ToByte(item.Value)); }
759 else { item2 = new ResultItem(item.Address, item.IsFrozen, Convert.ToSByte(item.Value)); }
760 break;
761 case SearchDataTypes._16bits:
762 if (item.IsUnsigned) { item2 = new ResultItem(item.Address, item.IsFrozen, Convert.ToUInt16(item.Value)); }
763 else { item2 = new ResultItem(item.Address, item.IsFrozen, Convert.ToInt16(item.Value)); }
764 break;
765 case SearchDataTypes._32bits:
766 if (item.IsUnsigned) { item2 = new ResultItem(item.Address, item.IsFrozen, Convert.ToUInt32(item.Value)); }
767 else { item2 = new ResultItem(item.Address, item.IsFrozen, Convert.ToInt32(item.Value)); }
768 break;
769 case SearchDataTypes._64bits:
770 if (item.IsUnsigned) { item2 = new ResultItem(item.Address, item.IsFrozen, Convert.ToUInt64(item.Value)); }
771 else { item2 = new ResultItem(item.Address, item.IsFrozen, Convert.ToInt64(item.Value)); }
772 break;
773 }
774 this.AddToPatchList(item2);
775 }
776 private void AddToPatchList(ListViewItem item)
777 {
778 try
779 {
780 ResultDataType _result = (ResultDataType)item.Tag;
781 this.AddToPatchList(_result);
782 }
783 catch (InvalidCastException ex)
784 {
785 // unable to cast
786 MessageBox.Show(ex.Message, "Invalid Cast Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
787 }
788 catch (Exception ex)
789 {
790 // other exception
791 MessageBox.Show(ex.Message, "Unhandled Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
792 }
793 }
794 private void AddToPatchList(ResultItem item)
795 {
796 if (!lstPatchList.Items.Contains(item)) lstPatchList.Items.Add(item);
797 }
798 private void AddToPatchList(string address, SearchDataTypes bitsize, bool IsUnsigned)
799 {
800 ResultItemState state = new ResultItemState(address, bitsize, IsUnsigned, (IAcceptsProcessAndConfig)this);
801 ResultItem item = new ResultItem(state.Address, state.Value, state.Frozen, state.ValueType, state.IsUnsigned);
802 this.AddToPatchList(item);
803 }
804
805 private void mnuItemAddToPatchList_Click(object sender, EventArgs e)
806 {
807 if (!(lstResults.SelectedItems.Count > 0)) return;
808 //if (SearchArgs == null) return;
809
810 try
811 {
812 for (int i = 0; i < lstResults.SelectedIndices.Count; i++)
813 {
814 //ResultDataType result = (ResultDataType)lstResults.Items[selected_index].Tag;
815 ListViewItem item = lstResults.Items[lstResults.SelectedIndices[i]];
816 this.AddToPatchList(item);
817 }
818 }
819 catch (Exception ex)
820 {
821 logger.Error.WriteLine(ex.ToString());
822 }
823 }
824
825 private void mnuItemRemoveResult_Click(object sender, EventArgs e)
826 {
827 if (!(lstPatchList.SelectedItems.Count > 0)) return;
828 //if (SearchArgs == null) return;
829 try
830 {
831 this.FreezeResultsUpdate();
832 for (int i = 0; i < lstPatchList.SelectedIndices.Count; i++)
833 {
834 //lstPatchList.ThawItem(lstPatchList.SelectedIndices[i]);
835 lstPatchList.Items[lstPatchList.SelectedIndices[i]].Remove();
836 }
837 this.ThawResultsUpdate();
838 }
839 catch (Exception ex)
840 {
841 Debug.WriteLine(ex.ToString());
842 }
843 }
844 private void PatchRange(bool SingleEntry)
845 {
846 //if (SearchArgs == null) return;
847 #region Patch Selected Address
848 // stop ResultsUpdate Thread
849 ResultsUpdateWorkerThread.CancelAsync();
850
851 List<ResultDataType> patch_list = new List<ResultDataType>();
852 List<int> SelectedIndexes = new List<int>();
853
854 if (SingleEntry)
855 {
856 SelectedIndexes.Add(lstPatchList.SelectedIndices[0]);
857 }
858 else
859 {
860 foreach (int index in lstPatchList.SelectedIndices)
861 {
862 SelectedIndexes.Add(index);
863 }
864 }
865 //PCSX2MemoryProvider provider = new PCSX2MemoryProvider(this.SearchPCSX2ProcessPID, resultslog);
866 foreach (int index in SelectedIndexes)
867 {
868 if (SingleEntry)
869 {
870 SearchPatcher patcher = null;
871 uint Address = 0;
872 ListViewItem item = lstPatchList.Items[index];
873 ResultDataType _result = (ResultDataType)item.Tag;
874 Address = Convert.ToUInt32(item.SubItems[col_Found_Address].Text, 16);
875 switch (_result.ValueType)
876 {
877 case SearchDataTypes._8bits:
878 if (_result.IsUnsigned)
879 {
880 byte value = Convert.ToByte(item.SubItems[col_Found_Value].Text, 16);
881 patcher = new SearchPatcher((IAcceptsProcessAndConfig)this, Address, value);
882 timer_update_results.Enabled = false;
883 patcher.ShowDialog();
884 timer_update_results.Enabled = true;
885 PatchedValue_NeedsUpdate = true;
886 if (!chkRefreshResults.Checked && !ResultsUpdateWorkerThread.IsBusy)
887 ResultsUpdateWorkerThread.RunWorkerAsync();
888 }
889 else
890 {
891 sbyte value = Convert.ToSByte(item.SubItems[col_Found_Value].Text, 16);
892 patcher = new SearchPatcher((IAcceptsProcessAndConfig)this, Address, value);
893 timer_update_results.Enabled = false;
894 patcher.ShowDialog();
895 timer_update_results.Enabled = true;
896 PatchedValue_NeedsUpdate = true;
897 if (!chkRefreshResults.Checked && !ResultsUpdateWorkerThread.IsBusy)
898 ResultsUpdateWorkerThread.RunWorkerAsync();
899 }
900 break;
901 case SearchDataTypes._16bits:
902 if (_result.IsUnsigned)
903 {
904 ushort value = Convert.ToUInt16(item.SubItems[col_Found_Value].Text, 16);
905 patcher = new SearchPatcher((IAcceptsProcessAndConfig)this, Address, value);
906 timer_update_results.Enabled = false;
907 patcher.ShowDialog();
908 timer_update_results.Enabled = true;
909 PatchedValue_NeedsUpdate = true;
910 if (!chkRefreshResults.Checked && !ResultsUpdateWorkerThread.IsBusy)
911 ResultsUpdateWorkerThread.RunWorkerAsync();
912 }
913 else
914 {
915 short value = Convert.ToInt16(item.SubItems[col_Found_Value].Text, 16);
916 patcher = new SearchPatcher((IAcceptsProcessAndConfig)this, Address, value);
917 timer_update_results.Enabled = false;
918 patcher.ShowDialog();
919 timer_update_results.Enabled = true;
920 PatchedValue_NeedsUpdate = true;
921 if (!chkRefreshResults.Checked && !ResultsUpdateWorkerThread.IsBusy)
922 ResultsUpdateWorkerThread.RunWorkerAsync();
923 }
924 break;
925 case SearchDataTypes._32bits:
926 if (_result.IsUnsigned)
927 {
928 uint value = Convert.ToUInt32(item.SubItems[col_Found_Value].Text, 16);
929 patcher = new SearchPatcher((IAcceptsProcessAndConfig)this, Address, value);
930 timer_update_results.Enabled = false;
931 patcher.ShowDialog();
932 timer_update_results.Enabled = true;
933 PatchedValue_NeedsUpdate = true;
934 if (!chkRefreshResults.Checked && !ResultsUpdateWorkerThread.IsBusy)
935 ResultsUpdateWorkerThread.RunWorkerAsync();
936 }
937 else
938 {
939 int value = Convert.ToInt32(item.SubItems[col_Found_Value].Text, 16);
940 patcher = new SearchPatcher((IAcceptsProcessAndConfig)this, Address, value);
941 timer_update_results.Enabled = false;
942 patcher.ShowDialog();
943 timer_update_results.Enabled = true;
944 PatchedValue_NeedsUpdate = true;
945 if (!chkRefreshResults.Checked && !ResultsUpdateWorkerThread.IsBusy)
946 ResultsUpdateWorkerThread.RunWorkerAsync();
947 }
948 break;
949 case SearchDataTypes._64bits:
950 if (_result.IsUnsigned)
951 {
952 ulong value = Convert.ToUInt32(item.SubItems[col_Found_Value].Text, 16);
953 patcher = new SearchPatcher((IAcceptsProcessAndConfig)this, Address, value);
954 timer_update_results.Enabled = false;
955 patcher.ShowDialog();
956 timer_update_results.Enabled = true;
957 PatchedValue_NeedsUpdate = true;
958 if (!chkRefreshResults.Checked && !ResultsUpdateWorkerThread.IsBusy)
959 ResultsUpdateWorkerThread.RunWorkerAsync();
960 }
961 else
962 {
963 long value = Convert.ToInt32(item.SubItems[col_Found_Value].Text, 16);
964 patcher = new SearchPatcher((IAcceptsProcessAndConfig)this, Address, value);
965 timer_update_results.Enabled = false;
966 patcher.ShowDialog();
967 timer_update_results.Enabled = true;
968 PatchedValue_NeedsUpdate = true;
969 if (!chkRefreshResults.Checked && !ResultsUpdateWorkerThread.IsBusy)
970 ResultsUpdateWorkerThread.RunWorkerAsync();
971 }
972 break;
973 }
974 }
975 else
976 {
977
978 ListViewItem item = lstPatchList.Items[index];
979 ResultDataType _result = (ResultDataType)item.Tag;
980 patch_list.Add(_result);
981 }
982 }
983
984 if (patch_list.Count > 0)
985 {
986 SearchRangePatcher rangePatcher = new SearchRangePatcher((IAcceptsProcessAndConfig)this, patch_list);
987 rangePatcher.ShowDialog();
988 }
989
990 #endregion
991 }
992 private void mnuItemPatchSelectedEntry_Click(object sender, EventArgs e)
993 {
994 if (!(lstPatchList.SelectedItems.Count == 1)) return;
995 PatchRange(true);
996 }
997
998 private void mnuItemPatchSelectedRange_Click(object sender, EventArgs e)
999 {
1000 if (!(lstPatchList.SelectedItems.Count >= 1)) return;
1001 PatchRange(false);
1002 }
1003
1004 private void mnuItemFreezeSelectedPatches_Click(object sender, EventArgs e)
1005 {
1006 if (!(lstPatchList.SelectedItems.Count > 0)) return;
1007 //if (SearchArgs == null) return;
1008 try
1009 {
1010 lstPatchList.ProcessID = this.AcceptedProcess.Id;
1011 this.FreezeResultsUpdate();
1012 for (int i = 0; i < lstPatchList.SelectedIndices.Count; i++)
1013 {
1014 lstPatchList.FreezeItem(lstPatchList.SelectedIndices[i]);
1015 }
1016 // force thaw and update
1017 this.ThawResultsUpdate();
1018 this.Update();
1019 }
1020 catch (Exception ex)
1021 {
1022 Debug.WriteLine(ex.ToString());
1023 }
1024 }
1025
1026 private void mnuItemThawSelectedPatches_Click(object sender, EventArgs e)
1027 {
1028 if (!(lstPatchList.SelectedItems.Count > 0)) return;
1029 //if (SearchArgs == null) return;
1030 try
1031 {
1032 lstPatchList.ProcessID = this.AcceptedProcess.Id;
1033 this.FreezeResultsUpdate();
1034 for (int i = 0; i < lstPatchList.SelectedIndices.Count; i++)
1035 {
1036 lstPatchList.ThawItem(lstPatchList.SelectedIndices[i]);
1037 }
1038 // force thaw and update
1039 this.ThawResultsUpdate();
1040 this.Update();
1041 }
1042 catch (Exception ex)
1043 {
1044 Debug.WriteLine(ex.ToString());
1045 }
1046 }
1047 private void search_provider_OnBytesRead(OnBytesReadEventArgs e)
1048 {
1049 if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
1050 SearchDataTypes sdt = SearchArgs.DataType;
1051 bool unsigned = SearchArgs.IsUnsignedDataType;
1052 int Last_Whole_Percent_Done = 0;
1053 uint CurrentIndex = e.CurrentIndex;
1054 if (e.UserState != null)
1055 {
1056 SearchResultWriter writer = (e.UserState as SearchResultWriter);
1057 if (writer == null)
1058 throw new InvalidOperationException("writer cannot be null");
1059 using (MemoryStream ms = new MemoryStream(e.Data))
1060 {
1061 using (BinaryReader br = new BinaryReader(ms))
1062 {
1063 while (br.BaseStream.Position < br.BaseStream.Length)
1064 {
1065 try
1066 {
1067 switch (sdt)
1068 {
1069 case SearchDataTypes._8bits:
1070 if (unsigned)
1071 {
1072 #region 8bits - unsigned
1073 var Value = br.ReadByte();
1074 using (_8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, CurrentIndex))
1075 {
1076 byte value = 0;
1077 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1078 {
1079 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1080 {
1081 try
1082 {
1083 gmp.OpenProvider();
1084 gmp.ReadMemory(CurrentIndex, out value);
1085 gmp.CloseProvider();
1086 }
1087 catch (Exception ex)
1088 {
1089 logger.VerboseError.WriteLine(ex.ToString());
1090 }
1091 }
1092 comparer.Value = value;
1093 }
1094 else
1095 {
1096 value = Convert.ToByte(SearchArgs.CompareStartValue);
1097 comparer.Value = value;
1098 }
1099 if (comparer.Compare(Convert.ToByte(Value), value))
1100 {
1101 writer.WriteResult<byte>(comparer.Address, comparer.Value);
1102 }
1103 }
1104 #endregion
1105 }
1106 else
1107 {
1108 #region 8bits - signed
1109 var Value = br.ReadSByte();
1110 using (_8bit_signed_comparer_ comparer = new _8bit_signed_comparer_(SearchArgs, CurrentIndex))
1111 {
1112 sbyte value = 0;
1113 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1114 {
1115 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1116 {
1117 try
1118 {
1119 gmp.OpenProvider();
1120 gmp.ReadMemory(CurrentIndex, out value);
1121 gmp.CloseProvider();
1122 }
1123 catch (Exception ex)
1124 {
1125 logger.VerboseError.WriteLine(ex.ToString());
1126 }
1127 }
1128 comparer.Value = value;
1129 }
1130 else
1131 {
1132 value = Convert.ToSByte(SearchArgs.CompareStartValue);
1133 comparer.Value = value;
1134 }
1135 if (comparer.Compare(Convert.ToSByte(Value), value))
1136 {
1137 writer.WriteResult<sbyte>(comparer.Address, comparer.Value);
1138 }
1139 }
1140 #endregion
1141 } break;
1142 case SearchDataTypes._16bits:
1143 if (unsigned)
1144 {
1145 #region 16bits - unsigned
1146 var Value = br.ReadUInt16();
1147 using (_16bit_unsigned_comparer_ comparer = new _16bit_unsigned_comparer_(SearchArgs, CurrentIndex))
1148 {
1149 ushort value = 0;
1150 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1151 {
1152 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1153 {
1154 try
1155 {
1156 gmp.OpenProvider();
1157 gmp.ReadMemory(CurrentIndex, out value);
1158 gmp.CloseProvider();
1159 }
1160 catch (Exception ex)
1161 {
1162 logger.VerboseError.WriteLine(ex.ToString());
1163 }
1164 }
1165 comparer.Value = value;
1166 }
1167 else
1168 {
1169 value = Convert.ToUInt16(SearchArgs.CompareStartValue);
1170 comparer.Value = value;
1171 }
1172 if (comparer.Compare(Convert.ToUInt16(Value), value))
1173 {
1174 writer.WriteResult<ushort>(comparer.Address, comparer.Value);
1175 }
1176 }
1177 #endregion
1178 writer.WriteResult<ushort>(CurrentIndex, br.ReadUInt16());
1179 }
1180 else
1181 {
1182 #region 16bits - signed
1183 var Value = br.ReadInt16();
1184 using (_16bit_signed_comparer_ comparer = new _16bit_signed_comparer_(SearchArgs, CurrentIndex))
1185 {
1186 short value = 0;
1187 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1188 {
1189 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1190 {
1191 try
1192 {
1193 gmp.OpenProvider();
1194 gmp.ReadMemory(CurrentIndex, out value);
1195 gmp.CloseProvider();
1196 }
1197 catch (Exception ex)
1198 {
1199 logger.VerboseError.WriteLine(ex.ToString());
1200 }
1201 }
1202 comparer.Value = value;
1203 }
1204 else
1205 {
1206 value = Convert.ToInt16(SearchArgs.CompareStartValue);
1207 comparer.Value = value;
1208 }
1209 if (comparer.Compare(Convert.ToSByte(Value), value))
1210 {
1211 writer.WriteResult<short>(comparer.Address, comparer.Value);
1212 }
1213 }
1214 #endregion
1215 } break;
1216 case SearchDataTypes._32bits:
1217 if (unsigned)
1218 {
1219 #region 32bits - unsigned
1220 var Value = br.ReadUInt32();
1221 using (_32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, CurrentIndex))
1222 {
1223 uint value = 0;
1224 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1225 {
1226 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1227 {
1228 try
1229 {
1230 gmp.OpenProvider();
1231 gmp.ReadMemory(CurrentIndex, out value);
1232 gmp.CloseProvider();
1233 }
1234 catch (Exception ex)
1235 {
1236 logger.VerboseError.WriteLine(ex.ToString());
1237 }
1238 }
1239 comparer.Value = value;
1240 }
1241 else
1242 {
1243 value = Convert.ToUInt32(SearchArgs.CompareStartValue);
1244 comparer.Value = value;
1245 }
1246 if (comparer.Compare(Convert.ToUInt32(Value), value))
1247 {
1248 writer.WriteResult<uint>(comparer.Address, comparer.Value);
1249 }
1250 }
1251 #endregion
1252 }
1253 else
1254 {
1255 #region 32bits - signed
1256 var Value = br.ReadInt32();
1257 using (_32bit_signed_comparer_ comparer = new _32bit_signed_comparer_(SearchArgs, CurrentIndex))
1258 {
1259 int value = 0;
1260 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1261 {
1262 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1263 {
1264 try
1265 {
1266 gmp.OpenProvider();
1267 gmp.ReadMemory(CurrentIndex, out value);
1268 gmp.CloseProvider();
1269 }
1270 catch (Exception ex)
1271 {
1272 logger.VerboseError.WriteLine(ex.ToString());
1273 }
1274 }
1275 comparer.Value = value;
1276 }
1277 else
1278 {
1279 value = Convert.ToInt32(SearchArgs.CompareStartValue);
1280 comparer.Value = value;
1281 }
1282 if (comparer.Compare(Convert.ToInt32(Value), value))
1283 {
1284 writer.WriteResult<int>(comparer.Address, comparer.Value);
1285 }
1286 }
1287 #endregion
1288 } break;
1289 case SearchDataTypes._64bits:
1290 if (unsigned)
1291 {
1292 #region 64bits - unsigned
1293 var Value = br.ReadUInt64();
1294 using (_64bit_unsigned_comparer_ comparer = new _64bit_unsigned_comparer_(SearchArgs, CurrentIndex))
1295 {
1296 ulong value = 0;
1297 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1298 {
1299 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1300 {
1301 try
1302 {
1303 gmp.OpenProvider();
1304 gmp.ReadMemory(CurrentIndex, out value);
1305 gmp.CloseProvider();
1306 }
1307 catch (Exception ex)
1308 {
1309 logger.VerboseError.WriteLine(ex.ToString());
1310 }
1311 }
1312 comparer.Value = value;
1313 }
1314 else
1315 {
1316 value = Convert.ToUInt64(SearchArgs.CompareStartValue);
1317 comparer.Value = value;
1318 }
1319 if (comparer.Compare(Convert.ToUInt64(Value), value))
1320 {
1321 writer.WriteResult<ulong>(comparer.Address, comparer.Value);
1322 }
1323 }
1324 #endregion
1325 }
1326 else
1327 {
1328 #region 64bits - signed
1329 var Value = br.ReadInt64();
1330 using (_64bit_signed_comparer_ comparer = new _64bit_signed_comparer_(SearchArgs, CurrentIndex))
1331 {
1332 long value = 0;
1333 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1334 {
1335 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1336 {
1337 try
1338 {
1339 gmp.OpenProvider();
1340 gmp.ReadMemory(CurrentIndex, out value);
1341 gmp.CloseProvider();
1342 }
1343 catch (Exception ex)
1344 {
1345 logger.VerboseError.WriteLine(ex.ToString());
1346 }
1347 }
1348 comparer.Value = value;
1349 }
1350 else
1351 {
1352 value = Convert.ToInt64(SearchArgs.CompareStartValue);
1353 comparer.Value = value;
1354 }
1355 if (comparer.Compare(Convert.ToInt64(Value), value))
1356 {
1357 writer.WriteResult<long>(comparer.Address, comparer.Value);
1358 }
1359 }
1360 #endregion
1361 } break;
1362 }
1363 if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
1364 }
1365 catch (EndOfStreamException) { }
1366 double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);
1367 int int_percent_done = (int)double_percent_done;
1368 if (int_percent_done != Last_Whole_Percent_Done && CurrentIndex % 100000 == 0)
1369 {
1370 if (int_percent_done <= 100)
1371 {
1372 resultsprogress.Value = int_percent_done;
1373 resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", (CurrentIndex + MemoryRangeStart));
1374 Last_Whole_Percent_Done = int_percent_done;
1375 }
1376 if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
1377 }
1378 switch (sdt)
1379 {
1380 case SearchDataTypes._8bits:
1381 CurrentIndex += sizeof(byte);
1382 break;
1383 case SearchDataTypes._16bits:
1384 CurrentIndex += sizeof(ushort);
1385 break;
1386 case SearchDataTypes._32bits:
1387 CurrentIndex += sizeof(uint);
1388 break;
1389 case SearchDataTypes._64bits:
1390 CurrentIndex += sizeof(ulong);
1391 break;
1392 }
1393 }
1394
1395 }
1396 }
1397 }
1398 if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
1399 }
1400 private void SearchWorkerThread_DoWork(object sender, DoWorkEventArgs e)
1401 {
1402 try
1403 {
1404 Stopwatch st = new Stopwatch();
1405 st.Start();
1406
1407 Stopwatch st_first_search = new Stopwatch();
1408 Stopwatch st_nonrange_search = new Stopwatch();
1409 Stopwatch st_ranged_search = new Stopwatch();
1410
1411 e.Result = st;
1412 //List<ResultType<object>> tmp_Results = new List<ResultType<object>>();
1413 List<ResultType<object>> second_tmp_Results = new List<ResultType<object>>();
1414 //const int ElementsBeforeDisplay = 100;
1415 SearchArgs.LogSearchOptions();
1416 uint STEP_SIZE = (uint)SearchArgs.DataType / 8;
1417
1418 bool unsigned = SearchArgs.IsUnsignedDataType;
1419 SearchDataTypes sdt = SearchArgs.DataType;
1420 //byte[] buffered_mem = new byte[(MemoryRangeSize - MemoryRangeStart)]; // throws OutOfMemoryException if size is over 2G
1421 logger.Debug.WriteLine(string.Format("Buffered Memory Size -> 0x{0:x8}", MemoryRangeSize - MemoryRangeStart));
1422 resultsprogress.Value = 0;
1423 resultsprogress.Message = string.Format("Search is Warming Up...Please Wait...");
1424
1425 Stopwatch provider_st = new Stopwatch();
1426 provider_st.Start();
1427 using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1428 {
1429 provider.OpenProvider();
1430 int count = (int)((MemoryRangeSize - MemoryRangeStart) / STEP_SIZE);
1431 SearchResultWriter writer = new SearchResultWriter((int)(count), SearchGuid);
1432 provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead);
1433 provider.ReadProcessMemoryAtOnce(MemoryRangeStart, (MemoryRangeSize - MemoryRangeStart), writer);
1434 provider.CloseProvider();
1435 if (SearchWorkerThread.CancellationPending)
1436 {
1437 provider_st.Stop();
1438 st.Stop();
1439 writer.CancelRequest();
1440 writer.Dispose();
1441 writer = null;
1442 e.Result = true;
1443 return;
1444 }
1445 writer.Dispose();
1446 writer = null;
1447 }
1448 provider_st.Stop();
1449 logger.Profiler.WriteLine("It took a total of {0} seconds for the memory provider to complete it's operation(s).", provider_st.Elapsed.TotalSeconds);
1450 //if (buffered_mem.Length == 0) { logger.Warn.WriteLine("Buffered Memory is Zero Length."); return; }
1451 //int Last_Whole_Percent_Done = 0;
1452
1453
1454 #region Subsequent Searches
1455 //r_ms.BaseStream.Seek(0, SeekOrigin.Begin);
1456
1457
1458 // hack to help with OutOfMemory Exceptions (OldValue and Equal compare will always add all found search results)
1459 bool NeedToCompare = true;
1460 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue &&
1461 SearchArgs.CompareType == SearchCompareTypes.Equal &&
1462 SearchArgs.IsFirstSearch)
1463 {
1464 NeedToCompare = false;
1465 //second_tmp_Results = null; // Free Memory
1466 }
1467
1468 if (NeedToCompare)
1469 {
1470 if (SearchArgs.CompareType != SearchCompareTypes.Between && SearchArgs.CompareType != SearchCompareTypes.NotBetween)
1471 {
1472 #region Non-Range Searches
1473 if (USE_NONRANGE_SEARCH_RESULT_READER)
1474 {
1475 st_nonrange_search.Start();
1476 //second_tmp_Results = new List<ResultType<object>>(SearchArgs.Results.Count * 1024);
1477 ////second_tmp_Results.c
1478 try
1479 {
1480 using (SearchResultReader reader = new SearchResultReader(SearchGuid))
1481 {
1482 try
1483 {
1484
1485 #region new comparator-support
1486 second_tmp_Results = new List<ResultType<object>>(reader.GetResults(SearchArgs, (IAcceptsProcessAndConfig)this, resultsprogress));
1487 #endregion
1488
1489 #region USE_OLD_SEARCH_RESULTS_COMPRATOR_CODE
1490 if (USE_OLD_SEARCH_RESULTS_COMPRATOR_CODE)
1491 {
1492 for (int i = 0; i < reader.ResultCount; i += 1)
1493 {
1494 object result_value = 0;
1495 uint address = 0;
1496 #region switch (SearchArgs.DataType)
1497 switch (SearchArgs.DataType)
1498 {
1499 case SearchDataTypes._8bits: if (unsigned)
1500 {
1501 using (ResultType<byte> result = reader.GetNextResult<byte>())
1502 {
1503 address = result.Address;
1504 result_value = result.Value;
1505 }
1506 }
1507 else
1508 {
1509 using (ResultType<sbyte> result = reader.GetNextResult<sbyte>())
1510 {
1511 address = result.Address;
1512 result_value = result.Value;
1513 }
1514 } break;
1515 case SearchDataTypes._16bits: if (unsigned)
1516 {
1517 using (ResultType<ushort> result = reader.GetNextResult<ushort>())
1518 {
1519 address = result.Address;
1520 result_value = result.Value;
1521 }
1522 }
1523 else
1524 {
1525 using (ResultType<short> result = reader.GetNextResult<short>())
1526 {
1527 address = result.Address;
1528 result_value = result.Value;
1529 }
1530 } break;
1531 case SearchDataTypes._32bits: if (unsigned)
1532 {
1533 using (ResultType<uint> result = reader.GetNextResult<uint>())
1534 {
1535 address = result.Address;
1536 result_value = result.Value;
1537 }
1538 }
1539 else
1540 {
1541 using (ResultType<int> result = reader.GetNextResult<int>())
1542 {
1543 address = result.Address;
1544 result_value = result.Value;
1545 }
1546 } break;
1547 case SearchDataTypes._64bits: if (unsigned)
1548 {
1549 using (ResultType<ulong> result = reader.GetNextResult<ulong>())
1550 {
1551 address = result.Address;
1552 result_value = result.Value;
1553 }
1554 }
1555 else
1556 {
1557 using (ResultType<long> result = reader.GetNextResult<long>())
1558 {
1559 address = result.Address;
1560 result_value = result.Value;
1561 }
1562 } break;
1563 }
1564 #endregion
1565 if (MemoryRangeStart > 0 && !SearchArgs.IsFirstSearch) { address = address - MemoryRangeStart; }
1566 try
1567 {
1568 //r_ms.BaseStream.Seek(address, SeekOrigin.Begin);
1569 }
1570 catch (Exception)
1571 {
1572 throw;
1573 }
1574 switch (SearchArgs.DataType)
1575 {
1576 #region Comparer Support
1577 #region case SearchDataTypes._8bits:
1578 case SearchDataTypes._8bits:
1579 if (SearchArgs.IsUnsignedDataType)
1580 {
1581 byte lookup_value = 0;
1582 //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
1583 lookup_value = Convert.ToByte(result_value);
1584 using (_8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, address))
1585 {
1586 byte value = 0;
1587 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1588 {
1589 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1590 {
1591 try
1592 {
1593 gmp.OpenProvider();
1594 gmp.ReadMemory(address, out value);
1595 gmp.CloseProvider();
1596 }
1597 catch (Exception ex)
1598 {
1599 logger.VerboseError.WriteLine(ex.ToString());
1600 }
1601 }
1602 comparer.Value = value;
1603 }
1604 else
1605 {
1606 value = Convert.ToByte(SearchArgs.CompareStartValue);
1607 comparer.Value = value;
1608 }
1609 if (comparer.Compare(lookup_value, value))
1610 {
1611 second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
1612 }
1613 }
1614 }
1615 else
1616 {
1617 sbyte lookup_value = 0;
1618 //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
1619 lookup_value = Convert.ToSByte(result_value);
1620 using (_8bit_signed_comparer_ comparer = new _8bit_signed_comparer_(SearchArgs, address))
1621 {
1622 sbyte value = 0;
1623 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1624 {
1625 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1626 {
1627 try
1628 {
1629 gmp.OpenProvider();
1630 gmp.ReadMemory(address, out value);
1631 gmp.CloseProvider();
1632 }
1633 catch (Exception ex)
1634 {
1635 logger.VerboseError.WriteLine(ex.ToString());
1636 }
1637 }
1638 comparer.Value = value;
1639 }
1640 else
1641 {
1642 value = Convert.ToSByte(SearchArgs.CompareStartValue);
1643 }
1644 if (comparer.Compare(lookup_value, value))
1645 {
1646 second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
1647 }
1648 }
1649 }
1650 break;
1651 #endregion
1652 #region case SearchDataTypes._16bits:
1653 case SearchDataTypes._16bits:
1654 if (SearchArgs.IsUnsignedDataType)
1655 {
1656 ushort lookup_value = 0;
1657 //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
1658 lookup_value = Convert.ToUInt16(result_value);
1659 using (_16bit_unsigned_comparer_ comparer = new _16bit_unsigned_comparer_(SearchArgs, address))
1660 {
1661 ushort value = 0;
1662 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1663 {
1664 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1665 {
1666 try
1667 {
1668 gmp.OpenProvider();
1669 gmp.ReadMemory(address, out value);
1670 gmp.CloseProvider();
1671 }
1672 catch (Exception ex)
1673 {
1674 logger.VerboseError.WriteLine(ex.ToString());
1675 }
1676 }
1677 comparer.Value = value;
1678 }
1679 else
1680 {
1681 value = Convert.ToUInt16(SearchArgs.CompareStartValue);
1682 comparer.Value = value;
1683 }
1684 if (comparer.Compare(lookup_value, value))
1685 {
1686 second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
1687 }
1688 }
1689 }
1690 else
1691 {
1692 short lookup_value = 0;
1693 //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
1694 lookup_value = Convert.ToInt16(result_value);
1695 using (_16bit_signed_comparer_ comparer = new _16bit_signed_comparer_(SearchArgs, address))
1696 {
1697 short value = 0;
1698 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1699 {
1700 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1701 {
1702 try
1703 {
1704 gmp.OpenProvider();
1705 gmp.ReadMemory(address, out value);
1706 gmp.CloseProvider();
1707 }
1708 catch (Exception ex)
1709 {
1710 logger.VerboseError.WriteLine(ex.ToString());
1711 }
1712 }
1713 comparer.Value = value;
1714 }
1715 else
1716 {
1717 value = Convert.ToInt16(SearchArgs.CompareStartValue);
1718 }
1719 if (comparer.Compare(lookup_value, value))
1720 {
1721 second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
1722 }
1723 }
1724 }
1725 break;
1726 #endregion
1727 #region case SearchDataTypes._32bits:
1728 case SearchDataTypes._32bits:
1729 if (SearchArgs.IsUnsignedDataType)
1730 {
1731 uint lookup_value = 0;
1732 //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
1733 lookup_value = Convert.ToUInt32(result_value);
1734 using (_32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, address))
1735 {
1736 uint value = 0;
1737 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1738 {
1739 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1740 {
1741 try
1742 {
1743 gmp.OpenProvider();
1744 gmp.ReadMemory(address, out value);
1745 gmp.CloseProvider();
1746 }
1747 catch (Exception ex)
1748 {
1749 logger.VerboseError.WriteLine(ex.ToString());
1750 }
1751 }
1752 comparer.Value = value;
1753 }
1754 else
1755 {
1756 value = Convert.ToUInt32(SearchArgs.CompareStartValue);
1757 comparer.Value = value;
1758 }
1759 if (comparer.Compare(lookup_value, value))
1760 {
1761 second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
1762 }
1763 }
1764 }
1765 else
1766 {
1767 int lookup_value = 0;
1768 //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
1769 lookup_value = Convert.ToInt32(result_value);
1770 using (_32bit_signed_comparer_ comparer = new _32bit_signed_comparer_(SearchArgs, address))
1771 {
1772 int value = 0;
1773 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1774 {
1775 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1776 {
1777 try
1778 {
1779 gmp.OpenProvider();
1780 gmp.ReadMemory(address, out value);
1781 gmp.CloseProvider();
1782 }
1783 catch (Exception ex)
1784 {
1785 logger.VerboseError.WriteLine(ex.ToString());
1786 }
1787 }
1788 comparer.Value = value;
1789 }
1790 else
1791 {
1792 value = Convert.ToInt32(SearchArgs.CompareStartValue);
1793 }
1794 if (comparer.Compare(lookup_value, value))
1795 {
1796 second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
1797 }
1798 }
1799 }
1800 break;
1801 #endregion
1802 #region case SearchDataTypes._64bits:
1803 case SearchDataTypes._64bits:
1804 if (SearchArgs.IsUnsignedDataType)
1805 {
1806 ulong lookup_value = 0;
1807 //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
1808 lookup_value = Convert.ToUInt64(result_value);
1809 using (_64bit_unsigned_comparer_ comparer = new _64bit_unsigned_comparer_(SearchArgs, address))
1810 {
1811 ulong value = 0;
1812 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1813 {
1814 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1815 {
1816 try
1817 {
1818 gmp.OpenProvider();
1819 gmp.ReadMemory(address, out value);
1820 gmp.CloseProvider();
1821 }
1822 catch (Exception ex)
1823 {
1824 logger.VerboseError.WriteLine(ex.ToString());
1825 }
1826 }
1827 comparer.Value = value;
1828 }
1829 else
1830 {
1831 value = Convert.ToUInt64(SearchArgs.CompareStartValue);
1832 comparer.Value = value;
1833 }
1834 if (comparer.Compare(lookup_value, value))
1835 {
1836 second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
1837 }
1838 }
1839 }
1840 else
1841 {
1842 long lookup_value = 0;
1843 //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
1844 lookup_value = Convert.ToInt64(result_value);
1845 using (_64bit_signed_comparer_ comparer = new _64bit_signed_comparer_(SearchArgs, address))
1846 {
1847 long value = 0;
1848 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
1849 {
1850 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
1851 {
1852 try
1853 {
1854 gmp.OpenProvider();
1855 gmp.ReadMemory(address, out value);
1856 gmp.CloseProvider();
1857 }
1858 catch (Exception ex)
1859 {
1860 logger.VerboseError.WriteLine(ex.ToString());
1861 }
1862 }
1863 comparer.Value = value;
1864 }
1865 else
1866 {
1867 value = Convert.ToInt64(SearchArgs.CompareStartValue);
1868 }
1869 if (comparer.Compare(lookup_value, value))
1870 {
1871 second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
1872 }
1873 }
1874 }
1875 break;
1876 #endregion
1877 #endregion
1878 }
1879 double double_percent_done = 100.0 * (double)((double)i / (double)reader.ResultCount);
1880 int int_percent_done = (int)double_percent_done;
1881 //if (int_percent_done != Last_Whole_Percent_Done && i % 100000 == 0)
1882 //{
1883 if (int_percent_done <= 100)
1884 {
1885 resultsprogress.Value = int_percent_done;
1886 resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart);
1887 //Last_Whole_Percent_Done = int_percent_done;
1888 }
1889 //}
1890 //this.Refresh();
1891 }
1892 }
1893 #endregion
1894 }
1895 catch (Exception ex)
1896 {
1897 throw ex;
1898 }
1899 }
1900 }
1901 catch (Exception ex)
1902 {
1903 throw ex;
1904 }
1905 st_nonrange_search.Stop();
1906 logger.Profiler.WriteLine("Non-Ranged search took a total of {0} seconds to complete.", st_nonrange_search.Elapsed.TotalSeconds);
1907 //Last_Whole_Percent_Done = 0;
1908 }
1909 #endregion
1910 }
1911 #region Ranged Searches
1912 #if !DONOT_HAVE_RANGED_SEARCH_SUPPORT
1913 if (SearchArgs.CompareType == SearchCompareTypes.Between || SearchArgs.CompareType == SearchCompareTypes.NotBetween)
1914 {
1915 st_ranged_search.Start();
1916 object start, end;
1917
1918 start = SearchArgs.CompareStartValue;
1919 end = SearchArgs.CompareEndValue;
1920 using (SearchResultReader reader = new SearchResultReader(SearchGuid))
1921 {
1922 for (int i = 0; i < reader.ResultCount; i += 1)
1923 {
1924 uint address = 0;
1925 #region switch (SearchArgs.DataType)
1926 switch (SearchArgs.DataType)
1927 {
1928 case SearchDataTypes._8bits: if (unsigned) { using (ResultType<byte> result = reader.GetNextResult<byte>()) { address = result.Address; } }
1929 else { using (ResultType<sbyte> result = reader.GetNextResult<sbyte>()) { address = result.Address; } } break;
1930 case SearchDataTypes._16bits: if (unsigned) { using (ResultType<ushort> result = reader.GetNextResult<ushort>()) { address = result.Address; } }
1931 else { using (ResultType<short> result = reader.GetNextResult<short>()) { address = result.Address; } } break;
1932 case SearchDataTypes._32bits: if (unsigned) { using (ResultType<uint> result = reader.GetNextResult<uint>()) { address = result.Address; } }
1933 else { using (ResultType<int> result = reader.GetNextResult<int>()) { address = result.Address; } } break;
1934 case SearchDataTypes._64bits: if (unsigned) { using (ResultType<ulong> result = reader.GetNextResult<ulong>()) { address = result.Address; } }
1935 else { using (ResultType<long> result = reader.GetNextResult<long>()) { address = result.Address; } } break;
1936 }
1937 #endregion
1938
1939 if (MemoryRangeStart > 0 && !SearchArgs.IsFirstSearch) { address = address - MemoryRangeStart; }
1940 //r_ms.BaseStream.Seek(address, SeekOrigin.Begin);
1941 if (SearchArgs.CompareType == SearchCompareTypes.Between)
1942 {
1943 using (InRangeComparer comparer = new InRangeComparer(address, 0))
1944 {
1945 if (comparer.Compare(start, end, SearchArgs.DataType, SearchArgs.IsUnsignedDataType, (IAcceptsProcessAndConfig)this))
1946 {
1947 using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
1948 {
1949 second_tmp_Results.Add(_tmp_result);
1950 }
1951 }
1952 }
1953 }
1954 else if (SearchArgs.CompareType == SearchCompareTypes.NotBetween)
1955 {
1956 using (NotInRangeComparer comparer = new NotInRangeComparer(address, 0))
1957 {
1958 if (comparer.Compare(start, end, SearchArgs.DataType, SearchArgs.IsUnsignedDataType, (IAcceptsProcessAndConfig)this))
1959 {
1960 using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
1961 {
1962 second_tmp_Results.Add(_tmp_result);
1963 }
1964 }
1965 }
1966 }
1967 else
1968 {
1969 throw new InvalidOperationException("Encounted unkown range search type: " + SearchArgs.CompareType);
1970 }
1971 double double_percent_done = 100.0 * (double)((double)i / (double)reader.ResultCount);
1972 int int_percent_done = (int)double_percent_done;
1973 if (int_percent_done != Last_Whole_Percent_Done)
1974 {
1975 if (int_percent_done <= 100)
1976 {
1977 resultsprogress.Value = int_percent_done;
1978 resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart);
1979 Last_Whole_Percent_Done = int_percent_done;
1980 }
1981 }
1982 }
1983 }
1984 st_ranged_search.Stop();
1985 logger.Profiler.WriteLine("Ranged search took a total of {0} seconds to complete.", st_ranged_search.Elapsed.TotalSeconds);
1986 }
1987 #endif
1988 #endregion
1989
1990 }
1991 #endregion
1992 //// leave SearchArgs.Results alone, if false
1993 //if (NeedToCompare)
1994 //{
1995 // // fix addresses when memory start is not zero
1996 // if (MemoryRangeStart > 0 && SearchArgs.IsFirstSearch) { for (int i = 0; i < second_tmp_Results.Count; i++) { second_tmp_Results[i].Address = second_tmp_Results[i].Address + MemoryRangeStart; } }
1997 // using (SearchResultWriter writer = new SearchResultWriter(second_tmp_Results.Count, SearchGuid))
1998 // {
1999 // for (int i = 0; i < second_tmp_Results.Count; i++)
2000 // {
2001 // switch (sdt)
2002 // {
2003 // case SearchDataTypes._8bits:
2004 // if (unsigned) { writer.WriteResult<Byte>(second_tmp_Results[i].Address, Convert.ToByte(second_tmp_Results[i].Value)); }
2005 // else { writer.WriteResult<SByte>(second_tmp_Results[i].Address, Convert.ToSByte(second_tmp_Results[i].Value)); } break;
2006 // case SearchDataTypes._16bits:
2007 // if (unsigned) { writer.WriteResult<UInt16>(second_tmp_Results[i].Address, Convert.ToUInt16(second_tmp_Results[i].Value)); }
2008 // else { writer.WriteResult<Int16>(second_tmp_Results[i].Address, Convert.ToInt16(second_tmp_Results[i].Value)); } break;
2009 // case SearchDataTypes._32bits:
2010 // if (unsigned) { writer.WriteResult<UInt32>(second_tmp_Results[i].Address, Convert.ToUInt32(second_tmp_Results[i].Value)); }
2011 // else { writer.WriteResult<Int32>(second_tmp_Results[i].Address, Convert.ToInt32(second_tmp_Results[i].Value)); } break;
2012 // case SearchDataTypes._64bits:
2013 // if (unsigned) { writer.WriteResult<UInt64>(second_tmp_Results[i].Address, Convert.ToUInt64(second_tmp_Results[i].Value)); }
2014 // else { writer.WriteResult<Int64>(second_tmp_Results[i].Address, Convert.ToInt64(second_tmp_Results[i].Value)); } break;
2015 // }
2016 // }
2017 // }
2018 // second_tmp_Results = null; // free memory
2019 //}
2020 }
2021 catch (Exception ex)
2022 {
2023 throw ex;
2024 }
2025 }
2026
2027
2028
2029 private void SearchWorkerThread_ProgressChanged(object sender, ProgressChangedEventArgs e)
2030 {
2031 //if (SearchArgs.ProgressLogger != null)
2032 //{
2033 // resultsprogress.Value = e.ProgressPercentage;
2034 // //Application.DoEvents();
2035 //}
2036 }
2037
2038 private void SearchWorkerThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
2039 {
2040 try { if ((bool)e.Result) { logger.Warn.WriteLine("Search operation was cancelled."); resultsprogress.Value = 0; resultsprogress.Message = ""; return; } }
2041 catch (InvalidCastException) { }
2042 try
2043 {
2044 Stopwatch st = (Stopwatch)e.Result;
2045 st.Stop();
2046 logger.Profiler.WriteLine("Search took {0} seconds, overall, to complete.", st.Elapsed.TotalSeconds);
2047 }
2048 catch (InvalidCastException) { }
2049 catch (Exception ex) { throw ex; }
2050
2051 resultsprogress.Value = 100;
2052 bool unsigned = SearchArgs.IsUnsignedDataType;
2053 using (SearchResultReader reader = new SearchResultReader(SearchGuid))
2054 {
2055 logger.Info.WriteLine(string.Format("Found 0x{0:x8} results", reader.ResultCount));
2056
2057 if (reader.ResultCount <= MIN_NUMBER_OF_RESULTS_BEFORE_DISPLAY)
2058 {
2059 lstResults.Items.Clear();
2060 //List<ResultItem> items = new List<ResultItem>();
2061 //for (int i = 0; i < reader.ResultCount; i++)
2062 //{
2063 // ResultItem item = new ResultItem(0, false);
2064 // //item.Text = string.Format("0x{0:x8}", SearchArgs.Results[i].Address);
2065 // //item.SubItems.Add(string.Format("0x{0:x8}", SearchArgs.Results[i].Address));
2066 // switch (SearchArgs.DataType)
2067 // {
2068 // case SearchDataTypes._8bits:
2069 // if (SearchArgs.IsUnsignedDataType) { ResultType<byte> result = new ResultType<byte>(); item = new ResultItem(result.Address, false, result.Value); }
2070 // else { ResultType<sbyte> result = reader.GetNextResult<sbyte>(); item = new ResultItem(result.Address, false, result.Value); }
2071 // break;
2072 // case SearchDataTypes._16bits:
2073 // if (SearchArgs.IsUnsignedDataType) { ResultType<ushort> result = reader.GetNextResult<ushort>(); item = new ResultItem(result.Address, false, result.Value); }
2074 // else { ResultType<short> result = reader.GetNextResult<short>(); item = new ResultItem(result.Address, false, result.Value); }
2075 // break;
2076 // case SearchDataTypes._32bits:
2077 // if (SearchArgs.IsUnsignedDataType) { ResultType<uint> result = reader.GetNextResult<uint>(); item = new ResultItem(result.Address, false, result.Value); }
2078 // else { ResultType<int> result = reader.GetNextResult<int>(); item = new ResultItem(result.Address, false, result.Value); }
2079 // break;
2080 // case SearchDataTypes._64bits:
2081 // if (SearchArgs.IsUnsignedDataType) { ResultType<ulong> result = reader.GetNextResult<ulong>(); item = new ResultItem(result.Address, false, result.Value); }
2082 // else { ResultType<long> result = reader.GetNextResult<long>(); item = new ResultItem(result.Address, false, result.Value); }
2083 // break;
2084 // }
2085 // if (!items.Contains(item))
2086 // items.Add(item);
2087 //}
2088 lstResults.Items.AddRange(reader.GetResultItems(SearchArgs, (IAcceptsProcessAndConfig)this, resultsprogress));
2089 }
2090 }
2091
2092 this.DoSearchDoneSpecific();
2093 //System.Threading.Thread.Sleep(100);
2094 //if (_SEARCH_MODE != SearchMode.SEARCH_MODE_NORMAL_WITH_JOKER)
2095 this.ThawResultsUpdate();
2096 Application.DoEvents();
2097 }
2098 private void DoSearchDoneSpecific()
2099 {
2100 SearchWorkerThread.CancelAsync();
2101 if (lstResults.Items.Count > 0) { timer_update_results.Enabled = true; }
2102 else { timer_update_results.Enabled = false; }
2103
2104 search_progress_updater.Enabled = false;
2105
2106 btnCancel.Enabled = false;
2107 btnReset.Enabled = true;
2108 btnSearch.Enabled = true;
2109 grpCompareType.Enabled = true;
2110 grpCompareValue.Enabled = true;
2111 resultsprogress.Value = 0;
2112 resultsprogress.Message = "";
2113 grpDataType.Enabled = false;
2114 // resume process on reset, incase it was suspended
2115 ThreadControl.ResumeProcess(this.AcceptedProcess.Id);
2116 //Application.DoEvents();
2117 this.Refresh();
2118 }
2119
2120 private void DoCancelSpecific()
2121 {
2122 this.DoSearchDoneSpecific();
2123 }
2124 private void DoResetSpecific()
2125 {
2126 this.DoCancelSpecific();
2127 IsFirstSearch = true;
2128 grpDataType.Enabled = true;
2129 btnReset.Enabled = false;
2130
2131 // delete any temporary search result files
2132 SearchResultWriter.CleanupTemporarySearchResultFiles();
2133
2134 }
2135 private void search_progress_updater_Tick(object sender, EventArgs e)
2136 {
2137 if ((this.AcceptedProcess ==null) || Process.GetProcessById(this.AcceptedProcess.Id) == null)
2138 {
2139 SearchWorkerThread.CancelAsync();
2140 //JokerSearchWorker.CancelAsync();
2141 ResultsUpdateWorkerThread.CancelAsync();
2142 }
2143 }
2144
2145 #region Search Button
2146 private void btnSearch_Click(object sender, EventArgs e)
2147 {
2148 if (this.SearchGuid == Guid.Empty)
2149 this.SearchGuid = Guid.NewGuid();
2150 this.SearchInProgess = true;
2151 btnCancel.Enabled = true;
2152 btnReset.Enabled = true;
2153 btnSearch.Enabled = false;
2154 this.FreezeResultsUpdate();
2155 this.handle_btnSearch_Click();
2156 }
2157 private void handle_btnSearch_Click()
2158 {
2159 //this.FreezeResultsUpdate();
2160 lstResults.Items.Clear();
2161
2162 if (lstResults.Items.Count > 0) { timer_update_results.Enabled = true; }
2163 else { timer_update_results.Enabled = false; }
2164
2165
2166 resultsprogress.Value = 0;
2167 bool _is_unsigned = chkUnsigned.Checked;
2168 SearchType search_type = new SearchType();
2169 SearchDataTypes _data_type = new SearchDataTypes();
2170 SearchCompareTypes _compare_type = new SearchCompareTypes();
2171 CompareValueTypes _compare_value_type = new CompareValueTypes();
2172 object start_value = 0;
2173 object end_value = 0;
2174 // get datatype
2175 if (radio_8bits.Checked) { _data_type = SearchDataTypes._8bits; }
2176 else if (radio_16bits.Checked) { _data_type = SearchDataTypes._16bits; }
2177 else if (radio_32bits.Checked) { _data_type = SearchDataTypes._32bits; }
2178 else if (radio_64bits.Checked) { _data_type = SearchDataTypes._64bits; }
2179 else { logger.Error.WriteLine("Could not determine search data type bit size. (was not 8/16/32/or 64bits)"); }
2180 // get compare type
2181 if (radiocompare_equal.Checked) { _compare_type = SearchCompareTypes.Equal; }
2182 else if (radiocompare_greaterthan.Checked) { _compare_type = SearchCompareTypes.GreaterThan; }
2183 else if (radiocompare_lessthan.Checked) { _compare_type = SearchCompareTypes.LessThan; }
2184 else if (radiocompare_greaterthan_orequal.Checked) { _compare_type = SearchCompareTypes.GreaterThanOrEqual; }
2185 else if (radiocompare_lessthan_orequal.Checked) { _compare_type = SearchCompareTypes.LessThanOrEqual; }
2186 else if (radiocompare_notequal.Checked) { _compare_type = SearchCompareTypes.NotEqual; }
2187 else if (radiocompare_between.Checked) { _compare_type = SearchCompareTypes.Between; }
2188 else if (radiocompare_notbetween.Checked) { _compare_type = SearchCompareTypes.NotBetween; }
2189 else { logger.Error.WriteLine("Could not determine search comparison type. (was not == > < >= <= != <> or !<>)"); }
2190 // get compare valure type
2191 if (radio_oldvalue.Checked) { _compare_value_type = CompareValueTypes.OldValue; }
2192 else if (radio_specificvalue.Checked) { _compare_value_type = CompareValueTypes.SpecificValue; }
2193 else { logger.Error.WriteLine("Could not determine search comparison type. (was not old or specific value"); }
2194
2195 if (_compare_value_type == CompareValueTypes.SpecificValue || (_compare_type == SearchCompareTypes.Between || _compare_type == SearchCompareTypes.NotBetween))
2196 {
2197
2198 switch (_data_type)
2199 {
2200 case SearchDataTypes._8bits:
2201 if (_is_unsigned) { start_value = txtStartAddr.ToByte(); }
2202 else { start_value = txtStartAddr.ToSByte(); }
2203 break;
2204 case SearchDataTypes._16bits:
2205 if (_is_unsigned) { start_value = txtStartAddr.ToUInt16(); }
2206 else { start_value = txtStartAddr.ToInt16(); }
2207 break;
2208 case SearchDataTypes._32bits:
2209 if (_is_unsigned) { start_value = txtStartAddr.ToUInt32(); }
2210 else { start_value = txtStartAddr.ToInt32(); }
2211 break;
2212 case SearchDataTypes._64bits:
2213 if (_is_unsigned) { start_value = txtStartAddr.ToUInt64(); }
2214 else { start_value = txtStartAddr.ToInt64(); }
2215 break;
2216 default: throw new InvalidOperationException("In SearchType(): Encounterd an Unkown Search Data Type.");
2217 }
2218 }
2219 if (_compare_type == SearchCompareTypes.Between || _compare_type == SearchCompareTypes.NotBetween)
2220 {
2221 switch (_data_type)
2222 {
2223 case SearchDataTypes._8bits:
2224 if (_is_unsigned) { end_value = txtEndAddr.ToByte(); }
2225 else { end_value = txtEndAddr.ToSByte(); }
2226 break;
2227 case SearchDataTypes._16bits:
2228 if (_is_unsigned) { end_value = txtEndAddr.ToUInt16(); }
2229 else { end_value = txtEndAddr.ToInt16(); }
2230 break;
2231 case SearchDataTypes._32bits:
2232 if (_is_unsigned) { end_value = txtEndAddr.ToUInt32(); }
2233 else { end_value = txtEndAddr.ToInt32(); }
2234 break;
2235 case SearchDataTypes._64bits:
2236 if (_is_unsigned) { end_value = txtEndAddr.ToUInt64(); }
2237 else { end_value = txtEndAddr.ToInt64(); }
2238 break;
2239 default: throw new InvalidOperationException("In SearchType(): Encounterd an Unkown Search Data Type.");
2240 }
2241 }
2242
2243 search_type = new SearchType(_data_type, _is_unsigned, _compare_type, _compare_value_type, start_value, end_value, resultsprogress);
2244
2245 //search_type.LogSearchOptions();
2246
2247 search_type.IsFirstSearch = IsFirstSearch;
2248
2249
2250
2251 DoSearch(search_type);
2252 IsFirstSearch = false;
2253 }
2254 private void DoSearch(SearchType args)
2255 {
2256 if (!args.IsFirstSearch && SearchArgs != null)
2257 {
2258 //args.Results.AddRange(SearchArgs.Results.ToArray());
2259 //args.Results = SearchArgs.Results;
2260 }
2261 SearchArgs = args;
2262 #if DONOT_HAVE_RANGED_SEARCH_SUPPORT
2263 if (SearchArgs.CompareType == SearchCompareTypes.Between || SearchArgs.CompareType == SearchCompareTypes.NotBetween)
2264 {
2265 throw new NotImplementedException("Between and Not Between Range searches have not been implemented.");
2266 }
2267 #endif
2268 search_progress_updater.Enabled = true;
2269 //padPluginSelector.Enabled = false;
2270 //gsPluginSelector.Enabled = false;
2271 btnReset.Enabled = true;
2272 btnSearch.Enabled = false;
2273 btnCancel.Enabled = true;
2274 grpDataType.Enabled = false;
2275 grpCompareType.Enabled = false;
2276 grpCompareValue.Enabled = false;
2277 this.Refresh();
2278 Application.DoEvents();
2279 SearchWorkerThread.RunWorkerAsync();
2280 }
2281 #endregion
2282 private void btnReset_Click(object sender, EventArgs e)
2283 {
2284 this.SearchGuid = Guid.Empty;
2285 this.SearchInProgess = false;
2286 btnSearch.Enabled = true;
2287 btnReset.Enabled = false;
2288 btnCancel.Enabled = false;
2289 this.DoResetSpecific();
2290 lstResults.Items.Clear();
2291 //try { SearchArgs.Results = new List<ResultType<object>>(); }
2292 //catch { }
2293 }
2294
2295 private void btnCancel_Click(object sender, EventArgs e)
2296 {
2297 this.SearchInProgess = false;
2298 btnCancel.Enabled = false;
2299 btnSearch.Enabled = true;
2300 btnReset.Enabled = true;
2301 this.DoCancelSpecific();
2302 }
2303
2304 private void mnuItemPatchListViewMemoryRegion_Click(object sender, EventArgs e)
2305 {
2306 List<ResultDataType> patch_list = new List<ResultDataType>();
2307 List<int> SelectedIndexes = new List<int>();
2308 foreach (int index in lstPatchList.SelectedIndices) { SelectedIndexes.Add(index); }
2309 foreach (int index in SelectedIndexes)
2310 {
2311 ListViewItem item = lstPatchList.Items[index];
2312 ResultDataType rdt = (ResultDataType)item.Tag;
2313 ViewMemoryRegion(rdt);
2314 break; // only get the fist item
2315 }
2316 }
2317
2318 private void mnuItemResultsListViewMemoryRegion_Click(object sender, EventArgs e)
2319 {
2320 List<ResultDataType> patch_list = new List<ResultDataType>();
2321 List<int> SelectedIndexes = new List<int>();
2322 foreach (int index in lstResults.SelectedIndices) { SelectedIndexes.Add(index); }
2323 foreach (int index in SelectedIndexes)
2324 {
2325 ListViewItem item = lstResults.Items[index];
2326 ResultDataType rdt = (ResultDataType)item.Tag;
2327 ViewMemoryRegion(rdt);
2328 break; // only get the fist item
2329 }
2330 }
2331 private void ViewMemoryRegion(ResultDataType rdt)
2332 {
2333 if (OnBrowseMemoryRegion != null)
2334 OnBrowseMemoryRegion(new BrowseMemoryRegionEvent(this, rdt.Address));
2335 }
2336
2337 private void mnuAddedResults_Opening(object sender, CancelEventArgs e)
2338 {
2339 if (!(lstPatchList.Items.Count > 0)) { mnuItemRemoveResult.Visible = false; e.Cancel = true; }
2340 if (!(lstPatchList.Items.Count > 0)) { mnuItemPatchSelectedEntry.Visible = false; e.Cancel = true; }
2341 if (e.Cancel) return;
2342 if (lstPatchList.Items.Count > 0) mnuItemRemoveResult.Visible = true;
2343 if (lstPatchList.Items.Count > 0) mnuItemPatchSelectedEntry.Visible = true;
2344
2345 if (!(lstPatchList.Items.Count > 0)) { mnuItemFreezeSelectedPatches.Visible = false; e.Cancel = true; }
2346 if (!(lstPatchList.Items.Count > 0)) { mnuItemThawSelectedPatches.Visible = false; e.Cancel = true; }
2347 if (e.Cancel) return;
2348
2349 if (lstPatchList.Items.Count > 0) mnuItemFreezeSelectedPatches.Visible = true;
2350 if (lstPatchList.Items.Count > 0) mnuItemThawSelectedPatches.Visible = true;
2351
2352 if (lstPatchList.SelectedItems.Count == 0) e.Cancel = true;
2353 if (e.Cancel) return;
2354
2355 }
2356
2357 private void mnuResults_Opening(object sender, CancelEventArgs e)
2358 {
2359 if (!(lstResults.Items.Count > 0)) e.Cancel = true;
2360 if (lstResults.SelectedItems.Count == 0) e.Cancel = true;
2361 if (SearchArgs == null) e.Cancel = true;
2362 if (e.Cancel) return;
2363 }
2364
2365 private void chkMemoryRangeExpertMode_CheckedChanged(object sender, EventArgs e)
2366 {
2367 txtMemoryRangeStart.ReadOnly = !chkMemoryRangeExpertMode.Checked;
2368 txtMemoryRangeSize.ReadOnly = !chkMemoryRangeExpertMode.Checked;
2369 }
2370
2371 private void txtMemoryRangeStart_ValueChanged(object sender, ValueChangedEventArgs e) { this.MemoryRangeStart = Convert.ToUInt32(e.NewValue); }
2372 private void txtMemoryRangeSize_ValueChanged(object sender, ValueChangedEventArgs e) { this.MemoryRangeSize = Convert.ToUInt32(e.NewValue); }
2373
2374 }
2375 }

  ViewVC Help
Powered by ViewVC 1.1.22