summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/examples/follow_reg_render_layer.py39
-rw-r--r--ui/disassemblyview.h2
-rw-r--r--ui/linearview.h2
-rw-r--r--ui/uicontext.h1
-rw-r--r--ui/viewframe.h2
5 files changed, 30 insertions, 16 deletions
diff --git a/python/examples/follow_reg_render_layer.py b/python/examples/follow_reg_render_layer.py
index 36e66576..dd33f6db 100644
--- a/python/examples/follow_reg_render_layer.py
+++ b/python/examples/follow_reg_render_layer.py
@@ -5,6 +5,7 @@ from binaryninja import DisassemblyTextLine, LowLevelILOperation, DisassemblyTex
MediumLevelILOperation, \
RenderLayer, BasicBlock, InstructionTextTokenType, RenderLayerDefaultEnableState, \
PluginCommand, BinaryView, interaction, InstructionTextToken, RegisterValueType
+from binaryninjaui import UIContext, UIActionHandler, UIAction, UIActionContext
"""
@@ -184,26 +185,32 @@ class FollowRegRenderLayer(RenderLayer):
return self.apply_to_lines(block, lines)
-def set_follow_reg(bv: BinaryView):
- if bv.platform is not None:
- regs = list(bv.platform.arch.regs.keys())
- idx = interaction.get_large_choice_input("Choose", "Choose Followed Register", regs)
+def set_follow_reg(ctx: UIActionContext):
+ bv = ctx.binaryView
+ if bv is not None:
+ if bv.platform is not None:
+ regs = list(bv.platform.arch.regs.keys())
+ idx = interaction.get_large_choice_input("Choose", "Choose Followed Register", regs)
+
+ # Save choice both in QSettings and on the RenderLayer object instance
+ layer = RenderLayer[FollowRegRenderLayer.name]
+ if idx is None:
+ layer.followed_reg = None
+ QSettings().remove("layer/followed_reg")
+ else:
+ layer.followed_reg = regs[idx]
+ QSettings().setValue("layer/followed_reg", regs[idx])
+
+ # Trigger view refresh
+ ctx.context.refreshCurrentViewContents()
- # Save choice both in QSettings and on the RenderLayer object instance
- layer = RenderLayer[FollowRegRenderLayer.name]
- if idx is None:
- layer.followed_reg = None
- QSettings().remove("layer/followed_reg")
- else:
- layer.followed_reg = regs[idx]
- QSettings().setValue("layer/followed_reg", regs[idx])
- # Trigger view refresh (gross)
- for func in bv.get_functions_containing(bv.offset):
- func.reanalyze()
+def can_set_follow_reg(ctx: UIActionContext) -> bool:
+ return ctx.binaryView is not None
FollowRegRenderLayer.register()
# Using a command for this is kinda janky but currently the only option
-PluginCommand.register("Set Followed Register", "Choose which register to follow for the Follow Register Render Layer", set_follow_reg)
+UIAction.registerAction("Set Followed Register")
+UIActionHandler.globalActions().bindAction("Set Followed Register", UIAction(set_follow_reg, can_set_follow_reg))
diff --git a/ui/disassemblyview.h b/ui/disassemblyview.h
index 7c97576d..024ef33e 100644
--- a/ui/disassemblyview.h
+++ b/ui/disassemblyview.h
@@ -84,6 +84,8 @@ class BINARYNINJAUIAPI DisassemblyView : public FlowGraphWidget
void toggleRenderLayer(const std::string& layer);
FlowGraphRef applyRenderLayers(FlowGraphRef graph);
+ virtual void refreshContents() override;
+
virtual DisassemblySettingsRef getDisassemblySettings() override;
virtual void setDisassemblySettings(DisassemblySettingsRef settings) override;
diff --git a/ui/linearview.h b/ui/linearview.h
index f7253e3f..588909be 100644
--- a/ui/linearview.h
+++ b/ui/linearview.h
@@ -508,6 +508,8 @@ public:
virtual bool goToReference(FunctionRef func, uint64_t source, uint64_t target) override;
QFont getFont() override { return m_render.getFont(); }
+ virtual void refreshContents() override;
+
virtual void clearRelatedHighlights() override;
virtual void setRelatedIndexHighlights(FunctionRef func, const std::set<size_t>& related) override;
virtual void setRelatedInstructionHighlights(FunctionRef func, const std::set<uint64_t>& related) override;
diff --git a/ui/uicontext.h b/ui/uicontext.h
index 6c541b9c..82062040 100644
--- a/ui/uicontext.h
+++ b/ui/uicontext.h
@@ -524,6 +524,7 @@ public:
virtual bool openProjectFile(ProjectFileRef file, ExternalLocationRef loc = nullptr, bool openWithOptions = false);
virtual bool openUrl(const QUrl& url, bool openWithOptions = false);
virtual void recreateViewFrames(FileContext* file) = 0;
+ virtual void refreshCurrentViewContents();
UIActionHandler* globalActions() { return &m_globalActions; }
virtual UIActionHandler* contentActionHandler() = 0;
diff --git a/ui/viewframe.h b/ui/viewframe.h
index aa3b5f02..01e833b5 100644
--- a/ui/viewframe.h
+++ b/ui/viewframe.h
@@ -245,6 +245,7 @@ class BINARYNINJAUIAPI View
void updateCrossReferenceSelection(ViewFrame* frame = nullptr);
void forceSyncFromView(ViewFrame* frame = nullptr);
+ virtual void refreshContents() {}
virtual void clearRelatedHighlights() {}
virtual void setRelatedIndexHighlights(FunctionRef func, const std::set<size_t>& related) { (void)func; (void)related; }
@@ -518,6 +519,7 @@ class BINARYNINJAUIAPI ViewFrame : public QWidget
void syncToOtherViews();
void forceSyncFromView();
+ void refreshContents();
ViewFrame* getOtherPane();