ghidra.framework.options.Options Java Examples

The following examples show how to use ghidra.framework.options.Options. 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: PropertyListMergeManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Check the property names in the list; if values changed in both
 * places, then this is a conflict.
 * @param listName name of the property list
 */
private void checkValues(String listName) {
	Options myList = myProgram.getOptions(listName);
	Options resultList = resultProgram.getOptions(listName);
	Options origList = originalProgram.getOptions(listName);

	List<String> myNameList = myList.getOptionNames();
	List<String> resultNameList = resultList.getOptionNames();

	for (int i = 0; i < myNameList.size(); i++) {
		String name = myNameList.get(i);
		if (resultNameList.contains(name)) {
			updateValue(myList, resultList, origList, name);
		}
		else {
			// not in the result
			checkForAddedProperty(myList, resultList, origList, name);
		}
	}
	checkDeletedProperties(resultList, origList, myNameList, resultNameList,
		origList.getOptionNames());
}
 
Example #2
Source File: MemSearchHexTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testHighlightGroupSize() throws Exception {
	Options opt = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS);
	opt.setInt(BytesFieldFactory.BYTE_GROUP_SIZE_MSG, 3);
	opt.setString(BytesFieldFactory.DELIMITER_MSG, "#@#");

	setValueText("fd ff ff");
	pressSearchAllButton();

	waitForSearch("Search Memory - ", 1);

	Highlight[] h = getByteHighlights(addr(0x10035f8), "b930fd#@#ffff");
	assertEquals(1, h.length);
	assertEquals(4, h[0].getStart());
	assertEquals(12, h[0].getEnd());

}
 
Example #3
Source File: PreCommentMarkupType.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public Options convertOptionsToForceApplyOfMarkupItem(VTMarkupItemApplyActionType applyAction,
		ToolOptions applyOptions) {
	ToolOptions options = applyOptions.copy();
	switch (applyAction) {
		case ADD:
			options.setEnum(VTOptionDefines.PRE_COMMENT, CommentChoices.APPEND_TO_EXISTING);
			break;
		case ADD_AS_PRIMARY:
			throw new IllegalArgumentException(getDisplayName() +
				" markup items cannot perform an Add As Primary action.");
		case REPLACE_DEFAULT_ONLY:
			throw new IllegalArgumentException(getDisplayName() +
				" markup items cannot perform a Replace Default Only action.");
		case REPLACE:
			options.setEnum(VTOptionDefines.PRE_COMMENT, CommentChoices.OVERWRITE_EXISTING);
			break;
	}
	return options;
}
 
Example #4
Source File: PlateFieldFactory.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 PlateFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
			Options displayOptions, Options fieldOptions) {
		super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
		init(fieldOptions);

//		showCasePlates = fieldOptions.getBoolean(name, SHOW_CASE_PLATES_OPTION, false);
		isWordWrap = fieldOptions.getBoolean(ENABLE_WORD_WRAP_MSG, false);
		showExternalPlates = fieldOptions.getBoolean(SHOW_EXT_ENTRY_PLATES_OPTION, false);
		showFunctionPlates = fieldOptions.getBoolean(SHOW_FUNCTION_PLATES_OPTION, true);
		showSubroutinePlates = fieldOptions.getBoolean(SHOW_SUBROUTINE_PLATES_OPTION, true);
		showTransitionPlates = fieldOptions.getBoolean(SHOW_TRANSITION_PLATES_OPTION, false);
		nLinesBeforeFunctions = fieldOptions.getInt(LINES_BEFORE_FUNCTIONS_OPTION, 0);
		nLinesBeforeLabels = fieldOptions.getInt(LINES_BEFORE_LABELS_OPTION, 1);
		nLinesBeforePlates = fieldOptions.getInt(LINES_BEFORE_PLATES_OPTION, 0);

		showExternalFunctionPointerPlates = fieldOptions.getBoolean(
			ListingModel.DISPLAY_EXTERNAL_FUNCTION_POINTER_OPTION_NAME, true);
		showNonExternalFunctionPointerPlates = fieldOptions.getBoolean(
			ListingModel.DISPLAY_NONEXTERNAL_FUNCTION_POINTER_OPTION_NAME, false);

	}
 
Example #5
Source File: AnalysisRecipeEditor.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void updateOptionsPanel() {
	analyzerOptionsPanel.removeAll();
	analyzerOptionsPanel.invalidate();
	if (selectedAnalyzer == null) {
		return;
	}
	Options options = recipe.getOptions(selectedAnalyzer);
	List<String> optionNames = options.getLeafOptionNames();
	if (optionNames.isEmpty()) {
		analyzerOptionsPanel.add(noOptionsPanel);
		return;
	}
	ScrollableOptionsEditor editorPanel =
		new ScrollableOptionsEditor("Options For " + selectedAnalyzer.getName(), options,
			optionNames, new EditorStateFactory());
	editorPanel.setBorder(BorderFactory.createEmptyBorder());
	analyzerOptionsPanel.add(editorPanel);
}
 
Example #6
Source File: ReferenceDecompilerHover.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeOptions() {
	options = tool.getOptions(GhidraOptions.CATEGORY_DECOMPILER_POPUPS);

	options.setOptionsHelpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "MouseHover"));
	HelpLocation help = new HelpLocation(HelpTopics.CODE_BROWSER, "ReferenceHover");
	options.getOptions(NAME).setOptionsHelpLocation(help);

	options.registerOption(NAME, true, null, DESCRIPTION);

	options.registerOption(NAME + Options.DELIMITER + "Dialog Height", 400, help,
		"Height of the popup window");
	options.registerOption(NAME + Options.DELIMITER + "Dialog Width", 600, help,
		"Width of the popup window");

	setOptions(options, NAME);
	options.addOptionsChangeListener(this);
}
 
Example #7
Source File: PdbAnalyzer.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {

	String pdbStorageLocation =
		Preferences.getProperty(PdbParser.PDB_STORAGE_PROPERTY, null, true);
	if (pdbStorageLocation != null) {
		File pdbDirectory = new File(pdbStorageLocation);

		if (pdbDirectory.isDirectory()) {
			options.registerOption(SYMBOLPATH_OPTION_NAME, pdbStorageLocation, null,
				SYMBOLPATH_OPTION_DESCRIPTION);
		}
	}
	else {
		options.registerOption(SYMBOLPATH_OPTION_NAME, SYMBOLPATH_OPTION_DEFAULT_VALUE, null,
			SYMBOLPATH_OPTION_DESCRIPTION);
	}

	options.registerOption(OPTION_NAME_INCLUDE_PE_PDB_PATH, includePeSpecifiedPdbPath, null,
		OPTION_DESCRIPTION_INCLUDE_PE_PDB_PATH);
}
 
Example #8
Source File: MachoProgramBuilder.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void processProgramDescription() {
	Options props = program.getOptions(Program.PROGRAM_INFO);
	props.setString("Mach-O File Type",
		MachHeaderFileTypes.getFileTypeName(machoHeader.getFileType()));
	props.setString("Mach-O File Type Description",
		MachHeaderFileTypes.getFileTypeDescription(machoHeader.getFileType()));
	List<String> flags = MachHeaderFlags.getFlags(machoHeader.getFlags());
	for (int i = 0; i < flags.size(); ++i) {
		props.setString("Mach-O Flag " + i, flags.get(i));
	}

	List<SubUmbrellaCommand> umbrellas = machoHeader.getLoadCommands(SubUmbrellaCommand.class);
	for (int i = 0; i < umbrellas.size(); ++i) {
		props.setString("Mach-O Sub-umbrella " + i,
			umbrellas.get(i).getSubUmbrellaFrameworkName().getString());
	}

	List<SubFrameworkCommand> frameworks =
		machoHeader.getLoadCommands(SubFrameworkCommand.class);
	for (int i = 0; i < frameworks.size(); ++i) {
		props.setString("Mach-O Sub-framework " + i,
			frameworks.get(i).getUmbrellaFrameworkName().getString());
	}
}
 
Example #9
Source File: ConstantPropagationAnalyzer.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
	options.registerOption(OPTION_NAME, checkParamRefsOption, null, OPTION_DESCRIPTION);
	options.registerOption(STORED_OPTION_NAME, checkStoredRefsOption, null,
		STORED_OPTION_DESCRIPTION);
	options.registerOption(TRUSTWRITEMEM_OPTION_NAME, trustWriteMemOption, null,
		TRUSTWRITEMEM_OPTION_DESCRIPTION);
	options.registerOption(MAXTHREADCOUNT_OPTION_NAME, maxThreadCount, null,
		MAXTHREADCOUNT_OPTION_DESCRIPTION);

	options.registerOption(MINKNOWNREFADDRESS_OPTION_NAME, minStoreLoadRefAddress, null,
		MINKNOWNREFADDRESS_OPTION_DESCRIPTION);

	long size = program.getAddressFactory().getDefaultAddressSpace().getSize();
	minSpeculativeRefAddress = size * 16;
	options.registerOption(MINSPECULATIVEREFADDRESS_OPTION_NAME, minSpeculativeRefAddress, null,
		MINSPECULATIVEREFADDRESS_OPTION_DESCRIPTION);
	
	maxSpeculativeRefAddress = size * 8;
	options.registerOption(MAXSPECULATIVEREFADDRESS_OPTION_NAME, maxSpeculativeRefAddress, null,
		MAXSPECULATIVEREFADDRESS_OPTION_DESCRIPTION);
}
 
Example #10
Source File: RegisterFieldFactory.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private RegisterFieldFactory(FieldFormatModel model, HighlightProvider highlightProvider,
		Options displayOptions, Options fieldOptions) {
	super(FIELD_NAME, model, highlightProvider, displayOptions, fieldOptions);
	regComp = new RegComparator();
	initDisplayOptions();

	fieldOptions.registerOption(DISPLAY_HIDDEN_REGISTERS_OPTION_NAME, false, null,
		"Shows/hides context registers");
	fieldOptions.registerOption(DISPLAY_DEFAULT_REGISTER_VALUES_OPTION_NAME, false, null,
		"Shows/hides default register values");
	regColor =
		displayOptions.getColor(OptionsGui.REGISTERS.getColorOptionName(), getDefaultColor());

	showHiddenRegisters = fieldOptions.getBoolean(DISPLAY_HIDDEN_REGISTERS_OPTION_NAME, false);
	showDefaultValues =
		fieldOptions.getBoolean(DISPLAY_DEFAULT_REGISTER_VALUES_OPTION_NAME, false);
}
 
Example #11
Source File: AnalysisScheduler.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public void registerOptions(Options options) {
	Options analyzerOptions = options.getOptions(analyzer.getName());

	boolean defaultEnable = analyzer.getDefaultEnablement(analysisMgr.getProgram());

	boolean overrideEnable = getEnableOverride(defaultEnable);

	// only warn when option registered
	if (defaultEnable != overrideEnable) {
		Msg.warn(this,
			"Analyzer \'" + analyzer.getName() + "\' for " +
				analysisMgr.getProgram().getName() + " " +
				(overrideEnable ? "enabled" : "disabled") + " by PSPEC file override");
	}

	options.registerOption(analyzer.getName(),
		overrideEnable, null,
		analyzer.getDescription());

	analyzer.registerOptions(analyzerOptions, analysisMgr.getProgram());
}
 
Example #12
Source File: PreCommentFieldFactory.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void fieldOptionsChanged(Options options, String optionName, Object oldValue,
		Object newValue) {

	if (optionName.equals(FLAG_FUNCTION_ENTRY_OPTION)) {
		flagFunctionEntry = ((Boolean) newValue).booleanValue();
		model.update();
	}
	else if (optionName.equals(FLAG_SUBROUTINE_ENTRY_OPTION)) {
		flagSubroutineEntry = ((Boolean) newValue).booleanValue();
		model.update();
	}
	else if (optionName.equals(ENABLE_WORD_WRAP_MSG)) {
		isWordWrap = ((Boolean) newValue).booleanValue();
	}
	else if (optionName.equals(ENABLE_ALWAYS_SHOW_AUTOMATIC_MSG)) {
		alwaysShowAutomatic = ((Boolean) newValue).booleanValue();
	}
}
 
Example #13
Source File: MnemonicFieldFactory.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 hsProvider the HightLightStringProvider.
 * @param displayOptions the Options for display properties.
 * @param fieldOptions the Options for field specific properties.
 */
private MnemonicFieldFactory(FieldFormatModel model, HighlightProvider hsProvider,
		Options displayOptions, ToolOptions fieldOptions) {
	super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);

	overrideColor = displayOptions.getColor(OVERRIDE_COLOR_OPTION, OVERRIDE_COLOR);

	HelpLocation hl = new HelpLocation("CodeBrowserPlugin", "Mnemonic_Field");
	fieldOptions.getOptions("Mnemonic Fields").setOptionsHelpLocation(hl);

	fieldOptions.registerOption(SHOW_UNDERLINE_FOR_REFERENCES, true, hl,
		"Shows an underline on mnemonic " + "fields that have references.");
	underliningEnabled = fieldOptions.getBoolean(SHOW_UNDERLINE_FOR_REFERENCES, true);

	// Create code unit format and associated options - listen for changes
	codeUnitFormat = new BrowserCodeUnitFormat(fieldOptions, true);
	codeUnitFormat.addChangeListener(codeUnitFormatListener);
}
 
Example #14
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 #15
Source File: ReferenceListingHover.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeOptions() {
	options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_POPUPS);

	options.setOptionsHelpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "MouseHover"));
	HelpLocation help = new HelpLocation(HelpTopics.CODE_BROWSER, "ReferenceHover");
	options.getOptions(NAME).setOptionsHelpLocation(help);

	options.registerOption(NAME, true, help, DESCRIPTION);

	options.registerOption(NAME + Options.DELIMITER + "Dialog Height", 400, help,
		"Height of the popup window");
	options.registerOption(NAME + Options.DELIMITER + "Dialog Width", 600, help,
		"Width of the popup window");

	setOptions(options, NAME);
	options.addOptionsChangeListener(this);
}
 
Example #16
Source File: AutoAnalysisWorkerTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public boolean analysisWorkerCallback(Program p, Object workerContext,
		TaskMonitor monitor) {

	// Can't invoke action since we are in background task here

	Options list = p.getOptions("TEST");
	assertTrue("Higher priorty analysis task failed to run first",
		list.getBoolean("p0", false));
	assertTrue("Lower priorty analysis task failed to run last",
		!list.getBoolean("p1", false));

	cb.goToField(addr("0x1001100"), "Operands", 0, 0);
	assertNull(p.getListing().getFunctionAt(addr("0x100110a")));

	DisassembleCommand cmd = new DisassembleCommand(addr("0x1001100"), null, true);
	cmd.applyTo(p, monitor);

	return true;
}
 
Example #17
Source File: GhidraScript.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Allows user to set one analysis option by passing in the analysis option to
 * be changed and the new value of that option. This method does the work of
 * converting the option value to its actual object type (if needed).
 *
 * @param program  the program for which analysis options should be set
 * @param optionName  the name of the option to be set
 * @param optionValue  the new value of the option
 */
public void setAnalysisOption(Program program, String optionName, String optionValue) {
	Options options = program.getOptions(Program.ANALYSIS_PROPERTIES);
	String errorMsg = setAnalysisOption(options, optionName, optionValue);

	if (errorMsg.length() > 0) {
		if (isRunningHeadless()) {
			Msg.error(this, errorMsg);
		}
		else {
			MultiLineMessageDialog dialog = new MultiLineMessageDialog("Analysis Options",
				"Ghidra encountered error(s) when attempting to set analysis options.",
				errorMsg, MultiLineMessageDialog.WARNING_MESSAGE, false);
			DockingWindowManager.showDialog(null, dialog);
		}
	}
}
 
Example #18
Source File: OperandFieldFactoryTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testOffcutStringDynamicLabelReference_ShowOffcutInfoOptionOff() {
	//
	// Use options to hide the offcut info for a dynamic string reference.  By default the
	// option is on (unless we change that).  This tests the 'off' condition.
	//

	ToolOptions options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS);
	options.setBoolean(
		GhidraOptions.OPERAND_GROUP_TITLE + Options.DELIMITER + "Show Offcut Information",
		false);

	assertTrue(cb.goToField(addr("1001000"), OperandFieldFactory.FIELD_NAME, 0, 1));
	ListingTextField tf = (ListingTextField) cb.getCurrentField();

	assertEquals("s_defgh", tf.getText());
}
 
Example #19
Source File: ImporterUtilities.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Ensure that a {@link Program}'s metadata includes its import origin.
 *
 * @param program imported {@link Program} to modify
 * @param fsrl {@link FSRL} of the import source.
 * @param monitor {@link TaskMonitor} to use when accessing filesystem stuff.
 * @throws CancelledException if user cancels
 * @throws IOException if IO error
 */
public static void setProgramProperties(Program program, FSRL fsrl, TaskMonitor monitor)
		throws CancelledException, IOException {

	Objects.requireNonNull(monitor);

	int id = program.startTransaction("setImportProperties");
	try {
		fsrl = FileSystemService.getInstance().getFullyQualifiedFSRL(fsrl, monitor);

		Options propertyList = program.getOptions(Program.PROGRAM_INFO);
		propertyList.setString(ProgramMappingService.PROGRAM_SOURCE_FSRL, fsrl.toString());
		String md5 = program.getExecutableMD5();
		if ((md5 == null || md5.isEmpty()) && fsrl.getMD5() != null) {
			program.setExecutableMD5(fsrl.getMD5());
		}
	}
	finally {
		program.endTransaction(id, true);
	}
	if (program.canSave()) {
		program.save("Added import properties", monitor);
	}
}
 
Example #20
Source File: PropertyListMergeManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * The property was not in the latest program; if the value changed
 * from the original, set the value in the result program.
 * @param myList property list from source program
 * @param resultList property list from result program
 * @param origList property list from the original checked out program
 * @param propertyName name of the property
 */
private void checkForAddedProperty(Options myList, Options resultList, Options origList,
		String propertyName) {

	Object myValue = getValue(myList, propertyName);
	Object origValue = getValue(origList, propertyName);

	if (!myValue.equals(origValue)) {
		setValue(resultList, propertyName, myList.getType(propertyName), myValue);
		currentMonitor.setProgress(++progressIndex);
	}

}
 
Example #21
Source File: TestEnv.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void setAutoSaveEnabled(final FrontEndTool frontEndToolInstance,
		final boolean enabled) {
	AbstractGenericTest.runSwing(() -> {
		Options options = frontEndToolInstance.getOptions(ToolConstants.TOOL_OPTIONS);
		options.setBoolean(FrontEndTool.AUTOMATICALLY_SAVE_TOOLS, enabled);
	});
}
 
Example #22
Source File: PcodeFieldFactory.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 setColors(Options options) {
	formatter.setColor(
		options.getColor(OptionsGui.ADDRESS.getColorOptionName(),
			OptionsGui.ADDRESS.getDefaultColor()),
		options.getColor(OptionsGui.REGISTERS.getColorOptionName(),
			OptionsGui.REGISTERS.getDefaultColor()),
		options.getColor(OptionsGui.CONSTANT.getColorOptionName(),
			OptionsGui.CONSTANT.getDefaultColor()),
		options.getColor(OptionsGui.LABELS_LOCAL.getColorOptionName(),
			OptionsGui.LABELS_LOCAL.getDefaultColor()));
	formatter.setFontMetrics(getMetrics());
}
 
Example #23
Source File: AcceptMatchTask.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public AcceptMatchTask(VTController controller, List<VTMatch> matches) {
	super("Accept Matches", controller.getSession());
	this.controller = controller;
	this.matches = matches;

	Options options = controller.getOptions();
	doApplyFunctionNames = options.getBoolean(APPLY_FUNCTION_NAME_ON_ACCEPT, true);
	doApplyDataNames = options.getBoolean(APPLY_DATA_NAME_ON_ACCEPT, true);
}
 
Example #24
Source File: FieldNameFieldFactory.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void fieldOptionsChanged(Options options, String optionName, Object oldValue,
		Object newValue) {
	super.fieldOptionsChanged(options, optionName, oldValue, newValue);

	if (options.getName().equals(GhidraOptions.CATEGORY_BROWSER_FIELDS)) {
		if (optionName.equals(ARRAY_INDEX_FORMAT_NAME)) {
			format = (IndexFormat) newValue;
			model.update();
		}
	}
}
 
Example #25
Source File: DataTypeArchiveUtility.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * get a list of known applicable .GDT archives for the given program.
 * 
 * @param program - program to lookup archives for
 * @return list of archives that could apply to this program
 */
public static List<String> getArchiveList(Program program) {
	List<String> list = new ArrayList<String>();

	Options props = program.getOptions(Program.PROGRAM_INFO);
	String format = props.getString("Executable Format", "");

	int size = program.getAddressFactory().getDefaultAddressSpace().getSize();

	if (format.equals(PeLoader.PE_NAME) ||
		(format.equals(CoffLoader.COFF_NAME) && isVisualStudio(program))) {
		// TODO: add in win7/win10
		if (size == 64) {
			list.add("windows_vs12_64");
		}
		else {
			list.add("windows_vs12_32");
		}
	}
	else if (format.equals(MachoLoader.MACH_O_NAME)) {
		// list.add("Cocoa");  // no more cocoa puffs for you
		// TODO: should we have a 64/32 version?
		// TODO: multiple OSX versions
		list.add("mac_osx");
	}
	else if (size == 64) {
		list.add("generic_clib_64");
	}
	// everyone else gets generic clib that was parsed as 32 bit wordsize
	else {
		list.add("generic_clib");
	}
	return list;
}
 
Example #26
Source File: BytesFieldFactory.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void setDisplayLines(int n, Options options) {
	if (n < 1) {
		n = 1;
		options.setInt(MAX_DISPLAY_LINES_MSG, 1);
	}
	maxDisplayLines = n;
}
 
Example #27
Source File: StackVariableAnalyzer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
	options.registerOption(GhidraLanguagePropertyKeys.USE_NEW_FUNCTION_STACK_ANALYSIS,
		!useOldStackAnalysisByDefault(program), null,
		"Use General Stack Reference Propogator (This works best on most processors)");

	options.registerOption("Create Local Variables", doLocalAnalysis, null,
		"Create Function Local stack variables and references");

	options.registerOption("Create Param Variables", doParameterAnalysis, null,
		"Create Function Parameter stack variables and references");
}
 
Example #28
Source File: KeyBindingsPanel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void processKeyBindingsFromOptions(Options keyBindingOptions) {
	if (keyBindingOptions == null) {
		return;
	}

	Map<String, KeyStroke> keyBindingsMap = createActionNameToKeyStrokeMap(keyBindingOptions);
	if (keyBindingsMap == null) {
		return;
	}

	boolean changes = false;

	// add each new key stroke mapping
	Iterator<String> iterator = keyBindingsMap.keySet().iterator();
	while (iterator.hasNext()) {

		String name = iterator.next();
		KeyStroke keyStroke = keyBindingsMap.get(name);
		keyStroke = KeyBindingUtils.validateKeyStroke(keyStroke);

		// prevent non-existing keybindings from being added to Ghidra (this can happen
		// when actions exist in the imported bindings, but have been removed from
		// Ghidra
		if (!keyStrokesByFullName.containsKey(name)) {
			continue;
		}

		// check to see if the key stroke results in a change and
		// record that value
		changes |= processKeyStroke(name, keyStroke);
	}

	if (changes) {
		changesMade(true);
	}
}
 
Example #29
Source File: Motorola68KAnalyzer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void optionsChanged(Options options, Program program) {
	super.optionsChanged(options, program);

	options.registerOption(SWITCH_OPTION_NAME, recoverSwitchTables, null,
		SWITCH_OPTION_DESCRIPTION);
	recoverSwitchTables = options.getBoolean(SWITCH_OPTION_NAME, recoverSwitchTables);
}
 
Example #30
Source File: KeyBindingsPanel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public KeyBindingsPanel(PluginTool tool, Options options) {
	this.tool = tool;
	this.options = options;

	createPanelComponents();
	createActionMap();
	addListeners();
}