mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-25 12:55:28 +00:00
f2ac1ece55
add
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: 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.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();
|
|
}
|
|
}
|
|
}
|
|
}
|