예제 #1
0
 public DisassembledAssembly Disassemble(IncomingAssembly assembly, Configuration configuration)
 {
   ProcessRunner runner = new ProcessRunner();
   Pathname ilPath = assembly.Path.ChangeDirectory(configuration.OutputDirectory).ChangeExtension("il");
   runner.Run(configuration.IlDasmPath, "/NOBAR", assembly.Path.AsString, "/OUT:" + ilPath);
   return new DisassembledAssembly(ilPath, assembly.Type);
 }
 private static IncomingAssembly CreateDependencyGraph(IDictionary<string, IncomingAssembly> map, Assembly assembly)
 {
   if (String.IsNullOrEmpty(assembly.FullName))
   {
     throw new InvalidOperationException();
   }
   if (map.ContainsKey(assembly.FullName))
   {
     return map[assembly.FullName];
   }
   byte[] publicKeyToken = assembly.GetName().GetPublicKeyToken();
   bool inGac = assembly.GlobalAssemblyCache;
   IncomingAssembly incomingAssembly = new IncomingAssembly(assembly.Pathname(), publicKeyToken.Length > 0, inGac);
   map[assembly.FullName] = incomingAssembly; 
   foreach (AssemblyName name in assembly.GetReferencedAssemblies())
   {
     Assembly referenced = null;
     try
     {
       referenced = Assembly.ReflectionOnlyLoad(name.ToString());
     }
     catch (Exception error)
     {
       foreach (string fileName in new [] { name.Name + ".dll", name.Name + ".exe" })
       {
         Pathname path = incomingAssembly.Path.ChangeFileName(fileName);
         if (path.IsFile)
         {
           referenced = Assembly.ReflectionOnlyLoadFrom(path.AsString);
         }
       }
     }
     if (referenced == null)
     {
       throw new InvalidOperationException();
     }
     incomingAssembly.Reference(CreateDependencyGraph(map, referenced));
   }
   return incomingAssembly;
 }
예제 #3
0
 public void Reference(IncomingAssembly assembly)
 {
   _referencedAssemblies.Add(assembly);
 }