Skip to content

Consider dropping ghidra_bridge again for native Py3 #123

@mahaloz

Description

@mahaloz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions