private void frmFileDisassembler_FormClosing(object sender, FormClosingEventArgs e) { if (_reflector != null) { _reflector = null; } }
public bool SelectReflector(IHost host, bool force) { string path = GetReflector(host); string initDir; if (String.IsNullOrEmpty(path) || !File.Exists(path)) { initDir = null; } else { if (!force && File.Exists(path)) { return(true); } initDir = Path.GetDirectoryName(path); } path = SimpleReflector.OpenReflector(initDir); if (!File.Exists(path)) { return(false); } SetReflector(host, path); return(true); }
public override void Unload() { if (_reflector != null) { base.Unload(); _reflector = null; } }
public frmMethodSearcher(IHost host, string[] rows, string sourceDir) { InitializeComponent(); _host = host; _rows = rows; _sourceDir = SimplePath.GetFullPath(sourceDir); cboSearchFor.Items.Add("// This item is obfuscated and can not be translated."); cboSearchFor.Items.Add("// This item appears to be generated and can not be translated."); cboSearchFor.Items.Add("using (enumerator ="); if (!String.IsNullOrEmpty(this.LastSearchFor)) { cboSearchFor.Text = this.LastSearchFor; } else { cboSearchFor.SelectedIndex = 0; } switch (this.LogTo) { case "Screen": rbToScreen.Checked = true; break; case "File": rbToFile.Checked = true; break; default: break; } _reflector = SimpleReflector.Default; //_reflector.FormatterType = typeof(TextFormatter); _reflector.FormatterTypeName = "SimpleAssemblyExplorer.LutzReflector.TextFormatter"; foreach (string l in _reflector.Languages) { int index = cboLanguage.Items.Add(l); if (l == "C#") { cboLanguage.SelectedIndex = index; } } //foreach (string op in SimpleReflector.OptimizationList) //{ // int index = cboOptimization.Items.Add(op); // if (op == "2.0") // { // cboOptimization.SelectedIndex = index; // } //} }
public FileDisassemblerHelper( SimpleReflector reflector, ProjectTypes projectType, string outputDirectory, WriteLineDelegate writeLineDelegate, SetProgressBarDelegate setProgressBarDelegate, IsCancelPendingDelegate isCancelPendingDelegate) { _reflector = reflector; _projectType = projectType; _outputDirectory = outputDirectory; WriteLine += writeLineDelegate; SetProgressBar += setProgressBarDelegate; _isCancelPendingDelegate = isCancelPendingDelegate; }
public static List <MethodDeclarationInfo> FindMethods(string[] files, string[] searchFors, string[] searchForTypes) { SimpleReflector reflector = CreateReflector(); try { return(reflector.FindMethods(files, searchFors, searchForTypes, null, null)); } catch { throw; } finally { foreach (string file in files) { reflector.UnloadAssembly(file); } } }
Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { Assembly a = _coreAssemblyResolver.DefaultResolveEventHandler(sender, args); if (a != null) { return(a); } a = AssemblyUtils.ResolveAssemblyFile(args.Name, _form.TreeViewHandler.CurrentPath); if (a != null) { return(a); } if (args.Name.IndexOf("Reflector,") >= 0) { string path = SimpleReflector.OpenReflector(); if (!String.IsNullOrEmpty(path)) { path = Path.GetDirectoryName(path); AddAssemblyResolveDir(path); a = AssemblyUtils.ResolveAssemblyFile(args.Name, path); if (a != null) { return(a); } } } if (_form.TextInfo != null && !IsResourcesAssembly(args.Name)) { string message = "Could not resolve: " + args.Name; if (!_form.TextInfo.TextInfo.Contains(message)) { _form.TextInfo.AppendTextInfoLine(message); } } return(null); }
public override void InitControls() { //TODO: better to new instance, but seems resource can't be released if (_reflector == null) { _reflector = SimpleReflector.Default; _reflector.FormatterType = typeof(RichTextFormatter); } foreach (string l in _reflector.Languages) { int index = cboLanguage.Items.Add(l); if (l == "C#") { cboLanguage.SelectedIndex = index; } } foreach (string op in SimpleReflector.OptimizationList) { int index = cboOptimization.Items.Add(op); if (op == "2.0") { cboOptimization.SelectedIndex = index; } } if (cboLanguage.Items.Count > 0 && cboLanguage.SelectedIndex < 0) { cboLanguage.SelectedIndex = 0; } if (IsReady) { tabPage.Text = String.Format("{0} {1}.{2}", _name, SimpleReflector.Version.Major, SimpleReflector.Version.Minor); cboLanguage.SelectedIndexChanged += new EventHandler(base.cboLanguage_SelectedIndexChanged); cboOptimization.SelectedIndexChanged += new EventHandler(cboOptimization_SelectedIndexChanged); } }
public override void InitControls() { //TODO: better to new instance, but seems resource can't be released if (_reflector == null) { _reflector = SimpleReflector.Default; _reflector.FormatterType = typeof(RichTextFormatter); } foreach (string l in _reflector.Languages) { int index = cboLanguage.Items.Add(l); if (l == "C#") { cboLanguage.SelectedIndex = index; } } foreach (string op in SimpleReflector.OptimizationList) { int index = cboOptimization.Items.Add(op); if (op == "2.0") { cboOptimization.SelectedIndex = index; } } if (cboLanguage.Items.Count > 0 && cboLanguage.SelectedIndex < 0) cboLanguage.SelectedIndex = 0; if (IsReady) { tabPage.Text = String.Format("{0} {1}.{2}", _name, SimpleReflector.Version.Major, SimpleReflector.Version.Minor); cboLanguage.SelectedIndexChanged += new EventHandler(base.cboLanguage_SelectedIndexChanged); cboOptimization.SelectedIndexChanged += new EventHandler(cboOptimization_SelectedIndexChanged); } }
private void btnOK_Click(object sender, EventArgs e) { const string btnOkText = "OK"; const string btnStopText = "Stop"; switch (btnOK.Text) { case btnStopText: _isCancelPending = true; return; default: break; } string outputDir = txtOutputDir.Text; //if (!Directory.Exists(outputDir)) //{ // SimpleMessage.ShowInfo("Please choose output directory"); // return; //} if (_sourceDir != null && _sourceDir.Equals(outputDir)) { OutputDir = String.Empty; } else { OutputDir = outputDir; } try { btnOK.Text = btnStopText; SimpleAssemblyExplorer.Utils.EnableUI(this.Controls, false); Application.DoEvents(); if (_reflector == null) { //TODO: better to new instance, but seems resource can't be released _reflector = SimpleReflector.Default; } _reflector.Optimization = cboOptimization.Text; txtInfo.Text = String.Empty; WriteLine(String.Format("=== Started at {0} ===\r\n", DateTime.Now)); Application.DoEvents(); _isCancelPending = false; _host.ResetProgress(); _reflector.LanguageManager.ActiveLanguage = _reflector.GetLanguage(cboLanguage.SelectedItem as string); for (int i = 0; i < lbAssemblies.Items.Count; i++) { string file = lbAssemblies.Items[i] as string; _reflector.LoadAssembly(file); } for (int i = 0; i < lbAssemblies.Items.Count; i++) { if (_isCancelPending) { break; } string file = lbAssemblies.Items[i] as string; _host.SetStatusText(String.Format("Handling {0} ...", file)); DisassembleFile(file); Application.DoEvents(); } for (int i = 0; i < lbAssemblies.Items.Count; i++) { string file = lbAssemblies.Items[i] as string; _reflector.UnloadAssembly(file); } if (_isCancelPending) { WriteLine("User breaked.\r\n"); } } catch (Exception ex) { WriteLine(String.Format("{0}\r\n\r\n", ex.Message)); } finally { btnOK.Text = btnOkText; SimpleAssemblyExplorer.Utils.EnableUI(this.Controls, true); _host.SetStatusText(null); _host.ResetProgress(); if (_reflector != null && _reflector.LanguageManager != null) { _reflector.LanguageManager.ActiveLanguage = _reflector.GetLanguage("C#"); } } WriteLine(String.Format("=== Completed at {0} ===\r\n", DateTime.Now)); //this.Close(); }
private void btnOK_Click(object sender, EventArgs e) { const string btnOkText = "OK"; const string btnStopText = "Stop"; switch (btnOK.Text) { case btnStopText: _isCancelPending = true; return; default: break; } string outputDir = txtOutputDir.Text; //if (!Directory.Exists(outputDir)) //{ // SimpleMessage.ShowInfo("Please choose output directory"); // return; //} if (_sourceDir != null && _sourceDir.Equals(outputDir)) OutputDir = String.Empty; else OutputDir = outputDir; try { btnOK.Text = btnStopText; SimpleAssemblyExplorer.Utils.EnableUI(this.Controls, false); Application.DoEvents(); if (_reflector == null) { //TODO: better to new instance, but seems resource can't be released _reflector = SimpleReflector.Default; } _reflector.Optimization = cboOptimization.Text; txtInfo.Text = String.Empty; WriteLine(String.Format("=== Started at {0} ===\r\n", DateTime.Now)); Application.DoEvents(); _isCancelPending = false; _host.ResetProgress(); _reflector.LanguageManager.ActiveLanguage = _reflector.GetLanguage(cboLanguage.SelectedItem as string); for (int i = 0; i < lbAssemblies.Items.Count; i++) { string file = lbAssemblies.Items[i] as string; _reflector.LoadAssembly(file); } for (int i = 0; i < lbAssemblies.Items.Count; i++) { if (_isCancelPending) break; string file = lbAssemblies.Items[i] as string; _host.SetStatusText(String.Format("Handling {0} ...", file)); DisassembleFile(file); Application.DoEvents(); } for (int i = 0; i < lbAssemblies.Items.Count; i++) { string file = lbAssemblies.Items[i] as string; _reflector.UnloadAssembly(file); } if (_isCancelPending) WriteLine("User breaked.\r\n"); } catch (Exception ex) { WriteLine(String.Format("{0}\r\n\r\n", ex.Message)); } finally { btnOK.Text = btnOkText; SimpleAssemblyExplorer.Utils.EnableUI(this.Controls, true); _host.SetStatusText(null); _host.ResetProgress(); if (_reflector != null && _reflector.LanguageManager != null) { _reflector.LanguageManager.ActiveLanguage = _reflector.GetLanguage("C#"); } } WriteLine(String.Format("=== Completed at {0} ===\r\n", DateTime.Now)); //this.Close(); }