mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch
'origin/GP-3446_ryanmkurtz_OriginalFileExporter' into patch (Closes #5346)
This commit is contained in:
commit
79c9e5cee6
1 changed files with 11 additions and 4 deletions
|
@ -178,6 +178,10 @@ public class OriginalFileExporter extends Exporter {
|
|||
Iterable<Relocation> relocs = () -> program.getRelocationTable().getRelocations();
|
||||
Memory memory = program.getMemory();
|
||||
for (Relocation reloc : relocs) {
|
||||
if (reloc.getStatus() != Relocation.Status.APPLIED &&
|
||||
reloc.getStatus() != Relocation.Status.APPLIED_OTHER) {
|
||||
continue;
|
||||
}
|
||||
Address addr = reloc.getAddress();
|
||||
AddressSourceInfo addrSourceInfo = memory.getAddressSourceInfo(addr);
|
||||
if (addrSourceInfo == null) {
|
||||
|
@ -187,10 +191,12 @@ public class OriginalFileExporter extends Exporter {
|
|||
if (offset >= 0) {
|
||||
MemoryBlockSourceInfo memSourceInfo = addrSourceInfo.getMemoryBlockSourceInfo();
|
||||
byte[] bytes = reloc.getBytes();
|
||||
int len = Math.min(bytes.length,
|
||||
(int) memSourceInfo.getMaxAddress().subtract(addr) + 1);
|
||||
fout.seek(offset);
|
||||
fout.write(bytes, 0, len);
|
||||
if (bytes != null) {
|
||||
int len = Math.min(bytes.length,
|
||||
(int) memSourceInfo.getMaxAddress().subtract(addr) + 1);
|
||||
fout.seek(offset);
|
||||
fout.write(bytes, 0, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,6 +204,7 @@ public class OriginalFileExporter extends Exporter {
|
|||
if (!tempFile.delete()) {
|
||||
log.appendMsg("Failed to delete malformed file: " + tempFile);
|
||||
}
|
||||
log.appendException(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue