GetTableSize() private method

private GetTableSize ( MDTable tabIx ) : uint
tabIx MDTable
return uint
Example #1
0
 internal static DeclSecurity FindSecurity(PEReader buff, MetaDataElement paren, uint codedParIx)
 {
     buff.SetElementPosition(MDTable.DeclSecurity,0);
     for (int i=0; i < buff.GetTableSize(MDTable.DeclSecurity); i++) {
         uint act = buff.ReadUInt16();
         if (buff.GetCodedIndex(CIx.HasDeclSecurity) == codedParIx)
             return new DeclSecurity(paren,(SecurityAction)act,buff.GetBlob());
         uint junk = buff.GetBlobIx();
     }
     return null;
 }
Example #2
0
 internal static string[] GetFeatureNames(PEReader buff, MDTable tabIx, MDTable mapTabIx,
     ClassDef theClass, uint classIx)
 {
     buff.SetElementPosition(mapTabIx,0);
     uint start = 0, end = 0, 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;
     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;
 }
Example #3
0
 internal static void Read(PEReader buff, TableRow[] typeDefs, bool isMSCorLib)
 {
     ClassDef prevDef = null;
     prevDef = new ClassDef(buff,1,isMSCorLib);
     typeDefs[0] = prevDef;
     for (int i=1; i < typeDefs.Length; i++) {
         ClassDef typeDef = new ClassDef(buff,(uint)i+1,isMSCorLib);
         prevDef.fieldEndIx = typeDef.fieldIx;
         prevDef.methodEndIx = typeDef.methodIx;
         prevDef = typeDef;
         typeDefs[i] = typeDef;
     }
     prevDef.fieldEndIx = buff.GetTableSize(MDTable.Field)+1;
     prevDef.methodEndIx = buff.GetTableSize(MDTable.Method)+1;
 }
Example #4
0
 internal static void GetClassRefs(PEReader buff, TableRow[] typeRefs, ReferenceScope paren, uint[] parIxs)
 {
     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]);
         }
     }
 }
Example #5
0
 internal static ClassLayout FindLayout(PEReader buff, ClassDef paren, uint classIx)
 {
     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;
 }
Example #6
0
 internal static void Read(PEReader buff, TableRow[] methDefs)
 {
     MethodDef prevDef = null;
     prevDef = new MethodDef(buff);
     methDefs[0] = prevDef;
     for (int i=1; i < methDefs.Length; i++) {
         prevDef.Row = (uint)i;
         MethodDef methDef = new MethodDef(buff);
         prevDef.numPars = methDef.parIx - prevDef.parIx;
         prevDef = methDef;
         methDefs[i] = methDef;
     }
     prevDef.Row = (uint)methDefs.Length;
     prevDef.numPars = (buff.GetTableSize(MDTable.Param)+1) - prevDef.parIx;
 }
Example #7
0
 internal static void Read(PEReader buff, TableRow[] maps, MDTable tab)
 {
     if (tab == MDTable.NestedClass) {
         for (int i=0; i < maps.Length; i++) {
             //maps[i] = new MapElem(buff,tab);
             uint nestClassIx = buff.GetIndex(MDTable.TypeDef);
             uint enclClassIx = buff.GetIndex(MDTable.TypeDef);
             ClassDef parent = (ClassDef)buff.GetElement(MDTable.TypeDef,enclClassIx);
             ClassDef nestClass = ((ClassDef)buff.GetElement(MDTable.TypeDef,nestClassIx)).MakeNestedClass(parent);
             buff.InsertInTable(MDTable.TypeDef,nestClass.Row,nestClass);
         }
     } else { // event or property map
         MapElem prev = new MapElem(buff,tab);
         maps[0] = prev;
         for (int i=1; i < maps.Length; i++) {
             maps[i] = new MapElem(buff,tab);
             prev.endIx = ((MapElem)maps[i]).elemIx;
             prev = (MapElem)maps[i];
         }
         switch (tab) {
             case MDTable.PropertyMap:
                 prev.endIx = buff.GetTableSize(MDTable.Property) + 1;
                 break;
             case MDTable.EventMap:
                 prev.endIx = buff.GetTableSize(MDTable.Event) + 1;
                 break;
             default:
                 prev.endIx = buff.GetTableSize(tab)+1;
                 break;
         }
     }
 }