Example #1
0
        public void AddTargetHandler(Target target, string name)
        {
            _targets.Add(target);
            Names.Add(name);

            if (_targets.Count > 0)
                SetBreakpoint();
        }
Example #2
0
 public Breakpoint(Process process, IntPtr address, Target target, string name)
 {
     _process = process;
     _address = address;
     _targets = new List<Target>(1);
     Names = new List<string>(1);
     _targets.Add(target);
     Names.Add(name);
     SetBreakpoint();
 }
Example #3
0
        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();
        }
Example #4
0
 public void HandleBreakpointEvent(Target target, Breakpoint breakpoint, IntPtr hThread, Context context, string eventName)
 {
     try
     {
         this.PyProcess.breakpoint_hit(target.PyTarget, eventName, context.GetIP(), context, hThread);
     }
     catch (Exception e)
     {
         _pyBoss.PrintError(e, string.Format("'Process' handler for instance '{0}' failed during attempt to call 'breakpoint_hit()':", _name));
     }
 }
Example #5
0
        public void RemoveTargetHandler(Target target)
        {
            if (_targets.Contains(target))
            {
                int index = _targets.IndexOf(target);
                _targets.Remove(target);
                Names.RemoveAt(index);
            }

            if (_targets.Count == 0)
                ClearBreakpoint();
        }