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

The following examples show how to use ghidra.framework.options.Options#registerOption() . 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: OptionsBasedDataTypeDisplayOptions.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public OptionsBasedDataTypeDisplayOptions(Options options) {
		this.options = options;

// TODO
//		fieldOptions.setHelpLocation(NAMESPACE_OPTIONS, new HelpLocation("CodeBrowserPlugin",
//				"Operands_Field"));

		// register the options
		options.registerOption(DISPLAY_ABBREVIATED_DEFAULT_LABELS, false, null,
			"Uses a shortened form of the " +
				"label name for dynamic String data types in the display of " +
				"operand references (e.g., STR_01234567)");
		options.registerOption(MAXIMUM_DEFAULT_LABEL_LENGTH,
			DataTypeDisplayOptions.MAX_LABEL_STRING_LENGTH, null,
			"Sets the maximumn number of characters from a String to include in dynamic " +
				"String labels in operand references");
	}
 
Example 2
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 3
Source File: GhidraProgramUtilities.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the analyzed flag to the specified value.
 * @param program the program to set property
 * @param analyzed the analyzed flag
 */
public static void setAnalyzedFlag(Program program, boolean analyzed) {
	Options options = program.getOptions(Program.PROGRAM_INFO);

	// once the program is analyzed, register the value, so it won't keep writing it to the database.
	if (analyzed && !options.isRegistered(Program.ANALYZED)) {
		options.registerOption(Program.ANALYZED, false, null,
			"Indicates if program has been analyzed");
	}
	int transactionID = program.startTransaction(Program.ANALYZED);
	try {
		options.setBoolean(Program.ANALYZED, analyzed);
	}
	finally {
		program.endTransaction(transactionID, true);
	}
}
 
Example 4
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 5
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 6
Source File: SharedReturnAnalyzer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
	HelpLocation helpLocation = new HelpLocation("AutoAnalysisPlugin",
		"Auto_Analysis_Option_Instructions");

	options.registerOption(OPTION_NAME_ASSUME_CONTIGUOUS_FUNCTIONS,
		OPTION_DEFAULT_ASSUME_CONTIGUOUS_FUNCTIONS_ENABLED, helpLocation,
		OPTION_DESCRIPTION_ASSUME_CONTIGUOUS_FUNCTIONS);

	options.registerOption(OPTION_NAME_CONSIDER_CONDITIONAL_BRANCHES_FUNCTIONS,
		OPTION_DEFAULT_CONSIDER_CONDITIONAL_BRANCHES_ENABLED, helpLocation,
		OPTION_DESCRIPTION_CONSIDER_CONDITIONAL_BRANCHES_FUNCTIONS);
}
 
Example 7
Source File: DWARFAnalyzer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
	options.registerOption(OPTION_IMPORT_DATATYPES, importOptions.isImportDataTypes(), null,
		OPTION_IMPORT_DATATYPES_DESC);

	options.registerOption(OPTION_PRELOAD_ALL_DIES, importOptions.isPreloadAllDIEs(), null,
		OPTION_PRELOAD_ALL_DIES_DESC);

	options.registerOption(OPTION_IMPORT_FUNCS, importOptions.isImportFuncs(), null,
		OPTION_IMPORT_FUNCS_DESC);

	options.registerOption(OPTION_OUTPUT_DWARF_DIE_INFO, importOptions.isOutputDIEInfo(), null,
		OPTION_OUTPUT_DWARF_DIE_INFO_DESC);

	options.registerOption(OPTION_OUTPUT_LEXICAL_BLOCK_COMMENTS,
		importOptions.isOutputLexicalBlockComments(), null,
		OPTION_OUTPUT_LEXICAL_BLOCK_COMMENTS_DESC);

	options.registerOption(OPTION_OUTPUT_INLINE_FUNC_COMMENTS,
		importOptions.isOutputInlineFuncComments(), null,
		OPTION_OUTPUT_INLINE_FUNC_COMMENTS_DESC);

	options.registerOption(OPTION_OUTPUT_SOURCE_INFO,
		importOptions.isOutputSourceLocationInfo(), null, OPTION_OUTPUT_SOURCE_INFO_DESC);

	options.registerOption(OPTION_IMPORT_LIMIT_DIE_COUNT,
		importOptions.getImportLimitDIECount(), null, OPTION_IMPORT_LIMIT_DIE_COUNT_DESC);

	options.registerOption(OPTION_NAME_LENGTH_CUTOFF, importOptions.getNameLengthCutoff(), null,
		OPTION_NAME_LENGTH_CUTOFF_DESC);

	options.registerOption(OPTION_COPY_ANON_TYPES, importOptions.isCopyRenameAnonTypes(), null,
		OPTION_COPY_ANON_TYPES_DESC);

	options.registerOption(OPTION_OUTPUT_FUNC_SIGS, importOptions.isCreateFuncSignatures(),
		null, OPTION_OUTPUT_FUNC_SIGS_DESC);
}
 
Example 8
Source File: DNLayoutOptions.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void registerOptions(Options options) {

	HelpLocation help = new HelpLocation(OWNER, HELP_ANCHOR);

	options.registerOption(USE_EDGE_ROUTING_AROUND_VERTICES_KEY, useEdgeRoutingAroundVertices,
		help, USE_EDGE_ROUTING_AROUND_VERTICES_DESCRIPTION);
}
 
Example 9
Source File: TurnOnLanguage.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected void run() throws Exception {
	Options decompilerPropertyList = currentProgram.getOptions(BasicCompilerSpec.DECOMPILER_PROPERTY_LIST_NAME);
	decompilerPropertyList.registerOption(
		BasicCompilerSpec.DECOMPILER_OUTPUT_LANGUAGE,
		BasicCompilerSpec.DECOMPILER_OUTPUT_DEF,
		null,
		BasicCompilerSpec.DECOMPILER_OUTPUT_DESC);
}
 
Example 10
Source File: ProgramDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void propertiesRestore() {
	Options pl = getOptions(PROGRAM_INFO);
	boolean origChangeState = changed;
	pl.registerOption(EXECUTABLE_PATH, UNKNOWN, null, "Original import path of program image");
	pl.registerOption(EXECUTABLE_FORMAT, UNKNOWN, null, "Original program image format");
	pl.registerOption(CREATED_WITH_GHIDRA_VERSION, "3.0 or earlier", null,
		"Version of Ghidra used to create this program.");
	pl.registerOption(DATE_CREATED, JANUARY_1_1970, null, "Date this program was created");
	changed = origChangeState;
}
 
Example 11
Source File: MipsAddressAnalyzer.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(OPTION_NAME_SWITCH_TABLE, OPTION_DEFAULT_SWITCH_TABLE, null,
		OPTION_DESCRIPTION_SWITCH_TABLE);

	options.registerOption(OPTION_NAME_MARK_DUAL_INSTRUCTION,
		OPTION_DEFAULT_MARK_DUAL_INSTRUCTION, null, OPTION_DESCRIPTION_MARK_DUAL_INSTRUCTION);

	options.registerOption(OPTION_NAME_ASSUME_T9_ENTRY, OPTION_DEFAULT_ASSUME_T9_ENTRY, null,
		OPTION_DESCRIPTION_ASSUME_T9_ENTRY);

	options.registerOption(OPTION_NAME_RECOVER_GP, OPTION_DEFAULT_RECOVER_GP, null,
		OPTION_DESCRIPTION_RECOVER_GP);

	trySwitchTables = options.getBoolean(OPTION_NAME_SWITCH_TABLE, OPTION_DEFAULT_SWITCH_TABLE);

	markupDualInstructionOption = options.getBoolean(OPTION_NAME_MARK_DUAL_INSTRUCTION,
		OPTION_DEFAULT_MARK_DUAL_INSTRUCTION);

	assumeT9EntryAddress =
		options.getBoolean(OPTION_NAME_ASSUME_T9_ENTRY, OPTION_DEFAULT_ASSUME_T9_ENTRY);

	discoverGlobalGPSetting =
		options.getBoolean(OPTION_NAME_RECOVER_GP, OPTION_DEFAULT_RECOVER_GP);
}
 
Example 12
Source File: ApplyDataArchiveAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
	options.registerOption(OPTION_NAME_CREATE_BOOKMARKS, createBookmarksEnabled, null,
		OPTION_DESCRIPTION_CREATE_BOOKMARKS);
}
 
Example 13
Source File: DecompilerSwitchAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
	options.registerOption(OPTION_NAME_DECOMPILER_TIMEOUT_SECS, decompilerTimeoutSecondsOption,
		null, OPTION_DESCRIPTION_DECOMPILER_TIMEOUT_SECS);
}
 
Example 14
Source File: AnalyzeStackRefsAction.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
protected void actionPerformed(ListingActionContext context) {
	// get the entry points for all the functions in the current selection/location
	Iterator<Function> iter = funcPlugin.getFunctions(context);
	if (iter.hasNext() == false) {
		String message = "No function at current location";
		ProgramSelection selection = context.getSelection();
		if (selection != null) {
			message = "No functions within current selection";
		}

		funcPlugin.getTool().setStatusInfo("Analyze Stack: " + message);
		return;
	}
	AddressSet funcSet = new AddressSet();
	while (iter.hasNext()) {
		Function func = iter.next();
		funcSet.addRange(func.getEntryPoint(), func.getEntryPoint());
	}

	boolean doNewStackAnalysis = true;
	boolean doLocalAnalysis = true;
	boolean doParameterAnalysis = true;

	Program program = context.getProgram();

	// TODO: THIS MAY NOT BE THE BEST WAY TO get the options to agree with the analysis options!  Advise.
	Options options = program.getOptions(Program.ANALYSIS_PROPERTIES).getOptions("Stack");
	options.registerOption(GhidraLanguagePropertyKeys.USE_NEW_FUNCTION_STACK_ANALYSIS,
		doNewStackAnalysis, 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");
	doNewStackAnalysis = options.getBoolean(
		GhidraLanguagePropertyKeys.USE_NEW_FUNCTION_STACK_ANALYSIS, doNewStackAnalysis);
	doLocalAnalysis = options.getBoolean("Create Local Variables", doLocalAnalysis);

	doParameterAnalysis = options.getBoolean("Create Param Variables", doParameterAnalysis);

	BackgroundCommand cmd = null;
	if (doNewStackAnalysis) {
		cmd = new NewFunctionStackAnalysisCmd(funcSet, doParameterAnalysis, doLocalAnalysis,
			true);
	}
	else {
		cmd = new FunctionStackAnalysisCmd(funcSet, doParameterAnalysis, doLocalAnalysis, true);
	}
	funcPlugin.execute(program, cmd);
}
 
Example 15
Source File: NoReturnFunctionAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
	options.registerOption(OPTION_NAME_CREATE_BOOKMARKS, createBookmarksEnabled, null,
		OPTION_DESCRIPTION_CREATE_BOOKMARKS);

}
 
Example 16
Source File: GCAnalyzer.java    From Ghidra-GameCube-Loader with Apache License 2.0 4 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
    options.registerOption(GCAnalyzer.SEARCH_SDA_REGISTERS_OPTION, OptionType.BOOLEAN_TYPE, true, null, "");
    options.registerOption(GCAnalyzer.SEARCH_GQR_REGISTERS_OPTION, OptionType.BOOLEAN_TYPE, true, null, "");
}
 
Example 17
Source File: WindowsResourceReferenceAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
	options.registerOption(OPTION_NAME_CREATE_BOOKMARKS, createBookmarksEnabled, null,
		OPTION_DESCRIPTION_CREATE_BOOKMARKS);

}
 
Example 18
Source File: AutoAnalysisManager.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void initializeToolOptions(PluginTool tool) {
	Options options = tool.getOptions("Auto Analysis");
	options.registerOption(OPTION_NAME_THREAD_USE, analysisSharedThreadPoolSize, null,
		OPTION_DESCRIPTION_THREAD_USE);
	analysisSharedThreadPoolSize = getSharedThreadPoolSizeOption(tool);
}
 
Example 19
Source File: AggressiveInstructionFinderAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
	options.registerOption(OPTION_NAME_CREATE_BOOKMARKS, createBookmarksEnabled, null,
		OPTION_DESCRIPTION_CREATE_BOOKMARKS);

}
 
Example 20
Source File: ScalarOperandAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void registerOptions(Options options, Program program) {
	options.registerOption(OPTION_NAME_RELOCATION_GUIDE, relocationGuideEnabled, null,
		OPTION_DESCRIPTION_RELOCATION_GUIDE);

}