Exemple #1
0
        public override AssemblyName[] GetReferencedAssemblies()
        {
            Token token;
            int   num;
            IMetadataAssemblyImport rawImport     = (IMetadataAssemblyImport)this.m_manifestModule.RawImport;
            List <AssemblyName>     assemblyNames = new List <AssemblyName>();
            HCORENUM hCORENUM = new HCORENUM();

            try
            {
                while (true)
                {
                    int num1 = rawImport.EnumAssemblyRefs(ref hCORENUM, out token, 1, out num);
                    Marshal.ThrowExceptionForHR(num1);
                    if (num == 0)
                    {
                        break;
                    }
                    assemblyNames.Add(AssemblyNameHelper.GetAssemblyNameFromRef(token, this.m_manifestModule, rawImport));
                }
            }
            finally
            {
                hCORENUM.Close(rawImport);
            }
            return(assemblyNames.ToArray());
        }
Exemple #2
0
        private static List <string> GetFileNamesFromFilesTable(MetadataOnlyModule manifestModule, bool getResources)
        {
            int                     num;
            int                     num1;
            int                     num2;
            UnusedIntPtr            unusedIntPtr;
            uint                    num3;
            CorFileFlags            corFileFlag;
            HCORENUM                hCORENUM      = new HCORENUM();
            StringBuilder           stringBuilder = new StringBuilder();
            List <string>           strs          = new List <string>();
            IMetadataAssemblyImport rawImport     = (IMetadataAssemblyImport)manifestModule.RawImport;

            try
            {
                while (true)
                {
                    rawImport.EnumFiles(ref hCORENUM, out num, 1, out num1);
                    if (num1 == 0)
                    {
                        break;
                    }
                    rawImport.GetFileProps(num, null, 0, out num2, out unusedIntPtr, out num3, out corFileFlag);
                    if (getResources || corFileFlag != CorFileFlags.ContainsNoMetaData)
                    {
                        if (num2 > stringBuilder.Capacity)
                        {
                            stringBuilder.Capacity = num2;
                        }
                        rawImport.GetFileProps(num, stringBuilder, num2, out num2, out unusedIntPtr, out num3, out corFileFlag);
                        strs.Add(stringBuilder.ToString());
                    }
                }
            }
            finally
            {
                hCORENUM.Close(rawImport);
            }
            return(strs);
        }
Exemple #3
0
        public override string[] GetManifestResourceNames()
        {
            int  num;
            int  num1;
            int  num2;
            int  num3;
            uint num4;
            CorManifestResourceFlags corManifestResourceFlag;
            HCORENUM                hCORENUM      = new HCORENUM();
            StringBuilder           stringBuilder = new StringBuilder();
            List <string>           strs          = new List <string>();
            IMetadataAssemblyImport rawImport     = (IMetadataAssemblyImport)this.m_manifestModule.RawImport;

            try
            {
                while (true)
                {
                    rawImport.EnumManifestResources(ref hCORENUM, out num, 1, out num1);
                    if (num1 == 0)
                    {
                        break;
                    }
                    rawImport.GetManifestResourceProps(num, null, 0, out num2, out num3, out num4, out corManifestResourceFlag);
                    if (num2 > stringBuilder.Capacity)
                    {
                        stringBuilder.Capacity = num2;
                    }
                    rawImport.GetManifestResourceProps(num, stringBuilder, num2, out num2, out num3, out num4, out corManifestResourceFlag);
                    strs.Add(stringBuilder.ToString());
                }
            }
            finally
            {
                hCORENUM.Close(rawImport);
            }
            return(strs.ToArray());
        }
        internal static IEnumerable <UnresolvedTypeName> GetRawTypeForwardedToAttributes(MetadataOnlyModule manifestModule)
        {
            int                     num;
            uint                    num1;
            int                     num2;
            int                     num3;
            int                     num4;
            CorTypeAttr             corTypeAttr;
            HCORENUM                hCORENUM  = new HCORENUM();
            IMetadataAssemblyImport rawImport = (IMetadataAssemblyImport)manifestModule.RawImport;

            try
            {
                while (true)
                {
                    rawImport.EnumExportedTypes(ref hCORENUM, out num, 1, out num1);
                    if (num1 == 0)
                    {
                        break;
                    }
                    rawImport.GetExportedTypeProps(num, null, 0, out num2, out num3, out num4, out corTypeAttr);
                    Token token = new Token(num3);
                    if (token.TokenType == System.Reflection.Adds.TokenType.AssemblyRef)
                    {
                        StringBuilder stringBuilder = new StringBuilder(num2);
                        rawImport.GetExportedTypeProps(num, stringBuilder, stringBuilder.Capacity, out num2, out num3, out num4, out corTypeAttr);
                        AssemblyName assemblyNameFromRef = AssemblyNameHelper.GetAssemblyNameFromRef(token, manifestModule, rawImport);
                        yield return(new UnresolvedTypeName(stringBuilder.ToString(), assemblyNameFromRef));
                    }
                }
            }
            finally
            {
                hCORENUM.Close(rawImport);
            }
        }
Exemple #5
0
 public override ParameterInfo[] GetParameters()
 {
     unsafe
     {
         uint         num;
         uint         num1;
         uint         num2;
         uint         num3;
         uint         num4;
         uint         num5;
         int          num6;
         UnusedIntPtr unusedIntPtr;
         if (!this.m_fullyInitialized)
         {
             this.Initialize();
         }
         int             length            = (int)this.m_descriptor.Parameters.Length;
         ParameterInfo[] fakeParameterInfo = new ParameterInfo[length];
         Type[]          type = new Type[length];
         for (int i = 0; i < length; i++)
         {
             type[i] = this.m_descriptor.Parameters[i].Type;
         }
         int[]           numArray  = new int[length + 1];
         IMetadataImport rawImport = this.m_resolver.RawImport;
         HCORENUM        hCORENUM  = new HCORENUM();
         if (rawImport.EnumParams(ref hCORENUM, this.m_methodDef.Value, numArray, (int)numArray.Length, out num) == 1)
         {
             for (int j = 0; j < length; j++)
             {
                 fakeParameterInfo[j] = this.Resolver.Policy.GetFakeParameterInfo(this, type[j], j);
             }
             return(fakeParameterInfo);
         }
         hCORENUM.Close(rawImport);
         if (num == 0)
         {
             return(fakeParameterInfo);
         }
         ParameterInfo metadataOnlyParameterInfo = null;
         for (int k = 0; (long)k < (ulong)num; k++)
         {
             int num7 = numArray[k];
             rawImport.GetParamProps(num7, out num6, out num3, null, 0, out num2, out num1, out num4, out unusedIntPtr, out num5);
             if (num3 != 0)
             {
                 uint num8 = num3 - 1;
                 fakeParameterInfo[num8] = new MetadataOnlyParameterInfo(this.m_resolver, new Token(num7), type[num8], this.m_descriptor.Parameters[num8].CustomModifiers);
             }
             else
             {
                 metadataOnlyParameterInfo = new MetadataOnlyParameterInfo(this.m_resolver, new Token(num7), this.ReturnType, this.m_descriptor.ReturnParameter.CustomModifiers);
             }
         }
         if (metadataOnlyParameterInfo == null)
         {
             metadataOnlyParameterInfo = this.Resolver.Policy.GetFakeParameterInfo(this, this.ReturnType, -1);
         }
         this.m_returnParameter = metadataOnlyParameterInfo;
         for (int l = 0; l < length; l++)
         {
             if (fakeParameterInfo[l] == null)
             {
                 fakeParameterInfo[l] = this.Resolver.Policy.GetFakeParameterInfo(this, type[l], l);
             }
         }
         return(fakeParameterInfo);
     }
 }