Skip to content

Commit 78833ee

Browse files
committed
GhiHorn improvements
1 parent 202a07c commit 78833ee

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Current Release
22

3+
## 231201
4+
5+
- Improvements:
6+
* Improve HighCfg entry node heuristic
7+
* Add additional logging when failing to create decompiler
8+
* Ensure that start and goal addresses are valid instructions
9+
310
## 231003
411

512
- Improvements:

src/main/java/kaiju/tools/ghihorn/decompiler/DecompilerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public DecompInterface createDecompiler() {
3232
options.grabFromToolAndProgram(null, opt, program);
3333
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException
3434
| InvocationTargetException | SecurityException e) {
35-
throw new RuntimeException("Unable to create decompiler");
35+
throw new RuntimeException("Unable to create decompiler: " + e.toString(), e);
3636
}
3737

3838
decompiler.setOptions(options);

src/main/java/kaiju/tools/ghihorn/tools/pathanalyzer/PathAnalyzerController.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.HashMap;
1515
import java.util.List;
1616
import java.util.Map;
17+
import java.util.function.Consumer;
1718
import java.util.stream.Collectors;
1819
import javax.swing.BorderFactory;
1920
import javax.swing.JCheckBox;
@@ -415,11 +416,16 @@ public List<Map<String, Object>> getCommandParameters() throws Exception {
415416
final Address endAddr = program.getAddressFactory().getDefaultAddressSpace()
416417
.getAddress(goalAddrText.getText());
417418

418-
// Make sure that the program contains the specified addresses
419-
if (!program.getMemory().contains(startAddr)
420-
|| !program.getMemory().contains(endAddr)) {
421-
throw new RuntimeException();
422-
}
419+
// Make sure that the program contains the specified addresses as instructions
420+
Consumer<Address> verifyAddress = (Address addr) -> {
421+
if (program.getListing().getInstructionAt(addr) == null) {
422+
throw new RuntimeException("Start or goal address " + addr + " is not an instruction");
423+
};
424+
};
425+
426+
verifyAddress.accept(startAddr);
427+
verifyAddress.accept(endAddr);
428+
423429
this.startAddrText.setText(startAddr.toString());
424430

425431
status("Looking for path from " + startAddr + " to " + endAddr);

0 commit comments

Comments
 (0)