Example #1
0
        public void Run(RemoteHooking.IContext ctx, DalamudStartInfo info)
        {
            // Setup logger
            Log.Logger = NewLogger(info.WorkingDirectory);

            try {
                Log.Information("Initializing a session..");

                // This is due to GitHub not supporting TLS 1.0, so we enable all TLS versions globally
                System.Net.ServicePointManager.SecurityProtocol =
                    SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;

                // Log any unhandled exception.
                AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

                using (var dalamud = new Dalamud(info)) {
                    Log.Information("Starting a session..");

                    // Run session
                    dalamud.Start();
                    dalamud.WaitForUnload();
                }
            } catch (Exception ex) {
                Log.Fatal(ex, "Unhandled exception on main thread.");
            } finally {
                AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;

                Log.Information("Session has ended.");
                Log.CloseAndFlush();
            }
        }
Example #2
0
 public GHRXInputModPayload(
     RemoteHooking.IContext aInContext,
     String aInChannelName)
 {
     _interface = RemoteHooking.IpcConnectClient <GHRXInputModInterface.GHRXInputModInterface>(aInChannelName);
     _instance  = this;
 }
Example #3
0
        public Main(RemoteHooking.IContext InContext, string serverName)
        {
            mySendClientQueue     = new Queue <Packet>();
            mySendClientLock      = new object();
            mySendServerQueue     = new Queue <Packet>();
            mySendServerLock      = new object();
            myRecvFilter          = new PacketFilter();
            mySendFilter          = new PacketFilter();
            myRecvDelegate        = new dSendRecv(ReceiveHook);
            mySendDelegate        = new dSendRecv(SendHook);
            myPID                 = RemoteHooking.GetCurrentProcessId();
            myThreadID            = RemoteHooking.GetCurrentThreadId();
            myDateStamp           = GetDateStamp();
            myServerSendBuffer    = Marshal.AllocHGlobal(65536);
            myClientSendBuffer    = Marshal.AllocHGlobal(65536);
            myServerBufferAddress = BitConverter.GetBytes(myServerSendBuffer.ToInt32());
            myClientBufferAddress = BitConverter.GetBytes(myClientSendBuffer.ToInt32());

            myClientInstance = new ClientInstance(serverName, true);
            myClientInstance.SendCommand(Command.ClientID, myPID);
            myClientInstance.SendPacketEvent       += new dSendPacket(myClientInstance_sendPacketEvent);
            myClientInstance.PingEvent             += new dPing(myClientInstance_pingEvent);
            myClientInstance.AddRecvFilterEvent    += new dAddRecvFilter(myClientInstance_addRecvFilterEvent);
            myClientInstance.AddSendFilterEvent    += new dAddSendFilter(myClientInstance_addSendFilterEvent);
            myClientInstance.RemoveRecvFilterEvent += new dRemoveRecvFilter(myClientInstance_removeRecvFilterEvent);
            myClientInstance.RemoveSendFilterEvent += new dRemoveSendFilter(myClientInstance_removeSendFilterEvent);
            myClientInstance.ClearRecvFilterEvent  += new dClearRecvFilter(myClientInstance_clearRecvFilterEvent);
            myClientInstance.ClearSendFilterEvent  += new dClearSendFilter(myClientInstance_clearSendFilterEvent);

            myClientInstance.SendCommand(Command.Message, "ClientHook Main()");
        }
Example #4
0
        public void Run(RemoteHooking.IContext context, GlobalConfig config)
        {
            LocalHook endScenePatch = null;

            try
            {
                endScenePatch = LocalHook.Create(
                    IntPtr.Zero + Offset.Function.EndScene,
                    new CommandCallback.EndScene(commandHandler.EndScenePatch),
                    this);

                endScenePatch.ThreadACL.SetExclusiveACL(new Int32[] { });
            }
            catch (Exception e)
            {
                ctrlInterface.hostControl.PrintMessage(e.ToString());
            }

            /* keep the remote from unloading */
            while (remoteMainOn)
            {
                Thread.Sleep(5000);
            }

            commandHandler?.Dispose();
            endScenePatch?.Dispose();
            wardenBuster?.Dispose();
        }
Example #5
0
        // ReSharper disable once UnusedParameter.Local
        /// <summary>
        ///     Initializing the Guest class
        /// </summary>
        /// <param name="inContext">Should contain information about the environment</param>
        /// <param name="adapterId"><see cref="string" /> identification of the desired network adapter</param>
        /// <param name="injectionGuessAddress">Address of the injection assembly to be used for child processes</param>
        /// <param name="injectionDelay">Number of milliseconds after child process creation to try to inject the code</param>
        /// <param name="isInDebug">Indicates if injected code should create a log file and print activity information</param>
        // ReSharper disable once TooManyDependencies
        public Guest(
            RemoteHooking.IContext inContext,
            string adapterId,
            string injectionGuessAddress,
            int injectionDelay,
            bool isInDebug)
        {
            DebugMessage(
                nameof(Guest),
                "Initializing ..."
                );
            InjectionGuessAddress = injectionGuessAddress;
            InjectionDelay        = injectionDelay;
            AdapterId             = adapterId;

            if (isInDebug)
            {
                try
                {
                    var process = Process.GetCurrentProcess();
                    LogPath = Path.Combine(Path.GetTempPath(),
                                           "NetworkAdapterSelector-" + process.ProcessName + "[" + process.Id + "].log");
                }
                catch
                {
                    // ignored
                }
            }
        }
Example #6
0
 public void Run(RemoteHooking.IContext InContext)
 {
     //while (true)
     {
         System.Threading.Thread.Sleep(30000);
     }
 }
Example #7
0
        public void Run(RemoteHooking.IContext context, string channelName)
        {
            server.IsClientInstalled(RemoteHooking.GetCurrentProcessId());

            var shellExecuteHook = LocalHook.Create(
                LocalHook.GetProcAddress("shell32.dll", "ShellExecuteExW"),
                new ShellExecuteExDelegate(ShellExecuteExHook),
                this);

            shellExecuteHook.ThreadACL.SetExclusiveACL(new int[] { 0 });

            RemoteHooking.WakeUpProcess();

            server.ReportMessage("Injected to osu! process");

            try
            {
                // Loop until closes (i.e. IPC fails)
                while (true)
                {
                    System.Threading.Thread.Sleep(500);

                    server.Ping();
                }
            }
            catch
            {
                // Ping() or ReportMessages() will raise an exception if host is unreachable
            }

            shellExecuteHook.Dispose();

            LocalHook.Release();
        }
Example #8
0
 public AoHookEntryPoint(RemoteHooking.IContext context, string channelName)
 {
     Console.WriteLine("some stuuffff");
     _server = EasyHook.RemoteHooking.IpcConnectClient <AoEntryPointInterface>(channelName);
     _server.ping();
     Console.WriteLine("some stuuffff´\r\n");
 }
Example #9
0
 public CreateWindowExRemoteHooker(
     RemoteHooking.IContext inContext,
     string inChannelName) : base(inContext, inChannelName)
 {
     _createWindowExHookerImplementation =
         new CreateWindowWxHookerImplementation <CreateWindowExRemoteHooker>(this);
 }
Example #10
0
        public void Run(RemoteHooking.IContext context, string channelName)
        {
            var createProcessHook = LocalHook.Create(LocalHook.GetProcAddress("kernel32.dll", "CreateProcessW"), new NativeDelegates.CreateProcessDelegate(OnCreateProcessHook), this);

            createProcessHook.ThreadACL.SetExclusiveACL(new[] { 0 });

            RemoteHooking.WakeUpProcess();

            try
            {
                while (true)
                {
                    // Periodically send status to the server
                    Server.RaisePingRequested(channelName);
                    Thread.Sleep(1000);
                }
            }
            catch
            {
                // ignored
            }

            createProcessHook.Dispose();
            LocalHook.Release();
        }
Example #11
0
        public void Run(
            RemoteHooking.IContext InContext,
            String InChannelName)
        {
            // install hook...
            Hook = LocalHook.Create(
                LocalHook.GetProcAddress("user32.dll", "SetWindowTextW"),
                new DSetWindowText(SetWindowText_Hooked),
                this);

            Hook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
            Interface.IsInstalled(RemoteHooking.GetCurrentProcessId());

            try
            {
                while (true)
                {
                    Thread.Sleep(500);
                }
            }
            catch (Exception e)
            {
                Interface.ReportException(e);
            }

            Hook.Dispose();
            LocalHook.Release();
        }
Example #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HookServer" /> class.
        /// </summary>
        /// <param name="context">Easyhook remoting context.</param>
        /// <param name="channelName">IPC channel name.</param>
        /// <param name="projectDirectory">The project directory to use when loading content.</param>
        public HookServer(RemoteHooking.IContext context, String channelName)
        {
            // Get reference to IPC to host application
            this.HookClient = RemoteHooking.IpcConnectClient <HookClientBase>(channelName);

            // Call the client immediately to test a successful connection
            this.HookClient.Log("Hook successfully connected");

            // Attempt to create a IpcServerChannel so that any event handlers on the client will function correctly
            try
            {
                System.Collections.IDictionary properties = new System.Collections.Hashtable();
                properties["name"]     = channelName;
                properties["portName"] = channelName + Guid.NewGuid().ToString("N");

                //// BinaryServerFormatterSinkProvider binaryProv = new BinaryServerFormatterSinkProvider();
                ////  binaryProv.TypeFilterLevel = TypeFilterLevel.Full;

                ////  IpcServerChannel clientServerChannel = new IpcServerChannel(properties, binaryProv);
                ////  ChannelServices.RegisterChannel(clientServerChannel, false);
            }
            catch (Exception ex)
            {
                this.HookClient.Log("Failed to set up bidirectional hook", ex.ToString());
            }
        }
Example #13
0
        /// <summary>
        /// Entry point for the server hook.
        /// </summary>
        /// <param name="context">Easyhook remoting context.</param>
        /// <param name="channelName">IPC channel name.</param>
        /// <param name="projectDirectory">The project directory to use when loading content.</param>
        public void Run(RemoteHooking.IContext context, String channelName)
        {
            try
            {
                AppDomain.CurrentDomain.AssemblyResolve += this.AssemblyResolve;
                this.HookClient.Disconnected            += this.OnDisconnect;

                this.TaskRunning = new ManualResetEvent(false);
                this.TaskRunning.Reset();

                this.RandomHook  = new RandomHook(this.HookClient);
                this.SpeedHook   = new SpeedHook(this.HookClient);
                this.NetworkHook = new NetworkHook(this.HookClient);

                this.MaintainConnection();
            }
            catch (Exception ex)
            {
                this.HookClient.Log("Error initializing hook", ex.ToString());
            }
            finally
            {
                try
                {
                    this.HookClient.Log("Detaching hooks");
                }
                catch
                {
                }

                // Sleep long enough for any remaining messages to complete sending
                Thread.Sleep(100);
            }
        }
Example #14
0
#pragma warning disable IDE0060 // Remove unused parameter
        public EntryPoint(RemoteHooking.IContext context, string channelName)
#pragma warning restore IDE0060 // Remove unused parameter
        {
            _channel = IpcChannel.Connect(channelName);

            _channel.LogBasic("Injection successful");
        }
Example #15
0
 public ButtplugGameVibrationRouterPayload(
     RemoteHooking.IContext aInContext,
     String aInChannelName)
 {
     _interface = RemoteHooking.IpcConnectClient <ButtplugGameVibrationRouterInterface>(aInChannelName);
     _instance  = this;
 }
        public void Run(RemoteHooking.IContext context,
                        string channelName)
        {
            var postMessageHook = LocalHook.Create(
                LocalHook.GetProcAddress("user32.dll", "PostMessageW"),
                new PostMessageDelegate(PostMessageHook),
                this);

            postMessageHook.ThreadACL.SetExclusiveACL(new[] { 0 });
            //RemoteHooking.WakeUpProcess();
            _server.Ping();
            try
            {
                while (true)
                {
                    Thread.Sleep(1000);

                    _server.Ping();
                }
            }
            finally
            {
                postMessageHook?.Dispose();
                LocalHook.Release();
            }
        }
Example #17
0
        public void Run(
            RemoteHooking.IContext aInContext,
            String aInArg1)
        {
            _interface.Ping(RemoteHooking.GetCurrentProcessId(), "Payload installed. Running payload loop.");

            foreach (var xinputVersion in Enum.GetValues(typeof(XInputVersion)))
            {
                try
                {
                    _interface.Ping(RemoteHooking.GetCurrentProcessId(), $"Trying to hook {xinputVersion}.dll");
                    _xinputSetStateHookObj = LocalHook.Create(
                        LocalHook.GetProcAddress($"{xinputVersion}.dll", "XInputSetState"),
                        new XInputSetStateDelegate(XInputSetStateHookFunc),
                        null);
                    _hookedVersion = (XInputVersion)xinputVersion;
                    _interface.Ping(RemoteHooking.GetCurrentProcessId(), $"Hooked {xinputVersion}.dll");
                    break;
                }
                catch
                {
                    // noop
                    _interface.Ping(RemoteHooking.GetCurrentProcessId(), $"Hooking {xinputVersion}.dll failed");
                }
            }
            if (_xinputSetStateHookObj == null)
            {
                _interface.ReportError(RemoteHooking.GetCurrentProcessId(), new Exception("No viable DLL to hook, payload exiting"));
                return;
            }
            // Set hook for all threads.
            _xinputSetStateHookObj.ThreadACL.SetExclusiveACL(new Int32[1]);
            try
            {
                while (_interface.Ping(RemoteHooking.GetCurrentProcessId(), ""))
                {
                    Thread.Sleep(1);

                    if (_messageQueue.Count > 0)
                    {
                        lock (_messageQueue)
                        {
                            _interface.Report(RemoteHooking.GetCurrentProcessId(), _messageQueue);
                            _messageQueue.Clear();
                        }
                    }
                    if (_ex != null)
                    {
                        _interface.ReportError(RemoteHooking.GetCurrentProcessId(), _ex);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                _interface.ReportError(RemoteHooking.GetCurrentProcessId(), e);
            }
            _interface.Ping(RemoteHooking.GetCurrentProcessId(), "Exiting payload loop");
            _interface.Exit();
        }
Example #18
0
 public void Run(RemoteHooking.IContext InContext, String InChannelName)
 {
     init();
     while (true)
     {
     }
 }
Example #19
0
File: Main.cs Project: uvbs/babbot
        public void Run(RemoteHooking.IContext InContext, string ChannelName)
        {
            LogMessage("LUAHost Run");
            try
            {
                string           outChannelName = null;
                IpcServerChannel ipcLogChannel  = RemoteHooking.IpcCreateServer <IPCInterface>(ref outChannelName,
                                                                                               WellKnownObjectMode.
                                                                                               Singleton);

                //notify client of channel creation via logger
                Logger.InjectedDLLChannelName = outChannelName;

                LogMessage("LUAHost Run (NativeAPI.RhWakeUpProcess)");
                NativeAPI.RhWakeUpProcess();

                while (true)
                {
                    Thread.Sleep(100);
                }
            }
            catch (Exception e)
            {
                LogMessage(string.Format("LUAHost Run(Exception) {0}", e.Message));
            }
        }
Example #20
0
        public HookInjection(
            RemoteHooking.IContext InContext,
            String InChannelName,
            String entryPoint,
            String dll,
            String returnType,
            String scriptBlock,
            String modulePath,
            String additionalCode,
            bool eventLog)
        {
            Log("Opening hook interface channel...", eventLog);
            Interface = RemoteHooking.IpcConnectClient <HookInterface>(InChannelName);
            try
            {
                Runspace = RunspaceFactory.CreateRunspace();
                Runspace.Open();

                //Runspace.SessionStateProxy.SetVariable("HookInterface", Interface);
            }
            catch (Exception ex)
            {
                Log("Failed to open PowerShell runspace." + ex.Message, eventLog);
                Interface.ReportError(RemoteHooking.GetCurrentProcessId(), ex);
            }
        }
Example #21
0
        public void Run(RemoteHooking.IContext context, string channelName, EntryPointParameters parameter)
        {
            try
            {
                using (var extractArchiveHook = LocalHook.Create(LocalHook.GetProcAddress("mia.lib", "ExtractArchive"),
                                                                 new ExtractArchiveFnPtr(ExtractArchive_Hooked),
                                                                 this))
                {
                    // Don't forget that all hooks will start deactivated.
                    // The following ensures that all threads are intercepted:
                    extractArchiveHook.ThreadACL.SetExclusiveACL(new int[1]);

                    _remoteObject.TriggerInjectionEvent(RemoteHooking.GetCurrentProcessId());
                    _remoteObject.TriggerMessageEvent(parameter.Message);

                    while (true)
                    {
                        Thread.Sleep(TimeSpan.FromMilliseconds(100));
                        _remoteObject.TriggerPingEvent();
                    }
                }
            }
            catch (Exception e)
            {
                // We should notice our host process about this error
                _remoteObject.TriggerExceptionEvent(e);
            }
            finally
            {
                _remoteObject.TriggerExitEvent();
            }
        }
Example #22
0
#pragma warning disable IDE0060 // Remove unused parameter
        public void Run(RemoteHooking.IContext context, string channelName)
#pragma warning restore IDE0060 // Remove unused parameter
        {
            var mod    = Process.GetCurrentProcess().MainModule;
            var reader = new MemoryReader(mod.BaseAddress,
                                          mod.ModuleMemorySize);

            foreach (var scanner in _scanners)
            {
                var name = scanner.GetType().Name;

                _channel.LogBasic("Running {0}...", name);

                try
                {
                    scanner.Run(reader, _channel);
                }
                catch (Exception e)
                {
                    _channel.LogError("Exception in {0}:", name);
                    _channel.LogError(e.ToString());
                }
            }

            _channel.Done();
        }
Example #23
0
 public CreateProcessARemoteHooker(
     RemoteHooking.IContext inContext,
     string inChannelName) : base(inContext, inChannelName)
 {
     _createProcessAHookerImplementation =
         new CreateProcessAHookerImplementation <CreateProcessARemoteHooker>(this);
 }
        public void Run(RemoteHooking.IContext context, string channelName)
        {
            ClientCallbackProxy.SessionClosed += OnSessionClosed;

            ResetEvent = new ManualResetEvent(false);
            ResetEvent.Reset();

            Proxy = new ClientCallbackProxy();
            Server.GrantProxy(Proxy);

            try {
                BeginHook();

                RemoteHooking.WakeUpProcess();

                StartCheckHostIsAliveThread();
                ResetEvent.WaitOne();
                StopCheckHostIsAliveThread();
            }
            catch (Exception ex) {
                Server.Debug(ex.ToString());
            }
            finally {
                ChannelServices.UnregisterChannel(ClientServerChannel);
                EndHook();
                Thread.Sleep(250);
            }
        }
Example #25
0
        public void Run(RemoteHooking.IContext iContext,
                        string channel)
        {
            //GetPuppetFilesFunc = getPuppetFilesFunc;
            /*获取目标函数的句柄*/
            IntPtr createFileWPtr       = LocalHook.GetProcAddress("kernel32.dll", "CreateFileW");
            IntPtr findFirstFileWPtr    = LocalHook.GetProcAddress("kernel32.dll", "FindFirstFileW");
            IntPtr findNextFileWPtr     = LocalHook.GetProcAddress("kernel32.dll", "FindNextFileW");
            IntPtr findClosePtr         = LocalHook.GetProcAddress("kernel32.dll", "FindClose");
            IntPtr getFileAttributesPtr = LocalHook.GetProcAddress("kernel32.dll", "GetFileAttributesW");
            IntPtr setFileAttributesPtr = LocalHook.GetProcAddress("kernel32.dll", "SetFileAttributesW");

            /*创建钩子*/
            _openHook              = LocalHook.Create(createFileWPtr, new DCreateFileW(CreateFileCallBack), this);
            _findFirstFileHook     = LocalHook.Create(findFirstFileWPtr, new DFindFirstFileW(FindFirstFileCallBack), this);
            _findNextFileHook      = LocalHook.Create(findNextFileWPtr, new DFindNextFileW(FindNextFileCallBack), this);
            _findCloseHook         = LocalHook.Create(findClosePtr, new DFindClose(FindCloseCallBack), this);
            _getFileAttributesHook = LocalHook.Create(getFileAttributesPtr, new DGetFileAttributesW(GetFileAttributesCallBack), this);
            _setFileAttributesHook = LocalHook.Create(setFileAttributesPtr, new DSetFileAttributesW(SetFileAttributesCallBack), this);

            /*设置ACL,我不知道有什么用*/
            _openHook.ThreadACL.SetExclusiveACL(new int[1]);
            _findFirstFileHook.ThreadACL.SetExclusiveACL(new int[1]);
            _findNextFileHook.ThreadACL.SetExclusiveACL(new int[1]);
            _findCloseHook.ThreadACL.SetExclusiveACL(new int[1]);
            _getFileAttributesHook.ThreadACL.SetInclusiveACL(new int[1]);
            _setFileAttributesHook.ThreadACL.SetInclusiveACL(new int[1]);

            RemoteHooking.WakeUpProcess();

            while (true)
            {
                Thread.Sleep(500);
            }
        }
Example #26
0
        public void Run(RemoteHooking.IContext inContext, string inChannelName, string[] dllsToLoad)
        {
            try
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                Interface.Log($"== {OtherUtils.GetAssemblyProductName()} v{OtherUtils.GetAssemblyVersion()} ==");
                Interface.Log($"Using {OtherUtils.ApiProductName} v{OtherUtils.ApiVersion}");

                GlobalHooks.InitGlobalHooks(Interface);

                Loader = new Loader(Interface);
                Loader.LoadMods(dllsToLoad);

                // Make sure the game is fully loaded
                while (Marshal.ReadByte((IntPtr)0x500380) < 9)
                {
                }

                Loader.InitMods();

                stopwatch.Stop();
                Interface.Log($"Done. ({stopwatch.Elapsed.TotalSeconds:F3}s)");

                RemoteHooking.WakeUpProcess();

                while (true)
                {
                    Thread.Sleep(1000);
                }
            }
            catch (Exception e)
            {
                Interface.HandleError(e);
            }
        }
Example #27
0
        public void Run(RemoteHooking.IContext context, string channelName)
        {
            try
            {
                Log.Trace("Entering EntryPoint Run().");

                if (IpcInterface.StartPaused)
                {
                    Process.GetCurrentProcess().Suspend();
                }

                Log.Trace("Installing game hooks...");
                Game.EntryPoint.InstallGameHooks();

                // TODO: AI.EntryPoint.Run();
                while (true)
                {
                    Thread.Sleep(0);
                }
            }
            catch (Exception ex)
            {
                Log.Fatal(ex);
            }
            finally
            {
                Log.Trace("Uninstalling game hooks...");
                Game.EntryPoint.UninstallGameHooks();
                Log.Trace("Exiting EntryPoint Run().");
            }
        }
Example #28
0
        // =====================

        public void Run(
            RemoteHooking.IContext InContext,
            String InChannelName)
        {
            // install hook...
            try
            {
                InterceptDNSHook = LocalHook.Create(
                    LocalHook.GetProcAddress("WS2_32.dll", "GetAddrInfoW"),
                    new DInterceptDNS(InterceptDNS_Hooked),
                    this);

                InterceptDNSHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
            }
            catch (Exception ExtInfo)
            {
                Interface.ReportException(ExtInfo);

                return;
            }

            Interface.IsInstalled(RemoteHooking.GetCurrentProcessId());

            RemoteHooking.WakeUpProcess();

            // wait for host process termination...
            try
            {
                while (true)
                {
                    Thread.Sleep(500);

                    // transmit newly monitored messages ...
                    if (Queue1.Count > 0)
                    {
                        String[] Package = null;

                        lock (Queue1)
                        {
                            Package = Queue1.ToArray();

                            Queue1.Clear();
                        }

                        Interface.OnInterceptDNS(RemoteHooking.GetCurrentProcessId(), Package);
                    }
                    else
                    {
                        Interface.Ping();
                    }
                }
            }
            catch
            {
                // Ping() will raise an exception if host is unreachable
            }
            finally
            {
            }
        }
Example #29
0
        public void Run(RemoteHooking.IContext context, string channelName)
        {
            Stealther stealther = null;

            try
            {
                Server.IsInstalled(RemoteHooking.GetCurrentProcessId());
                RemoteHooking.WakeUpProcess();
                if (DetectDirectXVersion())
                {
                    device.InstallHook();
                }
                stealther = new Stealther();
            }
            catch (Exception e)
            {
                Server.ReportException(e);
            }

            while (Server.RunLibrary)
            {
                Thread.Sleep(500);
            }

            stealther?.Dispose();
            device?.UninstallHook();
            LocalHook.Release();

            Server.DebugMessage("Hooks uninstalled, you can close app!");
        }
Example #30
0
        public void Run(RemoteHooking.IContext context, string channelName, int processId, string applicationName)
        {
            try
            {
                this.sendToLocalHook = LocalHook.Create(LocalHook.GetProcAddress("ws2_32.dll", "sendto"), new SendToDelegate(this.SendToHook), this);
                this.sendToLocalHook.ThreadACL.SetExclusiveACL(new int[] { 0 });
                this.handler.OnHookInstalled(this.applicationName, this.processName);
            }
            catch (Exception exception)
            {
                this.handler.OnError(this.applicationName, this.processName, exception);
            }

            // wait for host process termination
            try
            {
                do
                {
                    Thread.Sleep(30000);
                } while (Process.GetProcessById(processId) != null);
                this.Dispose();
            }
            catch (Exception exception)
            {
                this.handler.OnError(this.applicationName, this.processName, exception);
            }
        }