Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum representation shows 'foo | 0x10' instead of 'foo & ~0x10' #4402

Closed
comex opened this issue Jun 11, 2023 · 2 comments
Closed

Enum representation shows 'foo | 0x10' instead of 'foo & ~0x10' #4402

comex opened this issue Jun 11, 2023 · 2 comments
Assignees
Labels
Component: Core Issue needs changes to the core Effort: Trivial Issue should take < 1 day Impact: Medium Issue is impactful with a bad, or no, workaround Type: Bug Issue is a non-crashing bug with repro steps
Milestone

Comments

@comex
Copy link

comex commented Jun 11, 2023

Version and Platform (required):

  • Binary Ninja Version: 3.5.4325-dev (41782587)
  • OS: macOS
  • OS Version: 13.3 (22E252)
  • CPU Architecture: arm64

Bug Description:
When Binary Ninja displays the value 0x23 as type enum e : uint8_t { _0x33 = 0x33 }, it shows _0x33 | 0x10, when it should be _0x33 & ~0x10 or just 0x23.

Steps To Reproduce:

  1. Load this file which just consists of the bytes 0x23 0x33.
  2. Create an enum: enum e : uint8_t { _0x33 = 0x33 }
  3. Create a variable of type enum e for each byte.
  4. Notice the display:
00000000  enum e data_0 = _0x33 | 0x10  // this is 0x23
00000001  enum e data_1 = _0x33  // this is 0x33

Additional Information:
Question: Is there some way to mark an enum as "not a bitfield" so Binary Ninja only uses named constants if there's an exact match?

@plafosse
Copy link
Member

There isn't really a way to mark something as not bitfield. However you can break the logic that makes it infer bitfields by defining something like

enum FOO : int32_t {
  BAR = 1,
  NOT_BITFIELD = 0xFFFFFFFF
  }

@plafosse plafosse added Type: Bug Issue is a non-crashing bug with repro steps Component: Core Issue needs changes to the core Impact: Medium Issue is impactful with a bad, or no, workaround Effort: Trivial Issue should take < 1 day labels Jun 12, 2023
@negasora
Copy link
Member

Fixed in 3.5.4326-dev

@plafosse plafosse added this to the Coruscant milestone Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Issue needs changes to the core Effort: Trivial Issue should take < 1 day Impact: Medium Issue is impactful with a bad, or no, workaround Type: Bug Issue is a non-crashing bug with repro steps
Projects
None yet
Development

No branches or pull requests

3 participants