MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-1f15ee7e9f7da02b6bfb4c5a5e6484eb9fa71b82d3699c54bcc7a31794b4a66d/Microsoft/InfoCards/SystemIdentity.cs

63 lines
2.2 KiB
C#
Raw Normal View History

2022-08-18 11:28:56 +00:00
// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.SystemIdentity
// 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.Globalization;
using System.Runtime.InteropServices;
using System.Security.Principal;
namespace Microsoft.InfoCards
{
internal sealed class SystemIdentity : IDisposable
{
private bool m_isDisposed;
private WindowsIdentity m_identity;
private object m_sync;
public static readonly IdentityReference LsaIdentityReference = (IdentityReference) new SecurityIdentifier("SY");
public SystemIdentity(bool throwIfAlreadySystem)
{
this.m_sync = new object();
WindowsIdentity current = WindowsIdentity.GetCurrent();
if (current.IsSystem && throwIfAlreadySystem)
throw InfoCardTrace.ThrowHelperError((Exception) new InvalidOperationException(SR.GetString("UserIdentityEqualSystemNotSupported")));
if (!current.IsSystem)
{
this.m_identity = current;
if (NativeMethods.RevertToSelf())
return;
InfoCardTrace.Assert(false, "Identity management failure");
}
else
InfoCardTrace.Assert(null == this.m_identity, "m_identity should be null when we are system and throwIfAlreadySystem == false");
}
void IDisposable.Dispose()
{
if (this.m_isDisposed)
return;
lock (this.m_sync)
{
if (this.m_isDisposed)
return;
this.m_isDisposed = true;
if (this.m_identity == null)
return;
if (!NativeMethods.ImpersonateLoggedOnUser(this.m_identity.Token))
{
int forLastWin32Error = Marshal.GetHRForLastWin32Error();
InfoCardTrace.FailFast(string.Format((IFormatProvider) CultureInfo.InvariantCulture, SR.GetString("StoreImpersonateLoggedOnUserFailed"), new object[1]
{
(object) forLastWin32Error
}));
}
this.m_identity.Dispose();
}
}
}
}