/[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 357 - (show annotations) (download)
Sun Jun 10 00:47:58 2012 UTC (9 years, 5 months ago) by william
File size: 27096 byte(s)

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 IPEDData peData { get; set; }
117 public void SetPEViewerData(IPEDData 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 provider.WriteProcessMemory(start_address, data, out bytesReadSize);
360 //for (int i = 0; i < data.Length; i ++)
361 //{
362 // int addr = (int)(start_address + i);
363 // byte data_to_write = data[i];
364
365 //}
366 provider.CloseProvider();
367 }
368 catch (Exception ex) { logger.Error.WriteLine("{0}.WriteCurrentBytes():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
369 }
370
371 private void update_timer_Tick(object sender, EventArgs e) { this.UpdateGui(); }
372 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()); } }
373 private void ResultsUpdateWorkerThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
374 {
375 try
376 {
377 txtAddresses.Clear(); txtAddresses.Text = AddressList;
378 //txtAscii.Clear(); txtAscii.Text = AsciiData;
379 //this.Logger.LogDebugMessage(string.Format("RunWorkerCompeleted() -> Memory Size: {0}0x{2:X8}{1}", "{", "}", RamData.Length));
380 DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(RamData);
381 txtData.ByteProvider = _DynamicByteProvider;
382 //_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed);
383 }
384 catch (ObjectDisposedException) { } // ignore errors aobut disposed objects (usually only happens when the parent closes)
385 catch (Exception ex) { logger.Error.WriteLine("{0}.ResultsUpdateWorkerThread_RunWorkerCompleted():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
386 }
387 private void Handle_KeyDown(object sender, KeyEventArgs e)
388 {
389 //isScrolling = false;
390 //bool reenable = false;
391 //if (this.UpdateEnabled) reenable = true;
392 //this.UpdateEnabled = false;
393
394 this.UpdateMaxRamView();
395 int ORIGINAL_ADDR = this.CURRENT_TOP_ADDR;
396
397 ////if (e.Type == ScrollEventType.EndScroll) return;
398 //uint size = max_ram_view;
399
400 bool haveModifier = false;
401 switch (e.Modifiers)
402 {
403 case Keys.Control:
404 switch (e.KeyCode)
405 {
406 case Keys.Home:
407 this.CURRENT_TOP_ADDR = 0; //NonHandledKeysAreBeingPressed = false;
408 break;
409 case Keys.End:
410 this.CURRENT_TOP_ADDR = (int)((MemoryRangeSize - 1) - max_ram_view); //NonHandledKeysAreBeingPressed = false;
411 break;
412 default:
413 //NonHandledKeysAreBeingPressed = true;
414 break;
415 }
416 break;
417 }
418
419 if (!haveModifier)
420 {
421 switch (e.KeyCode)
422 {
423 case Keys.Up:
424 if (this.CURRENT_TOP_ADDR == 0 && (this.CURRENT_TOP_ADDR - small_scroll_change > this.CURRENT_TOP_ADDR))
425 {
426 this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
427 }
428 else
429 {
430 this.CURRENT_TOP_ADDR -= (int)small_scroll_change; //NonHandledKeysAreBeingPressed = false;
431 }
432 break;
433 case Keys.Down:
434 this.CURRENT_TOP_ADDR += (int)small_scroll_change; //NonHandledKeysAreBeingPressed = false;
435 break;
436 case Keys.PageUp:
437 if (this.CURRENT_TOP_ADDR == 0 && (this.CURRENT_TOP_ADDR - large_scroll_change > this.CURRENT_TOP_ADDR))
438 {
439 this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
440 }
441 else
442 {
443 this.CURRENT_TOP_ADDR -= (int)(large_scroll_change); //NonHandledKeysAreBeingPressed = false;
444 }
445 break;
446 case Keys.PageDown:
447 this.CURRENT_TOP_ADDR += (int)(large_scroll_change); //NonHandledKeysAreBeingPressed = false;
448 break;
449 default:
450 //NonHandledKeysAreBeingPressed = true;
451 break;
452 }
453 }
454 if (this.CURRENT_TOP_ADDR < MemoryRangeStart) this.CURRENT_TOP_ADDR = MemoryRangeStart;
455 //if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = (size - 1) - max_ram_view;
456 if (this.CURRENT_TOP_ADDR + max_ram_view >= MemoryRangeSize) this.CURRENT_TOP_ADDR = (int)(MemoryRangeSize - max_ram_view);
457
458 //this.UpdateEnabled = reenable;
459 }
460
461 private void UIMemoryViewer_KeyDown(object sender, KeyEventArgs e) { this.Handle_KeyDown(sender, e); }
462 private void txtAddresses_KeyDown(object sender, KeyEventArgs e) { this.Handle_KeyDown(sender, e); }
463 private void txtData_KeyDown(object sender, KeyEventArgs e) { this.Handle_KeyDown(sender, e); }
464
465 private void ramScroll_Scroll(object sender, ScrollEventArgs e) { this.Handle_Scroll(sender, e); }
466
467 private ScrollEventArgs GetMouseWheelScrollChange(int WheelDelta)
468 {
469 ScrollEventArgs args = new ScrollEventArgs(ScrollEventType.SmallIncrement,1);
470 if (WheelDelta < 0)
471 {
472 //// negative: scroll down
473 //// SmallDecrement -or- LargeDecrement
474 //if (WheelDelta <= small_scroll_change)
475 //{
476 // args = new ScrollEventArgs(ScrollEventType.SmallDecrement,(int)small_scroll_change);
477 //}
478 //if (WheelDelta > small_scroll_change && WheelDelta <= large_scroll_change)
479 //{
480 // args = new ScrollEventArgs(ScrollEventType.LargeDecrement, (int)large_scroll_change);
481 //}
482 args = new ScrollEventArgs(ScrollEventType.SmallIncrement, 1);
483 }
484 else
485 {
486 //// positive: scroll up
487 //// SmallIncrement -or- LargeIncrement
488 //if (WheelDelta <= small_scroll_change)
489 //{
490 // args = new ScrollEventArgs(ScrollEventType.SmallIncrement, (int)small_scroll_change);
491 //}
492 //if (WheelDelta > small_scroll_change && WheelDelta <= large_scroll_change)
493 //{
494 // args = new ScrollEventArgs(ScrollEventType.LargeIncrement, (int)large_scroll_change);
495 //}
496 args = new ScrollEventArgs(ScrollEventType.SmallDecrement, 1);
497 }
498 return args;
499 }
500
501 void txtAddresses_MouseWheel(object sender, MouseEventArgs e) { this.Handle_Scroll(sender, GetMouseWheelScrollChange(e.Delta)); }
502 void txtData_MouseWheel(object sender, MouseEventArgs e) { this.Handle_Scroll(sender, GetMouseWheelScrollChange(e.Delta)); }
503
504
505 private void Handle_Scroll(object sender, ScrollEventArgs e)
506 {
507 //isScrolling = true;
508 //bool reenable = false;
509 //if (this.UpdateEnabled) reenable = true;
510 //this.UpdateEnabled = false;
511
512 this.UpdateMaxRamView();
513 int ORIGINAL_ADDR = this.CURRENT_TOP_ADDR;
514 //uint size = MemorySize;
515 if (e.Type == ScrollEventType.EndScroll) return;
516
517 switch (e.Type)
518 {
519 case ScrollEventType.SmallDecrement:
520 if (this.CURRENT_TOP_ADDR == 0 && ((this.CURRENT_TOP_ADDR - small_scroll_change) > this.CURRENT_TOP_ADDR))
521 {
522 this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
523 }
524 else
525 {
526 this.CURRENT_TOP_ADDR -= (small_scroll_change);
527 }
528 break;
529 case ScrollEventType.SmallIncrement:
530 this.CURRENT_TOP_ADDR += (small_scroll_change);
531 break;
532
533 case ScrollEventType.LargeDecrement:
534 if (this.CURRENT_TOP_ADDR == 0 && ((this.CURRENT_TOP_ADDR - large_scroll_change) > this.CURRENT_TOP_ADDR))
535 {
536 this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
537 }
538 else
539 {
540 this.CURRENT_TOP_ADDR -= (large_scroll_change);
541 }
542 break;
543 case ScrollEventType.LargeIncrement:
544 this.CURRENT_TOP_ADDR += (large_scroll_change);
545 break;
546 case ScrollEventType.ThumbPosition:
547 //this.CURRENT_TOP_ADDR = (uint)e.NewValue;
548 //break;
549 default:
550 this.CURRENT_TOP_ADDR = (int)(e.NewValue & 0xFFFFFFF0);
551 break;
552 }
553 if (this.CURRENT_TOP_ADDR < 0) this.CURRENT_TOP_ADDR = 0;
554 //if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = VTLB_VADDR_SIZE - max_ram_view;
555 //if (this.CURRENT_TOP_ADDR < 0 || this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = ORIGINAL_ADDR;
556 if (this.CURRENT_TOP_ADDR + max_ram_view >= MemoryRangeSize) this.CURRENT_TOP_ADDR = (int)(MemoryRangeSize - max_ram_view);
557 //this.UpdateEnabled = reenable;
558 //isScrolling = false;
559 }
560
561 private void btnGotoImageBase_Click(object sender, EventArgs e)
562 {
563 if (this.peData == null) return;
564 object ImageBase = 0;
565 bool x86 = this.peData.Is32bitAssembly();
566 logger.VerboseDebug.WriteLine("UIMemoryViewer::btnGotoImageBase_Click(0x{0:x8})", ImageBase);
567 if (x86)
568 {
569 ImageBase = this.peData.NTHeader.OptionalHeader32._ImageBase;
570 uint ib = Convert.ToUInt32(ImageBase);
571 //logger.Debug.WriteLine("UIMemoryViewer::btnGotoImageBase_Click(0x{0:x8})", ib);
572 txthexGoto.Value = ib;
573 btnGotoAddress.PerformClick();
574 }
575 else
576 {
577 ImageBase = this.peData.NTHeader.OptionalHeader64._ImageBase;
578 ulong ib = Convert.ToUInt64(ImageBase);
579 txthexGoto.Value = (long)ib;
580 btnGotoAddress.PerformClick();
581 }
582 IntPtr lpBaseAddress = this.AcceptedProcess.MainModule.BaseAddress;
583 int BaseAddress = lpBaseAddress.ToInt32();
584 txthexGoto.Value = BaseAddress;
585 btnGotoAddress.PerformClick();
586 }
587
588 }
589 }

  ViewVC Help
Powered by ViewVC 1.1.22