internal FieldDef(PEReader buff) : base(null,null,null) { flags = buff.ReadUInt16(); name = buff.GetString(); sigIx = buff.GetBlobIx(); tabIx = MDTable.Field; }
internal static void GetFieldRefs(PEReader buff, uint num, ClassRef parent) { for (int i=0; i < num; i++) { uint flags = buff.ReadUInt16(); string name = buff.GetString(); uint sigIx = buff.GetBlobIx(); if ((flags & (uint)FieldAttr.Public) == (uint)FieldAttr.Public) { if (parent.GetField(name) == null) { //Console.WriteLine(parent.NameString()); buff.currentClassScope = parent; FieldRef fRef = new FieldRef(parent,name,buff.GetFieldType(sigIx)); buff.currentClassScope = null; parent.AddToFieldList(fRef); } } } }
internal Event(PEReader buff) { flags = buff.ReadUInt16(); name = buff.GetString(); typeIx = buff.GetCodedIndex(CIx.TypeDefOrRef); tabIx = MDTable.Event; }
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; }
internal static AssemblyRef Read(PEReader buff) { ushort majVer = buff.ReadUInt16(); ushort minVer = buff.ReadUInt16(); ushort bldNo = buff.ReadUInt16(); ushort revNo = buff.ReadUInt16(); uint flags = buff.ReadUInt32(); byte[] pKey = buff.GetBlob(); string name = buff.GetString(); string cult = buff.GetString(); byte[] hBytes = buff.GetBlob(); AssemblyRef assemRef; if (name.ToLower() == "mscorlib") { assemRef = MSCorLib.mscorlib; assemRef.AddVersionInfo(majVer,minVer,bldNo,revNo); assemRef.AddHash(hBytes); if (pKey.Length > 8) assemRef.AddKey(pKey); else assemRef.AddKeyToken(pKey); assemRef.AddCulture(cult); assemRef.SetFlags(flags); } else { assemRef = new AssemblyRef(name,majVer,minVer,bldNo,revNo,flags,pKey,cult,hBytes); } return assemRef; }
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; }
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; }
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); } } }
internal Property(PEReader buff) { flags = buff.ReadUInt16(); name = buff.GetString(); typeBlobIx = buff.GetBlobIx(); tabIx = MDTable.Property; }
internal ClassLayout(PEReader buff) { packSize = buff.ReadUInt16(); classSize = buff.ReadUInt32(); parentIx = buff.GetIndex(MDTable.TypeDef); tabIx = MDTable.ClassLayout; }
internal Param(PEReader buff) { parMode = buff.ReadUInt16(); seqNo = buff.ReadUInt16(); pName = buff.GetString(); tabIx = MDTable.Param; }
internal MethodSemantics(PEReader buff) { type = (MethodType)buff.ReadUInt16(); methIx = buff.GetIndex(MDTable.Method); assocIx = buff.GetCodedIndex(CIx.HasSemantics); sortTable = true; tabIx = MDTable.MethodSemantics; }
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); //if (parent.GetMethod(mSig) == null) { // MethodRef mRef = new MethodRef(mSig); // parent.AddToMethodList(mRef); //} } } }
internal static void Read(PEReader buff, TableRow[] table, PEFile pefile) { for (int i=0; i < table.Length; i++) { HashAlgorithmType hAlg = (HashAlgorithmType)buff.ReadUInt32(); ushort majVer = buff.ReadUInt16(); ushort minVer = buff.ReadUInt16(); ushort bldNo = buff.ReadUInt16(); ushort revNo = buff.ReadUInt16(); uint flags = buff.ReadUInt32(); byte[] pKey = buff.GetBlob(); string name = buff.GetString(); string cult = buff.GetString(); table[i] = new Assembly(name,hAlg,majVer,minVer,bldNo,revNo,flags,pKey,cult,pefile); } }
internal Section(PEReader input) { name = new char[8]; for (int i=0; i < name.Length; i++) name[i] = (char)input.ReadByte(); nameString = new String(name); tide = input.ReadUInt32(); rva = input.ReadUInt32(); size = input.ReadUInt32(); offset = input.ReadUInt32(); relocRVA = input.ReadUInt32(); lineRVA = input.ReadUInt32(); numRelocs = input.ReadUInt16(); numLineNums = input.ReadUInt16(); flags = input.ReadUInt32(); if (Diag.DiagOn) { Console.WriteLine(" " + nameString + " RVA = " + Hex.Int(rva) + " vSize = " + Hex.Int(tide)); Console.WriteLine(" FileOffset = " + Hex.Int(offset) + " aSize = " + Hex.Int(size)); } }
internal static AssemblyRef ReadAssemblyRef(PEReader buff) { buff.SetElementPosition(MDTable.Assembly,1); HashAlgorithmType hAlg = (HashAlgorithmType)buff.ReadUInt32(); ushort majVer = buff.ReadUInt16(); ushort minVer = buff.ReadUInt16(); ushort bldNo = buff.ReadUInt16(); ushort revNo = buff.ReadUInt16(); uint flags = buff.ReadUInt32(); byte[] pKey = buff.GetBlob(); string name = buff.GetString(); string cult = buff.GetString(); AssemblyRef assemRef = null; if (name.ToLower() == "mscorlib") { assemRef = MSCorLib.mscorlib; assemRef.AddVersionInfo(majVer,minVer,bldNo,revNo); if (pKey.Length > 8) assemRef.AddKey(pKey); else assemRef.AddKeyToken(pKey); assemRef.AddCulture(cult); assemRef.SetFlags(flags); } else { assemRef = new AssemblyRef(name,majVer,minVer,bldNo,revNo,flags,pKey,cult,null); } //AssemblyRef assemRef = new AssemblyRef(name,majVer,minVer,bldNo,revNo,flags,pKey,cult,null); assemRef.ReadAsDef(); return assemRef; }
internal DeclSecurity(PEReader buff) { action = (SecurityAction)buff.ReadUInt16(); parentIx = buff.GetCodedIndex(CIx.HasDeclSecurity); permissionSet = buff.GetBlob(); sortTable = true; tabIx = MDTable.DeclSecurity; }
internal ImplMap(PEReader buff) { flags = buff.ReadUInt16(); memForIndex = buff.GetCodedIndex(CIx.MemberForwarded); importName = buff.GetString(); scopeIx = buff.GetIndex(MDTable.ModuleRef); sortTable = true; tabIx = MDTable.ImplMap; }
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; }