Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider dropping ghidra_bridge again for native Py3 #123

Open
mahaloz opened this issue Oct 5, 2024 · 0 comments
Open

Consider dropping ghidra_bridge again for native Py3 #123

mahaloz opened this issue Oct 5, 2024 · 0 comments
Labels

Comments

@mahaloz
Copy link
Member

mahaloz commented Oct 5, 2024

Background

Since #82, we've mostly given up on the idea of using native Python 3 in Ghidra for two reasons:

  1. A crash in MacOS when importing PySide (needed for BinSync proper)
  2. The difficulty of a user starting Ghidra in the custom way needed for Pyhidra

Solutions

In the new Ghidra 11.3/12 update, Pyhidra will officially be a part of Ghidra! This means that we will be able to run Python3 code inside Ghidra without having to install anything extra. That solves point 2.

This has motivated me to look back into solving the issue of this line crashing (on Mac):

from PySide6.QtWidgets import QApplication
app = QApplication([])

Which has lead me to this on MacOS:

from PySide6.QtWidgets import QApplication, QMessageBox
import sys
from ctypes import cdll
libobjc = cdll.LoadLibrary('/usr/lib/libobjc.dylib')
libobjc.objc_getClass.restype = ctypes.c_void_p

def run_on_main_thread(func):
    import objc
    from Foundation import NSObject
    class MainThreadRunner(NSObject):
        def performOnMainThread_(self, arg):
            func()
    runner = MainThreadRunner.new()
    runner.performSelectorOnMainThread_withObject_waitUntilDone_('performOnMainThread:', None, True)

def main():
    app = QApplication([])
    msg_box = QMessageBox()
    msg_box.setText("Hi there!")
    msg_box.exec()

run_on_main_thread(main)

This needs to be investigated further if we want to move Ghidra to Py3 and be much faster than we are now.

@mahaloz mahaloz added the ghidra label Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant