Java Code Examples for ghidra.program.model.data.DataType#getDisplayName()
The following examples show how to use
ghidra.program.model.data.DataType#getDisplayName() .
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: FunctionFieldSearcher.java From ghidra with Apache License 2.0 | 6 votes |
private void checkTypeString(Variable variable, List<ProgramLocation> currentMatches) { DataType dt; if (variable instanceof Parameter) { dt = ((Parameter)variable).getFormalDataType(); } else { dt = variable.getDataType(); } if (dt == null) { return; } String searchString = dt.getDisplayName(); Matcher matcher = pattern.matcher(searchString); while (matcher.find()) { int index = matcher.start(); currentMatches.add(new VariableTypeFieldLocation(program, variable, index)); } }
Example 2
Source File: VariableTypeFieldFactory.java From ghidra with Apache License 2.0 | 6 votes |
/** * @see ghidra.app.util.viewer.field.FieldFactory#getField(ProxyObj, int) */ @Override public ListingField getField(ProxyObj<?> proxy, int varWidth) { Object obj = proxy.getObject(); if (!enabled || !(obj instanceof Variable)) { return null; } Variable sv = (Variable) obj; DataType dt; if (sv instanceof Parameter) { dt = ((Parameter) sv).getFormalDataType(); } else { dt = sv.getDataType(); } String dtName = (dt != null) ? dt.getDisplayName() : null; AttributedString as = new AttributedString((dtName != null) ? dtName : "", getColor(sv), getMetrics(sv)); FieldElement field = new TextFieldElement(as, 0, 0); return ListingTextField.createSingleLineTextField(this, proxy, field, startX + varWidth, width, hlProvider); }
Example 3
Source File: SymbolTableModel.java From ghidra with Apache License 2.0 | 5 votes |
@Override public String getValue(Symbol symbol, Settings settings, Program p, ServiceProvider svcProvider) throws IllegalArgumentException { if (!symbol.checkIsValid()) { return null; } DataType dt = null; Object obj = symbol.getObject(); if (obj instanceof Data) { dt = ((Data) obj).getDataType(); } else if (obj instanceof Function) { dt = ((Function) obj).getReturnType(); } else if (obj instanceof Variable) { dt = ((Variable) obj).getDataType(); } else if (obj instanceof ExternalLocation) { dt = ((ExternalLocation) obj).getDataType(); } if (dt != null) { return dt.getDisplayName(); } return ""; }
Example 4
Source File: RecentlyUsedAction.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void setPopupMenu(String name, boolean isSignatureAction) { DataType dt = getRecentDataType(); String displayName = "Last Used: " + (dt == null ? "<empty>" : dt.getDisplayName()); setPopupMenuData(new MenuData(new String[] { FunctionPlugin.SET_DATA_TYPE_PULLRIGHT, displayName }, GROUP_NAME)); }
Example 5
Source File: RecentlyUsedAction.java From ghidra with Apache License 2.0 | 5 votes |
private void updatePopupMenu(DataType dt) { MenuData popupData = getPopupMenuData(); String displayName = dt == null ? "<empty>" : dt.getDisplayName(); if (popupData != null) { popupData.setMenuPath(new String[] { "Data", "Last Used: " + displayName }); } else { setPopupMenuData(new MenuData(new String[] { "Data", "Last Used: " + displayName }, GROUP_NAME)); } }
Example 6
Source File: FavoritesAction.java From ghidra with Apache License 2.0 | 5 votes |
/** * Creates an action for applying a favorite data type. * @param provider the provider that owns this action * @param dt the favorite data type */ public FavoritesAction(CompositeEditorProvider provider, DataType dt) { super(provider, dt.getDisplayName(), GROUP_NAME, new String[] { "Favorite", dt.getDisplayName() }, new String[] { "Favorite", dt.getDisplayName() }, null); this.dataType = dt; getPopupMenuData().setParentMenuGroup(GROUP_NAME); adjustEnablement(); }
Example 7
Source File: ShowComponentPathAction.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionContext context) { String message = " "; int index = model.getMinIndexSelected(); DataTypeComponent dtc = model.getComponent(index); if (dtc != null) { DataType dt = dtc.getDataType(); message = dt.getDisplayName() + " is in category \"" + dt.getCategoryPath().getPath() + "\"."; } model.setStatus(message, false); requestTableFocus(); }
Example 8
Source File: PreviewTableCellData.java From ghidra with Apache License 2.0 | 5 votes |
private String getVariablePreview(VariableLocation loc) { if (loc instanceof VariableCommentFieldLocation) { return ((VariableCommentFieldLocation) loc).getComment(); } Variable var = loc.getVariable(); if (var == null) { return ""; // must no longer be a valid variable location } String comments = var.getComment(); StringBuilder sb = new StringBuilder(); DataType dt = var.getDataType(); String dtName = "Unknown"; if (dt != null) { dtName = dt.getDisplayName(); } sb.append(dtName); sb.append(" "); sb.append(var.getVariableStorage().toString()); sb.append(" "); sb.append(var.getName()); if (comments != null) { sb.append(" "); sb.append(comments); } return sb.toString(); }
Example 9
Source File: PropagateExternalParametersAnalyzer.java From ghidra with Apache License 2.0 | 4 votes |
private void propogateParams(Parameter[] params, CodeUnitIterator iterator, String externalFunctionName) { int index = 0; int numSkips = 0; while (iterator.hasNext() && index < params.length) { // Need to take into account calls between the pushes and skip the // pushes for those calls skip pushes that are used for another call. // If label, then probably a branch, allow current push to be commented and // next time through stop. Can also be a branch if not label there but // this case should still have parameters set // before it as long as not an unconditional jump - this wouldn't make // sense so it shouldn't happen CodeUnit cu = iterator.next(); boolean isBranch = cu.getLabel() != null; if (cu.getMnemonicString().equals("CALL")) { numSkips += numParams(cu); } else if (cu.getMnemonicString().equals("PUSH")) { if (numSkips > 0) { numSkips--; } else { Parameter param = params[index]; DataType dt = param.getDataType(); String name = param.getName(); SetCommentCmd cmd = new SetCommentCmd(cu.getAddress(), CodeUnit.EOL_COMMENT, dt.getDisplayName() + " " + name + " for " + externalFunctionName); cmd.applyTo(currentProgram); // add the following to the EOL comment to see the value of the optype addResult(name, dt, cu.getMinAddress(), externalFunctionName); index++; } } if (isBranch) { break; } } }
Example 10
Source File: DataAction.java From ghidra with Apache License 2.0 | 4 votes |
public DataAction(DataType dataType, FunctionPlugin plugin) { this("Define " + dataType.getDisplayName(), "Function", dataType, plugin); setHelpLocation(new HelpLocation(plugin.getName(), "DataType")); }
Example 11
Source File: ExternalFunctionMerger.java From ghidra with Apache License 2.0 | 4 votes |
private String[] getExternalInfo(final ExternalLocation[] externalLocations, int programVersion) { Address latestAddress = (externalLocations[LATEST] != null) ? externalLocations[LATEST].getExternalSpaceAddress() : null; Address myAddress = (externalLocations[MY] != null) ? externalLocations[MY].getExternalSpaceAddress() : null; Address originalAddress = (externalLocations[ORIGINAL] != null) ? externalLocations[ORIGINAL].getExternalSpaceAddress() : null; String[] info = new String[] { "", "", "", "", "", "", "" }; String versionName = RESULT_TITLE; String externalName = ""; String externalType = "label"; String actionString = "Keep"; ExternalLocation externalLocation = null; Program pgm = programs[RESULT]; switch (programVersion) { case HEADER: return new String[] { "Option", "Name", "Type", "Address", "DataType", "Source", "Function" }; case LATEST: pgm = programs[LATEST]; versionName = LATEST_TITLE; if (latestAddress == null) { actionString = "Remove"; break; } externalLocation = getExternalLocation(latestAddress, LATEST); break; case MY: pgm = programs[MY]; versionName = MY_TITLE; if (myAddress == null) { actionString = "Remove"; break; } externalLocation = getExternalLocation(myAddress, MY); break; case ORIGINAL: pgm = programs[ORIGINAL]; versionName = ORIGINAL_TITLE; if (originalAddress == null) { actionString = "No"; break; } externalLocation = getExternalLocation(originalAddress, ORIGINAL); break; } info[0] = actionString + " '" + versionName + "'."; if (externalLocation != null) { Symbol symbol = externalLocation.getSymbol(); externalName = symbol.getName(true); if (symbol.getSymbolType() == SymbolType.FUNCTION) { externalType = "function"; } Address externalAddress = externalLocation.getAddress(); DataType dataType = getResultDataType(externalLocation); SourceType sourceType = externalLocation.getSource(); Function function = externalLocation.getFunction(); info[1] = externalName; info[2] = externalType; info[3] = DiffUtility.getUserToAddressString(pgm, externalAddress); if (dataType != null) { info[4] = dataType.getDisplayName(); } info[5] = sourceType.getDisplayString(); if (function != null) { info[6] = function.getPrototypeString(true, true); } } return info; }
Example 12
Source File: CreateDataCmd.java From ghidra with Apache License 2.0 | 3 votes |
/** * This constructor provides the most flexibility when creating data, allowing optional pointer conversion and * various clearing options for conflicting data. * @param addr the address at which to apply the datatype. * @param dataType the datatype to be applied at the given address. * @param stackPointers if true simple pointer conversion is enabled * (see {@link DataUtilities#reconcileAppliedDataType(DataType, DataType, boolean)}). * @param clearMode indicates how conflicting data should be cleared */ public CreateDataCmd(Address addr, DataType dataType, boolean stackPointers, DataUtilities.ClearDataMode clearMode) { this.newDataType = dataType; this.addr = addr; this.stackPointers = stackPointers; this.clearMode = clearMode; cmdName = "Create " + dataType.getDisplayName(); }