Esempio n. 1
0
    def touch_window(self, target):
        """
        Touch a window/widget/form to ensure it gets drawn by IDA.
        XXX/HACK:
          We need to ensure that widget we will analyze actually gets drawn
          so that there are colors for us to steal.
          To do this, we switch to it, and switch back. I tried a few different
          ways to trigger this from Qt, but could only trigger the full
          painting by going through the IDA routines.
        """

        # get the currently active widget/form title (the form itself seems
        # transient...)
        twidget = ida_kernwin.get_current_widget()
        title = ida_kernwin.get_widget_title(twidget)

        # touch the target window by switching to it
        ida_kernwin.activate_widget(target, True)
        self.flush_ida_sync_requests()

        # locate our previous selection
        previous_twidget = ida_kernwin.find_widget(title)

        # return us to our previous selection
        ida_kernwin.activate_widget(previous_twidget, True)
        self.flush_ida_sync_requests()
Esempio n. 2
0
 def _commit_changes(self):
     vu = ida_hexrays.get_widget_vdui(self.parent_widget)
     if vu:
         vu.refresh_ctext()
         # "refresh_ctext()" took away the focus, take it back
         kw.activate_widget(kw.find_widget(self.title), True)
         self.SetFocusedField(self.cbEditable)
         return True
     return False
Esempio n. 3
0
def refresh_pseudocode_view(ea, set_focus=True):
    """Refreshes the pseudocode view in IDA."""
    names = ["Pseudocode-%c" % chr(ord("A") + i) for i in range(5)]
    for name in names:
        widget = ida_kernwin.find_widget(name)
        if widget:
            vu = ida_hexrays.get_widget_vdui(widget)

            # Check if the address is in the same function
            func_ea = vu.cfunc.entry_ea
            func = ida_funcs.get_func(func_ea)
            if ida_funcs.func_contains(func, ea):
                vu.refresh_view(True)
                ida_kernwin.activate_widget(widget, set_focus)
Esempio n. 4
0
    def open_control_panel(self):
        """
        Open the control panel view and attach it to IDA View-A or Pseudocode-A.
        """

        wrapper = ControlPanelViewWrapper(controller)
        if not wrapper.twidget:
            l.info(
                "BinSync is unable to find a widget to attach to. You are likely running headlessly"
            )
            return None

        flags = idaapi.PluginForm.WOPN_TAB | idaapi.PluginForm.WOPN_RESTORE | idaapi.PluginForm.WOPN_PERSIST
        idaapi.display_widget(wrapper.twidget, flags)
        wrapper.widget.visible = True

        # casually open a pseudocode window, this prevents magic sync from spawning pseudocode windows
        # in weird locations upon an initial run
        func_addr = next(idautils.Functions())
        ida_hexrays.open_pseudocode(
            func_addr, ida_hexrays.OPF_NO_WAIT | ida_hexrays.OPF_REUSE)
        # then attempt to flip back to IDA View-A
        twidget = idaapi.find_widget("IDA View-A")
        if twidget is not None:
            ida_kernwin.activate_widget(twidget, True)

        target = "Functions"
        fwidget = idaapi.find_widget(target)

        if not fwidget:
            # prioritize attaching the binsync panel to a decompilation window
            target = "Pseudocode-A"
            dwidget = idaapi.find_widget(target)

            if not dwidget:
                target = "IDA View-A"

        if target == "Functions":
            idaapi.set_dock_pos(ControlPanelViewWrapper.NAME, target,
                                idaapi.DP_INSIDE)
        else:
            # attach the panel to the found target
            idaapi.set_dock_pos(ControlPanelViewWrapper.NAME, target,
                                idaapi.DP_RIGHT)
Esempio n. 5
0
def activate_widget(form, active):
    if idaapi.IDA_SDK_VERSION <= 699:
        idaapi.switchto_tform(form, active)
    else:
        ida_kernwin.activate_widget(form, active)
Esempio n. 6
0
 def jumpto_in_view(self, view, ea):
     ida_kernwin.activate_widget(view, True)
     return ida_kernwin.jumpto(ea)