Files
reverse-engineering-anything/docs/providers
morluto 8ff311b4ca feat(ghidra): define function-pointer members and typedefs (#14889)
* feat(ghidra): define function-pointer members and typedefs

define_native_data_types refused every parenthesis in a definition, so
vtables, ops tables and callback structs could not be defined.

Admit ret (*name)(parameters) as a struct or union member or a typedef,
with (**name), (*name[N]) and a calling convention written before the
parenthesis. Ghidra 12.2 stores these as written. The tokenizer still
refuses, at its position, every form Ghidra stores differently: an empty
parameter list (stored as (void)), a calling convention inside the
parenthesis, _Noreturn, a nested function-pointer parameter, grouped
declarators and function types. A parameter Ghidra leaves untyped, such
as a K&R identifier list, is refused after parsing.

Ghidra names these function types by a per-parse counter, which would
collide across calls. Each is stored in /rea_caller_defined as
owner.member, or typedef.target, so a repeat is idempotent and a changed
prototype is refused. Arrays keep the element name they were built with,
so arrays of function pointers are rebuilt around the renamed type.

inspect_native_data_type reports a function type with kind function and
its function_definition: return type, parameters, varargs and calling
convention.

Refs #14887

* fix(ghidra): share caller parameter checks and bound prototype readback

Review of #14889:

- A function pointer after a comma, as in int (*open)(int), (*close)(int);
  or typedef int (*a)(int), (*b)(int);, was refused because its
  parenthesis followed ",". Ghidra 12.2 stores each declarator with the
  shared return type and calling convention, so the declarator check now
  admits "," before the parenthesis.
- A signature and a function-pointer member or typedef checked their
  parameter lists separately, so a function pointer accepted a repeated
  parameter name. requireCallerParameters is now the one check for both:
  repeated names, and a parameter written as a bare name that is not a
  type (a K&R identifier list), which Ghidra stores as undefined. The
  tokenizer records which identifiers fill a whole parameter slot, so an
  explicit undefined parameter type is not mistaken for one. This also
  refuses a K&R signature, which was previously applied with undefined
  parameters.
- inspect_native_data_type serialized every parameter of a function type
  without a bound or cancellation check. It now uses the same 20000-entry
  bound as fields and enum members, checks cancellation per parameter,
  and reports total_parameters and parameters_truncated.

Refs #14887
2026-11-27 10:50:54 -05:00
..