Vector35 / Vector35/binaryninja-api

Option for showing variable types only at top of function

Open
#3,313 0 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: UI Effort: Low Impact: Medium UI: Linear
Dominant language
C++
Stars
1.3k
Forks
298
Avg merge
5d 5h
Merged PRs (30d)
19

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the existing “Show Variable Types as At Top of Function” option in the Binary Ninja decompiler and trace how it controls HLIL or pseudo-C output. Define the separate “at top of function only” behavior using the two examples, then add coverage for both output modes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
reverse-engineering
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.