public Argument(PythonBoss pyBoss, long address, PythonDictionary spec, Process process, int depth, Arguments parent, string namePrefix) { Address = address; this.process = process; _pyBoss = pyBoss; _parent = parent; NamePrefix = namePrefix; // Parse the spec for this argument // stackspec: [{"name": "socket", // "size": 4, // "type": None, // "fuzz": NOFUZZ, // "type_args": None},] Fuzz = (bool)spec.get("fuzz"); Name = (string)spec.get("name"); _argumentType = (object)spec.get("type"); if ( spec.ContainsKey("type_args") ) { _typeArgs = spec.get("type_args"); } // Validate required fields if (Name == null) throw new Exception("ERROR: Argument specification must include 'name' attribute. Failed when parsing name prefix '" + namePrefix + "'."); else if (Fuzz == null) throw new Exception("ERROR: Argument specification must include 'fuzz' attribute. Failed when parsing type '" + namePrefix + Name + "'."); else if (spec.get("size") == null) throw new Exception("ERROR: Argument specification must include 'size' attribute. Failed when parsing type '" + namePrefix + Name + "'."); if (spec.get("size") is string) { object sizeArgument = null; if (parent.TryGetMemberSearchUp((string)spec.get("size"), out sizeArgument)) Size = ((Argument)sizeArgument).ToInt(); else throw new Exception("ERROR: Unable to load size for type '" + Name + "' from parent member named '" + (string)spec.get("size") + "'. Please make sure this field exists in the parent."); } else if (spec.get("size") is int) { Size = (int)spec.get("size"); } else { throw new Exception("ERROR: Unable to load size for type '" + Name + "'. The size must be of type 'int' or type 'string'. Size is type: '" + spec.get("size").ToString() + "'" ); } // Read the data try { Data = MemoryFunctions.ReadMemory(process.ProcessDotNet, address, (uint)Size); } catch (Exception e) { Data = null; } PointerTarget = null; }
public Target(object targetClass, PythonBoss pyBoss, Process process) { _targetClass = targetClass; _process = process; _pyBoss = pyBoss; _breakpoints = new List<Breakpoint>(1); _name = Target.GetName(targetClass); }
public VarTypes(XDocument reader, PythonBoss pyBoss) { _pyBoss = pyBoss; // Load all the <type>'s but in reverse-order because of // dependencies on one-another. IEnumerable<XElement> elements = reader.Descendants("types").Elements("type"); _types = new List<VarType>(10); for (int i = elements.Count() - 1; i >= 0; i--) { // Load this <type> description _types.Add(new VarType(pyBoss, this, elements.ElementAt(i))); } }
public Controller(string startScript, string[] args) { _scriptPath = System.IO.Path.GetFullPath(startScript); // Now that we slightly verified the xml structure, lets initialize _pyBoss = new PythonBoss(_scriptPath); string filename = System.IO.Path.GetFileName(startScript); if( filename.EndsWith(".py") ) filename = filename.Substring(0,filename.Length - 3); if (!_pyBoss.AddCode(String.Format(@"from {0} import *", filename) , startScript)) return; try { // Create the controller var pyTypeController = _pyBoss.PyScope.GetVariable("Controller"); PyController = _pyBoss.PyEngine.Operations.CreateInstance(pyTypeController, this); // Create the new process dispatcher check ProcessWatcher procWatcher = new ProcessWatcher(); procWatcher.ProcessCreated += new ProcessEventHandler(procWatcher_ProcessCreated); procWatcher.Start(); // Execute the controller main function try { PyController.main(args); } catch (Exception e) { Console.WriteLine("ERROR: Python class controller.main() not found or failed while executing."); Console.WriteLine(e.ToString()); return; } } catch (Exception e) { Console.WriteLine("ERROR: Python class controller(...) not found or failed while executing constructor."); Console.WriteLine(e.ToString()); return; } // Success, this controller is now loaded Initialized = true; }
public Process(PythonBoss pyBoss, Controller parent, dynamic pyProcess) { _targets = new Hashtable(10); _pyBoss = pyBoss; _parent = parent; _targetsToLoad = new List<object>(10); PyProcess = pyProcess; _name = PyProcess.get_name(); try { // Initialize the DotNet process class int pid = PyProcess.get_pid(); if (pid >= 0) { ProcessDotNet = System.Diagnostics.Process.GetProcessById(pid); // Start the debugger instance _debugger = new Debugger(pid, this); } else { Console.WriteLine(string.Format("ERROR: Constructor of dot net class 'Process' {0} failed. Python process class returned 'get_pid()' of -1, this is invalid.", _name)); return; } } catch (Exception e) { Console.WriteLine(string.Format("ERROR: Constructor of python class 'Process' {0} failed:", _name)); Console.WriteLine(e.ToString()); return; } Initialized = true; }
public Arguments(PythonBoss pyBoss, long address, List specs, Process process, int depth, Argument parent, string namePrefix) { NamePrefix = namePrefix; _process = process; _address = address; _pyBoss = pyBoss; _depth = depth; _parent = parent; _args = new List<Argument>(specs.Count); _arg_offsets = new List<long>(specs.Count); // Handle the case of infinite recursion if (depth > 1000) throw new Exception("Error when processing argument types: An infinite loop has been detected, this is caused by a type somehow including a pointer to itself. Name: " + namePrefix); ParseCurrentLevel(specs); ParseNextLevel(); }