void run()
        {
            while (thread != null)
            {
                TcpMessage m = TcpMessage.Receive(stream);

                Log.Main.Inform("Tcp message received: " + m.Name + "\r\n" + m.BodyAsText);
                InfoWindow.Create("Tcp message received: " + m.Name + "\r\n" + m.BodyAsText, null, "OK", null);

                string reply = TcpMessage.Success;
                try
                {
                    switch (m.Name)
                    {
                    case TcpMessage.FfmpegStart:
                        uint sessionId = WinApi.Wts.WTSGetActiveConsoleSessionId();
                        MpegStream.Start(sessionId, m.BodyAsText);
                        break;

                    case TcpMessage.FfmpegStop:
                        MpegStream.Stop();
                        break;

                    case TcpMessage.SslStart:
                        if (stream is SslStream)
                        {
                            throw new Exception("SSL is already started.");
                        }
                        break;

                    default:
                        throw new Exception("Unknown message: " + m.Name);
                    }
                }
                catch (Exception e)
                {
                    reply = e.Message;
                }
                Log.Main.Inform("Tcp message sending: " + m.Name + "\r\n" + reply);
                m.Reply(stream, reply);
                if (m.Name == TcpMessage.SslStart && reply == TcpMessage.Success)
                {
                    startSsl();
                }
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            try
            {
                uint dwSessionId = WinApi.Wts.WTSGetActiveConsoleSessionId();
                MpegStream.Start(dwSessionId, "-f gdigrab -framerate 10 -f rtp_mpegts -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params aMg7BqN047lFN72szkezmPyN1qSMilYCXbqP/sCt srtp://127.0.0.1:5920");
                //Process mpeg_stream_process;
                //var processId = Win32Process.CreateProcessInConsoleSession("cmd");
                //mpeg_stream_process = Process.GetProcessById((int)processId);
                //ProcessRoutines.AntiZombieTracker.Track(mpeg_stream_process);

                //    try
                //    {
                //        var p = new Process();
                //        p.StartInfo.UseShellExecute = false;
                //        //const string file = "cmd.exe";
                //        const string file = @"psexec.exe";
                //        p.StartInfo.WorkingDirectory = Path.GetDirectoryName(file);
                //        p.StartInfo.FileName = Path.GetFileName(file);
                //        //proc.StartInfo.Domain = "WIN08";
                //        p.StartInfo.Arguments = "-i -d -s cmd";
                //        //p.StartInfo.UserName = "******";
                //        //var password = new System.Security.SecureString();
                //        //foreach (var c in "123")
                //        //    password.AppendChar(c);
                //        //p.StartInfo.Password = password;
                //        p.StartInfo.LoadUserProfile = false;
                //        p.Start();
                //    }
                //    catch (Exception e)
                //    {
                //        Console.WriteLine(e);
                //    }

                //MpegStream.Start("-f gdigrab -framerate 10 -f rtp_mpegts -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params aMg7BqN047lFN72szkezmPyN1qSMilYCXbqP/sCt srtp://127.0.0.1:5920");
                //Thread.Sleep(2000);
                //MpegStream.Stop();

                Log.Main.Inform("Version: " + AssemblyRoutines.GetAppVersion());
                string m = "User: "******"(";
                if (WindowsUserRoutines.CurrentUserIsAdministrator())
                {
                    m += "administrator";
                    if (WindowsUserRoutines.CurrentUserHasElevatedPrivileges())
                    {
                        m += ", elevated privileges";
                    }
                    else
                    {
                        m += ", not elevated privileges";
                    }
                }
                else
                {
                    m += "not administrator";
                }
                Log.Main.Inform(m + ")");

                ProcessRoutines.RunSingleProcessOnly();

                Service.Running = true;

                Application.Run(SysTray.This);
            }
            catch (Exception e)
            {
                Message.Error(e);
            }
            finally
            {
                Environment.Exit(0);
            }
        }