mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-30 06:55:27 +00:00
f2ac1ece55
add
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: Microsoft.InfoCards.HandleDictionary`1
|
|
// 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 System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Microsoft.InfoCards
|
|
{
|
|
internal class HandleDictionary<TVal>
|
|
{
|
|
private const int m_MaxSessionCount = 1073741823;
|
|
private Dictionary<int, TVal> m_internalDictionary;
|
|
private Random m_random;
|
|
|
|
public int MaxSize => 1073741823;
|
|
|
|
public TVal this[int Key]
|
|
{
|
|
get => this.m_internalDictionary[Key];
|
|
set
|
|
{
|
|
if (!this.ContainsHandle(Key))
|
|
throw InfoCardTrace.ThrowHelperError((Exception) new KeyNotFoundException());
|
|
this.m_internalDictionary[Key] = value;
|
|
}
|
|
}
|
|
|
|
public HandleDictionary()
|
|
{
|
|
this.m_internalDictionary = new Dictionary<int, TVal>();
|
|
this.m_random = new Random();
|
|
}
|
|
|
|
public int GetNewHandle()
|
|
{
|
|
if (this.m_internalDictionary.Count >= 1073741823)
|
|
throw InfoCardTrace.ThrowHelperError((Exception) new MaxSessionCountExceededException());
|
|
int key = this.m_random.Next();
|
|
while (this.m_internalDictionary.ContainsKey(key) || key == 0)
|
|
key = this.m_random.Next();
|
|
this.m_internalDictionary[key] = default (TVal);
|
|
return key;
|
|
}
|
|
|
|
public bool Remove(int key) => this.m_internalDictionary.Remove(key);
|
|
|
|
public bool ContainsHandle(int key) => this.m_internalDictionary.ContainsKey(key);
|
|
}
|
|
}
|