dewolf icon indicating copy to clipboard operation
dewolf copied to clipboard

[Types] Create function pointer type

Open mari-mari opened this issue 3 years ago • 2 comments

Proposal

Add support to function pointers.

If a variable is called at some point, the type of it could be set to a function pointer.

Consider the following example:

$ python decompile.py extractme main
...
      int var_0;
...
      memcpy(var_0, 0x804c020, 71);
      var_0();
      var_0 = 0;
...

here, since the var_0 is being called after initialization, we can set its type to function pointer instead of integer. extractme.zip

Approach

  • add new type FunctionPointer with the following fields
    • name
    • return type
    • parameter / argument types
  • update TypePropagation to consider variables that are being called.
  • update CodeGenerator to generate declarations for the corresponding function pointers if needed.

mari-mari avatar Jan 25 '22 09:01 mari-mari

/cib

fnhartmann avatar Feb 22 '24 10:02 fnhartmann