internal static uint? AskForToken(string title) { var ask = new AskForInput(); ask.Owner = MainWindow.Instance; ask.Title = title; ask.label.Content = "_Metadata token"; ask.textBox.Text = ""; ask.textBox.ToolTip = "Enter an MD token: 0x06001234 or 0x0200ABCD"; ask.ShowDialog(); if (ask.DialogResult != true) return null; string tokenText = ask.textBox.Text; tokenText = tokenText.Trim(); if (string.IsNullOrEmpty(tokenText)) return null; string error; uint token = NumberVMUtils.ParseUInt32(tokenText, uint.MinValue, uint.MaxValue, out error); if (!string.IsNullOrEmpty(error)) { MainWindow.Instance.ShowMessageBox(error); return null; } return token; }
public string GetName() { var ask = new AskForInput(); ask.Owner = ownerWindow ?? MainWindow.Instance; ask.Title = "Add an Exception"; ask.label.Content = "_Full name"; ask.textBox.Text = string.Empty; ask.ShowDialog(); if (ask.DialogResult != true) return null; var t = ask.textBox.Text.Trim(); if (string.IsNullOrEmpty(t)) return null; return t; }
internal static void Execute() { DecompileTabState tabState; var module = GetModule(out tabState); if (module == null) return; var ask = new AskForInput(); ask.Owner = MainWindow.Instance; ask.Title = "Go to MD Token"; ask.label.Content = "_Metadata token"; ask.textBox.Text = ""; ask.textBox.ToolTip = "Enter an MD token: 0x06001234 or 0x0200ABCD"; ask.ShowDialog(); if (ask.DialogResult != true) return; string tokenText = ask.textBox.Text; tokenText = tokenText.Trim(); if (string.IsNullOrEmpty(tokenText)) return; string error; uint token = NumberVMUtils.ParseUInt32(tokenText, uint.MinValue, uint.MaxValue, out error); if (!string.IsNullOrEmpty(error)) { MainWindow.Instance.ShowMessageBox(error); return; } var memberRef = module.ResolveToken(token) as IMemberRef; var member = MainWindow.ResolveReference(memberRef); if (member == null) { if (memberRef == null) MainWindow.Instance.ShowMessageBox(string.Format("Invalid metadata token: 0x{0:X8}", token)); else MainWindow.Instance.ShowMessageBox(string.Format("Could not resolve member reference token: 0x{0:X8}", token)); return; } MainWindow.Instance.JumpToReference(tabState.TextView, member); }
protected override void Execute(DnHexBox dnHexBox) { var sel = dnHexBox.Selection; if (sel == null) return; var ask = new AskForInput(); ask.Owner = MainWindow.Instance; ask.Title = "Enter Value"; ask.label.Content = "_Byte"; ask.textBox.Text = "0xFF"; ask.ShowDialog(); if (ask.DialogResult != true) return; string error; byte b = NumberVMUtils.ParseByte(ask.textBox.Text, byte.MinValue, byte.MaxValue, out error); if (!string.IsNullOrEmpty(error)) { MainWindow.Instance.ShowMessageBox(error); return; } dnHexBox.FillBytes(sel.Value.StartOffset, sel.Value.EndOffset, b); dnHexBox.Selection = null; }
private void GoToLineExecuted(object sender, ExecutedRoutedEventArgs e) { var decompilerTextView = ActiveTextView; if (decompilerTextView == null) return; var ask = new AskForInput(); ask.Owner = this; ask.Title = "Go to Line"; ask.label.Content = "_Line [, column]"; ask.textBox.Text = ""; ask.textBox.ToolTip = "Enter a line and/or column\n10 => line 10, column 1\n,5 => column 5\n10,5 => line 10, column 5"; ask.ShowDialog(); if (ask.DialogResult != true) return; string lineText = ask.textBox.Text; int? line = null, column = null; Match match; if ((match = goToLineRegex1.Match(lineText)) != null && match.Groups.Count == 4) { line = TryParse(match.Groups[1].Value); column = match.Groups[3].Value != string.Empty ? TryParse(match.Groups[3].Value) : 1; } else if ((match = goToLineRegex2.Match(lineText)) != null && match.Groups.Count == 2) { line = decompilerTextView.TextEditor.TextArea.Caret.Line; column = TryParse(match.Groups[1].Value); } if (line == null || column == null) { ShowMessageBox(string.Format("Invalid line: {0}", lineText)); return; } decompilerTextView.ScrollAndMoveCaretTo(line.Value, column.Value); }