Beispiel #1
0
		static bool TextEditor_IsVisible(ContextMenuEntryContext context) {
			ModuleDef module;
			return context.Element is DecompilerTextView &&
				(module = GoToEntryPointCommand.GetModule()) != null &&
				module.GlobalType != null &&
				module.GlobalType.FindStaticConstructor() != null;
		}
Beispiel #2
0
 public override void Initialize(ContextMenuEntryContext context, MenuItem menuItem)
 {
     var tokRef = GetTokenReference(context);
     menuItem.Header = string.Format("Go to MD Table Row ({0:X8})", tokRef.Token);
     if (context.Element == MainWindow.Instance.treeView || context.Element is DecompilerTextView)
         menuItem.InputGestureText = "Shift+Alt+R";
 }
Beispiel #3
0
		static bool TreeView_IsVisible(ContextMenuEntryContext context) {
			ModuleDef module;
			return context.Element == MainWindow.Instance.treeView &&
				((module = ILSpyTreeNode.GetModule(context.SelectedTreeNodes)) != null) &&
				module.GlobalType != null &&
				module.GlobalType.FindStaticConstructor() != null;
		}
		public void Execute(ContextMenuEntryContext context) {
			if (context.SelectedTreeNodes != null) {
				foreach (var node in context.SelectedTreeNodes) {
					node.Parent.Children.Remove(node);
				}
			}
		}
Beispiel #5
0
		static ILSpyTreeNode GetTreeNode(ContextMenuEntryContext context) {
			if (context.Element is DecompilerTextView)
				return MainWindow.Instance.treeView.SelectedItem as ILSpyTreeNode;
			if (context.SelectedTreeNodes != null && context.SelectedTreeNodes.Length != 0)
				return context.SelectedTreeNodes[0] as ILSpyTreeNode;
			return null;
		}
		public bool IsVisible(ContextMenuEntryContext context) {
			if (context.SelectedTreeNodes != null)
				return context.SelectedTreeNodes.Length > 0 && context.SelectedTreeNodes.All(n => n is NamespaceTreeNode || n is IMemberTreeNode);

			if (context.Reference != null && context.Reference.Reference is IMemberRef)
				return IsPublic(context.Reference.Reference as IMemberRef);

			return false;
		}
Beispiel #7
0
		static MemoryModuleDefFile GetFile(ContextMenuEntryContext context) {
			var modNode = ILSpyTreeNode.GetNode<AssemblyTreeNode>(GetTreeNode(context));
			var mfile = modNode == null ? null : modNode.DnSpyFile as MemoryModuleDefFile;
			if (mfile == null)
				return null;
			if (mfile.Process.HasExited || mfile.Process.Debugger.ProcessState == DebuggerProcessState.Terminated)
				return null;
			return mfile;
		}
		public bool IsVisible(ContextMenuEntryContext context) {
			if (!CanExecute())
				return false;
			if (context.Element is DecompilerTextView)
				return true;
			if (context.SelectedTreeNodes == null || context.SelectedTreeNodes.Length == 0)
				return false;
			var elem = context.SelectedTreeNodes[0];
			return elem is ILSpyTreeNode || elem is AnalyzerTreeNode;
		}
		protected IMDTokenProvider GetReference(ContextMenuEntryContext context) {
			if (context.Reference != null)
				return context.Reference.Reference as IMDTokenProvider;
			if (context.SelectedTreeNodes != null && context.SelectedTreeNodes.Length != 0 &&
					context.SelectedTreeNodes[0] is ITokenTreeNode) {
				return ((ITokenTreeNode)context.SelectedTreeNodes[0]).MDTokenProvider;
			}

			return null;
		}
		public override void Execute(ContextMenuEntryContext context) {
			var obj = GetReference(context);
			if (obj != null) {
				var member = MainWindow.ResolveReference(obj);
				if (member == null)
					MainWindow.Instance.ShowMessageBox("Could not resolve member definition");
				else
					Execute(member);
			}
		}
Beispiel #11
0
		public void Execute(ContextMenuEntryContext context) {
			if (context.Element != MainWindow.Instance.treeView)
				return;
			var asms = new List<DnSpyFile>();
			foreach (var node in context.SelectedTreeNodes) {
				var file = GetDnSpyFile(node);
				if (file != null)
					asms.Add(file);
			}
			if (asms.Count > 0)
				MainWindow.Instance.DisableMemoryMappedIO(asms);
		}
		public bool IsEnabled(ContextMenuEntryContext context) {
			if (context.Element is AnalyzerTreeView && context.SelectedTreeNodes != null && context.SelectedTreeNodes.Length > 0 && context.SelectedTreeNodes.All(n => n.Parent.IsRoot))
				return false;
			if (context.SelectedTreeNodes == null)
				return context.Reference != null && MainWindow.ResolveReference(context.Reference.Reference) != null;
			foreach (var node in context.SelectedTreeNodes) {
				var mr = node as IMemberTreeNode;
				if (mr != null && CanAnalyze(mr.Member))
					return true;
			}
			return false;
		}
Beispiel #13
0
		public void Execute(ContextMenuEntryContext context) {
			if (context.Element != MainWindow.Instance.treeView)
				return;
			var asms = new List<LoadedAssembly>();
			foreach (var node in context.SelectedTreeNodes) {
				var loadedAsm = GetLoadedAssembly(node);
				if (loadedAsm != null)
					asms.Add(loadedAsm);
			}
			if (asms.Count > 0)
				MainWindow.Instance.DisableMemoryMappedIO(asms);
		}
		public void Execute(ContextMenuEntryContext context) {
			// Known problem: explorer can't show files in the .NET 2.0 GAC.
			var asmNode = (AssemblyTreeNode)context.SelectedTreeNodes[0];
			var filename = asmNode.LoadedAssembly.FileName;
			var args = string.Format("/select,{0}", filename);
			try {
				Process.Start(new ProcessStartInfo("explorer.exe", args));
			}
			catch (IOException) {
			}
			catch (Win32Exception) {
			}
		}
 public void Execute(ContextMenuEntryContext context)
 {
     if (context.SelectedTreeNodes != null) {
         foreach (var node in context.SelectedTreeNodes) {
             var mr = node as IMemberTreeNode;
             if (mr != null)
                 Analyze(mr.Member);
         }
     } else if (context.Reference != null && context.Reference.Reference is IMemberRef) {
         if (context.Reference.Reference is IMemberRef)
             Analyze((IMemberRef)context.Reference.Reference);
     }
 }
Beispiel #16
0
		public void Execute(ContextMenuEntryContext context)
		{
			if (context.SelectedTreeNodes == null)
				return;
			AssemblyTreeNode node = (AssemblyTreeNode)context.SelectedTreeNodes[0];
			var mod = node.LoadedAssembly.ModuleDefinition;
			if (mod != null) {
				SaveFileDialog dlg = new SaveFileDialog();
				dlg.FileName = node.LoadedAssembly.FileName;
				dlg.Filter = "Assembly|*.dll;*.exe";
				if (dlg.ShowDialog(MainWindow.Instance) == true) {
					mod.Write(dlg.FileName);
				}
			}
		}
Beispiel #17
0
        public void Execute(ContextMenuEntryContext context)
        {
            var list = GetMappings(context);
            if (list == null)
                return;

            var method = list[0].MemberMapping.MethodDefinition;
            var methodNode = MainWindow.Instance.AssemblyListTreeNode.FindMethodNode(method);
            if (methodNode == null) {
                MainWindow.Instance.ShowMessageBox(string.Format("Could not find method: {0}", method));
                return;
            }

            MethodBodySettingsCommand.Execute(new ILSpyTreeNode[] { methodNode }, GetInstructionOffsets(method, list));
        }
Beispiel #18
0
		public bool IsVisible(ContextMenuEntryContext context) {
			return GetFile(context) != null;
		}
Beispiel #19
0
		public bool IsEnabled(ContextMenuEntryContext context) {
			return IsVisible(context);
		}
Beispiel #20
0
		public void Execute(ContextMenuEntryContext context) {
			var file = GetFile(context);
			if (file != null)
				InMemoryModuleManager.Instance.UpdateModuleMemory(file);
		}
Beispiel #21
0
        internal LoadedAssembly GetCurrentExecutableAssembly(ContextMenuEntryContext context)
        {
            if (context == null)
                return null;
            if (IsDebugging)
                return null;

            SharpTreeNode node;
            if (context.Element is DecompilerTextView) {
                var tabState = MainWindow.Instance.GetActiveDecompileTabState();
                if (tabState == null)
                    return null;
                if (tabState.DecompiledNodes.Length == 0)
                    return null;
                node = tabState.DecompiledNodes[0];
            }
            else if (context.SelectedTreeNodes != null) {
                if (context.SelectedTreeNodes.Length == 0)
                    return null;
                node = context.SelectedTreeNodes[0];
            }
            else
                return null;

            return GetCurrentExecutableAssembly(node, true);
        }
		public override bool IsVisible(ContextMenuEntryContext context) {
			var obj = GetReference(context);
			return obj is IMemberRef && !(obj is IMemberDef);
		}
Beispiel #23
0
 public override void Execute(ContextMenuEntryContext context)
 {
     var @ref = GetAddressReference(context);
     if (@ref != null)
         MainWindow.Instance.GoToAddress(@ref);
 }
		public override bool IsVisible(ContextMenuEntryContext context) {
			return GetReference(context) != null;
		}
		public abstract void Execute(ContextMenuEntryContext context);
		public bool IsEnabled(ContextMenuEntryContext context) {
			return true;
		}
		public abstract bool IsVisible(ContextMenuEntryContext context);
		public override void Execute(ContextMenuEntryContext context) {
			var obj = GetReference(context);
			if (obj != null)
				Execute(obj);
		}
Beispiel #29
0
        static AddressReference GetAddressReference(ContextMenuEntryContext context)
        {
            if (context.SelectedTreeNodes == null || context.SelectedTreeNodes.Length != 1)
                return null;

            var rsrc = context.SelectedTreeNodes[0] as IResourceNode;
            if (rsrc != null && rsrc.FileOffset != 0) {
                var mod = ILSpyTreeNode.GetModule((ILSpyTreeNode)rsrc);
                if (mod != null && !string.IsNullOrEmpty(mod.Location))
                    return new AddressReference(mod.Location, false, rsrc.FileOffset, rsrc.Length);
            }

            return null;
        }
Beispiel #30
0
 internal static bool IsVisibleInternal(ContextMenuEntryContext context)
 {
     return GetTokenReference(context) != null;
 }