public TypeDescriptor(Type builtinType,
                                  NdrParamAttributes attributes,
                                  params CustomAttributeBuilder[] customAttributes)
            {
                ParameterAttributes real_attributes = ParameterAttributes.None;

                BuiltinType = builtinType;
                if (attributes.HasFlag(NdrParamAttributes.IsSimpleRef))
                {
                    PointerCount = 1;
                }

                CustomAttributes = new List <CustomAttributeBuilder>(customAttributes);
                if (attributes.HasFlag(NdrParamAttributes.IsIn))
                {
                    CustomAttributes.Add(CreateAttribute <InAttribute>());
                    real_attributes |= ParameterAttributes.In;
                }

                if (attributes.HasFlag(NdrParamAttributes.IsOut))
                {
                    CustomAttributes.Add(CreateAttribute <OutAttribute>());
                    real_attributes |= ParameterAttributes.Out;
                }
                Attributes = real_attributes;
            }
예제 #2
0
 internal NdrProcedureParameter(NdrParamAttributes attributes, int server_alloc_size, NdrBaseTypeReference type, int offset)
 {
     Attributes      = attributes;
     ServerAllocSize = server_alloc_size;
     Type            = type;
     Offset          = offset;
 }
예제 #3
0
 internal NdrProcedureHandleParameter(NdrParamAttributes attributes,
                                      NdrBaseTypeReference type, int offset, bool explicit_handle, NdrHandleParamFlags flags)
     : base(attributes, 0, type, offset)
 {
     Flags    = flags;
     Explicit = explicit_handle;
 }
 internal NdrProcedureHandleParameter(NdrParamAttributes attributes,
                                      NdrBaseTypeReference type, int offset, bool explicit_handle, NdrHandleParamFlags flags, bool generic)
     : base(attributes, 0, type, offset, string.Empty)
 {
     Flags    = flags;
     Explicit = explicit_handle;
     Generic  = generic;
 }
        private TypeDescriptor GetTypeDescriptor(NdrParamAttributes paramAttributes, NdrBaseTypeReference baseType, bool field_type = false)
        {
            if (baseType is NdrSimpleTypeReference || baseType is NdrBaseStringTypeReference)
            {
                switch (baseType.Format)
                {
                case NdrFormatCharacter.FC_BYTE:
                case NdrFormatCharacter.FC_USMALL:
                    return(new TypeDescriptor(typeof(byte), paramAttributes));

                case NdrFormatCharacter.FC_SMALL:
                case NdrFormatCharacter.FC_CHAR:
                    return(new TypeDescriptor(typeof(sbyte), paramAttributes));

                case NdrFormatCharacter.FC_WCHAR:
                    return(new TypeDescriptor(typeof(char), paramAttributes));

                case NdrFormatCharacter.FC_SHORT:
                    return(new TypeDescriptor(typeof(short), paramAttributes));

                case NdrFormatCharacter.FC_USHORT:
                    return(new TypeDescriptor(typeof(ushort), paramAttributes));

                case NdrFormatCharacter.FC_ENUM16:
                case NdrFormatCharacter.FC_LONG:
                case NdrFormatCharacter.FC_ENUM32:
                    return(new TypeDescriptor(typeof(int), paramAttributes));

                case NdrFormatCharacter.FC_ULONG:
                case NdrFormatCharacter.FC_ERROR_STATUS_T:
                    return(new TypeDescriptor(typeof(uint), paramAttributes));

                case NdrFormatCharacter.FC_FLOAT:
                    return(new TypeDescriptor(typeof(float), paramAttributes));

                case NdrFormatCharacter.FC_HYPER:
                    return(new TypeDescriptor(typeof(long), paramAttributes));

                case NdrFormatCharacter.FC_DOUBLE:
                    return(new TypeDescriptor(typeof(double), paramAttributes));

                case NdrFormatCharacter.FC_INT3264:
                    return(new TypeDescriptor(typeof(IntPtr), paramAttributes));

                case NdrFormatCharacter.FC_UINT3264:
                    return(new TypeDescriptor(typeof(UIntPtr), paramAttributes));

                case NdrFormatCharacter.FC_C_WSTRING:
                    return(new TypeDescriptor(typeof(string), paramAttributes, CreateMarshalAsAttribute(UnmanagedType.LPWStr)));

                case NdrFormatCharacter.FC_C_CSTRING:
                    return(new TypeDescriptor(typeof(string), paramAttributes, CreateMarshalAsAttribute(UnmanagedType.LPStr)));
                }
            }
            else if (baseType is NdrKnownTypeReference known_type)
            {
                switch (known_type.KnownType)
                {
                case NdrKnownTypes.BSTR:
                    return(new TypeDescriptor(typeof(string), paramAttributes, CreateMarshalAsAttribute(UnmanagedType.BStr)));

                case NdrKnownTypes.GUID:
                    return(new TypeDescriptor(typeof(Guid), paramAttributes));

                case NdrKnownTypes.HSTRING:
                    return(new TypeDescriptor(typeof(string), paramAttributes, CreateMarshalAsAttribute(UnmanagedType.HString)));

                case NdrKnownTypes.VARIANT:
                    return(new TypeDescriptor(typeof(object), paramAttributes, CreateMarshalAsAttribute(UnmanagedType.Struct)));
                }
            }
            else if (baseType is NdrPointerTypeReference pointer_type)
            {
                return(new TypeDescriptor(GetTypeDescriptor(paramAttributes, pointer_type.Type)));
            }
            else if (baseType is NdrInterfacePointerTypeReference interface_pointer)
            {
                TypeDescriptor intf_p;
                if (interface_pointer.IsConstant && m_proxies.ContainsKey(interface_pointer.Iid))
                {
                    intf_p = new TypeDescriptor(CreateInterface(m_proxies[interface_pointer.Iid]), paramAttributes, CreateMarshalAsAttribute(UnmanagedType.Interface));
                }
                else
                {
                    intf_p = new TypeDescriptor(typeof(object), paramAttributes, CreateMarshalAsAttribute(UnmanagedType.IUnknown));
                }
                // Interface pointer should have a pointer value of 1.
                return(new TypeDescriptor(intf_p));
            }
            else if (baseType is NdrBaseStructureTypeReference struct_type)
            {
                return(new TypeDescriptor(CreateStruct(struct_type), paramAttributes));
            }

            if (field_type)
            {
                return(null);
            }
            return(new TypeDescriptor(typeof(IntPtr), paramAttributes));
        }
예제 #6
0
 internal NdrProcedureParameter(NdrParamAttributes attributes, NdrBaseTypeReference type, int offset)
 {
     Attributes = attributes;
     Type       = type;
     Offset     = offset;
 }