Skip to content

Commit

Permalink
add state function to Python builtins that exposes GhidraState object (
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-hunhoff authored Sep 6, 2023
1 parent 6cab0ab commit 7489831
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/python/jepwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ def wrapped_monitor():
return get_script().getMonitor()


def wrapped_state():
return get_script_state()


def wrapped_currentProgram():
return get_script_state().getCurrentProgram()

Expand All @@ -328,6 +332,7 @@ def wrapped_currentHighlight():


__builtins__["monitor"] = wrapped_monitor
__builtins__["state"] = wrapped_state
__builtins__["currentProgram"] = wrapped_currentProgram
__builtins__["currentAddress"] = wrapped_currentAddress
__builtins__["currentLocation"] = wrapped_currentLocation
Expand Down
6 changes: 6 additions & 0 deletions data/python/tests/test_jepbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ def test_type_instance(self):

def test_ghidra_script_variables(self):
self.assertIsJavaObject(monitor())
self.assertIsJavaObject(state())
self.assertIsJavaObject(currentAddress())
self.assertIsJavaObject(currentProgram())
self.assertIsJavaObject(currentLocation())
self.assertIsJavaObject(currentHighlight())
self.assertIsJavaObject(currentSelection())

self.assertIsNotJavaObject(monitor)
self.assertIsNotJavaObject(state)
self.assertIsNotJavaObject(currentAddress)
self.assertIsNotJavaObject(currentProgram)
self.assertIsNotJavaObject(currentLocation)
Expand All @@ -61,8 +63,12 @@ def test_ghidra_script_variables(self):

def test_ghidra_script_methods(self):
self.assertIsInstance(getGhidraVersion(), str)
self.assertIsJavaObject(getState())

def test_java_excluded_packages(self):
import pdb

self.assertIsNotJavaObject(pdb)

def test_ghidra_script_state(self):
self.assertTrue(state() == getState())

0 comments on commit 7489831

Please sign in to comment.