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.
|
|
|
|
using Microsoft.Win32.SafeHandles;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.ConstrainedExecution;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Security;
|
|
|
|
|
|
|
|
|
|
namespace ZeroLevel.Services.AsService
|
|
|
|
|
{
|
|
|
|
|
public sealed class SafeTokenHandle
|
|
|
|
|
: SafeHandleZeroOrMinusOneIsInvalid
|
|
|
|
|
{
|
|
|
|
|
private SafeTokenHandle()
|
|
|
|
|
: base(true) { }
|
|
|
|
|
|
|
|
|
|
[DllImport("kernel32.dll")]
|
|
|
|
|
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
|
|
|
|
|
[SuppressUnmanagedCodeSecurity]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
private static extern bool CloseHandle(IntPtr handle);
|
|
|
|
|
|
|
|
|
|
protected override bool ReleaseHandle()
|
|
|
|
|
{
|
|
|
|
|
return CloseHandle(handle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|