コード例 #1
0
        // Token: 0x0600000A RID: 10 RVA: 0x00002AC8 File Offset: 0x00000CC8
        private void TimeSliceThreadMain()
        {
            int             num                    = 0;
            AntispamUpdates antispamUpdates        = new AntispamUpdates();
            string          microsoftUpdateCabPath = AntispamUpdateSvc.GetMicrosoftUpdateCabPath();

            while (!this.timeSliceThreadShutdown.WaitOne(num, false))
            {
                try
                {
                    antispamUpdates.LoadConfiguration(string.Empty);
                    OptInStatus optInStatus = this.hygieneUpdate.SetMicrosoftUpdateOptinStatus(antispamUpdates.MicrosoftUpdate, microsoftUpdateCabPath);
                    if (optInStatus != antispamUpdates.MicrosoftUpdate)
                    {
                        antispamUpdates.MicrosoftUpdate = optInStatus;
                        antispamUpdates.SaveConfiguration(string.Empty);
                    }
                }
                catch (SecurityException ex)
                {
                    UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_MuOptFail, null, new string[]
                    {
                        ex.Message
                    });
                }
                catch (IOException ex2)
                {
                    UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_MuOptFail, null, new string[]
                    {
                        ex2.Message
                    });
                }
                catch (UnauthorizedAccessException ex3)
                {
                    UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_MuOptFail, null, new string[]
                    {
                        ex3.Message
                    });
                }
                if (antispamUpdates.MicrosoftUpdate == OptInStatus.Configured && antispamUpdates.UpdateMode == AntispamUpdateMode.Automatic)
                {
                    this.hygieneUpdate.DoUpdate();
                }
                num = AntispamUpdateSvc.pollInterval * 1000;
                if (this.hygieneUpdate.ConsoleDiagnostics)
                {
                    Console.WriteLine("Sleeping {0} Seconds", num / 1000);
                }
            }
        }
コード例 #2
0
        // Token: 0x0600000C RID: 12 RVA: 0x00002C28 File Offset: 0x00000E28
        protected override void OnStopInternal()
        {
            bool flag = false;

            try
            {
                this.timeSliceThreadShutdown.Set();
                this.timeSliceThread.Join();
                UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_ServiceStopSuccess, null, new string[0]);
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_ServiceStopFailure, null, new string[0]);
                }
            }
        }
コード例 #3
0
        // Token: 0x06000008 RID: 8 RVA: 0x000029C0 File Offset: 0x00000BC0
        protected override void OnStartInternal(string[] args)
        {
            bool flag = false;

            try
            {
                this.hygieneUpdate   = new HygieneUpdate(!AntispamUpdateSvc.runningAsService);
                this.timeSliceThread = new Thread(new ThreadStart(this.TimeSliceThreadMain));
                this.timeSliceThread.Start();
                UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_ServiceStartSuccess, null, new string[0]);
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_ServiceStartFailure, null, new string[0]);
                }
            }
        }
コード例 #4
0
 // Token: 0x06000003 RID: 3 RVA: 0x000020E8 File Offset: 0x000002E8
 public void DoUpdate()
 {
     if (this.ConsoleDiagnostics)
     {
         Console.WriteLine("Checking for Updates.");
     }
     try
     {
         UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_StartScan, null, new string[0]);
         IUpdateSession updateSession = new UpdateSessionClass();
         updateSession.ClientApplicationID = "Exchange12";
         IUpdateSearcher updateSearcher = updateSession.CreateUpdateSearcher();
         ISearchResult   searchResult   = updateSearcher.Search("IsInstalled=0 and CategoryIDs contains 'ab62c5bd-5539-49f6-8aea-5a114dd42314'");
         UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_StopScan, null, new string[0]);
         if (searchResult.Updates.Count == 0)
         {
             if (this.ConsoleDiagnostics)
             {
                 Console.WriteLine("No Updates.");
             }
         }
         else
         {
             foreach (object obj in searchResult.Updates)
             {
                 IUpdate update = (IUpdate)obj;
                 UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_PatchAvailable, null, new string[]
                 {
                     update.Title
                 });
                 if (this.ConsoleDiagnostics)
                 {
                     Console.WriteLine("Title: {0}", update.Title);
                 }
             }
             UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_StartDownload, null, new string[0]);
             UpdateDownloader updateDownloader = updateSession.CreateUpdateDownloader();
             updateDownloader.Priority = 3;
             updateDownloader.Updates  = searchResult.Updates;
             IDownloadResult downloadResult = updateDownloader.Download();
             UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_StopDownload, null, new string[0]);
             for (int i = 0; i < updateDownloader.Updates.Count; i++)
             {
                 if (downloadResult.GetUpdateResult(i).ResultCode == 4 || downloadResult.GetUpdateResult(i).ResultCode == 5)
                 {
                     UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_DownloadFailure, null, new string[]
                     {
                         updateDownloader.Updates[i].Title,
                         downloadResult.GetUpdateResult(i).HResult.ToString()
                     });
                     if (this.ConsoleDiagnostics)
                     {
                         Console.WriteLine("Errors: {0}: {1}", updateDownloader.Updates[i].Title, downloadResult.GetUpdateResult(i).HResult);
                     }
                 }
             }
             bool flag = false;
             foreach (object obj2 in updateDownloader.Updates)
             {
                 IUpdate update2 = (IUpdate)obj2;
                 if (update2.IsDownloaded)
                 {
                     flag = true;
                 }
             }
             if (!flag)
             {
                 if (this.ConsoleDiagnostics)
                 {
                     Console.WriteLine("Nothing to Install.");
                 }
             }
             else
             {
                 if (this.ConsoleDiagnostics)
                 {
                     Console.WriteLine("Starting Installation.");
                 }
                 UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_StartInstall, null, new string[0]);
                 IUpdateInstaller updateInstaller = updateSession.CreateUpdateInstaller();
                 updateInstaller.Updates = updateDownloader.Updates;
                 IInstallationResult installationResult = updateInstaller.Install();
                 UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_StopInstall, null, new string[0]);
                 for (int j = 0; j < updateInstaller.Updates.Count; j++)
                 {
                     IUpdate update3 = updateInstaller.Updates[j];
                     if (installationResult.GetUpdateResult(j).ResultCode == 4 || installationResult.GetUpdateResult(j).ResultCode == 3)
                     {
                         UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_InstallFailure, null, new string[]
                         {
                             updateInstaller.Updates[j].Title,
                             installationResult.GetUpdateResult(j).HResult.ToString()
                         });
                         if (this.ConsoleDiagnostics)
                         {
                             Console.WriteLine("Errors: {0}: {1}", updateInstaller.Updates[j].Title, installationResult.GetUpdateResult(j).HResult);
                         }
                     }
                 }
                 if (this.ConsoleDiagnostics)
                 {
                     Console.WriteLine("Finished.");
                 }
             }
         }
     }
     catch (COMException ex)
     {
         UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_WuaFail, null, new string[]
         {
             ex.Message
         });
         if (this.ConsoleDiagnostics)
         {
             Console.WriteLine("Failed: {0}", ex.Message);
         }
     }
 }
コード例 #5
0
        // Token: 0x06000004 RID: 4 RVA: 0x00002528 File Offset: 0x00000728
        public OptInStatus SetMicrosoftUpdateOptinStatus(OptInStatus optIn, string cabLocation)
        {
            bool flag = optIn == OptInStatus.RequestDisabled || optIn == OptInStatus.RequestNotifyDownload || optIn == OptInStatus.RequestNotifyInstall || optIn == OptInStatus.RequestScheduled;

            try
            {
                IWindowsUpdateAgentInfo windowsUpdateAgentInfo = new WindowsUpdateAgentInfoClass();
                string text = windowsUpdateAgentInfo.GetInfo("ProductVersionString") as string;
                if (string.IsNullOrEmpty(text))
                {
                    if (flag)
                    {
                        UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_MuOpt, null, new string[0]);
                    }
                    if (this.ConsoleDiagnostics)
                    {
                        Console.WriteLine("Unable to determine WUA Version");
                    }
                    return(OptInStatus.NotConfigured);
                }
                Version v = new Version(text);
                if (v < HygieneUpdate.AgentMinVersion)
                {
                    if (flag)
                    {
                        UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_MuOpt, null, new string[0]);
                    }
                    if (this.ConsoleDiagnostics)
                    {
                        Console.WriteLine("Out of date client");
                    }
                    return(OptInStatus.NotConfigured);
                }
            }
            catch (COMException)
            {
                if (flag)
                {
                    UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_MuOpt, null, new string[0]);
                }
                if (this.ConsoleDiagnostics)
                {
                    Console.WriteLine("Unable to determine Windows Update Agent version");
                }
                return(OptInStatus.NotConfigured);
            }
            try
            {
                IUpdateServiceManager updateServiceManager = new UpdateServiceManagerClass();
                foreach (object obj in updateServiceManager.Services)
                {
                    IUpdateService updateService = (IUpdateService)obj;
                    if (this.ConsoleDiagnostics)
                    {
                        Console.WriteLine("Service {0}: {1} {2}", updateService.ServiceID, updateService.IsRegisteredWithAU, updateService.IsManaged);
                    }
                    if ((string.Compare("7971f918-a847-4430-9279-4a52d1efe18d", updateService.ServiceID, StringComparison.OrdinalIgnoreCase) == 0 && updateService.IsRegisteredWithAU) || updateService.IsManaged)
                    {
                        if (this.ConsoleDiagnostics)
                        {
                            Console.WriteLine("Microsoft Update already registered.");
                        }
                        return(OptInStatus.Configured);
                    }
                }
                if (!flag)
                {
                    return(OptInStatus.NotConfigured);
                }
                if (string.IsNullOrEmpty(cabLocation))
                {
                    UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_MuOpt, null, new string[0]);
                    if (this.ConsoleDiagnostics)
                    {
                        Console.WriteLine("Invalid CAB location");
                    }
                }
                updateServiceManager.AddService("7971f918-a847-4430-9279-4a52d1efe18d", cabLocation);
                updateServiceManager.RegisterServiceWithAU("7971f918-a847-4430-9279-4a52d1efe18d");
                IAutomaticUpdates automaticUpdates = new AutomaticUpdatesClass();
                if (!automaticUpdates.Settings.ReadOnly && automaticUpdates.Settings.NotificationLevel == null)
                {
                    automaticUpdates.Settings.NotificationLevel        = optIn;
                    automaticUpdates.Settings.ScheduledInstallationDay = 0;
                    automaticUpdates.Settings.Save();
                }
            }
            catch (COMException ex)
            {
                if (flag)
                {
                    UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_MuOptFail, null, new string[]
                    {
                        ex.Message
                    });
                }
                if (this.ConsoleDiagnostics)
                {
                    Console.WriteLine("Failed: {0}", ex.Message);
                }
                return(OptInStatus.NotConfigured);
            }
            catch (InvalidCastException ex2)
            {
                UpdateSvcEventLogger.LogEvent(AntispamUpdateServiceEventLogConstants.Tuple_MuGetFail, null, new string[]
                {
                    ex2.Message
                });
                if (this.ConsoleDiagnostics)
                {
                    Console.WriteLine("Failed: {0}", ex2.Message);
                }
                return(OptInStatus.NotConfigured);
            }
            return(OptInStatus.Configured);
        }