public void Run(IContext context, string channelName, int redirectionPort) { _interface.NotifyInstalled(Process.GetCurrentProcess().ProcessName); try { _connectHook = LocalHook.Create( LocalHook.GetProcAddress("Ws2_32.dll", "connect"), new WinsockConnectDelegate(_onConnect), this); _connectHook.ThreadACL.SetExclusiveACL(new[] { 0 }); } catch (Exception ex) { _interface.Error(ex); } WakeUpProcess(); try { while (true) { Thread.Sleep(500); _interface.Ping(); } } catch { _connectHook.Dispose(); LocalHook.Release(); } }
public void Run(IContext context, string channelName, int redirectionPort) { var process = Process.GetCurrentProcess(); _interface.DetourInstalled(process.ProcessName, process.Id); try { _connectHook = LocalHook.Create( LocalHook.GetProcAddress("Ws2_32.dll", "connect"), new WinsockConnectDelegate(_onConnect), this); _connectHook.ThreadACL.SetExclusiveACL(new[] { 0 }); } catch (Exception e) { _interface.Error(e); } WakeUpProcess(); while (true) { Thread.Sleep(1000); } }