Java Code Examples for ghidra.program.model.mem.Memory#getBlocks()
The following examples show how to use
ghidra.program.model.mem.Memory#getBlocks() .
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: MemorySectionResolver.java From ghidra with Apache License 2.0 | 6 votes |
/** * Determine loaded memory conflict set. Use physical address of loaded overlay * blocks to force reconciliation and avoid duplication. * @param rangeMin * @param rangeMax * @return conflict memory set */ private AddressSet getMemoryConflictSet(Address rangeMin, Address rangeMax) { // dedicated non-loaded overlay - don't bother with conflict check if (rangeMin.isNonLoadedMemoryAddress()) { return new AddressSet(); } // Get base memory conflict set Memory memory = getMemory(); AddressSet rangeSet = new AddressSet(rangeMin, rangeMax); AddressSet conflictSet = memory.intersect(rangeSet); // Add in loaded overlay conflicts (use their physical address) for (MemoryBlock block : memory.getBlocks()) { Address minAddr = block.getStart(); Address maxAddr = block.getEnd(); if (minAddr.isLoadedMemoryAddress() && minAddr.getAddressSpace().isOverlaySpace()) { AddressSet intersection = rangeSet.intersectRange(minAddr.getPhysicalAddress(), maxAddr.getPhysicalAddress()); conflictSet.add(intersection); } } return conflictSet; }
Example 2
Source File: FindAudioInProgramScript.java From ghidra with Apache License 2.0 | 6 votes |
List<Address> scanForAudioData(byte[] imageBytes, byte[] mask) { Memory memory = currentProgram.getMemory(); MemoryBlock[] blocks = memory.getBlocks(); List<Address> foundImages = new ArrayList<Address>(); for (int i = 0; i < blocks.length; i++) { if (blocks[i].isInitialized()) { Address start = blocks[i].getStart(); Address found = null; while (true) { if (monitor.isCancelled()) { break; } found = memory.findBytes(start, blocks[i].getEnd(), imageBytes, mask, true, monitor); if (found != null) { foundImages.add(found); start = found.add(1); } else break; } } } return foundImages; }
Example 3
Source File: TreeManager.java From ghidra with Apache License 2.0 | 5 votes |
/** * Method addMemoryBlocks; called when a new module manager is * being created. */ private void addMemoryBlocks(ModuleManager mgr) { Memory memory = program.getMemory(); MemoryBlock[] blocks = memory.getBlocks(); for (MemoryBlock block : blocks) { AddressRange range = new AddressRangeImpl(block.getStart(), block.getEnd()); try { mgr.addMemoryBlock(block.getName(), range); } catch (IOException e) { errHandler.dbError(e); break; } } }
Example 4
Source File: BinaryPropertyListAnalyzer.java From ghidra with Apache License 2.0 | 5 votes |
@Override public boolean canAnalyze(Program program) { // a binary plist does not specify it's length in the header, // the file determines the length. // therefore, a bplist must exists in it's own block // search through each block looking for the magic number Memory memory = program.getMemory(); MemoryBlock[] blocks = memory.getBlocks(); for (MemoryBlock block : blocks) { if (BinaryPropertyListUtil.isBinaryPropertyList(memory, block.getStart())) { return true; } } return false; }
Example 5
Source File: BinaryPropertyListAnalyzer.java From ghidra with Apache License 2.0 | 5 votes |
@Override public boolean analyze(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log) throws Exception { Memory memory = program.getMemory(); for (MemoryBlock block : memory.getBlocks()) { monitor.checkCanceled(); if (BinaryPropertyListUtil.isBinaryPropertyList(memory, block.getStart())) { ByteProvider provider = new ImmutableMemoryRangeByteProvider(memory, block.getStart(), block.getEnd()); markup(block.getStart(), provider, program, monitor); } } removeEmptyFragments(program); return true; }
Example 6
Source File: SearchTextPlugin.java From ghidra with Apache License 2.0 | 5 votes |
private AddressSetView getMemoryAddressSet(Program program, SearchOptions options) { Memory memory = program.getMemory(); if (options.includeNonLoadedMemoryBlocks()) { return memory; } AddressSet set = new AddressSet(); for (MemoryBlock block : memory.getBlocks()) { if (block.isLoaded()) { set.add(block.getStart(), block.getEnd()); } } return set; }
Example 7
Source File: DisassembleCommand.java From ghidra with Apache License 2.0 | 5 votes |
private AddressSetView getExecutableSet(Program program) { Memory memory = program.getMemory(); AddressSet set = new AddressSet(); for (MemoryBlock block : memory.getBlocks()) { if (block.isExecute()) { set.add(block.getStart(), block.getEnd()); } } return set; }
Example 8
Source File: FindImagesScript.java From ghidra with Apache License 2.0 | 5 votes |
List<Address> scanForImages(byte[] imageBytes) { Memory memory = currentProgram.getMemory(); MemoryBlock[] blocks = memory.getBlocks(); byte maskBytes[] = null; List<Address> foundImages = new ArrayList<Address>(); for (int i = 0; i < blocks.length; i++) { if (blocks[i].isInitialized()) { Address start = blocks[i].getStart(); Address found = null; while (true) { if (monitor.isCancelled()) { break; } found = memory.findBytes(start, blocks[i].getEnd(), imageBytes, maskBytes, true, monitor); if (found != null) { foundImages.add(found); start = found.add(1); } else break; } } } return foundImages; }