public override bool Rewrite(CodeDescriptor decompilee, MethodBase callee, StackElement[] args, IDecompiler stack, IFunctionBuilder builder)
        {
            if (args[0].Variability == Msil.EVariability.ExternVariable)
                throw new NotSupportedException("Delegate calls must have constant target!");

            Delegate deleg = (Delegate)args[0].Sample;
            if (deleg == null)
                return false;

            StackElement[] callArgs;
            if (deleg.Method.IsStatic)
            {
                callArgs = new StackElement[args.Length - 1];
                Array.Copy(args, 1, callArgs, 0, args.Length - 1);
            }
            else
            {
                callArgs = new StackElement[args.Length];
                Array.Copy(args, callArgs, args.Length);
                callArgs[0].Sample = deleg.Target;
                callArgs[0].Expr = LiteralReference.CreateConstant(deleg.Target);
                callArgs[0].Variability = Msil.EVariability.Constant;
            }
            stack.ImplementCall(deleg.Method, callArgs);
            return true;
        }
Example #2
0
		protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) {
			var tdr = TryGetTypeDefOrRef();
			if (tdr == null)
				output.Write(BoxedTextColor.Error, "???");
			else
				new NodePrinter().Write(output, decompiler, tdr, GetShowToken(options));
		}
		public void Setup()
		{
            mr = new MockRepository();
            form = new MainForm();
            sc = new ServiceContainer();
            loader = mr.StrictMock<ILoader>();
            dec = mr.StrictMock<IDecompiler>();
            sc = new ServiceContainer();
            uiSvc = new FakeShellUiService();
            host = mr.StrictMock<DecompilerHost>();
            memSvc = mr.StrictMock<ILowLevelViewService>();
            var image = new LoadedImage(Address.Ptr32(0x10000), new byte[1000]);
            var imageMap = image.CreateImageMap();
            var arch = mr.StrictMock<IProcessorArchitecture>();
            arch.Stub(a => a.CreateRegisterBitset()).Return(new BitSet(32));
            arch.Replay();
            var platform = mr.StrictMock<Platform>(null, arch);
            arch.BackToRecord();
            program = new Program(image, imageMap, arch, platform);
            project = new Project { Programs = { program } };

            browserSvc = mr.StrictMock<IProjectBrowserService>();

            sc.AddService<IDecompilerUIService>(uiSvc);
            sc.AddService(typeof(IDecompilerShellUiService), uiSvc);
            sc.AddService(typeof(IDecompilerService), new DecompilerService());
            sc.AddService(typeof(IWorkerDialogService), new FakeWorkerDialogService());
            sc.AddService(typeof(DecompilerEventListener), new FakeDecompilerEventListener());
            sc.AddService(typeof(IProjectBrowserService), browserSvc);
            sc.AddService(typeof(ILowLevelViewService), memSvc);
            sc.AddService<ILoader>(loader);

            i = new TestInitialPageInteractor(sc, dec);

		}
		public void Setup()
		{
            mr = new MockRepository();
            form = new MainForm();
            sc = new ServiceContainer();
            loader = mr.StrictMock<ILoader>();
            dec = mr.StrictMock<IDecompiler>();
            sc = new ServiceContainer();
            uiSvc = new FakeShellUiService();
            host = mr.StrictMock<DecompilerHost>();
            memSvc = mr.StrictMock<ILowLevelViewService>();
            var mem = new MemoryArea(Address.Ptr32(0x10000), new byte[1000]);
            var imageMap = new SegmentMap(
                mem.BaseAddress,
                new ImageSegment("code", mem, AccessMode.ReadWriteExecute));
            var arch = mr.StrictMock<IProcessorArchitecture>();
            var platform = mr.StrictMock<IPlatform>();
            program = new Program(imageMap, arch, platform);
            project = new Project { Programs = { program } };

            browserSvc = mr.StrictMock<IProjectBrowserService>();

            sc.AddService<IDecompilerUIService>(uiSvc);
            sc.AddService(typeof(IDecompilerShellUiService), uiSvc);
            sc.AddService(typeof(IDecompilerService), new DecompilerService());
            sc.AddService(typeof(IWorkerDialogService), new FakeWorkerDialogService());
            sc.AddService(typeof(DecompilerEventListener), new FakeDecompilerEventListener());
            sc.AddService(typeof(IProjectBrowserService), browserSvc);
            sc.AddService(typeof(ILowLevelViewService), memSvc);
            sc.AddService<ILoader>(loader);
            sc.AddService<DecompilerHost>(host);

            i = new TestInitialPageInteractor(sc, dec);

		}
Example #5
0
		static Guid CalculateLanguageGuid(IDecompiler decompiler) {
			if (decompiler.GenericGuid == DecompilerConstants.LANGUAGE_VISUALBASIC)
				return new Guid("F184B08F-C81C-45F6-A57F-5ABD9991F28F");

			Debug.Assert(decompiler.GenericGuid == DecompilerConstants.LANGUAGE_CSHARP);
			return new Guid("FAE04EC0-301F-11D3-BF4B-00C04F79EFBC");
		}
Example #6
0
		bool IsSupportedLanguage(IDecompiler decompiler, CompilationKind kind) {
			if (decompiler == null)
				return false;

			switch (kind) {
			case CompilationKind.Assembly:
				if (!decompiler.CanDecompile(DecompilationType.AssemblyInfo))
					return false;
				break;

			case CompilationKind.Method:
			case CompilationKind.EditClass:
				if (!decompiler.CanDecompile(DecompilationType.TypeMethods))
					return false;
				break;

			case CompilationKind.AddClass:
				break;

			default:
				throw new ArgumentOutOfRangeException(nameof(kind));
			}

			return languageCompilerProviders.Any(a => a.Language == decompiler.GenericGuid);
		}
		void Decompile(ModuleDef module, BamlDocument document, IDecompiler lang,
			IDecompilerOutput output, CancellationToken token) {
			var decompiler = new XamlDecompiler();
			var xaml = decompiler.Decompile(module, document, token, BamlDecompilerOptions.Create(lang), null);
			var xamlText = new XamlOutputCreator(xamlOutputOptionsProvider.Default).CreateText(xaml);
			documentWriterService.Write(output, xamlText, ContentTypes.Xaml);
		}
Example #8
0
		/// <summary>
		/// Writes a file
		/// </summary>
		/// <param name="output">Output</param>
		/// <param name="decompiler">Decompiler</param>
		/// <param name="document">Document</param>
		public void Write(ITextColorWriter output, IDecompiler decompiler, IDsDocument document) {
			var filename = GetFilename(document);
			var peImage = document.PEImage;
			if (peImage != null)
				output.Write(IsExe(peImage) ? BoxedTextColor.AssemblyExe : BoxedTextColor.Assembly, NameUtilities.CleanName(filename));
			else
				output.Write(BoxedTextColor.Text, NameUtilities.CleanName(filename));
		}
Example #9
0
		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 AppBamlResourceProjectFile(string filename, TypeDef type, IDecompiler decompiler) {
			Filename = filename;
			this.type = type;
			SubType = "Designer";
			Generator = "MSBuild:Compile";
			BuildAction = DotNetUtils.IsStartUpClass(type) ? BuildAction.ApplicationDefinition : BuildAction.Page;
			this.decompiler = decompiler;
		}
Example #11
0
		NodeTabSaver(IMessageBoxService messageBoxService, IDocumentTab tab, IDocumentTreeNodeDecompiler documentTreeNodeDecompiler, IDecompiler decompiler, IDocumentViewer documentViewer, DocumentTreeNodeData[] nodes) {
			this.messageBoxService = messageBoxService;
			this.tab = tab;
			this.documentTreeNodeDecompiler = documentTreeNodeDecompiler;
			this.decompiler = decompiler;
			this.documentViewer = documentViewer;
			this.nodes = nodes;
		}
Example #12
0
		protected virtual void DecompileFields(IDecompiler decompiler, IDecompilerOutput output) {
			foreach (var vm in HexVMs) {
				decompiler.WriteCommentLine(output, string.Empty);
				decompiler.WriteCommentLine(output, string.Format("{0}:", vm.Name));
				foreach (var field in vm.HexFields)
					decompiler.WriteCommentLine(output, string.Format("{0:X8} - {1:X8} {2} = {3}", field.Span.Start.ToUInt64(), field.Span.End.ToUInt64() - 1, field.FormattedValue, field.Name));
			}
		}
		public override void WriteShort(IDecompilerOutput output, IDecompiler decompiler, bool showOffset) {
			base.WriteShort(output, decompiler, showOffset);
			var documentViewerOutput = output as IDocumentViewerOutput;
			if (documentViewerOutput != null) {
				documentViewerOutput.AddButton(dnSpy_Resources.SaveResourceButton, () => Save());
				documentViewerOutput.WriteLine();
				documentViewerOutput.WriteLine();
			}
		}
Example #14
0
		public EditClassVM(IRawModuleBytesProvider rawModuleBytesProvider, IOpenFromGAC openFromGAC, IOpenAssembly openAssembly, ILanguageCompiler languageCompiler, IDecompiler decompiler, IMemberDef defToEdit, IList<MethodSourceStatement> statementsInMethodToEdit)
			: base(rawModuleBytesProvider, openFromGAC, openAssembly, languageCompiler, decompiler, defToEdit.Module) {
			this.defToEdit = defToEdit;
			nonNestedTypeToEdit = defToEdit as TypeDef ?? defToEdit.DeclaringType;
			while (nonNestedTypeToEdit.DeclaringType != null)
				nonNestedTypeToEdit = nonNestedTypeToEdit.DeclaringType;
			methodSourceStatement = statementsInMethodToEdit.Count == 0 ? (MethodSourceStatement?)null : statementsInMethodToEdit[0];
			StartDecompile();
		}
Example #15
0
		protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) {
			if ((options & DocumentNodeWriteOptions.ToolTip) == 0)
				new NodePrinter().Write(output, decompiler, Document);
			else {
				output.Write(BoxedTextColor.Text, TargetFrameworkUtils.GetArchString(Document.PEImage.ImageNTHeaders.FileHeader.Machine));

				output.WriteLine();
				output.WriteFilename(Document.Filename);
			}
		}
Example #16
0
		protected override void Write(ITextColorWriter output, IDecompiler decompiler) {
			if (hidesParent) {
				output.Write(BoxedTextColor.Punctuation, "(");
				output.Write(BoxedTextColor.Text, dnSpy_Analyzer_Resources.HidesParent);
				output.Write(BoxedTextColor.Punctuation, ")");
				output.WriteSpace();
			}
			decompiler.WriteType(output, analyzedProperty.DeclaringType, true);
			output.Write(BoxedTextColor.Operator, ".");
			new NodePrinter().Write(output, decompiler, analyzedProperty, Context.ShowToken, null);
		}
		public override void WriteShort(IDecompilerOutput output, IDecompiler decompiler, bool showOffset) {
			var documentViewerOutput = output as IDocumentViewerOutput;
			if (documentViewerOutput != null) {
				documentViewerOutput.AddUIElement(() => {
					return new System.Windows.Controls.Image {
						Source = ImageSource,
					};
				});
			}

			base.WriteShort(output, decompiler, showOffset);
		}
Example #18
0
        public override bool Rewrite(CodeDescriptor decompilee, MethodBase callee, StackElement[] args, IDecompiler stack, IFunctionBuilder builder)
        {
            var side = args[0].Sample as IXilinxBlockMemSide;
            if (side == null)
                return false;

            var code = IntrinsicFunctions.XILOpCode(
                DefaultInstructionSet.Instance.WrMem(side),
                typeof(void));
            builder.Call(code.Callee, args[1].Expr, args[2].Expr);
            return true;
        }
Example #19
0
        public override bool Rewrite(CodeDescriptor decompilee, MethodBase callee, StackElement[] args, IDecompiler stack, IFunctionBuilder builder)
        {
            var side = args[0].Sample as IXilinxBlockMemSide;
            if (side == null)
                return false;

            var sample = StdLogicVector._0s(side.DataReadWidth);
            var code = IntrinsicFunctions.XILOpCode(
                DefaultInstructionSet.Instance.RdMem(side),
                TypeDescriptor.GetTypeOf(sample),
                args[1].Expr);
            stack.Push(code, sample);
            return true;
        }
Example #20
0
		protected override void DecompileFields(IDecompiler decompiler, IDecompilerOutput output) {
			decompiler.WriteCommentLine(output, string.Empty);
			decompiler.WriteCommentBegin(output, true);
			WriteHeader(output);
			decompiler.WriteCommentEnd(output, true);
			output.WriteLine();

			for (int i = 0; i < (int)MetaDataTableVM.Rows; i++) {
				var obj = MetaDataTableVM.Get(i);
				decompiler.WriteCommentBegin(output, true);
				Write(output, obj);
				decompiler.WriteCommentEnd(output, true);
				output.WriteLine();
			}
		}
Example #21
0
		public ProjectModuleOptions(ModuleDef module, IDecompiler decompiler, DecompilationContext decompilationContext) {
			if (decompiler == null)
				throw new ArgumentNullException(nameof(decompiler));
			if (decompilationContext == null)
				throw new ArgumentNullException(nameof(decompilationContext));
			if (module == null)
				throw new ArgumentNullException(nameof(module));
			Module = module;
			Decompiler = decompiler;
			DecompilationContext = decompilationContext;
			ProjectGuid = Guid.NewGuid();
			UnpackResources = true;
			CreateResX = true;
			DecompileXaml = true;
		}
		protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) {
			if ((options & DocumentNodeWriteOptions.ToolTip) == 0)
				new NodePrinter().Write(output, decompiler, Document.AssemblyDef, false, Context.ShowAssemblyVersion, Context.ShowAssemblyPublicKeyToken);
			else {
				output.Write(Document.AssemblyDef);

				output.WriteLine();
				output.Write(BoxedTextColor.Text, TargetFrameworkInfo.Create(Document.AssemblyDef.ManifestModule).ToString());

				output.WriteLine();
				output.Write(BoxedTextColor.Text, TargetFrameworkUtils.GetArchString(Document.AssemblyDef.ManifestModule));

				output.WriteLine();
				output.WriteFilename(Document.Filename);
			}
		}
		protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) {
			if ((options & DocumentNodeWriteOptions.ToolTip) == 0)
				new NodePrinter().Write(output, decompiler, Document.ModuleDef, false);
			else {
				output.WriteModule(Document.ModuleDef.Name);

				output.WriteLine();
				output.Write(BoxedTextColor.Text, TargetFrameworkInfo.Create(Document.ModuleDef).ToString());

				output.WriteLine();
				output.Write(BoxedTextColor.Text, TargetFrameworkUtils.GetArchString(Document.ModuleDef));

				output.WriteLine();
				output.WriteFilename(Document.Filename);
			}
		}
Example #24
0
 public void Setup()
 {
     mr = new MockRepository();
     codeViewer = new CodeViewerPane();
     decompilerSvc = mr.Stub<IDecompilerService>();
     decompiler = mr.Stub<IDecompiler>();
     uiPreferencesSvc = mr.Stub<IUiPreferencesService>();
     uiSvc = mr.Stub<IDecompilerShellUiService>();
     font = new Font("Arial", 10);
     var sc = new ServiceContainer();
     decompilerSvc.Decompiler = decompiler;
     sc.AddService<IDecompilerService>(decompilerSvc);
     sc.AddService<IUiPreferencesService>(uiPreferencesSvc);
     sc.AddService<IDecompilerShellUiService>(uiSvc);
     codeViewer.SetSite(sc);
 }
		public ToolTipProviderContext(IDotNetImageService dotNetImageService, IDecompiler decompiler, ICodeToolTipSettings codeToolTipSettings, IDocumentViewer documentViewer, IClassificationFormatMap classificationFormatMap, IThemeClassificationTypeService themeClassificationTypeService) {
			if (dotNetImageService == null)
				throw new ArgumentNullException(nameof(dotNetImageService));
			if (decompiler == null)
				throw new ArgumentNullException(nameof(decompiler));
			if (codeToolTipSettings == null)
				throw new ArgumentNullException(nameof(codeToolTipSettings));
			if (documentViewer == null)
				throw new ArgumentNullException(nameof(documentViewer));
			if (classificationFormatMap == null)
				throw new ArgumentNullException(nameof(classificationFormatMap));
			if (themeClassificationTypeService == null)
				throw new ArgumentNullException(nameof(themeClassificationTypeService));
			DocumentViewer = documentViewer;
			this.dotNetImageService = dotNetImageService;
			Decompiler = decompiler;
			this.codeToolTipSettings = codeToolTipSettings;
			this.classificationFormatMap = classificationFormatMap;
			this.themeClassificationTypeService = themeClassificationTypeService;
		}
Example #26
0
		/// <summary>
		/// Writes an assembly
		/// </summary>
		/// <param name="output">Output</param>
		/// <param name="decompiler">Decompiler</param>
		/// <param name="asm">Assembly</param>
		/// <param name="showToken">true to write tokens</param>
		/// <param name="showAssemblyVersion">true to write version</param>
		/// <param name="showAssemblyPublicKeyToken">true to write public key token</param>
		public void Write(ITextColorWriter output, IDecompiler decompiler, AssemblyDef asm, bool showToken, bool showAssemblyVersion, bool showAssemblyPublicKeyToken) {
			output.Write(IsExe(asm.ManifestModule) ? BoxedTextColor.AssemblyExe : BoxedTextColor.Assembly, asm.Name);

			bool showAsmVer = showAssemblyVersion;
			bool showPublicKeyToken = showAssemblyPublicKeyToken && !PublicKeyBase.IsNullOrEmpty2(asm.PublicKeyToken);

			if (showAsmVer || showPublicKeyToken) {
				output.WriteSpace();
				output.Write(BoxedTextColor.Punctuation, "(");

				bool needComma = false;
				if (showAsmVer) {
					if (needComma)
						output.WriteCommaSpace();
					needComma = true;

					output.Write(asm.Version);
				}

				if (showPublicKeyToken) {
					if (needComma)
						output.WriteCommaSpace();
					needComma = true;

					var pkt = asm.PublicKeyToken;
					if (PublicKeyBase.IsNullOrEmpty2(pkt))
						output.Write(BoxedTextColor.Keyword, "null");
					else
						output.Write(BoxedTextColor.Number, pkt.ToString());
				}

				output.Write(BoxedTextColor.Punctuation, ")");
			}

			WriteToken(output, asm, showToken);
		}
Example #27
0
        public void Setup()
        {
            mr = new MockRepository();
            mockFactory = new MockFactory(mr);
            var platform = mockFactory.CreatePlatform(); ;

            program = new Program
            {
                Architecture = platform.Architecture,
                Platform = platform,
            };
            codeViewer = new CodeViewerPane();
            decompilerSvc = mr.Stub<IDecompilerService>();
            decompiler = mr.Stub<IDecompiler>();
            uiPreferencesSvc = mr.Stub<IUiPreferencesService>();
            uiSvc = mr.Stub<IDecompilerShellUiService>();
            frame = mr.Stub<IWindowFrame>();
            font = new Font("Arial", 10);
            var styles = new Dictionary<string, UiStyle>()
            {
                {
                    UiStyles.CodeWindow,
                    new UiStyle
                    {
                        Background = new SolidBrush(Color.White),
                    }
                }
            };
            uiPreferencesSvc.Stub(u => u.Styles).Return(styles);
            var sc = new ServiceContainer();
            decompilerSvc.Decompiler = decompiler;
            sc.AddService<IDecompilerService>(decompilerSvc);
            sc.AddService<IUiPreferencesService>(uiPreferencesSvc);
            sc.AddService<IDecompilerShellUiService>(uiSvc);
            codeViewer.SetSite(sc);
        }
Example #28
0
 NodeTabSaver(IMessageBoxService messageBoxService, IDocumentTab tab, IDocumentTreeNodeDecompiler documentTreeNodeDecompiler, IDecompiler decompiler, IDocumentViewer documentViewer, DocumentTreeNodeData[] nodes)
 {
     this.messageBoxService = messageBoxService;
     this.tab = tab;
     this.documentTreeNodeDecompiler = documentTreeNodeDecompiler;
     this.decompiler     = decompiler;
     this.documentViewer = documentViewer;
     this.nodes          = nodes;
 }
Example #29
0
		protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) => WriteCore(output, options);
Example #30
0
		protected override void Write(ITextColorWriter output, IDecompiler decompiler) =>
			output.WriteFilename(Path.GetFileName(document.Filename));
Example #31
0
 protected abstract void Write(ITextColorWriter output, IDecompiler decompiler);
 public abstract MethodDebugInfoResult GetMethodDebugInfo(DbgRuntime runtime, IDecompiler decompiler, IDbgDotNetCodeLocation location, CancellationToken cancellationToken);
Example #33
0
 protected override void Write(ITextColorWriter output, IDecompiler decompiler) =>
 output.Write(BoxedTextColor.AssemblyModule, NameUtilities.CleanIdentifier(module.Name));
Example #34
0
 /// <summary>
 /// Writes the contents
 /// </summary>
 /// <param name="output">Output</param>
 /// <param name="decompiler">Decompiler</param>
 /// <param name="options">Options</param>
 public void Write(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) =>
 WriteCore(output, decompiler, options);
 protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) =>
 output.Write(BoxedTextColor.Text, "Assembly Child");
Example #36
0
 protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options)
 {
 }
Example #37
0
 protected override void Write(ITextColorWriter output, IDecompiler decompiler) =>
 output.Write(BoxedTextColor.Text, dnSpy_Analyzer_Resources.OverriddenByTreeNode);
Example #38
0
 public TestInitialPageInteractor(IServiceProvider services, IDecompiler decompiler) : base(services)
 {
     this.decompiler = decompiler;
 }
Example #39
0
 /// <inheritdoc/>
 protected sealed override void Write(ITextColorWriter output, IDecompiler decompiler) =>
 output.WriteFilename(resourceElement.Name);
Example #40
0
 protected override void Write(ITextColorWriter output, IDecompiler decompiler) =>
 new NodePrinter().Write(output, decompiler, analyzedType, Context.ShowToken);
		protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) =>
			new NodePrinter().Write(output, decompiler, ModuleRef, GetShowToken(options));
Example #42
0
 /// <summary>
 /// Writes the contents
 /// </summary>
 /// <param name="output">Output</param>
 /// <param name="decompiler">Decompiler</param>
 /// <param name="options">Options</param>
 protected abstract void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options);
Example #43
0
        public EditCodeVM(IImageManager imageManager, IOpenFromGAC openFromGAC, IOpenAssembly openAssembly, ILanguageCompiler languageCompiler, IDecompiler decompiler, MethodDef methodToEdit, IList <MethodSourceStatement> statementsInMethodToEdit)
        {
            Debug.Assert(decompiler.CanDecompile(DecompilationType.TypeMethods));
            this.imageManager     = imageManager;
            this.openFromGAC      = openFromGAC;
            this.openAssembly     = openAssembly;
            this.languageCompiler = languageCompiler;
            this.decompiler       = decompiler;
            this.methodToEdit     = methodToEdit;
            var methodSourceStatement = statementsInMethodToEdit.Count == 0 ? (MethodSourceStatement?)null : statementsInMethodToEdit[0];

            this.assemblyReferenceResolver = new AssemblyReferenceResolver(methodToEdit.Module.Context.AssemblyResolver, methodToEdit.Module, makeEverythingPublic);
            StartDecompileAsync(methodToEdit, methodSourceStatement).ContinueWith(t => {
                var ex = t.Exception;
                Debug.Assert(ex == null);
            }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
        }
Example #44
0
 static void Analyze(IDsToolWindowService toolWindowService, Lazy <IAnalyzerService> analyzerService, IDecompiler decompiler, IEnumerable <IMemberRef?> mrs)
 {
     foreach (var mr in mrs)
     {
         Analyze(toolWindowService, analyzerService, decompiler, mr);
     }
 }
 protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) =>
 output.Write(BoxedTextColor.Comment, Message);
Example #46
0
        public static void Analyze(IDsToolWindowService toolWindowService, Lazy <IAnalyzerService> analyzerService, IDecompiler decompiler, IMemberRef?member)
        {
            var memberDef = ResolveReference(member);

            if (memberDef is TypeDef type)
            {
                toolWindowService.Show(AnalyzerToolWindowContent.THE_GUID);
                analyzerService.Value.Add(new TypeNode(type));
            }

            if (memberDef is FieldDef field)
            {
                toolWindowService.Show(AnalyzerToolWindowContent.THE_GUID);
                analyzerService.Value.Add(new FieldNode(field));
            }

            if (memberDef is MethodDef method)
            {
                toolWindowService.Show(AnalyzerToolWindowContent.THE_GUID);
                analyzerService.Value.Add(new MethodNode(method));
            }

            var propertyAnalyzer = PropertyNode.TryCreateAnalyzer(member, decompiler);

            if (propertyAnalyzer is not null)
            {
                toolWindowService.Show(AnalyzerToolWindowContent.THE_GUID);
                analyzerService.Value.Add(propertyAnalyzer);
            }

            var eventAnalyzer = EventNode.TryCreateAnalyzer(member, decompiler);

            if (eventAnalyzer is not null)
            {
                toolWindowService.Show(AnalyzerToolWindowContent.THE_GUID);
                analyzerService.Value.Add(eventAnalyzer);
            }
        }
 public abstract MethodDebugInfoResult GetMethodDebugInfo(IDecompiler decompiler, DbgModule module, uint token, CancellationToken cancellationToken);
Example #48
0
 /// <inheritdoc/>
 protected sealed override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) =>
 output.WriteFilename(resourceElement.Name);
Example #49
0
 protected override void Write(ITextColorWriter output, IDecompiler decompiler) =>
 output.Write(BoxedTextColor.Text, showWrites ? dnSpy_Analyzer_Resources.AssignedByTreeNode : dnSpy_Analyzer_Resources.ReadByTreeNode);
Example #50
0
 protected override void Write(ITextColorWriter output, IDecompiler decompiler)
 {
 }
Example #51
0
 public Key(IDecompiler decompiler, IDocumentTreeNodeData[] nodes, DecompilerSettingsBase settings)
 {
     this.Decompiler = decompiler;
     this.Nodes      = new List <IDocumentTreeNodeData>(nodes).ToArray();
     this.Settings   = settings.Clone();
 }
Example #52
0
 public DecompileDocumentTabContent(DecompileDocumentTabContentFactory decompileDocumentTabContentFactory, DocumentTreeNodeData[] nodes, IDecompiler decompiler, DecompilerTabContentContext context)
 {
     this.decompileDocumentTabContentFactory = decompileDocumentTabContentFactory;
     this.nodes   = nodes;
     Decompiler   = decompiler;
     this.context = context;
 }
Example #53
0
 public TypeProjectFile(TypeDef type, string filename, DecompilationContext decompilationContext, IDecompiler decompiler, Func <TextWriter, IDecompilerOutput> createDecompilerOutput)
 {
     Type                        = type;
     this.filename               = filename;
     this.decompilationContext   = decompilationContext;
     this.decompiler             = decompiler;
     this.createDecompilerOutput = createDecompilerOutput;
 }
Example #54
0
 protected override void WriteCore(ITextColorWriter output, IDecompiler decompiler, DocumentNodeWriteOptions options) =>
 output.Write(BoxedTextColor.Text, dnSpy_Resources.DerivedTypes);
 public AssemblyInfoProjectFile(ModuleDef module, string filename, DecompilationContext decompilationContext, IDecompiler decompiler, Func <TextWriter, IDecompilerOutput> createDecompilerOutput)
 {
     this.module = module;
     Filename    = filename;
     this.decompilationContext   = decompilationContext;
     this.decompiler             = decompiler;
     this.createDecompilerOutput = createDecompilerOutput;
 }
Example #56
0
 public XamlTypeProjectFile(TypeDef type, string filename, DecompilationContext decompilationContext, IDecompiler decompiler, Func <TextWriter, IDecompilerOutput> createDecompilerOutput)
     : base(type, filename, decompilationContext, decompiler, createDecompilerOutput)
 {
 }
Example #57
0
		public ExportToProjectVM(IPickDirectory pickDirectory, IDecompilerService decompilerService, IExportTask exportTask, bool canDecompileBaml) {
			this.pickDirectory = pickDirectory;
			this.decompilerService = decompilerService;
			this.exportTask = exportTask;
			this.canDecompileBaml = canDecompileBaml;
			unpackResources = true;
			createResX = true;
			decompileXaml = canDecompileBaml;
			createSolution = true;
			ProjectVersionVM.SelectedItem = ProjectVersion.VS2010;
			decompiler = decompilerService.AllDecompilers.FirstOrDefault(a => a.ProjectFileExtension != null);
			isIndeterminate = false;
			ProjectGuid = new NullableGuidVM(Guid.NewGuid(), a => HasErrorUpdated());
		}
Example #58
0
 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 DecompileDocumentTabContent(DecompileDocumentTabContentFactory decompileDocumentTabContentFactory, DocumentTreeNodeData[] nodes, IDecompiler decompiler)
 {
     this.decompileDocumentTabContentFactory = decompileDocumentTabContentFactory;
     this.nodes = nodes;
     Decompiler = decompiler;
 }
Example #60
0
 /// <inheritdoc/>
 protected sealed override void WriteToolTip(ITextColorWriter output, IDecompiler decompiler) =>
 base.WriteToolTip(output, decompiler);