43 |
|
|
44 |
txtAddresses.MouseWheel += new MouseEventHandler(txtAddresses_MouseWheel); |
txtAddresses.MouseWheel += new MouseEventHandler(txtAddresses_MouseWheel); |
45 |
txtData.MouseWheel += new MouseEventHandler(txtData_MouseWheel); |
txtData.MouseWheel += new MouseEventHandler(txtData_MouseWheel); |
46 |
} |
} |
47 |
|
|
48 |
|
private void GetFirstNonZeroByte() |
49 |
|
{ |
50 |
|
if (!DesignMode) |
51 |
|
{ |
52 |
|
Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader(); |
53 |
|
reader.ReadProcess = this.AcceptedProcess; |
54 |
|
reader.OpenProcess(); |
55 |
|
uint addr = 0; |
56 |
|
reader.ReadFirstNonZeroByte(MemoryStart, MemorySize, out addr); |
57 |
|
GotoAddress(addr); |
58 |
|
} |
59 |
|
} |
60 |
|
|
61 |
#region IProcessConfig Members |
#region IProcessConfig Members |
62 |
private Process _AcceptedProcess; |
private Process _AcceptedProcess; |
63 |
public Process AcceptedProcess |
public Process AcceptedProcess |
68 |
_AcceptedProcess = value; |
_AcceptedProcess = value; |
69 |
update_timer.Enabled = (value != null); |
update_timer.Enabled = (value != null); |
70 |
UpdateEnabled = update_timer.Enabled; |
UpdateEnabled = update_timer.Enabled; |
71 |
|
if (value != null) |
72 |
|
GetFirstNonZeroByte(); |
73 |
} |
} |
74 |
} |
} |
75 |
#endregion |
#endregion |
77 |
public IConfigPlugin AcceptedPlugin { get; set; } |
public IConfigPlugin AcceptedPlugin { get; set; } |
78 |
#endregion |
#endregion |
79 |
#region IAcceptsMemoryRange members |
#region IAcceptsMemoryRange members |
80 |
private uint MemoryStart { get { return 0; } } |
public uint MemoryStart { get { return 0; } } |
81 |
private uint MemorySize { get { return int.MaxValue; } } |
public uint MemorySize { get { return int.MaxValue; } } |
82 |
#endregion |
#endregion |
83 |
public void GotoTop() { this.CURRENT_TOP_ADDR = 0; } |
public void GotoTop() { this.CURRENT_TOP_ADDR = 0; } |
84 |
public void GotoBottom() { uint size = MemorySize; this.CURRENT_TOP_ADDR = (uint)((size - 1) - max_ram_view); } |
public void GotoBottom() { uint size = MemorySize; this.CURRENT_TOP_ADDR = (uint)((size - 1) - max_ram_view); } |
120 |
uint CURRENT_TOP_ADDR |
uint CURRENT_TOP_ADDR |
121 |
{ |
{ |
122 |
get { return _CURRENT_TOP_ADDR; } |
get { return _CURRENT_TOP_ADDR; } |
123 |
set { _CURRENT_TOP_ADDR = value; } |
set { txthexGoto.Value = _CURRENT_TOP_ADDR = value; } |
124 |
} |
} |
125 |
//uint CURRENT_BOITTOM_ADDR() { return CURRENT_TOP_ADDR + max_ram_view; } |
//uint CURRENT_BOITTOM_ADDR() { return CURRENT_TOP_ADDR + max_ram_view; } |
126 |
private void UpdateMaxRamView() |
private void UpdateMaxRamView() |
147 |
editor.ShowDialog(); |
editor.ShowDialog(); |
148 |
if (editor.BytesEdited) |
if (editor.BytesEdited) |
149 |
{ |
{ |
150 |
DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(editor.AsBytes); |
//DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(editor.AsBytes); |
151 |
txtData.ByteProvider = _DynamicByteProvider; |
//txtData.ByteProvider = _DynamicByteProvider; |
152 |
_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed); |
//_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed); |
153 |
this.WriteCurrentBytes(); |
this.WriteCurrentBytes(this.CURRENT_TOP_ADDR, editor.AsBytes); |
154 |
} |
} |
155 |
this.UpdateEnabled = reenable; |
this.UpdateEnabled = reenable; |
156 |
} |
} |
194 |
reader.ReadProcess = this.AcceptedProcess; |
reader.ReadProcess = this.AcceptedProcess; |
195 |
reader.OpenProcess(); |
reader.OpenProcess(); |
196 |
int bytesReadSize; |
int bytesReadSize; |
197 |
byte[] data = reader.ReadProcessMemory(CURRENT_TOP_ADDR, max_ram_view, out bytesReadSize); |
byte[] data; |
198 |
|
reader.ReadProcessMemory(CURRENT_TOP_ADDR, max_ram_view, out bytesReadSize, out data); |
199 |
//this.Logger.LogDebugMessage(string.Format("GetMemory() -> Memory Size: {0}0x{2:X8}{1}", "{", "}", data.Length)); |
//this.Logger.LogDebugMessage(string.Format("GetMemory() -> Memory Size: {0}0x{2:X8}{1}", "{", "}", data.Length)); |
200 |
return data; |
return data; |
201 |
} |
} |
269 |
} |
} |
270 |
catch (Exception ex) { logger.Error.WriteLine("{0}.UpdateMemroyView():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); } |
catch (Exception ex) { logger.Error.WriteLine("{0}.UpdateMemroyView():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); } |
271 |
} |
} |
272 |
private void HexResourceViewerBytes_Changed(object sender, System.EventArgs e) |
//private void HexResourceViewerBytes_Changed(object sender, System.EventArgs e) |
273 |
{ |
//{ |
274 |
this.WriteCurrentBytes(); |
// this.WriteCurrentBytes(); |
275 |
} |
//} |
276 |
private void WriteCurrentBytes() |
private void WriteCurrentBytes(uint start_address, byte[] data) |
277 |
{ |
{ |
278 |
try |
try |
279 |
{ |
{ |
280 |
if (AcceptedProcess == null) { return; } |
if (AcceptedProcess == null) { return; } |
281 |
if (AcceptedPlugin == null) { return; } |
if (AcceptedPlugin == null) { return; } |
282 |
// Byte changed |
// Byte changed |
283 |
byte[] data = (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray(); |
//byte[] data = (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray(); |
284 |
|
|
285 |
|
|
286 |
Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader(); |
Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader(); |
288 |
reader.OpenProcess(); |
reader.OpenProcess(); |
289 |
int bytesReadSize; |
int bytesReadSize; |
290 |
|
|
291 |
for (int i = 0; i < data.Length; i += sizeof(uint)) |
for (int i = 0; i < data.Length; i ++) |
292 |
{ |
{ |
293 |
uint addr = (uint)(this.CURRENT_TOP_ADDR + i); |
uint addr = (uint)(start_address + i); |
294 |
uint data_to_write = BitConverter.ToUInt32(data, i); |
byte data_to_write = data[i]; |
295 |
reader.WriteProcessMemory((UIntPtr)addr, data, out bytesReadSize); |
reader.WriteProcessMemory((UIntPtr)addr, data_to_write, out bytesReadSize); |
296 |
} |
} |
297 |
} |
} |
298 |
catch (Exception ex) { logger.Error.WriteLine("{0}.WriteCurrentBytes():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); } |
catch (Exception ex) { logger.Error.WriteLine("{0}.WriteCurrentBytes():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); } |
309 |
//this.Logger.LogDebugMessage(string.Format("RunWorkerCompeleted() -> Memory Size: {0}0x{2:X8}{1}", "{", "}", RamData.Length)); |
//this.Logger.LogDebugMessage(string.Format("RunWorkerCompeleted() -> Memory Size: {0}0x{2:X8}{1}", "{", "}", RamData.Length)); |
310 |
DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(RamData); |
DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(RamData); |
311 |
txtData.ByteProvider = _DynamicByteProvider; |
txtData.ByteProvider = _DynamicByteProvider; |
312 |
_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed); |
//_DynamicByteProvider.Changed += new EventHandler(HexResourceViewerBytes_Changed); |
313 |
} |
} |
314 |
catch (ObjectDisposedException) { } // ignore errors aobut disposed objects (usually only happens when the parent closes) |
catch (ObjectDisposedException) { } // ignore errors aobut disposed objects (usually only happens when the parent closes) |
315 |
catch (Exception ex) { logger.Error.WriteLine("{0}.ResultsUpdateWorkerThread_RunWorkerCompleted():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); } |
catch (Exception ex) { logger.Error.WriteLine("{0}.ResultsUpdateWorkerThread_RunWorkerCompleted():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); } |
325 |
uint ORIGINAL_ADDR = this.CURRENT_TOP_ADDR; |
uint ORIGINAL_ADDR = this.CURRENT_TOP_ADDR; |
326 |
|
|
327 |
////if (e.Type == ScrollEventType.EndScroll) return; |
////if (e.Type == ScrollEventType.EndScroll) return; |
328 |
uint size = max_ram_view; |
//uint size = max_ram_view; |
329 |
|
|
330 |
bool haveModifier = false; |
bool haveModifier = false; |
331 |
switch (e.Modifiers) |
switch (e.Modifiers) |
337 |
this.CURRENT_TOP_ADDR = 0; //NonHandledKeysAreBeingPressed = false; |
this.CURRENT_TOP_ADDR = 0; //NonHandledKeysAreBeingPressed = false; |
338 |
break; |
break; |
339 |
case Keys.End: |
case Keys.End: |
340 |
this.CURRENT_TOP_ADDR = (uint)((size - 1) - max_ram_view); //NonHandledKeysAreBeingPressed = false; |
this.CURRENT_TOP_ADDR = (uint)((MemorySize - 1) - max_ram_view); //NonHandledKeysAreBeingPressed = false; |
341 |
break; |
break; |
342 |
default: |
default: |
343 |
//NonHandledKeysAreBeingPressed = true; |
//NonHandledKeysAreBeingPressed = true; |
351 |
switch (e.KeyCode) |
switch (e.KeyCode) |
352 |
{ |
{ |
353 |
case Keys.Up: |
case Keys.Up: |
354 |
this.CURRENT_TOP_ADDR -= (uint)small_scroll_change; //NonHandledKeysAreBeingPressed = false; |
if (this.CURRENT_TOP_ADDR == 0 && (this.CURRENT_TOP_ADDR - small_scroll_change > this.CURRENT_TOP_ADDR)) |
355 |
|
{ |
356 |
|
this.CURRENT_TOP_ADDR = ORIGINAL_ADDR; |
357 |
|
} |
358 |
|
else |
359 |
|
{ |
360 |
|
this.CURRENT_TOP_ADDR -= (uint)small_scroll_change; //NonHandledKeysAreBeingPressed = false; |
361 |
|
} |
362 |
break; |
break; |
363 |
case Keys.Down: |
case Keys.Down: |
364 |
this.CURRENT_TOP_ADDR += (uint)small_scroll_change; //NonHandledKeysAreBeingPressed = false; |
this.CURRENT_TOP_ADDR += (uint)small_scroll_change; //NonHandledKeysAreBeingPressed = false; |
365 |
break; |
break; |
366 |
case Keys.PageUp: |
case Keys.PageUp: |
367 |
this.CURRENT_TOP_ADDR -= (uint)(large_scroll_change); //NonHandledKeysAreBeingPressed = false; |
if (this.CURRENT_TOP_ADDR == 0 && (this.CURRENT_TOP_ADDR - large_scroll_change > this.CURRENT_TOP_ADDR)) |
368 |
|
{ |
369 |
|
this.CURRENT_TOP_ADDR = ORIGINAL_ADDR; |
370 |
|
} |
371 |
|
else |
372 |
|
{ |
373 |
|
this.CURRENT_TOP_ADDR -= (uint)(large_scroll_change); //NonHandledKeysAreBeingPressed = false; |
374 |
|
} |
375 |
break; |
break; |
376 |
case Keys.PageDown: |
case Keys.PageDown: |
377 |
this.CURRENT_TOP_ADDR += (uint)(large_scroll_change); //NonHandledKeysAreBeingPressed = false; |
this.CURRENT_TOP_ADDR += (uint)(large_scroll_change); //NonHandledKeysAreBeingPressed = false; |
383 |
} |
} |
384 |
if (this.CURRENT_TOP_ADDR < MemoryStart) this.CURRENT_TOP_ADDR = MemoryStart; |
if (this.CURRENT_TOP_ADDR < MemoryStart) this.CURRENT_TOP_ADDR = MemoryStart; |
385 |
//if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = (size - 1) - max_ram_view; |
//if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = (size - 1) - max_ram_view; |
386 |
if (this.CURRENT_TOP_ADDR + max_ram_view >= MemorySize) this.CURRENT_TOP_ADDR = (size - 1); |
if (this.CURRENT_TOP_ADDR + max_ram_view >= MemorySize) this.CURRENT_TOP_ADDR = (MemorySize - max_ram_view); |
387 |
|
|
388 |
//this.UpdateEnabled = reenable; |
//this.UpdateEnabled = reenable; |
389 |
} |
} |
390 |
|
|
441 |
|
|
442 |
this.UpdateMaxRamView(); |
this.UpdateMaxRamView(); |
443 |
uint ORIGINAL_ADDR = this.CURRENT_TOP_ADDR; |
uint ORIGINAL_ADDR = this.CURRENT_TOP_ADDR; |
444 |
uint size = MemorySize; |
//uint size = MemorySize; |
445 |
if (e.Type == ScrollEventType.EndScroll) return; |
if (e.Type == ScrollEventType.EndScroll) return; |
446 |
|
|
447 |
switch (e.Type) |
switch (e.Type) |
483 |
if (this.CURRENT_TOP_ADDR < 0) this.CURRENT_TOP_ADDR = 0; |
if (this.CURRENT_TOP_ADDR < 0) this.CURRENT_TOP_ADDR = 0; |
484 |
//if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = VTLB_VADDR_SIZE - max_ram_view; |
//if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = VTLB_VADDR_SIZE - max_ram_view; |
485 |
//if (this.CURRENT_TOP_ADDR < 0 || this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = ORIGINAL_ADDR; |
//if (this.CURRENT_TOP_ADDR < 0 || this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = ORIGINAL_ADDR; |
486 |
if (this.CURRENT_TOP_ADDR + max_ram_view >= MemorySize) this.CURRENT_TOP_ADDR = (size - 1) - max_ram_view; |
if (this.CURRENT_TOP_ADDR + max_ram_view >= MemorySize) this.CURRENT_TOP_ADDR = MemorySize - max_ram_view; |
487 |
//this.UpdateEnabled = reenable; |
//this.UpdateEnabled = reenable; |
488 |
//isScrolling = false; |
//isScrolling = false; |
489 |
} |
} |
490 |
|
|
491 |
} |
} |
492 |
} |
} |