Form1.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. namespace BfAeDebug
  14. {
  15. public partial class Form1 : Form
  16. {
  17. public Form1(String[] args)
  18. {
  19. InitializeComponent();
  20. try
  21. {
  22. Process process = Process.GetProcessById(int.Parse(Program.sProcessId));
  23. mLabel.Text = String.Format("Process {0} ({1})", Program.sProcessId, process.ProcessName);
  24. process.Dispose();
  25. //var mainWindowHandle = process.MainWindowHandle;
  26. //NativeWindow.FromHandle(mainWindowHandle).
  27. }
  28. catch (Exception)
  29. {
  30. }
  31. mLabel.Text += " crash args:";
  32. foreach (var arg in args)
  33. {
  34. mLabel.Text += " " + arg;
  35. }
  36. CenterToScreen();
  37. }
  38. private void button1_Click(object sender, EventArgs e)
  39. {
  40. Directory.SetCurrentDirectory(@"C:\Beef\IDE\dist");
  41. var process = Process.Start(@"C:\Beef\IDE\dist\BeefIDE_d.exe", String.Format("-attachId={0} -attachHandle={1}", Program.sProcessId, Program.sEventId));
  42. Hide();
  43. process.WaitForExit();
  44. Close();
  45. }
  46. private void mVsButton_Click(object sender, EventArgs e)
  47. {
  48. // ProcessStartInfo psi = new ProcessStartInfo();
  49. // psi.FileName = @"c:\\windows\\system32\\vsjitdebugger.exe";
  50. // psi.CreateNoWindow = false;
  51. // psi.WorkingDirectory = "C:\\";
  52. // psi.WindowStyle = ProcessWindowStyle.Normal;
  53. // psi.Arguments = String.Format("-p {0} -e {1}", Program.sProcessId, Program.sEventId);
  54. // psi.UseShellExecute = false;
  55. // psi.ErrorDialog = true;
  56. // psi.RedirectStandardError = true;
  57. // psi.RedirectStandardInput = true;
  58. // psi.RedirectStandardOutput = true;
  59. // var process = Process.Start(psi);
  60. //MessageBox.Show(@"C:\Windows\system32\vsjitdebugger.exe" + " " + String.Format("-p {0} -e {1}", Program.sProcessId, Program.sEventId));
  61. try
  62. {
  63. var process = Process.Start(@"C:\Windows\system32\vsjitdebugger.exe\", String.Format("-p {0} -e {1}", Program.sProcessId, Program.sEventId));
  64. Hide();
  65. process.WaitForExit();
  66. int exitCode = process.ExitCode;
  67. if (exitCode != 0)
  68. MessageBox.Show("vsjitdebugger exit code: " + exitCode);
  69. }
  70. catch (Exception ex)
  71. {
  72. MessageBox.Show("vsjitdebugger exception: " + ex.ToString());
  73. }
  74. //MessageBox.Show("Done");
  75. Close();
  76. }
  77. private void mCancelButton_Click(object sender, EventArgs e)
  78. {
  79. Close();
  80. }
  81. private void label1_Click(object sender, EventArgs e)
  82. {
  83. }
  84. }
  85. }