//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Linq;

namespace NtApiDotNet.Win32.Security.Authentication.Kerberos.Ndr
{
    
    #region Marshal Helpers
    internal class _Unmarshal_HelperDeviceInfo : NtApiDotNet.Ndr.Marshal.NdrUnmarshalBuffer
    {
        internal _Unmarshal_HelperDeviceInfo(NtApiDotNet.Win32.Rpc.RpcClientResponse r) : 
                base(r.NdrBuffer, r.Handles, r.DataRepresentation)
        {
        }
        internal _Unmarshal_HelperDeviceInfo(byte[] ba) : 
                base(ba)
        {
        }
        internal _Unmarshal_HelperDeviceInfo(NtApiDotNet.Ndr.Marshal.NdrPickledType pickled_type) : 
                base(pickled_type)
        {
        }
        internal PAC_DEVICE_INFO Read_0()
        {
            return ReadStruct<PAC_DEVICE_INFO>();
        }
        internal RPC_SID_DEVICE Read_1()
        {
            return ReadStruct<RPC_SID_DEVICE>();
        }
        internal RPC_SID_IDENTIFIER_AUTHORITY_DEVICE Read_2()
        {
            return ReadStruct<RPC_SID_IDENTIFIER_AUTHORITY_DEVICE>();
        }
        internal GROUP_MEMBERSHIP_DEVICE Read_3()
        {
            return ReadStruct<GROUP_MEMBERSHIP_DEVICE>();
        }
        internal KERB_SID_AND_ATTRIBUTES_DEVICE Read_4()
        {
            return ReadStruct<KERB_SID_AND_ATTRIBUTES_DEVICE>();
        }
        internal DOMAIN_GROUP_MEMBERSHIP Read_7()
        {
            return ReadStruct<DOMAIN_GROUP_MEMBERSHIP>();
        }
        internal GROUP_MEMBERSHIP_DEVICE[] Read_8()
        {
            return ReadConformantStructArray<GROUP_MEMBERSHIP_DEVICE>();
        }
        internal KERB_SID_AND_ATTRIBUTES_DEVICE[] Read_9()
        {
            return ReadConformantStructArray<KERB_SID_AND_ATTRIBUTES_DEVICE>();
        }
        internal DOMAIN_GROUP_MEMBERSHIP[] Read_10()
        {
            return ReadConformantStructArray<DOMAIN_GROUP_MEMBERSHIP>();
        }
        internal int[] Read_11()
        {
            return ReadConformantArray<int>();
        }
        internal byte[] Read_12()
        {
            return ReadFixedPrimitiveArray<byte>(6);
        }
        internal int[] Read_13()
        {
            return ReadConformantArray<int>();
        }
        internal byte[] Read_14()
        {
            return ReadFixedByteArray(6);
        }
        internal GROUP_MEMBERSHIP_DEVICE[] Read_15()
        {
            return ReadConformantStructArray<GROUP_MEMBERSHIP_DEVICE>();
        }
    }
    #endregion
    #region Complex Types
    internal struct PAC_DEVICE_INFO : NtApiDotNet.Ndr.Marshal.INdrStructure
    {
        void NtApiDotNet.Ndr.Marshal.INdrStructure.Marshal(NtApiDotNet.Ndr.Marshal.NdrMarshalBuffer m)
        {
            throw new NotImplementedException();
        }

        void NtApiDotNet.Ndr.Marshal.INdrStructure.Unmarshal(NtApiDotNet.Ndr.Marshal.NdrUnmarshalBuffer u)
        {
            Unmarshal(((_Unmarshal_HelperDeviceInfo)(u)));
        }
        private void Unmarshal(_Unmarshal_HelperDeviceInfo u)
        {
            UserId = u.ReadInt32();
            PrimaryGroupId = u.ReadInt32();
            AccountDomainId = u.ReadEmbeddedPointer<RPC_SID_DEVICE>(new System.Func<RPC_SID_DEVICE>(u.Read_1), false);
            AccountGroupCount = u.ReadInt32();
            AccountGroupIds = u.ReadEmbeddedPointer<GROUP_MEMBERSHIP_DEVICE[]>(new System.Func<GROUP_MEMBERSHIP_DEVICE[]>(u.Read_8), false);
            SidCount = u.ReadInt32();
            ExtraSids = u.ReadEmbeddedPointer<KERB_SID_AND_ATTRIBUTES_DEVICE[]>(new System.Func<KERB_SID_AND_ATTRIBUTES_DEVICE[]>(u.Read_9), false);
            DomainGroupCount = u.ReadInt32();
            DomainGroup = u.ReadEmbeddedPointer<DOMAIN_GROUP_MEMBERSHIP[]>(new System.Func<DOMAIN_GROUP_MEMBERSHIP[]>(u.Read_10), false);
        }
        int NtApiDotNet.Ndr.Marshal.INdrStructure.GetAlignment()
        {
            return 4;
        }
        internal int UserId;
        internal int PrimaryGroupId;
        internal NtApiDotNet.Ndr.Marshal.NdrEmbeddedPointer<RPC_SID_DEVICE> AccountDomainId;
        internal int AccountGroupCount;
        internal NtApiDotNet.Ndr.Marshal.NdrEmbeddedPointer<GROUP_MEMBERSHIP_DEVICE[]> AccountGroupIds;
        internal int SidCount;
        internal NtApiDotNet.Ndr.Marshal.NdrEmbeddedPointer<KERB_SID_AND_ATTRIBUTES_DEVICE[]> ExtraSids;
        internal int DomainGroupCount;
        internal NtApiDotNet.Ndr.Marshal.NdrEmbeddedPointer<DOMAIN_GROUP_MEMBERSHIP[]> DomainGroup;
    }
    internal struct RPC_SID_DEVICE : NtApiDotNet.Ndr.Marshal.INdrConformantStructure
    {
        void NtApiDotNet.Ndr.Marshal.INdrStructure.Marshal(NtApiDotNet.Ndr.Marshal.NdrMarshalBuffer m)
        {
            throw new NotImplementedException();
        }

        void NtApiDotNet.Ndr.Marshal.INdrStructure.Unmarshal(NtApiDotNet.Ndr.Marshal.NdrUnmarshalBuffer u)
        {
            Unmarshal(((_Unmarshal_HelperDeviceInfo)(u)));
        }
        private void Unmarshal(_Unmarshal_HelperDeviceInfo u)
        {
            Revision = u.ReadByte();
            SubAuthorityCount = u.ReadByte();
            IdentifierAuthority = u.Read_2();
            SubAuthority = u.Read_11();
        }
        int NtApiDotNet.Ndr.Marshal.INdrConformantStructure.GetConformantDimensions()
        {
            return 1;
        }
        int NtApiDotNet.Ndr.Marshal.INdrStructure.GetAlignment()
        {
            return 4;
        }

        internal Sid ToSid()
        {
            return new Sid(new SidIdentifierAuthority(IdentifierAuthority.Value),
                SubAuthority.Select(r => (uint)r).ToArray());
        }

        internal byte Revision;
        internal byte SubAuthorityCount;
        internal RPC_SID_IDENTIFIER_AUTHORITY_DEVICE IdentifierAuthority;
        internal int[] SubAuthority;
    }
    internal struct RPC_SID_IDENTIFIER_AUTHORITY_DEVICE : NtApiDotNet.Ndr.Marshal.INdrStructure
    {
        void NtApiDotNet.Ndr.Marshal.INdrStructure.Marshal(NtApiDotNet.Ndr.Marshal.NdrMarshalBuffer m)
        {
            throw new NotImplementedException();
        }

        void NtApiDotNet.Ndr.Marshal.INdrStructure.Unmarshal(NtApiDotNet.Ndr.Marshal.NdrUnmarshalBuffer u)
        {
            Unmarshal(((_Unmarshal_HelperDeviceInfo)(u)));
        }
        private void Unmarshal(_Unmarshal_HelperDeviceInfo u)
        {
            Value = u.Read_12();
        }
        int NtApiDotNet.Ndr.Marshal.INdrStructure.GetAlignment()
        {
            return 1;
        }
        internal byte[] Value;
    }
    internal struct GROUP_MEMBERSHIP_DEVICE : NtApiDotNet.Ndr.Marshal.INdrStructure
    {
        void NtApiDotNet.Ndr.Marshal.INdrStructure.Marshal(NtApiDotNet.Ndr.Marshal.NdrMarshalBuffer m)
        {
            throw new NotImplementedException();
        }

        void NtApiDotNet.Ndr.Marshal.INdrStructure.Unmarshal(NtApiDotNet.Ndr.Marshal.NdrUnmarshalBuffer u)
        {
            Unmarshal(((_Unmarshal_HelperDeviceInfo)(u)));
        }
        private void Unmarshal(_Unmarshal_HelperDeviceInfo u)
        {
            RelativeId = u.ReadInt32();
            Attributes = u.ReadInt32();
        }
        int NtApiDotNet.Ndr.Marshal.INdrStructure.GetAlignment()
        {
            return 4;
        }
        internal int RelativeId;
        internal int Attributes;
    }
    internal struct KERB_SID_AND_ATTRIBUTES_DEVICE : NtApiDotNet.Ndr.Marshal.INdrStructure
    {
        void NtApiDotNet.Ndr.Marshal.INdrStructure.Marshal(NtApiDotNet.Ndr.Marshal.NdrMarshalBuffer m)
        {
            throw new NotImplementedException();
        }

        void NtApiDotNet.Ndr.Marshal.INdrStructure.Unmarshal(NtApiDotNet.Ndr.Marshal.NdrUnmarshalBuffer u)
        {
            Unmarshal(((_Unmarshal_HelperDeviceInfo)(u)));
        }
        private void Unmarshal(_Unmarshal_HelperDeviceInfo u)
        {
            Sid = u.ReadEmbeddedPointer<RPC_SID_DEVICE>(new System.Func<RPC_SID_DEVICE>(u.Read_1), false);
            Attributes = u.ReadInt32();
        }
        int NtApiDotNet.Ndr.Marshal.INdrStructure.GetAlignment()
        {
            return 4;
        }
        internal NtApiDotNet.Ndr.Marshal.NdrEmbeddedPointer<RPC_SID_DEVICE> Sid;
        internal int Attributes;
    }
    internal struct DOMAIN_GROUP_MEMBERSHIP : NtApiDotNet.Ndr.Marshal.INdrStructure
    {
        void NtApiDotNet.Ndr.Marshal.INdrStructure.Marshal(NtApiDotNet.Ndr.Marshal.NdrMarshalBuffer m)
        {
            throw new NotImplementedException();
        }

        void NtApiDotNet.Ndr.Marshal.INdrStructure.Unmarshal(NtApiDotNet.Ndr.Marshal.NdrUnmarshalBuffer u)
        {
            Unmarshal(((_Unmarshal_HelperDeviceInfo)(u)));
        }
        private void Unmarshal(_Unmarshal_HelperDeviceInfo u)
        {
            DomainId = u.ReadEmbeddedPointer<RPC_SID_DEVICE>(new System.Func<RPC_SID_DEVICE>(u.Read_1), false);
            GroupCount = u.ReadInt32();
            GroupIds = u.ReadEmbeddedPointer<GROUP_MEMBERSHIP_DEVICE[]>(new System.Func<GROUP_MEMBERSHIP_DEVICE[]>(u.Read_15), false);
        }
        int NtApiDotNet.Ndr.Marshal.INdrStructure.GetAlignment()
        {
            return 4;
        }
        internal NtApiDotNet.Ndr.Marshal.NdrEmbeddedPointer<RPC_SID_DEVICE> DomainId;
        internal int GroupCount;
        internal NtApiDotNet.Ndr.Marshal.NdrEmbeddedPointer<GROUP_MEMBERSHIP_DEVICE[]> GroupIds;

    }
    #endregion
    #region Complex Type Encoders
    internal static class PacDeviceInfoParser
    {
        internal static System.Nullable<PAC_DEVICE_INFO> Decode(NtApiDotNet.Ndr.Marshal.NdrPickledType pickled_type)
        {
            _Unmarshal_HelperDeviceInfo u = new _Unmarshal_HelperDeviceInfo(pickled_type);
            System.Nullable<PAC_DEVICE_INFO> v;
            v = u.ReadReferentValue<PAC_DEVICE_INFO>(new System.Func<PAC_DEVICE_INFO>(u.Read_0), false);
            return v;
        }
    }
    #endregion
}

