public Target(object targetClass, PythonBoss pyBoss, Process process) { _targetClass = targetClass; _process = process; _pyBoss = pyBoss; _breakpoints = new List <Breakpoint>(1); _name = Target.GetName(targetClass); }
public void HandleProcessLoaded() { // Actually create the _targets foreach (object targetClass in _targetsToLoad) { try { // Initialize the target Target newTarget = new Target(targetClass, _pyBoss, this); try { newTarget.Initialize(); if (_targets.ContainsKey(newTarget.PyTarget)) Console.WriteLine(string.Format("WARNING: Constructor of python class 'Target' {0} attempted to add target handler '{1}' more than once.", targetClass.ToString(), Target.GetName(newTarget.PyTarget))); else { _targets.Add(newTarget.PyTarget, newTarget); try { newTarget.PyTarget.on_attached(); } catch (Exception e) { Console.WriteLine(string.Format("ERROR: Python class 'Target' {0} failed to call 'on_attached()':", newTarget.GetName())); Console.WriteLine(e.ToString()); return; } } } catch (Exception e) { Console.WriteLine(string.Format("ERROR: Constructor of python class 'Target' {0} failed:", newTarget.GetName())); Console.WriteLine(e.ToString()); return; } } catch (Exception e) { Console.WriteLine(string.Format("ERROR: Constructor of python class 'Target' '{0}' failed:", targetClass.ToString())); Console.WriteLine(e.ToString()); return; } } // Let the Process() class handle the process loaded event PyProcess.handle_process_loaded(); }
public void RemoveBreakpoint(object targetHandler, long address) { // Remove the specified breakpoint with targetHandlerName as the event handler if (_targets.Contains(targetHandler)) { Target target = (Target)_targets[targetHandler]; _debugger.RemoveBreakpoint(target, (IntPtr)address, this); } else { Console.WriteLine(string.Format("ERROR: Failed to find 'Target' breakpoint handler name '{0}' as specified by 'AddBreakpoint' argument.", Target.GetName(targetHandler))); } }
public void AddBreakpoint(object targetHandler, long address, string eventName) { // Add the specified breakpoint with targetHandlerName as the event handler try { if (_targets.Contains(targetHandler)) { Target target = (Target)_targets[targetHandler]; _debugger.AddBreakpoint(target, (IntPtr)address, this, eventName); } else { Console.WriteLine(string.Format("ERROR: Failed to find 'Target' breakpoint handler name '{0}' as specified by 'AddBreakpoint' argument.", Target.GetName(targetHandler))); } } catch (Exception e) { Console.WriteLine(string.Format("ERROR: Failed to call 'Engine.AddBreakpoints()'. This is likely are a result of improperly formed argument inputs to AddBreakpoints().")); Console.WriteLine(e.ToString()); //throw e; } }
public void AddBreakpoints(object targetHandler, List addresses) { // Add the specified breakpoint with targetHandlerName as the event handler try { if (_targets.Contains(targetHandler)) { Target target = (Target)_targets[targetHandler]; foreach (List address in addresses) { UInt64 address_uint = 0; if (address[0] is Int64) { address_uint = (UInt64)(Int64)address[0]; } else if (address[0] is UInt64) { address_uint = (UInt64)address[0]; } else { address_uint = (UInt64)(int)address[0]; } _debugger.AddBreakpoint(target, (IntPtr)address_uint, this, (string)address[1]); } } else { Console.WriteLine(string.Format("ERROR: Failed to find 'Target' breakpoint handler name '{0}' as specified by 'AddBreakpoint' argument.", Target.GetName(targetHandler))); } } catch (Exception e) { Console.WriteLine(string.Format("ERROR: Failed to call 'Engine.AddBreakpoints()'. This is likely are a result of improperly formed argument inputs to AddBreakpoints().")); Console.WriteLine(e.ToString()); //throw e; } }
public void HandleProcessLoaded() { // Actually create the _targets foreach (object targetClass in _targetsToLoad) { try { // Initialize the target Target newTarget = new Target(targetClass, _pyBoss, this); try { newTarget.Initialize(); if (_targets.ContainsKey(newTarget.PyTarget)) { Console.WriteLine(string.Format("WARNING: Constructor of python class 'Target' {0} attempted to add target handler '{1}' more than once.", targetClass.ToString(), Target.GetName(newTarget.PyTarget))); } else { _targets.Add(newTarget.PyTarget, newTarget); try { newTarget.PyTarget.on_attached(); } catch (Exception e) { Console.WriteLine(string.Format("ERROR: Python class 'Target' {0} failed to call 'on_attached()':", newTarget.GetName())); Console.WriteLine(e.ToString()); return; } } } catch (Exception e) { Console.WriteLine(string.Format("ERROR: Constructor of python class 'Target' {0} failed:", newTarget.GetName())); Console.WriteLine(e.ToString()); return; } } catch (Exception e) { Console.WriteLine(string.Format("ERROR: Constructor of python class 'Target' '{0}' failed:", targetClass.ToString())); Console.WriteLine(e.ToString()); return; } } // Let the Process() class handle the process loaded event PyProcess.handle_process_loaded(); }