internal Event(PEReader buff) { flags = buff.ReadUInt16(); name = buff.GetString(); typeIx = buff.GetCodedIndex(CIx.TypeDefOrRef); tabIx = MDTable.Event; }
internal DeclSecurity(PEReader buff) { Contract.Requires(buff != null); action = (SecurityAction)buff.ReadUInt16(); parentIx = buff.GetCodedIndex(CIx.HasDeclSecurity); permissionSet = buff.GetBlob(); tabIx = MDTable.DeclSecurity; }
internal ClassLayout(PEReader buff) { Contract.Requires(buff != null); packSize = buff.ReadUInt16(); classSize = buff.ReadUInt32(); parentIx = buff.GetIndex(MDTable.TypeDef); tabIx = MDTable.ClassLayout; }
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 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); } } }
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; }
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 FieldDef(PEReader buff) : base(null, null, null) { flags = buff.ReadUInt16(); name = buff.GetString(); sigIx = buff.GetBlobIx(); tabIx = MDTable.Field; }
internal Section(PEReader input) { Contract.Requires(input != null); name = new char[8]; for (int i = 0; i < name.Length; i++) name[i] = (char)input.ReadByte(); nameString = new String(name); loadedSize = input.ReadUInt32(); loadedRVA = input.ReadUInt32(); sizeOnDisk = input.ReadUInt32(); fileOffset = 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(loadedRVA) + " vSize = " + Hex.Int(loadedSize)); Console.WriteLine(" FileOffset = " + Hex.Int(fileOffset) + " aSize = " + Hex.Int(sizeOnDisk)); } }
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; }
internal Property(PEReader buff) { flags = buff.ReadUInt16(); name = buff.GetString(); typeBlobIx = buff.GetBlobIx(); tabIx = MDTable.Property; }
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); } } }
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 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; }
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 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; 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 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; }