Пример #1
0
 internal FieldMarshal(PEReader buff)
 {
     Contract.Requires(buff != null);
     parentIx = buff.GetCodedIndex(CIx.HasFieldMarshal);
     ntIx     = buff.GetBlobIx();
     tabIx    = MDTable.FieldMarshal;
 }
Пример #2
0
 internal Event(PEReader buff)
 {
     flags  = buff.ReadUInt16();
     name   = buff.GetString();
     typeIx = buff.GetCodedIndex(CIx.TypeDefOrRef);
     tabIx  = MDTable.Event;
 }
Пример #3
0
 internal GenericParam(PEReader buff)
     : base(VAR)
 {
     Contract.Requires(buff != null);
     index    = buff.ReadUInt16();
     flags    = buff.ReadUInt16();
     parentIx = buff.GetCodedIndex(CIx.TypeOrMethodDef);
     name     = buff.GetString();
     if (extraField)
     {
         kind = buff.ReadUInt16();
     }
     tabIx = MDTable.GenericParam;
     // resolve generic param immediately for signature resolution
     parent = buff.GetCodedElement(CIx.TypeOrMethodDef, parentIx);
     if (parent != null)
     {
         if (parent is MethodDef)
         {
             typeIndex = MVAR;
             ((MethodDef)parent).AddGenericParam(this);
         }
         else
         {
             ((ClassDef)parent).AddGenericParam(this);
         }
     }
 }
Пример #4
0
 internal static void Read(PEReader buff, TableRow[] typeRefs, bool resolve)
 {
     for (uint i = 0; i < typeRefs.Length; i++)
     {
         uint   resScopeIx = buff.GetCodedIndex(CIx.ResolutionScope);
         string name       = buff.GetString();
         string nameSpace  = buff.GetString();
         if (buff.CodedTable(CIx.ResolutionScope, resScopeIx) == MDTable.TypeRef)
         {
             typeRefs[i] = new NestedClassRef(resScopeIx, nameSpace, name);
         }
         else
         {
             typeRefs[i] = new ClassRef(resScopeIx, nameSpace, name);
         }
         typeRefs[i].Row = i + 1;
     }
     if (resolve)
     {
         foreach (TableRow typeRef in typeRefs)
         {
             ((ClassRef)typeRef).ResolveParent(buff, false);
         }
     }
 }
Пример #5
0
 internal MethodSpec(PEReader buff)
     : base(null)
 {
     parentIx        = buff.GetCodedIndex(CIx.MethodDefOrRef);
     instIx          = buff.GetBlobIx();
     tabIx           = MDTable.MethodSpec;
     this.unresolved = true;
 }
Пример #6
0
 public ExternClass(PEReader buff)
 {
     flags     = buff.ReadUInt32();
     typeDefId = buff.ReadUInt32();
     Name      = buff.GetString();
     NameSpace = buff.GetString();
     implIx    = buff.GetCodedIndex(CIx.Implementation);
     tabIx     = MDTable.ExportedType;
 }
Пример #7
0
        internal static string[] GetFeatureNames(PEReader buff, MDTable tabIx, MDTable mapTabIx,
                                                 ClassDef theClass, uint classIx)
        {
            buff.SetElementPosition(mapTabIx, 0);
            uint start = 0;
            uint i     = 0;

            for (; (i < buff.GetTableSize(tabIx)) && (start == 0); i++)
            {
                if (buff.GetIndex(MDTable.TypeDef) == classIx)
                {
                    start = buff.GetIndex(tabIx);
                }
            }
            if (start == 0)
            {
                return(null);
            }
            uint end;

            if (i < buff.GetTableSize(mapTabIx))
            {
                uint junk = buff.GetIndex(MDTable.TypeDef);
                end = buff.GetIndex(tabIx);
            }
            else
            {
                end = buff.GetTableSize(tabIx);
            }
            if (tabIx == MDTable.Event)
            {
                theClass.eventIx = start;
            }
            else
            {
                theClass.propIx = start;
            }
            string[] names = new string[end - start];
            buff.SetElementPosition(tabIx, start);
            for (i = start; i < end; i++)
            {
                uint junk = buff.ReadUInt16();
                names[i] = buff.GetString();
                if (tabIx == MDTable.Event)
                {
                    junk = buff.GetCodedIndex(CIx.TypeDefOrRef);
                }
                else
                {
                    junk = buff.GetBlobIx();
                }
            }
            return(names);
        }
Пример #8
0
 internal static void GetClassRefs(PEReader buff, TableRow[] eClasses)
 {
     for (uint i = 0; i < eClasses.Length; i++)
     {
         uint junk = buff.ReadUInt32();
         junk = buff.ReadUInt32();
         string name      = buff.GetString();
         string nameSpace = buff.GetString();
         uint   implIx    = buff.GetCodedIndex(CIx.Implementation);
         eClasses[i]     = new ClassRef(implIx, nameSpace, name);
         eClasses[i].Row = i + 1;
     }
 }
Пример #9
0
        internal static ClassRef ReadClass(PEReader buff, ReferenceScope resScope)
        {
            uint     resScopeIx = buff.GetCodedIndex(CIx.ResolutionScope);
            string   name       = buff.GetString();
            string   nameSpace  = buff.GetString();
            ClassRef newClass   = (ClassRef)resScope.GetExistingClass(nameSpace, name);

            if (newClass == null)
            {
                newClass = new ClassRef(resScope, nameSpace, name);
            }
            return(newClass);
        }
Пример #10
0
        internal static ClassRef ReadDef(PEReader buff, ReferenceScope resScope, uint index)
        {
            uint     junk     = buff.ReadUInt32();
            string   cName    = buff.GetString();
            string   nsName   = buff.GetString();
            ClassRef newClass = (ClassRef)resScope.GetExistingClass(nsName, cName);

            if (newClass == null)
            {
                newClass = new ClassRef(resScope, nsName, cName);
                resScope.AddToClassList(newClass);
            }
            newClass.readAsDef = true;
            newClass.Row       = index;
            junk              = buff.GetCodedIndex(CIx.TypeDefOrRef);
            newClass.fieldIx  = buff.GetIndex(MDTable.Field);
            newClass.methodIx = buff.GetIndex(MDTable.Method);
            return(newClass);
        }
Пример #11
0
 internal static void ReadMember(PEReader buff, TableRow[] members)
 {
     Contract.Requires(buff != null);
     Contract.Requires(members != null);
     for (int i = 0; i < members.Length; i++)
     {
         uint parenIx = buff.GetCodedIndex(CIx.MemberRefParent);
         string memName = buff.GetString();
         uint sigIx = buff.GetBlobIx();
         if (buff.FirstBlobByte(sigIx) == Field.FieldTag) // got a field
             members[i] = new FieldRef(parenIx, memName, sigIx);
         else
             members[i] = new MethodRef(parenIx, memName, sigIx);
     }
 }
Пример #12
0
 internal ConstantElem(PEReader buff)
 {
     Contract.Requires(buff != null);
     byte constType = buff.ReadByte();
     byte pad = buff.ReadByte();
     parentIx = buff.GetCodedIndex(CIx.HasConstant);
     //valIx = buff.GetBlobIx();
     cValue = buff.GetBlobConst(constType);
     tabIx = MDTable.Constant;
 }
Пример #13
0
 internal MethodSemantics(PEReader buff)
 {
     Contract.Requires(buff != null);
     type = (MethodType)buff.ReadUInt16();
     methIx = buff.GetIndex(MDTable.Method);
     assocIx = buff.GetCodedIndex(CIx.HasSemantics);
     tabIx = MDTable.MethodSemantics;
 }
Пример #14
0
 internal MethodImpl(PEReader buff)
 {
     Contract.Requires(buff != null);
     classIx = buff.GetIndex(MDTable.TypeDef);
     methBodyIx = buff.GetCodedIndex(CIx.MethodDefOrRef);
     methDeclIx = buff.GetCodedIndex(CIx.MethodDefOrRef);
     tabIx = MDTable.MethodImpl;
 }