Java Code Examples for ghidra.app.util.bin.ByteProvider#getFile()
The following examples show how to use
ghidra.app.util.bin.ByteProvider#getFile() .
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: GzfLoader.java From ghidra with Apache License 2.0 | 5 votes |
private DomainFile doLoad(ByteProvider provider, String programName, DomainFolder programFolder, TaskMonitor monitor) throws InvalidNameException, CancelledException, IOException { File file = provider.getFile(); DomainFolder folder = programFolder; monitor.setMessage("Restoring " + file.getName()); DomainFile df = folder.createFile(programName, file, monitor); return df; }
Example 2
Source File: XmlLoader.java From ghidra with Apache License 2.0 | 5 votes |
@Override protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options, MessageLog log, Program prog, TaskMonitor monitor) throws IOException, CancelledException { File file = provider.getFile(); return doImport(new ProgramXmlMgr(file), options, log, prog, monitor, true); }
Example 3
Source File: AutoImporter.java From ghidra with Apache License 2.0 | 5 votes |
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 4
Source File: GameCubeLoader.java From Ghidra-GameCube-Loader with Apache License 2.0 | 5 votes |
@Override protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options, MessageLog messageLog, Program program, TaskMonitor monitor) throws IOException { if (this.binaryType != BinaryType.UNKNOWN) { boolean autoLoadMaps = OptionUtils.getBooleanOptionValue(AUTOLOAD_MAPS_OPTION_NAME, options, true); boolean saveRelocations = OptionUtils.getBooleanOptionValue(ADD_RELOCATIONS_OPTION_NAME, options, false); boolean createDefaultSections = OptionUtils.getBooleanOptionValue(ADD_RESERVED_AND_HARDWAREREGISTERS, options, true); boolean specifyFileMemAddresses = OptionUtils.getBooleanOptionValue(SPECIFY_BINARY_MEM_ADDRESSES, options, false); if (this.binaryType == BinaryType.DOL) { new DOLProgramBuilder(dolHeader, provider, program, monitor, autoLoadMaps, createDefaultSections); } else if (this.binaryType == BinaryType.REL) { try { // We have to check if the source file is compressed & decompress it again if it is. var file = provider.getFile(); Yaz0 yaz0 = new Yaz0(); if (yaz0.IsValid(provider)) { provider = yaz0.Decompress(provider); } new RELProgramBuilder(relHeader, provider, program, monitor, file, autoLoadMaps, saveRelocations, createDefaultSections, specifyFileMemAddresses); } catch (AddressOverflowException | AddressOutOfBoundsException | MemoryAccessException e ) { e.printStackTrace(); } } else { new ApploaderProgramBuilder(apploaderHeader, provider, program, monitor, createDefaultSections); } return true; } return false; }
Example 5
Source File: AbstractLibrarySupportLoader.java From ghidra with Apache License 2.0 | 3 votes |
/** * Returns the path the loaded {@link ByteProvider} is located in. * <p> * Special case when the ByteProvider specifies a {@link FSRL}, try to get the 'real' * path on the local filesystem, otherwise return null. * * @param provider The {@link ByteProvider}. * @return The path the loaded {@link ByteProvider} is located in. */ private String getProviderFilePath(ByteProvider provider) { FSRL fsrl = provider.getFSRL(); if ((fsrl != null) && !fsrl.getFS().hasContainer()) { return FilenameUtils.getFullPathNoEndSeparator(fsrl.getPath()); } File f = provider.getFile(); return (f != null) ? f.getParent() : null; }
Example 6
Source File: GdtLoader.java From ghidra with Apache License 2.0 | 3 votes |
private DomainFile doImport(ByteProvider provider, String filename, DomainFolder programFolder, TaskMonitor monitor) throws InvalidNameException, CancelledException, IOException { File file = provider.getFile(); DomainFolder folder = programFolder; monitor.setMessage("Restoring " + file.getName()); DomainFile df = folder.createFile(filename, file, monitor); return df; }
Example 7
Source File: ProgramXmlMgr.java From ghidra with Apache License 2.0 | 2 votes |
/** * Constructs a new program XML manager using the specified {@link ByteProvider}. * <p> * If {@link ByteProvider} has a {@link FSRL} and it is a simple local filepath, * convert that to a normal local java.io.File instance instead of using the * {@link ByteProvider}'s File property which is probably located in the * {@link FileSystemService} filecache directory, which will break the ability * to find the *.bytes file associated with this .xml file. * <p> * This workaround will not help xml files that are truly embedded in a GFileSystem * (ie. in a .zip file). * * @param bp */ public ProgramXmlMgr(ByteProvider bp) { this.file = (bp.getFSRL() != null && bp.getFSRL().getNestingDepth() == 1) ? new File(bp.getFSRL().getPath()) : bp.getFile(); }