Esempio n. 1
0
        public override void Start()
        {
            _screenshotServer = RemoteHooking.IpcCreateServer <ScreenshotInterface.ScreenshotInterface>(
                ref _channelName,
                WellKnownObjectMode.Singleton);

            // Inject to process
            this.TargetProcess = this.Target;

            if (String.IsNullOrEmpty(this.TargetProcess))
            {
                Logger.Warn("Configuration: No executable name has been provided to capture");
                return;
            }

            ScreenshotManager.OnScreenshotDebugMessage += (pid, message) => Debug.WriteLine("{0}: {1}", pid, message);

            Inject();
            _stopped        = false;
            _screenshotPump = new Task(() =>
            {
                _startTime = DateTime.Now;
                while (!_stopped)
                {
                    var response = ScreenshotManager.GetScreenshotSynchronous(_processId,
                                                                              new ScreenshotRequest(
                                                                                  Rectangle.Empty));
                    if (response != null)
                    {
                        Interlocked.Increment(ref _captures);
                    }
                    Interlocked.Exchange(ref _currentResponse, response);
                    Thread.Sleep(5);
                }
            }, TaskCreationOptions.LongRunning);
            _screenshotPump.Start();
        }