예제 #1
0
 internal FieldRVA(PEReader buff)
 {
     Contract.Requires(buff != null);
     rva = buff.ReadUInt32();
     fieldIx = buff.GetIndex(MDTable.Field);
     tabIx = MDTable.FieldRVA;
 }
예제 #2
0
 internal ClassLayout(PEReader buff)
 {
     Contract.Requires(buff != null);
     packSize = buff.ReadUInt16();
     classSize = buff.ReadUInt32();
     parentIx = buff.GetIndex(MDTable.TypeDef);
     tabIx = MDTable.ClassLayout;
 }
예제 #3
0
 internal ClassDef(PEReader buff, uint row, bool isMSCorLib)
 {
     flags = buff.ReadUInt32();
     Name = buff.GetString();
     NameSpace = buff.GetString();
     extendsIx = buff.GetCodedIndex(CIx.TypeDefOrRef);
     fieldIx = buff.GetIndex(MDTable.Field);
     methodIx = buff.GetIndex(MDTable.Method);
     this.Row = row;
     tabIx = MDTable.TypeDef;
     if (isMSCorLib && (Name == "ValueType"))
         typeIndex = (byte)ElementType.ValueType;
 }
예제 #4
0
 internal static void GetClassRefs(PEReader buff, TableRow[] typeRefs, ReferenceScope paren, uint[] parIxs)
 {
     Contract.Requires(buff != null);
     Contract.Requires(typeRefs != null);
     Contract.Requires(paren != null);
     Contract.Requires(parIxs != null);
     int num = typeRefs.Length;
     uint[] fieldStart = new uint[num + 1], methStart = new uint[num + 1], extends = new uint[num + 1];
     for (int i = 0; i < num; i++)
     {
         uint flags = buff.ReadUInt32();
         string name = buff.GetString();
         string nameSpace = buff.GetString();
         extends[i] = buff.GetCodedIndex(CIx.TypeDefOrRef);
         fieldStart[i] = buff.GetIndex(MDTable.Field);
         methStart[i] = buff.GetIndex(MDTable.Method);
         //Console.WriteLine("flags = " + Hex.Int(flags));
         if (i == 0) // ASSERT first entry is always <Module>
             typeRefs[i] = paren.GetDefaultClass();
         else if (isPublic(flags))
         {
             if (parIxs[i] != 0)
             {
                 typeRefs[i] = new NestedClassRef(paren, nameSpace, name);
             }
             else
             {
                 typeRefs[i] = paren.GetExistingClass(nameSpace, name);
                 if (typeRefs[i] == null)
                 {
                     typeRefs[i] = new ClassRef(paren, nameSpace, name);
                     paren.AddToClassList((ClassRef)typeRefs[i]);
                 }
             }
         }
     }
     fieldStart[num] = buff.GetTableSize(MDTable.Field) + 1;
     methStart[num] = buff.GetTableSize(MDTable.Method) + 1;
     // Find Nested Classes
     for (int i = 0; i < typeRefs.Length; i++)
     {
         if ((typeRefs[i] != null) && (typeRefs[i] is NestedClassRef))
         {
             NestedClassRef nRef = (NestedClassRef)typeRefs[i];
             ClassRef nPar = (ClassRef)typeRefs[parIxs[i] - 1];
             if (nPar == null)
             {  // parent is private, so ignore
                 typeRefs[i] = null;
             }
             else
             {
                 nRef.SetParent(nPar);
                 nPar.AddToClassList(nRef);
             }
         }
         if (typeRefs[i] != null)
         {
             if (buff.GetCodedElement(CIx.TypeDefOrRef, extends[i]) == MSCorLib.mscorlib.ValueType())
                 ((ClassRef)typeRefs[i]).MakeValueClass();
             buff.SetElementPosition(MDTable.Field, fieldStart[i]);
             FieldDef.GetFieldRefs(buff, fieldStart[i + 1] - fieldStart[i], (ClassRef)typeRefs[i]);
             buff.SetElementPosition(MDTable.Method, methStart[i]);
             MethodDef.GetMethodRefs(buff, methStart[i + 1] - methStart[i], (ClassRef)typeRefs[i]);
         }
     }
 }
예제 #5
0
 internal static void GetMethodRefs(PEReader buff, uint num, ClassRef parent)
 {
     for (int i = 0; i < num; i++)
     {
         uint rva = buff.ReadUInt32();
         ushort implFlags = buff.ReadUInt16();
         ushort methFlags = buff.ReadUInt16();
         string name = buff.GetString();
         uint sigIx = buff.GetBlobIx();
         uint parIx = buff.GetIndex(MDTable.Param);
         if (IsPublicOrProtected(methFlags))
         {
             MethodRef mRef = new MethodRef(parIx, name, sigIx);  // changed
             mRef.SetParent(parent);
             //Console.WriteLine(parent.NameString());
             MethSig mSig = buff.ReadMethSig(mRef, name, sigIx);
             //mSig.name = name;
             mRef.SetSig(mSig); // changed
             parent.AddToMethodList(mRef);
         }
     }
 }
예제 #6
0
 internal MethodDef(PEReader buff)
     : base(null)
 {
     rva = buff.ReadUInt32();
     implFlags = buff.ReadUInt16();
     methFlags = buff.ReadUInt16();
     name = buff.GetString();
     sigIx = buff.GetBlobIx();
     parIx = buff.GetIndex(MDTable.Param);
     tabIx = MDTable.Method;
 }
예제 #7
0
 internal FieldLayout(PEReader buff)
 {
     offset = buff.ReadUInt32();
     fieldIx = buff.GetIndex(MDTable.Field);
     tabIx = MDTable.FieldLayout;
 }
예제 #8
0
 internal static ClassLayout FindLayout(PEReader buff, ClassDef paren, uint classIx)
 {
     Contract.Requires(buff != null);
     Contract.Requires(paren != null);
     buff.SetElementPosition(MDTable.ClassLayout, 0);
     for (int i = 0; i < buff.GetTableSize(MDTable.ClassLayout); i++)
     {
         ushort packSize = buff.ReadUInt16();
         uint classSize = buff.ReadUInt32();
         if (buff.GetIndex(MDTable.TypeDef) == classIx)
             return new ClassLayout(packSize, classSize, paren);
     }
     return null;
 }
예제 #9
0
 internal InterfaceImpl(PEReader buff)
 {
     Contract.Requires(buff != null);
     classIx = buff.GetIndex(MDTable.TypeDef);
     interfacesIndex = buff.GetCodedIndex(CIx.TypeDefOrRef);
     tabIx = MDTable.InterfaceImpl;
 }
예제 #10
0
 internal ImplMap(PEReader buff)
 {
     Contract.Requires(buff != null);
     flags = buff.ReadUInt16();
     memForIndex = buff.GetCodedIndex(CIx.MemberForwarded);
     importName = buff.GetString();
     scopeIx = buff.GetIndex(MDTable.ModuleRef);
     tabIx = MDTable.ImplMap;
 }
예제 #11
0
 internal GenericParamConstraint(PEReader buff)
 {
     parentIx = buff.GetIndex(MDTable.GenericParam);
     constraintIx = buff.GetCodedIndex(CIx.TypeDefOrRef);
     tabIx = MDTable.GenericParamConstraint;
 }
예제 #12
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;
 }
예제 #13
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;
 }