Skip to content

Commit

Permalink
Merge pull request #8 from CERTCC/main
Browse files Browse the repository at this point in the history
sync to 230406 release
  • Loading branch information
sei-gwassermann authored Apr 6, 2023
2 parents ce442a4 + 5f0580b commit 4e8224b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extension.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=CERT Kaiju
description=CERT Kaiju - Binary Analysis Framework for Ghidra
author=CERT Executable Code Analysis Team
createdOn=03/30/2023
createdOn=04/06/2023
version=@extversion@
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ protected void hornifyCfg(final HornProgram hornProgram, final HornFunction horn
// Go through each pcode operation and add it as an expression for
// this block
for (final PcodeOp pcode : vertex.getEntity().getPcode()) {
PcodeExpression pcX = new PcodeExpression(pcode);
PcodeExpression pcX = new PcodeExpression(pcode, vertex.getLocator());
pcX.getUseVariables().forEach(newBlock::addUseVariable);
pcX.getDefVariables().forEach(newBlock::addDefVariable);
newBlock.addExpression(pcode, pcX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.microsoft.z3.BoolExpr;
import com.microsoft.z3.Expr;
import com.microsoft.z3.Sort;
import ghidra.program.model.address.Address;
import ghidra.program.model.pcode.HighVariable;
import ghidra.program.model.pcode.PcodeOp;
import ghidra.program.model.pcode.Varnode;
Expand All @@ -32,13 +33,20 @@ public class PcodeExpression implements HornExpression {
private HornVariable outVariable;
private HornExpression operation;
private final PcodeOp pcode;
private Address address;

/**
* @param defVariables
* @param useVariables
* @param inVariables
* @param outVariable
*/

public PcodeExpression(PcodeOp pcode, Address address) {
this(pcode);
this.address = address;
}

public PcodeExpression(PcodeOp pcode) {

this.defVariables = new ArrayList<>();
Expand All @@ -47,13 +55,23 @@ public PcodeExpression(PcodeOp pcode) {
this.outVariable = null;
this.operation = null;
this.pcode = pcode;
this.address = null;

// First the I/O variables must be computed
try {
computeIOVariables();
} catch (Exception e) {
Msg.error(this, "Failed to generate variables for p-code: " + pcode);
throw new GhiHornException("Failed to generate variables for p-code: " + pcode + ". This is an issue with Ghidra's HighConstant class");
StringBuilder errorMessage = new StringBuilder("Failed to generate variables for p-code");
if (this.address != null) {
errorMessage.append(" at address " + this.address + ":");
} else {
errorMessage.append(":");
}
errorMessage.append(pcode);
errorMessage.append(", exception: " + e.getMessage());
errorMessage.append(". This is an issue with Ghidra's HighConstant class.");
Msg.error(this, errorMessage);
throw new GhiHornException(errorMessage.toString());
}

// Second the operations need to be generated from the I/O variables. This will
Expand Down

0 comments on commit 4e8224b

Please sign in to comment.