Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lucid Reloaded]: New features, QoL updates, fixes + enhancements #5

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
48 changes: 37 additions & 11 deletions plugins/lucid/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ida_idaapi
import ida_kernwin

from lucid.microtext import MicrocodeOptions
from lucid.util.ida import UIHooks, IDACtxEntry, hexrays_available
from lucid.ui.explorer import MicrocodeExplorer

Expand All @@ -20,27 +21,25 @@
class LucidCore(object):

PLUGIN_NAME = "Lucid"
PLUGIN_VERSION = "0.1.1"
PLUGIN_AUTHORS = "Markus Gaasedelen"
PLUGIN_DATE = "2020"
PLUGIN_VERSION = "0.2.3"
PLUGIN_AUTHORS = "Markus Gaasedelen, Fireboyd78"
PLUGIN_DATE = "2024"

def __init__(self, defer_load=False):
self.loaded = False
self.explorer = None

MicrocodeOptions.clear_listeners()

#
# we can 'defer' the load of the plugin core a little bit. this
# ensures that all the other plugins (eg, decompilers) can get loaded
# and initialized when opening an idb/bin
#

class UIHooks(ida_kernwin.UI_Hooks):
def ready_to_run(self):
pass

self._startup_hooks = UIHooks()
self._startup_hooks.ready_to_run = self.load

if defer_load:
self._startup_hooks.hook()
return
Expand All @@ -58,7 +57,7 @@ def load(self):
"""
self._startup_hooks.unhook()

# the plugin will only load for decompiler-capabale IDB's / installs
# the plugin will only load for decompiler-capable IDB's / installs
if not hexrays_available():
return

Expand All @@ -71,7 +70,30 @@ def load(self):

# all done, mark the core as loaded
self.loaded = True


def get_hotload_state(self):
"""
Gets persistent parameters that can be used to restore after a hotload.
"""
state = {}
# TODO: Let the classes handle their state data.
if self.explorer:
explorer_params = {
"active": self.explorer.view.visible,
}
state["explorer"] = explorer_params
return state

def set_hotload_state(self, state):
"""
Restores saved parameters that were retrieved prior to a hotload.
"""
explorer_params = state.get("explorer", {})
# TODO: Let the classes handle their state data.
if explorer_params:
if explorer_params.get("active", False):
self.interactive_view_microcode()

def unload(self, from_ida=False):
"""
Unload the plugin core.
Expand All @@ -85,6 +107,10 @@ def unload(self, from_ida=False):
return

print("Unloading %s..." % self.PLUGIN_NAME)

if self.explorer:
self.explorer.unload()
del self.explorer

# mark the core as 'unloaded' and teardown its components
self.loaded = False
Expand All @@ -102,7 +128,7 @@ def interactive_view_microcode(self, ctx=None):
"""
current_address = ida_kernwin.get_screen_ea()
if current_address == ida_idaapi.BADADDR:
print("Could not open Microcode Explorer (bad cursor address)")
ida_kernwin.warning("Could not open Microcode Explorer (bad cursor address)")
return

#
Expand Down
Loading