private void button1_Click(object sender, EventArgs e) { string c = textBox1.Text; MDbgShell shell = ThreadWorker.shell; shell.Write(c); }
public static int LoadMdb(string[] args) { if (args.Length > 0) { switch (args[0]) { case "/?": case "-?": Console.WriteLine("usageString"); return(0); } } shell = new MDbgShell(); return(shell.Start(args)); }
public void startMDbg(O2Thread.FuncVoid onShellStart) { if (shell == null) { O2Thread.mtaThread(() => { setMDbgEventsMessagesCallbacks(); shell = new MDbgShell(); shell.Start(new string[0]); setO2MDbgShellCallbacks(); o2MdbgIsReady.Set(); if (onShellStart != null) { onShellStart(); } }); } }
public static int Main(string[] args) { //new Test().Do(); Test.Tests(); if (args.Length > 0) { switch (args[0]) { case "/?": case "-?": Console.WriteLine(usageString); return(0); } } MDbgShell shell = new MDbgShell(); return(shell.Start(args)); }
public static int Main(string[] args) { if (args.Length == 0 || !Regex.IsMatch(args[0].Trim('"'), @"\.py$")) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(@"Please specify a python script file."); Console.ResetColor(); Console.ReadKey(); return(1); } else if (!File.Exists(args[0].Trim('"'))) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(@"The python script file does not exist."); Console.ResetColor(); Console.ReadKey(); return(2); } MDbgShell shell = new MDbgShell(); shell.Start(new string[] { }); var engine = Python.CreateEngine(); var scope = engine.CreateScope(); engine.Execute("import clr", scope); engine.Execute($@"clr.AddReferenceToFileAndPath('{AppDomain.CurrentDomain.BaseDirectory.Replace(@"\", @"\\")}mdbgTypes.dll')", scope); engine.Execute($@"clr.AddReferenceToFileAndPath('{AppDomain.CurrentDomain.BaseDirectory.Replace(@"\", @"\\")}mdbgeng.dll')", scope); engine.Execute($@"clr.AddReferenceToFileAndPath('{AppDomain.CurrentDomain.BaseDirectory.Replace(@"\", @"\\")}mdbgext.dll')", scope); engine.Execute($@"clr.AddReferenceToFileAndPath('{AppDomain.CurrentDomain.BaseDirectory.Replace(@"\", @"\\")}PhiDebugging.dll')", scope); engine.Execute($@"clr.AddReferenceToFileAndPath('{AppDomain.CurrentDomain.BaseDirectory.Replace(@"\", @"\\")}InvariantDetector.dll')", scope); engine.Execute(@"clr.AddReference(""System.Core"")", scope); engine.Execute(@"import System", scope); engine.Execute(@"from System.Collections.Generic import Dictionary,List", scope); engine.Execute(@"from PhiDebugging import *", scope); engine.Execute(@"from InvariantDetector import *", scope); engine.Execute(@"from Microsoft.Samples.Debugging.MdbgEngine import *", scope); engine.Execute(@"from Microsoft.Samples.Tools.Mdbg import *", scope); /* * import clr * clr.AddReference("System.Core") * import System * clr.ImportExtensions(System.Linq) * from System.Collections.Generic import Dictionary,List * */ try { engine.ExecuteFile(args[0].Trim('"'), scope); } catch (SyntaxErrorException syntaxError) { Console.BackgroundColor = ConsoleColor.DarkRed; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine($@"Syntax error in line: {syntaxError.Line}, column: {syntaxError.Column}"); Console.WriteLine(syntaxError.Message); Console.ResetColor(); } catch (Exception ex) { Console.BackgroundColor = ConsoleColor.DarkRed; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine($"The script generated an '{ex.GetType().Name}' exception:"); Console.WriteLine(ex.Message); Console.ResetColor(); } Console.WriteLine("<------->"); Console.ReadKey(); return(0); }