mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-21 10:56:10 +00:00
96 lines
2.9 KiB
C#
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-00000-msil\Virus.Win32.Expiro.w-67b630ead60119692b9abbdfd8717c96904ef041127c2cae033c86b718eaa61e.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();
|
|||
|
}
|
|||
|
}
|