Esempio n. 1
0
        internal static AddrRange?GetValue(LocalsCtxMenuContext context)
        {
            var value = SaveDataLocalsCtxMenuCommand.GetValue(context);

            if (value == null)
            {
                return(null);
            }

            if (value.IsArray)
            {
                if (value.ArrayCount == 0)
                {
                    return(new AddrRange(value.Address, 0));
                }

                var   elemValue = value.GetElementAtPosition(0);
                ulong elemSize  = elemValue?.Size ?? 0;
                ulong elemAddr  = elemValue?.Address ?? 0;
                ulong addr      = value.Address;
                ulong totalSize = elemSize * value.ArrayCount;
                if (elemAddr == 0 || elemAddr < addr || elemAddr - addr > int.MaxValue || totalSize > int.MaxValue)
                {
                    return(null);
                }

                ulong dataIndex = elemAddr - addr;
                return(new AddrRange(value.Address + dataIndex, totalSize));
            }

            return(new AddrRange(value.Address, value.Size));
        }
Esempio n. 2
0
        protected override void Execute(LocalsCtxMenuContext context)
        {
            var output = new PlainTextOutput();

            foreach (var vm in context.SelectedItems)
            {
                //TODO: Break if it takes too long and the user cancels
                var printer = new ValuePrinter(output, DebuggerSettings.Instance.UseHexadecimal);
                printer.WriteExpander(vm);
                output.Write('\t', TextTokenType.Text);
                // Add an extra here to emulate VS output
                output.Write('\t', TextTokenType.Text);
                printer.WriteName(vm);
                output.Write('\t', TextTokenType.Text);
                printer.WriteValue(vm);
                output.Write('\t', TextTokenType.Text);
                printer.WriteType(vm);
                output.WriteLine();
            }
            var s = output.ToString();

            if (s.Length > 0)
            {
                Clipboard.SetText(s);
            }
        }
Esempio n. 3
0
 public override void Execute(LocalsCtxMenuContext context)
 {
     if (IsEnabled(context))
     {
         context.SelectedItems[0].IsEditingValue = true;
     }
 }
Esempio n. 4
0
		protected override void Execute(LocalsCtxMenuContext context) {
			var vm = GetLocalParent(context);
			if (vm != null) {
				foreach (var child in vm.Children)
					child.IsExpanded = false;
			}
		}
Esempio n. 5
0
		static CorValue GetValue(LocalsCtxMenuContext context) {
			if (context.SelectedItems.Length != 1)
				return null;
			var nv = context.SelectedItems[0] as NormalValueVM;
			var value = nv == null ? null : nv.ReadOnlyCorValue;
			if (value == null)
				return null;
			for (int i = 0; i < 2; i++) {
				if (!value.IsReference)
					break;
				if (value.IsNull)
					return null;
				if (value.Type == CorElementType.Ptr || value.Type == CorElementType.FnPtr)
					return null;
				value = value.NeuterCheckDereferencedValue;
				if (value == null)
					return null;
			}
			if (value.IsReference)
				return null;
			if (value.IsBox) {
				value = value.BoxedValue;
				if (value == null)
					return null;
			}
			return value;
		}
Esempio n. 6
0
        public override void Execute(LocalsCtxMenuContext context)
        {
            var output = new StringBuilderTextColorOutput();

            foreach (var vm in context.SelectedItems)
            {
                //TODO: Break if it takes too long and the user cancels
                var printer = new ValuePrinter(output, debuggerSettings.UseHexadecimal);
                printer.WriteExpander(vm);
                output.Write(BoxedTextColor.Text, "\t");
                // Add an extra here to emulate VS output
                output.Write(BoxedTextColor.Text, "\t");
                printer.WriteName(vm);
                output.Write(BoxedTextColor.Text, "\t");
                printer.WriteValue(vm);
                output.Write(BoxedTextColor.Text, "\t");
                printer.WriteType(vm);
                output.WriteLine();
            }
            var s = output.ToString();

            if (s.Length > 0)
            {
                try {
                    Clipboard.SetText(s);
                }
                catch (ExternalException) { }
            }
        }
Esempio n. 7
0
		protected override bool IsEnabled(LocalsCtxMenuContext context) {
			var p = GetLocalParent(context);
			if (p == null)
				return false;
			if (!p.IsExpanded)
				return false;
			return p.Children.Any(c => c.IsExpanded);
		}
Esempio n. 8
0
		static ValueVM GetLocalParent(LocalsCtxMenuContext context) {
			if (context.SelectedItems.Length == 0)
				return null;
			var vm = context.SelectedItems[0];
			if (vm.LazyLoading)
				return vm;
			return vm.Children.Count == 0 ? null : vm;
		}
Esempio n. 9
0
 static ValueVM GetLocalParent(LocalsCtxMenuContext context)
 {
     if (context.SelectedItems.Length == 0)
     {
         return(null);
     }
     return(context.SelectedItems[0].Parent as ValueVM);
 }
Esempio n. 10
0
        public override void Execute(LocalsCtxMenuContext context)
        {
            var addrRange = ShowInMemoryWindowLocalsCtxMenuCommand.GetValue(context);

            if (addrRange != null)
            {
                memoryWindowManager.Show(addrRange.Value.Address, addrRange.Value.Size);
            }
        }
Esempio n. 11
0
        protected override void Execute(LocalsCtxMenuContext context)
        {
            var addrRange = GetValue(context);

            if (addrRange != null)
            {
                MemoryUtils.ShowInMemoryWindow(windowNumber, addrRange.Value.Address, addrRange.Value.Size);
            }
        }
Esempio n. 12
0
        public override void Execute(LocalsCtxMenuContext context)
        {
            var vm = GetValueVM(context);

            if (vm != null)
            {
                vm.IsExpanded = !vm.IsExpanded;
            }
        }
Esempio n. 13
0
        public override void Execute(LocalsCtxMenuContext context)
        {
            var addrRange = ShowInMemoryWindowLocalsCtxMenuCommand.GetValue(context);

            if (addrRange != null)
            {
                memoryWindowService.Show(addrRange.Value);
            }
        }
Esempio n. 14
0
        public override void Execute(LocalsCtxMenuContext context)
        {
            var vm = GetLocalParent(context);

            if (vm != null)
            {
                vm.IsExpanded = false;
            }
        }
Esempio n. 15
0
        public override void Execute(LocalsCtxMenuContext context)
        {
            var addrRange = GetValue(context);

            if (addrRange != null)
            {
                memoryWindowService.Show(addrRange.Value.Address, addrRange.Value.Size, windowIndex);
            }
        }
Esempio n. 16
0
		protected override void Execute(LocalsCtxMenuContext context) {
			var vm = GetLocalParent(context);
			if (vm != null) {
				vm.IsExpanded = true;
				foreach (ValueVM child in vm.Children) {
					if (CanExpand(child))
						child.IsExpanded = true;
				}
			}
		}
Esempio n. 17
0
		static ValueVM GetValueVM(LocalsCtxMenuContext context) {
			if (context.SelectedItems.Length != 1)
				return null;
			var vm = context.SelectedItems[0];
			if (vm.LazyLoading)
				return vm;
			if (vm.Children.Count > 0)
				return vm;
			return null;
		}
Esempio n. 18
0
        static ValueVM GetLocalParent(LocalsCtxMenuContext context)
        {
            if (context.SelectedItems.Length == 0)
            {
                return(null);
            }
            var vm = context.SelectedItems[0];

            return(vm.Children.Count == 0 ? null : vm);
        }
Esempio n. 19
0
		protected override void Execute(LocalsCtxMenuContext context) {
			var value = GetValue(context);
			if (value == null)
				return;

			var filename = new PickSaveFilename().GetFilename(string.Empty, "bin", null);
			if (string.IsNullOrEmpty(filename))
				return;

			byte[] data;
			int? dataIndex = null, dataSize = null;
			if (value.IsString) {
				var s = value.String;
				data = s == null ? null : Encoding.Unicode.GetBytes(s);
			}
			else if (value.IsArray) {
				if (value.ArrayCount == 0)
					data = new byte[0];
				else {
					var elemValue = value.GetElementAtPosition(0);
					ulong elemSize = elemValue == null ? 0 : elemValue.Size;
					ulong elemAddr = elemValue == null ? 0 : elemValue.Address;
					ulong addr = value.Address;
					ulong totalSize = elemSize * value.ArrayCount;
					if (elemAddr == 0 || elemAddr < addr || elemAddr - addr > int.MaxValue || totalSize > int.MaxValue) {
						MainWindow.Instance.ShowMessageBox("Could not get array data");
						return;
					}
					data = value.ReadGenericValue();
					dataIndex = (int)(elemAddr - addr);
					dataSize = (int)totalSize;
				}
			}
			else
				data = value.ReadGenericValue();
			if (data == null) {
				MainWindow.Instance.ShowMessageBox("Could not read any data");
				return;
			}

			try {
				if (dataIndex == null)
					dataIndex = 0;
				if (dataSize == null)
					dataSize = data.Length - dataIndex.Value;
				using (var file = File.Create(filename))
					file.Write(data, dataIndex.Value, dataSize.Value);
			}
			catch (Exception ex) {
				MainWindow.Instance.ShowMessageBox(string.Format("Error saving data to '{0}'\nERROR: {1}", filename, ex.Message));
				return;
			}
		}
Esempio n. 20
0
		protected override void Execute(LocalsCtxMenuContext context) {
			var output = new PlainTextOutput();
			foreach (var vm in context.SelectedItems) {
				//TODO: Break if it takes too long and the user cancels
				var printer = new ValuePrinter(output, DebuggerSettings.Instance.UseHexadecimal);
				printer.WriteValue(vm);
				if (context.SelectedItems.Length > 1)
					output.WriteLine();
			}
			var s = output.ToString();
			if (s.Length > 0)
				Clipboard.SetText(s);
		}
Esempio n. 21
0
        public override bool IsEnabled(LocalsCtxMenuContext context)
        {
            var p = GetLocalParent(context);

            if (p == null)
            {
                return(false);
            }
            if (!p.IsExpanded)
            {
                return(false);
            }
            return(p.Children.Any(c => c.IsExpanded));
        }
Esempio n. 22
0
        protected override bool IsEnabled(LocalsCtxMenuContext context)
        {
            var p = GetLocalParent(context);

            if (p == null)
            {
                return(false);
            }
            if (!p.IsExpanded)
            {
                return(true);
            }
            return(p.Children.Any(c => CanExpand((ValueVM)c)));
        }
Esempio n. 23
0
 protected override void Initialize(LocalsCtxMenuContext context, MenuItem menuItem)
 {
     foreach (var tuple in subCmds)
     {
         var mi = new MenuItem {
             Command = tuple.Item1,
             Header  = tuple.Item2,
         };
         if (!string.IsNullOrEmpty(tuple.Item3))
         {
             mi.InputGestureText = tuple.Item3;
         }
         MainWindow.CreateMenuItemImage(mi, this, "MemoryWindow", BackgroundType.ContextMenuItem);
         menuItem.Items.Add(mi);
     }
 }
Esempio n. 24
0
        internal static CorValue GetValue(LocalsCtxMenuContext context)
        {
            if (context.SelectedItems.Length != 1)
            {
                return(null);
            }
            var nv    = context.SelectedItems[0] as NormalValueVM;
            var value = nv?.ReadOnlyCorValue;

            if (value == null)
            {
                return(null);
            }
            for (int i = 0; i < 2; i++)
            {
                if (!value.IsReference)
                {
                    break;
                }
                if (value.IsNull)
                {
                    return(null);
                }
                if (value.ElementType == CorElementType.Ptr || value.ElementType == CorElementType.FnPtr)
                {
                    return(null);
                }
                value = value.NeuterCheckDereferencedValue;
                if (value == null)
                {
                    return(null);
                }
            }
            if (value.IsReference)
            {
                return(null);
            }
            if (value.IsBox)
            {
                value = value.BoxedValue;
                if (value == null)
                {
                    return(null);
                }
            }
            return(value);
        }
Esempio n. 25
0
        static ValueVM GetValueVM(LocalsCtxMenuContext context)
        {
            if (context.SelectedItems.Length != 1)
            {
                return(null);
            }
            var vm = context.SelectedItems[0];

            if (vm.LazyLoading)
            {
                return(vm);
            }
            if (vm.Children.Count > 0)
            {
                return(vm);
            }
            return(null);
        }
Esempio n. 26
0
        public override void Execute(LocalsCtxMenuContext context)
        {
            var output = new NoSyntaxHighlightOutput();

            foreach (var vm in context.SelectedItems)
            {
                //TODO: Break if it takes too long and the user cancels
                var printer = new ValuePrinter(output, debuggerSettings.UseHexadecimal);
                printer.WriteValue(vm);
                if (context.SelectedItems.Length > 1)
                {
                    output.WriteLine();
                }
            }
            var s = output.ToString();

            if (s.Length > 0)
            {
                try {
                    Clipboard.SetText(s);
                }
                catch (ExternalException) { }
            }
        }
Esempio n. 27
0
 public override bool IsChecked(LocalsCtxMenuContext context) => localsSettings.ShowTokens;
Esempio n. 28
0
 public override bool IsChecked(LocalsCtxMenuContext context) => localsSettings.ShowTypeKeywords;
Esempio n. 29
0
 public override void Execute(LocalsCtxMenuContext context) => localsSettings.ShowTokens = !localsSettings.ShowTokens;
Esempio n. 30
0
 public override void Execute(LocalsCtxMenuContext context) => localsSettings.ShowTypeKeywords = !localsSettings.ShowTypeKeywords;