Example #1
0
 private void ScanDefinedFunctions(ITypeInfo typeInfo, System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttributes)
 {
     for (int i = 0; i < typeAttributes.cFuncs; i++)
     {
         IntPtr zero = IntPtr.Zero;
         try
         {
             System.Runtime.InteropServices.ComTypes.FUNCDESC funcdesc;
             ComReference.GetFuncDescForDescIndex(typeInfo, i, out funcdesc, out zero);
             int num2 = 0;
             for (int j = 0; j < funcdesc.cParams; j++)
             {
                 System.Runtime.InteropServices.ComTypes.ELEMDESC elementDesc = (System.Runtime.InteropServices.ComTypes.ELEMDESC)Marshal.PtrToStructure(new IntPtr(funcdesc.lprgelemdescParam.ToInt64() + num2), typeof(System.Runtime.InteropServices.ComTypes.ELEMDESC));
                 this.AnalyzeElement(typeInfo, elementDesc);
                 num2 += Marshal.SizeOf(typeof(System.Runtime.InteropServices.ComTypes.ELEMDESC));
             }
             this.AnalyzeElement(typeInfo, funcdesc.elemdescFunc);
         }
         finally
         {
             if (zero != IntPtr.Zero)
             {
                 typeInfo.ReleaseFuncDesc(zero);
             }
         }
     }
 }
Example #2
0
        private bool CanSkipType(ITypeInfo typeInfo, ITypeLib typeLib, System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttributes, System.Runtime.InteropServices.ComTypes.TYPELIBATTR typeLibAttributes)
        {
            if (((typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IUnknown) || (typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IDispatch)) || (((typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IDispatchEx) || (typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_IEnumVariant)) || (typeAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_ITypeInfo)))
            {
                return(true);
            }
            if (typeLibAttributes.guid == Microsoft.Build.Tasks.NativeMethods.IID_StdOle)
            {
                string str;
                string str2;
                string str3;
                int    num;
                typeInfo.GetDocumentation(-1, out str, out str2, out num, out str3);
                if (string.CompareOrdinal(str, "GUID") == 0)
                {
                    return(true);
                }
            }
            ITypeLib2 lib = typeLib as ITypeLib2;

            if (lib != null)
            {
                object obj2;
                lib.GetCustData(ref Microsoft.Build.Tasks.NativeMethods.GUID_ExportedFromComPlus, out obj2);
                string str4 = obj2 as string;
                if (!string.IsNullOrEmpty(str4))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
 public ComStruct(ITypeLib typeLib, ITypeInfo info, TYPEATTR attrib, int index)
     : base(typeLib, attrib, index)
 {
     _fields = new List <ComField>();
     Type    = DeclarationType.UserDefinedType;
     GetFields(info, attrib);
 }
Example #4
0
        public ComInterfaceType GetInterfaceType()
        {
            Debug.Assert(m_typeInfo != null, "m_typeInfo != null");

            IntPtr ptr = IntPtr.Zero;

            m_typeInfo.ComType.GetTypeAttr(out ptr);

            try
            {
                TYPEATTR typeAttr = (TYPEATTR)Marshal.PtrToStructure(ptr, typeof(TYPEATTR));

                ObjectType type = GetObjectType(typeAttr);
                if (type != ObjectType.Interface)
                {
                    throw new ApplicationException("Unable to get the interface type for type '"
                                                   + DisplayName + "', because its object type is '" + ComBrowserSettings.GetKeyword(type)
                                                   + "', not 'interface'.");
                }

                return(GetInterfaceType(typeAttr));
            }
            finally
            {
                m_typeInfo.ComType.ReleaseTypeAttr(ptr);
            }
        }
Example #5
0
        internal static ITypeInfo GetDispatchTypeInfoFromCoClassTypeInfo(ITypeInfo typeinfo)
        {
            int       cImplTypes = (int)ComTypeInfo.GetTypeAttr(typeinfo).cImplTypes;
            ITypeInfo ppTI       = (ITypeInfo)null;

            for (int index = 0; index < cImplTypes; ++index)
            {
                int href;
                typeinfo.GetRefTypeOfImplType(index, out href);
                typeinfo.GetRefTypeInfo(href, out ppTI);
                System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttr = ComTypeInfo.GetTypeAttr(ppTI);
                if (typeAttr.typekind == System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_DISPATCH)
                {
                    return(ppTI);
                }
                if ((typeAttr.wTypeFlags & System.Runtime.InteropServices.ComTypes.TYPEFLAGS.TYPEFLAG_FDUAL) != (System.Runtime.InteropServices.ComTypes.TYPEFLAGS) 0)
                {
                    ppTI = ComTypeInfo.GetDispatchTypeInfoFromCustomInterfaceTypeInfo(ppTI);
                    if (ComTypeInfo.GetTypeAttr(ppTI).typekind == System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_DISPATCH)
                    {
                        return(ppTI);
                    }
                }
            }
            return((ITypeInfo)null);
        }
Example #6
0
        private static Guid GetParentLibGuid(object comProxy)
        {
            Guid returnGuid = Guid.Empty;

            IDispatch dispatcher = (IDispatch)comProxy;

            COMTypes.ITypeInfo typeInfo      = dispatcher.GetTypeInfo(0, 0);
            COMTypes.ITypeLib  parentTypeLib = null;

            int i = 0;

            typeInfo.GetContainingTypeLib(out parentTypeLib, out i);

            IntPtr attributesPointer = IntPtr.Zero;

            parentTypeLib.GetLibAttr(out attributesPointer);

            COMTypes.TYPEATTR attributes = (COMTypes.TYPEATTR)Marshal.PtrToStructure(attributesPointer, typeof(COMTypes.TYPEATTR));
            returnGuid = attributes.guid;

            parentTypeLib.ReleaseTLibAttr(attributesPointer);
            Marshal.ReleaseComObject(parentTypeLib);
            Marshal.ReleaseComObject(typeInfo);

            return(returnGuid);
        }
Example #7
0
        internal static ObjectType GetObjectType(TYPEATTR typeAttr)
        {
            switch (typeAttr.typekind)
            {
            case TYPEKIND.TKIND_COCLASS:
                return(ObjectType.Class);

            case TYPEKIND.TKIND_INTERFACE:
            case TYPEKIND.TKIND_DISPATCH:
                return(ObjectType.Interface);

            case TYPEKIND.TKIND_ENUM:
                return(ObjectType.Enum);

            case TYPEKIND.TKIND_RECORD:
                return(ObjectType.Struct);

            case TYPEKIND.TKIND_UNION:
                return(ObjectType.Union);

            case TYPEKIND.TKIND_MODULE:
                return(ObjectType.Module);

            case TYPEKIND.TKIND_ALIAS:
                return(ObjectType.Alias);

            default:
                throw new ApplicationException("Unsupported object type: '" + typeAttr.typekind.ToString() + "'.");
            }
        }
Example #8
0
        private void Initialize()
        {
            using (ComTypeInfo.tracer.TraceMethod())
            {
                if (this.typeinfo == null)
                {
                    return;
                }
                System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttr = ComTypeInfo.GetTypeAttr(this.typeinfo);
                this.guid = typeAttr.guid;
                for (int firstUserMethod = ComTypeInfo.FindFirstUserMethod(typeAttr); firstUserMethod < (int)typeAttr.cFuncs; ++firstUserMethod)
                {
                    System.Runtime.InteropServices.ComTypes.FUNCDESC funcDesc = ComTypeInfo.GetFuncDesc(this.typeinfo, firstUserMethod);
                    string nameFromFuncDesc = ComUtil.GetNameFromFuncDesc(this.typeinfo, funcDesc);
                    switch (funcDesc.invkind)
                    {
                    case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_FUNC:
                        this.AddMethod(nameFromFuncDesc, firstUserMethod);
                        break;

                    case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYGET:
                    case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYPUT:
                    case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYPUTREF:
                        this.AddProperty(nameFromFuncDesc, funcDesc, firstUserMethod);
                        break;
                    }
                }
            }
        }
Example #9
0
        internal static ComTypeInfo GetDispatchTypeInfo(object comObject)
        {
            ComTypeInfo result = null;
            IDispatch   disp   = comObject as IDispatch;

            if (disp != null)
            {
                COM.ITypeInfo typeinfo = null;
                disp.GetTypeInfo(0, 0, out typeinfo);
                if (typeinfo != null)
                {
                    COM.TYPEATTR typeattr = GetTypeAttr(typeinfo);

                    if ((typeattr.typekind == COM.TYPEKIND.TKIND_INTERFACE))
                    {
                        // We have typeinfo for custom interface. Get typeinfo for Dispatch interface.
                        typeinfo = GetDispatchTypeInfoFromCustomInterfaceTypeInfo(typeinfo);
                    }

                    if ((typeattr.typekind == COM.TYPEKIND.TKIND_COCLASS))
                    {
                        // We have typeinfo for the COClass.  Find the default interface and get typeinfo for default interface.
                        typeinfo = GetDispatchTypeInfoFromCoClassTypeInfo(typeinfo);
                    }

                    result = new ComTypeInfo(typeinfo);
                }
            }

            return(result);
        }
Example #10
0
        internal ComTypeEnumDesc(ComTypes.ITypeInfo typeInfo, ComTypeLibDesc typeLibDesc) :
            base(typeInfo, ComType.Enum, typeLibDesc)
        {
            ComTypes.TYPEATTR typeAttr     = ComRuntimeHelpers.GetTypeAttrForTypeInfo(typeInfo);
            string[]          memberNames  = new string[typeAttr.cVars];
            object[]          memberValues = new object[typeAttr.cVars];

            IntPtr p = IntPtr.Zero;

            // For each enum member get name and value.
            for (int i = 0; i < typeAttr.cVars; i++)
            {
                typeInfo.GetVarDesc(i, out p);

                // Get the enum member value (as object).
                ComTypes.VARDESC varDesc;

                try {
                    varDesc = (ComTypes.VARDESC)Marshal.PtrToStructure(p, typeof(ComTypes.VARDESC));

                    if (varDesc.varkind == ComTypes.VARKIND.VAR_CONST)
                    {
                        memberValues[i] = Marshal.GetObjectForNativeVariant(varDesc.desc.lpvarValue);
                    }
                } finally {
                    typeInfo.ReleaseVarDesc(p);
                }

                // Get the enum member name
                memberNames[i] = ComRuntimeHelpers.GetNameOfMethod(typeInfo, varDesc.memid);
            }

            _memberNames  = memberNames;
            _memberValues = memberValues;
        }
Example #11
0
 public ComInterface(IComBase parent, ITypeLib typeLib, ITypeInfo info, TYPEATTR attrib, int index) : base(parent, typeLib, attrib, index)
 {
     Type = DeclarationType.ClassModule;
     GetImplementedInterfaces(info, attrib);
     GetComProperties(info, attrib);
     GetComMembers(info, attrib);
 }
Example #12
0
 public ComEnumeration(ITypeLib typeLib, ITypeInfo info, TYPEATTR attrib, int index) : base(typeLib, attrib, index)
 {
     Members = new List <ComEnumerationMember>();
     Type    = DeclarationType.Enumeration;
     GetEnumerationMembers(info, attrib);
     ComProject.KnownEnumerations.TryAdd(Guid, this);
 }
Example #13
0
        internal static ITypeInfo GetDispatchTypeInfoFromCoClassTypeInfo(ITypeInfo typeinfo)
        {
            int       cImplTypes = GetTypeAttr(typeinfo).cImplTypes;
            ITypeInfo ppTI       = null;

            for (int i = 0; i < cImplTypes; i++)
            {
                int num2;
                typeinfo.GetRefTypeOfImplType(i, out num2);
                typeinfo.GetRefTypeInfo(num2, out ppTI);
                System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttr = GetTypeAttr(ppTI);
                if (typeAttr.typekind == System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_DISPATCH)
                {
                    return(ppTI);
                }
                if (((short)(typeAttr.wTypeFlags & System.Runtime.InteropServices.ComTypes.TYPEFLAGS.TYPEFLAG_FDUAL)) != 0)
                {
                    ppTI = GetDispatchTypeInfoFromCustomInterfaceTypeInfo(ppTI);
                    if (GetTypeAttr(ppTI).typekind == System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_DISPATCH)
                    {
                        return(ppTI);
                    }
                }
            }
            return(null);
        }
Example #14
0
 public ComCoClass(ITypeLib typeLib, ITypeInfo info, TYPEATTR attrib, int index) : base(typeLib, attrib, index)
 {
     Type = DeclarationType.ClassModule;
     GetImplementedInterfaces(info, attrib);
     IsControl = attrib.wTypeFlags.HasFlag(TYPEFLAGS.TYPEFLAG_FCONTROL);
     Debug.Assert(attrib.cFuncs == 0);
 }
Example #15
0
        internal static ComTypeInfo GetDispatchTypeInfo(object comObject)
        {
            ComTypeInfo info = null;

            System.Management.Automation.IDispatch dispatch = comObject as System.Management.Automation.IDispatch;
            if (dispatch == null)
            {
                return(info);
            }
            ITypeInfo ppTInfo = null;

            dispatch.GetTypeInfo(0, 0, out ppTInfo);
            if (ppTInfo == null)
            {
                return(info);
            }
            System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttr = GetTypeAttr(ppTInfo);
            if (typeAttr.typekind == System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_INTERFACE)
            {
                ppTInfo = GetDispatchTypeInfoFromCustomInterfaceTypeInfo(ppTInfo);
            }
            if (typeAttr.typekind == System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_COCLASS)
            {
                ppTInfo = GetDispatchTypeInfoFromCoClassTypeInfo(ppTInfo);
            }
            return(new ComTypeInfo(ppTInfo));
        }
Example #16
0
        private void Initialize()
        {
            if (this.typeinfo != null)
            {
                System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttr = GetTypeAttr(this.typeinfo);
                this.guid = typeAttr.guid;
                for (int i = 0; i < typeAttr.cFuncs; i++)
                {
                    string nameFromFuncDesc;
                    System.Runtime.InteropServices.ComTypes.FUNCDESC funcDesc = GetFuncDesc(this.typeinfo, i);
                    if ((funcDesc.wFuncFlags & 1) != 1)
                    {
                        nameFromFuncDesc = ComUtil.GetNameFromFuncDesc(this.typeinfo, funcDesc);
                        switch (funcDesc.invkind)
                        {
                        case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_FUNC:
                            this.AddMethod(nameFromFuncDesc, i);
                            break;

                        case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYGET:
                        case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYPUT:
                        case System.Runtime.InteropServices.ComTypes.INVOKEKIND.INVOKE_PROPERTYPUTREF:
                            goto Label_0075;
                        }
                    }
                    continue;
Label_0075:
                    this.AddProperty(nameFromFuncDesc, funcDesc, i);
                }
            }
        }
Example #17
0
        private void LoadTypes()
        {
            _typeInfos = new List <ComTypeInfo>();

            int count = _typeLib.GetTypeInfoCount();

            for (int i = 0; i < count; i++)
            {
                ITypeInfo typeInfo = null;
                _typeLib.GetTypeInfo(i, out typeInfo);

                IntPtr pTypeAttr = IntPtr.Zero;
                typeInfo.GetTypeAttr(out pTypeAttr);
                System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttr = pTypeAttr.ToStructure <System.Runtime.InteropServices.ComTypes.TYPEATTR>();

                switch (typeAttr.typekind)
                {
                case System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_ALIAS:
                    _typeInfos.Add(new ComAliasInfo(this, typeInfo, pTypeAttr));
                    break;

                case System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_COCLASS:
                    _typeInfos.Add(new ComCoClassInfo(this, typeInfo, pTypeAttr));
                    break;

                case System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_DISPATCH:
                    _typeInfos.Add(new ComDispatchInfo(this, typeInfo, pTypeAttr));
                    break;

                case System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_ENUM:
                    _typeInfos.Add(new ComEnumInfo(this, typeInfo, pTypeAttr));
                    break;

                case System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_INTERFACE:
                    _typeInfos.Add(new ComInterfaceInfo(this, typeInfo, pTypeAttr));
                    break;

                //case System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_MAX:
                //    _typeInfos.Add(new ComMaxInfo(this, typeInfo, pTypeAttr));
                //    break;
                case System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_MODULE:
                    _typeInfos.Add(new ComModuleInfo(this, typeInfo, pTypeAttr));
                    break;

                case System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_RECORD:
                    _typeInfos.Add(new ComRecordInfo(this, typeInfo, pTypeAttr));
                    break;

                case System.Runtime.InteropServices.ComTypes.TYPEKIND.TKIND_UNION:
                    _typeInfos.Add(new ComUnionInfo(this, typeInfo, pTypeAttr));
                    break;
                }
            }

            _typeInfos.Sort(delegate(ComTypeInfo a, ComTypeInfo b)
            {
                return(a.Name.CompareTo(b.Name));
            });
        }
Example #18
0
 public ComTypeInfo(ComTypeLibrary comTypeLibrary, ITypeInfo typeInfo, IntPtr pTypeAttr)
 {
     _comTypeLibrary = comTypeLibrary;
     _typeInfo       = typeInfo;
     _pTypeAttr      = pTypeAttr;
     _typeAttr       = _pTypeAttr.ToStructure <System.Runtime.InteropServices.ComTypes.TYPEATTR>();
     _typeInfo.GetDocumentation(-1, out _name, out _description, out _helpContext, out _helpFile);
 }
Example #19
0
 private static void AppendTypeAttribute(DescriptionBuilder sb, TYPEATTR typeAttr, TYPEFLAGS attribute)
 {
     if ((typeAttr.wTypeFlags & attribute) == attribute)
     {
         sb.Append(", ");
         sb.Append(ComBrowserSettings.GetKeyword(attribute));
     }
 }
Example #20
0
        internal static COM.TYPEATTR GetTypeAttr(COM.ITypeInfo typeinfo)
        {
            IntPtr pTypeAttr;

            typeinfo.GetTypeAttr(out pTypeAttr);
            COM.TYPEATTR typeattr = Marshal.PtrToStructure <COM.TYPEATTR>(pTypeAttr);
            typeinfo.ReleaseTypeAttr(pTypeAttr);
            return(typeattr);
        }
Example #21
0
        internal static System.Runtime.InteropServices.ComTypes.TYPEATTR GetTypeAttr(ITypeInfo typeinfo)
        {
            IntPtr ptr;

            typeinfo.GetTypeAttr(out ptr);
            System.Runtime.InteropServices.ComTypes.TYPEATTR typeattr = (System.Runtime.InteropServices.ComTypes.TYPEATTR)Marshal.PtrToStructure(ptr, typeof(System.Runtime.InteropServices.ComTypes.TYPEATTR));
            typeinfo.ReleaseTypeAttr(ptr);
            return(typeattr);
        }
Example #22
0
        private static int FindFirstUserMethod(System.Runtime.InteropServices.ComTypes.TYPEATTR typeattr)
        {
            int num = 0;

            if (typeattr.cFuncs >= (short)7)
            {
                num = 7;
            }
            return(num);
        }
Example #23
0
 private void LoadVars(ITypeInfo typeInfo, TYPEATTR typeAttr)
 {
     //TODO: Узнать что сюда прилетает
     // for (var i = 0; i < typeAttr.cVars; i++)
     // {
     //     typeInfo.GetVarDesc(i, out var ptVarDesc);
     //     var varDesc = Marshal.PtrToStructure<VARDESC>(ptVarDesc);
     //
     //     Marshal.Release(ptVarDesc);
     // }
 }
Example #24
0
        /// <summary>
        /// Returns id of an interface
        /// </summary>
        /// <param name="typeInfo">com type informations</param>
        /// <returns>interface id(iid)</returns>
        internal static Guid GetTypeGuid(this COMTypes.ITypeInfo typeInfo)
        {
            IntPtr attribPtr = IntPtr.Zero;

            typeInfo.GetTypeAttr(out attribPtr);
            COMTypes.TYPEATTR Attributes = (COMTypes.TYPEATTR)Marshal.PtrToStructure(attribPtr, typeof(COMTypes.TYPEATTR));
            Guid typeGuid = Attributes.guid;

            typeInfo.ReleaseTypeAttr(attribPtr);
            return(typeGuid);
        }
Example #25
0
        private void LoadFuncs(ITypeInfo typeInfo, TYPEATTR typeAttr)
        {
            var skippingFlags = FUNCFLAGS.FUNCFLAG_FRESTRICTED | FUNCFLAGS.FUNCFLAG_FHIDDEN;

            for (var i = 0; i < typeAttr.cFuncs; i++)
            {
                typeInfo.GetFuncDesc(i, out var ptFuncDesc);
                var funcDesc = Marshal.PtrToStructure <FUNCDESC>(ptFuncDesc);

                var currentFlags = (FUNCFLAGS)funcDesc.wFuncFlags;

                if ((currentFlags & skippingFlags) != 0)
                {
                    Marshal.Release(ptFuncDesc);
                    continue;
                }

                var arrOfNames = new string[1];
                var cNames     = arrOfNames.Length;
                var dispId     = funcDesc.memid;

                typeInfo.GetNames(dispId, arrOfNames, cNames, out var names);

                if (names == 0)
                {
                    Marshal.Release(ptFuncDesc);
                    continue;
                }

                var memberName = arrOfNames[0];

                if (funcDesc.invkind == INVOKEKIND.INVOKE_FUNC)
                {
                    var isFunc = funcDesc.elemdescFunc.tdesc.vt != VT_VOID;
                    AddMethod(memberName, dispId, isFunc);
                }
                else
                {
                    var prop = GetOrAddProperty(memberName, dispId);

                    if (funcDesc.invkind == INVOKEKIND.INVOKE_PROPERTYGET)
                    {
                        prop.IsReadable = true;
                    }
                    else
                    {
                        prop.IsWritable = true;
                    }
                }

                Marshal.Release(ptFuncDesc);
            }
        }
Example #26
0
 public ComModule(IComBase parent, ITypeLib typeLib, ITypeInfo info, TYPEATTR attrib, int index) : base(parent, typeLib, attrib, index)
 {
     Debug.Assert(attrib.cFuncs >= 0 && attrib.cVars >= 0);
     Type = DeclarationType.ProceduralModule;
     if (attrib.cFuncs > 0)
     {
         GetComMembers(info, attrib);
     }
     if (attrib.cVars > 0)
     {
         GetComFields(info, attrib);
     }
 }
Example #27
0
        private void GetEnumerationMembers(ITypeInfo info, TYPEATTR attrib)
        {
            var count = attrib.cVars;

            for (var index = 0; index < count; index++)
            {
                IntPtr varPtr;
                info.GetVarDesc(index, out varPtr);
                var desc = (VARDESC)Marshal.PtrToStructure(varPtr, typeof(VARDESC));
                Members.Add(new ComEnumerationMember(info, desc));
                info.ReleaseVarDesc(varPtr);
            }
        }
Example #28
0
 public ComModule(ITypeLib typeLib, ITypeInfo info, TYPEATTR attrib, int index) : base(typeLib, attrib, index)
 {
     Type = DeclarationType.ProceduralModule;
     if (attrib.cFuncs > 0)
     {
         Debug.Assert(attrib.cVars == 0);
         GetComMembers(info, attrib);
     }
     else
     {
         Debug.Assert(attrib.cVars > 0);
         GetComFields(info, attrib);
     }
 }
        private void GetEnumerationMembers(ITypeInfo info, TYPEATTR attrib)
        {
            var count = attrib.cVars;

            for (var index = 0; index < count; index++)
            {
                info.GetVarDesc(index, out IntPtr varPtr);
                using (DisposalActionContainer.Create(varPtr, info.ReleaseVarDesc))
                {
                    var desc = Marshal.PtrToStructure <VARDESC>(varPtr);
                    Members.Add(new ComEnumerationMember(this, info, desc));
                }
            }
        }
        private IEnumerable <string> GetImplementedInterfaceNames(TYPEATTR typeAttr, ITypeInfo info)
        {
            var output = new List <string>();

            for (var implIndex = 0; implIndex < typeAttr.cImplTypes; implIndex++)
            {
                int href;
                info.GetRefTypeOfImplType(implIndex, out href);

                ITypeInfo implTypeInfo;
                info.GetRefTypeInfo(href, out implTypeInfo);

                IntPtr typeAttributesPointer;
                implTypeInfo.GetTypeAttr(out typeAttributesPointer);

                var typeAttributes = (TYPEATTR)Marshal.PtrToStructure(typeAttributesPointer, typeof(TYPEATTR));

                IMPLTYPEFLAGS flags = 0;
                try
                {
                    info.GetImplTypeFlags(implIndex, out flags);
                }
                catch (COMException) { }

                var implTypeName = GetTypeName(implTypeInfo);
                if (implTypeName != "IDispatch" && implTypeName != "IUnknown")
                {
                    // skip IDispatch.. just about everything implements it and RD doesn't need to care about it; don't care about IUnknown either
                    output.Add(implTypeName);
                }

                if (flags != 0)
                {
                    ComInformation comInfo;
                    if (_comInformation.TryGetValue(typeAttributes.guid, out comInfo))
                    {
                        _comInformation[typeAttributes.guid].ImplTypeFlags =
                            _comInformation[typeAttributes.guid].ImplTypeFlags | flags;
                    }
                    else
                    {
                        _comInformation.Add(typeAttributes.guid,
                                            new ComInformation(typeAttributes, flags, implTypeInfo, implTypeName, new QualifiedModuleName(), null, 0));
                    }
                }

                info.ReleaseTypeAttr(typeAttributesPointer);
            }
            return(output);
        }
Example #31
0
        /// <summary>
        /// Helper method for retrieving type attributes for a given type info
        /// </summary>
        /// <param name="typeInfo"></param>
        /// <param name="typeAttr"></param>
        /// <returns></returns>
        internal static void GetTypeAttrForTypeInfo(ITypeInfo typeInfo, out TYPEATTR typeAttr)
        {
            IntPtr pAttrs = IntPtr.Zero;
            typeInfo.GetTypeAttr(out pAttrs);

            // GetTypeAttr should never return null, this is just to be safe
            if (pAttrs == IntPtr.Zero)
            {
                throw new COMException(
                    ResourceUtilities.FormatResourceString("ResolveComReference.CannotRetrieveTypeInformation"));
            }

            try
            {
                typeAttr = (TYPEATTR)Marshal.PtrToStructure(pAttrs, typeof(TYPEATTR));
            }
            finally
            {
                typeInfo.ReleaseTypeAttr(pAttrs);
            }
        }
Example #32
0
 public ComTypeInfo(ComTypeLibrary comTypeLibrary, ITypeInfo typeInfo, IntPtr pTypeAttr)
 {
     _comTypeLibrary = comTypeLibrary;
     _typeInfo = typeInfo;
     _pTypeAttr = pTypeAttr;
     _typeAttr = _pTypeAttr.ToStructure<System.Runtime.InteropServices.ComTypes.TYPEATTR>();
     _typeInfo.GetDocumentation(-1, out _name, out _description, out _helpContext, out _helpFile);
 }
Example #33
0
 private static string ProgIdFromTypeAttr(TYPEATTR typeattr)
 {
     string lplpszProgID;
     ProgIDFromCLSID(ref typeattr.guid, out lplpszProgID);
     return lplpszProgID;
 }