Example #1
0
        /// <summary>
        /// Try and kill the process requested by the client
        /// </summary>
        /// <param name="processID"></param>
        public void RequestKillProcess(int processID)
        {
            if (processID > 0)
            {
                RemoteAppManager.Packets.Message message = null;

                ServerUtils.DisplayMessage("Received request to kill process [" + processID + "]");

                try {
                    Process process = Process.GetProcessById(processID);

                    if (process != null)
                    {
                        ServerUtils.DisplayMessage("Killing process " + process.ProcessName);
                        process.Kill();

                        if (process.WaitForExit(2000) && process.HasExited)
                        {
                            message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_KILL_SUCCESS, processID.ToString());
                        }
                        else
                        {
                            message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_ERROR);
                        }
                    }
                }
                catch (Exception e) {
                    ServerUtils.DisplayMessage("Could not kill process [" + processID + "]");
                    Utils.Log(LogLevels.WARNING, e.ToString());
                    message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_ERROR);
                }

                Send(Socket, message.Data);
            }
        }
Example #2
0
        /// <summary>
        /// Send process icon to the client
        /// </summary>
        private void SendProcessIcon(int previousProcessID)
        {
            if (ProcessPrototypesList != null && ProcessPrototypesList.Count > 0)
            {
                ProcessPrototype prototype = null;

                if (previousProcessID == 0)
                {
                    prototype = ProcessPrototypesList.FirstOrDefault();
                }
                else
                {
                    prototype = ProcessPrototypesList.SkipWhile(x => x.ProcessID != previousProcessID).Skip(1).FirstOrDefault();
                }

                if (prototype != null)
                {
                    Icon ico = Icon.ExtractAssociatedIcon(prototype.FileName);
                    if (ico != null)
                    {
                        Bitmap bitmap = ico.ToBitmap();
                        RemoteAppManager.Packets.Message message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_IMAGE, Utils.BitmapToBase64String(bitmap) + ConnectionService.PROCESS_START_DELIMITER + prototype.ProcessID + ConnectionService.PROCESS_END_DELIMITER);

                        Send(this.Socket, message.Data, true);
                    }
                }
            }
        }
Example #3
0
        private void SendNextProcessImage(int previousImagePiece)
        {
            String imageString = _imageStringList.ElementAtOrDefault(++previousImagePiece);

            if (imageString != null)
            {
                RemoteAppManager.Packets.Message message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_PROCESS_IMAGE, imageString + ConnectionService.PROCESS_START_DELIMITER + previousImagePiece + ConnectionService.PROCESS_END_DELIMITER);

                Send(this.Socket, message.Data, true);
            }
            else
            {
                Send(this.Socket, new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_PROCESS_IMAGE_END).Data);
            }
        }
Example #4
0
        private void TrySendProcess(Process process)
        {
            try {
                if (Socket.Connected && process.Id > 0)
                {
                    String data = process.Id + ";" + process.ProcessName;
                    RemoteAppManager.Packets.Message message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_PROCESS, data);

                    Send(Socket, message.Data, true);
                }
            }
            catch (Exception e) {
                Utils.Log(LogLevels.WARNING, "Process not sent " + process.ToString());
            }
        }
Example #5
0
        private void TrySendProcessToStart(ProcessPrototype process)
        {
            try
            {
                if (Socket.Connected && process != null && process.ProcessID >= 0)
                {
                    String data = process.ProcessID + ";" + process.Name;
                    RemoteAppManager.Packets.Message message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_PROCESS_TO_START, data);

                    Send(Socket, message.Data, true);
                }
            }
            catch (Exception e)
            {
                Utils.Log(LogLevels.WARNING, "Process not sent " + process.ToString());
            }
        }
Example #6
0
        /// <summary>
        /// Handle message received from the connection service
        /// </summary>
        /// <param name="message">Message received</param>
        public void ServerConnectionService_MessageReceived(RemoteAppManager.Packets.Message message)
        {
            switch (message.Type)
            {
            case MessageTypes.REQUEST_PROCESSES:
                InitSendProcess();
                break;

            case MessageTypes.REQUEST_NEXT_PROCESS:
                SendProcess(message.GetIntegerValue);
                break;

            case MessageTypes.REQUEST_ICONS:
                InitSendProcessIcons(message);
                break;

            case MessageTypes.REQUEST_NEXT_ICON:
                SendProcessIcon(message.GetIntegerValue);
                break;

            case MessageTypes.REQUEST_KILL_PROCESS:
                RequestKillProcess(message.GetIntegerValue);
                break;

            case MessageTypes.REQUEST_SEARCH_PROCESS:
                RequestSearchProcess(message.Text);
                break;

            case MessageTypes.REQUEST_NEXT_PROCESS_TO_START:
                SendProcessToStart(message.GetIntegerValue);
                break;

            case MessageTypes.REQUEST_START_PROCESS:
                StartProcess(message.GetIntegerValue);
                break;

            case MessageTypes.REQUEST_PROCESS_IMAGE_NEXT:
                SendNextProcessImage(message.GetIntegerValue);
                break;
            }
        }
Example #7
0
        private void SendProcessImage(String imageString)
        {
            RemoteAppManager.Packets.Message message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_PROCESS_IMAGE, imageString + ConnectionService.PROCESS_START_DELIMITER + "0" + ConnectionService.PROCESS_END_DELIMITER);

            Send(this.Socket, message.Data, true);
        }
Example #8
0
 private void InitSendProcessIcons(RemoteAppManager.Packets.Message message)
 {
     ServerUtils.DisplayMessage("Received request for icons");
     RefreshProcessPrototypesList();
     SendProcessIcon(0);
 }