Vector35 / binaryninja-api

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

Swtiching to HLIL from disassembly can cause the linear view to go to a wrong address #5503

Open fakhrizulkifli opened 3 months ago

fakhrizulkifli commented 3 months ago

Version and Platform (required):

Bug Description: Please provide a clear and concise description of what happened.

Switching views between HLIL and Disassembly using TAB key may relocate the highlighted lines elsewhere.

Steps To Reproduce: Please provide all steps required to reproduce the behavior:

  1. Use https://docs.binary.ninja/files/taped binary
  2. Go to 0x8049522
  3. Make sure you are viewing the disassembly in the linear view
  4. Switch to HLIL using TAB key
  5. Observe the line 0x80494d0 is selected
  6. Press Tab again to switch back
  7. Notice now it highlights the line at 0x80494d0

Expected Behavior:

highlighted lines should be somewhere relevant to their IL form.

Screenshots:

https://github.com/Vector35/binaryninja-api/assets/4518763/9cfc8d39-957b-4268-8cf9-81128dcd66bd

Additional Information: Please add any other context about the problem here.

xusheng6 commented 3 months ago

I have updated the repro steps for clearer instructions.

Initially I thought this might be related to the imperfect matching between disassembly and HLIL. However, upon closer examination, it seems NOT the case. When we view disassembly and HLIL side-by-side and select 0x8049522 in the disassembly, we see the line 0x8049528 is selected in the HLIL:

Screenshot 2024-06-11 at 12 50 39 PM

This is correct and expected, since we can verify the disassembly instructions corresponding to the HLIL instruction includes 0x8049522:

Screenshot 2024-06-11 at 12 51 31 PM

So the issue is actually whey the view navigates to 0x80494d0 when we initially switch to HLIL (I expected it to navigate to 0x8049528). When we switch back, it actually goes to the correct address (that is one of the disassembly instruction associated with the HLIL at 0x80494d0)

Also this has nothing to do with switching the view using Tab or the view selection drop-down -- the issue is all the same