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

The following examples show how to use ghidra.framework.options.Options#removeOption() . 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: ProgramDataTypeManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void removeOldFileNameList() {
	if (upgrade) {
		Options options = program.getOptions(Program.PROGRAM_INFO);
		if (options.contains(OLD_DT_ARCHIVE_FILENAMES)) {
			options.removeOption(OLD_DT_ARCHIVE_FILENAMES);
		}
	}
}
 
Example 2
Source File: PropertyListMergeManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Delete the properties
 * @param latestList
 * @param myNames
 * @param latestNames
 * @param origNames
 */
private void checkDeletedProperties(Options latestList, Options origList, List<String> myNames,
		List<String> latestNames, List<String> origNames) {

	for (int i = 0; i < latestNames.size(); i++) {
		String propertyName = latestNames.get(i);
		if (!myNames.contains(propertyName) && origNames.contains(propertyName)) {
			try {
				Object latestValue = getValue(latestList, propertyName);
				Object origValue = getValue(origList, propertyName);

				if (latestValue.equals(origValue)) {
					latestList.removeOption(propertyName);
					currentMonitor.setProgress(++progressIndex);
				}
				else {
					String listName = latestList.getName();
					ArrayList<ConflictInfo> mapList = getConflictList(listName);
					mapList.add(new ConflictInfo(listName, propertyName,
						latestList.getType(propertyName), OptionType.NO_TYPE,
						origList.getType(propertyName), latestValue, null, origValue));
					++totalConflictCount;
				}
			}
			catch (IllegalArgumentException e) {
			}
		}
	}
}
 
Example 3
Source File: GhidraProgramUtilities.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Removes the analyzed flag from the program properties.
 * With this property removed, the user will be prompted to analyze the
 * program the next time it is opened.
 * @param program the program containing the property to be removed
 */
public static void removeAnalyzedFlag(Program program) {
	int transactionID = program.startTransaction(Program.ANALYZED);
	try {
		Options options = program.getOptions(Program.PROGRAM_INFO);
		options.removeOption(Program.ANALYZED);
	}
	finally {
		program.endTransaction(transactionID, true);
	}
}
 
Example 4
Source File: ProgramDB.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void checkOldProperties(int openMode, TaskMonitor monitor)
		throws IOException, VersionException {
	Record record = table.getRecord(new StringField(EXECUTE_PATH));
	if (record != null) {
		if (openMode == READ_ONLY) {
			return; // not important, get on path or format will return "unknown"
		}
		if (openMode != UPGRADE) {
			throw new VersionException(true);
		}
		Options pl = getOptions(PROGRAM_INFO);
		String value = record.getString(0);
		pl.setString(EXECUTABLE_PATH, value);
		table.deleteRecord(record.getKeyField());
		record = table.getRecord(new StringField(EXECUTE_FORMAT));
		if (record != null) {
			pl.setString(EXECUTABLE_FORMAT, value);
			table.deleteRecord(record.getKeyField());
		}
	}
	int storedVersion = getStoredVersion();
	if (storedVersion < ANALYSIS_OPTIONS_MOVED_VERSION) {
		if (openMode == READ_ONLY) {
			return;
		}
		if (openMode != UPGRADE) {
			throw new VersionException(true);
		}
		Options oldList = getOptions("Analysis");
		for (String propertyName : oldList.getOptionNames()) {
			oldList.removeOption(propertyName);
		}
	}
	if (storedVersion < METADATA_ADDED_VERSION) {
		if (openMode == READ_ONLY) {
			return;
		}
		if (openMode != UPGRADE) {
			throw new VersionException(true);
		}
	}

}
 
Example 5
Source File: PropertyListMergeManager.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void processConflictList(ArrayList<ConflictInfo> conflictList, int listNameIndex,
		String currentListName) throws CancelledException {

	for (int i = 0; i < conflictList.size(); i++) {
		currentMonitor.setProgress(++progressIndex);

		ConflictInfo info = conflictList.get(i);

		++currentConflict;
		if (propertyListChoice != ASK_USER) {
			conflictOption = propertyListChoice;
		}
		else if (mergeManager != null && conflictOption == ASK_USER) {
			showMergePanel(info, currentConflict, totalConflictCount);
			// block until the user resolves the conflict or cancels the 
			// process 
		}

		switch (conflictOption) {
			case LATEST_VERSION:
				break;// no action required

			case MY_VERSION:
			case ORIGINAL_VERSION:
				Options options = resultProgram.getOptions(info.getListName());
				options.removeOption(info.getPropertyName());
				if (conflictOption == MY_VERSION) {
					Object myValue = info.getMyValue();
					if (myValue != null) {
						setValue(options, info.getPropertyName(), info.getMyType(),
							info.getMyValue());
					}
				}
				else {
					Object origValue = info.getOrigValue();
					if (origValue != null) {
						setValue(options, info.getPropertyName(), info.getOrigType(),
							info.getOrigValue());
					}
				}
				break;

			case CANCELED:
				throw new CancelledException();
		}
		conflictOption = ASK_USER;
	}
}