Example #1
0
        public void Run(EasyHook.RemoteHooking.IContext context, string channelName)
        {
            _server.ReportMessage("InjectionEntryPoint Run:");
            _server.IsInstalled(clientPID, channelName2);

            functions = new FunctionImports(_server.GetDebug());

            //Install hooks
            PlayerChangeManagerIsEnabledHook = EasyHook.LocalHook.Create(functions.dbPlayerChangeManagerIsEnabledAddr, new FunctionImports.PlayerChangeManagerIsEnabled(PlayerChangeManagerIsEnabled_Hook), null);
            OnSelectPlayerChangeMenuHook     = EasyHook.LocalHook.Create(FunctionImports.OnSelectPlayerChangeMenuAddr, new FunctionImports.OnSelectPlayerChangeMenu(OnSelectPlayerChangeMenu_Hook), null);
            PlayerChangeManagerUpdateHook    = EasyHook.LocalHook.Create(FunctionImports.PlayerChangeManagerUpdateAddr, new FunctionImports.PlayerChangeManagerUpdate(PlayerChangeManagerUpdate_Hook), null);

            //Activate hooks
            PlayerChangeManagerIsEnabledHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
            OnSelectPlayerChangeMenuHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
            PlayerChangeManagerUpdateHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });

            //0x5137Ab0
            //0x1aa58e780
            //functions.SetUserControlActorFunc(0x5137AB0, 0x1AA59E3F0, true, false, true);

            try
            {
                while (true)
                {
                    System.Threading.Thread.Sleep(500);

                    string[] queued = null;

                    lock (_messageQueue)
                    {
                        queued = _messageQueue.ToArray();
                        _messageQueue.Clear();
                    }

                    // Send newly monitored file accesses to FileMonitor
                    if (queued != null && queued.Length > 0)
                    {
                        _server.ReportMessages(queued);
                    }
                    else
                    {
                        _server.Ping();
                    }
                }
            }
            catch
            {
            }

            return;
        }
        /// <summary>
        /// Logic of the entrypoint.
        /// </summary>
        /// <param name="context">The RemoteHooking context</param>
        /// <param name="channelName">The name of the IPC channel</param>
        public void Run(EasyHook.RemoteHooking.IContext context, string channelName)
        {
            EasyHook.LocalHook monoOpenImageHook = null;
            var filename = @"Mono\EmbedRuntime\mono.dll";

            LoadLibraryW(filename);

            // Install the hook
            IntPtr pTargetProc = EasyHook.LocalHook.GetProcAddress(filename, "mono_image_open_from_data_with_name");

            monoOpenImageHook = EasyHook.LocalHook.Create(pTargetProc, new MonoOpenImage_Delegate(MonoOpenImage_Hook), this);
            monoOpenImageHook.ThreadACL.SetExclusiveACL(new int[] { 0 });

            // Wake up the process
            EasyHook.RemoteHooking.WakeUpProcess();

            while (true)
            {
                Thread.Sleep(500);

                string[] queued = null;

                lock (_messageQueue)
                {
                    queued = _messageQueue.ToArray();
                    _messageQueue.Clear();
                }

                // Send newly received message back to Loader.exe
                if (queued != null && queued.Length > 0)
                {
                    _server.OutputMessages(queued);
                }
                else
                {
                    _server.Ping();
                }
            }
        }
Example #3
0
        unsafe public void Run(EasyHook.RemoteHooking.IContext context, string channelName)
        {
            string s  = dllpurpose;
            int    id = EasyHook.RemoteHooking.GetCurrentProcessId();

            _server.HookIsInstalled(id);
            EasyHook.LocalHook chatMessageFunctionHook = null;
            try
            {
                Native.ModuleInformation moduleInformation = new Native.ModuleInformation();
                var size = Convert.ToUInt32(Marshal.SizeOf(typeof(Native.ModuleInformation)));
                Native.GetModuleInformation(Process.GetCurrentProcess().Handle, Native.GetModuleHandle("client.dll"), out moduleInformation, size);
                var pointer = FindThePrintFunction(moduleInformation, messageSignature);
                originalMethod = Marshal.GetDelegateForFunctionPointer <DotaChatFunction_Delegate>(pointer);

                chatMessageFunctionHook = EasyHook.LocalHook.Create(
                    pointer,
                    new DotaChatFunction_Delegate(MyDotaChatFunction),
                    this);
                chatMessageFunctionHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
                originalMethodByPass = Marshal.GetDelegateForFunctionPointer <DotaChatFunction_Delegate>(chatMessageFunctionHook.HookBypassAddress);


                _server.ReportMessage(id, "Local Hook Installation complete.");

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

                        string[] queued = null;

                        lock (_messageQueue)
                        {
                            queued = _messageQueue.ToArray();
                            _messageQueue.Clear();
                        }

                        // Send newly monitored file accesses to FileMonitor
                        if (queued != null && queued.Length > 0)
                        {
                            _server.ReportChatMessages(queued);
                        }
                        else
                        {
                            _server.Ping();
                        }
                    }
                }
                catch (Exception ex)
                {
                    // Ping() or ReportMessages() will raise an exception if host is unreachable
                    try
                    {
                        _server.ReportException(ex);
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                _server.ReportException(ex);
            }
            finally
            {
                try
                {
                    if (chatMessageFunctionHook != null)
                    {
                        chatMessageFunctionHook.Dispose();
                    }

                    EasyHook.LocalHook.Release();
                }
                catch (Exception ex)
                {
                    _server.ReportException(ex);
                }
            }
        }