set_prototype
Define a function's signature and C++ method context to improve decompilation. Specify return type, parameters, and class to propagate class types through callers.
Instructions
Set a function's prototype, including a C++ this pointer and methods.
This is the main tool for typing C++ methods so the decompiler propagates
the class type through callers and grows the class struct. Datatypes are
resolved from the program's datatype manager (create them first with
`set_types` when needed). The result reports the signature before and after.
Two ways to specify the signature:
- `prototype`: a full C declaration string, e.g.
`"int process(MyClass *this, int cmd)"`. Parsed and applied as-is.
- structured: `return_type` (e.g. `"void"`), `parameters` (a list of
`{"name": ..., "type": ...}` objects; a bare type string is also
accepted), and optionally a leading `this` pointer (see below).
C++ method typing (structured mode):
- `class_name`: attach the function as a method of this class (a real
`GhidraClass`, created if missing) and, unless `this_type` is given, add a
leading `this` parameter of type `<class_name> *`. An empty struct named
after the class is created if one does not exist yet, so the decompiler
has a type to grow.
- `this_type`: explicit type for the leading `this` parameter, e.g.
`"MyClass"` (a ` *` is added if absent). Overrides the class-derived type.
`calling_convention` is applied only if the program's language defines it
(e.g. `__thiscall` exists on x86 but usually not on embedded targets); an
undefined convention is reported in `notes` and left unchanged. On most
embedded ABIs the `this` pointer is simply the first argument under the
default convention, which this tool sets up correctly without a special
convention. When you do use `__thiscall`, omit the explicit `this` (Ghidra
injects it); otherwise pass `this` via `class_name`/`this_type`.
Args:
target: Function selector (address, exact label, or function name).
program: Required Ghidra project path or name to target.
prototype: Full C declaration string. Takes precedence when supplied.
return_type: Return datatype name (structured mode).
parameters: Ordered parameter list as `{"name", "type"}` objects
(structured mode), excluding the auto-added `this`.
calling_convention: Optional calling-convention name to apply if the
language defines it.
this_type: Explicit `this`-pointer datatype (structured mode).
class_name: Class to attach the method to and derive `this` from.
timeout: Bridge execution timeout in seconds.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | ||
| program | Yes | ||
| timeout | No | ||
| prototype | No | ||
| this_type | No | ||
| class_name | No | ||
| parameters | No | ||
| return_type | No | ||
| calling_convention | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |