Beispiel #1
0
        public static bool Hook(IntPtr targetWindowHandle, IntPtr thisHandle)
        {
            try
            {
                if (targetWindowHandle != IntPtr.Zero)
                {
                    int processId;
                    var threadId = NativeUtils.GetWindowThreadProcessId(targetWindowHandle, out processId);

                    var panelHandle  = thisHandle.ToInt32();
                    var targetHandle = targetWindowHandle.ToInt32();

                    var b1 = BitConverter.GetBytes(panelHandle);
                    var b2 = BitConverter.GetBytes(targetHandle);

                    var data = new byte[b1.Length + b2.Length];
                    Array.Copy(b1, data, b1.Length);
                    Array.Copy(b2, 0, data, b1.Length, b2.Length);

#warning FIX
                    // Pickup an idle message from the queue
                    //fixHookHelper.InstallIdleHandler(processId, threadId, typeof (RuntimeEditorHook).Assembly.Location, typeof (RuntimeEditorHook).FullName, data);

                    // send an idle ;;)
                    NativeUtils.SendMessage(targetWindowHandle, 0, IntPtr.Zero, IntPtr.Zero);
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "RuntimeObjectEditor");
                return(false);
            }
        }
        public static void Capture(IntPtr hwnd, Direct3DVersion direct3DVersion = Direct3DVersion.AUTO_DETECT)
        {
            NativeUtils.GetWindowThreadProcessId(hwnd, out var processID);
            var process = Process.GetProcessById(processID);

            var captureConfig = new CaptureConfig
            {
                Direct3DVersion       = direct3DVersion,
                ShowOverlay           = true,
                CaptureMouseEvents    = true,
                CaptureKeyboardEvents = true
            };

            var captureInterface = new CaptureInterface();

            captureInterface.RemoteMessage += e =>
            {
                Debug.WriteLine(e.Message);
            };

            captureInterface.Connected += () =>
            {
                captureInterface.DrawOverlayInGame(new Overlay
                {
                    Elements = new List <IOverlayElement>
                    {
                        new RectangleElement
                        {
                            Colour   = Color.FromArgb(Color.Gray.ToArgb() ^ (0x33 << 24)),
                            Location = new Point(0, 0),
                            Width    = -1,
                            Height   = -1
                        },
                        new RectangleMouseHookElement
                        {
                            Colour = Color.FromArgb(Color.Green.ToArgb() ^ (0x33 << 24)),
                            Width  = 0,
                            Height = 0
                        },
                        new FramesPerSecond(new Font("Arial", 16, FontStyle.Bold))
                        {
                            Location    = new Point(0, 0),
                            Color       = Color.Red,
                            AntiAliased = true,
                            Text        = "{0:N0} FPS"
                        }
                    },
                    Hidden = false
                });
            };

            var captureProcess = new CaptureProcess(process, captureConfig, captureInterface);

            while (!captureProcess.IsDisposed)
            {
                Thread.Sleep(500);
            }

            Debug.WriteLine("Disconnected from DirectX Hook");
        }