-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add a hotkey for toggling immediate base (#2420) #2429
base: dev
Are you sure you want to change the base?
Conversation
(Removes the entry from the context menu)
…cpp" This reverts commit 1473d2f.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @plaets thanks for a very nice pull request! Welcome to Cutter <3
This feature is a very good addition as it makes it easier to perform common task such as replacing immediate base.
Before even looking at the code, I have some design concerns I wish to share:
-
The item is shown even when we don't have any candidate for immediate base change. We aspire to make the context menu as much context-aware as possible. And this means not to show redundant menu items that can be irrelevant.
-
Instead of showing "Toggle immediate base (Dec/Hex)" I'd prefer to see the outcome. If it is decimal, show me the hex value in the menu (and in the future also the string value) and if it is hex, show em the decimal.
- as you very wisely mentioned, it's bad that users need to press twice on H in order to change the initial immediate base. We can discuss with people in radare2 as well as trying to figure it out by ourselves.
Thanks for the review!
|
Good point in your (2) paragraph. Maybe @karliss or @thestr4ng3r will know better For point (3), it might require solving it in radare2 to add the immediate base. Need to ask in radare2 group and bug tracker. Maybe @karliss and @thestr4ng3r can help with it as well (cc @ret2libc for point (3) as well, you might know how to solve this issue that the immediate base isn't available) |
I think there is no way currently to determine what is the base used for a number when no hint is defined yet. I see https://github.com/radareorg/radare2/blob/master/libr/parse/filter.c#L402 , which seems to mean that whatever is returned by the disassembler is shown to the user. Capstone seems to show the number as "decimal" if < 10 (by "decimal" i mean that it doesn't show With regards to which number the hint is applied, you could use I think the best thing would be to open an issue on radare2 repository and discuss it there, but probably r2 should provide an API to get these kind of info, though it could be harder than what we think because, as said above, when no hints are set we just get the disassembler default. |
Your checklist for this pull request
Detailed description
This pull request implements issue #2420
Currently, the hotkey to toggle the base is set to
h
, however, I see that Cutter tries to mimic some vim key bindings (j
andk
) and because of thath
might not be the best option. I've also consideredb
or maybe event
but I would need some feedback on that.As I already mentioned in the comments of #2420:
I'm not sure how to fix this yet.
(Also, since I reverted 1473d2 this works in graph view)
Another (potential) problem is that this hotkey is not respecting the condition from
https://github.com/radareorg/cutter/blob/ad66718f375b013a3021e531891c71082ee48867/src/menus/DisassemblyContextMenu.cpp#L415-L421
I can't just disable it from there, since
aboutToShowSlot
is run only on the context menu trigger. That would mean that the hotkey would be disabled every time a user right-clicks on an address that does not meet this condition and enabled only after the user right-clicks on an address that meets this condition. I thought about adding a method to disable/enable the hotkey that would be called every time DissasemblyWidget/GraphWidget is updated, but I'm not sure if this is the best approach and where exactly such method should be called.Test plan (required)
h
or right-click ->Toggle Immediate Base (Hex/Dec)
Closing issues
closes #2420