SetOutputStream() 공개 메소드

Direct PE File output to an existing stream, instead of creating a new file.
public SetOutputStream ( Stream output ) : void
output Stream The output stream
리턴 void
예제 #1
0
파일: Emitter.cs 프로젝트: nomit007/f4
 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);
       }
 }
예제 #2
0
        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;
        }