Skip to content

Commit

Permalink
remove c keywords when parsing function signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
astrelsky committed Apr 27, 2024
1 parent e6c8f5b commit 0b68cd2
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -191,6 +191,12 @@ private void addParameter(List<ParameterDefinition> parameterList, String arg)
if (arg.length() == 0) {
throw new ParseException("Missing parameter");
}

// remove c keywords that Ghidra doesn't support
arg = arg.replaceAll("\\b((const)|(volatile)|(restrict)|(struct)|(union))\\b", "");

// remove any trailing whitespace and semicolon
arg = arg.replaceAll("\\s*;?\\s*$", "");

// Attempt to resolve parameter assuming only a datatype is specified
DataType dt = resolveDataType(arg);
Expand Down Expand Up @@ -260,6 +266,9 @@ DataType extractReturnType(String signatureText) throws ParseException, Cancelle
throw new ParseException("Can't find return type");
}
String returnTypeName = StringUtils.join(split, " ", 0, split.length - 1);

// remove any c keywords from the return type name
returnTypeName = returnTypeName.replaceAll("\\b((static)|(inline)|(const)|(volatile)|(restrict)|(struct)|(union))\\b", "");

DataType dt = resolveDataType(returnTypeName);
if (dt == null) {
Expand Down

0 comments on commit 0b68cd2

Please sign in to comment.