binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

Option for showing variable types only at top of function

Open kevre91 opened this issue 3 years ago • 0 comments

I know that there is an option which is under Show Variable Types as At Top of Function. But this is not what I'm thinking of. Because when I enable that option, it shows variables at top of function, but they also visible in de-compiler output as inline too.

How about adding one more option, in this way there will be two option like:

  • At top of function and inline
  • At top of function only

Let me show an example:

At top of function and inline: Binary ninja already have this.

00401170  void print_list(struct list_T* list)

uint32_t dwCount  {Frame offset -50}
char buf[0x4]  {Frame offset -44}
int32_t i  {Frame offset -40}
char line[0x32]  {Frame offset -3c}
int32_t __saved_ebp  {Frame offset -4}
struct list_T* list  {Frame offset 4}
int32_t eax_1  {Register eax}
HANDLE hOut  {Register eax}
struct person_T* person  {Register edx}

0040117b  int32_t __saved_ebp
0040117b  int32_t eax_1 = stack_cookie ^ &__saved_ebp
00401182  HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE)
004011a6  for (int32_t i = 0; i u< list->size; i = i + 1) {
004011b2      char buf[0x4]
004011b2      my_memset(&buf, 4)
004011c0      char line[0x32]
004011c0      my_memset(&line, 50)
004011d0      struct person_T* person = list->items[i]
004011df      my_strcat(&line, &data_40303c)
004011f1      my_ultostr(person->age, &buf)
00401201      my_strcat(&line, &buf)
00401212      my_strcat(&line, &data_403044)
00401225      my_strcat(&line, person->name)
00401236      my_strcat(&line, &data_40304c)
00401259      uint32_t dwCount
00401259      WriteConsoleA(hOut, &line, my_strlen(&line), &dwCount, nullptr)
0040123e  }
...

At top of function only: This is what I think would be useful.

00401170  void print_list(struct list_T* list)

uint32_t dwCount  {Frame offset -50}
char buf[0x4]  {Frame offset -44}
int32_t i  {Frame offset -40}
char line[0x32]  {Frame offset -3c}
int32_t __saved_ebp  {Frame offset -4}
struct list_T* list  {Frame offset 4}
int32_t eax_1  {Register eax}
HANDLE hOut  {Register eax}
struct person_T* person  {Register edx}

0040117b  eax_1 = stack_cookie ^ &__saved_ebp
00401182  hOut = GetStdHandle(STD_OUTPUT_HANDLE)
004011a6  for (i = 0; i u< list->size; i = i + 1) {
004011b2      my_memset(&buf, 4)
004011c0      my_memset(&line, 50)
004011d0      person = list->items[i]
004011df      my_strcat(&line, &data_40303c)
004011f1      my_ultostr(person->age, &buf)
00401201      my_strcat(&line, &buf)
00401212      my_strcat(&line, &data_403044)
00401225      my_strcat(&line, person->name)
00401236      my_strcat(&line, &data_40304c)
00401259      WriteConsoleA(hOut, &line, my_strlen(&line), &dwCount, nullptr)
0040123e  }
...

This way de-compiler's output could be more clean and suitable for some users needs.

One more step from there would be an option that hides all of variable types from de-compiler output. But if done so, there will be need for feature to show variable types on hover like in IDA. Currently binary ninja shows some explanation about what opcode does, which is, in my humble opinion, a little bit meaningless for HLIL or Pseudo C.

Actually, I think binary ninja should show variable types on hover in HLIL or Pseudo C view regardless of this feature implemented.

kevre91 avatar Jul 21 '22 19:07 kevre91