mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-22 19:36:11 +00:00
63 lines
2.2 KiB
C#
63 lines
2.2 KiB
C#
|
// 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-00000-msil\Virus.Win32.Expiro.w-67b630ead60119692b9abbdfd8717c96904ef041127c2cae033c86b718eaa61e.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();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|