radeco icon indicating copy to clipboard operation
radeco copied to clipboard

Use SDB to determine the number of argument of a given function

Open Maijin opened this issue 6 years ago • 9 comments

tmp = sym.imp.puts("Hello, world.", rsi, rdx, rcx, r8, r9) -> anal/types/func.puts.args=1 tmp = sym.imp.puts("Hello, world.", rsi)

Maijin avatar Aug 13 '18 12:08 Maijin

Can probably add a new r2 command that provide the return type and one that provide the number of argument from the function definition afcfj?

Maijin avatar Aug 16 '18 10:08 Maijin

@Maijin sounds like a good idea. @sivaramaaa do you think anything else can be done here?

XVilka avatar Aug 16 '18 10:08 XVilka

@Maijin , IMHO i think , no need to print the registers if we already no the value in it , the below output will be very close to original C code i guess !

tmp = sym.imp.puts("Hello, world.", rsi, rdx, rcx, r8, r9)
anal/types/func.puts.args=1
+tmp = sym.imp.puts("Hello, world.")
-tmp = sym.imp.puts("Hello, world.", rsi)

And yess , if u guys need the command to afcfj to provide {return type , no of arguments , types of each argument} , pls let me know , i shall implement it !

sivaramaaa avatar Aug 16 '18 11:08 sivaramaaa

yeah well that's up to the @radareorg/radeco team ;) as long as it doesn't print ALL registers that's already better.

Maijin avatar Aug 16 '18 11:08 Maijin

yeah if you can implement such a command i think could be useful for that case

Maijin avatar Aug 16 '18 11:08 Maijin

Okk sure , will do it today !

sivaramaaa avatar Aug 16 '18 11:08 sivaramaaa

So i think i have implemented the afcfj command

[0x00000000]> afcfj fgets~{}
[
  {
    "name": "fgets",
    "return": "char *",
    "count": 3,
    "args": [
      {
        "name": "s",
        "type": "char *"
      },
      {
        "name": "size",
        "type": "int"
      },
      {
        "name": "stream",
        "type": "FILE *"
      }
    ]
  }
]

Hopefully this should solve this issue , pls let me know , if u guys feel anything missing !

sivaramaaa avatar Aug 16 '18 17:08 sivaramaaa

@sivaramaaa What happens for no-return functions?

Maijin avatar Aug 17 '18 07:08 Maijin

https://github.com/wargio/r2dec-js/commit/3cfd552cad35275eada93f9d92075f5e5b9bcde5

Maijin avatar Nov 10 '18 17:11 Maijin