Closed Rwkeith closed 10 months ago
updated original post
I haven't had a chance to test this myself, but I stumbled across the CreateEmptyProgramScript that comes with Ghidra, which uses SwingUtilities.invokeAndWait to do some UI stuff. Perhaps it would allow you to get around the Swing errors? I believe you should be able to call it from a Pyhidra environment with an import?
That looks like a promising lead, but I can't find a way to get a reference to state
. state
, currentAddress
, goTo()
, and friends seem to be from GhidraState
and GhidraScript
which I haven't found a way to access through the flatapi from pyhidra. If you know a way to do this please share! Thanks again for looking.
Edit:
So I was able to get past the swing thread error and successfully run this after running the above
from javax.swing import SwingUtilities
def myRunnable():
ltt[0].createTool(project.project)
SwingUtilities.invokeAndWait(myRunnable)
While there was some output indicating success, INFO Packed database cache: /tmp/user-Ghidra/packed-db-cache (PackedDatabaseCache)
, I didn't get a gui window to spawn, and I don't see a way of getting a returned object.
Edit2:
I was able to spawn an empty tool window through a reference to the workspace. Now just need to see a way for a CodeBrowser
wsArray = project.getProjectManager().activeProject.getToolManager().getWorkspaces()
from javax.swing import SwingUtilities
def myRunnable():
wsArray[0].createTool()
SwingUtilities.invokeAndWait(myRunnable)
Edit3:
Was able to get a CodeBrowser window by
from javax.swing import SwingUtilities
def myRunnable():
ws[0].runTool(ltt[0])
SwingUtilities.invokeAndWait(myRunnable)
Now need to find a way to set the CodeBrowser to be the program desired
Could you provide some more details about what the intent of your code is? We want to make sure that we have a good understanding of your use case to ensure that we can provide a meaningful response.
Hello pyhidra developers and contributors!
I'd like to control the listing view of a binary I have open in ghidra and see it update in real time.
So I found that using the DeferredPyhidraLauncher is what I need, but displaying the actual binary is the current issue.
This all works fine, but I see only Ghidra's project window, with no active project selected, even though the output indicates that the project and program was opened. I'd like to see the binary open also and was seeing how that could be done? Thank you.
Edit: Now I've been trying to create a CodeBrowser Tool doing something like
but any time I try to create a tool, I get a java exception,
Calls to MenuManager must be in the Swing Thread!