Skip to content

Ghidra is a software reverse engineering (SRE) framework

fix for MzLoader exception

caheckman8a771971872c
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/clear/ClearFlowAndRepairCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/clear/ClearFlowAndRepairCmd.java
index b0c288e9a7..f38a40b6f0 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/clear/ClearFlowAndRepairCmd.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/clear/ClearFlowAndRepairCmd.java
@@ -213,6 +213,7 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
}
if (repairFunctions) {
repairFunctions(program, clearSet, monitor);
+ monitor.setIndeterminate(false);
}
return true;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/GccExceptionAnalyzer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/GccExceptionAnalyzer.java
index 47f8ef027f..dac4588c0b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/GccExceptionAnalyzer.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/GccExceptionAnalyzer.java
@@ -147,6 +147,8 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
// handleArmSections(program, monitor, log);
visitedPrograms.add(program);
+ monitor.setIndeterminate(false);
+ monitor.setShowProgressValue(true);
return true;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MzLoader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MzLoader.java
index 65896e1cd9..a281102a3c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MzLoader.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MzLoader.java
@@ -202,22 +202,27 @@ public class MzLoader extends AbstractLibrarySupportLoader {
MemoryBlock[] blocks = mem.getBlocks();
for (int i = 1; i < blocks.length; i++) {
- if (!blocks[i].isInitialized()) {
+ MemoryBlock block = blocks[i];
+ if (!block.isInitialized()) {
continue;
}
//scan the first 0x10 bytes of this block
//if a FAR RETURN exists, then move that code
//to the preceding block...
- for (int mIndex = 15; mIndex >= 0; mIndex--) {
+ int mIndex = 15;
+ if (block.getSize() <= 16) {
+ mIndex = (int) block.getSize() - 2;
+ }
+ for (; mIndex >= 0; mIndex--) {
try {
- Address offAddr = blocks[i].getStart().add(mIndex);
- int val = blocks[i].getByte(offAddr);
+ Address offAddr = block.getStart().add(mIndex);
+ int val = block.getByte(offAddr);
val &= 0xff;
if (val == FAR_RETURN_OPCODE) {
// split here and join to previous
Address splitAddr = offAddr.add(1);
- String oldName = blocks[i].getName();
- mem.split(blocks[i], splitAddr);
+ String oldName = block.getName();
+ mem.split(block, splitAddr);
mem.join(blocks[i - 1], blocks[i]);
blocks = mem.getBlocks();
try {