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

106 lines
2.7 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.RpcCryptoContext
// 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 Microsoft.InfoCards.Diagnostics;
using System;
using System.ComponentModel;
namespace Microsoft.InfoCards
{
internal class RpcCryptoContext : IDisposable
{
private string m_portName;
private string m_contextKey;
private IntPtr m_idlHandle;
private object m_syncRoot;
private bool m_open;
private bool m_disposed;
public RpcCryptoContext(string portName, string contextKey)
{
this.m_portName = portName;
this.m_contextKey = contextKey;
this.m_syncRoot = new object();
this.m_disposed = false;
}
~RpcCryptoContext()
{
if (this.m_disposed)
return;
((IDisposable) this).Dispose();
}
public string ContextKey => this.m_contextKey;
public IntPtr InterfaceHandle => this.m_idlHandle;
public bool IsOpen => this.m_open;
public void Open()
{
this.ThrowIfDisposed();
if (this.m_open)
return;
try
{
this.m_idlHandle = NativeMcppMethods.RpcCryptoOpen(this.m_portName);
}
catch (Win32Exception ex)
{
throw InfoCardTrace.ThrowHelperError((Exception) new CommunicationException((string) null, (Exception) ex));
}
this.m_open = true;
}
public void Close()
{
if (!this.m_open)
return;
try
{
NativeMcppMethods.RpcCryptoClose(this.m_idlHandle, this.m_contextKey);
}
catch (Win32Exception ex)
{
throw InfoCardTrace.ThrowHelperError((Exception) new CommunicationException((string) null, (Exception) ex));
}
this.m_idlHandle = IntPtr.Zero;
this.m_open = false;
}
void IDisposable.Dispose()
{
if (this.m_disposed)
return;
lock (this.m_syncRoot)
{
if (this.m_disposed)
return;
this.m_disposed = true;
try
{
this.Close();
}
catch (CommunicationException ex)
{
string message = ex.Message;
}
this.m_portName = (string) null;
this.m_contextKey = (string) null;
this.m_idlHandle = IntPtr.Zero;
GC.SuppressFinalize((object) this);
}
}
private void ThrowIfDisposed()
{
if (this.m_disposed)
throw InfoCardTrace.ThrowHelperError((Exception) new ObjectDisposedException(nameof (RpcCryptoContext)));
}
}
}