Example #1
0
 private void btnILSpyReload_Click(object sender, EventArgs e)
 {
     using (new SimpleWaitCursor())
     {
         ILSpyHandler.UnloadAssemblies();
         ILSpyHandler.LoadAssemblies();
     }
 }
Example #2
0
 private void tabILSpy_Enter(object sender, EventArgs e)
 {
     ILSpyHandler.tabPage_Enter(sender, e);
 }
Example #3
0
 private void btnILSpyLoad_Click(object sender, EventArgs e)
 {
     ILSpyHandler.btnLoad_Click(sender, e);
 }
Example #4
0
 private void tabControl1_Selected(object sender, TabControlEventArgs e)
 {
     ILSpyHandler.CheckDecompile();
 }
Example #5
0
            private void worker_DoWork(object sender, DoWorkEventArgs e)
            {
                MainForm.RtbILSpy.BeginInvoke(new MethodInvoker(() =>
                {
                    ILSpyHandler.Clear();
                    MainForm.RtbILSpy.Text = Environment.NewLine + "Decompiling..." + Environment.NewLine +
                                             "First time might take a while.";
                }));

                try
                {
                    AssemblyDefinition assembly = Translate(MainForm.CurrentAssembly.ManifestModule);

                    if (assembly == null)
                    {
                        throw new Exception("Could not write assembly to stream!");
                    }

                    var    dnMethod = new MonoMethod(MainForm.CurrentAssembly.Method);
                    object method   = dnMethod.Method(assembly);

                    if (method == null)
                    {
                        return;
                    }

                    var mtp = (IMetadataTokenProvider)method;
                    method = assembly.MainModule.LookupToken(mtp.MetadataToken);

                    if (method == null || string.IsNullOrEmpty(method.ToString()))
                    {
                        MainForm.RtbILSpy.BeginInvoke(new MethodInvoker(
                                                          () =>
                        {
                            ILSpyHandler.Clear();
                            MainForm.RtbILSpy.Text = Environment.NewLine +
                                                     "Could not find member by Metadata Token!";
                        }));

                        return;
                    }

                    DefaultAssemblyResolver bar     = GlobalAssemblyResolver.Instance;
                    bool savedRaiseResolveException = true;
                    try
                    {
                        if (bar != null)
                        {
                            savedRaiseResolveException = bar.RaiseResolveException;
                            bar.RaiseResolveException  = false;
                        }

                        var    il     = new ILSpyDecompiler();
                        string source = il.Decompile(method);

                        MainForm.RtbILSpy.BeginInvoke(new MethodInvoker(() =>
                        {
                            ILSpyHandler.Clear();
                            MainForm.RtbILSpy.Rtf = source;
                        }));
                    }
                    finally
                    {
                        if (bar != null)
                        {
                            bar.RaiseResolveException = savedRaiseResolveException;
                        }
                    }
                }
                catch (Exception o)
                {
                    MainForm.RtbILSpy.BeginInvoke(new MethodInvoker(
                                                      () =>
                    {
                        ILSpyHandler.Clear();
                        MainForm.RtbILSpy.Text = Environment.NewLine + "Decompilation unsuccessful!" +
                                                 Environment.NewLine +
                                                 Environment.NewLine + o.Message;
                    }));
                }
            }