// MaverickPipeWatch.exe — descobre QUEM cria o pipe, sem GUI e sem risco de travar. // Metodo: monitora o aparecimento do pipe e cruza com processos iniciados na janela. // csc /nologo /optimize+ /out:MaverickPipeWatch.exe MaverickPipeWatch.cs // MaverickPipeWatch.exe --pipe gfn-ccjsonrpc --minutes 10 // MaverickPipeWatch.exe --pipe gfn-ccpipe --minutes 10 using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; using System.Threading; internal static class MaverickPipeWatch { static readonly StringBuilder LogBuf = new StringBuilder(); static string LogPath = "MaverickPipeWatch.log"; static void Log(string m) { string line = DateTime.Now.ToString("HH:mm:ss.fff") + " " + m; LogBuf.AppendLine(line); Console.WriteLine(line); try { File.WriteAllText(LogPath, LogBuf.ToString()); } catch { } } static bool Exists(string pipe) { try { foreach (string p in Directory.GetFiles(@"\\.\pipe\")) if (string.Equals(p.Substring(9), pipe, StringComparison.OrdinalIgnoreCase)) return true; } catch { } return false; } static Dictionary Snapshot() { var map = new Dictionary(); foreach (Process p in Process.GetProcesses()) { try { map[p.Id] = p.ProcessName; } catch { } finally { p.Dispose(); } } return map; } static void ReportNew(Dictionary before, DateTime when) { foreach (Process p in Process.GetProcesses()) { try { if (before.ContainsKey(p.Id)) continue; string path = ""; DateTime start = DateTime.MinValue; try { path = p.MainModule.FileName; } catch { } try { start = p.StartTime; } catch { } double ageMs = start == DateTime.MinValue ? -1 : (when - start).TotalMilliseconds; Log(string.Format(" NOVO PID {0,-7} {1,-24} idade={2:F0}ms {3}", p.Id, p.ProcessName, ageMs, path)); } catch { } finally { p.Dispose(); } } } static void Main(string[] args) { string pipe = "gfn-ccjsonrpc"; int minutes = 10; int pollMs = 150; for (int i = 0; i < args.Length; i++) { if (args[i] == "--pipe" && i + 1 < args.Length) pipe = args[++i]; else if (args[i] == "--minutes" && i + 1 < args.Length) int.TryParse(args[++i], out minutes); else if (args[i] == "--poll" && i + 1 < args.Length) int.TryParse(args[++i], out pollMs); } string dir = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); LogPath = Path.Combine(dir ?? ".", "MaverickPipeWatch.log"); Log("=== MaverickPipeWatch pipe=" + pipe + " minutes=" + minutes); Log("user=" + Environment.UserName + " session=" + Process.GetCurrentProcess().SessionId); var end = DateTime.UtcNow.AddMinutes(minutes); bool last = Exists(pipe); Log("estado inicial: " + (last ? "PRESENTE" : "ausente")); int appear = 0, disappear = 0; var before = Snapshot(); while (DateTime.UtcNow < end) { Thread.Sleep(pollMs); bool now = Exists(pipe); if (now == last) { if (appear == 0) before = Snapshot(); continue; } if (now) { appear++; Log(""); Log("*** PIPE APARECEU #" + appear + " ***"); ReportNew(before, DateTime.Now); } else { disappear++; Log("*** pipe sumiu #" + disappear + " ***"); } last = now; before = Snapshot(); } Log(""); Log("=== fim. apareceu " + appear + "x, sumiu " + disappear + "x em " + minutes + " min"); if (appear == 0) Log("o pipe nao apareceu nessa janela. deixe rodando e provoque a sessao (abrir jogo, reconectar stream)."); } }