Exemplo n.º 1
0
        public Overlay(Process process)
        {
            this.process = process;
            this.handle  = base.Handle;
            int windowLong = Managed.GetWindowLong(base.Handle, -20);

            Managed.SetWindowLong(base.Handle, -20, (windowLong | 0x80000) | 0x20);
            IntPtr hWndInsertAfter = new IntPtr(-1);

            Managed.SetWindowPos(base.Handle, hWndInsertAfter, 0, 0, 0, 0, 3);
            this.OnResize(null);
            this.InitializeComponent();
        }
Exemplo n.º 2
0
        // Init
        public Overlay(Process process)
        {
            this.process = process;
            this.handle  = Handle;

            int initialStyle = Managed.GetWindowLong(this.Handle, -20);

            Managed.SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);

            IntPtr       HWND_TOPMOST  = new IntPtr(-1);
            const UInt32 SWP_NOSIZE    = 0x0001;
            const UInt32 SWP_NOMOVE    = 0x0002;
            const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;

            Managed.SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
            OnResize(null);

            InitializeComponent();
        }
Exemplo n.º 3
0
        private void SetWindow(object sender)
        {
            IntPtr ptr;

Label_0000:
            ptr = IntPtr.Zero;
            ptr = Managed.FindWindow(null, "Rust");
            if (ptr != IntPtr.Zero)
            {
                External_ESP_Base.RECT lpRect = new External_ESP_Base.RECT();
                Managed.GetWindowRect(ptr, out lpRect);
                if (((lpRect.Left < 0) && (lpRect.Top < 0)) && ((lpRect.Right < 0) && (lpRect.Bottom < 0)))
                {
                    this.IsMinimized = true;
                    goto Label_0000;
                }
                this.IsMinimized = false;
                External_ESP_Base.RECT rect2 = new External_ESP_Base.RECT();
                Managed.GetClientRect(ptr, out rect2);
                if ((this.rect.Width != (lpRect.Bottom - lpRect.Top)) && (this.rect.Width != (rect2.Right - rect2.Left)))
                {
                    this.IsResize = true;
                }
                this.rect.Width  = lpRect.Right - lpRect.Left;
                this.rect.Height = lpRect.Bottom - lpRect.Top;
                if ((Managed.GetWindowLong(ptr, Managed.GWL_STYLE) & Managed.WS_BORDER) != 0)
                {
                    int num = lpRect.Bottom - lpRect.Top;
                    this.rect.Height = rect2.Bottom - rect2.Top;
                    this.rect.Width  = rect2.Right - rect2.Left;
                    int num2 = num - rect2.Bottom;
                    int num3 = ((lpRect.Right - lpRect.Left) - rect2.Right) / 2;
                    num2          -= num3;
                    lpRect.Left   += num3;
                    lpRect.Top    += num2;
                    this.rect.Left = lpRect.Left;
                    this.rect.Top  = lpRect.Top;
                }
                Managed.MoveWindow(this.handle, lpRect.Left, lpRect.Top, this.rect.Width, this.rect.Height, true);
            }
            Thread.Sleep(300);
            goto Label_0000;
        }
Exemplo n.º 4
0
        // Get Window Rect
        private void SetWindow(object sender)
        {
            while (true)
            {
                IntPtr targetWnd = IntPtr.Zero;
                targetWnd = Managed.FindWindow(null, "Battlefield™ 1");

                if (targetWnd != IntPtr.Zero)
                {
                    RECT targetSize = new RECT();
                    Managed.GetWindowRect(targetWnd, out targetSize);

                    // Game is Minimized
                    if (targetSize.Left < 0 && targetSize.Top < 0 && targetSize.Right < 0 && targetSize.Bottom < 0)
                    {
                        IsMinimized = true;
                        continue;
                    }

                    // Reset
                    IsMinimized = false;

                    RECT borderSize = new RECT();
                    Managed.GetClientRect(targetWnd, out borderSize);

                    int dwStyle = Managed.GetWindowLong(targetWnd, Managed.GWL_STYLE);

                    int windowheight;
                    int windowwidth;
                    int borderheight;
                    int borderwidth;

                    if (rect.Width != (targetSize.Bottom - targetSize.Top) &&
                        rect.Width != (borderSize.Right - borderSize.Left))
                    {
                        IsResize = true;
                    }

                    rect.Width  = targetSize.Right - targetSize.Left;
                    rect.Height = targetSize.Bottom - targetSize.Top;

                    if ((dwStyle & Managed.WS_BORDER) != 0)
                    {
                        windowheight = targetSize.Bottom - targetSize.Top;
                        windowwidth  = targetSize.Right - targetSize.Left;

                        rect.Height = borderSize.Bottom - borderSize.Top;
                        rect.Width  = borderSize.Right - borderSize.Left;

                        borderheight  = (windowheight - borderSize.Bottom);
                        borderwidth   = (windowwidth - borderSize.Right) / 2; //only want one side
                        borderheight -= borderwidth;                          //remove bottom

                        targetSize.Left += borderwidth;
                        targetSize.Top  += borderheight;

                        rect.Left = targetSize.Left;
                        rect.Top  = targetSize.Top;
                    }
                    Managed.MoveWindow(handle, targetSize.Left, targetSize.Top, rect.Width, rect.Height, true);
                }
                Thread.Sleep(300);
            }
        }