private void JumpIsRet(object sender, RoutedEventArgs e) { ListViewFunction item = (ListViewFunction)FunctionsView.SelectedItem; Function f = item.Details; state.CallIsRet.Add(f); }
private void FunctionViewSearchNext() { int curIndex = FunctionsView.SelectedIndex; if (curIndex == -1) { curIndex = 0; } for (int i = curIndex; i < FunctionsView.Items.Count; i++) { ListViewFunction f = FunctionsView.Items[i] as ListViewFunction; if (f.FuncName.StartsWith(searchBuffer, true, null)) { FunctionsViewScrollTo(i); return; } } for (int i = 0; i < curIndex; i++) { ListViewFunction f = FunctionsView.Items[i] as ListViewFunction; if (f.FuncName.StartsWith(searchBuffer, true, null)) { FunctionsViewScrollTo(i); return; } } }
private void OpenProject(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); ofd.Filter = "x360Dec projects (*.xdp)|*.xdp"; bool?res = ofd.ShowDialog(); if (res == null || res == false) { return; } _FuncCollection.Clear(); projFn = ofd.FileName; state = State.FromFile(projFn); foreach (Function f in state.Functions) { ListViewFunction lvf = new ListViewFunction(f.Name, f.Address, f); _FuncCollection.Add(lvf); f.ListViewEntry = lvf; } SaveMenu.IsEnabled = true; PdbMenu.IsEnabled = true; ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefaultView(FunctionsView.ItemsSource); view.CustomSort = nameSorter; }
private void IgnoreCalls(object sender, RoutedEventArgs e) { ListViewFunction item = (ListViewFunction)FunctionsView.SelectedItem; Function f = item.Details; state.IgnoredCalls.Add(f); }
private void DisassembleFunction(object sender, RoutedEventArgs e) { ListViewFunction item = (ListViewFunction)FunctionsView.SelectedItem; Function f = item.Details; if (f.Size == 0xFFFFFFFF || f.Blocks == null) { f.FindSize(); FindDominators(f.Blocks); } _InstrCollection.Clear(); foreach (FunctionBlock block in f.Blocks) { uint offset = state.Pe.Rva2Offset(block.StartAddress - (uint)state.Pe.optHdr.ImageBase); for (uint i = 0; i < block.InstrCount; i++) { uint instruction = state.Pe.ReadInstruction(offset + i * 4); XenonInstructions.OpCodeInfo info = state.Instructions.GetInfo(instruction); ListViewInstr instr = new ListViewInstr("0x" + (block.StartAddress + i * 4).ToString("X8"), info.Name, ""); _InstrCollection.Add(instr); } } }
private void OpenPdb(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); ofd.Filter = "Program Database (*.pdb)|*.pdb"; bool?res = ofd.ShowDialog(); if (res.HasValue && res == true) { pdb = new PdbParser.PdbParser(ofd.FileName); List <Symbol> syms = pdb.DumpAllPublics(); foreach (Symbol s in syms) { UInt32 addr = s.Rva + (uint)state.Pe.GetImageBase(); XPeParser.SectionHeader section = state.Pe.GetSectionByAddress(s.Rva); /* Code or Mem_Executable */ if ((section.Characteristics & 0x20000020) != 0) { Function f = new Function(state, s.Name, addr); f.Name = s.Name; f.Address = addr; ListViewFunction lvf = new ListViewFunction(s.Name, addr, f); _FuncCollection.Add(lvf); f.ListViewEntry = lvf; state.Functions.Add(f); } } state.Functions.Sort(FunctionAddressComparison); } }
private void OpenFuncProperties(object sender, RoutedEventArgs e) { ListViewFunction item = (ListViewFunction)FunctionsView.SelectedItem; Function f = item.Details; FunctionProperties fp = new FunctionProperties(f); fp.ShowDialog(); }
private void DecompileFunction(object sender, RoutedEventArgs e) { ListViewFunction item = (ListViewFunction)FunctionsView.SelectedItem; Function f = item.Details; if (f.Size == 0xFFFFFFFF || f.Blocks == null) { f.FindSize(); FindDominators(f.Blocks); } f.Loops = FindLoops(f.Blocks); DecompileEasy(f); ComputeUseDefs(f.Blocks); // PropagateExpressions(f.Blocks); // NiceConditions(f.Blocks); // LoopPhase2(f.Blocks, f.Loops); // IfElse(f.Blocks); List <CStatement> statements = new List <CStatement>(); foreach (FunctionBlock b in f.Blocks) { CStatement label = new CStatement(CStatement.Kinds.Label); label.LabelName = "L" + b.StartAddress.ToString("X8"); statements.Add(label); statements.AddRange(b.Statements); } string csource = "void " + f.Name + "()\n{\n"; foreach (CStatement stat in statements) { if (stat.Kind != CStatement.Kinds.Label) { csource += "\t"; } csource += stat.ToString(1); if (stat.Kind != CStatement.Kinds.Conditional && stat.Kind != CStatement.Kinds.Label) { csource += ";\n"; } else { csource += "\n"; } } csource += "}"; CSource src = new CSource(csource); src.Show(); }
public int Compare(object a, object b) { ListViewFunction f1 = (ListViewFunction)a, f2 = (ListViewFunction)b; return(f1.FuncAddr.CompareTo(f2.FuncAddr)); }
private void OpenProject(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); ofd.Filter = "x360Dec projects (*.xdp)|*.xdp"; bool? res = ofd.ShowDialog(); if (res == null || res == false) return; _FuncCollection.Clear(); projFn = ofd.FileName; state = State.FromFile(projFn); foreach (Function f in state.Functions) { ListViewFunction lvf = new ListViewFunction(f.Name, f.Address, f); _FuncCollection.Add(lvf); f.ListViewEntry = lvf; } SaveMenu.IsEnabled = true; PdbMenu.IsEnabled = true; ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefaultView(FunctionsView.ItemsSource); view.CustomSort = nameSorter; }
private void OpenPdb(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); ofd.Filter = "Program Database (*.pdb)|*.pdb"; bool? res = ofd.ShowDialog(); if (res.HasValue && res == true) { pdb = new PdbParser.PdbParser(ofd.FileName); List<Symbol> syms = pdb.DumpAllPublics(); foreach (Symbol s in syms) { UInt32 addr = s.Rva + (uint) state.Pe.GetImageBase(); XPeParser.SectionHeader section = state.Pe.GetSectionByAddress(s.Rva); /* Code or Mem_Executable */ if ((section.Characteristics & 0x20000020) != 0) { Function f = new Function(state, s.Name, addr); f.Name = s.Name; f.Address = addr; ListViewFunction lvf = new ListViewFunction(s.Name, addr, f); _FuncCollection.Add(lvf); f.ListViewEntry = lvf; state.Functions.Add(f); } } state.Functions.Sort(FunctionAddressComparison); } }