patching icon indicating copy to clipboard operation
patching copied to clipboard

IDA 9.2 compatibility update

Open loqstrz opened this issue 4 months ago • 5 comments

Starting with IDA 9.2, the QT Framework has been updated from QT5 to QT6 and patching is using QT5.

Therefore the plugin does no longer work.

loqstrz avatar Aug 25 '25 05:08 loqstrz

When using Macos 9.2 to close IDA, an error occurs

rmhh888 avatar Sep 11 '25 08:09 rmhh888

qt.py:

# this global is used to indicate whether Qt bindings for python are present
# and whether the plugin should expect to be using UI features

QT_AVAILABLE = False

# attempt to load PySide6
try:
    from PySide6 import QtGui, QtCore, QtWidgets
    import shiboken6

    # importing PySide6 went okay, let's see if we're in an IDA Qt context
    try:
        import ida_kernwin
        QT_AVAILABLE = ida_kernwin.is_idaq()
    except ImportError:
        pass

# import failed, PySide6 is not available
except ImportError:
    pass

#--------------------------------------------------------------------------
# Qt Misc Helpers
#--------------------------------------------------------------------------

def get_main_window():
    """
    Return the Qt Main Window.
    """
    app = QtWidgets.QApplication.instance()
    for widget in app.topLevelWidgets():
        if isinstance(widget, QtWidgets.QMainWindow):
            return widget
    return None

def center_widget(widget):
    """
    Center the given widget to the Qt Main Window.
    """
    main_window = get_main_window()
    if not main_window:
        return False

    # compute a new position for the floating widget such that it will center
    # over the Qt application's main window

    rect_main = main_window.geometry()
    rect_widget = widget.rect()

    centered_position = rect_main.center() - rect_widget.center()
    widget.move(centered_position)

    return True

ida.py:

......
    # 
    # convert IDA alt shortcut syntax to whatever they use in Qt Text menus
    # eg: '~A~ssemble patches to...' --> '&Assemble patches to...'
    #

    prev_action_name = re.sub(r'~(.)~', r'&\1', prev_action_name)

    # cast an IDA 'popup handle' pointer back to a QMenu object
    p_qmenu = ctypes.cast(int(popup_handle), ctypes.POINTER(ctypes.c_void_p))[0]
    qmenu = shiboken6 .wrapInstance(int(p_qmenu), QtWidgets.QMenu)
......
    p_qmenu = ctypes.cast(int(popup), ctypes.POINTER(ctypes.c_void_p))[0]
    qmenu = shiboken6 .wrapInstance(int(p_qmenu), QtWidgets.QMenu)
    filter = FilterMenu(qmenu)
    qmenu.installEventFilter(filter)

    # return the filter as I think we need to maintain its lifetime in py
    return filter

0x4e38 avatar Sep 12 '25 14:09 0x4e38

Imageusing Macos 9.2 to close IDA, an error occurs,patching, intel CPU

rmhh888 avatar Sep 12 '25 16:09 rmhh888

index 693a6e8..93ee99f 100644
--- a/plugins/patching/util/ida.py
+++ b/plugins/patching/util/ida.py
@@ -170,7 +170,7 @@ def attach_submenu_to_popup(popup_handle, submenu_name, prev_action_name):
         qmenu = sip.wrapinstance(int(p_qmenu), QtWidgets.QMenu)
 
     # create a Qt (sub)menu that can be injected into an IDA-originating menu
-    submenu = QtWidgets.QMenu(submenu_name)
+    submenu = QtWidgets.QMenu(submenu_name, qmenu)
 
     # search for the target action to insert the submenu next to
     all_actions = list(qmenu.actions())
@@ -896,7 +896,7 @@ def remove_ida_actions(popup):
 
     class FilterMenu(QtCore.QObject):
         def __init__(self, qmenu):
-            super(FilterMenu, self).__init__()
+            super(FilterMenu, self).__init__(qmenu)
             self.qmenu = qmenu
 
         def eventFilter(self, obj, event):

try to apply this diff to avoid orphaned idapro popup menus, this may be the reason that lead crash on linux when close idapro.

yzctzl avatar Oct 16 '25 14:10 yzctzl

index 693a6e8..93ee99f 100644 --- a/plugins/patching/util/ida.py +++ b/plugins/patching/util/ida.py @@ -170,7 +170,7 @@ def attach_submenu_to_popup(popup_handle, submenu_name, prev_action_name): qmenu = sip.wrapinstance(int(p_qmenu), QtWidgets.QMenu)

 # create a Qt (sub)menu that can be injected into an IDA-originating menu
  • submenu = QtWidgets.QMenu(submenu_name)
  • submenu = QtWidgets.QMenu(submenu_name, qmenu)

    search for the target action to insert the submenu next to

    all_actions = list(qmenu.actions()) @@ -896,7 +896,7 @@ def remove_ida_actions(popup):

    class FilterMenu(QtCore.QObject): def init(self, qmenu):

  •        super(FilterMenu, self).__init__()
    
  •        super(FilterMenu, self).__init__(qmenu)
           self.qmenu = qmenu
    
       def eventFilter(self, obj, event):
    

尝试应用此差异以避免孤立的 idapro 弹出菜单,这可能是关闭 idapro 时导致 Linux 崩溃的原因。 Thank you for the guidance from the teacher. After making the necessary modifications, the error message did not pop up,

rmhh888 avatar Oct 16 '25 14:10 rmhh888