private static void Main(string[] args)
        {
            new LocalizedString("Workaround for bug # 72378");
            int num = Privileges.RemoveAllExcept(AssistantsService.requiredPrivileges);

            if (num != 0)
            {
                Environment.Exit(num);
            }
            ExWatson.Register();
            ExWatson.RegisterReportAction(new WatsonRegKeyReportAction("HKLM\\SYSTEM\\CurrentControlSet\\Services\\MSExchangeIS\\ImagePath"), WatsonActionScope.Process);
            AssistantsService.ReadRegParams();
            Globals.InitializeMultiPerfCounterInstance("MSExchMbxAsst");
            ResourceHealthMonitorManager.Initialize(ResourceHealthComponent.Assistants);
            AssistantsService service = new AssistantsService();

            if (Environment.UserInteractive && args.Length >= 1 && string.Compare(args[0], "-crash", true) == 0)
            {
                throw new Exception("Startup crash to test ExWatson stuff");
            }
            if (Environment.UserInteractive && args.Length >= 1 && string.Compare(args[0], "-console", true) == 0)
            {
                AssistantsService.TracerPfd.TracePfd <int>(3L, "PFD IWS {0} Starting the Mailbox Assistants Service in Console Mode", 28055);
                ExServiceBase.RunAsConsole(service);
                return;
            }
            ServiceBase.Run(service);
        }
        // Token: 0x06000014 RID: 20 RVA: 0x0000236C File Offset: 0x0000056C
        private static int MainInternal(string[] args)
        {
            string userName = Environment.UserName;

            DagMgmtService.Tracer.TraceDebug <string>(0L, "Running as {0}", userName);
            int num = Privileges.RemoveAllExcept(DagMgmtService.requiredPrivileges);

            if (num != 0)
            {
                return(num);
            }
            Globals.InitializeSinglePerfCounterInstance();
            bool flag  = !DagMgmtService.IsRunningAsService();
            bool flag2 = false;
            bool flag3 = false;

            foreach (string text in args)
            {
                if (DagMgmtService.IsArgumentEqual(text, "-wait"))
                {
                    flag3 = true;
                }
                else
                {
                    DagMgmtService.ReportError("Invalid option specified :{0}\n", new object[]
                    {
                        text
                    });
                    flag2 = true;
                }
            }
            if (flag2)
            {
                DagMgmtService.Tracer.TraceError(0L, "Invalid argument specified. Exiting process.");
                return(1);
            }
            if (flag)
            {
                DagMgmtService.Tracer.TraceDebug <string, DateTime>(0L, "{0} Service starting in console mode at {1}", DagMgmtService.serviceName, DateTime.UtcNow);
                Console.WriteLine("Starting {0}, running in console mode.", Assembly.GetExecutingAssembly().GetName().Name);
                if (flag3)
                {
                    Console.WriteLine("Press <ENTER> to continue.");
                    Console.ReadLine();
                }
                ExServiceBase.RunAsConsole(new DagMgmtService(flag));
            }
            else
            {
                ServiceBase.Run(new DagMgmtService(flag));
            }
            return(0);
        }
        // Token: 0x0600000E RID: 14 RVA: 0x00002CA0 File Offset: 0x00000EA0
        private static void RunConsole()
        {
            Console.WriteLine("Starting {0}, running in console mode.", AntispamUpdateSvc.GetAssemblyName());
            if (AntispamUpdateSvc.waitToContinue)
            {
                Console.WriteLine("Press ENTER to continue startup.");
                Console.ReadLine();
            }
            AntispamUpdateSvc service = new AntispamUpdateSvc();

            ExServiceBase.RunAsConsole(service);
        }
        // Token: 0x06000010 RID: 16 RVA: 0x00002290 File Offset: 0x00000490
        public static void Main(string[] args)
        {
            bool flag  = false;
            bool flag2 = false;

            foreach (string text in args)
            {
                if (text.StartsWith("-?", StringComparison.Ordinal))
                {
                    FrontEndTransportService.Usage();
                    Environment.Exit(0);
                }
                else if (text.StartsWith("-console"))
                {
                    flag = true;
                }
                else if (text.StartsWith("-wait"))
                {
                    flag2 = true;
                }
            }
            FrontEndTransportService.runningAsService = !Environment.UserInteractive;
            if (!FrontEndTransportService.runningAsService)
            {
                if (!flag)
                {
                    FrontEndTransportService.Usage();
                    Environment.Exit(0);
                }
                Console.WriteLine("Starting {0}, running in console mode.", Assembly.GetExecutingAssembly().GetName().Name);
                if (flag2)
                {
                    Console.WriteLine("Press ENTER to continue.");
                    Console.ReadLine();
                }
            }
            Globals.InitializeSinglePerfCounterInstance();
            ExWatson.Register();
            string text2;

            if (!Components.TryLoadTransportAppConfig(out text2))
            {
                Environment.Exit(1);
            }
            SettingOverrideSync.Instance.Start(true);
            FrontEndTransportService.instance = new FrontEndTransportService();
            if (FrontEndTransportService.runningAsService)
            {
                ServiceBase.Run(FrontEndTransportService.instance);
                return;
            }
            ExServiceBase.RunAsConsole(FrontEndTransportService.instance);
        }
        // Token: 0x06000003 RID: 3 RVA: 0x00002160 File Offset: 0x00000360
        public static void Main(string[] args)
        {
            ExWatson.Register();
            Globals.InitializeMultiPerfCounterInstance("MSExchMbxRepl");
            MailboxReplicationServiceImpl.runningAsService = !Environment.UserInteractive;
            bool flag  = false;
            bool flag2 = false;

            foreach (string text in args)
            {
                if (text.StartsWith("-?", StringComparison.Ordinal))
                {
                    MailboxReplicationServiceImpl.Usage();
                    Environment.Exit(0);
                }
                else if (text.StartsWith("-console"))
                {
                    flag = true;
                }
                else if (text.StartsWith("-wait"))
                {
                    flag2 = true;
                }
            }
            if (!MailboxReplicationServiceImpl.runningAsService)
            {
                if (!flag)
                {
                    MailboxReplicationServiceImpl.Usage();
                    Environment.Exit(0);
                }
                Console.WriteLine("Starting {0}, running in console mode.", Assembly.GetExecutingAssembly().GetName().Name);
                if (flag2)
                {
                    Console.WriteLine("Press ENTER to continue.");
                    Console.ReadLine();
                }
            }
            MailboxReplicationServiceImpl.instance = new MailboxReplicationServiceImpl();
            if (!MailboxReplicationServiceImpl.runningAsService)
            {
                ExServiceBase.RunAsConsole(MailboxReplicationServiceImpl.instance);
                return;
            }
            ServiceBase.Run(MailboxReplicationServiceImpl.instance);
        }
        // Token: 0x0600000E RID: 14 RVA: 0x000022C0 File Offset: 0x000004C0
        public static void Main(string[] args)
        {
            CommonDiagnosticsLog.Initialize(HostId.MailboxTransportSubmissionService);
            MailboxTransportSubmissionService.LogStage(MailboxTransportSubmissionService.Stage.StartProcess);
            int num = Privileges.RemoveAllExcept(new string[]
            {
                "SeAuditPrivilege",
                "SeChangeNotifyPrivilege",
                "SeCreateGlobalPrivilege"
            });

            if (num != 0)
            {
                Environment.Exit(num);
            }
            MailboxTransportSubmissionService.LogStage(MailboxTransportSubmissionService.Stage.RegisterWatson);
            ExWatson.Register();
            MailboxTransportSubmissionService.LogStage(MailboxTransportSubmissionService.Stage.RegisterWatsonAction);
            ExWatson.RegisterReportAction(new WatsonRegKeyReportAction(MailboxTransportSubmissionService.watsonRegKeyReportActionString), WatsonActionScope.Process);
            MailboxTransportSubmissionService.runningAsService = !Environment.UserInteractive;
            bool flag  = false;
            bool flag2 = false;

            foreach (string text in args)
            {
                if (text.StartsWith("-?", StringComparison.Ordinal))
                {
                    MailboxTransportSubmissionService.Usage();
                    Environment.Exit(0);
                }
                else if (text.StartsWith("-console"))
                {
                    flag = true;
                }
                else if (text.StartsWith("-wait"))
                {
                    flag2 = true;
                }
            }
            if (!MailboxTransportSubmissionService.runningAsService)
            {
                if (!flag)
                {
                    MailboxTransportSubmissionService.Usage();
                    Environment.Exit(0);
                }
                Console.WriteLine("Starting {0}, running in console mode.", Assembly.GetExecutingAssembly().GetName().Name);
                if (flag2)
                {
                    Console.WriteLine("Press ENTER to continue.");
                    Console.ReadLine();
                }
            }
            MailboxTransportSubmissionService.LogStage(MailboxTransportSubmissionService.Stage.InitializePerformanceCounterInstance);
            Globals.InitializeSinglePerfCounterInstance();
            SettingOverrideSync.Instance.Start(true);
            MailboxTransportSubmissionService.LogStage(MailboxTransportSubmissionService.Stage.LoadLatencyTrackerConfiguration);
            try
            {
                LatencyTracker.Configuration = TransportAppConfig.LatencyTrackerConfig.Load();
            }
            catch (ConfigurationErrorsException)
            {
            }
            MailboxTransportSubmissionService.LogStage(MailboxTransportSubmissionService.Stage.LoadTransportAppConfig);
            string text2;

            if (!Components.TryLoadTransportAppConfig(out text2))
            {
                MailboxTransportSubmissionEventLogger.LogEvent(MSExchangeSubmissionEventLogConstants.Tuple_SubmissionServiceStartFailure, null, new object[]
                {
                    text2
                });
                Environment.Exit(1);
            }
            MailboxTransportSubmissionService.LogStage(MailboxTransportSubmissionService.Stage.CreateService);
            MailboxTransportSubmissionService.mailboxTransportSubmissionService = new MailboxTransportSubmissionService();
            MailboxTransportSubmissionService.LogStage(MailboxTransportSubmissionService.Stage.RunService);
            if (!MailboxTransportSubmissionService.runningAsService)
            {
                ExServiceBase.RunAsConsole(MailboxTransportSubmissionService.mailboxTransportSubmissionService);
                return;
            }
            ServiceBase.Run(MailboxTransportSubmissionService.mailboxTransportSubmissionService);
        }
Exemple #7
0
        // Token: 0x0600002F RID: 47 RVA: 0x00002CA0 File Offset: 0x00000EA0
        public static void Main(string[] args)
        {
            ThrottlingService.StartStopBreadcrumbs.Drop("Execution began", new object[0]);
            int num = Privileges.RemoveAllExcept(new string[]
            {
                "SeAuditPrivilege",
                "SeChangeNotifyPrivilege",
                "SeCreateGlobalPrivilege"
            });

            if (num != 0)
            {
                ThrottlingService.StartStopBreadcrumbs.Drop("Failed to remove excessive privileges; Win32 error: {0}", new object[]
                {
                    num
                });
                ThrottlingService.tracer.TraceError <int>(0L, "Failed to remove excessive privileges; Win32 error: {0}", num);
                ThrottlingService.eventLogger.LogEvent(ThrottlingServiceEventLogConstants.Tuple_RemovePrivilegesFailure, null, new object[]
                {
                    num
                });
                Environment.Exit(num);
            }
            ExWatson.Register();
            ThrottlingService.runningAsService = !Environment.UserInteractive;
            Globals.InitializeSinglePerfCounterInstance();
            bool flag  = false;
            bool flag2 = false;

            foreach (string text in args)
            {
                if (text.StartsWith("-?", StringComparison.Ordinal))
                {
                    ThrottlingService.Usage();
                    Environment.Exit(0);
                }
                else if (text.StartsWith("-console"))
                {
                    flag = true;
                }
                else if (text.StartsWith("-wait"))
                {
                    flag2 = true;
                }
            }
            ThrottlingService.StartStopBreadcrumbs.Drop("runningAsService={0}", new object[]
            {
                ThrottlingService.runningAsService
            });
            if (!ThrottlingService.runningAsService)
            {
                if (!flag)
                {
                    ThrottlingService.Usage();
                    ThrottlingService.StartStopBreadcrumbs.Drop("Usage shown", new object[0]);
                    Environment.Exit(0);
                }
                Console.WriteLine("Starting {0}, running in console mode.", Assembly.GetExecutingAssembly().GetName().Name);
                if (flag2)
                {
                    ThrottlingService.StartStopBreadcrumbs.Drop("Waiting for user input to proceed with initialization", new object[0]);
                    Console.WriteLine("Press ENTER to continue.");
                    Console.ReadLine();
                }
            }
            ThrottlingService.instance = new ThrottlingService();
            if (!ThrottlingService.runningAsService)
            {
                ExServiceBase.RunAsConsole(ThrottlingService.instance);
            }
            else
            {
                ServiceBase.Run(ThrottlingService.instance);
            }
            ThrottlingService.StartStopBreadcrumbs.Drop("Execution ended", new object[0]);
        }