Java Code Examples for ghidra.util.Msg

The following examples show how to use ghidra.util.Msg. These examples are extracted from open source projects. 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 Project: ghidra   Source File: DIEAggregate.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the {@link DebugInfoEntry die} instance pointed to by the requested attribute,
 * or null if the attribute does not exist.
 * <p>
 * @param attribute
 * @return
 */
public DebugInfoEntry getRefDIE(int attribute) {
	AttrInfo attrInfo = findAttribute(attribute);
	if (attrInfo == null) {
		return null;
	}

	DWARFNumericAttribute val = attrInfo.getValue(DWARFNumericAttribute.class);
	long offset = (val != null) ? val.getUnsignedValue() : -1;

	DebugInfoEntry result = getProgram().getEntryAtByteOffsetUnchecked(offset);
	if (result == null) {
		Msg.warn(this, "Invalid reference value [" + Long.toHexString(offset) + "]");
		Msg.warn(this, this.toString());
	}
	return result;
}
 
Example 2
Source Project: ghidra   Source File: EntryDescriptorID.java    License: Apache License 2.0 6 votes vote down vote up
public final static String convertEntryIdToName(int entryID) {
	Field [] fields = EntryDescriptorID.class.getDeclaredFields();
	for (Field field : fields) {
		if (field.getName().startsWith("ENTRY_")) {
			try {
				Integer value = (Integer)field.get(null);
				if (value == entryID) {
					return field.getName().substring("ENTRY_".length());
				}
			}
			catch (Exception e) {
			    Msg.error(EntryDescriptorID.class, "Unexpected Exception: " + e.getMessage(), e);
			}
		}
	}
	return "Unrecognized entry id: 0x"+Integer.toHexString(entryID);
}
 
Example 3
Source Project: ghidra   Source File: ExtensionUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Extracts information from a Java Properties file to create an {@link ExtensionDetails}
 * object.
 * 
 * @param resourceFile the resource file file to parse
 * @return a new extension details object
 */
public static ExtensionDetails createExtensionDetailsFromPropertyFile(
		ResourceFile resourceFile) {

	try (InputStream in = resourceFile.getInputStream()) {
		Properties props = new Properties();
		props.load(in);
		return createExtensionDetailsFromProperties(props);
	}
	catch (IOException e) {
		Msg.error(null,
			"Error processing extension properties for " + resourceFile.getAbsolutePath(),
			e);
		return null;
	}
}
 
Example 4
Source Project: ghidra   Source File: AnalysisScheduler.java    License: 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 Project: ghidra   Source File: Preferences.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets an input stream to a file that is the same named file within a different 
 * application version directory for this user. This method will search for an 
 * alternate file based on the application version directories modification times 
 * and will use the first matching file it finds.  
 * 
 * @return a file input stream for an alternate file or null.
 */
private static FileInputStream getAlternateFileInputStream() {
	File previousFile =
		GenericRunInfo.getPreviousApplicationSettingsFile(APPLICATION_PREFERENCES_FILENAME);
	if (previousFile == null) {
		return null;
	}

	try {
		FileInputStream fis = new FileInputStream(previousFile);
		Msg.info(Preferences.class, "Loading previous preferences: " + previousFile);
		return fis;
	}
	catch (FileNotFoundException fnfe) {
		// Ignore so we can try another directory.
	}

	return null;
}
 
Example 6
Source Project: ghidra   Source File: EditActionManager.java    License: Apache License 2.0 6 votes vote down vote up
private void clearCertPath() {

		String path = ApplicationKeyManagerFactory.getKeyStore();
		if (path == null) {
			// unexpected
			clearCertPathAction.setEnabled(false);
			return;
		}

		if (OptionDialog.YES_OPTION != OptionDialog.showYesNoDialog(tool.getToolFrame(),
			"Clear PKI Certificate", "Clear PKI certificate setting?\n(" + path + ")")) {
			return;
		}

		try {
			ApplicationKeyManagerFactory.setKeyStore(null, true);
			clearCertPathAction.setEnabled(false);
		}
		catch (IOException e) {
			Msg.error(this,
				"Error occurred while clearing PKI certificate setting: " + e.getMessage());
		}
	}
 
Example 7
Source Project: ghidra   Source File: BlockGraphTask.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Runs the move memory operation.
 */
@Override
public void run(TaskMonitor monitor) throws CancelledException {
	AttributedGraph graph = createGraph();
	monitor.setMessage("Generating Graph...");
	try {
		GraphDisplay display = graphService.getGraphDisplay(reuseGraph, monitor);
		display.setGraphDisplayListener(
			new BlockModelGraphDisplayListener(tool, blockModel, display));
		if (showCode) {
			display.defineVertexAttribute(CODE_ATTRIBUTE);
			display.defineVertexAttribute(SYMBOLS_ATTRIBUTE);
			display.setVertexLabel(CODE_ATTRIBUTE, GraphDisplay.ALIGN_LEFT, 12, true,
				codeLimitPerBlock + 1);
		}
		display.setGraph(graph, actionName, appendGraph, monitor);
	}
	catch (GraphException e) {
		if (!monitor.isCancelled()) {
			Msg.showError(this, null, "Graphing Error", e.getMessage());
		}
	}
}
 
Example 8
Source Project: ghidra   Source File: ELFExternalSymbolResolver.java    License: Apache License 2.0 6 votes vote down vote up
private static Collection<String> getOrderedLibraryNamesNeeded(Program program) {
	TreeMap<Integer, String> orderLibraryMap = new TreeMap<>();
	Options options = program.getOptions(Program.PROGRAM_INFO);
	//List<String> sortedOptionNames = new ArrayList<>();
	for (String optionName : options.getOptionNames()) {
		if (!optionName.startsWith(ElfLoader.ELF_REQUIRED_LIBRARY_PROPERTY_PREFIX) ||
			!optionName.endsWith("]")) {
			continue;
		}
		String libName = options.getString(optionName, null);
		if (libName == null) {
			continue;
		}
		String indexStr =
			optionName.substring(ElfLoader.ELF_REQUIRED_LIBRARY_PROPERTY_PREFIX.length(),
				optionName.length() - 1).trim();
		try {
			orderLibraryMap.put(Integer.parseInt(indexStr), libName.trim());
		}
		catch (NumberFormatException e) {
			Msg.error(ELFExternalSymbolResolver.class,
				"Program contains invalid property: " + optionName);
		}
	}
	return orderLibraryMap.values();
}
 
Example 9
Source Project: ghidra   Source File: EclipseConnectorTask.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link ProcessBuilder} to launch Eclipse.
 * 
 * @param eclipseExecutableFile The Eclipse executable file.
 * @param eclipseWorkspaceDir The Eclipse workspace directory.  Could be null.
 * @return A {@link ProcessBuilder} to launch Eclipse.
 */
private ProcessBuilder createEclipseProcessBuilder(File eclipseExecutableFile,
		File eclipseWorkspaceDir) {
	List<String> args = new ArrayList<>();
	args.add(eclipseExecutableFile.getAbsolutePath());

	if (eclipseWorkspaceDir != null) {
		args.add("-data");
		args.add(eclipseWorkspaceDir.getAbsolutePath());
	}

	args.add("--launcher.appendVmargs");
	args.add("-vmargs");
	args.add("-Dghidra.install.dir=" + Application.getInstallationDirectory());

	// Eclipse on OS X can have file locking issues if the user home directory is networked.
	// The following property is set in the launch script if we should disable file locking
	// via the appropriate Eclipse JVM arg.
	if (Boolean.getBoolean("eclipse.filelock.disable")) {
		Msg.info(this, "Disabling Eclipse file locking...");
		args.add("-Dosgi.locking=none");
	}

	return new ProcessBuilder(args);
}
 
Example 10
Source Project: ghidra   Source File: ExactInstructionsFunctionHasher.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected long hash(TaskMonitor monitor, ArrayList<CodeUnit> units, int byteCount)
		throws MemoryAccessException, CancelledException {
	byte[] buffer = new byte[byteCount];
	int offset = 0;
	for (CodeUnit codeUnit : units) {
		monitor.checkCanceled();

		try {
			codeUnit.getBytesInCodeUnit(buffer, offset);
			applyMask(buffer, offset, codeUnit);
		}
		catch (MemoryAccessException e) {
			Msg.warn(this, "Could not get code unit bytes at " + codeUnit.getAddress());
		}
		offset += codeUnit.getLength();
	}
	if (offset != byteCount) {
		throw new IllegalStateException("did NOT use all the codeUnit buffer bytes");
	}
	synchronized (digest) {
		digest.reset();
		digest.update(buffer, monitor);
		return digest.digestLong();
	}
}
 
Example 11
Source Project: Ghidra-Switch-Loader   Source File: ByteUtil.java    License: ISC License 6 votes vote down vote up
public static void logBytes(byte[] data)
{
    StringBuilder sb = new StringBuilder();
    int lineWidth = 0;
    
    for (byte b : data) 
    {
        sb.append(String.format("%02X ", b));
        lineWidth++;
        
        if (lineWidth >= 16)
        {
            sb.append("\n");
            lineWidth = 0;
        }
    }
    
    Msg.info(null, sb.toString());
}
 
Example 12
Source Project: ghidra   Source File: ThreadedTableTest.java    License: Apache License 2.0 6 votes vote down vote up
private void assertPendingPanelShowing() {
	JComponent pendingPanel = (JComponent) getInstanceField("pendingPanel", threadedTablePanel);

	waitForCondition(() -> {

		boolean isShowing = isShowing(pendingPanel);

		if (!isShowing) {
			JComponent loadedComponent =
				(JComponent) getInstanceField("loadedComponent", threadedTablePanel);
			String name = (loadedComponent == null) ? "<no component showing>"
					: loadedComponent.getName();
			Msg.debug(this, "Pending is not yet showing--what is?: " + name);
		}

		return isShowing;
	});
}
 
Example 13
Source Project: ghidra   Source File: ToolActionManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create the Template object and add it to the tool chest.
 */
private void addToolTemplate(InputStream instream, String path) {
	try {
		SAXBuilder sax = XmlUtilities.createSecureSAXBuilder(false, false);
		Element root = sax.build(instream).getRootElement();

		ToolTemplate template = new GhidraToolTemplate(root, path);
		if (plugin.getActiveProject().getLocalToolChest().addToolTemplate(template)) {
			Msg.info(this,
				"Successfully added " + template.getName() + " to project tool chest.");
		}
		else {
			Msg.warn(this, "Could not add " + template.getName() + " to project tool chest.");
		}
	}
	catch (Exception e) {
		Msg.showError(getClass(), tool.getToolFrame(), "Error Reading Tool",
			"Could not read tool: " + e, e);
	}
}
 
Example 14
Source Project: ghidra   Source File: AbstractToolSavingTest.java    License: Apache License 2.0 6 votes vote down vote up
protected Map<String, Object> getOptionsMap(PluginTool tool) {
	Map<String, Object> map = new TreeMap<>();
	Options[] options = tool.getOptions();
	for (Options option : options) {
		String optionsName = option.getName();

		if (optionsName.equals("Key Bindings")) {
			Msg.debug(this, "break");
		}

		List<String> optionNames = option.getOptionNames();
		for (String name : optionNames) {
			Object value = invokeInstanceMethod("getObject", option,
				new Class[] { String.class, Object.class }, new Object[] { name, null });
			map.put(optionsName + "." + name, value);
		}
	}
	return map;
}
 
Example 15
Source Project: ghidra   Source File: ModuleSortPlugin.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void run(TaskMonitor monitor) {
	int txId = -1;
	boolean success = false;
	try {
		txId = currentProgram.startTransaction(getName());
		doSort(module, comparator, monitor);
		success = true;
	}
	catch (CancelledException ce) {
		// don't care
	}
	catch (Throwable t) {
		Msg.showError(this, null, "Error", "Module Sort Failed", t);
	}
	finally {
		currentProgram.endTransaction(txId, success);
	}
}
 
Example 16
Source Project: ghidra   Source File: VTHashedFunctionAddressCorrelation.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public AddressRange getCorrelatedDestinationRange(Address sourceAddress, TaskMonitor monitor)
		throws CancelledException {
	try {
		initializeCorrelation(monitor);
		Address destinationAddress = addressCorrelation.getAddressInSecond(sourceAddress);
		if (destinationAddress == null) {
			return null; // No matching destination.
		}
		return new AddressRangeImpl(destinationAddress, destinationAddress);
	}
	catch (MemoryAccessException e) {
		Msg.error(this, "Could not create HashedFunctionAddressCorrelation", e);
		return null;
	}
}
 
Example 17
Source Project: ghidra   Source File: LinuxFileUrlHandler.java    License: Apache License 2.0 6 votes vote down vote up
private void doImport(Component component, Object transferData, ServiceProvider sp,
		DomainFolder folder) {

	FileImporterService im = sp.getService(FileImporterService.class);
	if (im == null) {
		Msg.showError(this, component, "Could Not Import", "Could not find importer service.");
		return;
	}

	List<File> files = toFiles(transferData);
	if (files.isEmpty()) {
		return;
	}

	if (files.size() == 1 && files.get(0).isFile()) {
		im.importFile(folder, files.get(0));
	}
	else {
		im.importFiles(folder, files);
	}
}
 
Example 18
Source Project: ghidra   Source File: DWARFSectionProviderFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Iterates through the statically registered {@link #sectionProviderFactoryFuncs factory funcs},
 * trying each factory method until one returns a {@link DWARFSectionProvider} 
 * that can successfully retrieve the {@link DWARFSectionNames#MINIMAL_DWARF_SECTIONS minimal} 
 * sections we need to do a DWARF import.
 * <p>
 * The resulting {@link DWARFSectionProvider} is {@link Closeable} and it is the caller's
 * responsibility to ensure that the object is closed when done. 
 * 
 * @param program
 * @return {@link DWARFSectionProvider} that should be closed by the caller or NULL if no
 * section provider types match the specified program.
 */
public static DWARFSectionProvider createSectionProviderFor(Program program) {
	for (Function<Program, DWARFSectionProvider> factoryFunc : sectionProviderFactoryFuncs) {
		DWARFSectionProvider sp = factoryFunc.apply(program);
		if (sp != null) {
			try {
				if (sp.hasSection(DWARFSectionNames.MINIMAL_DWARF_SECTIONS)) {
					return sp;
				}
			}
			catch (Exception e) {
				Msg.warn(DWARFSectionProviderFactory.class,
					"Problem detecting DWARFSectionProvider", e);
			}
			sp.close();
		}
	}
	return null;
}
 
Example 19
Source Project: ghidra   Source File: AbstractMergeTest.java    License: Apache License 2.0 6 votes vote down vote up
protected void checkTransactions(String prefix) {
	Program p = mtf.getResultProgram();
	if (p == null) {
		return;
	}

	Transaction tx = p.getCurrentTransaction();
	if (tx == null) {
		return;
	}
	ArrayList<String> list = tx.getOpenSubTransactions();
	StringBuffer tip = new StringBuffer();
	Iterator<String> iter = list.iterator();
	while (iter.hasNext()) {
		if (tip.length() != 0) {
			tip.append('\n');
		}
		tip.append(iter.next());
	}
	Msg.error(this, prefix + "Test Case " + testName.getMethodName() +
		" : ERROR: Transactions still exist!  " + tip.toString());
}
 
Example 20
Source Project: ghidra   Source File: GhidraFileChooserTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDesktop_SystemNativeDesktop() throws Exception {
	File userDesktopDir = chooser.getModel().getDesktopDirectory();

	if (userDesktopDir == null) {
		Msg.warn(this, "NOTE: unable to test 'Desktop' button in GhidraFileChooser " +
			"in this enviornment because it does not have a detectable Desktop folder.");
		return;
	}

	pressDesktop();
	waitForChooser();

	assertEquals("File chooser did not switch to the user's Desktop directory", userDesktopDir,
		getCurrentDirectory());
}
 
Example 21
Source Project: ghidra   Source File: OptionType.java    License: Apache License 2.0 6 votes vote down vote up
@Override
Object stringToObject(String string) {
	SaveState saveState = getSaveStateFromXmlString(string);
	String customOptionClassName = saveState.getString("CUSTOM_OPTION_CLASS", null);
	try {
		Class<?> c = Class.forName(customOptionClassName);
		CustomOption option = (CustomOption) c.newInstance();
		option.readState(saveState);
		return option;
	}
	catch (Exception e) {
		Msg.error(this, "Can't create customOption instance for: " + customOptionClassName,
			e);
	}
	return null;
}
 
Example 22
Source Project: ghidra   Source File: GNUExternalDisassembler.java    License: Apache License 2.0 6 votes vote down vote up
private static void reportMultipleMappings(Language language) {
	List<String> externalNames = language.getLanguageDescription().getExternalNames("gnu");
	if (externalNames != null && externalNames.size() > 1) {
		LanguageID currentLanguageID = language.getLanguageID();
		StringBuilder sb = new StringBuilder();
		boolean prependSeparator = false;
		for (String name : externalNames) {
			if (prependSeparator)
				sb.append(", ");
			sb.append(name);
			prependSeparator = true;
		}
		Msg.warn(GNUExternalDisassembler.class,
			"Language " + currentLanguageID + " illegally maps to multiple (" +
				externalNames.size() + ") external gnu names: " + sb.toString() +
				".  The first external name will be used.");
	}
}
 
Example 23
Source Project: ghidra   Source File: MemoryBlockUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Adjusts the name of the fragment at the given address to the given name.
 * @param program the program whose fragment is to be renamed.
 * @param address the address of the fragment to be renamed.
 * @param name the new name for the fragment.
 */
public static void adjustFragment(Program program, Address address, String name) {
	Listing listing = program.getListing();
	String[] treeNames = listing.getTreeNames();
	for (String treeName : treeNames) {
		try {
			ProgramFragment frag = listing.getFragment(treeName, address);
			frag.setName(name);
		}
		catch (DuplicateNameException e) {
			Msg.warn(MemoryBlockUtils.class,
				"Could not rename fragment to match newly created block because of name conflict");
		}
	}
}
 
Example 24
Source Project: ghidra   Source File: ParameterInfo.java    License: Apache License 2.0 5 votes vote down vote up
public Parameter createParameterDefinition(Function destFunction, int ordinal) {
	try {
		Parameter var =
			new MyParameter(getName(), getOrdinal(), getDataType(),
				getVariableStorage().getSerializationString(), destFunction.getProgram(),
				getSource());
		var.setComment(getComment());
		return var;
	}
	catch (InvalidInputException e) {
		Msg.error(this, "Unable to apply parameter '" + getName() + "' to function " +
			destFunction.getName() + ": " + e.getMessage());
		return null;
	}
}
 
Example 25
Source Project: ghidra   Source File: ImageBaseDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @see ghidra.util.bean.GhidraDialog#okCallback()
 */
@Override
   protected void okCallback() {
	if (addr != null && !addr.equals(currentAddr)) {
		Msg.info(this, "old base = "+program.getImageBase());
		Command cmd = new SetBaseCommand(addr);
		if (!tool.execute(cmd, program)) {
			setStatusText(cmd.getStatusMsg());
			return;
		}
		Msg.info(this, "new base = "+((ProgramDB)program).getImageBase());
	}
	close();
}
 
Example 26
Source Project: ghidra   Source File: FileSystemFactoryMgr.java    License: Apache License 2.0 5 votes vote down vote up
private void addFactory(Class<? extends GFileSystem> fsClass) {
	FileSystemInfoRec fsir = FileSystemInfoRec.fromClass(fsClass);
	if (fsir == null) {
		Msg.error(this, "No valid FileSystemInfo found for " + fsClass.getName());
		return;
	}
	if (fsByType.containsKey(fsir.getType())) {
		FileSystemInfoRec prevFSI = fsByType.get(fsir.getType());
		Msg.error(this,
			"GFileSystem type '" + fsir.getType() + "' registered more than one time: " +
				fsClass.getName() + ", " + prevFSI.getFSClass().getName() +
				", ommitting second instance.");
		return;
	}

	if (fsir.getFactory() instanceof GFileSystemFactoryIgnore) {
		// don't register any filesystem that uses this factory
		return;
	}
	if (fsir.getFactory() instanceof GFileSystemProbeBytesOnly) {
		GFileSystemProbeBytesOnly pbo = (GFileSystemProbeBytesOnly) fsir.getFactory();
		if (pbo.getBytesRequired() > GFileSystemProbeBytesOnly.MAX_BYTESREQUIRED) {
			Msg.error(this,
				"GFileSystemProbeBytesOnly for " + fsClass.getName() +
					" specifies too large value for bytes_required: " + pbo.getBytesRequired() +
					", skipping this probe.");
		}
		else {
			largestBytesRequired = Math.max(largestBytesRequired, pbo.getBytesRequired());
		}
	}

	fsByType.put(fsir.getType(), fsir);
	sortedFactories.add(fsir);
}
 
Example 27
Source Project: ghidra   Source File: DefaultPdbMember.java    License: Apache License 2.0 5 votes vote down vote up
private void parseBitField(String name) {
	if (name == null || kind != PdbKind.MEMBER) {
		return;
	}
	int bitFieldColonIndex = name.indexOf(':');
	if (bitFieldColonIndex >= 0) {

		isBitField = true;

		String bitSizeOffsetStr = name.substring(bitFieldColonIndex + 1);

		try {
			int colonIndex = bitSizeOffsetStr.indexOf(':');
			if (colonIndex > 0) {
				bitFieldOffset = (int) NumericUtilities.parseNumber(
					bitSizeOffsetStr.substring(colonIndex + 1));
				bitSizeOffsetStr = bitSizeOffsetStr.substring(0, colonIndex);
			}
			else {
				dataTypeParser.setMissingBitOffsetError();
			}
			bitFieldSize = (int) NumericUtilities.parseNumber(bitSizeOffsetStr);
		}
		catch (NumberFormatException e) {
			Msg.error(this, "Invalid PDB bitfield specification: " + name);
		}
	}
}
 
Example 28
Source Project: ghidra   Source File: MemoryBytePatternSearcher.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Search initialized memory blocks for all patterns(bytes/mask/action).
 * Call associated action for each pattern matched.
 * 
 * @param program to be searched
 * @param searchSet set of bytes to restrict search, if null or empty then search all memory blocks
 * @param monitor allow canceling and reporting of progress
 * 
 * @throws CancelledException if canceled
 */
public void search(Program program, AddressSetView searchSet, TaskMonitor monitor)
		throws CancelledException {
	if (root == null) {
		root = SequenceSearchState.buildStateMachine(patternList);
	}

	numToSearch = getNumToSearch(program, searchSet);
	monitor.setMessage(searchName + " Search");
	monitor.initialize(numToSearch);

	MemoryBlock[] blocks = program.getMemory().getBlocks();
	for (MemoryBlock block : blocks) {
		monitor.setProgress(numSearched);
		// check if entire block has anything that is searchable
		if (!block.isInitialized()) {
			continue;
		}
		if (doExecutableBlocksOnly && !block.isExecute()) {
			continue;
		}
		if (searchSet != null && !searchSet.isEmpty() &&
			!searchSet.intersects(block.getStart(), block.getEnd())) {
			continue;
		}

		try {
			searchBlock(root, program, block, searchSet, monitor);
		}
		catch (IOException e) {
			Msg.error(this, "Unable to scan block " + block.getName() + " for " + searchName);
		}
		numSearched += block.getSize();
	}
}
 
Example 29
Source Project: ghidra   Source File: AbstractCreateDataBackgroundCmd.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Output the error message to the log and output a possibly shorter status message for this 
 * command. This also creates a bookmark with the error message at the indicated address.
 * @param program the program where the error bookmark should be created.
 * @param bookmarkAddress the address where an error bookmark should be created.
 * @param errorMessage the detailed error message.
 * @param statusMessage an abbreviated error message that will appear as a status message.
 */
protected void handleErrorMessage(Program program, Address bookmarkAddress, String errorMessage,
		String statusMessage) {
	Msg.error(this, errorMessage);
	setStatusMsg(statusMessage);
	if (applyOptions.shouldCreateBookmarks()) {
		BookmarkManager bookmarkManager = program.getBookmarkManager();
		bookmarkManager.setBookmark(bookmarkAddress, BookmarkType.ERROR, "Data", errorMessage);
	}
}
 
Example 30
Source Project: Ghidra-Switch-Loader   Source File: NXProgramBuilder.java    License: ISC License 5 votes vote down vote up
protected void createGlobalOffsetTable() throws AddressOverflowException, AddressOutOfBoundsException, IOException
{
    NXOAdapter adapter = this.nxo.getAdapter();
    ByteProvider memoryProvider = adapter.getMemoryProvider();
    
    // .got.plt needs to have been created first
    long gotStartOff = adapter.getGotOffset() - this.nxo.getBaseAddress();
    long gotSize = adapter.getGotSize();
    
    if (gotSize > 0)
    {
        Msg.info(this, String.format("Created got from 0x%X to 0x%X", gotStartOff, gotStartOff + gotSize));
        this.memBlockHelper.addSection(".got", gotStartOff, gotStartOff, gotSize, true, false, false);
    }
}