예제 #1
0
 // Token: 0x0600079C RID: 1948 RVA: 0x00024C40 File Offset: 0x00022E40
 internal void UpdateKillTime(DateTime killTime)
 {
     this.LastKillTime = killTime;
     ServiceKillConfig.WithKey(this.ServiceName, true, delegate(RegistryKey key)
     {
         string value = killTime.ToString("o");
         key.SetValue("LastKillTime", value);
     });
 }
예제 #2
0
        // Token: 0x0600079B RID: 1947 RVA: 0x00024BD4 File Offset: 0x00022DD4
        internal static ServiceKillConfig Read(string serviceName)
        {
            ServiceKillConfig skc = new ServiceKillConfig(serviceName);

            ServiceKillConfig.WithKey(serviceName, false, delegate(RegistryKey key)
            {
                string value = ServiceKillConfig.GetValue <string>(key, "LastKillTime", null);
                if (value != null)
                {
                    skc.LastKillTime = DateTime.Parse(value);
                }
                skc.IsDisabled          = (ServiceKillConfig.GetValue <int>(key, "IsDisabled", 0) > 0);
                skc.DurationBetweenKill = TimeSpan.FromSeconds((double)ServiceKillConfig.GetValue <int>(key, "DurationBetweenKillInSec", 14400));
            });
            return(skc);
        }
예제 #3
0
        private static void HandleRequestInternal(RpcKillServiceImpl.Request req, RpcKillServiceImpl.Reply rep)
        {
            Exception exception = null;

            Privilege.RunWithPrivilege("SeDebugPrivilege", true, delegate
            {
                ServiceKillConfig serviceKillConfig = ServiceKillConfig.Read(req.ServiceName);
                rep.LastKillTime = serviceKillConfig.LastKillTime;
                if (!serviceKillConfig.IsDisabled)
                {
                    using (Process serviceProcess = ServiceOperations.GetServiceProcess(req.ServiceName, out exception))
                    {
                        if (serviceProcess != null)
                        {
                            DateTime startTime   = serviceProcess.StartTime;
                            rep.ProcessStartTime = startTime;
                            bool flag            = false;
                            if (req.IsForce)
                            {
                                flag = true;
                            }
                            else if (ExDateTime.Now.LocalTime - serviceKillConfig.LastKillTime > serviceKillConfig.DurationBetweenKill)
                            {
                                if (req.CheckTime > startTime)
                                {
                                    flag = true;
                                }
                                else
                                {
                                    rep.IsSkippedDueToTimeCheck = true;
                                }
                            }
                            else
                            {
                                rep.IsThrottled = true;
                            }
                            if (flag)
                            {
                                bool flag2            = false;
                                DateTime lastKillTime = serviceKillConfig.LastKillTime;
                                try
                                {
                                    ReplayCrimsonEvents.KillingServiceProcess.Log <string, string, int, RpcKillServiceImpl.Request>(req.ServiceName, serviceProcess.ProcessName, serviceProcess.Id, req);
                                    serviceKillConfig.UpdateKillTime(DateTime.UtcNow.ToLocalTime());
                                    Exception ex = null;
                                    try
                                    {
                                        serviceProcess.Kill();
                                    }
                                    catch (Win32Exception ex2)
                                    {
                                        ex = ex2;
                                    }
                                    catch (InvalidOperationException ex3)
                                    {
                                        ex = ex3;
                                    }
                                    if (ex != null)
                                    {
                                        throw new FailedToKillProcessForServiceException(req.ServiceName, ex.Message);
                                    }
                                    flag2 = true;
                                    goto IL_194;
                                }
                                finally
                                {
                                    if (!flag2)
                                    {
                                        serviceKillConfig.UpdateKillTime(lastKillTime);
                                    }
                                    rep.IsSucceeded = flag2;
                                }
                                goto IL_178;
                            }
                            IL_194:
                            return;
                        }
                        IL_178:
                        throw new FailedToGetProcessForServiceException(req.ServiceName, exception.Message);
                    }
                }
                rep.IsSkippedDueToRegistryOverride = true;
            });
        }