Skip to content

Commit 255b8e5

Browse files
committed
handle VARIABLE varnode in GoFuncCallStrings
1 parent eec9708 commit 255b8e5

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

ghidra_scripts/GoFuncCallStrings.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ protected List<CandidateGroup> callParamsCheck(PcodeOpAST pcodeOpAST) {
8282
addrCandidates.addAll(addrs.stream()
8383
.map(addr -> new AddressCandidate(addr, 0xdeadbeef, pcodeOpAST))
8484
.collect(Collectors.toList()));
85-
continue;
85+
constants.removeAll(addrs.stream()
86+
.map(addr -> addr.getOffset())
87+
.collect(Collectors.toList()));
8688
}
8789

8890
List<Integer> lens = filterLengthConstants(constants);

src/main/java/ghostrings/PcodeUtil.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ private static List<Long> getConstantInputs(FlatProgramAPI programAPI, Varnode v
234234
return results;
235235
}
236236

237+
PcodeOp def = varnode.getDef();
238+
237239
if (varnode.isConstant()) {
238240
results.add(varnode.getOffset());
239-
} else if (varnode.isRegister() && varnode.getDef() != null) {
241+
} else if (varnode.isRegister() && def != null) {
240242
// Register may hold a constant
241-
PcodeOp def = varnode.getDef();
242-
243243
switch (def.getOpcode()) {
244244
case PcodeOp.LOAD:
245245
// Check for LOAD op that loaded a constant into the register,
@@ -276,6 +276,10 @@ private static List<Long> getConstantInputs(FlatProgramAPI programAPI, Varnode v
276276
}
277277
break;
278278
}
279+
} else if (def != null && def.getOpcode() == PcodeOp.PIECE) {
280+
for (Varnode pieceInput: def.getInputs()) {
281+
results.addAll(getConstantInputs(programAPI, pieceInput, depth + 1));
282+
}
279283
}
280284

281285
return results;

0 commit comments

Comments
 (0)