Vector35 / binaryninja-api

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

Default Make function fails to identify a function for thumb2 binaries #5714

Closed river-li closed 1 month ago

river-li commented 1 month ago

From public slack by @martyx00: https://binaryninja.slack.com/archives/C0CV88A83/p1720515368408829

Bug Description:

A potential bug (or at least weird behavior) I have noticed is that setting the arch and platform and then using the default option of "Make function at this address" (Hotkey P) fails to identify a function, however, selecting that very same platform and architecture from the dropdown menu does so (Linear sweep fails to find that function and makes another one right after it on a non-sense location).

This bug affects thumb2 architecture. Functions created with the default option have a different architecture (armv7).

Example:

>>> current_function.platform
<platform: windows-thumb2>
>>> bv.remove_function(current_function)
>>> # define the function using the default option
>>> current_function.platform
<platform: windows-armv7>

And the newly defined result is not correct.

Steps To Reproduce:

  1. Open any thumb2 arch binary
  2. Find a function
  3. Undefine it
  4. Using hotkey p to define the function
  5. Observe the difference

Expected Behavior:

Make function at this address should stick to the default platform

Screenshots/Video Recording: https://binaryninja.slack.com/files/UQTF3HLN5/F07BLEEKB18/weird.webm

Additional Information Given a function's address, the API get_associated_arch_by_address will always return armv7(the function start address is aligned?). Seems like it is not very useful when defining functions.

river-li commented 1 month ago

Duplicate of #1177