-
Hi! Migrating my IDA gui scripts wrote simple plugin to implement string creation from selection, but found strange behavior of BN when defining global variable from python: from binaryninjaui import (UIAction, UIActionHandler)
def handle_action(context):
current_selection_range = context.view.getSelectionOffsets()
bv = context.binaryView
t = bv.parse_type_string(f"char[{current_selection_range[1] - current_selection_range[0]}]")
bv.define_user_data_var(current_selection_range[0], t[0])
UIAction.registerAction("Enhanced make string")
UIActionHandler.globalActions().bindAction("Enhanced make string", UIAction(handle_action)) actually same behavior if define string from python-console So the question is how can i refresh current view from python to force BN render created variable? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
RE: 2) can you screenshot what you mean when you say the selection doesn't match? Do you mean the offset and bytes in the bottom-right don't match what you actually have selected? RE: 1) you may need to trigger update_analysis_and_wait. The scripting console and snippets do this for you automatically but plugins do not since it's not necessarily obvious that all scripts should immediately trigger analysis so it's not forced on any plugin. However, there is a known visual issue where sometimes after making changes you have to navigate the UI to get it freshed and we don't have a known fix for it at this time beyond just moving or hitting space twice to make the view refresh. |
Beta Was this translation helpful? Give feedback.
RE: 2) can you screenshot what you mean when you say the selection doesn't match? Do you mean the offset and bytes in the bottom-right don't match what you actually have selected?
RE: 1) you may need to trigger update_analysis_and_wait. The scripting console and snippets do this for you automatically but plugins do not since it's not necessarily obvious that all scripts should immediately trigger analysis so it's not forced on any plugin. However, there is a known visual issue where sometimes after making changes you have to navigate the UI to get it freshed and we don't have a known fix for it at this time beyond just moving or hitting space twice to make the view refresh.