Java Code Examples for ghidra.program.model.symbol.SymbolTable#getPrimarySymbol()
The following examples show how to use
ghidra.program.model.symbol.SymbolTable#getPrimarySymbol() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VersionTrackingPluginScreenShots.java From ghidra with Apache License 2.0 | 6 votes |
private VTMatch getMatch(String sourceLabel, VTAssociationType matchType) { List<VTMatchSet> matchSets = session.getMatchSets(); for (VTMatchSet vtMatchSet : matchSets) { Collection<VTMatch> matches = vtMatchSet.getMatches(); for (VTMatch vtMatch : matches) { VTAssociation association = vtMatch.getAssociation(); VTAssociationType type = association.getType(); if (type != matchType) { continue; } Address sourceAddr = association.getSourceAddress(); SymbolTable symbolTable = sourceProgram.getSymbolTable(); Symbol primarySymbol = symbolTable.getPrimarySymbol(sourceAddr); String name = primarySymbol.getName(false); if (name.equals(sourceLabel)) { return vtMatch; } } } return null; }
Example 2
Source File: FindReferencesToSymbolAction.java From ghidra with Apache License 2.0 | 6 votes |
private Symbol getSymbol(DecompilerActionContext context) { ProgramLocation location = context.getLocation(); if (location == null) { return null; } Address address = getDecompilerSymbolAddress(location); if (address == null) { address = location.getAddress(); } Program program = context.getProgram(); SymbolTable symbolTable = program.getSymbolTable(); Symbol symbol = symbolTable.getPrimarySymbol(address); return symbol; }
Example 3
Source File: NextPrevAddressPlugin.java From ghidra with Apache License 2.0 | 6 votes |
private static String getAddressRepresentation(Program program, Address address, CodeUnitFormat formatter) { SymbolTable symbolTable = program.getSymbolTable(); Symbol symbol = symbolTable.getPrimarySymbol(address); if (symbol != null) { // try label first return truncateAsNecessary(symbol.getName()); } Listing listing = program.getListing(); CodeUnit codeUnit = listing.getCodeUnitAt(address); if (codeUnit == null) { return null; } String displayString = formatter.getRepresentationString(codeUnit); if (displayString != null) { return truncateAsNecessary(displayString); } return null; }
Example 4
Source File: NamespaceTableColumn.java From ghidra with Apache License 2.0 | 6 votes |
private Symbol getSymbol(ProgramLocation rowObject, Program program) throws IllegalArgumentException { ProgramLocation location = rowObject; if (rowObject instanceof VariableLocation) { Variable var = ((VariableLocation) rowObject).getVariable(); if (var != null) { return var.getSymbol(); } } Address address = location.getAddress(); SymbolTable symbolTable = program.getSymbolTable(); Symbol symbol = symbolTable.getPrimarySymbol(address); if (symbol != null) { return symbol; } return null; }
Example 5
Source File: SymbolAnnotatedStringHandler.java From ghidra with Apache License 2.0 | 6 votes |
private static List<Symbol> getSymbols(String rawText, Program program) { List<Symbol> list = NamespaceUtils.getSymbols(rawText, program); if (!list.isEmpty()) { return list; } // if we get here, then see if the value is an address Address address = program.getAddressFactory().getAddress(rawText); if (address != null) { SymbolTable symbolTable = program.getSymbolTable(); Symbol symbol = symbolTable.getPrimarySymbol(address); if (symbol != null) { return Arrays.asList(symbol); } } return Collections.emptyList(); }
Example 6
Source File: ListingGraphComponentPanel.java From ghidra with Apache License 2.0 | 5 votes |
private String createTitle() { Address minAddress = addressSet.getMinAddress(); String newTitle = minAddress.toString(); SymbolTable symbolTable = program.getSymbolTable(); Symbol primarySymbol = symbolTable.getPrimarySymbol(minAddress); if (primarySymbol != null) { newTitle += " - " + primarySymbol.getName(false); } return newTitle; }
Example 7
Source File: AbstractTextFilter.java From ghidra with Apache License 2.0 | 5 votes |
protected String getSymbolText(Address address) { VTSession session = controller.getSession(); Program sourceProgram = session.getSourceProgram(); SymbolTable symbolTable = sourceProgram.getSymbolTable(); Symbol symbol = symbolTable.getPrimarySymbol(address); if (symbol == null) { return "<No Symbol>"; } return symbol.getName(); }
Example 8
Source File: LabelTableColumn.java From ghidra with Apache License 2.0 | 5 votes |
private Symbol getSymbol(ProgramLocation rowObject, Program program) throws IllegalArgumentException { ProgramLocation location = rowObject; if (rowObject instanceof VariableLocation) { Variable var = ((VariableLocation) rowObject).getVariable(); if (var != null) { return var.getSymbol(); } } Address address = location.getAddress(); SymbolTable symbolTable = program.getSymbolTable(); return symbolTable.getPrimarySymbol(address); }
Example 9
Source File: SourceTypeTableColumn.java From ghidra with Apache License 2.0 | 5 votes |
@Override public String getValue(ProgramLocation rowObject, Settings settings, Program program, ServiceProvider serviceProvider) throws IllegalArgumentException { SymbolTable symbolTable = program.getSymbolTable(); Symbol primarySymbol = symbolTable.getPrimarySymbol(rowObject.getAddress()); if (primarySymbol != null) { return primarySymbol.getSource().toString(); } return null; }
Example 10
Source File: AddressLocationDescriptor.java From ghidra with Apache License 2.0 | 5 votes |
private String getLabelForAddress(CodeUnitLocation location) { Address address = getAddressForLocation(location); SymbolTable symbolTable = program.getSymbolTable(); Symbol symbol = symbolTable.getPrimarySymbol(address); if (symbol != null) { return symbol.getName(); } if (location instanceof AddressFieldLocation) { return ((AddressFieldLocation) location).getAddressRepresentation(); } return location.getAddress().toString(); }
Example 11
Source File: AutoRenamePlugin.java From ghidra with Apache License 2.0 | 5 votes |
/** * Perform Fragment Auto-Rename on selected Fragments. * Rename is performed on all selected Fragments within Program Tree. */ void autoRenameCallback(ActionContext context) { Object obj = context.getContextObject(); if (obj instanceof ProgramNode) { ProgramNode node = (ProgramNode) obj; CompoundCmd cmd = new CompoundCmd("Auto Rename Fragment(s)"); SymbolTable symTable = currentProgram.getSymbolTable(); // Find selected Fragments TreePath[] selectedPaths = node.getTree().getSelectionPaths(); boolean ignoreDuplicateNames = (selectedPaths.length > 1); for (int i = 0; i < selectedPaths.length; i++) { ProgramNode n = (ProgramNode) selectedPaths[i].getLastPathComponent(); if (!n.isFragment()) continue; // Rename Fragment using minimum address label ProgramFragment f = n.getFragment(); Address a = f.getMinAddress(); if (a == null) continue; // empty Fragment Symbol s = symTable.getPrimarySymbol(a); if (s != null) { cmd.add(new RenameCmd(f.getTreeName(), false, f.getName(), s.getName(), ignoreDuplicateNames)); } } if (cmd.size() > 0 && !tool.execute(cmd, currentProgram)) { tool.setStatusInfo("Error renaming fragment: " + cmd.getStatusMsg()); } } }
Example 12
Source File: ListingGraphComponentPanel.java From ghidra with Apache License 2.0 | 5 votes |
@Override void editLabel(JComponent parentComponent) { AddressSetView view = listingPanel.getView(); Address minAddress = view.getMinAddress(); SymbolTable symbolTable = program.getSymbolTable(); Symbol primarySymbol = symbolTable.getPrimarySymbol(minAddress); AddEditDialog dialog = new AddEditDialog("", tool); if (primarySymbol == null) { dialog.addLabel(minAddress, program, parentComponent); } else { dialog.editLabel(primarySymbol, program, parentComponent); } }
Example 13
Source File: BlockModelGraphDisplayListener.java From ghidra with Apache License 2.0 | 5 votes |
@Override protected List<String> getVertices(AddressSetView addrSet) { if (addrSet.isEmpty()) { return Collections.emptyList(); } // Identify all blocks which have an entry point within the selection address set ArrayList<String> blockList = new ArrayList<String>(); try { SymbolTable symTable = program.getSymbolTable(); CodeBlockIterator cbIter = blockModel.getCodeBlocksContaining(addrSet, TaskMonitor.DUMMY); while (cbIter.hasNext()) { CodeBlock block = cbIter.next(); String addrString; Address addr = block.getFirstStartAddress(); if (addr.isExternalAddress()) { Symbol s = symTable.getPrimarySymbol(addr); addrString = s.getName(true); } else { addrString = addr.toString(); } blockList.add(addrString); } } catch (CancelledException e) { // Will not happen with dummyMonitor // Model has already done the work when the graph was created } return blockList; }
Example 14
Source File: ReferenceFromLabelTableColumn.java From ghidra with Apache License 2.0 | 4 votes |
private Symbol getSymbol( ReferenceAddressPair rowObject, Program program ) { Address fromAddress = rowObject.getSource(); SymbolTable symbolTable = program.getSymbolTable(); return symbolTable.getPrimarySymbol(fromAddress); }
Example 15
Source File: ProgramLocationToSymbolTableRowMapper.java From ghidra with Apache License 2.0 | 4 votes |
@Override public Symbol map(ProgramLocation rowObject, Program program, ServiceProvider serviceProvider) { SymbolTable symbolTable = program.getSymbolTable(); return symbolTable.getPrimarySymbol(rowObject.getByteAddress()); }
Example 16
Source File: AddressToSymbolTableRowMapper.java From ghidra with Apache License 2.0 | 4 votes |
@Override public Symbol map(Address rowObject, Program program, ServiceProvider serviceProvider) { SymbolTable symbolTable = program.getSymbolTable(); return symbolTable.getPrimarySymbol(rowObject); }
Example 17
Source File: VTMatchOneToManyTableProvider.java From ghidra with Apache License 2.0 | 4 votes |
public void loadLocalInfo(Address infoAddress) { if (infoAddress == null) { labelValue.setText(""); labelTypeValue.setText(""); addressValue.setText(""); return; } VTSession session = controller.getSession(); Program program = (isSource ? session.getSourceProgram() : session.getDestinationProgram()); // LABEL, SymbolTable symbolTable = program.getSymbolTable(); Symbol symbol = symbolTable.getPrimarySymbol(infoAddress); String labelValueText; if (symbol == null) { labelValueText = "<No Symbol>"; } else { labelValueText = symbol.getName(); } labelValue.setText(labelValueText); // LABEL_SOURCE, String labelTypeValueText; if (symbol == null) { labelTypeValueText = "<none>"; } else { labelTypeValueText = symbol.getSource().getDisplayString(); } labelTypeValue.setText(labelTypeValueText); // ADDRESS DisplayableListingAddress displayableAddress = new DisplayableListingAddress(program, infoAddress); addressValue.setText(displayableAddress.getDisplayString()); localPanel.validate(); localPanel.invalidate(); }