private void BuildSubstitutionNode(PineappleTreeNode node, INamedEntity entity, string originalLine)
 {
     node.BacklightColorIndex = (int)Highlights.Substitution;
     node.Text += "\nClass substitution";
     if (originalLine != null && Configs.Instance.ShowOriginal)
     {
         node.Text += "\nOriginal line: " + originalLine;
     }
     node.ToolTipText = "Target method not found in mapping.";
     node.ImageIndex  = TreeBuilder.GetIconForEntity(entity.EntityType, mainForm);
 }
 private void BuildFailedNode(PineappleTreeNode node, INamedEntity entity, string originalLine)
 {
     node.ImageIndex          = TreeBuilder.GetIconForEntity(entity.EntityType, mainForm);
     node.BacklightColorIndex = (int)Highlights.Unknown;
     node.Text += "\nUnable to deobfuscate.";
     if (originalLine != null && Configs.Instance.ShowOriginal)
     {
         node.Text += "\nOriginal line: " + originalLine;
     }
     node.ToolTipText = "Unable to deobfuscate method. It is of an unknown or system assembly.";
 }
        private void BuildResult(RenamedBase item)
        {
            ListViewItem l = new ListViewItem(item.NameOldSimple);

            l.ImageIndex = TreeBuilder.GetIconForEntity(item.EntityType, mainForm);
            lvResults.Items.Add(l);
            ItemDescriptor d = new ItemDescriptor(item);

            l.Tag = d;
            string tip;

            if (item is RenamedClass)
            {
                tip = TreeBuilder.BuildHintForClass((RenamedClass)item);
            }
            else
            {
                tip = TreeBuilder.BuildHintForItem((RenamedItem)item);
            }

            if (!mainForm.HavePdb)
            {
                tip += "Unable to map to source code, no PDB files attached.";
            }
            else
            {
                if (item.EntityType != EntityType.Method)
                {
                    tip += "Mapping to source code works only for methods.";
                }
                else
                {
                    string filename;
                    int    line;
                    if (mainForm.SearchInPdb(out filename, out line, item))
                    {
                        tip       += "Source position:\n" + filename + ":" + line + " (Ctrl+Click to open)";
                        d.Filename = filename;
                        d.Line     = line;
                    }
                    else
                    {
                        tip += "Unable to map to source code.";
                    }
                }
            }

            tip += "\nDouble-click to select in classes tree.";

            l.ToolTipText = tip;
        }
            public string GetToolTip()
            {
                RenamedItem item = renamed as RenamedItem;

                if (item != null)
                {
                    return(TreeBuilder.BuildHintForItem(item));
                }
                RenamedClass @class = renamed as RenamedClass;

                if (@class != null)
                {
                    return(TreeBuilder.BuildHintForClass(@class));
                }

                return(entity.NameFull);
            }
        public SearchResultsForm(MainForm mainForm, SearchResults items, string name)
        {
            InitializeComponent();
            lvItems.SmallImageList = mainForm.IconsList;

            Text = name;
            foreach (INamedEntity item in items.Results)
            {
                string itemName = item.NameFull;

                ListViewItem lv = new ListViewItem(itemName);
                lv.ImageIndex = TreeBuilder.GetIconForEntity(item.EntityType, mainForm);
                lv.Tag        = item;
                lvItems.Items.Add(lv);
                lv.ToolTipText = ((RenamedBase)item).TreeNode.ToolTipText + "Double-click to select in classes tree.";;
            }

            chItem.Width = lvItems.ClientSize.Width;
        }
示例#6
0
        private void BuildMapping()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            ptvElements.BeginUpdate();
            mapping.PurgeTreeNodes();

            TreeBuilder builder = new TreeBuilder(ptvElements, mapping, this);

            builder.GroupNamespaces    = Configs.Instance.GroupNamespaces;
            builder.GroupModules       = Configs.Instance.GroupModules;
            builder.ShowModules        = Configs.Instance.ShowModules;
            builder.ShowResources      = Configs.Instance.ShowResources;
            builder.ShowSkippedMembers = Configs.Instance.ShowSkipped;
            builder.GroupResources     = Configs.Instance.GroupResources;
            try
            {
                builder.Build();
            }
            catch (Exception e)
            {
                RestApi.Instance.SendCrashReport(
                    new CrashReport("Mapping tree builder", "Error on building classes tree", CrashType.JustReport)
                {
                    Exception = e
                },
                    this
                    );
            }

            Sort(Configs.Instance.SortingType);
            focusedItem = null;

            ptvElements.CollapseAll();
            ptvElements.EndUpdate();
            sw.Stop();
            Debug.WriteLine($"Tree building: {sw.ElapsedMilliseconds} ms");
        }
        private void BuildNormalNode(PineappleTreeNode node, INamedEntity entity, string originalLine)
        {
            node.ImageIndex = TreeBuilder.GetIconForEntity(entity.EntityType, mainForm);
            ItemDescriptor descriptor = new ItemDescriptor(entity);
            string         tooltip    = descriptor.GetToolTip();

            node.Tag = descriptor;

            RenamedItem item = entity as RenamedItem;

            if (item != null)
            {
                node.Text += "\nOwner class: " + item.Owner.NameOldFull;
            }

            RenamedBase renamedBase = (RenamedBase)entity;

            if (tbtnShort.Checked)
            {
                node.Text += "\nNew name: " + renamedBase.NameNew;
            }
            if (tbtnSimple.Checked)
            {
                node.Text += "\nNew name: " + renamedBase.NameNewSimple;
            }
            if (tbtnFull.Checked)
            {
                node.Text += "\nNew name: " + renamedBase.NameNewFull;
            }

            if (originalLine != null && Configs.Instance.ShowOriginal)
            {
                node.Text += "\nOriginal line: " + originalLine;
            }

            if (!mainForm.HavePdb)
            {
                tooltip += "Unable to map to source code, no PDB files attached.";
            }
            else
            {
                if (entity.EntityType != EntityType.Method)
                {
                    tooltip += "Mapping to source code works only for methods.";
                }
                else
                {
                    ProcessPdb(descriptor);
                    if (descriptor.Filename != null)
                    {
                        node.Text += "\n" + PathUtils.ShortenPath(descriptor.Filename, 100) + ":" + descriptor.Line;
                        tooltip   += descriptor.Filename + ":" + descriptor.Line;
                    }
                    else
                    {
                        tooltip += "Unable to map to source code.";
                    }
                }
            }

            node.ToolTipText = tooltip;
        }