public bool Decompile(IDecompileNodeContext context) { var er = Resource as EmbeddedResource; if (er != null) return ResourceUtils.Decompile(context, new MemoryStream(er.GetResourceData()), er.Name); return false; }
public static bool Decompile(IDecompileNodeContext context, Stream stream, string name) { if (stream == null || stream.Length > 500 * 1024) return false; stream.Position = 0; FileType type = GuessFileType.DetectFileType(stream); if (type == FileType.Binary) return false; stream.Position = 0; context.Output.Write(FileReader.OpenStream(stream, Encoding.UTF8).ReadToEnd(), TextTokenKind.Text); string ext; if (type == FileType.Xml) ext = ".xml"; else { try { ext = Path.GetExtension(NameUtils.CleanName(name)); } catch (ArgumentException) { ext = ".txt"; } } context.HighlightingExtension = ext; return true; }
void DecompileNode(IDecompileNodeContext context, DocumentTreeNodeData node) { foreach (var d in decompileNodes) { if (d.Decompile(context, node)) return; } Debug.Fail("Missing decompiler"); }
public bool Decompile(IDecompileNodeContext context) { context.ContentTypeString = context.Decompiler.ContentTypeString; context.Decompiler.WriteCommentLine(context.Output, string.Format("{0:X8} - {1:X8} {2}", Span.Start.ToUInt64(), Span.End.ToUInt64() - 1, ToString())); DecompileFields(context.Decompiler, context.Output); (context.Output as IDocumentViewerOutput)?.DisableCaching(); return true; }
public NodeDecompiler(Func<Func<object>, object> execInThread, ITextOutput output, ILanguage language, DecompilationContext decompilationContext, IDecompileNodeContext decompileNodeContext = null) { this.execInThread = execInThread; this.output = output; this.language = language; this.decompilationContext = decompilationContext; this.decompileNodeContext = decompileNodeContext; }
public bool Decompile(IDecompileNodeContext context) { context.Language.WriteCommentLine(context.Output, string.Format("{0:X8} - {1:X8} {2}", StartOffset, EndOffset, this.ToString())); DecompileFields(context.Language, context.Output); var smartOutput = context.Output as ISmartTextOutput; if (smartOutput != null) smartOutput.DontCacheOutput(); return true; }
public NodeDecompiler(Func<Func<object>, object> execInThread, IDecompilerOutput output, IDecompiler decompiler, DecompilationContext decompilationContext, IDecompileNodeContext decompileNodeContext = null) { this.execInThread = execInThread; this.output = output; this.decompiler = decompiler; this.decompilationContext = decompilationContext; this.decompileNodeContext = decompileNodeContext; this.decompileNodeContext.ContentTypeString = decompiler.ContentTypeString; }
public NodeDecompiler(Func <Func <object>, object> execInThread, IDecompilerOutput output, IDecompiler decompiler, DecompilationContext decompilationContext, IDecompileNodeContext decompileNodeContext = null) { this.execInThread = execInThread; this.output = output; this.decompiler = decompiler; this.decompilationContext = decompilationContext; this.decompileNodeContext = decompileNodeContext; this.decompileNodeContext.ContentTypeString = decompiler.ContentTypeString; }
public bool Decompile(IDecompileNodeContext context) { var er = Resource as EmbeddedResource; if (er != null) { return(ResourceUtilities.Decompile(context, new MemoryStream(er.GetResourceData()), er.Name)); } return(false); }
void DecompileNode(IDecompileNodeContext context, DocumentTreeNodeData node) { foreach (var d in decompileNodes) { if (d.Decompile(context, node)) { return; } } Debug.Fail("Missing decompiler"); }
public bool Decompile(IDecompileNodeContext context) { context.Language.WriteCommentLine(context.Output, string.Format("{0:X8} - {1:X8} {2}", StartOffset, EndOffset, this.ToString())); DecompileFields(context.Language, context.Output); var smartOutput = context.Output as ISmartTextOutput; if (smartOutput != null) { smartOutput.DontCacheOutput(); } return(true); }
public bool Decompile(IDecompileNodeContext context, IFileTreeNodeData node) { var msgNode = node as SomeMessageNode; if (msgNode == null) { return(false); } context.Language.WriteCommentLine(context.Output, "The secret message has been decrypted."); context.Language.WriteCommentLine(context.Output, string.Format("The message is: {0}", msgNode.Message)); return(true); }
public bool Decompile(IDecompileNodeContext context) { if (ResourceElement.ResourceData.Code == ResourceTypeCode.String) { context.Output.Write((string)((BuiltInResourceData)ResourceElement.ResourceData).Data, BoxedTextColor.Text); context.ContentTypeString = ContentTypes.PlainText; return true; } if (ResourceElement.ResourceData.Code == ResourceTypeCode.ByteArray || ResourceElement.ResourceData.Code == ResourceTypeCode.Stream) { var data = (byte[])((BuiltInResourceData)ResourceElement.ResourceData).Data; return ResourceUtilities.Decompile(context, new MemoryStream(data), Name); } return false; }
public bool Decompile(IDecompileNodeContext context, DocumentTreeNodeData node) { var msgNode = node as SomeMessageNode; if (msgNode == null) { return(false); } context.Decompiler.WriteCommentLine(context.Output, "The secret message has been decrypted."); context.Decompiler.WriteCommentLine(context.Output, string.Format("The message is: {0}", msgNode.Message)); context.ContentTypeString = ContentTypes.PlainText; return(true); }
public bool Decompile(IDecompileNodeContext context) { if (ResourceElement.ResourceData.Code == ResourceTypeCode.String) { context.Output.Write((string)((BuiltInResourceData)ResourceElement.ResourceData).Data, TextTokenKind.Text); context.HighlightingExtension = ".txt"; return true; } if (ResourceElement.ResourceData.Code == ResourceTypeCode.ByteArray || ResourceElement.ResourceData.Code == ResourceTypeCode.Stream) { var data = (byte[])((BuiltInResourceData)ResourceElement.ResourceData).Data; return ResourceUtils.Decompile(context, new MemoryStream(data), Name); } return false; }
public bool Decompile(IDecompileNodeContext context) { var children = context.ExecuteInUIThread(() => { TreeNode.EnsureChildrenLoaded(); return(TreeNode.DataChildren.OfType <HexNode>().ToArray()); }); context.Language.WriteCommentLine(context.Output, dnSpy_AsmEditor_Resources.HexNode_PE); context.Language.WriteCommentLine(context.Output, dnSpy_AsmEditor_Resources.NodesUseHexEditorMsg); foreach (HexNode node in children) { context.Language.WriteCommentLine(context.Output, string.Empty); node.Decompile(context); } return(true); }
public bool Decompile(IDecompileNodeContext context) { if (ResourceElement.ResourceData.Code == ResourceTypeCode.String) { context.Output.Write((string)((BuiltInResourceData)ResourceElement.ResourceData).Data, BoxedTextColor.Text); context.ContentTypeString = ContentTypes.PlainText; return(true); } if (ResourceElement.ResourceData.Code == ResourceTypeCode.ByteArray || ResourceElement.ResourceData.Code == ResourceTypeCode.Stream) { var data = (byte[])((BuiltInResourceData)ResourceElement.ResourceData).Data; return(ResourceUtilities.Decompile(context, new MemoryStream(data), Name)); } return(false); }
public bool Decompile(IDecompileNodeContext context) { if (ResourceElement.ResourceData.Code == ResourceTypeCode.String) { context.Output.Write((string)((BuiltInResourceData)ResourceElement.ResourceData).Data, TextTokenKind.Text); context.HighlightingExtension = ".txt"; return(true); } if (ResourceElement.ResourceData.Code == ResourceTypeCode.ByteArray || ResourceElement.ResourceData.Code == ResourceTypeCode.Stream) { var data = (byte[])((BuiltInResourceData)ResourceElement.ResourceData).Data; return(ResourceUtils.Decompile(context, new MemoryStream(data), Name)); } return(false); }
public void Decompile(IDecompileNodeContext decompileNodeContext, DocumentTreeNodeData[] nodes) { foreach (var dc in decompileNodeCollections) { if (dc.Decompile(decompileNodeContext, nodes)) return; } if (nodes.Length == 1) { var ds = nodes[0] as IDecompileSelf; if (ds?.Decompile(decompileNodeContext) == true) return; } for (int i = 0; i < nodes.Length; i++) { decompileNodeContext.DecompilationContext.CancellationToken.ThrowIfCancellationRequested(); if (i > 0) decompileNodeContext.Output.WriteLine(); DecompileNode(decompileNodeContext, nodes[i]); } }
public bool Decompile(IDecompileNodeContext context) { context.ContentTypeString = ContentTypes.PlainText; context.Output.Write(document.Text, BoxedTextColor.Text); return(true); }
public bool Decompile(IDecompileNodeContext context, IFileTreeNodeData node) { new NodeDecompiler(a => context.ExecuteInUIThread(() => a()), context.Output, context.Language, context.DecompilationContext, context).Decompile(node); return(true); }
// Gets called by dnSpy if there's only one node to decompile. This method gets called in a // worker thread. The output is also cached unless you call AvalonEditTextOutput.DontCacheOutput(). public bool Decompile(IDecompileNodeContext context) { // Pretend we actually do something... Thread.Sleep(2000); // If you don't want the output to be cached, call DontCacheOutput() bool cacheOutput = true; if (!cacheOutput) { var avOutput = context.Output as AvalonEditTextOutput; if (avOutput != null) avOutput.DontCacheOutput(); } // Create the output and a few references that other code in this plugin will use, eg. // to show a tooltip when hovering over the reference. context.HighlightingExtension = ".cs"; context.Language.WriteCommentLine(context.Output, "Initialize it to the secret key"); context.Output.WriteReference("int", new StringInfoReference("This is a reference added by the code"), TextTokenKind.Keyword); context.Output.WriteSpace(); context.Output.WriteReference("secret", new StringInfoReference("The real secret is actually 42 not 1234"), TextTokenKind.Local); context.Output.WriteSpace(); context.Output.Write("=", TextTokenKind.Operator); context.Output.WriteSpace(); context.Output.Write("1234", TextTokenKind.Number); context.Output.Write(";", TextTokenKind.Operator); context.Output.WriteLine(); // We decompiled ourselves so return true return true; }
public bool Decompile(IDecompileNodeContext context) { context.ContentTypeString = Decompile(context.Output, context.DecompilationContext.CancellationToken); return true; }
public bool Decompile(IDecompileNodeContext context) { context.HighlightingExtension = Decompile(context.Output, context.DecompilationContext.CancellationToken); return true; }
public bool Decompile(IDecompileNodeContext context, DocumentTreeNodeData node) { new NodeDecompiler(a => context.UIThread(() => a()), context.Output, context.Decompiler, context.DecompilationContext, context).Decompile(node); return(true); }
public bool Decompile(IDecompileNodeContext context) { context.Output.Write(file.Text, TextTokenKind.Text); return(true); }
/// <summary> /// "Decompiles" the data /// </summary> /// <param name="context">Context</param> /// <param name="stream">Stream</param> /// <param name="name">Name</param> /// <returns></returns> public static bool Decompile(IDecompileNodeContext context, Stream stream, string name) { if (stream == null || stream.Length > 500 * 1024) return false; stream.Position = 0; FileType type = GuessFileType.DetectFileType(stream); if (type == FileType.Binary) return false; string ext; if (type == FileType.Xml) ext = ".xml"; else { try { ext = Path.GetExtension(NameUtilities.CleanName(name)); } catch (ArgumentException) { ext = ".txt"; } } context.ContentTypeString = ContentTypesHelper.TryGetContentTypeStringByExtension(ext) ?? ContentTypes.PlainText; stream.Position = 0; context.DocumentWriterService.Write(context.Output, new StreamReader(stream, true).ReadToEnd(), context.ContentTypeString); return true; }
public bool Decompile(IDecompileNodeContext context, IFileTreeNodeData node) { var msgNode = node as SomeMessageNode; if (msgNode == null) return false; context.Language.WriteCommentLine(context.Output, "The secret message has been decrypted."); context.Language.WriteCommentLine(context.Output, string.Format("The message is: {0}", msgNode.Message)); return true; }
public NodeDecompiler(Func <Func <object>, object> execInThread, ITextOutput output, ILanguage language, DecompilationContext decompilationContext, IDecompileNodeContext decompileNodeContext = null) { this.execInThread = execInThread; this.output = output; this.language = language; this.decompilationContext = decompilationContext; this.decompileNodeContext = decompileNodeContext; }
public bool Decompile(IDecompileNodeContext context) { context.HighlightingExtension = Decompile(context.Output, context.DecompilationContext.CancellationToken); return(true); }
public bool Decompile(IDecompileNodeContext context) { context.ContentTypeString = ContentTypes.PlainText; context.Output.Write(document.Text, BoxedTextColor.Text); return true; }
public bool Decompile(IDecompileNodeContext context) { context.Output.Write(file.Text, TextTokenKind.Text); return true; }
public bool Decompile(IDecompileNodeContext context) { context.ContentTypeString = Decompile(context.Output, context.DecompilationContext.CancellationToken); return(true); }
public bool Decompile(IDecompileNodeContext context) { context.ContentTypeString = context.Decompiler.ContentTypeString; var children = context.UIThread(() => { TreeNode.EnsureChildrenLoaded(); return TreeNode.DataChildren.OfType<HexNode>().ToArray(); }); context.Decompiler.WriteCommentLine(context.Output, dnSpy_AsmEditor_Resources.HexNode_PE); context.Decompiler.WriteCommentLine(context.Output, dnSpy_AsmEditor_Resources.NodesUseHexEditorMsg); foreach (HexNode node in children) { context.Decompiler.WriteCommentLine(context.Output, string.Empty); node.Decompile(context); } return true; }
public bool Decompile(IDecompileNodeContext context, IFileTreeNodeData node) { new NodeDecompiler(a => context.ExecuteInUIThread(() => a()), context.Output, context.Language, context.DecompilationContext, context).Decompile(node); return true; }