Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion plugins/lighthouse/ui/palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,11 @@ def _qt_theme_hint(self):
# lmao, don't ask me why they forgot about this attribute from 5.0 - 5.6
#

if disassembler.NAME == "BINJA":
# IDA 9.2 SDK fix: migrate from PyQt5 to PySide6
# https://docs.hex-rays.com/user-guide/plugins/migrating-pyqt5-code-to-pyside6
if disassembler.NAME == "BINJA" or (disassembler.NAME == "IDA"
and disassembler._version_major == 9
and disassembler._version_minor >= 2):
test_widget.setAttribute(QtCore.Qt.WA_DontShowOnScreen)
else:
test_widget.setAttribute(103) # taken from http://doc.qt.io/qt-5/qt.html
Expand Down
31 changes: 25 additions & 6 deletions plugins/lighthouse/util/disassembler/ida_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,21 @@ def register_dockable(self, dockable_name, create_widget_callback):
self._dockable_factory[dockable_name] = create_widget_callback

def create_dockable_widget(self, parent, dockable_name):
import sip
# IDA 9.2 SDK fix: migrate from PyQt5 to PySide6
# https://docs.hex-rays.com/user-guide/plugins/migrating-pyqt5-code-to-pyside6
try:
from shiboken6 import wrapInstance
except ImportError:
import sip
def wrapInstance(ptr, base=None):
return sip.wrapinstance(int(ptr), base)

# create a dockable widget, and save a reference to it for later use
twidget = idaapi.create_empty_widget(dockable_name)
self._dockable_widgets[dockable_name] = twidget

# cast the IDA 'twidget' as a Qt widget for use
widget = sip.wrapinstance(int(twidget), QtWidgets.QWidget)
widget = wrapInstance(int(twidget), QtWidgets.QWidget)
widget.name = dockable_name
widget.visible = False

Expand Down Expand Up @@ -226,7 +233,12 @@ def _get_ida_bg_color_from_file(self):
# attempt to generate an 'html' dump of the first 0x20 bytes (instructions)
ida_fd = idaapi.fopenWT(path)
idaapi.gen_file(idaapi.OFILE_LST, ida_fd, imagebase, imagebase+0x20, idaapi.GENFLG_GENHTML)
idaapi.eclose(ida_fd)
# IDA 9.x SDK fix: removed `idaapi.eclose`, added `ida_fpro.qfclose`
if int(idaapi.get_kernel_version()[0]) >= 9:
import ida_fpro
ida_fpro.qfclose(ida_fd)
else:
idaapi.eclose(ida_fd)

# read the dumped text
with open(path, "r") as fd:
Expand Down Expand Up @@ -290,9 +302,16 @@ def _get_ida_bg_color_from_view(self):
# touch the target form so we know it is populated
self._touch_ida_window(twidget)

# locate the Qt Widget for a form and take 1px image slice of it
import sip
widget = sip.wrapinstance(int(twidget), QtWidgets.QWidget)
# IDA 9.2 SDK fix: migrate from PyQt5 to PySide6
# https://docs.hex-rays.com/user-guide/plugins/migrating-pyqt5-code-to-pyside6
try:
from shiboken6 import wrapInstance
except ImportError:
import sip
def wrapInstance(ptr, base=None):
return sip.wrapinstance(int(ptr), base)

widget = wrapInstance(int(twidget), QtWidgets.QWidget)
pixmap = widget.grab(QtCore.QRect(0, 10, widget.width(), 1))

# convert the raw pixmap into an image (easier to interface with)
Expand Down
19 changes: 12 additions & 7 deletions plugins/lighthouse/util/qt/shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@
# specific dependencies in here...
#

# IDA 9.2 SDK fix: migrate from PyQt5 to PySide6
# https://docs.hex-rays.com/user-guide/plugins/migrating-pyqt5-code-to-pyside6
try:
import ida_idaapi
USING_IDA = True
import idaapi
ver_major, ver_minor = map(int, idaapi.get_kernel_version().split("."))
USING_NEW_IDA = ver_major == 9 and ver_minor >= 2
USING_OLD_IDA = not(USING_NEW_IDA)
except ImportError:
USING_IDA = False
USING_NEW_IDA = False
USING_OLD_IDA = False

try:
import binaryninjaui
Expand All @@ -47,8 +52,8 @@
# PyQt5 Compatibility
#------------------------------------------------------------------------------

# attempt to load PyQt5 (IDA 7.0+)
if USING_IDA:
# attempt to load PyQt5 (IDA from 7.0 to 9.1)
if USING_OLD_IDA:

try:
import PyQt5.QtGui as QtGui
Expand Down Expand Up @@ -91,8 +96,8 @@
# PySide6 Compatibility
#------------------------------------------------------------------------------

# If all else fails, try to load PySide6 (New Binary Ninja)
if not QT_AVAILABLE and USING_NEW_BINJA:
# If all else fails, try to load PySide6 (New Binary Ninja and IDA)
if not QT_AVAILABLE and (USING_NEW_BINJA or USING_NEW_IDA):

try:
import PySide6.QtGui as QtGui
Expand Down