Java Code Examples for ghidra.framework.options.Options#getInt()

The following examples show how to use ghidra.framework.options.Options#getInt() . 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: PreCommentFieldFactory.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor
 * @param model the model that the field belongs to.
 * @param hlProvider the HightLightStringProvider.
 * @param displayOptions the Options for display properties.
 * @param fieldOptions the Options for field specific properties.
 */
private PreCommentFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
		Options displayOptions, Options fieldOptions) {
	super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);

	fieldOptions.registerOption(FLAG_FUNCTION_ENTRY_OPTION, false, null,
		"Toggles the display of a pre-comment for a function entry");
	fieldOptions.registerOption(FLAG_SUBROUTINE_ENTRY_OPTION, false, null,
		"Toggles the display of a pre-comment for a sub-routine entry");

	flagFunctionEntry = fieldOptions.getBoolean(FLAG_FUNCTION_ENTRY_OPTION, false);
	flagSubroutineEntry = fieldOptions.getBoolean(FLAG_SUBROUTINE_ENTRY_OPTION, false);

	automaticCommentColor =
		displayOptions.getColor(OptionsGui.COMMENT_AUTO.getColorOptionName(),
			OptionsGui.COMMENT_AUTO.getDefaultColor());
	automaticCommentStyle =
		displayOptions.getInt(OptionsGui.COMMENT_AUTO.getStyleOptionName(), -1);

	init(fieldOptions);
}
 
Example 2
Source File: PostCommentFieldFactory.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor
 * @param model the model that the field belongs to.
 * @param hlProvider the HightLightStringProvider.
 * @param displayOptions the Options for display properties.
 * @param fieldOptions the Options for field specific properties.
 */
private PostCommentFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
		Options displayOptions, Options fieldOptions) {
	super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);

	fieldOptions.registerOption(FLAG_FUNCTION_EXIT_OPTION, false, null,
		"Toggles the display of a post-comment for a function exit");
	fieldOptions.registerOption(FLAG_TERMINATOR_OPTION, false, null,
		"Toggles the display of a jump/return post-comments");
	fieldOptions.registerOption(LINES_AFTER_BLOCKS_OPTION, 0, null,
		"The number of lines to display after basic blocks");

	flagFunctionExits = fieldOptions.getBoolean(FLAG_FUNCTION_EXIT_OPTION, false);
	flagJMPsRETs = fieldOptions.getBoolean(FLAG_TERMINATOR_OPTION, false);
	nLinesAfterBlocks = fieldOptions.getInt(LINES_AFTER_BLOCKS_OPTION, 0);

	automaticCommentColor =
		displayOptions.getColor(OptionsGui.COMMENT_AUTO.getColorOptionName(),
			OptionsGui.COMMENT_AUTO.getDefaultColor());
	automaticCommentStyle =
		displayOptions.getInt(OptionsGui.COMMENT_AUTO.getStyleOptionName(), -1);

	init(fieldOptions);
}
 
Example 3
Source File: GraphASTControlFlowAction.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected void decompilerActionPerformed(DecompilerActionContext context) {
	PluginTool tool = context.getTool();
	GraphDisplayBroker service = tool.getService(GraphDisplayBroker.class);
	if (service == null) {
		Msg.showError(this, tool.getToolFrame(), "AST Graph Failed",
			"Graph consumer not found: Please add a graph consumer provider to your tool");
		return;
	}

	// TODO: Options should really be obtained from graph service
	Options options = tool.getOptions("Graph");
	boolean reuseGraph = options.getBoolean("Reuse Graph", false);
	int codeLimitPerBlock = options.getInt("Max Code Lines Displayed", 10);
	HighFunction highFunction = context.getHighFunction();
	Address locationAddr = context.getLocation().getAddress();
	ASTGraphTask task = new ASTGraphTask(service, !reuseGraph, codeLimitPerBlock, locationAddr,
		highFunction, CONTROL_FLOW_GRAPH, tool);
	new TaskLauncher(task, tool.getToolFrame());
}
 
Example 4
Source File: AbstractVariableFieldFactory.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void displayOptionsChanged(Options options, String optionName, Object oldValue,
		Object newValue) {

	if (optionName.equals(FONT_OPTION_NAME)) {
		baseFont = SystemUtilities.adjustForFontSizeOverride((Font) newValue);
		setMetrics(baseFont, parameterFieldOptions[CUSTOM_PARAM_INDEX]);
		setMetrics(baseFont, parameterFieldOptions[DYNAMIC_PARAM_INDEX]);
	}
	else {
		for (int i = 0; i < 2; i++) {
			if (optionName.equals(parameterFieldOptions[i].getColorOptionName())) {
				parameterFieldOptions[i].color = (Color) newValue;
			}
			else if (optionName.equals(styleOptionName)) {
				parameterFieldOptions[i].style = options.getInt(optionName, -1);
				setMetrics(baseFont, parameterFieldOptions[i]);
			}
		}
	}
	super.displayOptionsChanged(options, optionName, oldValue, newValue);
}
 
Example 5
Source File: OperandReferenceAnalyzer.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void optionsChanged(Options options, Program program) {

	minStringLength = options.getInt(OPTION_NAME_MIN_STRING_LENGTH, minStringLength);
	switchTableAlignment = options.getInt(OPTION_NAME_SWITCH_ALIGNMENT, switchTableAlignment);
	minimumAddressTableSize =
		options.getInt(OPTION_NAME_MINIMUM_TABLE_SIZE, minimumAddressTableSize);

	asciiEnabled = options.getBoolean(OPTION_NAME_ASCII, asciiEnabled);
	unicodeEnabled = options.getBoolean(OPTION_NAME_UNICODE, unicodeEnabled);
	alignStringsEnabled = options.getBoolean(OPTION_NAME_ALIGN_STRINGS, alignStringsEnabled);
	pointerEnabled = options.getBoolean(OPTION_NAME_POINTER, pointerEnabled);
	relocationGuideEnabled =
		options.getBoolean(OPTION_NAME_RELOCATION_GUIDE, relocationGuideEnabled);
	subroutinesEnabled = options.getBoolean(OPTION_NAME_SUBROUTINE, subroutinesEnabled);
	addressTablesEnabled = options.getBoolean(OPTION_NAME_ADDRESS_TABLE, addressTablesEnabled);
	switchTableEnabled = options.getBoolean(OPTION_NAME_SWITCH, switchTableEnabled);
	respectExecuteFlags =
		options.getBoolean(OPTION_NAME_RESPECT_EXECUTE_FLAG, respectExecuteFlags);
}
 
Example 6
Source File: AbstractReferenceHover.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void setOptions(Options options, String name) {
	enabled = options.getBoolean(name, true);
	int dialogWidth = options.getInt(name + Options.DELIMITER + "Dialog Width", 600);
	if (dialogWidth <= 0) {
		throw new OptionsVetoException(
			"Reference Code Viewer Dialog Width must be greater than 0");
	}

	int dialogHeight = options.getInt(name + Options.DELIMITER + "Dialog Height", 400);
	if (dialogHeight <= 0) {
		throw new OptionsVetoException(
			"Reference Code Viewer Dialog Height must be greater than 0");
	}

	Dimension d = new Dimension(dialogWidth, dialogHeight);
	if (panel != null) {
		panel.setPreferredSize(d);
	}
}
 
Example 7
Source File: PostCommentFieldFactory.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Adjust the Automatic Comment display options if the associated options changed.
 * @param options the Display Options object that changed.
 * @param optionName the name of the property that changed.
 * @param oldValue the old value of the property.
 * @param newValue the new value of the property.
 */
private void adjustAutomaticCommentDisplayOptions(Options options, String optionName,
		Object oldValue, Object newValue) {
	if (optionName.equals(OptionsGui.COMMENT_AUTO.getColorOptionName())) {
		automaticCommentColor = (Color) newValue;
	}
	String automaticCommentStyleName = OptionsGui.COMMENT_AUTO.getStyleOptionName();
	if (optionName.equals(automaticCommentStyleName)) {
		automaticCommentStyle = options.getInt(automaticCommentStyleName, -1);
	}
}
 
Example 8
Source File: GoToQuery.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public GoToQuery(Navigatable navigatable, Plugin plugin, GoToService goToService,
		QueryData queryData, Address fromAddr, GoToServiceListener listener,
		NavigationOptions navigationOptions, TaskMonitor monitor) {

	this.navigatable = navigatable;
	this.queryData = queryData;
	this.plugin = plugin;
	this.goToService = goToService;
	this.navigationOptions = navigationOptions;
	Options opt = plugin.getTool().getOptions(PluginConstants.SEARCH_OPTION_NAME);

	if (!opt.contains(GhidraOptions.OPTION_SEARCH_LIMIT)) {
		opt.registerOption(GhidraOptions.OPTION_SEARCH_LIMIT,
			PluginConstants.DEFAULT_SEARCH_LIMIT, null,
			"The maximum number of search hits before stopping.");
	}
	this.maxHits =
		opt.getInt(GhidraOptions.OPTION_SEARCH_LIMIT, PluginConstants.DEFAULT_SEARCH_LIMIT);
	this.fromAddress = fromAddr;
	this.monitor = monitor;

	if (listener != null) {
		this.listener = listener;
	}
	else {
		this.listener = new DummyGoToServiceListener();
	}

	programs = getAllPrograms();
	tableModelListener = new GoToQueryThreadedTableModelListener();
}
 
Example 9
Source File: PropertyListMergeManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private Object getValue(Options options, String propertyName) {
	OptionType type = options.getType(propertyName);
	switch (type) {
		case BOOLEAN_TYPE:
			return options.getBoolean(propertyName, false) ? Boolean.TRUE : Boolean.FALSE;

		case DOUBLE_TYPE:
			return new Double(options.getDouble(propertyName, 0d));

		case INT_TYPE:
			return new Integer(options.getInt(propertyName, 0));

		case LONG_TYPE:
			return new Long(options.getLong(propertyName, 0L));

		case NO_TYPE:
			return null;

		case STRING_TYPE:
			return options.getString(propertyName, (String) null);

		case DATE_TYPE:
			return options.getDate(propertyName, (Date) null);

		default:
			return null;
	}
}
 
Example 10
Source File: GoToServicePlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
int getMaxHits() {
	Options opt = tool.getOptions(PluginConstants.SEARCH_OPTION_NAME);
	int maxSearchHits =
			opt.getInt(GhidraOptions.OPTION_SEARCH_LIMIT, PluginConstants.DEFAULT_SEARCH_LIMIT);

	return maxSearchHits;
}
 
Example 11
Source File: OperandFieldHelper.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Called when the fonts are first initialized or when one of the options
 * changes.  It looks up all the color settings and resets the its values.
 */
private void setOptions(Options options) {
	separatorAttributes.colorAttribute = options.getColor(
		OptionsGui.SEPARATOR.getColorOptionName(), OptionsGui.SEPARATOR.getDefaultColor());
	separatorAttributes.styleAttribute =
		options.getInt(OptionsGui.SEPARATOR.getStyleOptionName(), -1);
	scalarAttributes.colorAttribute = options.getColor(OptionsGui.CONSTANT.getColorOptionName(),
		OptionsGui.CONSTANT.getDefaultColor());
	scalarAttributes.styleAttribute =
		options.getInt(OptionsGui.CONSTANT.getStyleOptionName(), -1);
	variableRefAttributes.colorAttribute = options.getColor(
		OptionsGui.VARIABLE.getColorOptionName(), OptionsGui.VARIABLE.getDefaultColor());
	variableRefAttributes.styleAttribute =
		options.getInt(OptionsGui.VARIABLE.getStyleOptionName(), -1);
	addressAttributes.colorAttribute = options.getColor(OptionsGui.ADDRESS.getColorOptionName(),
		OptionsGui.ADDRESS.getDefaultColor());
	addressAttributes.styleAttribute =
		options.getInt(OptionsGui.ADDRESS.getStyleOptionName(), -1);
	externalRefAttributes.colorAttribute =
		options.getColor(OptionsGui.EXT_REF_RESOLVED.getColorOptionName(),
			OptionsGui.EXT_REF_RESOLVED.getDefaultColor());
	externalRefAttributes.styleAttribute =
		options.getInt(OptionsGui.EXT_REF_RESOLVED.getStyleOptionName(), -1);
	badRefAttributes.colorAttribute =
		options.getColor(OptionsGui.BAD_REF_ADDR.getColorOptionName(),
			OptionsGui.BAD_REF_ADDR.getDefaultColor());
	badRefAttributes.styleAttribute =
		options.getInt(OptionsGui.BAD_REF_ADDR.getStyleOptionName(), -1);
	registerAttributes.colorAttribute = options.getColor(
		OptionsGui.REGISTERS.getColorOptionName(), OptionsGui.REGISTERS.getDefaultColor());
	registerAttributes.styleAttribute =
		options.getInt(OptionsGui.REGISTERS.getStyleOptionName(), -1);

}
 
Example 12
Source File: AbstractSearchTableModel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public AbstractSearchTableModel(PluginTool tool, Program p, AddressSetView set,
		SearchOptions options) {

	super(TITLE, tool, p, null, true);
	this.tool = tool;
	this.set = set;
	this.options = options;
	Options opt = tool.getOptions(PluginConstants.SEARCH_OPTION_NAME);
	searchLimit = opt.getInt(GhidraOptions.OPTION_SEARCH_LIMIT, DEFAULT_SEARCH_LIMIT);
}
 
Example 13
Source File: EolCommentFieldFactory.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Adjust the Referenced Repeatable Comments display options if the associated options changed.
 *
 * @param options the Display Options object that changed.
 * @param optionName the name of the property that changed.
 * @param oldValue the old value of the property.
 * @param newValue the new value of the property.
 */
private void adjustRefRepeatDisplayOptions(Options options, String optionName, Object oldValue,
		Object newValue) {
	if (optionName.equals(OptionsGui.COMMENT_REF_REPEAT.getColorOptionName())) {
		refRepeatableCommentColor = (Color) newValue;
	}
	String refRepeatStyleName = OptionsGui.COMMENT_REF_REPEAT.getStyleOptionName();
	if (optionName.equals(refRepeatStyleName)) {
		refRepeatableCommentStyle = options.getInt(refRepeatStyleName, -1);
	}
}
 
Example 14
Source File: EolCommentFieldFactory.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Adjust the Repeatable Comment display options if the associated options changed.
 *
 * @param options the Display Options object that changed.
 * @param optionName the name of the property that changed.
 * @param oldValue the old value of the property.
 * @param newValue the new value of the property.
 */
private void adjustRepeatableDisplayOptions(Options options, String optionName, Object oldValue,
		Object newValue) {
	if (optionName.equals(OptionsGui.COMMENT_REPEATABLE.getColorOptionName())) {
		repeatableCommentColor = (Color) newValue;
	}
	String repeatableStyleName = OptionsGui.COMMENT_REPEATABLE.getStyleOptionName();
	if (optionName.equals(repeatableStyleName)) {
		repeatableCommentStyle = options.getInt(repeatableStyleName, -1);
	}
}
 
Example 15
Source File: BytesFieldFactory.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 * @param model the model that the field belongs to.
 * @param hsProvider the HightLightStringProvider.
 * @param displayOptions the Options for display properties.
 * @param fieldOptions the Options for field specific properties.
 */
private BytesFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
		Options displayOptions, Options fieldOptions) {
	super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);

	HelpLocation hl = new HelpLocation("CodeBrowserPlugin", "Bytes_Field");
	fieldOptions.getOptions(GROUP_TITLE).setOptionsHelpLocation(hl);

	fieldOptions.registerOption(DELIMITER_MSG, " ", hl,
		"String used to separate groups of bytes in the bytes field.");
	fieldOptions.registerOption(MAX_DISPLAY_LINES_MSG, 3, hl,
		"The maximum number of lines used to display bytes.");
	fieldOptions.registerOption(BYTE_GROUP_SIZE_MSG, 1, hl,
		"The number of bytes to group together without delimeters in the bytes field.");
	fieldOptions.registerOption(DISPLAY_UCASE_MSG, false, hl,
		"Displays the hex digits in upper case in the bytes field");
	fieldOptions.registerOption(REVERSE_INSTRUCTION_BYTE_ORDERING, false, hl,
		"Reverses the normal order of the bytes in the bytes field." +
			"  Only used for instructions in Little Endian format");
	fieldOptions.registerOption(DISPLAY_STRUCTURE_ALIGNMENT_BYTES_MSG, true, hl,
		"Display trailing alignment bytes in structures.");

	delim = fieldOptions.getString(DELIMITER_MSG, " ");
	maxDisplayLines = fieldOptions.getInt(MAX_DISPLAY_LINES_MSG, 3);
	byteGroupSize = fieldOptions.getInt(BYTE_GROUP_SIZE_MSG, 1);
	displayUpperCase = fieldOptions.getBoolean(DISPLAY_UCASE_MSG, false);
	reverseInstByteOrdering = fieldOptions.getBoolean(REVERSE_INSTRUCTION_BYTE_ORDERING, false);
	displayStructureAlignmentBytes =
		fieldOptions.getBoolean(DISPLAY_STRUCTURE_ALIGNMENT_BYTES_MSG, false);
}
 
Example 16
Source File: AutoAnalysisManager.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private static int getSharedThreadPoolSizeOption(PluginTool tool) {
	Options options = tool.getOptions("Auto Analysis");
	return options.getInt(OPTION_NAME_THREAD_USE, analysisSharedThreadPoolSize);
}
 
Example 17
Source File: CondenseFillerBytesAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void optionsChanged(Options options, Program program) {
	fillerValue = options.getString("Filler Value", fillerValue);
	minBytes = options.getInt("Minimum number of sequential bytes", minBytes);
}
 
Example 18
Source File: DecompilerCallConventionAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void optionsChanged(Options options, Program program) {
	decompilerTimeoutSecondsOption =
		options.getInt(OPTION_NAME_DECOMPILER_TIMEOUT_SECS, decompilerTimeoutSecondsOption);
}
 
Example 19
Source File: FindNoReturnFunctionsAnalyzer.java    From ghidra with Apache License 2.0 3 votes vote down vote up
@Override
public void optionsChanged(Options options, Program prog) {

	evidenceThresholdFunctions =
		options.getInt(OPTION_FUNCTION_NONRETURN_THRESHOLD, OPTION_DEFAULT_EVIDENCE_THRESHOLD);

	repairDamageEnabled = options.getBoolean(OPTION_NAME_REPAIR_DAMAGE, repairDamageEnabled);

	createBookmarksEnabled =
		options.getBoolean(OPTION_NAME_CREATE_BOOKMARKS, createBookmarksEnabled);

}
 
Example 20
Source File: AddressTableAnalyzer.java    From ghidra with Apache License 2.0 3 votes vote down vote up
@Override
public void optionsChanged(Options options, Program program) {

	if (minimumTableSize == -1) {
		calculateMinimumTableSize(program);
	}

	minimumTableSize = options.getInt(OPTION_NAME_MIN_TABLE_SIZE, minimumTableSize);

	tableAlignment = options.getInt(OPTION_NAME_TABLE_ALIGNMENT, tableAlignment);

	ptrAlignment = options.getInt(OPTION_NAME_PTR_ALIGNMENT, ptrAlignment);
	autoLabelTable = options.getBoolean(OPTION_NAME_AUTO_LABEL_TABLE, autoLabelTable);

	relocationGuideEnabled =
		options.getBoolean(OPTION_NAME_RELOCATION_GUIDE, relocationGuideEnabled);

	allowOffcutReferences =
		options.getBoolean(OPTION_NAME_ALLOW_OFFCUT_REFERENCES, allowOffcutReferences);

	minPointerAddress = options.getLong(OPTION_NAME_MIN_POINTER_ADDR, minPointerAddress);

	maxPointerDistance = options.getLong(OPTION_NAME_MAX_POINTER_DIFF, maxPointerDistance);

	createBookmarksEnabled =
		options.getBoolean(OPTION_NAME_CREATE_BOOKMARKS, createBookmarksEnabled);

}