Skip to content

Instantly share code, notes, and snippets.

@b2ag
b2ag / gist:1eb9cafb0e269165191339fc9395b5e0
Last active April 28, 2023 22:47
Ghidra import_memory_map_from_other_program (assumes tool as program loaded and another program named 'FragmentBundle_F.prx' exists)
def import_memory_map_from_other_program( program2_name ):
program2_file = state.getProject().getProjectData().getRootFolder().getFile(program2_name)
program2 = program2_file.getImmutableDomainObject(currentProgram,ghidra.framework.model.DomainFile.DEFAULT_VERSION,monitor)
try:
# process each memory block from program2
for memblock in program2.getMemory().getBlocks():
#memblock = program2.getMemory().getBlocks()[0]
if memblock.isOverlay() or not memblock.isInitialized():
print('Memblock "{}" of "{}" is overlay or not initialized. Skipping.'.format(memblock.getName(),program2_name))
continue