protected override bool TryGetSymbol(int operand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol, ref NumberFormattingOptions options) { if (owner.cachedSymbolResolver.TryResolve(address, out var symResult, out bool fakeSymbol)) { if (!fakeSymbol || owner.AddLabels) { Debug.Assert(symResult.Address == address, "Symbol address != orig address: NYI"); if (symResult.Address == address) { symbol = new SymbolResult(symResult.Symbol, SymbolKindUtils.ToFormatterOutputTextKind(symResult.Kind), SymbolFlags.Address); return(true); } } } return(base.TryGetSymbol(operand, ref instruction, address, addressSize, out symbol, ref options)); }
protected override bool TryGetSymbol(int operand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol, ref NumberFormattingOptions options) { if (owner.cachedSymbolResolver.TryResolve(address, out var symResult, out bool fakeSymbol)) { if (!fakeSymbol || owner.AddLabels) { bool isBranch = symResult.Kind == SymbolKind.Function && instruction.FlowControl is var flowControl && (flowControl == FlowControl.UnconditionalBranch || flowControl == FlowControl.ConditionalBranch || flowControl == FlowControl.Call || flowControl == FlowControl.XbeginXabortXend); if (!isBranch || !IsCurrentMethod(symResult.Address)) { //TODO: need to support 'symResult.Address != address' (add a displacement to the symbol, eg. func+123) symbol = new SymbolResult(symResult.Symbol, SymbolKindUtils.ToFormatterOutputTextKind(symResult.Kind), SymbolFlags.Address); return(true); } } } return(base.TryGetSymbol(operand, ref instruction, address, addressSize, out symbol, ref options)); }
public DisassemblyContentProvider Create() { var blocks = X86BlockFactory.Create(bitness, this.blocks); var cachedSymResolver = new CachedSymbolResolver(); if (symbolResolver != null) { var addresses = GetPossibleSymbolAddresses(blocks); if (addresses.Length != 0) { var symbolResolverResults = new SymbolResolverResult[addresses.Length]; symbolResolver.Resolve(addresses, symbolResolverResults); cachedSymResolver.AddSymbols(addresses, symbolResolverResults, fakeSymbol: false); } } foreach (var block in blocks) { if (!string.IsNullOrEmpty(block.Label)) { cachedSymResolver.AddSymbol(block.Address, new SymbolResolverResult(SymbolKindUtils.ToSymbolKind(block.LabelKind), block.Label, block.Address), fakeSymbol: true); } } return(new X86DisassemblyContentProvider(bitness, cachedSymResolver, deps.DisasmSettings, deps.MasmSettings, deps.NasmSettings, deps.GasSettings, formatterOptions, header, optimization, blocks, codeInfo, variableInfo, methodName)); }
public bool TryGetSymbol(int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) { if (owner.cachedSymbolResolver.TryResolve(address, out var symResult, out bool fakeSymbol)) { if (!fakeSymbol || owner.AddLabels) { symbol = new SymbolResult(symResult.Address, symResult.Symbol, SymbolKindUtils.ToFormatterOutputTextKind(symResult.Kind), SymbolFlags.None); return(true); } } symbol = default; return(false); }
public DisassemblyContentProvider Create() { var blocks = X86BlockFactory.Create(bitness, this.blocks); var cachedSymResolver = new CachedSymbolResolver(); foreach (var block in blocks) { if (!string.IsNullOrEmpty(block.Label)) { cachedSymResolver.AddSymbol(block.Address, new SymbolResolverResult(SymbolKindUtils.ToSymbolKind(block.LabelKind), block.Label, block.Address), fakeSymbol: true); } } if (symbolResolver != null) { var addresses = GetPossibleSymbolAddresses(blocks); if (addresses.Length != 0) { var symbolResolverResults = new SymbolResolverResult[addresses.Length]; symbolResolver.Resolve(addresses, symbolResolverResults); cachedSymResolver.AddSymbols(addresses, symbolResolverResults, fakeSymbol: false); } } for (int i = 0; i < blocks.Length; i++) { var block = blocks[i]; if (cachedSymResolver.TryResolve(block.Address, out var symbol, out _) && block.Label != symbol.Symbol) { blocks[i] = new X86Block(block.Kind, block.Address, block.Comment, symbol.Symbol, SymbolKindUtils.ToFormatterOutputTextKind(symbol.Kind), block.Instructions); } } return(new X86DisassemblyContentProvider(bitness, cachedSymResolver, deps.DisasmSettings, deps.MasmSettings, deps.NasmSettings, deps.GasSettings, formatterOptions, header, optimization, blocks, codeInfo, variableInfo, methodName)); }