Example #1
0
        /// <summary>
        /// This is the main entry point for the SHRD host service.
        /// </summary>
        /// <param name="args"></param>
        public static void Run(string[] args)
        {
            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            Globals.InitializeProgram(exePath, "Self Hosted Remote Desktop", true);
            PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "SHRD_Log.txt");

            FileInfo fiExe = new FileInfo(exePath);

            Environment.CurrentDirectory = fiExe.Directory.FullName;

            System.Windows.Forms.Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException       += CurrentDomain_UnhandledException;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            //byte[] buf = new byte[4];
            //ByteUtil.WriteFloat(5, buf, 0);
            //float f = ByteUtil.ReadFloat(buf, 0);
            //Logger.Info(f.ToString());

            if (Environment.UserInteractive)
            {
                bool cmd = args.Length > 0 && args[0] == "cmd";
                if (cmd || Debugger.IsAttached)
                {
                    BPUtil.NativeWin.WinConsole.Initialize();
                    Logger.logType = LoggingMode.Console | LoggingMode.File;
                    Logger.Info("Console environment detected. Logging to console is enabled.");
                    ServiceWrapper.Initialize();
                    ServiceWrapper.Start();
                    do
                    {
                        Console.WriteLine("Type \"exit\" to close");
                    }while (Console.ReadLine().ToLower() != "exit");
                    ServiceWrapper.Stop();
                    return;
                }
                else
                {
                    Logger.logType = LoggingMode.File;
                }

                string             Title           = "SelfHostedRemoteDesktop " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager";
                string             ServiceName     = "SelfHostedRemoteDesktop";
                ButtonDefinition   btnStartCmdTest = new ButtonDefinition("Test w/console", btnStartCmdTest_Click);
                ButtonDefinition[] customButtons   = new ButtonDefinition[] { btnStartCmdTest };

                System.Windows.Forms.Application.Run(new ServiceManager(Title, ServiceName, customButtons));
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new SelfHostedRemoteDesktopSvc()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Example #2
0
        static void Main()
        {
            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            Globals.Initialize(exePath);
            PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "Advisor_Log.txt");

            FileInfo fiExe = new FileInfo(exePath);

            Environment.CurrentDirectory = fiExe.Directory.FullName;

            settings = new AdvisorSettings();
            settings.Load();
            if (string.IsNullOrWhiteSpace(settings.secret))
            {
                settings.secret = Hash.GetSHA256Hex(Guid.NewGuid().ToString());
                settings.Save();
            }
            settings.SaveIfNoExist();

            RegistryUtil.Force32BitRegistryAccess = settings.bi32OnWin64;

            AutoFixBad32BitSetting();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Example #3
0
        public static void MainMethod()
        {
            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            Globals.Initialize(exePath);
            PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "MJpegCameraErrors.txt");

            if (Environment.UserInteractive)
            {
                string             Title         = "CameraProxy " + CameraProxyGlobals.Version + " Service Manager";
                string             ServiceName   = "MJpegCameraProxy";
                ButtonDefinition   btnCmd        = new ButtonDefinition("Command Line Test", btnCmd_Click);
                ButtonDefinition[] customButtons = new ButtonDefinition[] { btnCmd };

                Application.Run(new ServiceManager(Title, ServiceName, customButtons));
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new CameraProxyService()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Example #4
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            Globals.Initialize(Application.ExecutablePath);
            PrivateAccessor.SetStaticFieldValue(typeof(Globals), "configFilePath", Globals.WritableDirectoryBase + "IpCameraSpeedometerSettings.xml");

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            if (Environment.UserInteractive)
            {
                ServiceWrapper.settings.SaveIfNoExist(Globals.ConfigFilePath);
                string           Title            = "IpCameraSpeedometer " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager";
                ButtonDefinition btnConfiguration = new ButtonDefinition("Configuration", btnConfiguration_Click);
                ServiceManager   serviceManager   = new ServiceManager(Title, ServiceWrapper.settings.ServiceName, new ButtonDefinition[] { btnConfiguration }, new ServiceName(ServiceWrapper.settings.ServiceName, ServiceNameChange));
                Application.Run(serviceManager);
                while (ServiceWrapper.restartServiceManager)
                {
                    ServiceWrapper.restartServiceManager = false;
                    serviceManager = new ServiceManager(Title, ServiceWrapper.settings.ServiceName, new ButtonDefinition[] { btnConfiguration }, new ServiceName(ServiceWrapper.settings.ServiceName, ServiceNameChange));
                    Application.Run(serviceManager);
                }
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new IpCameraSpeedometer()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Example #5
0
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		static void Main()
		{
			string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
			Globals.Initialize(exePath);
			PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "BiUpdateHelper_Log.txt");

			FileInfo fiExe = new FileInfo(exePath);
			Environment.CurrentDirectory = fiExe.Directory.FullName;

			settings = new BiUpdateHelperSettings();
			settings.Load();
			if (string.IsNullOrWhiteSpace(settings.secret))
			{
				settings.secret = Hash.GetSHA256Hex(Guid.NewGuid().ToString());
				settings.Save();
			}
			settings.SaveIfNoExist();

			RegistryUtil.Force32BitRegistryAccess = settings.bi32OnWin64;

			AutoFixBad32BitSetting();

			PerformanceData.PerformanceDataCollector.onReportUploaded = () =>
			{
				settings.Load();
				settings.lastUsageReportAt = TimeUtil.GetTimeInMsSinceEpoch();
				settings.Save();
			};
			PerformanceData.PerformanceDataCollector.getSecretString = () =>
			{
				return Program.settings.secret;
			};

			if (Environment.UserInteractive)
			{
				string Title = "BiUpdateHelper " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager";
				string ServiceName = "BiUpdateHelper";
				ButtonDefinition btnRegKey = new ButtonDefinition("BI Registration Info", btnRegkey_Click);
				ButtonDefinition btnSettings = new ButtonDefinition("Edit Service Settings", btnSettings_Click);
				ButtonDefinition btnCameraConfigLinks = new ButtonDefinition("Camera Config Links", btnCameraConfigLinks_Click);
				ButtonDefinition btnRegistryBackupNow = new ButtonDefinition("Take Registry Backup Now", btnRegistryBackupNow_Click);
				ButtonDefinition btnPerfData = new ButtonDefinition("Performance Data", btnPerfData_Click);
				ButtonDefinition[] customButtons = new ButtonDefinition[] { btnRegKey, btnSettings, btnCameraConfigLinks, btnRegistryBackupNow, btnPerfData };

				System.Windows.Forms.Application.Run(new ServiceManager(Title, ServiceName, customButtons));
			}
			else
			{
				ServiceBase[] ServicesToRun;
				ServicesToRun = new ServiceBase[]
				{
					new MainSvc()
				};
				ServiceBase.Run(ServicesToRun);
			}
		}
Example #6
0
        public MJpegWrapper()
        {
            if (Environment.UserInteractive)
            {
                Logger.logType = LoggingMode.Console | LoggingMode.File;
            }
            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            Globals.Initialize(exePath);
            PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "MJpegCameraErrors.txt");

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            System.Net.ServicePointManager.Expect100Continue      = false;
            System.Net.ServicePointManager.DefaultConnectionLimit = 640;

            cfg = new ProxyConfig();
            if (File.Exists(CameraProxyGlobals.ConfigFilePath))
            {
                cfg.Load(CameraProxyGlobals.ConfigFilePath);
            }
            else
            {
                if (cfg.users.Count == 0)
                {
                    cfg.users.Add(new User("admin", "admin", 100));
                }
                cfg.Save(CameraProxyGlobals.ConfigFilePath);
            }
            SimpleHttpLogger.RegisterLogger(Logger.httpLogger);
            bool killed = false;

            try
            {
                foreach (var process in Process.GetProcessesByName("live555ProxyServer"))
                {
                    try
                    {
                        process.Kill();
                        killed = true;
                    }
                    catch (Exception ex)
                    {
                        Logger.Debug(ex, "Trying to kill existing live555ProxyServer process");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Debug(ex, "Trying to iterate through existing live555ProxyServer processes");
            }
            if (killed)
            {
                Thread.Sleep(500);
            }
        }
Example #7
0
        static void Main(string[] args)
        {
            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            Globals.Initialize(exePath);
            PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "GWS_Log.txt");

            FileInfo fiExe = new FileInfo(exePath);

            Environment.CurrentDirectory = fiExe.Directory.FullName;

            settings = new Settings();
            settings.Load();
            settings.SaveIfNoExist();

            db = new DB();

            if (Environment.UserInteractive)
            {
                string             Title             = "GeolocationWebService " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager";
                string             ServiceName       = "GeolocationWebService";
                ButtonDefinition[] additionalButtons = new ButtonDefinition[] {
                    new ButtonDefinition("Setup", btnImportGeolocationData_Click),
                    new ButtonDefinition("Open Web Interface", btnOpenWebInterface_Click)
                };

                if (Debugger.IsAttached)
                {
                    debugService = new GeolocationService();
                    debugService.DoStart();
                }

                System.Windows.Forms.Application.Run(new ServiceManager(Title, ServiceName, additionalButtons));

                debugService?.DoStop();
            }
            else
            {
                GeolocationService[] ServicesToRun;
                ServicesToRun = new GeolocationService[]
                {
                    new GeolocationService()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Example #8
0
        /// <summary>
        /// This is the main entry point for the SHRD streamer.
        /// </summary>
        /// <param name="args"></param>
        public static void Run(string[] args)
        {
            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            Globals.InitializeProgram(exePath, "Self Hosted Remote Desktop", true);
            PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "SHRD_Streamer_Log.txt");

            Logger.logType = LoggingMode.File;
            Logger.Info("SHRDStreamer Startup");

            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ApplicationExit += Application_ApplicationExit;
            Microsoft.Win32.SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;

            desktopInfo = DxgiOutputDuplicator.GetDesktopInfo();

            streamerArgs = new StreamerArgs(args);

            thrMain              = new Thread(mainThreadRunner);
            thrMain.Name         = "Streamer Main";
            thrMain.IsBackground = true;
            thrMain.Start();

            thrDesktopCapture = new Thread(desktopCaptureThreadRunner);
            thrDesktopCapture.SetApartmentState(ApartmentState.MTA);
            thrDesktopCapture.Name         = "Desktop Capture";
            thrDesktopCapture.IsBackground = true;
            // thrDesktopCapture is started by thrMain after static_sm is set.

            if (streamerArgs.ServiceProcessId != null)
            {
                service_process                = Process.GetProcessById(streamerArgs.ServiceProcessId.Value);
                thrMonitorService              = new Thread(monitoringThreadRunner);
                thrMonitorService.Name         = "Monitoring Service";
                thrMonitorService.IsBackground = true;
                thrMonitorService.Start();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
            //Application.Run();
        }
Example #9
0
 /// <summary>
 /// Call this to initialize global static variables.
 /// </summary>
 /// <param name="exePath">Pass in the path to the exe in the root directory of the application.  The directory must exist, but the exe name can just be a descriptive exe file name like "My Application.exe" and does not need to exist.</param>
 public static void Initialize(string exePath)
 {
     Globals.Initialize(exePath, "Images/writabledir/");
     PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "TimelapseErrors.txt");
 }