mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
more changes for filebytes
This commit is contained in:
parent
8576bd66e9
commit
a8934fbd95
3 changed files with 100 additions and 118 deletions
|
@ -26,8 +26,9 @@
|
|||
import java.util.Iterator;
|
||||
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.app.util.MemoryBlockUtil;
|
||||
import ghidra.app.util.MemoryBlockUtils;
|
||||
import ghidra.app.util.NamespaceUtils;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.mem.*;
|
||||
import ghidra.program.model.symbol.*;
|
||||
|
@ -241,45 +242,29 @@ public class MergeTwoProgramsScript extends GhidraScript {
|
|||
|
||||
private void mergeMemory( Program currProgram, Program otherProgram ) throws Exception {
|
||||
monitor.setMessage( "Merging memory..." );
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(currProgram);
|
||||
try {
|
||||
Memory otherMemory = otherProgram.getMemory();
|
||||
MemoryBlock [] otherBlocks = otherMemory.getBlocks();
|
||||
for ( MemoryBlock otherBlock : otherBlocks ) {
|
||||
if ( monitor.isCancelled() ) {
|
||||
break;
|
||||
}
|
||||
if ( otherBlock.getType() != MemoryBlockType.DEFAULT ) {
|
||||
printerr( "Unhandled memory block type: " + otherBlock.getName() );
|
||||
continue;
|
||||
}
|
||||
if ( otherBlock.isInitialized() ) {
|
||||
mbu.createInitializedBlock( otherBlock.getName(),
|
||||
otherBlock.getStart(),
|
||||
otherBlock.getData(),
|
||||
otherBlock.getSize(),
|
||||
otherBlock.getComment(),
|
||||
otherBlock.getSourceName(),
|
||||
otherBlock.isRead(),
|
||||
otherBlock.isWrite(),
|
||||
otherBlock.isExecute(),
|
||||
monitor );
|
||||
}
|
||||
else {
|
||||
mbu.createUninitializedBlock( false,
|
||||
otherBlock.getName(),
|
||||
otherBlock.getStart(),
|
||||
otherBlock.getSize(),
|
||||
otherBlock.getComment(),
|
||||
otherBlock.getSourceName(),
|
||||
otherBlock.isRead(),
|
||||
otherBlock.isWrite(),
|
||||
otherBlock.isExecute() );
|
||||
}
|
||||
Memory otherMemory = otherProgram.getMemory();
|
||||
MemoryBlock[] otherBlocks = otherMemory.getBlocks();
|
||||
MessageLog log = new MessageLog();
|
||||
for (MemoryBlock otherBlock : otherBlocks) {
|
||||
if (monitor.isCancelled()) {
|
||||
break;
|
||||
}
|
||||
if (otherBlock.getType() != MemoryBlockType.DEFAULT) {
|
||||
printerr("Unhandled memory block type: " + otherBlock.getName());
|
||||
continue;
|
||||
}
|
||||
if (otherBlock.isInitialized()) {
|
||||
MemoryBlockUtils.createInitializedBlock(currProgram, false, otherBlock.getName(),
|
||||
otherBlock.getStart(), otherBlock.getData(), otherBlock.getSize(),
|
||||
otherBlock.getComment(), otherBlock.getSourceName(), otherBlock.isRead(),
|
||||
otherBlock.isWrite(), otherBlock.isExecute(), log, monitor);
|
||||
}
|
||||
else {
|
||||
MemoryBlockUtils.createUninitializedBlock(currProgram, false, otherBlock.getName(),
|
||||
otherBlock.getStart(), otherBlock.getSize(), otherBlock.getComment(),
|
||||
otherBlock.getSourceName(), otherBlock.isRead(), otherBlock.isWrite(),
|
||||
otherBlock.isExecute(), log);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
mbu.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue