Skip to content

ExportCallArgs ​

Tool tools/ghidra/ExportCallArgs.java (ghidra, Ghidra scripts). List every call to chosen functions with the arguments the decompiler can resolve at each call: constants, strings and global addresses.

A Ghidra script: scripts/ghidra-export.sh and scripts/ghidra-run.sh run it headless. Source on GitHub.

Its own help ​

This is the help text in the tool itself, as ./gameframe tool ExportCallArgs prints it.

text
List every call to chosen functions with the arguments the decompiler can resolve at each
call: constants, strings and global addresses. Answers "every sound the game plays and its
id", "every file it opens", "every random draw and its range" in one pass.

Usage: analyzeHeadless PROJECT NAME -process PROGRAM -noanalysis -scriptPath tools/ghidra \
  -postScript ExportCallArgs.java OUTPUT.tsv TARGET [TARGET ...]
TARGET is a function name (as Ghidra or your labels name it) or an address. The output has
one line per call: callee, call address, calling function, then each argument. An argument
the decompiler cannot reduce to a constant shows as the expression's variable name.
It works on the decompiler's P-Code, so it is the same for x86, 68000, MIPS or any other
processor Ghidra supports. scripts/ghidra-run.sh BINARY callargs OUT TARGET... runs it.

regs=SPEC also reads arguments passed in registers, which the decompiler drops when it
assumes a stack convention (Watcom, hand-written assembly). SPEC is `watcom` (EAX, EDX, EBX,
ECX: Watcom's order) or a comma list of register names. For each call it walks back through
the instructions before the call, in the same block, to the last one that writes each
register, and reports a constant it loads (mov REG, imm; xor REG, REG; lea REG, [address]).
A register written another way, or not written in the block, shows as ?. The values follow
the decompiler's arguments as REG=value. It does not follow values across jumps or calls.

Code: Apache 2.0. Content: CC0 1.0. No game material: bring your own copy.