Java Code Examples for ghidra.app.util.importer.MessageLog#error()

The following examples show how to use ghidra.app.util.importer.MessageLog#error() . 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: DefLoader.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
		TaskMonitor monitor, MessageLog log) throws IOException {

	if (!prog.getExecutableFormat().equals(PeLoader.PE_NAME)) {
		throw new IOException("Program must be a " + PeLoader.PE_NAME);
	}

	SymbolTable symtab = prog.getSymbolTable();
	Consumer<String> errorConsumer = err -> log.error("DefLoader", err);
	for (DefExportLine def : parseExports(provider)) {
		Symbol symbol = SymbolUtilities.getLabelOrFunctionSymbol(prog,
			SymbolUtilities.ORDINAL_PREFIX + def.getOrdinal(), errorConsumer);
		if (symbol == null) {
			continue;
		}
		try {
			Symbol label =
				symtab.createLabel(symbol.getAddress(), def.getName(), SourceType.IMPORTED);
			label.setPrimary();
		}
		catch (InvalidInputException e) {
			log.appendMsg(e.getMessage());
		}
	}
}
 
Example 2
Source File: AbstractDemanglerAnalyzer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean added(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log)
		throws CancelledException {

	DemanglerOptions options = getOptions();
	if (!validateOptions(options, log)) {
		log.error(getName(), "Invalid demangler options--cannot demangle");
		return false;
	}

	monitor.initialize(100);

	SymbolTable symbolTable = program.getSymbolTable();
	SymbolIterator it = symbolTable.getPrimarySymbolIterator(set, true);
	while (it.hasNext()) {
		monitor.checkCanceled();

		Symbol symbol = it.next();
		if (skipSymbol(symbol)) {
			continue;
		}

		Address address = symbol.getAddress();
		String mangled = cleanSymbol(address, symbol.getName());
		DemangledObject demangled = demangle(mangled, options, log);
		if (demangled != null) {
			apply(program, address, demangled, options, log, monitor);
		}

		Address min = set.getMinAddress();
		Address max = set.getMaxAddress();
		int distance = (int) (address.getOffset() - min.getOffset());
		int percent = (int) ((distance / max.getOffset()) * 100);
		monitor.setProgress(percent);
	}

	return true;
}