You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Impersonation/MySafeTokenHandle.cs

26 lines
773 B

using Microsoft.Win32.SafeHandles;
using System.Runtime.ConstrainedExecution;
using System.Security.Permissions;
namespace ZeroLevel.Services.Impersonation
{
/// <summary>
/// Implementing a safe pointer
/// </summary>
[SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode = true)]
[SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)]
internal class MySafeTokenHandle
: SafeHandleZeroOrMinusOneIsInvalid
{
private MySafeTokenHandle()
: base(true)
{
}
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
override protected bool ReleaseHandle()
{
return ImpersonationNativeMethods.CloseHandle(handle);
}
}
}

Powered by TurnKey Linux.