mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-22 11:26:11 +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: 516D8B44-4448-4D2C-8B8E-FFBB3FFE472B
|
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Virus.Win32.Expiro.w-69bb73081eac86b8cf86f45e33515d0095855636967076e2b593d7a30cd80a07.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);
|
|
}
|
|
}
|