ShowWindow() private method

private ShowWindow ( IntPtr, hWnd, int nCmdShow ) : bool
hWnd IntPtr,
nCmdShow int
return bool
Esempio n. 1
0
        public void ShowMainWindow()
        {
            var handle = Process.GetCurrentProcess().MainWindowHandle;

            NativeImports.ShowWindow(handle, 5);
            NativeImports.SetForegroundWindow(handle);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            WindowChrome.SetWindowChrome(this, new WindowChrome {
                CaptionHeight = 0
            });

            if (Owner != null)
            {
                AllowMove     = false;
                ShowInTaskbar = false;
            }
            else
            {
                var handle = new WindowInteropHelper(this).Handle;

                NativeImports.ShowWindow(handle, 5);
                NativeImports.SetForegroundWindow(handle);
            }
        }
Esempio n. 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>
        /// <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);
            }
        }
Esempio n. 4
0
 private void Show_BTN_Click(object sender, RoutedEventArgs e)
 {
     if (_processes.Length > ProcessCB.SelectedIndex && ProcessCB.SelectedIndex >= 0)
     {
         var window = _processes[ProcessCB.SelectedIndex].MainWindowHandle;
         if (window == IntPtr.Zero)
         {
             var windows = NativeImports.GetProcessWindows(_processes[ProcessCB.SelectedIndex].Id);
             foreach (var ptr in windows)
             {
                 NativeImports.ShowWindow(ptr);
             }
         }
         else
         {
             NativeImports.ShowWindow(window);
         }
     }
     else
     {
         Logger.Warn("Please pick a process to show");
     }
 }