Java Code Examples for ghidra.program.model.listing.Program#getEquateTable()

The following examples show how to use ghidra.program.model.listing.Program#getEquateTable() . 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: EquateReferenceTableModel.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void populateReferences() {
	referenceList.clear();

	Program program = getProgram();
	if (program == null) {
		return;
	}

	EquateTable equateTable = program.getEquateTable();
	if (equateTable == null || currentEquate == null) {
		return;
	}

	// @formatter:off
	Arrays.asList(currentEquate.getReferences())
		.forEach(r -> referenceList.add(r));
	// @formatter:on

	fireTableDataChanged();
}
 
Example 2
Source File: EquateOperandFieldLocation.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void restoreState(Program p, SaveState obj) {

	super.restoreState(p, obj);
	long value = obj.getLong("_EQUATE_VALUE", 0);

	EquateTable equateTable = p.getEquateTable();
	equate = equateTable.getEquate(addr, getOperandIndex(), value);
}
 
Example 3
Source File: EnumEditorProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Checks to see if the new changes to the enum will affect equates based off of it.
 * @param editedEnum the enum to check for conflicts with
 * @param dtm the data type manager that this enum lies within
 * @return true if the enum should save its changes; otherwise, false
 */
private boolean resolveEquateConflicts(Enum editedEnum, DataTypeManager dtm) {

	Program program = plugin.getProgram();
	if (program == null) {
		// No open program; data type not from the program archive.
		return true;
	}

	EquateTable et = program.getEquateTable();
	Set<String> oldFieldConflicts = new HashSet<>();
	Set<String> conflictingEquates = new HashSet<>();

	for (Equate eq : CollectionUtils.asIterable(et.getEquates())) {
		if (eq.isEnumBased() && originalEnum.getUniversalID().equals(eq.getEnumUUID()) &&
			editedEnum.getName(eq.getValue()) == null) {
			oldFieldConflicts.add(originalEnum.getName(eq.getValue()));
			conflictingEquates.add(eq.getName());
		}
	}
	if (conflictingEquates.isEmpty()) {
		return true;
	}
	switch (showOptionDialog(editedEnum, oldFieldConflicts)) {
		case OptionDialog.OPTION_ONE:
			removeEquates(et, conflictingEquates);
		case OptionDialog.OPTION_TWO:
			return true;
		case OptionDialog.CANCEL_OPTION:
		default:
			return false;
	}
}
 
Example 4
Source File: SetEquateDialog.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param tool the EquatePlugin that launched this dialog(used to validate input)
 * @param program the program the equate is located in.
 * @param value the equate value to set.
 */

public SetEquateDialog(PluginTool tool, Program program, Scalar value) {
	super("Set Equate", true, true, true, false);
	this.tool = tool;
	this.program = program;
	this.scalar = value;
	this.dataTypeManager = program.getDataTypeManager();
	this.equateTable = program.getEquateTable();
	addWorkPanel(buildMainPanel());
	addOKButton();
	addCancelButton();
	setRememberSize(false);
}
 
Example 5
Source File: EquateTableModel.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void populateEquates() {

		equateList.clear();

		Program program = plugin.getProgram();

		if (program == null) {
			fireTableDataChanged();
			return;
		}

		EquateTable equateTable = program.getEquateTable();

		equateList = CollectionUtils.asList(equateTable.getEquates());

		fireTableDataChanged();
	}