Java Code Examples for ghidra.app.util.bin.ByteProvider#getName()

The following examples show how to use ghidra.app.util.bin.ByteProvider#getName() . 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: DecryptorFactory.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public final static DecryptedPacket decrypt(String firmwareName, String firmwarePath,
		ByteProvider provider, TaskMonitor monitor) throws IOException, CryptoException,
CancelledException {

	List<Decryptor> instances = ClassSearcher.getInstances(Decryptor.class);
	for (Decryptor decryptor : instances) {
		if (monitor.isCancelled()) {
			throw new CancelledException();
		}
		if (decryptor.isValid(provider)) {
			return decryptor.decrypt(firmwareName, firmwarePath, provider, monitor);
		}
	}
	throw new CryptoException("Unable to decrypt " + provider.getName() +
			" unable to locate decryption provider.");
}
 
Example 2
Source File: MapLoader.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<LoadSpec> findSupportedLoadSpecs(ByteProvider provider) throws IOException {
	List<LoadSpec> loadSpecs = new ArrayList<>();

	if (provider.getName() != null && provider.getName().toLowerCase().endsWith(".map") &&
		!parseExports(provider, null).isEmpty()) {
		List<QueryResult> results = QueryOpinionService.query(getName(), NO_MAGIC, null);
		for (QueryResult result : results) {
			loadSpecs.add(new LoadSpec(this, 0, result));
		}
		if (loadSpecs.isEmpty()) {
			loadSpecs.add(new LoadSpec(this, 0, true));
		}
	}

	return loadSpecs;
}
 
Example 3
Source File: DefLoader.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<LoadSpec> findSupportedLoadSpecs(ByteProvider provider) throws IOException {
	List<LoadSpec> loadSpecs = new ArrayList<>();

	String name = provider.getName();
	if (name != null && name.toLowerCase().endsWith(".def") &&
		!parseExports(provider).isEmpty()) {
		List<QueryResult> results = QueryOpinionService.query(getName(), NO_MAGIC, null);
		for (QueryResult result : results) {
			loadSpecs.add(new LoadSpec(this, 0, result));
		}
		if (loadSpecs.isEmpty()) {
			loadSpecs.add(new LoadSpec(this, 0, true));
		}
	}

	return loadSpecs;
}
 
Example 4
Source File: RELProgramBuilder.java    From Ghidra-GameCube-Loader with Apache License 2.0 6 votes vote down vote up
public RELProgramBuilder(RELHeader rel, ByteProvider provider, Program program,
		TaskMonitor monitor, File originalFile, boolean autoloadMaps, boolean saveRelocations,
		boolean createDefaultMemSections, boolean specifyModuleMemAddrs)
				throws IOException, AddressOverflowException, AddressOutOfBoundsException, MemoryAccessException {
	this.rel = rel;
	this.program = program;
	this.monitor = monitor;
	this.autoloadMaps = autoloadMaps;
	this.saveRelocations = saveRelocations;
	this.specifyModuleMemAddrs = specifyModuleMemAddrs;
	this.binaryName = provider.getName();
	this.symbolInfoList = new ArrayList<Map<Long, SymbolInfo>>();
	
	this.load(provider, originalFile);
	if (createDefaultMemSections) {
		SystemMemorySections.Create(program);
	}
}
 
Example 5
Source File: XmlLoader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public String getPreferredFileName(ByteProvider provider) {
	String name = provider.getName();
	if (name.toLowerCase().endsWith(FILE_EXTENSION)) {
		return name.substring(0, name.length() - FILE_EXTENSION.length());
	}
	return name;
}
 
Example 6
Source File: AutoImporter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private static LoadSpec getLoadSpec(Predicate<Loader> loaderFilter,
		LoadSpecChooser loadSpecChooser, ByteProvider provider) {
	LoaderMap loaderMap = LoaderService.getSupportedLoadSpecs(provider, loaderFilter);

	LoadSpec loadSpec = loadSpecChooser.choose(loaderMap);
	if (loadSpec != null) {
		return loadSpec;
	}

	File f = provider.getFile();
	String name = f != null ? f.getAbsolutePath() : provider.getName();
	Msg.info(AutoImporter.class, "No load spec found for import file: " + name);
	return null;
}
 
Example 7
Source File: DOLProgramBuilder.java    From Ghidra-GameCube-Loader with Apache License 2.0 5 votes vote down vote up
public DOLProgramBuilder(DOLHeader dol, ByteProvider provider, Program program,
		TaskMonitor monitor, boolean autoloadMaps, boolean createDefaultMemSections) {
	this.dol = dol;
	this.program = program;
	this.autoloadMaps = autoloadMaps;
	this.binaryName = provider.getName();
	
	this.load(monitor, provider);
	if (createDefaultMemSections) {
		SystemMemorySections.Create(program);
	}
}