// Token: 0x06000007 RID: 7 RVA: 0x00002504 File Offset: 0x00000704
 protected override bool Initialize()
 {
     try
     {
         MonitoringService.LogDiagnosticInfo("Flushing Kerberos ticket cache.", new object[0]);
         Kerberos.FlushTicketCache();
     }
     catch (Win32Exception ex)
     {
         MonitoringService.LogDiagnosticInfo("Caught Win32Exception: {0}", new object[]
         {
             ex.ToString()
         });
         if (ex.ErrorCode == -2146232828)
         {
             return(false);
         }
         throw;
     }
     return(base.Initialize());
 }
        // Token: 0x06000006 RID: 6 RVA: 0x00002400 File Offset: 0x00000600
        protected override void OnStartInternal(string[] args)
        {
            MonitoringService.LogDiagnosticInfo("Starting the Active Monitoring RPC server", new object[0]);
            ExTraceGlobals.ServiceTracer.TraceDebug(0L, "Starting RPC server");
            bool flag = false;

            foreach (string text in args)
            {
                if (text.StartsWith("-NoWorker", StringComparison.OrdinalIgnoreCase))
                {
                    flag = true;
                }
            }
            try
            {
                MonitoringService.ConfigureRpc();
                ActiveMonitoringRpcServer.Start(new ActiveMonitoringRpcServer.DiagnosticLogger(MonitoringService.LogDiagnosticInfo));
                this.rpcServerStarted = true;
                MonitoringService.LogDiagnosticInfo("Started the Active Monitoring RPC server successfully", new object[0]);
            }
            catch (Exception ex)
            {
                MonitoringService.LogDiagnosticInfo("Active monitoring RPC server fails to start: {0}", new object[]
                {
                    ex.Message
                });
                ExTraceGlobals.ServiceTracer.TraceError(0L, string.Format("Active monitoring RPC server fails to start: {0}", ex.Message));
                MonitoringService.logger.LogEvent(MSExchangeHMEventLogConstants.Tuple_RpcServerFailedToStart, null, new object[]
                {
                    ex.Message
                });
            }
            if (!flag)
            {
                base.OnStartInternal(args);
            }
        }
        // Token: 0x06000005 RID: 5 RVA: 0x000021B4 File Offset: 0x000003B4
        internal static void Main(string[] args)
        {
            MonitoringService.LogDiagnosticInfo("Registering for Watson.", new object[0]);
            ExWatson.Register();
            bool flag  = !Environment.UserInteractive;
            bool flag2 = false;
            bool flag3 = false;

            MonitoringService.LogDiagnosticInfo("Parsing command line args.", new object[0]);
            foreach (string text in args)
            {
                if (text.StartsWith("-?", StringComparison.OrdinalIgnoreCase))
                {
                    MonitoringService.LogDiagnosticInfo("Printing usage and exiting.", new object[0]);
                    MonitoringService.PrintUsage();
                    Environment.Exit(0);
                }
                else if (text.StartsWith("-console", StringComparison.OrdinalIgnoreCase))
                {
                    MonitoringService.LogDiagnosticInfo("Running from console.", new object[0]);
                    flag2 = true;
                }
                else if (text.StartsWith("-wait", StringComparison.OrdinalIgnoreCase))
                {
                    flag3 = true;
                }
                else if (text.StartsWith("-ForceConsole", StringComparison.OrdinalIgnoreCase))
                {
                    MonitoringService.LogDiagnosticInfo("Force running from console.", new object[0]);
                    flag  = false;
                    flag2 = true;
                }
            }
            if (!flag)
            {
                if (!flag2)
                {
                    MonitoringService.LogDiagnosticInfo("Printing usage and exiting.", new object[0]);
                    MonitoringService.PrintUsage();
                    Environment.Exit(0);
                }
                Console.WriteLine("Starting {0}, running in console mode.", Assembly.GetExecutingAssembly().GetName().Name);
                if (flag3)
                {
                    MonitoringService.LogDiagnosticInfo("Waiting for user input before continuing.", new object[0]);
                    Console.WriteLine("Press ENTER to continue.");
                    Console.ReadLine();
                }
            }
            if (!ServiceTopologyProvider.IsAdTopologyServiceInstalled())
            {
                MonitoringService.LogDiagnosticInfo("Can't use AD Topology service; setting admin mode instead.", new object[0]);
                ADSession.SetAdminTopologyMode();
            }
            MonitoringService.LogDiagnosticInfo("Initializing perf counters.", new object[0]);
            Globals.InitializeMultiPerfCounterInstance("MSExchangeHM");
            MonitoringService monitoringService = new MonitoringService(flag);

            if (!monitoringService.Initialize())
            {
                ExTraceGlobals.ServiceTracer.TraceError(0L, "Failed to initialize the service. Exiting.");
                MonitoringService.LogDiagnosticInfo("Initialization of the service failed. Stopping service and exiting.", new object[0]);
                ProcessManagerService.StopService();
            }
            if (!flag)
            {
                monitoringService.OnStartInternal(args);
                bool flag4 = false;
                while (!flag4)
                {
                    Console.WriteLine("Enter 'q' to shutdown.");
                    string text2 = Console.ReadLine();
                    if (string.IsNullOrEmpty(text2))
                    {
                        break;
                    }
                    switch (text2[0])
                    {
                    case 'q':
                        flag4 = true;
                        break;

                    case 'r':
                        monitoringService.OnCustomCommandInternal(200);
                        break;

                    case 'u':
                        monitoringService.OnCustomCommandInternal(201);
                        break;
                    }
                }
                Console.WriteLine("Shutting down ...");
                monitoringService.OnStopInternal();
                Console.WriteLine("Done.");
                return;
            }
            ServiceBase.Run(monitoringService);
        }
 // Token: 0x06000002 RID: 2 RVA: 0x00002164 File Offset: 0x00000364
 internal MonitoringService(bool runningAsService) : base("MSExchangeHM", MonitoringService.GetWorkerProcessPathName(MonitoringService.workerProcessName), MonitoringService.jobObjectName, true, 30, runningAsService, ExTraceGlobals.ServiceTracer, MonitoringService.serviceLogger)
 {
     base.CanPauseAndContinue = true;
 }