Ejemplo n.º 1
0
 public static void ShowClientDetails(object sender, EventArgs e)
 {
     foreach (ConnectionTable.ClientInformation clientInformation in _connectionTable.GetChecked())
     {
         TraceOps.Out("ClientInformation for " + clientInformation.GetName());
         try
         {
             ConnectionTable.ClientInformation information = clientInformation;
             var thread = new Thread(new ThreadStart(() =>
             {
                 var clientDetailForm = new ServerClientDetailForm(information)
                 {
                     TopLevel = false
                 };
                 var d = new PluginFormCallback(SetWindowToPanel);
                 _mainForm.Invoke(d, new object[] { clientDetailForm });
             }));
             thread.Start();
         }
         catch (Exception et)
         {
             TraceOps.Out(et.ToString());
         }
     }
 }
Ejemplo n.º 2
0
        private void MainServerForm_Load(object sender, EventArgs e)
        {
            TraceOps.LoadLog();
            try
            {
                _name = "Server";

                Services.PrepareSetService(_port);
                Services.SetService(typeof(ConnectionTable));
                Services.SetService(typeof(MessageQueue));

                _connectionTable = ConnectionTable.GetRemote("localhost", _port);
                _messageQueue    = MessageQueue.GetRemote("localhost", _port);

                _taskManager       = new TaskManager(ref _messageQueue, ref _name);
                _taskManager.Task += TaskManagerOnTask;

                var ci = new ConnectionTable.ClientInformation(_name);
                ci.SetGroup("server");
                ci.SetIp(NetworkOps.GetIpString(HashOps.GetFqdn()));
                ci.SetPort(_port);
                _connectionTable.Set(_name, ci);

                LoadClientsTable();
                LoadPlugIns();
            }
            catch (Exception ex)
            {
                TraceOps.Out(ex.Message);
            }
        }
Ejemplo n.º 3
0
 public static void StartZTree(object sender, EventArgs eventArgs)
 {
     try
     {
         var exeToRun = Path.Combine(Path.GetTempPath(), "ztree.exe");
         if (ProcessControl.FindProcess("ztree"))
         {
             DialogResult dialogResult = MessageBox.Show(Resources.Control_StartZTree_Are_you_sure_to_restart_z_Tree_, Resources.Control_StartZTree_z_Tree_is_still_running, MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.No)
             {
                 return;
             }
         }
         try
         {
             FindDeleteFileAndStartAgain(exeToRun, "ztree", true);
         }
         catch (Exception innerException)
         {
             TraceOps.Out(innerException.ToString());
         }
     }
     catch (Exception exception)
     {
         TraceOps.Out(exception.ToString());
     }
 }
Ejemplo n.º 4
0
        private void ConnectToServer(string ip, int port)
        {
            TraceOps.Out("Connect to: " + ip + " : " + port);
            Services.GetService(ip, port, typeof(ConnectionTable));
            Services.GetService(ip, port, typeof(MessageQueue));
            _connectionTable = ConnectionTable.GetRemote(ip, port);
            _messageQueue    = MessageQueue.GetRemote(ip, port);
            _name            = HashOps.GetFqdn();

            try
            {
                foreach (IClientPlugin plugin in _plugins)
                {
                    plugin.SetForm(this);
                    plugin.SetName(ref _name);
                    plugin.SetQueue(ref _messageQueue);
                    plugin.SetTable(ref _connectionTable);
                }

                _networkClient     = new NetworkClient(ref _messageQueue, ref _connectionTable, _name);
                _taskManager       = new TaskManager(ref _messageQueue, ref _name);
                _taskManager.Task += TaskManagerOnTask;
                if (_plugins != null)
                {
                    _taskManager.SetListener(_plugins);
                }
            }
            catch (Exception ex)
            {
                TraceOps.Out(ex.Message);
            }
        }
Ejemplo n.º 5
0
        private void MessageWorker()
        {
            try
            {
                Register();

                while (_clientRunning)
                {
                    Thread.Sleep(Threshold);

                    var cpu = _cpuCounter.NextValue();

                    var count = _messageQueue.GetCount(_name);

                    var processes = "";
                    foreach (Process p in Process.GetProcesses())
                    {
                        if (p.MainWindowTitle.Length > 1)
                        {
                            processes += p.MainWindowTitle + "; ";
                        }
                    }

                    var ci = _connectionTable.Get(_name);
                    ci.SetPerformance(cpu);
                    ci.SetApplicationNames(processes);
                    ci.SetMessagesInQueue(count);
                    _connectionTable.Set(_name, ci);
                }
            }
            catch (Exception exception)
            {
                TraceOps.Out(exception.ToString());
            }
        }
Ejemplo n.º 6
0
        public void SetTask(Message message)
        {
            try
            {
                var thread = new Thread(new ThreadStart(() =>
                {
                    try
                    {
                        TraceOps.Out("WebControl Client recived Message: " + message.GetCommand());
                        if (message.GetCommand() == "open_browser")
                        {
                            var d = new PluginCallback(_control.StartBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "open_custom_browser")
                        {
                            var d = new PluginCallback(_control.StartCustomBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "close_browser")
                        {
                            var d = new PluginCallback(_control.StopBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "change_url")
                        {
                            var p     = message.GetParameter();
                            var value = "";

                            if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                            {
                                value = Message.GetAttribute(p, "url");
                            }

                            if (value != "")
                            {
                                _control.SetUrl(value);
                            }

                            var d = new PluginCallback(_control.ChangeUrl);
                            _mainForm.Invoke(d, new object[] { });
                        }
                    }
                    catch (Exception e)
                    {
                        TraceOps.Out(e.ToString());
                    }
                }));
                thread.Start();
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }
        }
Ejemplo n.º 7
0
 private void TaskManagerOnTask(Message message)
 {
     switch (message.GetCommand())
     {
     default:
         TraceOps.Out(message.GetCommand());
         break;
     }
 }
Ejemplo n.º 8
0
 public Window()
 {
     try
     {
         this.CreateHandle(new CreateParams());
     }
     catch (Exception ex)
     {
         TraceOps.Out(System.Environment.NewLine + "Target  :  " + ex.TargetSite.ToString() + System.Environment.NewLine + "Message :  " + ex.Message.ToString() + System.Environment.NewLine + "Stack   :  " + ex.StackTrace.ToString());
     }
 }
Ejemplo n.º 9
0
        private void securityOptionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var securityOptionsForm = new SecurityOptionsForm()
            {
                TopLevel = true
            };

            if (securityOptionsForm.ShowDialog() == DialogResult.OK)
            {
                TraceOps.Out("Set PaceServer Security.\r\n");
            }
        }
Ejemplo n.º 10
0
 public static void RemoteStopLeaf(object sender, EventArgs e)
 {
     foreach (ConnectionTable.ClientInformation clientInformation in _connectionTable.GetChecked())
     {
         TraceOps.Out(clientInformation.GetName());
         var p = new string[, ] {
             { }, { }
         };
         var m = new Message(p, true, "stop_zleaf", clientInformation.GetName());
         _messageQueue.SetMessage(m);
     }
 }
Ejemplo n.º 11
0
        public void StartZLeaf()
        {
            try
            {
                var exeToRun  = Path.Combine(Path.GetTempPath(), "zleaf.exe");
                var ci        = _connectionTable.Get("Server");
                var arguments = ClientModel.BuildCommandLineOptionsZLeaf(ci.GetIp(), _name, 200, 200, 200, 200);

                ProcessControl.FindDeleteFileAndStartAgain(exeToRun, "zleaf", true, true, Resources.zleaf, arguments);
            }
            catch (Exception exception)
            {
                TraceOps.Out(exception.ToString());
            }
        }
Ejemplo n.º 12
0
 public void StartCustomBrowser()
 {
     try
     {
         _customBrowserForm = new CustomBrowser()
         {
             TopLevel = true
         };
         _customBrowserForm.Show();
     }
     catch (Exception exception)
     {
         TraceOps.Out(exception.ToString());
     }
 }
Ejemplo n.º 13
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            var p = new string[, ] {
                { "p1", "v1" }, { "p2", "v2" }
            };
            var m = new Message(p, true, "ping", "Server");

            if (_messageQueue != null)
            {
                _messageQueue.SetMessage(m);
            }
            else
            {
                TraceOps.Out("no connection to server message queue");
            }
        }
Ejemplo n.º 14
0
        public void RegisterGlobalHotKey(ModifierKeys modifier, Keys key, Form mainForm)
        {
            try
            {
                _currentId = _currentId + 1;

                if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
                {
                    TraceOps.Out("Couldn’t register the hot key.");
                }
            }
            catch (Exception ex)
            {
                TraceOps.Out(System.Environment.NewLine + "Target  :  " + ex.TargetSite.ToString() + System.Environment.NewLine + "Message :  " + ex.Message.ToString() + System.Environment.NewLine + "Stack   :  " + ex.StackTrace.ToString());
            }
        }
Ejemplo n.º 15
0
        private void preferencesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var preferencesForm = new PreferencesForm()
            {
                TopLevel = true
            };

            if (preferencesForm.ShowDialog() == DialogResult.OK)
            {
                var startOnSystemStart = preferencesForm.checkBoxRunOnStartup.Checked;
                if (startOnSystemStart)
                {
                    TraceOps.Out("Set PaceServer Preferences.\r\n");
                }
            }
        }
Ejemplo n.º 16
0
        private void TaskManagerOnTask(Message message)
        {
            switch (message.GetCommand())
            {
            case "":
                Console.WriteLine("Case 1");
                break;

            case "a":
                Console.WriteLine("Case 2");
                break;

            default:
                TraceOps.Out(message.GetCommand());
                break;
            }
        }
Ejemplo n.º 17
0
 public KeyboardControl()
 {
     Running = true;
     try
     {
         _window.KeyPressed += delegate(object sender, KeyPressedEventArgs args)
         {
             if (KeyPressed != null)
             {
                 KeyPressed(this, args);
             }
         };
     }
     catch (Exception ex)
     {
         TraceOps.Out(System.Environment.NewLine + "Target  :  " + ex.TargetSite.ToString() + System.Environment.NewLine + "Message :  " + ex.Message.ToString() + System.Environment.NewLine + "Stack   :  " + ex.StackTrace.ToString());
     }
 }
Ejemplo n.º 18
0
        public void StopBrowser()
        {
            try
            {
                if (_customBrowserForm != null)
                {
                    _customBrowserForm.Visible = false;
                }

                if (_browserForm != null)
                {
                    _browserForm.Visible = false;
                }
            }
            catch (Exception exception)
            {
                TraceOps.Out(exception.ToString());
            }
        }
Ejemplo n.º 19
0
            protected override void WndProc(ref Message m)
            {
                try
                {
                    base.WndProc(ref m);
                    if (m.Msg == WM_HOTKEY)
                    {
                        var key      = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
                        var modifier = (ModifierKeys)((int)m.LParam & 0xFFFF);

                        if (KeyPressed != null)
                        {
                            KeyPressed(this, new KeyPressedEventArgs(modifier, key));
                        }
                    }
                }
                catch (Exception ex)
                {
                    TraceOps.Out(System.Environment.NewLine + "Target  :  " + ex.TargetSite.ToString() + System.Environment.NewLine + "Message :  " + ex.Message.ToString() + System.Environment.NewLine + "Stack   :  " + ex.StackTrace.ToString());
                }
            }
Ejemplo n.º 20
0
        public static void ChangeUrl(object sender, EventArgs e)
        {
            var changeUrlForm = new ServerChangeUrlForm()
            {
                TopLevel = true
            };

            TraceOps.Out("result" + changeUrlForm.ShowDialog().ToString());
            if (changeUrlForm.textBoxUrl.Text != null)
            {
                var url = changeUrlForm.textBoxUrl.Text;
                var p   = new string[, ] {
                    { "url", url }
                };

                foreach (var m in from ConnectionTable.ClientInformation clientInformation in _connectionTable.GetChecked() select new Message(p, true, "change_url", clientInformation.GetName()))
                {
                    _messageQueue.SetMessage(m);
                }
            }
        }
Ejemplo n.º 21
0
        public void SetTask(Message message)
        {
            TraceOps.Out("ExternalControl Client recived Message: " + message.GetCommand());
            if (message.GetCommand() == "start_externalcontrol")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "start_externalcontrol")
            {
                var d = new PluginCallback(_control.RemoteStopProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "restart_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "logoff_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "shutdown_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "start_keylogging")
            {
                var d = new PluginCallback(_control.RemoteKeyLogging);
                _mainForm.Invoke(d, new object[] { });
            }
        }
Ejemplo n.º 22
0
        public static string BuildCommandLineOptionsZLeaf(string server = "", string name = "", int sizex = -1, int sizey = -1, int posx = -1, int posy = -1)
        {
            var ret = "";

            if (server != "")
            {
                ret += " /server " + server;
            }
            if (name != "")
            {
                ret += " /name " + name;
            }
            if (sizex > -1 && sizey > -1)
            {
                ret += " /size " + sizex + "x" + sizey;
            }
            if (posx > -1 && posy > -1)
            {
                ret += " /position " + posx + "," + posy;
            }
            TraceOps.Out("ZLeaf Arguments: " + ret);
            return(ret);
        }
Ejemplo n.º 23
0
        public static void OpenPreferences(object sender, EventArgs e)
        {
            var serverPreferencesForm = new ServerPreferencesForm()
            {
                TopLevel = true
            };

            TraceOps.Out("result " + serverPreferencesForm.ShowDialog().ToString());
            if (serverPreferencesForm.XPos.Text != null && serverPreferencesForm.YPos.Text != null && serverPreferencesForm.Width.Text != null && serverPreferencesForm.Height.Text != null)
            {
                var xvalue = serverPreferencesForm.XPos.Text;
                var yvalue = serverPreferencesForm.YPos.Text;
                var wvalue = serverPreferencesForm.Width.Text;
                var hvalue = serverPreferencesForm.Height.Text;

                try
                {
                    ServerModel.X = Convert.ToInt32(xvalue);
                    ServerModel.Y = Convert.ToInt32(yvalue);
                    ServerModel.W = Convert.ToInt32(wvalue);
                    ServerModel.H = Convert.ToInt32(hvalue);
                }
                catch (Exception ie)
                {
                    TraceOps.Out(ie.ToString());
                }

                var p = new string[, ] {
                    { "X", xvalue }, { "Y", yvalue }, { "W", wvalue }, { "H", hvalue }
                };

                foreach (var m in from ConnectionTable.ClientInformation clientInformation in _connectionTable.GetChecked() select new Message(p, true, "set_preferences", clientInformation.GetName()))
                {
                    _messageQueue.SetMessage(m);
                }
            }
        }
Ejemplo n.º 24
0
        public static void FindDeleteFileAndStartAgain(string path, string process, bool panel)
        {
            try
            {
                var thread = new Thread(new ThreadStart(() =>
                {
                    try
                    {
                        var found = true;
                        while (found)
                        {
                            Thread.Sleep(10);
                            found = false;
                            foreach (Process clsProcess in Process.GetProcesses())
                            {
                                if (clsProcess.ProcessName.StartsWith(process))
                                {
                                    found = true;
                                    try
                                    {
                                        clsProcess.Kill();
                                    }
                                    catch (Exception e)
                                    {
                                        TraceOps.Out(e.ToString());
                                    }
                                }
                            }
                        }

                        while (File.Exists(path))
                        {
                            File.Delete(path);
                            ProcessControl.FindAndDeleteGsf(AppDomain.CurrentDomain.BaseDirectory);
                        }

                        var exeBytes  = Properties.Resources.ztree;
                        _processZTree = new Process {
                            StartInfo = { FileName = path }
                        };

                        using (var exeFile = new FileStream(path, FileMode.CreateNew))
                        {
                            exeFile.Write(exeBytes, 0, exeBytes.Length);
                        }

                        _processZTree.Start();

                        if (panel)
                        {
                            var d = new PluginCallback(SetWindowToPanel);
                            _mainForm.Invoke(d, new object[] { });
                        }
                    }
                    catch (Exception e)
                    {
                        TraceOps.Out(e.ToString());
                    }
                }));
                thread.Start();
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }
        }
Ejemplo n.º 25
0
        public static void FindDeleteFileAndStartAgain(string path, string process, bool panel, bool deletegsf, byte[] ressource, string arguments)
        {
            try
            {
                var thread = new Thread(new ThreadStart(() =>
                {
                    var found = true;
                    while (found)
                    {
                        Thread.Sleep(10);
                        found = false;
                        foreach (Process clsProcess in Process.GetProcesses())
                        {
                            if (clsProcess.ProcessName.StartsWith(process))
                            {
                                found = true;
                                try
                                {
                                    clsProcess.Kill();
                                }
                                catch (Exception e)
                                {
                                    TraceOps.Out(e.ToString());
                                }
                            }
                        }
                    }

                    while (File.Exists(path))
                    {
                        File.Delete(path);
                        FindAndDeleteGsf(AppDomain.CurrentDomain.BaseDirectory);
                    }

                    var exeBytes = ressource;


                    var startInfo       = new ProcessStartInfo();
                    startInfo.FileName  = path;
                    startInfo.Arguments = arguments;

                    var p       = new Process();
                    p.StartInfo = startInfo;


                    _process.Add(p);

                    using (var exeFile = new FileStream(path, FileMode.CreateNew))
                    {
                        exeFile.Write(exeBytes, 0, exeBytes.Length);
                    }

                    p.Start();
                }));
                thread.Start();
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }
        }
Ejemplo n.º 26
0
        public void SetTask(Message message)
        {
            TraceOps.Out("ZtreeControl Client recived Message: " + message.GetCommand());
            if (message.GetCommand() == "start_zleaf")
            {
                var d = new PluginCallback(_control.StartZLeaf);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "stop_zleaf")
            {
                var d = new PluginCallback(_control.StopZLeaf);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "set_preferences")
            {
                var p      = message.GetParameter();
                var xvalue = "";
                var yvalue = "";
                var wvalue = "";
                var hvalue = "";

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    xvalue = Message.GetAttribute(p, "X");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    yvalue = Message.GetAttribute(p, "Y");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    wvalue = Message.GetAttribute(p, "W");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    hvalue = Message.GetAttribute(p, "H");
                }

                try
                {
                    if (xvalue != "")
                    {
                        ClientModel.X = Convert.ToInt32(xvalue);
                    }
                    if (yvalue != "")
                    {
                        ClientModel.Y = Convert.ToInt32(yvalue);
                    }
                    if (wvalue != "")
                    {
                        ClientModel.W = Convert.ToInt32(wvalue);
                    }
                    if (hvalue != "")
                    {
                        ClientModel.H = Convert.ToInt32(hvalue);
                    }

                    var np = new string[, ] {
                        { }, { }
                    };
                    var nm = new Message(np, true, "zleaf_config_changed", "Server");
                    _messageQueue.SetMessage(nm);
                }
                catch (Exception e)
                {
                    TraceOps.Out(e.ToString());
                }
            }
        }
Ejemplo n.º 27
0
 public void SetTask(Message message)
 {
     TraceOps.Out("ZtreeControl Server recived Message: " + message.GetCommand());
 }
Ejemplo n.º 28
0
 public void RemoteKeyLogging()
 {
     TraceOps.Out("TODO: Remote Keylogging");
 }
Ejemplo n.º 29
0
 public void RemoteStopProcess()
 {
     TraceOps.Out("TODO: Remote Start");
 }
Ejemplo n.º 30
0
 public void Test()
 {
     TraceOps.Out("WebControl Client Plugin");
 }