From 3771d39fb01d6dceb84c5f4a390b67cbf324e7ca Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Sun, 14 Feb 2021 22:16:42 +0800 Subject: [PATCH] RDR Bypass Netch Directory --- Netch/Controllers/NFController.cs | 2 +- Netch/Utils/StringEx.cs | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Netch/Controllers/NFController.cs b/Netch/Controllers/NFController.cs index fcd78b01..0439b8f3 100644 --- a/Netch/Controllers/NFController.cs +++ b/Netch/Controllers/NFController.cs @@ -270,6 +270,7 @@ namespace Netch.Controllers } aio_dial((int) NameList.TYPE_ADDNAME, @"NTT\.exe"); + aio_dial((int) NameList.TYPE_BYPNAME, "^" + Global.NetchDir.ToRegexString() + @"((?!NTT\.exe).)*$"); } #region NativeMethods @@ -291,7 +292,6 @@ namespace Netch.Controllers [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] private static extern ulong aio_getDL(); - public enum NameList { TYPE_FILTERLOOPBACK, diff --git a/Netch/Utils/StringEx.cs b/Netch/Utils/StringEx.cs index c655c9c0..55c5fca3 100644 --- a/Netch/Utils/StringEx.cs +++ b/Netch/Utils/StringEx.cs @@ -1,10 +1,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; namespace Netch.Utils { - static class StringEx + public static class StringEx { public static bool IsNullOrEmpty(this string value) { @@ -42,5 +43,17 @@ namespace Netch.Utils yield return line; } } + + public static string ToRegexString(this string value) + { + var sb = new StringBuilder(); + foreach (var t in value) + { + if (new[] {'\\', '(', ')', '[', ']', '.'}.Any(s => s == t)) + sb.Append(@"\"); + sb.Append(t); + } + return sb.ToString(); + } } -} +} \ No newline at end of file