/[RomCheater]/trunk/RomCheater/Docking/UI/UIMemoryViewer.cs
ViewVC logotype

Contents of /trunk/RomCheater/Docking/UI/UIMemoryViewer.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 398 - (show annotations) (download)
Wed Jun 20 12:16:34 2012 UTC (8 years, 8 months ago) by william
File size: 27569 byte(s)
MemmoryProvider: using statements

1 //#define DISABLE_GETFIRSTNONZEROBYTE_ONUPDATE_ACCEPTEDPROCESS // when defined will not call GetFirstNonZeroByte() when AcceptedProcess is updated and is not null
2 #define DISABLE_GETFIRSTNONZERO_BYTE // when defined will make GetFirstNonZeroByte() an empty void method
3 using System;
4 using System.Collections.Generic;
5 using System.ComponentModel;
6 using System.Drawing;
7 using System.Data;
8 using System.Linq;
9 using System.Text;
10 using System.Windows.Forms;
11 using Be.Windows.Forms;
12 using RomCheater.Logging;
13 using RomCheater.PluginFramework.Interfaces;
14 using System.Diagnostics;
15 using Sojaner.MemoryScanner.MemoryProviers;
16 using System.Runtime.InteropServices;
17 using RomCheater.PluginFramework.Events;
18 using Sojaner.MemoryScanner;
19
20 namespace RomCheater.Docking.UI
21 {
22 public partial class UIMemoryViewer : UserControl,
23 IAcceptsPlugin<IConfigPlugin>,
24 IAcceptsProcess<Process>,
25 IAcceptsProcessAndConfig,
26 IAcceptsMemoryRange,
27 IBrowseMemoryRegion,
28 IAcceptPEData
29 {
30
31
32 public delegate void SetTextDelegate(string text);
33 public void SetAsciiData(string text)
34 {
35 if (txtAscii.InvokeRequired)
36 {
37 SetTextDelegate std = new SetTextDelegate(SetAsciiData);
38 txtAscii.Invoke(std, text);
39 return;
40 }
41 txtAscii.Text = text;
42 }
43
44 public UIMemoryViewer()
45 {
46 InitializeComponent();
47 SetStyle(ControlStyles.UserPaint, true);
48 SetStyle(ControlStyles.DoubleBuffer, true);
49 SetStyle(ControlStyles.AllPaintingInWmPaint, true);
50 SetStyle(ControlStyles.ResizeRedraw, true);
51
52 //this.OnPCSX2ProcessCallback = new UIEvents.PCSX2ProcessCallback(this.PCSX2ProcessCallback);
53 //if (this.OnPCSX2ProcessCallback != null) { this.OnPCSX2ProcessCallback.Invoke(out procdata); }
54 this.UpdateEnabled = false;
55 txtData.BytesPerLine = (int)max_address_width;
56 txtData.UseFixedBytesPerLine = true;
57 //txtData.StringViewVisible = true;
58 ramScroll.Minimum = (int)MemoryRangeStart;
59 for (uint i = MemoryRangeStart; i < (MemoryRangeStart + max_ram_view); i += max_address_width) { ramScroll.Maximum += (int)max_address_width; }
60 ramScroll.Value = ramScroll.Minimum;
61 this.CanChangeUpdateInterval = false;
62
63
64 lblAddressMarker.Text = "";
65 for (uint i = 0; i < max_address_width; i++)
66 {
67 lblAddressMarker.Text = lblAddressMarker.Text + string.Format("{0:X2} ", i);
68 }
69 this.AcceptedPlugin = null; this.AcceptedProcess = null;
70
71 txtAddresses.MouseWheel += new MouseEventHandler(txtAddresses_MouseWheel);
72 txtData.MouseWheel += new MouseEventHandler(txtData_MouseWheel);
73 txtAscii.MouseWheel += new MouseEventHandler(txtAscii_MouseWheel);
74 }
75
76 private void GetFirstNonZeroByte()
77 {
78 #if !DISABLE_GETFIRSTNONZERO_BYTE
79 if (!DesignMode)
80 {
81 GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
82 provider.OpenProvider();
83 int addr = 0;
84 provider.ReadFirstNonZeroByte(MemoryRangeStart, MemoryRangeSize, out addr);
85 provider.CloseProvider();
86 GotoAddress(addr);
87 }
88 #else
89 this.GotoImageBase();
90 #endif
91 }
92 #region IBrowseMemoryRegion
93 public bool BrowseMemoryRegion(uint MemoryRegion)
94 {
95 try
96 {
97 if (!((MemoryRangeStart <= MemoryRegion) && (MemoryRegion <= (MemoryRangeStart + MemoryRangeSize)))) { return false; }
98 GotoAddress(MemoryRegion);
99 return true;
100 }
101 catch (Exception ex)
102 {
103 logger.Error.WriteLine("UIMemoryViewer.BrowseMemoryRegion(int MemoryRegion): Failed to Browse Memory Region: 0x{0:x8}", MemoryRegion);
104 logger.Error.WriteLine(ex.ToString());
105 return false;
106 }
107 }
108 #endregion
109 #region IAcceptsProcess<Process> Members
110 private Process _AcceptedProcess;
111 public Process AcceptedProcess
112 {
113 get { return _AcceptedProcess; }
114 set
115 {
116 _AcceptedProcess = value;
117 update_timer.Enabled = (value != null);
118 UpdateEnabled = update_timer.Enabled;
119 #if !DISABLE_GETFIRSTNONZEROBYTE_ONUPDATE_ACCEPTEDPROCESS
120 if (value != null)
121 GetFirstNonZeroByte();
122 #endif
123 }
124 }
125 #endregion
126 #region IAcceptsPlugin<IConfigPlugin> Members
127 public IConfigPlugin AcceptedPlugin { get; set; }
128 #endregion
129 #region IAcceptsMemoryRange members
130 public uint MemoryRangeStart { get { return MemorySizeConstants.MinimumAddress; } set { } }
131 public uint MemoryRangeSize { get { return MemoryRangeStart + MemorySizeConstants.MaximumAddressSize; } set { } }
132 #endregion
133 #region IAcceptPEData members
134 private IPEDData peData { get; set; }
135 public void SetPEViewerData(IPEDData peData) { this.peData = peData; }
136 #endregion
137 public void GotoTop() { this.CURRENT_TOP_ADDR = 0; }
138 public void GotoBottom() { uint size = (uint)MemoryRangeSize; this.CURRENT_TOP_ADDR = (uint)((size - 1) - max_ram_view); }
139 public void GotoAddress(uint addr)
140 {
141 logger.VerboseDebug.WriteLine("UIMemoryViewer::GotoAddress(0x{0:x8})", addr);
142 this.CURRENT_TOP_ADDR = (uint)(addr & 0xFFFFFFF0);
143 }
144 private bool _UpdateEnabled;
145 public bool UpdateEnabled
146 {
147 get { return _UpdateEnabled; }
148 set
149 {
150 _UpdateEnabled = value;
151 if (value) { this.update_timer.Enabled = true; }
152 else { this.update_timer.Enabled = false; }
153 }
154 }
155 private bool _CanChangeUpdateInterval;
156 public bool CanChangeUpdateInterval
157 {
158 get { return _CanChangeUpdateInterval; }
159 set { _CanChangeUpdateInterval = value; }
160 }
161
162 public int UpdateInterval
163 {
164 get { return this.update_timer.Interval; }
165 set { if (CanChangeUpdateInterval) this.update_timer.Interval = value; }
166 }
167 private string AddressList = "";
168 private string AsciiData = "";
169 private byte[] RamData = new byte[] { };
170
171 const uint max_address_width = 16;
172 static uint max_ram_view = max_address_width * 20;
173
174 static uint small_scroll_change = max_address_width * 1; // scrolls one line (when you clikc the up or down arrows)
175 static uint medium_scroll_change = max_ram_view / 2; // scrolls half a page
176 static uint large_scroll_change = max_ram_view; // scrolls a full page
177 private uint _CURRENT_TOP_ADDR;
178 uint CURRENT_TOP_ADDR
179 {
180 get { return _CURRENT_TOP_ADDR; }
181 set { txthexGoto.Value = _CURRENT_TOP_ADDR = value; }
182 }
183 //uint CURRENT_BOITTOM_ADDR() { return CURRENT_TOP_ADDR + max_ram_view; }
184 private void UpdateMaxRamView()
185 {
186 if (this.IsDisposed) return;
187 Graphics g = this.CreateGraphics();
188 Size size = g.MeasureString("00", txtData.Font).ToSize();
189 uint ByteHeight = (uint)size.Height;
190 uint TotalHeight = (uint)txtData.Height;
191 uint NumberOfBytes = (uint)((TotalHeight / ByteHeight) * max_address_width) - max_address_width;
192 uint byte_width = (max_address_width * 2);
193 max_ram_view = NumberOfBytes + (byte_width);
194 }
195 private void btnGotoAddress_Click(object sender, EventArgs e)
196 {
197 logger.VerboseDebug.WriteLine("UIMemoryViewer::btnGotoAddress_Click(0x{0:x8})", txthexGoto.ToInt32());
198 this.GotoAddress(txthexGoto.ToUInt32());
199 }
200
201 private void btnEditBytes_Click(object sender, EventArgs e)
202 {
203 byte[] data = (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray();
204 logger.Info.WriteLine("UIMemoryViewer :: editing {0} bytes", data.Length);
205 bool reenable = false;
206 if (this.UpdateEnabled) reenable = true;
207 this.UpdateEnabled = false;
208 ByteEditor editor = new ByteEditor(data, this.CURRENT_TOP_ADDR);
209 editor.ShowDialog();
210 int changed_byte_count = 0;
211 if (editor.BytesEdited)
212 {
213
214 if (editor.AsBytes.Length == data.Length)
215 {
216
217 for (int i = 0; i < data.Length; i++)
218 {
219 if (data[i] != editor.AsBytes[i])
220 changed_byte_count++;
221 }
222 }
223 //DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(editor.AsBytes);
224 //txtData.ByteProvider = _DynamicByteProvider;
225 //_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);
226 this.WriteCurrentBytes(this.CURRENT_TOP_ADDR, editor.AsBytes);
227 }
228 logger.Info.WriteLine("UIMemoryViewer :: changed {0} bytes", changed_byte_count);
229 this.UpdateEnabled = reenable;
230 }
231 private bool ForceUpdate = false;
232 private bool ShouldUpdateResults()
233 {
234 //if (ResultsUpdateWorkerThread.IsBusy) { return false; }
235 if (ForceUpdate) return true;
236 //else if (TextIsBeingSelected) return false;
237 //else if (NonHandledKeysAreBeingPressed) return false;
238 else if (this.UpdateEnabled) return true;
239 else { return false; }
240 }
241 private void UpdateGui(bool force)
242 {
243 if (AcceptedProcess == null) { return; }
244 if (AcceptedPlugin == null) { return; }
245
246 if (!this.ShouldUpdateResults()) { return; }// this.Logger.LogDebugMessage(string.Format("ShouldUpdateResults() -> returning false")); return; }
247 this.UpdateMaxRamView();
248 //if (!force)
249 //{
250 if (!ResultsUpdateWorkerThread.IsBusy)
251 ResultsUpdateWorkerThread.RunWorkerAsync();
252 //}
253 //else
254 //{
255 // while (!ResultsUpdateWorkerThread.IsBusy) { ResultsUpdateWorkerThread.CancelAsync(); Application.DoEvents(); }
256 // ResultsUpdateWorkerThread.RunWorkerAsync();
257 //}
258 }
259 private void UpdateGui()
260 {
261 this.UpdateGui(false);
262 }
263 private byte[] GetMemory()
264 {
265 byte[] data = new byte[max_ram_view];
266 try
267 {
268 using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
269 {
270 provider.OpenProvider();
271 int bytesReadSize;
272 provider.ReadProcessMemory(CURRENT_TOP_ADDR, (uint)max_ram_view, out bytesReadSize, out data);
273 provider.CloseProvider();
274 }
275 }
276 catch (Exception ex)
277 {
278 logger.Error.WriteLine("{0}.GetMemory():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString());
279 }
280 finally
281 {
282 if (data.Length == 0)
283 {
284 data = new byte[max_ram_view];
285 for (int i = 0; i < data.Length; i++) { data[i] = 0x0; }
286 }
287 }
288 return data;
289 }
290 private void UpdateMemroyView() { this.UpdateMemroyView(this.CURRENT_TOP_ADDR); }
291 private void UpdateMemroyView(uint address)
292 {
293 try
294 {
295 if (AcceptedProcess == null) { return; }
296 if (AcceptedPlugin == null) { return; }
297
298 byte[] data = GetMemory();
299 RamData = data;
300 #region old ascii-code
301 try
302 {
303 AddressList = "";
304 AsciiData = "";
305 // write the addreses out
306 for (uint i = address; i < (address + max_ram_view); i += max_address_width) { AddressList = AddressList + string.Format("{0:X8}:\n", i); }
307 StringBuilder builder = new StringBuilder();
308 int count = 0;
309 // write ascii text
310 for (uint i = 0; i < (0 + max_ram_view); i += max_address_width)
311 {
312 try
313 {
314 for (uint j = 0; j < max_address_width; j++)
315 {
316 uint current_real_address = address + j + i;
317 uint current_addr = i + j;
318 if (current_addr >= MemoryRangeSize) break;
319 byte ascii_value_raw = data[current_addr];
320 char ascii_value;
321 char c = (char)data[current_addr];
322 if (char.IsControl(c)) { ascii_value = '.'; }
323 else { ascii_value = c; }
324 using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
325 {
326 gmp.OpenProvider();
327 byte t;
328 if (!gmp.ReadMemory(current_real_address, out t)) { ascii_value = '?'; }
329 gmp.CloseProvider();
330 }
331 builder.Append(ascii_value.ToString());
332 }
333 builder.AppendLine();
334 }
335 catch (Exception ex)
336 {
337 logger.Error.WriteLine("{0}.UpdateMemroyView().BuildingAsciiString:{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString());
338 return;
339 }
340 count++;
341 }
342 AsciiData = builder.ToString();
343 }
344 catch (Exception ex)
345 {
346 logger.Error.WriteLine("{0}.UpdateMemroyView():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString());
347 return;
348 }
349 #endregion
350 }
351 catch (Exception ex) { logger.Error.WriteLine("{0}.UpdateMemroyView():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
352 }
353 //private void HexResourceViewerBytes_Changed(object sender, System.EventArgs e)
354 //{
355 // this.WriteCurrentBytes();
356 //}
357 private void WriteCurrentBytes(uint start_address, byte[] data)
358 {
359 try
360 {
361 if (AcceptedProcess == null) { return; }
362 if (AcceptedPlugin == null) { return; }
363 // Byte changed
364 //byte[] data = (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray();
365 using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
366 {
367 provider.OpenProvider();
368 uint bytesReadSize;
369
370 provider.WriteProcessMemory(start_address, data, out bytesReadSize);
371 //for (int i = 0; i < data.Length; i ++)
372 //{
373 // int addr = (int)(start_address + i);
374 // byte data_to_write = data[i];
375
376 //}
377 provider.CloseProvider();
378 }
379 }
380 catch (Exception ex) { logger.Error.WriteLine("{0}.WriteCurrentBytes():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
381 }
382
383 private void update_timer_Tick(object sender, EventArgs e) { this.UpdateGui(); }
384 private void ResultsUpdateWorkerThread_DoWork(object sender, DoWorkEventArgs e) { try { this.UpdateMemroyView(); } catch (Exception ex) { logger.Error.WriteLine("{0}.ResultsUpdateWorkerThread_DoWork():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); } }
385 private void ResultsUpdateWorkerThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
386 {
387 try
388 {
389 txtAddresses.Text = AddressList;
390 txtAscii.Text = AsciiData;
391 //this.Logger.LogDebugMessage(string.Format("RunWorkerCompeleted() -> Memory Size: {0}0x{2:X8}{1}", "{", "}", RamData.Length));
392 DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(RamData);
393 txtData.ByteProvider = _DynamicByteProvider;
394 //_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);
395 }
396 catch (ObjectDisposedException) { } // ignore errors aobut disposed objects (usually only happens when the parent closes)
397 catch (Exception ex) { logger.Error.WriteLine("{0}.ResultsUpdateWorkerThread_RunWorkerCompleted():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
398 }
399 private void Handle_KeyDown(object sender, KeyEventArgs e)
400 {
401 //isScrolling = false;
402 //bool reenable = false;
403 //if (this.UpdateEnabled) reenable = true;
404 //this.UpdateEnabled = false;
405
406 this.UpdateMaxRamView();
407 uint ORIGINAL_ADDR = this.CURRENT_TOP_ADDR;
408
409 ////if (e.Type == ScrollEventType.EndScroll) return;
410 //uint size = max_ram_view;
411
412 bool haveModifier = false;
413 switch (e.Modifiers)
414 {
415 case Keys.Control:
416 switch (e.KeyCode)
417 {
418 case Keys.Home:
419 this.CURRENT_TOP_ADDR = 0; //NonHandledKeysAreBeingPressed = false;
420 break;
421 case Keys.End:
422 this.CURRENT_TOP_ADDR = (uint)((MemoryRangeSize - 1) - max_ram_view); //NonHandledKeysAreBeingPressed = false;
423 break;
424 default:
425 //NonHandledKeysAreBeingPressed = true;
426 break;
427 }
428 break;
429 }
430
431 if (!haveModifier)
432 {
433 switch (e.KeyCode)
434 {
435 case Keys.Up:
436 if (this.CURRENT_TOP_ADDR == 0 && (this.CURRENT_TOP_ADDR - small_scroll_change > this.CURRENT_TOP_ADDR))
437 {
438 this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
439 }
440 else
441 {
442 this.CURRENT_TOP_ADDR -= (uint)small_scroll_change; //NonHandledKeysAreBeingPressed = false;
443 }
444 break;
445 case Keys.Down:
446 this.CURRENT_TOP_ADDR += (uint)small_scroll_change; //NonHandledKeysAreBeingPressed = false;
447 break;
448 case Keys.PageUp:
449 if (this.CURRENT_TOP_ADDR == 0 && (this.CURRENT_TOP_ADDR - large_scroll_change > this.CURRENT_TOP_ADDR))
450 {
451 this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
452 }
453 else
454 {
455 this.CURRENT_TOP_ADDR -= (uint)(large_scroll_change); //NonHandledKeysAreBeingPressed = false;
456 }
457 break;
458 case Keys.PageDown:
459 this.CURRENT_TOP_ADDR += (uint)(large_scroll_change); //NonHandledKeysAreBeingPressed = false;
460 break;
461 default:
462 //NonHandledKeysAreBeingPressed = true;
463 break;
464 }
465 }
466 if (this.CURRENT_TOP_ADDR < MemoryRangeStart) this.CURRENT_TOP_ADDR = MemoryRangeStart;
467 //if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = (size - 1) - max_ram_view;
468 if (this.CURRENT_TOP_ADDR + max_ram_view >= MemoryRangeSize) this.CURRENT_TOP_ADDR = (uint)(MemoryRangeSize - max_ram_view);
469
470 //this.UpdateEnabled = reenable;
471 }
472
473 private void UIMemoryViewer_KeyDown(object sender, KeyEventArgs e) { this.Handle_KeyDown(sender, e); }
474 private void txtAddresses_KeyDown(object sender, KeyEventArgs e) { this.Handle_KeyDown(sender, e); }
475 private void txtData_KeyDown(object sender, KeyEventArgs e) { this.Handle_KeyDown(sender, e); }
476 private void txtAscii_KeyDown(object sender, KeyEventArgs e) { this.Handle_KeyDown(sender, e); }
477 private void ramScroll_Scroll(object sender, ScrollEventArgs e) { this.Handle_Scroll(sender, e); }
478
479 private ScrollEventArgs GetMouseWheelScrollChange(int WheelDelta)
480 {
481 ScrollEventArgs args = new ScrollEventArgs(ScrollEventType.SmallIncrement, 1);
482 if (WheelDelta < 0)
483 {
484 //// negative: scroll down
485 //// SmallDecrement -or- LargeDecrement
486 //if (WheelDelta <= small_scroll_change)
487 //{
488 // args = new ScrollEventArgs(ScrollEventType.SmallDecrement,(int)small_scroll_change);
489 //}
490 //if (WheelDelta > small_scroll_change && WheelDelta <= large_scroll_change)
491 //{
492 // args = new ScrollEventArgs(ScrollEventType.LargeDecrement, (int)large_scroll_change);
493 //}
494 args = new ScrollEventArgs(ScrollEventType.SmallIncrement, 1);
495 }
496 else
497 {
498 //// positive: scroll up
499 //// SmallIncrement -or- LargeIncrement
500 //if (WheelDelta <= small_scroll_change)
501 //{
502 // args = new ScrollEventArgs(ScrollEventType.SmallIncrement, (int)small_scroll_change);
503 //}
504 //if (WheelDelta > small_scroll_change && WheelDelta <= large_scroll_change)
505 //{
506 // args = new ScrollEventArgs(ScrollEventType.LargeIncrement, (int)large_scroll_change);
507 //}
508 args = new ScrollEventArgs(ScrollEventType.SmallDecrement, 1);
509 }
510 return args;
511 }
512
513 void txtAddresses_MouseWheel(object sender, MouseEventArgs e) { this.Handle_Scroll(sender, GetMouseWheelScrollChange(e.Delta)); }
514 void txtData_MouseWheel(object sender, MouseEventArgs e) { this.Handle_Scroll(sender, GetMouseWheelScrollChange(e.Delta)); }
515 void txtAscii_MouseWheel(object sender, MouseEventArgs e) { this.Handle_Scroll(sender, GetMouseWheelScrollChange(e.Delta)); }
516 private void Handle_Scroll(object sender, ScrollEventArgs e)
517 {
518 //isScrolling = true;
519 //bool reenable = false;
520 //if (this.UpdateEnabled) reenable = true;
521 //this.UpdateEnabled = false;
522
523 this.UpdateMaxRamView();
524 uint ORIGINAL_ADDR = this.CURRENT_TOP_ADDR;
525 //uint size = MemorySize;
526 if (e.Type == ScrollEventType.EndScroll) return;
527
528 switch (e.Type)
529 {
530 case ScrollEventType.SmallDecrement:
531 if (this.CURRENT_TOP_ADDR == 0 && ((this.CURRENT_TOP_ADDR - small_scroll_change) > this.CURRENT_TOP_ADDR))
532 {
533 this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
534 }
535 else
536 {
537 this.CURRENT_TOP_ADDR -= (small_scroll_change);
538 }
539 break;
540 case ScrollEventType.SmallIncrement:
541 this.CURRENT_TOP_ADDR += (small_scroll_change);
542 break;
543
544 case ScrollEventType.LargeDecrement:
545 if (this.CURRENT_TOP_ADDR == 0 && ((this.CURRENT_TOP_ADDR - large_scroll_change) > this.CURRENT_TOP_ADDR))
546 {
547 this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
548 }
549 else
550 {
551 this.CURRENT_TOP_ADDR -= (large_scroll_change);
552 }
553 break;
554 case ScrollEventType.LargeIncrement:
555 this.CURRENT_TOP_ADDR += (large_scroll_change);
556 break;
557 case ScrollEventType.ThumbPosition:
558 //this.CURRENT_TOP_ADDR = (uint)e.NewValue;
559 //break;
560 default:
561 this.CURRENT_TOP_ADDR = (uint)(e.NewValue & 0xFFFFFFF0);
562 break;
563 }
564 if (this.CURRENT_TOP_ADDR < 0) this.CURRENT_TOP_ADDR = 0;
565 //if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = VTLB_VADDR_SIZE - max_ram_view;
566 //if (this.CURRENT_TOP_ADDR < 0 || this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
567 if (this.CURRENT_TOP_ADDR + max_ram_view >= MemoryRangeSize) this.CURRENT_TOP_ADDR = (uint)(MemoryRangeSize - max_ram_view);
568 //this.UpdateEnabled = reenable;
569 //isScrolling = false;
570 }
571 private void GotoImageBase()
572 {
573 if (this.peData == null) return;
574 object ImageBase = 0;
575 bool x86 = this.peData.Is32bitAssembly();
576 if (x86)
577 {
578 ImageBase = this.peData.NTHeader.OptionalHeader32._ImageBase;
579 uint ib = Convert.ToUInt32(ImageBase);
580 logger.VerboseDebug.WriteLine("UIMemoryViewer::GotoImageBase(0x{0:x8})", ib);
581 txthexGoto.Value = ib;
582 }
583 else
584 {
585 ImageBase = this.peData.NTHeader.OptionalHeader64._ImageBase;
586 ulong ib = Convert.ToUInt64(ImageBase);
587 logger.VerboseDebug.WriteLine("UIMemoryViewer::GotoImageBase(0x{0:x16})", ib);
588 txthexGoto.Value = (long)ib;
589 }
590
591 this.GotoAddress(txthexGoto.ToUInt32());
592 }
593 private void btnGotoImageBase_Click(object sender, EventArgs e)
594 {
595
596 this.GotoImageBase();
597 }
598
599 }
600 }

  ViewVC Help
Powered by ViewVC 1.1.22