Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
934 stars 212 forks source link

'create struct members referenced' breaks when structure size is greater than padding threshold (0x10000) #5253

Open psifertex opened 7 months ago

psifertex commented 7 months ago

Structures over 0x400 aren't properly created when using "s" on the call of an allocator:

Note this is especially problematic because it's extremely difficult using the UI to turn the invalid __padding offset back into the actual padding.

(just press "s" on x0_7 and x0_6 in the attached)

Screenshot 2024-04-09 at 22 15 55

sample.zip

xusheng6 commented 7 months ago

The structure are created in the very same way. They look different in the types view because we did some UI hack to avoid the excessive padding in really large structs. You can test that if you create a structure >=0x400 directly, it is the same.

Does this behavior causes anything inconvenient?

CouleeApps commented 7 months ago

This is just a consequence of the analysis.types.paddingThreshold setting being rather low by default. Any types >= that setting are rendered in a single line for performance reasons (previous users had trouble with structures that were gigabytes in size). The default setting value of 0x400 may be a bit too low for this, given that it can trigger with very reasonably sized structs as you've noticed here. So the crux of this issue is likely just "make that setting bigger by default," as it seems to otherwise be working as intended.

psifertex commented 7 months ago

Ultimately rendering it like that is actually fine visually if we fixed the fact that "create struct members referenced" feature fails to work when it's rendered like this. Don't know if that is an easy change or not though.

I might actually change the issue to reflect that is the real breaking bug.