internal CodeGenContext(CodeGenContext context) { this.Assembly = context.Assembly; this.Method = context.Method; this.CLRLocals = context.CLRLocals; this.labels = context.labels; this.CurrentRubyClass = context.CurrentRubyClass; this.orig_func = context.orig_func; // BBTAG this.orig_func_formals = context.orig_func_formals; // BBTAG this.currentSkeleton = context.currentSkeleton; // BBTAG this.postPassList = context.postPassList; // BBTAG this.peFiles = context.peFiles; // BBTAG }
/*-------------------- Constructors ---------------------------------*/ internal Assembly(string name, PEFile pefile) : base(name) { this.pefile = pefile; tabIx = MDTable.Assembly; }
internal void SetScope(PEFile mod) { scope = mod; }
//uint[] interfaceIndexes; //private string[] eventNames, propertyNames, nestedNames; //internal string[][] names = new string[numListIx][]; /*-------------------- Constructors ---------------------------------*/ internal ClassDef(PEFile scope, TypeAttr attrSet, string nsName, string name) : base(nsName,name) { this.scope = scope; superType = MSCorLib.mscorlib.ObjectClass; flags = (uint)attrSet; tabIx = MDTable.TypeDef; }
public CILWriter(string filename, bool debug, PEFile pefile) : base(new FileStream(filename, FileMode.Create)) { this.pefile = pefile; WriteLine("// ILASM output by PERWAPI"); WriteLine("// for file <" + pefile.GetFileName() + ">"); }
public static PEFile ReadPEFile(string filename, bool skipBody) { System.IO.FileStream file = GetFile(filename); PEFile pefile = new PEFile(filename); PEReader reader = new PEReader(pefile,file,false,skipBody); return pefile; }
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; }
private void InitResource(PEFile pefile, string name, bool isPub) { this.pefile = pefile; mrName = name; if (isPub) flags = PublicResource; else flags = PrivateResource; tabIx = MDTable.ManifestResource; }
internal ManifestResource(PEFile pefile, string name, MetaDataElement fileRef, uint offset, bool isPub) { InitResource(pefile,name,isPub); impl = fileRef; fileOffset = offset; }
internal ManifestResource(PEFile pefile, ManifestResource mres, bool isPub) { this.pefile = pefile; mrName = mres.mrName; flags = mres.flags; this.impl = mres.impl; this.fileOffset = mres.fileOffset; this.resourceBytes = mres.resourceBytes; }
/*-------------------- Constructors ---------------------------------*/ internal ManifestResource(PEFile pefile, string name, byte[] resBytes, bool isPub) { InitResource(pefile,name,isPub); this.resourceBytes = resBytes; }
public void init(string assemblyName, string stubName) { this.assemblyName = assemblyName; if (stubName == null) { string libPath = Fan.Sys.Sys.m_homeDir + "/lib/tmp"; if (!Directory.Exists(libPath)) Directory.CreateDirectory(libPath); this.fileName = libPath + "/" + assemblyName + ".dll"; } else { this.fileName = stubName; this.stubFileName = stubName; } peFile = new PEFile(fileName, assemblyName); if (!debug && !cache) { // Normally we have to write the dll to disk in order to get // the .pdb file. But if we don't need that, we can just // generate the whole assembly in memory buf = new MemoryStream(4096); peFile.SetOutputStream(buf); } }
internal static System.Reflection.Assembly Load(PEFile assembly) { MemoryStream binaryStream = new MemoryStream(); assembly.SetOutputStream(binaryStream); assembly.MakeDebuggable(false, false); assembly.WritePEFile(false); byte[] assemblyBytes = binaryStream.ToArray(); System.Reflection.Assembly loadedAssembly = System.Reflection.Assembly.Load(assemblyBytes); loaded.Add(loadedAssembly); return loadedAssembly; }
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; }
/*------------------------- 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) { 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; }
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 void CreateAssembly(string directory, string fileName, string assemblyName, bool GUI) { Assembly = new PEFile(fileName, assemblyName); Assembly.SetSubSystem(GUI ? SubSystem.Windows_GUI : SubSystem.Windows_CUI); Assembly.SetNetVersion(NetVersion.Version2); Assembly.GetThisAssembly().AddCustomAttribute(Runtime.RubyAttribute.ctor, new byte[0]); Assembly.SetOutputDirectory(directory); }