Skip to content

Conversation

mike-hunhoff
Copy link
Collaborator

@mike-hunhoff mike-hunhoff commented Sep 4, 2023

Jython exposes the GhidraState object through a variable named state that is available to the scripting environment, similar to currentProgram and friends. This PR adds similar support in Ghidrathon where the GhidraState object is exposed through a function named state that is added to the Python builtins scope.

The following is an example of accessing the new state function:

> state()  == getState()
True

Fixes #74

@slippycheeze
Copy link

note quite: state was a member variable of GhidraScript, visible to JPython scripts, and also Ghidrathon scripts, prior to the change. Optionall, see the JavaDoc

@mike-hunhoff
Copy link
Collaborator Author

mike-hunhoff commented Sep 5, 2023

note quite: state was a member variable of GhidraScript, visible to JPython scripts, and also Ghidrathon scripts, prior to the change. Optionall, see the JavaDoc

@slippycheeze I am following you - unfortunately like the other breaking changes introduced in Ghidrathon v3, Ghidrathon must expose state via a function call to ensure the correct object is returned. This is the same way monitor, currentProgram, etc. are implemented as of Ghidrathon v3.

These breaking changes do diverge from the Jython implementation but facilitate a more stable support for Python 3, as you noted in #74. I intend updating existing Python 3 Ghidra scripts to be minimal, e.g., to update your existing Python 3 Ghidra scripts to use the state support added in this PR you need only change state to state().

@slippycheeze
Copy link

I have no problem with the change to use a function, this is fine. :) Seems like we were talking past each other, and there was actually no issue. all good. thank you. :)

@mike-hunhoff
Copy link
Collaborator Author

I have no problem with the change to use a function, this is fine. :) Seems like we were talking past each other, and there was actually no issue. all good. thank you. :)

No problem, thanks again for reporting!

@mike-hunhoff mike-hunhoff merged commit 7489831 into main Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

undocumented: the move to separate state removed access to the GhidraScript.state variable
2 participants