ghidra.framework.model.DomainFolder Java Examples

The following examples show how to use ghidra.framework.model.DomainFolder. 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: ProjectDataDeleteTask.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void preprocessFolder(DomainFolder folder, TaskMonitor monitor)
		throws CancelledException {
	if (foldersToDelete.containsKey(folder)) {
		return;
	}

	monitor.setMessage("Checking " + folder.getPathname());
	foldersToDelete.put(folder, null);
	for (DomainFile file : folder.getFiles()) {
		monitor.checkCanceled();
		preprocessFile(file, monitor);
		monitor.incrementProgress(1);
	}

	for (DomainFolder subFolder : folder.getFolders()) {
		monitor.checkCanceled();
		preprocessFolder(subFolder, monitor);
	}
}
 
Example #2
Source File: FindFunctionByHash.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void findPrograms(ArrayList<DomainFile> programs, DomainFolder folder)
		throws VersionException, CancelledException, IOException {
	DomainFile[] files = folder.getFiles();
	for (DomainFile domainFile : files) {
		if (monitor.isCancelled()) {
			return;
		}
		if (domainFile.getContentType().equals(ProgramContentHandler.PROGRAM_CONTENT_TYPE)) {
			programs.add(domainFile);
		}
	}
	DomainFolder[] folders = folder.getFolders();
	for (DomainFolder domainFolder : folders) {
		if (monitor.isCancelled()) {
			return;
		}
		findPrograms(programs, domainFolder);
	}
}
 
Example #3
Source File: FrontEndPluginActionsTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testDragMoveFolderAndChild2Folder() throws Exception {
	// Test drag/dropping a folder and its children (at the same time)
	// to make sure children aren't moved twice
	DomainFolder f = rootFolder.createFolder("myFolder");
	createNotepadFile(f);
	rootFolder.createFolder("otherFolder");
	waitForSwing();

	GTreeNode selectedFolderNode = getChild(rootNode, "myFolder");
	GTreeNode selectedFile = getChild(selectedFolderNode, "notepad");
	GTreeNode destNode = getChild(rootNode, "otherFolder");

	doDrag(destNode, DnDConstants.ACTION_MOVE, selectedFolderNode, selectedFile);

	expandTreePath(destNode.getTreePath());
	assertEquals(1, destNode.getChildCount());
	GTreeNode movedFolderNode = getChild(destNode, "myFolder");
	assertNotNull(movedFolderNode);
	assertNotNull(getChild(movedFolderNode, "notepad"));
	assertNull(getChild(rootNode, "myFolder"));
}
 
Example #4
Source File: CollectFailedRelocations.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void findPrograms(ArrayList<DomainFile> programs, DomainFolder folder)
		throws VersionException, CancelledException, IOException {
	DomainFile[] files = folder.getFiles();
	for (DomainFile domainFile : files) {
		if (monitor.isCancelled()) {
			return;
		}
		if (domainFile.getContentType().equals(ProgramContentHandler.PROGRAM_CONTENT_TYPE)) {
			programs.add(domainFile);
		}
	}
	DomainFolder[] folders = folder.getFolders();
	for (DomainFolder domainFolder : folders) {
		if (monitor.isCancelled()) {
			return;
		}
		findPrograms(programs, domainFolder);
	}
}
 
Example #5
Source File: LocalTreeNodeHandler.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void addDraggedTreeNode(DomainFolder destFolder, GTreeNode data, int dropAction,
		TaskMonitor monitor) {
	try {
		if (data instanceof DomainFolderNode) {
			DomainFolder sourceFolder = ((DomainFolderNode) data).getDomainFolder();
			handleFolderDrag(destFolder, dropAction, sourceFolder, monitor);
		}
		else {
			DomainFile file = ((DomainFileNode) data).getDomainFile();
			handleFileDrag(destFolder, dropAction, file, monitor);
		}
	}
	catch (Exception e) {
		String msg = e.getMessage();
		if (msg == null) {
			msg = e.toString();
		}
		String nodeType = (data instanceof DomainFolderNode) ? "folder" : "file";
		Msg.showError(this, dataTree, "Copy/Move Failed",
			"Failed to copy/move " + nodeType + ": " + data.getName() + "\n" + msg, e);
	}
}
 
Example #6
Source File: GenerateLotsOfProgramsScript.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected void run() throws Exception {
	DomainFolder root = getProjectRootFolder();
	DomainFolder stuff = root.createFolder("stuff");
	createPrograms(stuff, 30);
	DomainFolder a = stuff.createFolder("A");
	createPrograms(a, 10);
	DomainFolder b = stuff.createFolder("B");
	createPrograms(b, 10);
	DomainFolder c = stuff.createFolder("C");
	createPrograms(c, 10);
	DomainFolder d = stuff.createFolder("D");
	createPrograms(d, 10);
	DomainFolder e = stuff.createFolder("E");
	createPrograms(e, 10);
	DomainFolder f = stuff.createFolder("F");
	createPrograms(f, 10);

	DomainFolder big = a.createFolder("Big");
	createPrograms(big, 200);
}
 
Example #7
Source File: MSLibBatchImportWorker.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private static DomainFolder getFolder(DomainFolder folder, String path,
		boolean createIfMissing) throws InvalidNameException, IOException {
	for (String pathpart : path.split("[/\\\\]")) {
		if (pathpart.isEmpty()) {
			continue;
		}
		pathpart = ensureSafeProjectObjName(pathpart);
		DomainFolder tmp = folder.getFolder(pathpart);
		if (tmp == null) {
			if (!createIfMissing) {
				return null;
			}
			tmp = folder.createFolder(pathpart);
		}
		folder = tmp;
	}
	return folder;
}
 
Example #8
Source File: DeleteProjectFilesTask.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void deleteFolder(DomainFolder folder, TaskMonitor monitor) throws CancelledException {

		for (DomainFolder subFolder : folder.getFolders()) {
			monitor.checkCanceled();
			if (!selectedFolders.contains(subFolder)) {
				deleteFolder(subFolder, monitor);
			}
		}

		for (DomainFile file : folder.getFiles()) {
			monitor.checkCanceled();
			if (!selectedFiles.contains(file)) {
				deleteFile(file);
				monitor.incrementProgress(1);
			}
		}

		deleteEmptyFolder(folder);
	}
 
Example #9
Source File: FrontEndPluginActionsTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testCollapseAll() throws Exception {
	DomainFolder f = rootFolder.createFolder("myFolder");
	f = f.createFolder("A");
	f = f.createFolder("B");
	f = f.createFolder("C");
	waitForSwing();

	GTreeNode myNode = rootNode.getChild("myFolder");
	setSelectionPath(myNode.getTreePath());
	DockingActionIf expandAction = getAction("Expand All");
	performAction(expandAction, getDomainFileActionContext(), true);
	waitForTree();

	DockingActionIf collapseAction = getAction("Collapse All");
	performAction(collapseAction, getDomainFileActionContext(), true);
	waitForTree();
	assertTrue(!tree.isExpanded(myNode.getTreePath()));
	GTreeNode aNode = myNode.getChild("A");
	assertTrue(!tree.isExpanded(aNode.getTreePath()));
	GTreeNode bNode = aNode.getChild("B");
	assertTrue(!tree.isExpanded(bNode.getTreePath()));
	GTreeNode cNode = bNode.getChild("C");
	assertNotNull(cNode);
	assertTrue(!tree.isExpanded(cNode.getTreePath()));
}
 
Example #10
Source File: FrontEndPluginActionsTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testCutPasteFile2Folder() throws Exception {
	// cut/paste file -> folder
	DomainFolder f = rootFolder.createFolder("myFolder");
	createNotepadFile(f);

	GTreeNode winNode = getChild(rootNode, "tms");
	setSelectionPaths(new TreePath[] { winNode.getTreePath() });

	DockingActionIf cutAction = getAction("Cut");
	DockingActionIf pasteAction = getAction("Paste");

	performAction(cutAction, getDomainFileActionContext(), true);
	GTreeNode myNode = getChild(rootNode, "myFolder");
	assertNotNull(myNode);
	setSelectionPaths(new TreePath[] { myNode.getTreePath() });

	performAction(pasteAction, getDomainFileActionContext(), true);
	waitForTree();

	// myFolder should have 2 files
	expandTreePath(myNode.getTreePath());
	assertEquals(2, myNode.getChildCount());
	assertNull(getChild(rootNode, "tms"));
}
 
Example #11
Source File: FrontEndPluginActionsTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testDragCopyFile2Folder() throws Exception {
	DomainFolder f = rootFolder.createFolder("myFolder");
	createNotepadFile(f);

	GTreeNode winNode = getChild(rootNode, "tms");
	GTreeNode myNode = getChild(rootNode, "myFolder");
	assertNotNull(myNode);
	setSelectionPaths(new TreePath[] { myNode.getTreePath() });

	doDrag(myNode, DnDConstants.ACTION_COPY, winNode);

	waitForTree();

	// myFolder should have 2 files
	expandTreePath(myNode.getTreePath());
	assertEquals(2, myNode.getChildCount());
	assertNotNull(getChild(rootNode, "tms"));

}
 
Example #12
Source File: IngestTask.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Recursively finds all domain objects that are program files under a domain folder.
 * @param programs the "return" value; found programs are placed in this collection
 * @param myFolder the domain folder to search
 * @param monitor a task monitor
 * @throws CancelledException if the user cancels
 */
protected void findPrograms(ArrayList<DomainFile> programs, DomainFolder myFolder,
		TaskMonitor monitor) throws CancelledException {
	if (myFolder == null) {
		return;
	}
	DomainFile[] files = myFolder.getFiles();
	for (DomainFile domainFile : files) {
		monitor.checkCanceled();
		monitor.incrementProgress(1);
		if (domainFile.getContentType().equals(ProgramContentHandler.PROGRAM_CONTENT_TYPE)) {
			programs.add(domainFile);
		}
	}
	DomainFolder[] folders = myFolder.getFolders();
	for (DomainFolder domainFolder : folders) {
		monitor.checkCanceled();
		monitor.incrementProgress(1);
		findPrograms(programs, domainFolder, monitor);
	}
}
 
Example #13
Source File: IngestTask.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public IngestTask(String title, FidFile fidFile, LibraryRecord libraryRecord,
		DomainFolder folder, String libraryFamilyName, String libraryVersion,
		String libraryVariant, String languageId, File commonSymbolsFile, FidService fidService,
		FidPopulateResultReporter reporter) {
	super(title);
	this.fidFile = fidFile;
	this.libraryRecord = libraryRecord;
	this.folder = folder;
	this.libraryFamilyName = libraryFamilyName;
	this.libraryVersion = libraryVersion;
	this.libraryVariant = libraryVariant;
	this.commonSymbolsFile = commonSymbolsFile;
	this.fidService = fidService;
	this.reporter = reporter;
	this.languageId = new LanguageID(languageId);
}
 
Example #14
Source File: ProjectDataRenameAction.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean isEnabledForContext(ProjectDataContext context) {
	if (!context.hasExactlyOneFileOrFolder()) {
		return false;
	}
	if (context.getFileCount() == 1) {
		DomainFile file = context.getSelectedFiles().get(0);
		if (file.isReadOnly()) {
			return false;
		}
	}
	else {
		DomainFolder folder = context.getSelectedFolders().get(0);
		if (folder.getParent() == null) {
			return false;  // can't rename root folder
		}
	}
	if (context.isReadOnlyProject()) {
		return false;
	}
	return true;
}
 
Example #15
Source File: ProjectDataDeleteAction.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected void actionPerformed(ProjectDataContext context) {
	Set<DomainFile> files = CollectionUtils.asSet(context.getSelectedFiles());
	Set<DomainFolder> folders = CollectionUtils.asSet(context.getSelectedFolders());

	// Task 1 - count the files.  This probably does not need a task, but just in case.
	CountDomainFilesTask countTask = new CountDomainFilesTask(folders, files);
	new TaskLauncher(countTask, context.getComponent(), 750);
	if (countTask.wasCancelled()) {
		return;
	}

	// Confirm the delete *without* using a task so that do not have 2 dialogs showing
	int fileCount = countTask.getFileCount();
	if (!confirmDelete(fileCount, files, context.getComponent())) {
		return;
	}

	// Task 2 - perform the delete--this could take a while
	DeleteProjectFilesTask deleteTask = createDeleteTask(context, files, folders, fileCount);
	TaskLauncher.launch(deleteTask);
}
 
Example #16
Source File: ProjectDataNewFolderAction.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new folder for the selected node that represents
 * a folder.
 */
private void createNewFolder(T context) {
	DomainFolder parentFolder = getFolder(context);

	DomainFolder newFolder = createNewFolderWithDefaultName(parentFolder);
	DataTree tree = context.getTree();

	Swing.runLater(() -> {
		GTreeNode node = findNodeForFolder(tree, newFolder);
		if (node != null) {
			tree.setEditable(true);
			tree.startEditing(node.getParent(), node.getName());
		}
	});

}
 
Example #17
Source File: LocalTreeNodeHandler.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void handleFileDrag(DomainFolder destFolder, int dropAction, DomainFile file,
		TaskMonitor monitor) {
	if (dropAction == DnDConstants.ACTION_COPY || !file.isInWritableProject()) {
		CopyTask task = new CopyTask(destFolder, file);
		task.run(monitor);
		return;
	}

	try {
		file.moveTo(destFolder);
	}
	catch (IOException e) {
		String msg = e.getMessage();
		if (msg == null) {
			msg = e.toString();
		}
		Msg.showError(this, dataTree, "Cannot Move File",
			"Move file " + file.getName() + " failed.\n" + msg);
	}
}
 
Example #18
Source File: FrontEndPluginActionsTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testExpandAll() throws Exception {
	DomainFolder f = rootFolder.createFolder("myFolder");
	f = f.createFolder("A");
	f = f.createFolder("B");
	f = f.createFolder("C");
	waitForSwing();

	GTreeNode myNode = rootNode.getChild("myFolder");
	setSelectionPath(rootNode.getTreePath());
	DockingActionIf expandAction = getAction("Expand All");
	performAction(expandAction, getDomainFileActionContext(), true);
	GTreeNode aNode = myNode.getChild("A");
	assertNotNull(aNode);
	GTreeNode bNode = aNode.getChild("B");
	assertNotNull(bNode);
	GTreeNode cNode = bNode.getChild("C");
	assertNotNull(cNode);
}
 
Example #19
Source File: GenerateLotsOfProgramsScript.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void createPrograms(DomainFolder parent, int count)
		throws IOException, InvalidNameException, CancelledException {
	Processor processor = Processor.toProcessor("x86");
	Language language = getDefaultLanguage(processor);
	Program program = new ProgramDB("dummy", language, language.getDefaultCompilerSpec(), this);
	for (int i = 0; i < count; i++) {
		parent.createFile("Prog_" + i, program, monitor);
	}
	program.release(this);
}
 
Example #20
Source File: RecursiveRecursiveMSLibImport.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private Pair<DomainFolder, String> establishProgramFolder(DomainFolder current,
		String preferredName) throws InvalidNameException, IOException {
	String[] splits = preferredName.split("[/\\\\]");
	for (int ii = 0; ii < splits.length - 1; ++ii) {
		String nextName = splits[ii];
		DomainFolder next = current.getFolder(nextName);
		if (next == null) {
			next = current.createFolder(mangleNameBecauseDomainFoldersAreSoRetro(nextName));
		}
		current = next;
	}
	return new Pair<DomainFolder, String>(current, splits[splits.length - 1]);
}
 
Example #21
Source File: JavaFileListHandler.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void doImport(FileImporterService importer, DomainFolder folder, Object files) {

		List<File> fileList = CollectionUtils.asList((List<?>) files, File.class);
		if (fileList.size() == 1 && fileList.get(0).isFile()) {
			importer.importFile(folder, fileList.get(0));
		}
		else {
			importer.importFiles(folder, fileList);
		}
	}
 
Example #22
Source File: IntelHexLoader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected List<Program> loadProgram(ByteProvider provider, String programName,
		DomainFolder programFolder, LoadSpec loadSpec, List<Option> options, MessageLog log,
		Object consumer, TaskMonitor monitor) throws IOException, CancelledException {
	LanguageCompilerSpecPair pair = loadSpec.getLanguageCompilerSpec();
	Language importerLanguage = getLanguageService().getLanguage(pair.languageID);
	CompilerSpec importerCompilerSpec =
		importerLanguage.getCompilerSpecByID(pair.compilerSpecID);

	Program prog = createProgram(provider, programName, null, getName(), importerLanguage,
		importerCompilerSpec, consumer);
	boolean success = false;
	try {
		success = loadInto(provider, loadSpec, options, log, prog, monitor);
		if (success) {
			createDefaultMemoryBlocks(prog, importerLanguage, log);
		}
	}
	finally {
		if (!success) {
			prog.release(consumer);
			prog = null;
		}
	}
	List<Program> results = new ArrayList<Program>();
	if (prog != null) {
		results.add(prog);
	}
	return results;
}
 
Example #23
Source File: ElfLoader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected void postLoadProgramFixups(List<Program> importedPrograms, DomainFolder importFolder,
		List<Option> options, MessageLog messageLog, TaskMonitor monitor)
		throws CancelledException, IOException {
	super.postLoadProgramFixups(importedPrograms, importFolder, options, messageLog, monitor);

	if (OptionUtils.getBooleanOptionValue(
		ElfLoaderOptionsFactory.RESOLVE_EXTERNAL_SYMBOLS_OPTION_NAME, options,
		ElfLoaderOptionsFactory.RESOLVE_EXTERNAL_SYMBOLS_DEFAULT)) {
		for (Program importedProgram : importedPrograms) {
			ELFExternalSymbolResolver.fixUnresolvedExternalSymbols(importedProgram, true,
				messageLog, monitor);
		}
	}
}
 
Example #24
Source File: MotorolaHexLoader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected List<Program> loadProgram(ByteProvider provider, String programName,
		DomainFolder programFolder, LoadSpec loadSpec, List<Option> options, MessageLog log,
		Object consumer, TaskMonitor monitor) throws IOException, CancelledException {
	LanguageCompilerSpecPair pair = loadSpec.getLanguageCompilerSpec();
	Language importerLanguage = getLanguageService().getLanguage(pair.languageID);
	CompilerSpec importerCompilerSpec =
		importerLanguage.getCompilerSpecByID(pair.compilerSpecID);

	Program prog = createProgram(provider, programName, null, getName(), importerLanguage,
		importerCompilerSpec, consumer);
	boolean success = false;
	try {
		success = loadInto(provider, loadSpec, options, log, prog, monitor);
		if (success) {
			createDefaultMemoryBlocks(prog, importerLanguage, log);
		}
	}
	finally {
		if (!success) {
			prog.release(consumer);
			prog = null;
		}
	}
	List<Program> results = new ArrayList<Program>();
	if (prog != null) {
		results.add(prog);
	}
	return results;
}
 
Example #25
Source File: GhidraFileTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testRenameFolder() throws IOException, InvalidNameException {
	createDB(sharedFS, "/a", "A");
	createDB(sharedFS, "/a", "B");
	refresh();

	DomainFolder folder = root.getFolder("a");
	folder.getFiles();// visit folder

	folder = folder.setName("C");
	assertEquals("C", folder.getName());

	DomainFile df = folder.getFile("A");
	assertNotNull(df);
	assertEquals("/C/A", df.getPathname());

	df = folder.getFile("B");
	assertNotNull(df);
	assertEquals("/C/B", df.getPathname());

	assertNull(root.getFolder("a"));

	GhidraFolder dFolder = root.createFolder("D");
	dFolder.getFiles();// visit folder

	folder = folder.moveTo(dFolder);

	df = folder.getFile("A");
	assertNotNull(df);
	assertEquals("/D/C/A", df.getPathname());

	df = folder.getFile("B");
	assertNotNull(df);
	assertEquals("/D/C/B", df.getPathname());

	assertNull(root.getFolder("C"));

}
 
Example #26
Source File: XmlLoader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected List<Program> loadProgram(ByteProvider provider, String programName,
		DomainFolder programFolder, LoadSpec loadSpec, List<Option> options, MessageLog log,
		Object consumer, TaskMonitor monitor) throws IOException, CancelledException {
	List<Program> results = new ArrayList<>();

	LanguageCompilerSpecPair pair = loadSpec.getLanguageCompilerSpec();
	Language importerLanguage = getLanguageService().getLanguage(pair.languageID);
	CompilerSpec importerCompilerSpec =
		importerLanguage.getCompilerSpecByID(pair.compilerSpecID);

	ParseResult result = parse(provider);

	if (result.lastInfo == null) {
		return results;
	}
	Address imageBase = null;
	if (result.lastInfo.imageBase != null) {
		imageBase = importerLanguage.getAddressFactory().getAddress(result.lastInfo.imageBase);
	}
	Program prog = createProgram(provider, programName, imageBase, getName(), importerLanguage,
		importerCompilerSpec, consumer);
	boolean success = false;
	try {
		success = doImport(result.lastXmlMgr, options, log, prog, monitor, false);
		if (success) {
			createDefaultMemoryBlocks(prog, importerLanguage, log);
		}
	}
	finally {
		if (!success) {
			prog.release(consumer);
			prog = null;
		}
	}
	if (prog != null) {
		results.add(prog);
	}
	return results;
}
 
Example #27
Source File: AutoImporter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public static Program importByUsingBestGuess(File file, DomainFolder programFolder,
		Object consumer, MessageLog messageLog, TaskMonitor monitor) throws IOException,
		CancelledException, DuplicateNameException, InvalidNameException, VersionException {
	List<Program> programs = importFresh(file, programFolder, consumer, messageLog, monitor,
		LoaderService.ACCEPT_ALL, LoadSpecChooser.CHOOSE_THE_FIRST_PREFERRED, null,
		OptionChooser.DEFAULT_OPTIONS, MultipleProgramsStrategy.ONE_PROGRAM_OR_NULL);
	if (programs != null && programs.size() == 1) {
		return programs.get(0);
	}
	return null;
}
 
Example #28
Source File: AutoImporter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public static Program importAsBinary(File file, DomainFolder programFolder, Language language,
		CompilerSpec compilerSpec, Object consumer, MessageLog messageLog, TaskMonitor monitor)
		throws IOException, CancelledException, DuplicateNameException, InvalidNameException,
		VersionException {
	List<Program> programs = importFresh(file, programFolder, consumer, messageLog, monitor,
		BINARY_LOADER, new LcsHintLoadSpecChooser(language, compilerSpec), null,
		OptionChooser.DEFAULT_OPTIONS, MultipleProgramsStrategy.ONE_PROGRAM_OR_NULL);
	if (programs != null && programs.size() == 1) {
		return programs.get(0);
	}
	return null;
}
 
Example #29
Source File: AutoImporter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public static Program importByUsingBestGuess(ByteProvider provider, DomainFolder programFolder,
		Object consumer, MessageLog messageLog, TaskMonitor monitor) throws IOException,
		CancelledException, DuplicateNameException, InvalidNameException, VersionException {
	List<Program> programs = importFresh(provider, programFolder, consumer, messageLog, monitor,
		LoaderService.ACCEPT_ALL, LoadSpecChooser.CHOOSE_THE_FIRST_PREFERRED, null,
		OptionChooser.DEFAULT_OPTIONS, MultipleProgramsStrategy.ONE_PROGRAM_OR_NULL);
	if (programs != null && programs.size() == 1) {
		return programs.get(0);
	}
	return null;
}
 
Example #30
Source File: BatchImportDialog.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private BatchImportDialog(BatchInfo batchInfo, DomainFolder defaultFolder) {
	super("Batch Import", true);

	this.batchInfo = (batchInfo != null) ? batchInfo : new BatchInfo();
	this.destinationFolder = defaultFolder != null ? defaultFolder
			: ghidra.framework.main.AppInfo.getActiveProject().getProjectData().getRootFolder();
	setHelpLocation(new HelpLocation("ImporterPlugin", "Batch_Import_Dialog"));

	// a reasonable size that is long enough to show path information and table columns with
	// a height that has enough room to show table rows and import sources
	setPreferredSize(900, 600);
}