示例#1
0
 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() + ">");
 }
示例#2
0
 /*-------------------- 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;
 }
示例#3
0
 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;
 }
示例#4
0
 internal void SetScope(PEFile mod)
 {
     Contract.Requires(mod != null);
     scope = mod;
 }
示例#5
0
 /*-------------------- Constructors ---------------------------------*/
 internal Assembly(string name, PEFile pefile)
     : base(name)
 {
     this.pefile = pefile;
     tabIx = MDTable.Assembly;
 }
示例#6
0
 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);
     }
 }
示例#7
0
 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;
 }
示例#8
0
 /*------------------------- 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;
 }
示例#9
0
        /*-------------------- Constructors ---------------------------------*/

        internal Assembly(string name, PEFile pefile)
            : base(name)
        {
            this.pefile = pefile;
            tabIx       = MDTable.Assembly;
        }