Reorganization of interop objects
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
internal struct FieldDescriptor
|
||||
{
|
||||
public uint FieldID;
|
||||
|
||||
public FieldType FieldType;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string Label;
|
||||
|
||||
public Guid FieldTypeGuid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Pack = 8, Size = 8)]
|
||||
internal struct InnerPropertyValue
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public sbyte cVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public byte bVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public short iVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public ushort uiVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public int lVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public uint ulVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public int intVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public uint uintVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public LargeInteger hVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public ULargeInteger uhVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public float fltVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public double dblVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public short boolVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public short __OBSOLETE__VARIANT_BOOL;
|
||||
|
||||
[FieldOffset(0)]
|
||||
[MarshalAs(UnmanagedType.Error)]
|
||||
public int scode;
|
||||
|
||||
[FieldOffset(0)]
|
||||
[MarshalAs(UnmanagedType.Currency)]
|
||||
public decimal cyVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public DateTime date;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public System.Runtime.InteropServices.ComTypes.FILETIME filetime;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedBlob bstrblobVal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedBlob blob;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedArray cac;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedArray caub;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedArray cai;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedArray caui;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedArray cal;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedArray caul;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedArray caflt;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedArray cadbl;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedArray cabool;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UnmanagedArray cascode;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr pcVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr pbVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr piVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr puiVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr plVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr pulVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr pintVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr puintVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr pfltVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr pdblVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr pboolVal;
|
||||
|
||||
[ComConversionLoss]
|
||||
[FieldOffset(0)]
|
||||
public IntPtr pscode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct KerberosInteractiveUnlockLogon
|
||||
{
|
||||
public KerbLogonSubmitType SubmitType;
|
||||
public LsaStringUni LogonDomainName;
|
||||
public LsaStringUni Username;
|
||||
public LsaStringUni Password;
|
||||
|
||||
public long LoginId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
internal struct LargeInteger
|
||||
{
|
||||
public long QuadPart;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct LsaString : IDisposable
|
||||
{
|
||||
public ushort Length;
|
||||
public ushort MaxLength;
|
||||
public IntPtr Buffer;
|
||||
|
||||
public LsaString(string value)
|
||||
{
|
||||
this.Length = (ushort)value.Length;
|
||||
this.MaxLength = this.Length;
|
||||
this.Buffer = Marshal.StringToHGlobalAnsi(value);
|
||||
}
|
||||
|
||||
public static implicit operator LsaString(string value) => new LsaString(value);
|
||||
public static implicit operator string(LsaString value) => value.ToString();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Marshal.PtrToStringAnsi(this.Buffer) ?? string.Empty;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Marshal.FreeHGlobal(this.Buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct LsaStringUni : IDisposable
|
||||
{
|
||||
public ushort Length;
|
||||
public ushort MaxLength;
|
||||
public IntPtr Buffer;
|
||||
|
||||
public LsaStringUni(string value)
|
||||
{
|
||||
this.Length = (ushort)(value.Length * sizeof(ushort));
|
||||
this.MaxLength = this.Length;
|
||||
this.Buffer = Marshal.StringToHGlobalUni(value);
|
||||
}
|
||||
|
||||
public static implicit operator LsaStringUni(string value) => new LsaStringUni(value);
|
||||
public static implicit operator string(LsaStringUni value) => value.ToString();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Marshal.PtrToStringUni(this.Buffer) ?? string.Empty;
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
Marshal.FreeHGlobal(this.Buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
internal struct PropertyKey
|
||||
{
|
||||
public Guid FormatID;
|
||||
|
||||
public uint PropertyID;
|
||||
|
||||
public PropertyKey(string format, uint property)
|
||||
{
|
||||
FormatID = new Guid(format);
|
||||
PropertyID = property;
|
||||
}
|
||||
|
||||
public PropertyKey(uint propertyId,
|
||||
uint a,
|
||||
ushort b,
|
||||
ushort c,
|
||||
byte d,
|
||||
byte e,
|
||||
byte f,
|
||||
byte g,
|
||||
byte h,
|
||||
byte i,
|
||||
byte j,
|
||||
byte k)
|
||||
{
|
||||
PropertyID = propertyId;
|
||||
FormatID = new Guid(a, b, c, d, e, f, g, h, i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
internal struct PropertyValue
|
||||
{
|
||||
public ushort vt;
|
||||
|
||||
public byte wReserved1;
|
||||
|
||||
public byte wReserved2;
|
||||
|
||||
public uint wReserved3;
|
||||
|
||||
public InnerPropertyValue Value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
internal struct ULargeInteger
|
||||
{
|
||||
public ulong QuadPart;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
internal struct UnmanagedArray
|
||||
{
|
||||
public uint cElems;
|
||||
|
||||
[ComConversionLoss]
|
||||
public IntPtr pElems;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lithnet.CredentialProvider.Interop
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
internal struct UnmanagedBlob
|
||||
{
|
||||
public uint cbSize;
|
||||
|
||||
[ComConversionLoss]
|
||||
public IntPtr pData;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user