public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            ISolution     solution;
            IAssemblyFile existingAssemblyFile = TryGetExistingAssemblyFile(context, out solution);

            if (existingAssemblyFile == null)
            {
                return;
            }

            var deobfuscator = solution.TryGetComponent <IAssemblyDeobfuscatorManager>();

            if (deobfuscator == null)
            {
                return;
            }

            string newFileName = AskUser(existingAssemblyFile);

            if (newFileName == null)
            {
                return;
            }

            FileSystemPath newAssembly = null;

            Shell.Instance.GetComponent <UITaskExecutor>().FreeThreaded.ExecuteTask("Deobfuscating...", TaskCancelable.Yes, progressIndicator =>
            {
                using (ReadLockCookie.Create())
                    newAssembly = deobfuscator.Execute(existingAssemblyFile, newFileName, progressIndicator);
            });

            if (newAssembly != null)
            {
                if (MessageBox.ShowYesNo("Deobfuscation complete!\nWould you like to open the deobfuscated assembly?"))
                {
                    AddToAssemblyExplorer(newAssembly, solution);
                }
            }
        }
예제 #2
0
        private static void HandleElement(ITextControl editor, ITreeNode element, int offset)
        {
            string stringToInsert = Clipboard.GetText();

            if (string.IsNullOrEmpty(stringToInsert))
            {
                return;
            }

            IDocCommentNode docCommentNode = element as IDocCommentNode;

            if (docCommentNode != null)
            {
                JetBrains.Util.dataStructures.TypedIntrinsics.Int32 <DocLine> currentLineNumber =
                    editor.Document.GetCoordsByOffset(editor.Caret.Offset()).Line;
                string currentLine = editor.Document.GetLineText(currentLineNumber);
                int    index       = currentLine.IndexOf("///", StringComparison.Ordinal);
                if (index < 0)
                {
                    return;
                }
                string prefix = currentLine.Substring(0, index);

                if (ShallEscape(docCommentNode, editor.Caret.Offset()) &&
                    JetBrains.UI.RichText.RichTextBlockToHtml.HtmlEncode(stringToInsert) != stringToInsert &&
                    MessageBox.ShowYesNo("Do you want the text to be escaped?"))
                {
                    stringToInsert = JetBrains.UI.RichText.RichTextBlockToHtml.HtmlEncode(stringToInsert);
                }

                stringToInsert = stringToInsert.Replace("\n", "\n" + prefix + "///");
            }

            ITokenNode token = element as ITokenNode;

            if (token != null)
            {
                if (token.GetTokenType() == CSharpTokenType.STRING_LITERAL &&
                    offset < token.GetTreeTextRange().EndOffset.Offset)
                {
                    string text = token.GetText();
                    if (text.StartsWith("@") && offset > token.GetTreeTextRange().StartOffset.Offset + 1)
                    {
                        stringToInsert = stringToInsert.Replace("\"", "\"\"");
                    }
                    else if (!text.StartsWith("@"))
                    {
                        stringToInsert = stringToInsert.
                                         Replace("\\", "\\\\").
                                         Replace("\a", "\\a").
                                         Replace("\b", "\\b").
                                         Replace("\f", "\\f").
                                         Replace("\n", "\\n").
                                         Replace("\r", "\\r").
                                         Replace("\t", "\\t").
                                         Replace("\v", "\\v").
                                         Replace("\'", "\\'").
                                         Replace("\"", "\\\"");
                    }
                }
            }

            editor.Document.InsertText(editor.Caret.Offset(), stringToInsert);
        }