Skip to main content
Glama
I-CAN-hack
by I-CAN-hack

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

TableJSON Schema
NameRequiredDescriptionDefault
targetYes
programYes
timeoutNo
prototypeNo
this_typeNo
class_nameNo
parametersNo
return_typeNo
calling_conventionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden, and it delivers: it discloses that datatypes are resolved from the datatype manager, that an empty struct may be created when the class does not exist, that `calling_convention` is only applied when supported and otherwise reported in notes, and that the result reports the signature before and after. These are meaningful side effects and edge cases beyond the input schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long, but the tool is complex with 9 parameters, two specification modes, and calling-convention nuances. It is well structured with a lead sentence, short explanatory sections, an example, and a compact Args list. Every sentence adds functional or behavioral information; there is no filler or repetition of schema defaults.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity, no annotation support, and zero schema parameter descriptions, the description covers all necessary context: parameter formats, prerequisites, side effects, precedence rules, and platform-specific calling-convention behavior. The output schema exists, so the mention of before/after signature reporting is sufficient for return-value understanding. An agent can invoke this tool correctly without external documentation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema description coverage is 0%, so the description must fully explain every parameter. It does: the Args section explains target, program, prototype, return_type, parameters, calling_convention, this_type, class_name, and timeout. It also adds crucial semantics like prototype precedence, auto-added `this`, and the ` *` appended to `this_type`, which the schema alone would never convey.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Set a function's prototype, including a C++ `this` pointer and methods.' It further distinguishes the tool as 'the main tool for typing C++ methods,' which separates it from siblings like set_types, apply_types, and create_function. The purpose is concrete and not a tautology or vague restatement.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit when-to-use context: 'This is the main tool for typing C++ methods so the decompiler propagates the class type through callers.' It also names an alternative prerequisite ('create them first with set_types when needed') and gives mode-selection guidance, such as when to use `prototype` vs structured mode and when to omit the explicit `this` with `__thiscall`. This is thorough, practical guidance an agent can act on.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.