Esempio n. 1
0
        public HookEntity Handle(ProxyEntity request)
        {
            return(_repository.ActionResult(x => x.Port == request.Port, x =>
            {
                HookElement _hook = x.Hooker.Hook;

                RemoteHooking.CreateAndInject(
                    x.Hooker.ExePath,
                    string.Empty,
                    0x00000004,
                    InjectionOptions.DoNotRequireStrongName,
                    "./SocketHook.dll",
                    "./SocketHook.dll",
                    out _hook.ProcessId,
                    _hook.ChannelName,
                    request.Port);

                while (_hook.ProcessId == 0)
                {
                    ;
                }

                x.ProcessId = _hook.ProcessId;

                logger.Debug($"Process id : {_hook.ProcessId}");

                return x;
            }).Hooker);
        }
Esempio n. 2
0
        /// <summary>
        /// Класс для манипуляции нарисованными элемнтами
        /// </summary>
        /// <param name="GetDistanceXY">Функция возвращающая дистанцию до цели</param>
        /// <param name="DrawElement">Рисование копии объекта</param>
        /// <param name="DrawShadow">Рисование тени объекта</param>
        /// <param name="GetHookPoint">Функция возвращающая точку захвата</param>
        /// <param name="AcceptNewCoordinates">Применить изменения к оригиналу</param>
        /// <param name="Element">Манипулируемый элемент</param>
        /// <param name="SubHooks"></param>
        /// <param name="ContextMenu">Контекстное меню</param>
        /// <param name="ChangeMethod">Метод передвижения</param>
        /// <param name="GetMagnetRadius">Радиус Зацепления</param>
        public Hook(
            HookElement Element,
            Func <Point, double> GetDistanceXY,
            Func <Point, Point> GetHookPoint,
            Func <double> GetMagnetRadius,
            Action <Vector?> ChangeMethod,
            Action <Vector?, DrawingVisual, DrawingVisual, DrawingVisual, bool> DrawElement,
            Action <DrawingVisual, DrawingVisual, DrawingVisual> DrawShadow,
            Action AcceptNewCoordinates,
            List <Hook> SubHooks = null)
        {
            this.Element       = Element;
            this.GetDistanceXY = GetDistanceXY;
            ActionDrawShadow   = DrawShadow;
            GetVal             = GetHookPoint;
            this.ChangeMethod  = ChangeMethod;
            ActionDrawOver     = DrawElement;
            this.SubHooks      = SubHooks;
            this.MagnetRadius  = GetMagnetRadius;
            this.AcceptChanges = AcceptNewCoordinates;

            Sets = Element.Sets;

            Element.Changed += o => Task.Run(() => ResetElement?.Invoke(o));
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            try
            {
                bool   onlyInject         = int.TryParse(args[0], out int processIdReq);
                string processPathReq     = onlyInject ? string.Empty : args[0];
                int    redirectionPortReq = int.Parse(args[1]);

                HookElement hook = new HookElement();
                {
                    hook.IpcServer = RemoteHooking.IpcCreateServer <HookInterface>(ref hook.ChannelName, WellKnownObjectMode.Singleton);
                }

                if (onlyInject)
                {
                    RemoteHooking.Inject(
                        processIdReq,
                        "./SocketHook.dll",
                        "./SocketHook.dll",
                        hook.ChannelName,
                        redirectionPortReq
                        );
                }
                else
                {
                    RemoteHooking.CreateAndInject(
                        processPathReq,
                        string.Empty,
                        0x00000004,
                        InjectionOptions.DoNotRequireStrongName,
                        "./SocketHook.dll",
                        "./SocketHook.dll",
                        out hook.ProcessId,
                        hook.ChannelName,
                        redirectionPortReq
                        );
                }

                Console.Read();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 4
0
        public void InitHook(string exePath, string hookDllPath, int instanceCount = 1)
        {
            if (instanceCount <= 0)
            {
                return;
            }

            int port = Port;

            HookElement element = new HookElement();

            {
                element.IpcServer = RemoteHooking.IpcCreateServer <CustomHookInterface>(ref element.ChannelName, WellKnownObjectMode.Singleton);
            }

            RemoteHooking.CreateAndInject(
                exePath,
                string.Empty,
                0x00000004,
                InjectionOptions.DoNotRequireStrongName,
                hookDllPath,
                hookDllPath,
                out element.ProcessId,
                element.ChannelName,
                port);

            PortUsedByProcess.Add(element.ProcessId, port);
            Process process = Process.GetProcessById(element.ProcessId);

            process.EnableRaisingEvents = true;

            process.Exited += (obj, arg) =>
            {
                PortUsedByProcess.Remove(process.Id);
                UIManager.Instance.RemovePage(process.Id);
            };

            UIManager.Instance.OpenPage(process.Id);

            Task.Delay(TimeSpan.FromMilliseconds(ConfigurationManager.Instance.Startup.time_wait_in_ms)).ContinueWith(task =>
            {
                InitHook(exePath, hookDllPath, instanceCount - 1);
            });
        }
Esempio n. 5
0
        public void Inject()
        {
            StartupConfiguration configuration = ConfigurationManager.Instance.Startup;

            if (configuration is null)
            {
                logger.Error("startup configuration is null");
                return;
            }

            int port = ProxyPort;

            _hook = new HookElement();
            {
                _hook.IpcServer = RemoteHooking.IpcCreateServer <BotoxHookInterface <T> >(ref _hook.ChannelName, WellKnownObjectMode.Singleton);
            }

            RemoteHooking.CreateAndInject(
                configuration.game_location,
                string.Empty,
                0x00000004,
                InjectionOptions.DoNotRequireStrongName,
                configuration.dll_location,
                configuration.dll_location,
                out _hook.ProcessId,
                _hook.ChannelName,
                port);

            Proxy = new CustomProxy <T>(ProxyPort, _hook.ProcessId);

            Process process = Process.GetProcessById(_hook.ProcessId);

            process.EnableRaisingEvents = true;

            if (process.WaitForInputIdle())
            {
                logger.Info($"process opened : {process.ProcessName} {process.Id}");
                OnProcessStarted?.Invoke(this);
            }

            process.Exited += Process_Exited;
        }