Skip to content

Commit

Permalink
adds a more informative error message
Browse files Browse the repository at this point in the history
  • Loading branch information
huettenhain committed Mar 16, 2020
1 parent 6f936dd commit 63ab807
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions DhrakeParseClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import ghidra.program.model.data.DataType;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.GhidraClass;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.symbol.SourceType;

public class DhrakeParseClass extends GhidraScript {
Expand All @@ -35,11 +36,19 @@ protected void log(String message) {

@Override
protected void run() throws Exception {

String className = null;
Address nameAddress = this.toAddr(this.getInt(currentAddress.add(32)));
String className = new String(
this.getBytes(nameAddress.add(1), this.getByte(nameAddress))
);
try {
className = new String(this.getBytes(nameAddress.add(1), this.getByte(nameAddress)));
} catch (MemoryAccessException e) {
this.popup(
"Unfortunately, we got a memory access error trying to even read the class name. " +
"Either you executed this at the wrong address or the class metadata layout is " +
"unknown. If you can figure out how to identify this Delphi compiler and how it " +
"stores class metadata, that'd be Bill-Lumbergh-Level great."
);
return;
}
assert className.startsWith("T");
this.log(className);
this.log(String.format("creating class %s", className));
Expand Down

0 comments on commit 63ab807

Please sign in to comment.