Initial commit

This commit is contained in:
Ryan Newington
2023-01-28 21:15:17 +11:00
parent eb7b6fa4eb
commit 52e75c1748
90 changed files with 7306 additions and 0 deletions
@@ -0,0 +1,40 @@
using System;
using System.ComponentModel;
namespace Lithnet.CredentialProvider.Interop
{
internal struct LsaHandle : IDisposable
{
public IntPtr Handle;
public LsaHandle(IntPtr handle)
{
this.Handle = handle;
}
public static implicit operator LsaHandle(IntPtr handle) => new LsaHandle(handle);
public static implicit operator IntPtr(LsaHandle handle) => handle.Handle;
public static LsaHandle ConnectUntrusted()
{
var result = PInvoke.LsaConnectUntrusted(out var handle);
if (result != 0)
{
throw new Win32Exception((int)result);
}
return handle;
}
public bool IsValid()
{
return this.Handle != IntPtr.Zero;
}
public void Dispose()
{
PInvoke.LsaDeregisterLogonProcess(this.Handle);
}
}
}