MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-1f15ee7e9f7da02b6bfb4c5a5e6484eb9fa71b82d3699c54bcc7a31794b4a66d/Microsoft/InfoCards/LifeTimeMonitor.cs
2022-08-18 06:28:56 -05:00

96 lines
2.9 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.LifeTimeMonitor
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: ADE0A079-11DB-4A46-8BDE-D2A592CA8DEA
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Expiro.w-1f15ee7e9f7da02b6bfb4c5a5e6484eb9fa71b82d3699c54bcc7a31794b4a66d.exe
using Microsoft.InfoCards.Diagnostics;
using Microsoft.Win32;
using System;
using System.ServiceProcess;
using System.Timers;
namespace Microsoft.InfoCards
{
internal class LifeTimeMonitor
{
private const int DefaultShutdownInterval = 3600000;
private const int MinimumShutdownInterval = 60000;
private const string ServiceIdleTimeValue = "ServiceIdleTime";
private int m_activeCount;
private bool m_isShuttingDown;
private Timer m_shutdownTimer;
private object m_syncRoot = new object();
public LifeTimeMonitor()
{
int interval = 3600000;
using (new SystemIdentity(false))
{
using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(InfoCardConstants.RegistryKey, false))
{
if (registryKey != null)
{
object obj = registryKey.GetValue("ServiceIdleTime", (object) 3600000);
if (obj is int num)
{
if (num >= 60000)
interval = (int) obj;
}
}
}
}
this.m_activeCount = 0;
this.m_shutdownTimer = new Timer((double) interval);
this.m_shutdownTimer.Elapsed += new ElapsedEventHandler(this.OnShutdown);
this.m_shutdownTimer.AutoReset = false;
this.m_isShuttingDown = false;
this.StartShutdownTimer();
}
public void AddClient()
{
lock (this.m_syncRoot)
{
InfoCardTrace.Assert(this.m_activeCount >= 0, "incorrect active count");
if (this.m_isShuttingDown)
throw InfoCardTrace.ThrowHelperError((Exception) new ServiceBusyException());
++this.m_activeCount;
if (1 != this.m_activeCount)
return;
this.StopShutdownTimer();
}
}
public void RemoveClient()
{
lock (this.m_syncRoot)
{
InfoCardTrace.Assert(this.m_activeCount > 0, "invalid active count");
--this.m_activeCount;
if (this.m_activeCount != 0)
return;
this.StartShutdownTimer();
}
}
private void OnShutdown(object sender, ElapsedEventArgs args)
{
lock (this.m_syncRoot)
{
if (this.m_activeCount > 0)
return;
this.m_shutdownTimer.Enabled = false;
this.m_isShuttingDown = true;
InfoCardTrace.Audit(EventCode.AUDIT_SERVICE_IDLE_STOP);
}
using (new SystemIdentity(false))
new ServiceController("idsvc").Stop();
}
private void StartShutdownTimer() => this.m_shutdownTimer.Start();
private void StopShutdownTimer() => this.m_shutdownTimer.Stop();
}
}