ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Docking/UI/UIMemoryViewer.cs
Revision: 351
Committed: Sat Jun 9 20:52:19 2012 UTC (10 years, 5 months ago) by william
File size: 26876 byte(s)
Log Message:

File Contents

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