// MaverickPipeScan.exe — lista os pipes reais e insiste na conexao. // O pipe gfn-ccjsonrpc pode ter instancia unica: conectar exige retry. // csc /nologo /optimize+ /out:MaverickPipeScan.exe MaverickPipeScan.cs // MaverickPipeScan.exe -> lista + tenta 20x // MaverickPipeScan.exe --tries 100 // MaverickPipeScan.exe --probe OK -> conecta e manda uma sonda JSON-RPC using System; using System.Collections.Generic; using System.IO; using System.IO.Pipes; using System.Text; using System.Threading; internal static class MaverickPipeScan { static List ListPipes() { var result = new List(); try { foreach (string p in Directory.GetFiles(@"\\.\pipe\")) result.Add(p.Substring(9)); } catch (Exception ex) { Console.WriteLine("listar pipes falhou: " + ex.Message); } return result; } static bool TryConnect(NamedPipeClientStream client, int timeoutMs, int tries, int delayMs) { for (int i = 1; i <= tries; i++) { try { client.Connect(timeoutMs); return true; } catch (TimeoutException) { Thread.Sleep(delayMs); } catch (IOException) { Thread.Sleep(delayMs); } catch (UnauthorizedAccessException) { return false; } } return false; } static int Main(string[] args) { int tries = 20, delay = 250; string probe = null; for (int i = 0; i < args.Length; i++) { if (args[i] == "--tries" && i + 1 < args.Length) int.TryParse(args[++i], out tries); else if (args[i] == "--probe" && i + 1 < args.Length) probe = args[++i]; } Console.WriteLine("=== MaverickPipeScan ==="); Console.WriteLine("user=" + Environment.UserName + " session=" + System.Diagnostics.Process.GetCurrentProcess().SessionId); Console.WriteLine("\n--- pipes visiveis (filtro gfn/Nv/NVIDIA) ---"); foreach (string name in ListPipes()) { string lower = name.ToLowerInvariant(); if (lower.Contains("gfn") || lower.Contains("nv") || lower.Contains("nvidia")) Console.WriteLine(" " + name); } string[] targets = { "gfn-ccjsonrpc", "gfn-ccpipe" }; foreach (string target in targets) { Console.WriteLine("\n--- " + target + " (" + tries + " tentativas) ---"); using (var client = new NamedPipeClientStream(".", target, PipeDirection.InOut, PipeOptions.None)) { bool ok = false; int attempt = 0; for (; attempt < tries; attempt++) { try { client.Connect(500); ok = true; break; } catch (TimeoutException) { Thread.Sleep(delay); } catch (IOException) { Thread.Sleep(delay); } catch (UnauthorizedAccessException) { Console.WriteLine(" NEGADO (ACL) na tentativa " + (attempt + 1)); break; } catch (Exception ex) { Console.WriteLine(" " + ex.GetType().Name + " na tentativa " + (attempt + 1)); Thread.Sleep(delay); } } Console.WriteLine(ok ? " conectou na tentativa " + (attempt + 1) : " nao conectou em " + tries + " tentativas"); if (ok && probe != null) { string payload = "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"" + probe + "\",\"params\":{}}"; byte[] data = Encoding.UTF8.GetBytes(payload); client.Write(data, 0, data.Length); client.Flush(); Console.WriteLine(" --> " + payload); var buf = new byte[8192]; var end = DateTime.UtcNow.AddSeconds(3); bool any = false; while (DateTime.UtcNow < end) { try { var task = client.ReadAsync(buf, 0, buf.Length); if (!task.Wait(300)) continue; int n = task.Result; if (n <= 0) break; any = true; Console.WriteLine(" <-- " + Encoding.UTF8.GetString(buf, 0, Math.Min(n, 400))); } catch { break; } } if (!any) Console.WriteLine(" <-- sem resposta em 3s"); } } } return 0; } }