mirror of https://github.com/ogoun/Zero.git
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.
27 lines
775 B
27 lines
775 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);
|
|
}
|
|
}
|
|
}
|