static void Main() { try { Log.Main.Inform("Application version: " + AssemblyRoutines.GetAppVersion()); string m = "Appication 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 + ")"); ServiceBase.Run(new Service()); } catch (Exception e) { Log.Main.Error(e); } }
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); } }
static public string GetUserName() { return(WindowsUserRoutines.GetCurrentUserName3()); }
public static void Start(string arguments) { if (mpeg_stream_process != null) { Log.Main.Warning("The previous MpegStream was not stopped!"); } Stop(); if (string.IsNullOrWhiteSpace(Settings.General.CapturedMonitorDeviceName)) { Settings.General.CapturedMonitorDeviceName = MonitorRoutines.GetDefaultMonitorName(); if (string.IsNullOrWhiteSpace(Settings.General.CapturedMonitorDeviceName)) { throw new Exception("No monitor was found."); } } WinApi.User32.RECT?an = MonitorRoutines.GetMonitorAreaByMonitorName(Settings.General.CapturedMonitorDeviceName); if (an == null) { Settings.General.CapturedMonitorDeviceName = MonitorRoutines.GetDefaultMonitorName(); Log.Main.Warning("Monitor '" + Settings.General.CapturedMonitorDeviceName + "' was not found. Using default one '" + Settings.General.CapturedMonitorDeviceName + "'"); an = MonitorRoutines.GetMonitorAreaByMonitorName(Settings.General.CapturedMonitorDeviceName); if (an == null) { throw new Exception("Monitor '" + Settings.General.CapturedMonitorDeviceName + "' was not found."); } } WinApi.User32.RECT a = (WinApi.User32.RECT)an; string source = " -offset_x " + a.Left + " -offset_y " + a.Top + " -video_size " + (a.Right - a.Left) + "x" + (a.Bottom - a.Top) + " -show_region 1 -i desktop "; arguments = Regex.Replace(arguments, @"-framerate\s+\d+", "$0" + source); commandLine = "ffmpeg.exe " + arguments; Log.Main.Inform("Launching:\r\n" + commandLine); mpeg_stream_process = new Process() { //EnableRaisingEvents = true, }; mpeg_stream_process.StartInfo = new ProcessStartInfo("ffmpeg.exe", arguments) { ErrorDialog = false, UseShellExecute = false, CreateNoWindow = !Settings.General.ShowMpegWindow, //WindowStyle = ProcessWindowStyle.Hidden, }; if (Settings.General.WriteMpegOutput2Log) { mpeg_stream_process.StartInfo.RedirectStandardOutput = true; mpeg_stream_process.StartInfo.RedirectStandardError = true; string file0 = Log.WorkDir + "\\ffmpeg_" + DateTime.Now.ToString("yyMMddHHmmss"); string file = file0; for (int count = 1; File.Exists(file); count++) { file = file0 + "_" + count.ToString(); } file += ".log"; TextWriter tw = new StreamWriter(file, false); tw.WriteLine("STARTED: " + DateTime.Now.ToString()); tw.WriteLine(">" + commandLine); tw.WriteLine("\r\n"); tw.Flush(); mpeg_stream_process.OutputDataReceived += (object sender, DataReceivedEventArgs e) => { lock (tw) { tw.WriteLine(e.Data); tw.Flush(); } }; mpeg_stream_process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => { lock (tw) { //tw.WriteLine("ERROR: " + e.Data);//ffmpeg all the data sends to Error tw.WriteLine(e.Data); tw.Flush(); } }; } if (!mpeg_stream_process.Start()) { throw new Exception("Cound not start the process: " + mpeg_stream_process.StartInfo.FileName + " " + mpeg_stream_process.StartInfo.Arguments); } if (Settings.General.WriteMpegOutput2Log) { mpeg_stream_process.BeginOutputReadLine(); mpeg_stream_process.BeginErrorReadLine(); } if (!WindowsUserRoutines.CurrentUserIsAdministrator()) { throw new Exception("!CurrentUserIsAdministrator. User's name: " + WindowsUserRoutines.GetCurrentUserName3()); } ProcessRoutines.AntiZombieTracker.This.Track(mpeg_stream_process); }