Base class for scopes (extended by Module, ModuleRef, Assembly, AssemblyRef)
Inheritance: MetaDataElement
Exemple #1
0
 private void SetThisScope()
 {
     if (refsOnly)
         thisScope = Module.ReadModuleRef(this);
     else
         ((PEFile)thisScope).Read(this);
     tables[(int)MDTable.Module][0] = thisScope;
     if (tableLengths[(int)MDTable.Assembly] > 0) {
         SetElementPosition(MDTable.Assembly,1);
         if (refsOnly) {
             ModuleRef thisMod = (ModuleRef)thisScope;
             thisScope = Assembly.ReadAssemblyRef(this);
             //if ((thisMod != null) && (thisMod.ismscorlib) && (thisScope != null)) {
             //  ((AssemblyRef)thisScope).CopyVersionInfoToMSCorLib();
             //  thisScope = MSCorLib.mscorlib;
             //}
             tables[(int)MDTable.Assembly][0] = thisScope;
         } else {
             Assembly.Read(this,tables[(int)MDTable.Assembly],(PEFile)thisScope);
             ((PEFile)thisScope).SetThisAssembly((Assembly)tables[(int)MDTable.Assembly][0]);
         }
     }
 }
Exemple #2
0
        private PEReader(PEFile pefile, System.IO.FileStream file, bool refs, bool skipBody)
            : base(new MemoryStream(new BinaryReader(file).ReadBytes(System.Convert.ToInt32(file.Length))))
        {
            this.skipBody = skipBody;
            thisScope = pefile;
            refsOnly = refs;
            verInfo.fromExisting = true;
            try {
                ReadDOSHeader();
            } catch (PEFileException) {
                Console.WriteLine("Bad DOS header");
                return;
            }
            ReadFileHeader();
            ReadSectionHeaders();
            ReadCLIHeader();
            ReadMetaData();
            if (refsOnly)
                ReadMetaDataTableRefs();
            else {
                ReadMetaDataTables();
                pefile.metaDataTables = new MetaDataTables(tables);
            }
            file.Close();

            if (thisScope != null) {
                thisScope.buffer = this;
                if (pefile != null) {
                    pefile.versionInfo = verInfo;
                }
            }
            strings = null;
            userstring = null;
            blob = null;
            guid = null;
        }