mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-23 03:46:10 +00:00
f2ac1ece55
add
60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: Microsoft.InfoCards.ProcessMonitor
|
|
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
|
|
// MVID: 1D4D5564-A025-490C-AF1D-DF4FBB709D1F
|
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Expiro.w-f8f9f26e940480624825f6bddbea86e70fc4aa746c4dd8efa7d98dcb477000ed.exe
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
|
|
namespace Microsoft.InfoCards
|
|
{
|
|
internal class ProcessMonitor
|
|
{
|
|
private static ProcessMonitor s_current = new ProcessMonitor();
|
|
private Dictionary<int, Process> m_cache;
|
|
private object m_sync;
|
|
|
|
private ProcessMonitor()
|
|
{
|
|
this.m_sync = new object();
|
|
this.m_cache = new Dictionary<int, Process>();
|
|
}
|
|
|
|
public static Process GetProcessById(int id) => ProcessMonitor.s_current.InnerGetProcessById(id);
|
|
|
|
private Process InnerGetProcessById(int id)
|
|
{
|
|
Process process = (Process) null;
|
|
lock (this.m_sync)
|
|
{
|
|
if (!this.m_cache.TryGetValue(id, out process))
|
|
{
|
|
process = Process.GetProcessById(id);
|
|
if (!process.HasExited)
|
|
{
|
|
this.InitializeProcessObject(process);
|
|
this.m_cache.Add(process.Id, process);
|
|
}
|
|
}
|
|
}
|
|
return process;
|
|
}
|
|
|
|
private void InitializeProcessObject(Process process)
|
|
{
|
|
process.EnableRaisingEvents = true;
|
|
process.Exited += new EventHandler(this.Process_Exited);
|
|
}
|
|
|
|
private void Process_Exited(object sender, EventArgs e)
|
|
{
|
|
Process process = (Process) sender;
|
|
lock (this.m_sync)
|
|
this.m_cache.Remove(process.Id);
|
|
process.Exited -= new EventHandler(this.Process_Exited);
|
|
}
|
|
}
|
|
}
|