Struct Overlapping Single Variables on Stack

Open
#5,285 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp

Research direction

Start with discussion #5260 and the linked private issue, since no source file, test, or entry point is named here. The desired result is to retain earlier overlapping stack variables while showing the later struct and its members at the same addresses.

Written by the indexing model from the issue text.

Description

Component: Core

If I understand the following correctly, I do not believe we currently support this use-case. But, I can understand how/why it would be useful. So, we should consider adding support for this.

EDIT: Vector 35 employees, please see the private issue that has been linked into this one below that discusses some implementation details.

Discussed in https://github.com/Vector35/binaryninja-api/discussions/5260

Originally posted by utkonos April 10, 2024
When a particular address on the stack is used for different variables, they're all created automatically and nicely (this is just an examples of overlap at an address; these particular variables are totally not related to the problem below):
image

However, if I want to set the type to a struct that overlaps the locations used previously on the stack, after setting that type, the other varables are gone. Is there a way to get this to work?

Here is how the Stack view looks before. That struct is incorrectly a pointer at the moment just as a placeholder.
image

The two variables enc_str.size and fill_value are both input parameters for init_string here:
image

That function cleans up the stack via ret 8.

Later in the function, space is created for the struct on the stack via sub esp, 0x18. For some reason, if I set the type at that location to the struct, it blows away those two previous stack variables.
image

I want to keep those two variables in the second screenshot above and set a struct at the same addresses in the stack. This way it reflects both usages at the different points in the function.

Is what I want to do possible? I can always just write comments to work around this, but the downstream uses of that struct don't show up nicely with the members in the disassembly view.

Dominant language
C++
Stars
1.3k
Forks
298
Avg merge
5d 5h
Merged PRs (30d)
19

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.

More from Vector35/binaryninja-api

All issues in Vector35/binaryninja-api

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.