상속: System.MarshalByRefObject
예제 #1
0
        /// <summary>
        /// Add a screenshot request
        /// </summary>
        /// <param name="clientPID"></param>
        /// <param name="screenshotRequest"></param>
        /// <param name="responseNotification"></param>
        public static void AddScreenshotRequest(Int32 clientPID, ScreenshotRequest screenshotRequest, ScreenshotRequestResponseNotification responseNotification)
        {
            try
            {
                if (!HookManager.HookedProcesses.Contains(clientPID))
                {
                    throw new ArgumentException("The client process must be hooked first", "clientPID");
                }
                if (screenshotRequest == null)
                {
                    throw new ArgumentNullException("screenshotRequest");
                }
                if (responseNotification == null)
                {
                    throw new ArgumentNullException("responseNotification");
                }

                lock (_screenshotRequestByClientPID)
                {
                    lock (_screenshotRequestNotifications)
                    {
                        _screenshotRequestByClientPID[clientPID] = screenshotRequest;
                        _screenshotRequestNotifications[clientPID] = responseNotification;
                    }
                }
            }
            catch
            {
            }
        }
예제 #2
0
        public static ScreenshotResponse GetScreenshotSynchronous(Int32 clientPID, ScreenshotRequest screenshotRequest, TimeSpan timeout)
        {
            object srLock = new object();
            ScreenshotResponse sr = null;

            ScreenshotRequestResponseNotification srrn = delegate(Int32 cPID, ResponseStatus status, ScreenshotResponse screenshotResponse)
            {
                Interlocked.Exchange(ref sr, screenshotResponse);
            };
            DateTime startRequest = DateTime.Now;
            AddScreenshotRequest(clientPID, screenshotRequest, srrn);

            // Wait until the response has been returned
            while (true)
            {
                Thread.Sleep(10);

                if (sr != null)
                {
                    break;
                }

                // Break if timed out (will result in a null return value)
                if (DateTime.Now - startRequest > timeout)
                {
                    return null;
                }
            }

            return sr;
        }
예제 #3
0
 public void newRequest(ScreenshotRequest request)
 {
     try
     {
         lock (requestLock)
         {
             if (request is PauseRequest)
             {
                 paused = true;
             }
             else if (request is StopRequest)
             {
                 paused = true;
                 if (frameTarget != null)
                 {
                     frameTarget.close();
                     frameTarget = null;
                 }
             }
             else if (request is ResumeRequest)
             {
                 if (frameTarget != null)
                 {
                     paused = false;
                 }
             }
             else if (request is StreamRequest)
             {
                 StreamRequest streamRequest = (StreamRequest)request;
                 frameTarget = new FrameServer(streamRequest.Host, streamRequest.Port);
                 this.captureRect = streamRequest.Region;
                 this.freq = 1 / streamRequest.Fps;
                 paused = false;
             }
             else if (request is CaptureRequest)
             {
                 CaptureRequest captureRequest = (CaptureRequest)request;
                 frameTarget = new IPCHostSink(ProcessId, request.RequestId, Interface);
                 this.captureRect = captureRequest.Region;
                 this.freq = 1 / captureRequest.Fps;
                 paused = false;
             }
         }
     }
     catch (Exception e)
     {
         paused = true;
         if (frameTarget != null)
         {
             frameTarget.close();
             frameTarget = null;
         }
         ErrorMessage("Exception when processing request" + request + "\n\r" + e);
         paused = true;
     }
 }
예제 #4
0
 public static ScreenshotResponse GetScreenshotSynchronous(Int32 clientPID, ScreenshotRequest screenshotRequest)
 {
     // 2 second timeout
     return GetScreenshotSynchronous(clientPID, screenshotRequest, new TimeSpan(0, 0, 2));
 }
예제 #5
0
 public void sendRequest(ScreenshotRequest request)
 {
     ScreenshotManager.AddScreenshotRequest(hookedProcess.Id, request, notify);
 }