Beispiel #1
1
 public DisassembledIl Read(Pathname path)
 {
   using (StringWriter writer = new StringWriter())
   {
     using (StreamReader reader = new StreamReader(path.AsString))
     {
       foreach (string line in reader.Lines())
       {
         writer.WriteLine(line);
       }
     }
     return new DisassembledIl(writer.ToString());
   }
 }
Beispiel #2
0
 public bool IsValid()
 {
   if (_args.Length != 3)
   {
     Console.WriteLine("{0}: <root-assembly> <key-file> <output-directory>", "Machine.Hancock.exe");
     return false;
   }
   _rootAssembly = new Pathname(_args[0]);
   if (!_rootAssembly.IsFile)
   {
     Console.WriteLine("Root assembly is missing!");
     return false;
   }
   _keyFile = new Pathname(_args[1]);
   if (!_keyFile.IsFile)
   {
     Console.WriteLine("Key file is missing!");
     return false;
   }
   _outputDirectory = new Pathname(_args[2]);
   if (!_outputDirectory.IsDirectory)
   {
     Console.WriteLine("Output directory is missing!");
     return false;
   }
   return true;
 }
Beispiel #3
0
 public void Write(DisassembledIl il, Pathname path)
 {
   using (StreamWriter writer = new StreamWriter(path.AsString))
   {
     using (TextReader reader = il.OpenStream())
     {
       AssemblyExternParser parser = null;
       foreach (string line in reader.Lines())
       {
         if (line.StartsWith(".assembly extern"))
         {
           parser = new AssemblyExternParser(_publicKeyTokenProvider, line.Split(' ')[2]);
         }
         if (parser != null)
         {
           if (!parser.Line(line, writer))
           {
             parser = null;
           }
         }
         writer.WriteLine(line);
       }
     }
   }
 }
 public void Run(Pathname path, params string[] args)
 {
   ProcessStartInfo startInfo = new ProcessStartInfo(path.AsString);
   startInfo.Arguments = args.Join(" ");
   startInfo.UseShellExecute = false;
   startInfo.CreateNoWindow = true;
   Process process = Process.Start(startInfo);
   if (process == null)
   {
     throw new InvalidOperationException();
   }
   process.WaitForExit();
   if (process.ExitCode != 0)
   {
     throw new InvalidOperationException();
   }
 }
 public IncomingAssembly CreateDependencyGraph(Pathname path)
 {
   Dictionary<string, IncomingAssembly> map = new Dictionary<string, IncomingAssembly>();
   Assembly assembly = Assembly.ReflectionOnlyLoadFrom(path.AsString);
   return CreateDependencyGraph(map, assembly);
 }
 public AssembledAssembly(Pathname path, PublicKeyToken publicKeyToken)
 {
   _path = path;
   _publicKeyToken = publicKeyToken;
 }
 public IncomingAssembly(Pathname path, bool isSigned, bool inGac)
 {
   _path = path;
   _inGac = inGac;
   _isSigned = isSigned;
 }
 public Configuration(Pathname outputDirectory, Pathname keyFile)
 {
   _outputDirectory = outputDirectory;
   _keyFile = keyFile;
 }
Beispiel #9
0
 public Pathname ChangeDirectory(Pathname directory)
 {
   return directory.Join(this.FileName);
 }
Beispiel #10
0
 public Pathname Join(Pathname other)
 {
   return new Pathname(Path.Combine(_value, other.AsString));
 }
Beispiel #11
0
 private static PublicKeyToken ReadAssemblyPublicKeyToken(Pathname path)
 {
   Assembly assembly = Assembly.ReflectionOnlyLoadFrom(path.AsString);
   byte[] publicKeyToken = assembly.GetName().GetPublicKeyToken();
   return new PublicKeyToken(publicKeyToken);
 }
 public DisassembledAssembly(Pathname path, AssemblyType type)
 {
   _path = path;
   _type = type;
 }