public void Start(string path, string workDirectory) { if (_Process != null && !_Process.HasExited) { throw new InvalidOperationException(); } ProcessStartInfo tInfo = new ProcessStartInfo(path); tInfo.Arguments = "/debugger:" + DebuggerPort.ToString(); tInfo.WorkingDirectory = workDirectory; DebugMonitor.Start(); Thread.Sleep(500); try { _Process = Process.Start(tInfo); _Process.EnableRaisingEvents = true; _Process.Exited += Process_Exited; } catch { DebugMonitor.Stop(); throw; } _WorkingSet = new PerformanceCounter("Process", "Working Set", _Process.ProcessName); _PrivateWorkingSet = new PerformanceCounter("Process", "Working Set - Private", _Process.ProcessName); _CpuTime = new PerformanceCounter("Process", "% Processor Time", _Process.ProcessName); }
public FMonitor() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // DebugMonitor.OnOutputDebugString += new OnOutputDebugStringHandler(DebugMonitor_OnOutputDebugString); try { DebugMonitor.Start(); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Failed to start DebugMonitor", MessageBoxButtons.OK); return; } Debug.WriteLine(System.Runtime.InteropServices.Marshal.SizeOf(typeof(int))); if (Debugger.IsAttached) { AppendText(-1, "You are currently debugging TurBoLog so you won't get any 'Debug.WriteLine's from it."); } else { Debug.WriteLine("TurBoLog loaded."); Debug.WriteLine("Press 'F1' to open a window where you can send a 'Debug.WriteLine' message."); Debug.WriteLine("Press 'F2' to clear this window."); } }
public static void Main(string[] args) { InitializeLogging.Perform(); using (var driver = new GameDriver()) { driver.ChangeState(GameState.Initializing); driver.IsMouseVisible = true; driver.Content.RootDirectory = "Content"; driver.BackgroundColor = Color.DarkGray; driver.TimeScale = 1.0f; driver.Graphics = GenerateDeviceManager(driver); driver.TextureBank = new TextureBank().Initialize(driver); driver.SpriteBatch = new SpriteBatch(driver.GraphicsDevice); driver.GameCamera = GenerateGameCamera(driver); driver.GameInterface = GameInterface.Initialize(driver); driver.ShopBackground = ShopBackground.Initialize(driver); driver.Phone = PhoneMachine.Initialize(driver); driver.Money = Money.Initialize(driver); driver.HotSpots = LoadHotSpots.Perform(driver); driver.Toys = LoadToys.Perform(driver); driver.Clock = DeskClock.Initialize(driver); driver.SewingKit = SewingKit.Initialize(driver); driver.PaintingKit = PaintingKit.Initialize(driver); driver.Customer = Customer.Initialize(driver); DebugMonitor.Initialize(driver); driver.ChangeState(GameState.SplashScreen).ChangeState(GameState.WaitingForClient); driver.Run(); } DisposeLogging.Perform(); }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine( "Tool for monitoring .Net processes for exceptions and log.\r\n" + "Usage examples:\r\n" + "Rain.exe MyFavoriteProcess\r\n" + "Rain.exe MyFavoriteProcess,MyOtherFavoriteProcess\r\n" + "Rain.exe MyFavoriteProcess someLogFile.log\r\n" + "\r\n" + "Further options:\r\n" + "-ft:exception|log\r\n" + "Press any key to exit..."); Console.Read(); return; } var processNames = args[0].Split(','); if (args.Length > 1 && !args[1].StartsWith("-")) { _writer = new StreamWriter(args[1]); new Thread(LogWorker).Start(); } var arguments = args .Where(p => p.StartsWith("-")) .Select(p => p.TrimStart('-').Split(':')) .ToDictionary(p => p[0], p => p[1]); foreach (var argument in arguments) { switch (argument.Key) { case "ft": _eventFilter = argument.Value .Split('|') .Select(p => Enum.Parse(typeof(EventType), p, true)) .OfType <EventType>() .Aggregate((a, b) => a | b); break; } } var debugMonitor = new DebugMonitor(); debugMonitor.ExceptionReceived += OnExceptionReceived; debugMonitor.LogReceived += OnLogEntryReceived; var debugProvider = new DebugProvider(); foreach (var wProcessName in processNames) { debugProvider.Monitor(wProcessName); } Thread.Sleep(Timeout.Infinite); }
private static void Ret_ShouldDispose(object sender, EventArgs e) { if (sender != null) { DebugMonitor mon = (DebugMonitor)sender; mon.ShouldDispose -= Ret_ShouldDispose; mon.Dispose(); } }
/// <summary> /// Create a monitor which can debug process on the same machine as this. /// </summary> /// <param name="symbols">The symbol paths to load.</param> /// <returns>A debug monitor task object.</returns> public static Task <IDebugMonitor> CreateUserMode(string[] symbols) { return(Task.Run <IDebugMonitor>(() => { DebugMonitor ret = new DebugMonitor(); ret.SetSymbols(symbols); ret.ShouldDispose += Ret_ShouldDispose; return ret; })); }
static void Main(string[] args) { DebugMonitor.Start(); DebugMonitor.OnOutputDebugString += new OnOutputDebugStringHandler(OnOutputDebugString); Console.WriteLine("Press 'Enter' to exit."); Console.ReadLine(); DebugMonitor.Stop(); }
protected override void Draw(GameTime time) { GraphicsDevice.Clear(BackgroundColor); SpriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null, null, GameCamera.Transformation); SpriteBatch.DrawSprite(ShopBackground.Transform, ShopBackground.Sprite); foreach (var hotspot in HotSpots) { SpriteBatch.DrawHotspot(hotspot); } foreach (var toy in Toys.Where(element => element.Active)) { SpriteBatch.DrawToy(toy); } if (EditingMode) { SpriteBatch.DrawSprite(GameInterface.ToyLocationOnTable, GameInterface.Square); SpriteBatch.DrawSprite(GameInterface.ToyLocationInFront, GameInterface.Square); SpriteBatch.DrawSprite(GameInterface.CustomerLocation, GameInterface.Square); SpriteBatch.DrawSprite(GameInterface.SpeechLocation, GameInterface.Square); SpriteBatch.DrawSprite(GameInterface.PhoneSpeechLocation, GameInterface.Square); SpriteBatch.DrawSprite(GameInterface.MoneyLocation, GameInterface.Square); } SpriteBatch.DrawMoney(Money); SpriteBatch.DrawSprite(GameInterface.TableTransform, GameInterface.TableSprite); SpriteBatch.DrawSprite(GameInterface.SpeechLocation, GameInterface.SpeechSprite); SpriteBatch.DrawSprite(Clock.HourHandTransform, Clock.HourHandSprite); SpriteBatch.DrawSprite(Clock.MinuteHandTransform, Clock.MinuteHandSprite); SpriteBatch.DrawSprite(SewingKit.Transform, SewingKit.Sprite); SpriteBatch.DrawSprite(PaintingKit.Transform, PaintingKit.Sprite); switch (Customer.State) { case Customer.StateType.Happy: GameInterface.SpeechIcon.ImageId = "HappyFace"; SpriteBatch.DrawSprite(GameInterface.SpeechLocation, GameInterface.SpeechIcon); break; } if (Phone.State == PhoneMachine.StateType.Talking) { SpriteBatch.DrawSprite(GameInterface.PhoneSpeechLocation, GameInterface.SpeechSprite); } if (State != GameState.WaitingForClient && State != GameState.ClientLeaving) { SpriteBatch.DrawSprite(Customer.Transform, Customer.Sprite); } SpriteBatch.End(); DebugMonitor.Draw(); base.Draw(time); }
/// <summary> /// Connect to a KM debugger and return a monitor object for the target device. /// </summary> /// <param name="connStr">The remote connection string.</param> /// <param name="symbols">The symbol path to load.</param> /// <returns>A debug monitor object.</returns> public static Task <IDebugMonitor> ConnectKernel(string connStr, string[] symbols) { return(Task.Run <IDebugMonitor>(() => { DebugMonitor ret = new DebugMonitor(); ret.SetSymbols(symbols); ret.ConnectToProcessServer(connStr, true); ret.ShouldDispose += Ret_ShouldDispose; return ret; })); }
protected override void Update(GameTime time) { var elapsed = (float)time.ElapsedGameTime.TotalSeconds; var frameTime = new FrameTime(elapsed, TimeScale); var keyState = Keyboard.GetState(); KeyInput.Update(keyState); MouseInput.Update(); ToggleHotspotBoxes.Perform(this); ToggleQuitGame.Perform(this); ToggleFullscreen.Perform(this); ToggleEditingMode.Perform(this); ReloadGameInterface.Perform(this); RefreshHotspotsState.Perform(this); RefreshToysState.Perform(this); RefreshBackgroundElements.Perform(this); EditingMouseGrab.Perform(this); if (State == GameState.WaitingForClient) { Customer.State = Customer.StateType.Waiting; GenerateNewCustomer.Perform(this, frameTime); } if (State == GameState.FixingToy) { Customer.State = Customer.StateType.Waiting; HandleHotspotInteraction.Perform(this); ResolveCurrentToy.Perform(this); HandlePaymentProcess.Paid = false; HandlePaymentProcess.Delay = 1.5f; } if (State == GameState.ClientPayment) { Customer.State = Customer.StateType.Happy; HandlePaymentProcess.Perform(this, frameTime); } if (State == GameState.ClientLeaving) { Customer.State = Customer.StateType.Waiting; GameInterface.SpeechSprite.Tint = new Color(GameInterface.SpeechSprite.Tint, 0.0f); GenerateNewCustomer.WaitTime = GetRandom.Float(1.0f, 2.0f); ChangeState(GameState.WaitingForClient); } Clock.Update(frameTime); GameCamera.Update(GraphicsDevice.Viewport); DebugMonitor.Update(frameTime); base.Update(time); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); DebugMonitor.Stop(); }
protected override void OnClosing(CancelEventArgs e) { Boolean cancel = false; if (IsValidProcess && hlvrPatcher.IsGamePatched()) { MessageBoxResult result; if (HLVRSettingsManager.Settings.LauncherSettings[HLVRLauncherConfig.CategoryLauncher][HLVRLauncherConfig.AutoUnpatchAndCloseGame].IsTrue()) { result = MessageBoxResult.Yes; } else if (hlvrPatcher.IsGameRunning()) { result = MessageBox.Show("Half-Life: VR is still running and Half-Life is still patched. Do you want to quit Half-Life and unpatch the game before exiting? If you chose no, Half-Life will remain patched after Half-Life: VR quit.", "Half-Life: VR is running!", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); } else { result = MessageBox.Show("Half-Life is still patched. Do you want to unpatch the game before exiting? If you chose no, Half-Life will remain patched.", "Half-Life is still patched!", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); } switch (result) { case MessageBoxResult.Yes: case MessageBoxResult.OK: hlvrPatcher.TerminateGame(); hlvrPatcher.UnpatchGame(); break; case MessageBoxResult.No: break; case MessageBoxResult.Cancel: case MessageBoxResult.None: default: cancel = true; break; } } e.Cancel = cancel; if (!cancel) { singleProcessEnforcer.Dispose(); try { if (DebugMonitor.IsStarted) { DebugMonitor.Stop(); } } catch (Exception) { } } }
// Use this for initialization void Start () { degubber = GameObject.Find("Debug_Monitor").GetComponent<DebugMonitor>(); if (degubber) { degubber.UpdateText("1: Dakota Scene"); degubber.UpdateText("2: Josh Scene"); degubber.UpdateText("3: Logan Scene"); degubber.UpdateText("4: Sam Scene"); degubber.UpdateText("5: Steve Scene"); degubber.UpdateText("6: Menu Scene"); //degubber.UpdateText("7: Dakota Scene"); } }
protected override void OnClosing(CancelEventArgs e) { I18N.SaveI18NFile(); if (IsValidProcess && hlvrModLauncher.IsGameRunning() && HLVRSettingsManager.LauncherSettings.GeneralSettings[LauncherSettings.CategoryLauncher][LauncherSettings.AutoCloseGame].IsTrue()) { hlvrModLauncher.TerminateGame(); } singleProcessEnforcer.Dispose(); try { if (DebugMonitor.IsStarted) { DebugMonitor.Stop(); } } catch (Exception) { } }
void Process_Exited(object sender, EventArgs e) { DebugMonitor.Stop(); if (OnProcessExit != null) { if (SynchronizeInvoke != null) { SynchronizeInvoke.Invoke((Action)(() => { OnProcessExit(_Process.ExitCode); }), null); } else { OnProcessExit(_Process.ExitCode); } } }
protected override void Initialize() { Components.Add(EventsEngine = new EventsEngine(this)); Components.Add(InputMonitor = new InputMonitor(this)); Components.Add(DebugMonitor = new DebugMonitor(this, 60) { Visible = Program.Debug }); InputMonitor.KeyReleased += keys => { if (keys == Keys.F1) { DebugMonitor.Visible = !DebugMonitor.Visible; } //else if (keys == Keys.F11) Graphics.ToggleFullScreen(); }; ContentEngine.GlobalContent.LoadContent(); base.Initialize(); }
private void HookIntoHLProcess() { lock (gameLock) { hlProcess.EnableRaisingEvents = true; hlProcess.Exited += new EventHandler(GameTerminated); try { if (!DebugMonitor.IsStarted) { DebugMonitor.Start(); DebugMonitor.OnOutputDebugString += (int pid, string text) => { if (hlProcess != null && pid == hlProcess.Id) { Brush color; if (text.ToLower().Contains("error")) { color = Brushes.Red; } else if (text.ToLower().Contains("warning")) { color = Brushes.OrangeRed; } else { color = Brushes.Black; } System.Windows.Application.Current?.Dispatcher?.BeginInvoke((Action)(() => (System.Windows.Application.Current?.MainWindow as MainWindow)?.ConsoleLog(text, color))); } }; } } catch (Exception e) { string error = "ERROR Couldn't connect to Half-Life console: " + e.Message + "\n\n" + e.StackTrace; System.Windows.Application.Current?.Dispatcher?.BeginInvoke((Action)(() => (System.Windows.Application.Current?.MainWindow as MainWindow)?.ConsoleLog(error, Brushes.Red))); } } }
static int Main(string[] args) { Console.OutputEncoding = System.Text.Encoding.UTF8; //RefreshListeners(); try { DebugMonitor.OnOutputDebugString += DebugMonitor_OnOutputDebugString; DebugMonitor.Start(); return(0); } catch (AlreadyRunningException) { return(3); } catch (Exception e) { Console.WriteLine("===== Error: " + e.Message + " ====="); return(4); } }
private void mnuDebugCapture_Click(object sender, System.EventArgs e) { if (mnuDebugCapture.Checked) { try { DebugMonitor.Stop(); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Failed to stop DebugMonitor", MessageBoxButtons.OK); return; } } else { try { DebugMonitor.Start(); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Failed to start DebugMonitor", MessageBoxButtons.OK); return; } } mnuDebugCapture.Checked = !mnuDebugCapture.Checked; }
private void HookIntoHLProcess() { lock (gameLock) { hlProcess.EnableRaisingEvents = true; hlProcess.Exited += new EventHandler(GameTerminated); try { if (!DebugMonitor.IsStarted) { DebugMonitor.Start(); DebugMonitor.OnOutputDebugString += (int pid, string text) => { if (hlProcess != null && pid == hlProcess.Id) { Brush color; if (text.ToLower().Contains("error")) { color = Brushes.Red; } else if (text.ToLower().Contains("warning")) { color = Brushes.OrangeRed; } else { color = Brushes.Black; } System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => ((MainWindow)System.Windows.Application.Current.MainWindow)?.ConsoleLog(text, color))); } }; } } catch (Exception) { } } }
private void Button_Click(object sender, RoutedEventArgs e) { var tag = (sender as Button).Tag.ToString(); DebugMonitor.Text = ""; var raw_script = textEditor.Text.Split( new[] { '\n' }, StringSplitOptions.None ).ToList(); if (tag == "Open") { var ofd = new OpenFileDialog(); ofd.InitialDirectory = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "script"); ofd.Filter = "SRCAL 스크립트 파일 (*.srcal)|*.srcal"; if (ofd.ShowDialog() == true) { textEditor.Text = File.ReadAllText(ofd.FileName); } } else if (tag == "Save") { string default_filename = ""; try { var parser = new SRCALParser(); script = parser.Parse(raw_script); default_filename = parser.attributes["$ScriptName"]; } catch { } var sfd = new SaveFileDialog(); sfd.InitialDirectory = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "script"); sfd.FileName = default_filename; sfd.Filter = "SRCAL 스크립트 파일 (*.srcal)|*.srcal"; if (sfd.ShowDialog() == true) { File.WriteAllText(sfd.FileName, string.Join("\r\n", raw_script)); } } else if (tag == "Parse") { bool err = false; var parser = new SRCALParser(); try { script = parser.Parse(raw_script); var attribute = new SRCALAttribute(); attribute.ScriptName = parser.attributes["$ScriptName"]; attribute.ScriptVersion = parser.attributes["$ScriptVersion"]; attribute.ScriptAuthor = parser.attributes["$ScriptAuthor"]; attribute.ScriptFolderName = parser.attributes["$ScriptFolderName"]; attribute.ScriptRequestName = parser.attributes["$ScriptRequestName"]; attribute.URLSpecifier = parser.attributes["$URLSpecifier"]; int v; if (int.TryParse(parser.attributes["$UsingDriver"], out v)) { attribute.UsingDriver = v == 0 ? false : true; } else { err = true; DebugMonitor.Text = "Using driver must be integer type.\r\n"; } DebugMonitor.Text = Monitor.SerializeObject(attribute) + "\r\n"; } catch (Exception ex) { DebugMonitor.Text += $"Script parsing error. {ex.Message}\r\n{ex.StackTrace}\r\n"; err = true; } if (parser.errors.Count > 0) { DebugMonitor.Text += $"Occurred some errors when parsing script ...\r\n"; for (int i = 0; i < parser.errors.Count; i++) { DebugMonitor.Text += $"[{parser.errors[i].Item1.Line + 1}, {parser.errors[i].Item1.Column + 1}] {parser.errors[i].Item2}\r\n"; } err = true; } if (!err) { DebugMonitor.Text += "Complete parsing."; } else { DebugMonitor.Text += "Error occured when parse script."; } DebugMonitor.ScrollToEnd(); } else if (tag == "Inject") { try { if (!ScriptManager.Instance.Subscribe(string.Join("\r\n", raw_script))) { MessageBox.Show("인젝션에 성공했습니다!\r\n메인창에서 스크립트를 실행하고, 콘솔에서 상태를 점검하세요.\r\n인젝션을 재시도하기 전에 반드시 이젝트해야합니다.", Title, MessageBoxButton.OK, MessageBoxImage.Information); return; } } catch (Exception ex) { Monitor.Instance.Push($"[Script Editor] Fail to inject. {ex.Message}\r\n{ex.StackTrace}"); } MessageBox.Show("인젝션에 실패했습니다. 자세한 내용은 콘솔을 참고해주세요.", Title, MessageBoxButton.OK, MessageBoxImage.Error); } else if (tag == "Eject") { var parser = new SRCALParser(); try { script = parser.Parse(raw_script); if (ScriptManager.Instance.Unsubscribe(parser.attributes["$ScriptName"]) >= 1) { MessageBox.Show("이젝션 완료!", Title, MessageBoxButton.OK, MessageBoxImage.Information); return; } else { MessageBox.Show("이젝션할 내용이 없습니다.", Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); } } catch (Exception ex) { Monitor.Instance.Push($"[Script Editor] Fail to eject. {ex.Message}\r\n{ex.StackTrace}"); MessageBox.Show("이젝션을 실패했습니다. 자세한 내용은 콘솔을 참고해주세요.", Title, MessageBoxButton.OK, MessageBoxImage.Error); } } else if (tag == "CC") { (new CustomCrawler()).Show(); } else if (tag == "Help") { Process.Start("https://github.com/dc-koromo/koromo-copy/blob/master/Document/SRCAL.md"); } }