Skip to content

Instantly share code, notes, and snippets.

@nfalliere
Created August 27, 2021 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfalliere/b67c17984262cb84a94af609434073f1 to your computer and use it in GitHub Desktop.
Save nfalliere/b67c17984262cb84a94af609434073f1 to your computer and use it in GitHub Desktop.
#?description=
#?shortcut=
from com.pnfsoftware.jeb.client.api import IScript
from com.pnfsoftware.jeb.core.units.code.android import IDexUnit
from com.pnfsoftware.jeb.core.actions import ActionContext, ActionTypeHierarchyData, Actions
class PrintDexHierarchy(IScript):
def run(self, ctx):
prj = ctx.getMainProject()
# method 1: retrieving the selected class graphically: set the caret on a class item
unit = ctx.getFocusedUnit()
assert isinstance(unit, IDexUnit)
current_item = ctx.getFocusedItem()
item_id = current_item.getItemId()
# method 2: retrieving a class Item programmatically from the full-class name
#unit = prj.findUnit(IDexUnit)
#cl = unit.getClass('Lcom/foo/Bar;')
#item_id = cl.getItemId()
data = ActionTypeHierarchyData()
if unit.prepareExecution(ActionContext(unit, Actions.QUERY_TYPE_HIER, item_id, None), data):
print('Base node for the hierarchy: %s' % data.getBaseNode())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment