MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-1f15ee7e9f7da02b6bfb4c5a5e6484eb9fa71b82d3699c54bcc7a31794b4a66d/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: ADE0A079-11DB-4A46-8BDE-D2A592CA8DEA
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Expiro.w-1f15ee7e9f7da02b6bfb4c5a5e6484eb9fa71b82d3699c54bcc7a31794b4a66d.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)));
}
}
}