public CILWriter(string filename, bool debug, PEFile pefile) : base(new FileStream(filename, FileMode.Create)) { Contract.Requires(filename != null); Contract.Requires(pefile != null); this.pefile = pefile; WriteLine("// ILASM output by PERWAPI"); WriteLine("// for file <" + pefile.GetFileName() + ">"); }
/*-------------------- Constructors ---------------------------------*/ internal ClassDef(PEFile scope, TypeAttr attrSet, string nsName, string name) : base(nsName, name) { Contract.Requires(scope != null); this.scope = scope; superType = MSCorLib.mscorlib.ObjectClass; flags = (uint)attrSet; tabIx = MDTable.TypeDef; }
internal Assembly(string name, HashAlgorithmType hashAlgId, ushort majVer, ushort minVer, ushort bldNo, ushort revNo, uint flags, byte[] pKey, string cult, PEFile pefile) : base(name) { this.hashAlgId = hashAlgId; this.majorVer = majVer; this.minorVer = minVer; this.buildNo = bldNo; this.revisionNo = revNo; this.flags = flags; this.publicKey = pKey; this.culture = cult; tabIx = MDTable.Assembly; }
internal void SetScope(PEFile mod) { Contract.Requires(mod != null); scope = mod; }
/*-------------------- Constructors ---------------------------------*/ internal Assembly(string name, PEFile pefile) : base(name) { this.pefile = pefile; tabIx = MDTable.Assembly; }
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); } }
public static PEFile ReadPEFile([NotNull] string filename, bool skipBody) { Contract.Requires(filename != null); Contract.Ensures(Contract.Result<PEFile>() != null); System.IO.FileStream file = GetFile(filename); PEFile pefile = new PEFile(filename); PEReader reader = new PEReader(pefile, file, false, skipBody); return pefile; }
/*------------------------- public set and get methods --------------------------*/ /// <summary> /// Add a class which is declared public in this external module of /// THIS assembly. This class will be exported from this assembly. /// The ilasm syntax for this is .extern class /// </summary> /// <param name="attrSet">attributes of the class to be exported</param> /// <param name="nsName">name space name</param> /// <param name="name">external class name</param> /// <param name="declFile">the file where the class is declared</param> /// <param name="isValueClass">is this class a value type?</param> /// <returns>a descriptor for this external class</returns> public ClassRef AddExternClass(TypeAttr attrSet, string nsName, string name, bool isValueClass, PEFile pefile) { Contract.Requires(nsName != null); Contract.Requires(name != null); Contract.Requires(pefile != null); ClassRef cRef = new ClassRef(this, nsName, name); if (isValueClass) cRef.MakeValueClass(); ExternClass eClass = new ExternClass(attrSet, nsName, name, modFile); exportedClasses.Add(eClass); cRef.SetExternClass(eClass); classes.Add(cRef); return cRef; }