Base class for all Meta Data table elements
Inheritance: TableRow, IComparable
Example #1
0
 internal ManifestResource(PEFile pefile, ManifestResource mres, bool isPub)
 {
     this.pefile = pefile;
     mrName = mres.mrName;
     flags = mres.flags;
     this.impl = mres.impl;
     this.fileOffset = mres.fileOffset;
     this.resourceBytes = mres.resourceBytes;
 }
Example #2
0
 internal GenericParam(PEReader buff)
     : base(VAR)
 {
     index = buff.ReadUInt16();
     flags = buff.ReadUInt16();
     parentIx = buff.GetCodedIndex(CIx.TypeOrMethodDef);
     name = buff.GetString();
     if (extraField) kind = buff.ReadUInt16();
     sortTable = true;
     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);
         }
     }
 }
Example #3
0
 internal void SetClassParam(Class paren, int ix)
 {
     typeIndex = VAR;
     parent = paren;
     index = (ushort)ix;
 }
Example #4
0
 internal override void Resolve(PEReader buff)
 {
     parent = buff.GetCodedElement(CIx.HasDeclSecurity,parentIx);
     if (parent != null) {
         if (parent is ClassDef) ((ClassDef)parent).AddSecurity(this);
         if (parent is Assembly) ((Assembly)parent).AddSecurity(this);
         if (parent is MethodDef) ((MethodDef)parent).AddSecurity(this);
     }
 }
Example #5
0
 internal override void Resolve(PEReader buff)
 {
     field = buff.GetCodedElement(CIx.HasFieldMarshal,parentIx);
     nt = buff.GetBlobNativeType(ntIx);
     if (field is FieldDef) {
         ((FieldDef)field).SetMarshalType(nt);
     } else {
         ((Param)field).SetMarshalType(nt);
     }
 }
Example #6
0
 internal CustomAttribute(MetaDataElement paren, Method constrType,
     byte[] val)
 {
     parent = paren;
     type = constrType;
     tabIx = MDTable.CustomAttribute;
     byteVal = val;
     sortTable = true;
     changed = true;
 }
Example #7
0
 /*-------------------- Constructors ---------------------------------*/
 internal DeclSecurity(MetaDataElement paren, SecurityAction act, byte[] perSet)
 {
     parent = paren;
     action = act;
     permissionSet = perSet;
     sortTable = true;
     tabIx = MDTable.DeclSecurity;
 }
Example #8
0
 internal override void Resolve(PEReader buff)
 {
     parent = buff.GetCodedElement(CIx.HasConstant,parentIx);
     if (parent != null) {
         if (parent is Param) ((Param)parent).AddDefaultValue(cValue);
         else if (parent is FieldDef) ((FieldDef)parent).AddValue(cValue);
         else ((Property)parent).AddInitValue(cValue);
     }
 }
Example #9
0
 internal void ClassToken(MetaDataElement cToken)
 {
     classToken = cToken;
 }
Example #10
0
 private Type SubstituteType(Type origType, MetaDataElement paren, Type[] genTypes)
 {
     if ((origType is GenericParam) && (((GenericParam)origType).GetParent() == paren))
         return genTypes[((GenericParam)origType).Index];
     return origType;
 }
Example #11
0
 /*-------------------- Constructors ---------------------------------*/
 internal ConstantElem(MetaDataElement parent, Constant val)
 {
     this.parent = parent;
     cValue = val;
     sortTable = true;
     tabIx = MDTable.Constant;
 }
Example #12
0
 private Type[] ReplaceGenPars(Type[] typeList, MetaDataElement paren, Type[] genTypes)
 {
     if (typeList == null) return null;
     Type[] newList = new Type[typeList.Length];
     for (int i=0; i < typeList.Length; i++) {
         newList[i] = SubstituteType(typeList[i],paren,genTypes);
     }
     return newList;
 }
Example #13
0
 internal void DescriptorError(MetaDataElement elem)
 {
     throw new DescriptorException(elem.NameString());
 }
Example #14
0
 internal override void Resolve(PEReader buff)
 {
     impl = buff.GetCodedElement(CIx.Implementation,implIx);
     if (impl == null) {
         if (!buff.skipBody)
             resourceBytes = buff.GetResource(fileOffset);
     }
 }
Example #15
0
 internal void WriteCodedIndex(CIx code, MetaDataElement elem)
 {
     metaData.WriteCodedIndex(code,elem,this);
 }
Example #16
0
 /*-------------------- Constructors ---------------------------------*/
 internal ExternClass(TypeAttr attr, string ns, string name, MetaDataElement paren)
 {
     flags = (uint)attr;
     nameSpace = ns;
     this.name = name;
     implementation = paren;
     tabIx = MDTable.ExportedType;
 }
Example #17
0
 /*-------------------- Constructors ---------------------------------*/
 internal CustomAttribute(MetaDataElement paren, Method constrType,
     Constant[] val)
 {
     parent = paren;
     type = constrType;
     argVals = val;
     changed = true;
     sortTable = true;
     tabIx = MDTable.CustomAttribute;
 }
Example #18
0
 internal override sealed void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.ExportedType,this);
     nameSpaceIx = md.AddToStringsHeap(nameSpace);
     nameIx = md.AddToStringsHeap(name);
     if (implementation is ModuleRef) {
         ModuleFile mFile = ((ModuleRef)implementation).modFile;
         mFile.BuildMDTables(md);
         implementation = mFile;
     }
 }
Example #19
0
 internal override void Resolve(PEReader buff)
 {
     parent = buff.GetCodedElement(CIx.HasCustomAttr,parentIx);
     if (parent == null) return;
     parent.AddCustomAttribute(this);
     type = (Method)buff.GetCodedElement(CIx.CustomAttributeType,typeIx);
     byteVal = buff.GetBlob(valIx);
 }
Example #20
0
 internal override void Resolve(PEReader buff)
 {
     implementation = buff.GetCodedElement(CIx.Implementation,implIx);
     while (implementation is ExternClass)
         implementation = ((ExternClass)implementation).implementation;
     ((ModuleFile)implementation).fileModule.AddExternClass(this);
 }
Example #21
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 #22
0
 internal void AddToTable(MDTable tableIx, MetaDataElement elem)
 {
     // updates Row field of the element
     // Console.WriteLine("Adding element to table " + (uint)tableIx);
     ArrayList table = GetTable(tableIx);
     if (table.Contains(elem)) {
         Console.Out.WriteLine("ERROR - element already in table " + tableIx);
         return;
     }
     elem.Row = (uint)table.Count + 1;
     table.Add(elem);
 }
Example #23
0
 /*-------------------- Constructors ---------------------------------*/
 internal FieldMarshal(MetaDataElement field, NativeType nType)
 {
     this.field = field;
     this.nt = nType;
     sortTable = true;
     tabIx = MDTable.FieldMarshal;
 }
Example #24
0
 internal void SetEntryPoint(MetaDataElement ep)
 {
     entryPoint = ep;
 }
Example #25
0
 internal GenericParam(string name, MetaDataElement parent, int index)
     : base(VAR)
 {
     this.name = name;
     this.parent = parent;
     this.index = (ushort)index;
     if (parent is Method) typeIndex = MVAR;
     sortTable = true;
     tabIx = MDTable.GenericParam;
 }
Example #26
0
 internal void WriteCodedIndex(CIx code, MetaDataElement elem, PEWriter output)
 {
     uint ix = 0;
     if (elem != null) {
         ix = (elem.Row << CIxShiftMap[(uint)code]) | elem.GetCodedIx(code);
         // Console.WriteLine("coded index = " + ix + " row = " + elem.Row);
         //} else {
         // Console.WriteLine("elem for coded index is null");
     }
     if (lgeCIx[(uint)code])
         output.Write(ix);
     else
         output.Write((ushort)ix);
 }
Example #27
0
 internal void CheckParent(MethodDef paren, PEReader buff)
 {
     if (paren == buff.GetCodedElement(CIx.TypeOrMethodDef,parentIx)) {
         parent = paren;
         paren.InsertGenericParam(this);
     }
 }
Example #28
0
 internal void InsertInTable(MDTable tabIx, uint ix, MetaDataElement elem)
 {
     tables[(int)tabIx][ix-1] = elem;
 }
Example #29
0
 internal void SetMethParam(Method paren,int ix)
 {
     typeIndex = MVAR;
     parent = paren;
     index = (ushort)ix;
 }
Example #30
0
 internal ManifestResource(PEFile pefile, string name, MetaDataElement fileRef, uint offset, bool isPub)
 {
     InitResource(pefile,name,isPub);
     impl = fileRef;
     fileOffset = offset;
 }