File: _generated\0\LibraryImports.g.cs
Web Access
Project: src\src\runtime\src\libraries\System.DirectoryServices.AccountManagement\src\System.DirectoryServices.AccountManagement.csproj (System.DirectoryServices.AccountManagement)
// <auto-generated/>
internal static unsafe partial class Interop
{
    internal static unsafe partial class Activeds
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int ADsOpenObject(string path, string userName, string password, int flags, ref global::System.Guid iid, out nint ppObject)
        {
            ppObject = default;
            int __retVal;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (nint* __ppObject_native = &ppObject)
            fixed (global::System.Guid* __iid_native = &iid)
            fixed (void* __password_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(password))
            fixed (void* __userName_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(userName))
            fixed (void* __path_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(path))
            {
                __retVal = __PInvoke((ushort*)__path_native, (ushort*)__userName_native, (ushort*)__password_native, flags, __iid_native, __ppObject_native);
            }
 
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("activeds.dll", EntryPoint = "ADsOpenObject", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe int __PInvoke(ushort* __path_native, ushort* __userName_native, ushort* __password_native, int __flags_native, global::System.Guid* __iid_native, nint* __ppObject_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial global::Interop.BOOL ConvertSidToStringSid(nint sid, out string stringSid)
        {
            int __lastError;
            bool __invokeSucceeded = default;
            stringSid = default;
            ushort* __stringSid_native = default;
            global::Interop.BOOL __retVal = default;
            try
            {
                {
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(sid, &__stringSid_native);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
 
                __invokeSucceeded = true;
                // Unmarshal - Convert native data to managed data.
                stringSid = global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.ConvertToManaged(__stringSid_native);
            }
            finally
            {
                if (__invokeSucceeded)
                {
                    // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
                    global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.Free(__stringSid_native);
                }
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "ConvertSidToStringSidW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe global::Interop.BOOL __PInvoke(nint __sid_native, ushort** __stringSid_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static unsafe partial global::Interop.BOOL ConvertStringSidToSid(string StringSid, out void* Sid)
        {
            int __lastError;
            Sid = default;
            global::Interop.BOOL __retVal;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (void** __Sid_native = &Sid)
            fixed (void* __StringSid_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(StringSid))
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal = __PInvoke((ushort*)__StringSid_native, __Sid_native);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "ConvertStringSidToSidW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe global::Interop.BOOL __PInvoke(ushort* __StringSid_native, void** __Sid_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool CopySid(int destinationLength, nint pSidDestination, nint pSidSource)
        {
            int __lastError;
            bool __retVal;
            int __retVal_native;
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal_native = __PInvoke(destinationLength, pSidDestination, pSidSource);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CopySid", ExactSpelling = true)]
            static extern unsafe int __PInvoke(int __destinationLength_native, nint __pSidDestination_native, nint __pSidSource_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        public static partial bool EqualDomainSid(nint pSid1, nint pSid2, ref bool equal)
        {
            int __equal_native;
            bool __retVal;
            int __retVal_native;
            // Marshal - Convert managed data to native data.
            __equal_native = (int)(equal ? 1 : 0);
            {
                __retVal_native = __PInvoke(pSid1, pSid2, &__equal_native);
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            equal = __equal_native != 0;
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "EqualDomainSid", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __pSid1_native, nint __pSid2_native, int* __equal_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "GetLengthSid", ExactSpelling = true)]
        internal static extern partial int GetLengthSid(nint sid);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "GetSidIdentifierAuthority", ExactSpelling = true)]
        internal static extern partial nint GetSidIdentifierAuthority(nint sid);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "GetSidSubAuthority", ExactSpelling = true)]
        internal static extern partial nint GetSidSubAuthority(nint sid, int index);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "GetSidSubAuthorityCount", ExactSpelling = true)]
        internal static extern partial nint GetSidSubAuthorityCount(nint sid);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool GetTokenInformation(nint TokenHandle, uint TokenInformationClass, nint TokenInformation, uint TokenInformationLength, out uint ReturnLength)
        {
            int __lastError;
            ReturnLength = default;
            bool __retVal;
            int __retVal_native;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (uint* __ReturnLength_native = &ReturnLength)
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal_native = __PInvoke(TokenHandle, TokenInformationClass, TokenInformation, TokenInformationLength, __ReturnLength_native);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "GetTokenInformation", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __TokenHandle_native, uint __TokenInformationClass_native, nint __TokenInformation_native, uint __TokenInformationLength_native, uint* __ReturnLength_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int ImpersonateLoggedOnUser(nint userToken)
        {
            int __lastError;
            int __retVal;
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal = __PInvoke(userToken);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "ImpersonateLoggedOnUser", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __userToken_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool IsValidSid(nint sid)
        {
            int __lastError;
            bool __retVal;
            int __retVal_native;
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal_native = __PInvoke(sid);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "IsValidSid", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __sid_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int LogonUser(string username, string domain, string password, int logonType, int logonProvider, ref nint token)
        {
            int __lastError;
            int __retVal;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (nint* __token_native = &token)
            fixed (void* __password_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(password))
            fixed (void* __domain_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(domain))
            fixed (void* __username_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(username))
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal = __PInvoke((ushort*)__username_native, (ushort*)__domain_native, (ushort*)__password_native, logonType, logonProvider, __token_native);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "LogonUserW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe int __PInvoke(ushort* __username_native, ushort* __domain_native, ushort* __password_native, int __logonType_native, int __logonProvider_native, nint* __token_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        public static unsafe partial int LookupAccountSid(string lpSystemName, byte[] Sid, char* Name, ref int cchName, char* ReferencedDomainName, ref int cchReferencedDomainName, out int peUse)
        {
            int __lastError;
            peUse = default;
            int __retVal;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (int* __peUse_native = &peUse)
            fixed (int* __cchReferencedDomainName_native = &cchReferencedDomainName)
            fixed (int* __cchName_native = &cchName)
            fixed (void* __Sid_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(Sid))
            fixed (void* __lpSystemName_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(lpSystemName))
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal = __PInvoke((ushort*)__lpSystemName_native, (byte*)__Sid_native, Name, __cchName_native, ReferencedDomainName, __cchReferencedDomainName_native, __peUse_native);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "LookupAccountSidW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe int __PInvoke(ushort* __lpSystemName_native, byte* __Sid_native, char* __Name_native, int* __cchName_native, char* __ReferencedDomainName_native, int* __cchReferencedDomainName_native, int* __peUse_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int LsaClose(nint handle)
        {
            int __lastError;
            int __retVal;
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal = __PInvoke(handle);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "LsaClose", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int LsaFreeMemory(nint handle)
        {
            int __lastError;
            int __retVal;
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal = __PInvoke(handle);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "LsaFreeMemory", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial uint LsaLookupSids(global::Microsoft.Win32.SafeHandles.SafeLsaPolicyHandle handle, int count, nint[] sids, out global::Microsoft.Win32.SafeHandles.SafeLsaMemoryHandle referencedDomains, out global::Microsoft.Win32.SafeHandles.SafeLsaMemoryHandle names)
        {
            int __lastError;
            bool __invokeSucceeded = default;
            referencedDomains = default;
            names = default;
            nint __handle_native = default;
            nint __referencedDomains_native = default;
            nint __names_native = default;
            uint __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeLsaMemoryHandle>.ManagedToUnmanagedOut __names_native__marshaller = new();
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeLsaMemoryHandle>.ManagedToUnmanagedOut __referencedDomains_native__marshaller = new();
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeLsaPolicyHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __handle_native__marshaller.FromManaged(handle);
                // Pin - Pin data in preparation for calling the P/Invoke.
                fixed (void* __sids_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<nint, nint>.ManagedToUnmanagedIn.GetPinnableReference(sids))
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__handle_native, count, (nint*)__sids_native, &__referencedDomains_native, &__names_native);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
 
                __invokeSucceeded = true;
                // UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
                __names_native__marshaller.FromUnmanaged(__names_native);
                __referencedDomains_native__marshaller.FromUnmanaged(__referencedDomains_native);
                // Unmarshal - Convert native data to managed data.
                names = __names_native__marshaller.ToManaged();
                referencedDomains = __referencedDomains_native__marshaller.ToManaged();
            }
            finally
            {
                if (__invokeSucceeded)
                {
                    // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
                    __names_native__marshaller.Free();
                    __referencedDomains_native__marshaller.Free();
                }
 
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "LsaLookupSids", ExactSpelling = true)]
            static extern unsafe uint __PInvoke(nint __handle_native, int __count_native, nint* __sids_native, nint* __referencedDomains_native, nint* __names_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "LsaNtStatusToWinError", ExactSpelling = true, SetLastError = false)]
        internal static extern partial uint LsaNtStatusToWinError(uint status);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        private static partial uint LsaOpenPolicy(ref global::Interop.UNICODE_STRING SystemName, ref global::Interop.OBJECT_ATTRIBUTES ObjectAttributes, int AccessMask, out global::Microsoft.Win32.SafeHandles.SafeLsaPolicyHandle PolicyHandle)
        {
            int __lastError;
            bool __invokeSucceeded = default;
            PolicyHandle = default;
            nint __PolicyHandle_native = default;
            uint __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeLsaPolicyHandle>.ManagedToUnmanagedOut __PolicyHandle_native__marshaller = new();
            try
            {
                // Pin - Pin data in preparation for calling the P/Invoke.
                fixed (global::Interop.OBJECT_ATTRIBUTES* __ObjectAttributes_native = &ObjectAttributes)
                fixed (global::Interop.UNICODE_STRING* __SystemName_native = &SystemName)
                {
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__SystemName_native, __ObjectAttributes_native, AccessMask, &__PolicyHandle_native);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
 
                __invokeSucceeded = true;
                // UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
                __PolicyHandle_native__marshaller.FromUnmanaged(__PolicyHandle_native);
                // Unmarshal - Convert native data to managed data.
                PolicyHandle = __PolicyHandle_native__marshaller.ToManaged();
            }
            finally
            {
                if (__invokeSucceeded)
                {
                    // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
                    __PolicyHandle_native__marshaller.Free();
                }
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "LsaOpenPolicy", ExactSpelling = true)]
            static extern unsafe uint __PInvoke(global::Interop.UNICODE_STRING* __SystemName_native, global::Interop.OBJECT_ATTRIBUTES* __ObjectAttributes_native, int __AccessMask_native, nint* __PolicyHandle_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial uint LsaQueryInformationPolicy(nint policyHandle, int policyInformationClass, ref nint buffer)
        {
            uint __retVal;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (nint* __buffer_native = &buffer)
            {
                __retVal = __PInvoke(policyHandle, policyInformationClass, __buffer_native);
            }
 
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "LsaQueryInformationPolicy", ExactSpelling = true)]
            static extern unsafe uint __PInvoke(nint __policyHandle_native, int __policyInformationClass_native, nint* __buffer_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool OpenThreadToken(nint ThreadHandle, global::System.Security.Principal.TokenAccessLevels dwDesiredAccess, bool bOpenAsSelf, out global::Microsoft.Win32.SafeHandles.SafeTokenHandle phThreadToken)
        {
            int __lastError;
            bool __invokeSucceeded = default;
            phThreadToken = default;
            int __bOpenAsSelf_native = default;
            nint __phThreadToken_native = default;
            bool __retVal = default;
            int __retVal_native = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeTokenHandle>.ManagedToUnmanagedOut __phThreadToken_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __bOpenAsSelf_native = (int)(bOpenAsSelf ? 1 : 0);
                {
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal_native = __PInvoke(ThreadHandle, dwDesiredAccess, __bOpenAsSelf_native, &__phThreadToken_native);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
 
                __invokeSucceeded = true;
                // UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
                __phThreadToken_native__marshaller.FromUnmanaged(__phThreadToken_native);
                // Unmarshal - Convert native data to managed data.
                __retVal = __retVal_native != 0;
                phThreadToken = __phThreadToken_native__marshaller.ToManaged();
            }
            finally
            {
                if (__invokeSucceeded)
                {
                    // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
                    __phThreadToken_native__marshaller.Free();
                }
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "OpenThreadToken", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __ThreadHandle_native, global::System.Security.Principal.TokenAccessLevels __dwDesiredAccess_native, int __bOpenAsSelf_native, nint* __phThreadToken_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool OpenProcessToken(nint ProcessHandle, int DesiredAccess, out global::Microsoft.Win32.SafeHandles.SafeTokenHandle TokenHandle)
        {
            int __lastError;
            bool __invokeSucceeded = default;
            TokenHandle = default;
            nint __TokenHandle_native = default;
            bool __retVal = default;
            int __retVal_native = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeTokenHandle>.ManagedToUnmanagedOut __TokenHandle_native__marshaller = new();
            try
            {
                {
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal_native = __PInvoke(ProcessHandle, DesiredAccess, &__TokenHandle_native);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
 
                __invokeSucceeded = true;
                // UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
                __TokenHandle_native__marshaller.FromUnmanaged(__TokenHandle_native);
                // Unmarshal - Convert native data to managed data.
                __retVal = __retVal_native != 0;
                TokenHandle = __TokenHandle_native__marshaller.ToManaged();
            }
            finally
            {
                if (__invokeSucceeded)
                {
                    // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
                    __TokenHandle_native__marshaller.Free();
                }
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "OpenProcessToken", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe int __PInvoke(nint __ProcessHandle_native, int __DesiredAccess_native, nint* __TokenHandle_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Advapi32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool RevertToSelf()
        {
            int __lastError;
            bool __retVal;
            int __retVal_native;
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal_native = __PInvoke();
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "RevertToSelf", ExactSpelling = true)]
            static extern unsafe int __PInvoke();
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Authz
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool AuthzGetInformationFromContext(nint hAuthzClientContext, int InfoClass, int BufferSize, out int pSizeRequired, nint Buffer)
        {
            int __lastError;
            pSizeRequired = default;
            bool __retVal;
            int __retVal_native;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (int* __pSizeRequired_native = &pSizeRequired)
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal_native = __PInvoke(hAuthzClientContext, InfoClass, BufferSize, __pSizeRequired_native, Buffer);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("authz.dll", EntryPoint = "AuthzGetInformationFromContext", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __hAuthzClientContext_native, int __InfoClass_native, int __BufferSize_native, int* __pSizeRequired_native, nint __Buffer_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Authz
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool AuthzInitializeContextFromSid(int Flags, nint UserSid, nint AuthzResourceManager, nint pExpirationTime, global::Interop.LUID Identitifier, nint DynamicGroupArgs, out nint pAuthzClientContext)
        {
            int __lastError;
            pAuthzClientContext = default;
            bool __retVal;
            int __retVal_native;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (nint* __pAuthzClientContext_native = &pAuthzClientContext)
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal_native = __PInvoke(Flags, UserSid, AuthzResourceManager, pExpirationTime, Identitifier, DynamicGroupArgs, __pAuthzClientContext_native);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("authz.dll", EntryPoint = "AuthzInitializeContextFromSid", ExactSpelling = true)]
            static extern unsafe int __PInvoke(int __Flags_native, nint __UserSid_native, nint __AuthzResourceManager_native, nint __pExpirationTime_native, global::Interop.LUID __Identitifier_native, nint __DynamicGroupArgs_native, nint* __pAuthzClientContext_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Authz
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool AuthzFreeContext(nint AuthzClientContext)
        {
            bool __retVal;
            int __retVal_native;
            {
                __retVal_native = __PInvoke(AuthzClientContext);
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("authz.dll", EntryPoint = "AuthzFreeContext", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __AuthzClientContext_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Authz
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool AuthzInitializeResourceManager(int flags, nint pfnAccessCheck, nint pfnComputeDynamicGroups, nint pfnFreeDynamicGroups, string name, out nint rm)
        {
            int __lastError;
            rm = default;
            bool __retVal;
            int __retVal_native;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (nint* __rm_native = &rm)
            fixed (void* __name_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(name))
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal_native = __PInvoke(flags, pfnAccessCheck, pfnComputeDynamicGroups, pfnFreeDynamicGroups, (ushort*)__name_native, __rm_native);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("authz.dll", EntryPoint = "AuthzInitializeResourceManager", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe int __PInvoke(int __flags_native, nint __pfnAccessCheck_native, nint __pfnComputeDynamicGroups_native, nint __pfnFreeDynamicGroups_native, ushort* __name_native, nint* __rm_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Authz
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool AuthzFreeResourceManager(nint rm)
        {
            bool __retVal;
            int __retVal_native;
            {
                __retVal_native = __PInvoke(rm);
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("authz.dll", EntryPoint = "AuthzFreeResourceManager", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __rm_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Credui
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static unsafe partial int CredUIParseUserName(string pszUserName, char* pszUser, uint ulUserMaxChars, char* pszDomain, uint ulDomainMaxChars)
        {
            int __lastError;
            int __retVal;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (void* __pszUserName_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszUserName))
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal = __PInvoke((ushort*)__pszUserName_native, pszUser, ulUserMaxChars, pszDomain, ulDomainMaxChars);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("credui.dll", EntryPoint = "CredUIParseUserNameW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe int __PInvoke(ushort* __pszUserName_native, char* __pszUser_native, uint __ulUserMaxChars_native, char* __pszDomain_native, uint __ulDomainMaxChars_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Dsrole
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("dsrole.dll", EntryPoint = "DsRoleFreeMemory", ExactSpelling = true)]
        public static extern partial int DsRoleFreeMemory(nint buffer);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Dsrole
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int DsRoleGetPrimaryDomainInformation(string lpServer, global::Interop.Dsrole.DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, out nint Buffer)
        {
            Buffer = default;
            int __retVal;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (nint* __Buffer_native = &Buffer)
            fixed (void* __lpServer_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(lpServer))
            {
                __retVal = __PInvoke((ushort*)__lpServer_native, InfoLevel, __Buffer_native);
            }
 
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("dsrole.dll", EntryPoint = "DsRoleGetPrimaryDomainInformation", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe int __PInvoke(ushort* __lpServer_native, global::Interop.Dsrole.DSROLE_PRIMARY_DOMAIN_INFO_LEVEL __InfoLevel_native, nint* __Buffer_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Kernel32
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial bool CloseHandle(nint handle)
        {
            int __lastError;
            bool __retVal;
            int __retVal_native;
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal_native = __PInvoke(handle);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            // Unmarshal - Convert native data to managed data.
            __retVal = __retVal_native != 0;
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "CloseHandle", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Kernel32
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "GetCurrentProcess", ExactSpelling = true)]
        internal static extern partial nint GetCurrentProcess();
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Kernel32
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "GetCurrentThread", ExactSpelling = true)]
        internal static extern partial nint GetCurrentThread();
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Kernel32
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "GetCurrentThreadId", ExactSpelling = true)]
        public static extern partial int GetCurrentThreadId();
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Kernel32
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "LocalFree", ExactSpelling = true)]
        private static extern partial nint LocalFree(nint hMem);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Logoncli
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int DsGetDcName(string computerName, string domainName, nint domainGuid, string siteName, int flags, out nint domainControllerInfo)
        {
            domainControllerInfo = default;
            int __retVal;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (nint* __domainControllerInfo_native = &domainControllerInfo)
            fixed (void* __siteName_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(siteName))
            fixed (void* __domainName_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(domainName))
            fixed (void* __computerName_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(computerName))
            {
                __retVal = __PInvoke((ushort*)__computerName_native, (ushort*)__domainName_native, domainGuid, (ushort*)__siteName_native, flags, __domainControllerInfo_native);
            }
 
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("logoncli.dll", EntryPoint = "DsGetDcNameW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe int __PInvoke(ushort* __computerName_native, ushort* __domainName_native, nint __domainGuid_native, ushort* __siteName_native, int __flags_native, nint* __domainControllerInfo_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Netutils
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("netutils.dll", EntryPoint = "NetApiBufferFree", ExactSpelling = true)]
        internal static extern partial int NetApiBufferFree(nint buffer);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Wkscli
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int NetWkstaGetInfo(string server, int level, ref nint buffer)
        {
            int __retVal;
            // Pin - Pin data in preparation for calling the P/Invoke.
            fixed (nint* __buffer_native = &buffer)
            fixed (void* __server_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(server))
            {
                __retVal = __PInvoke((ushort*)__server_native, level, __buffer_native);
            }
 
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("wkscli.dll", EntryPoint = "NetWkstaGetInfo", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
            static extern unsafe int __PInvoke(ushort* __server_native, int __level_native, nint* __buffer_native);
        }
    }
}