Exemple #1
0
        /// <summary>
        ///     Inject x86 assembly into the target process and execute it
        /// </summary>
        /// <param name="asm">Assembly code to inject</param>
        /// <returns>true if the code was injected. Otherwise false.</returns>
        /// <exception cref="HookNotAppliedException">Thrown when the required hook has not been applied</exception>
        private static void InjectAndExecute(IEnumerable <string> asm)
        {
            lock (LockObject)
            {
                if (!_isApplied)
                {
                    throw new HookNotAppliedException("Tried to inject code when the Hook was not applied");
                }
                //Lets Inject the passed ASM
                Inject(asm, _allocatedMemory["codeCavePtr"]);


                _allocatedMemory.Write("addressInjection", _allocatedMemory["codeCavePtr"]);

                Stopwatch timer = Stopwatch.StartNew();

                while (_allocatedMemory.Read <int>("addressInjection") > 0)
                {
                    Thread.Sleep(1);
                    if (timer.ElapsedMilliseconds >= 10000)
                    {
                        throw new CodeInjectionFailedException("Failed to inject code after 10 seconds. Last Error: " + Marshal.GetLastWin32Error());
                    }
                } // Wait to launch code

                _allocatedMemory.WriteBytes("codeCavePtr", Eraser);
            }
        }
Exemple #2
0
        /// <summary>
        /// mono_assembly_open
        /// </summary>
        /// <param name="string_0"></param>
        /// <param name="int_0"></param>
        /// <returns></returns>
        internal IntPtr method_40(string string_0, out int int_0)
        {
            IntPtr result;

            using (AllocatedMemory allocatedMemory = this.externalProcessMemory_0.CreateAllocatedMemory(string_0.Length * 2 + 2 + 4))
            {
                allocatedMemory.WriteString(4, string_0, Encoding.UTF8);
                IntPtr intPtr = this.method_17 <IntPtr>(this.intptr_6, //mono_assembly_open
                                                        new object[]
                {
                    allocatedMemory.Address + 4,
                    allocatedMemory.Address
                });
                int_0  = allocatedMemory.Read <int>(0);
                result = intPtr;
            }
            return(result);
        }
Exemple #3
0
        /// <summary>
        ///     Inject x86 assembly into the target process and execute it
        /// </summary>
        /// <param name="asm">Assembly code to inject</param>
        /// <returns>true if the code was injected. Otherwise false.</returns>
        private void InjectAndExecute(IEnumerable <string> asm)
        {
            lock (_injectLock)
            {
                //Lets Inject the passed ASM
                Inject(asm, _allocatedMemory["codeCavePtr"]);



                _allocatedMemory.Write("addressInjection", _allocatedMemory["codeCavePtr"]);

                while (_allocatedMemory.Read <int>("addressInjection") > 0)
                {
                    Thread.Sleep(1);
                } // Wait to launch code


                _allocatedMemory.WriteBytes("codeCavePtr", _eraser);
            }
        }
Exemple #4
0
        /// <summary>
        ///     Inject x86 assembly into the target process and execute it
        /// </summary>
        /// <param name="asm">Assembly code to inject</param>
        /// <returns>true if the code was injected. Otherwise false.</returns>
        /// <exception cref="HookNotAppliedException">Thrown when the required hook has not been applied</exception>
        private static void InjectAndExecute(IEnumerable <string> asm)
        {
            lock (LockObject)
            {
                if (!_isApplied)
                {
                    throw new HookNotAppliedException("Tried to inject code when the Hook was not applied");
                }
                //Lets Inject the passed ASM
                Inject(asm, _allocatedMemory["codeCavePtr"]);


                _allocatedMemory.Write("addressInjection", _allocatedMemory["codeCavePtr"]);


                Stopwatch timer = Stopwatch.StartNew();

                while (_allocatedMemory.Read <int>("addressInjection") > 0)
                {
                    Thread.Sleep(1);
                    if (timer.ElapsedMilliseconds >= 3000)
                    {
                        var window = BotManager.Memory.Process.MainWindowHandle;
                        if (NativeImports.isWindowMinimized(window))
                        {
                            Logger.Warn("CoolFish can not run when WoW is minimized. Please keep the window in background only.");
                            NativeImports.ShowWindow(window);
                            timer.Restart();
                        }
                        else
                        {
                            throw new CodeInjectionFailedException("Failed to inject code after 3 seconds. Last Error: " + Marshal.GetLastWin32Error());
                        }
                    }
                } // Wait to launch code

                _allocatedMemory.WriteBytes("codeCavePtr", Eraser);
            }
        }