Java Code Examples for org.apache.commons.collections4.BidiMap#keySet()
The following examples show how to use
org.apache.commons.collections4.BidiMap#keySet() .
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: PrelinkFileSystem.java From ghidra with Apache License 2.0 | 5 votes |
/** * Processes PRELINK and Macho-O offsets in order to map files to their Mach-O offsets in the * providers. * * @param prelinkList The list of discovered {@link PrelinkMap}s. * @param machoHeaderOffsets The list of provider offsets where prelinked Mach-O headers start. * @param monitor A monitor * @throws IOException if an IO-related problem occurred. * @throws MachException if there was a problem parsing Mach-O headers. */ private void processPrelinkWithMacho(List<PrelinkMap> prelinkList, List<Long> machoHeaderOffsets, TaskMonitor monitor) throws IOException, MachException { monitor.setMessage("Processing PRELINK with found Mach-O headers..."); monitor.initialize(prelinkList.size()); BidiMap<PrelinkMap, Long> map = MachoPrelinkUtils.matchPrelinkToMachoHeaderOffsets(provider, prelinkList, machoHeaderOffsets, monitor); for (PrelinkMap info : map.keySet()) { if (monitor.isCancelled()) { break; } monitor.incrementProgress(1); if (info.getPrelinkBundlePath() == null) { continue; } // The following could end up being a directory once we discover it has a child...we'll // handle that in storeFile() GFileImpl file = GFileImpl.fromPathString(this, root, info.getPrelinkBundlePath(), null, false, 0); if (info.getPrelinkExecutableSize() > -1) { file.setLength(info.getPrelinkExecutableSize()); } file = storeFile(file, info); if (isChildOf(systemKextFile, file)) { continue; } fileToMachoOffsetMap.put(file, map.get(info)); } }
Example 2
Source File: DecompilerNestedLayout.java From ghidra with Apache License 2.0 | 4 votes |
private BlockGraph buildCurrentFunctionGraph(Program program, VisualGraph<FGVertex, FGEdge> jungGraph, TaskMonitor taskMonitor) throws CancelledException { CodeBlockModel blockModel = new BasicBlockModel(program); AddressSetView addresses = function.getBody(); CodeBlockIterator iterator = blockModel.getCodeBlocksContaining(addresses, taskMonitor); BlockGraph blockGraph = new BlockGraph(); BidiMap<CodeBlock, PcodeBlock> bidiMap = new DualHashBidiMap<>(); for (; iterator.hasNext();) { taskMonitor.checkCanceled(); CodeBlock codeBlock = iterator.next(); FGVertex vertex = getVertex(jungGraph, codeBlock.getMinAddress()); if (vertex == null) { // this is unusual; can happen if the program is being changed while this is running continue; } PcodeBlock pcodeBlock = new BlockCopy(vertex, codeBlock.getMinAddress()); bidiMap.put(codeBlock, pcodeBlock); blockGraph.addBlock(pcodeBlock); } for (CodeBlock block : bidiMap.keySet()) { taskMonitor.checkCanceled(); CodeBlockReferenceIterator destinations = block.getDestinations(taskMonitor); while (destinations.hasNext()) { taskMonitor.checkCanceled(); CodeBlockReference ref = destinations.next(); // We only want control flow that is internal to the function. Make sure to // exclude the case where a function contains a (recursive) call to itself: // The reference would be between addresses internal to the function, but the // link doesn't represent internal flow. So we filter out ANY call reference. if (ref.getFlowType().isCall()) { continue; } CodeBlock destination = ref.getDestinationBlock(); PcodeBlock sourcePcodeBlock = bidiMap.get(block); PcodeBlock destPcodeBlock = bidiMap.get(destination); if (destPcodeBlock == null) { continue; } blockGraph.addEdge(sourcePcodeBlock, destPcodeBlock); } } blockGraph.setIndices(); return blockGraph; }