From 4584151a765ee1b21dce4e116a14f6901e16eeb2 Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Tue, 25 Jun 2024 16:22:35 -0400 Subject: Fix il magic variables for lifted, mmlil, mmlil_ssa --- python/scriptingprovider.py | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py index c830cbd2..922fa507 100644 --- a/python/scriptingprovider.py +++ b/python/scriptingprovider.py @@ -1525,6 +1525,15 @@ def _get_current_llil(instance: PythonScriptingInstance): PythonScriptingProvider.register_magic_variable("current_llil", _get_current_llil) +def _get_current_lifted_il(instance: PythonScriptingInstance): + if instance.interpreter.active_func is None: + return None + return instance.interpreter.active_func.lifted_il_if_available + + +PythonScriptingProvider.register_magic_variable("current_lifted_il", _get_current_lifted_il) + + def _get_current_llil_ssa(instance: PythonScriptingInstance): if instance.interpreter.locals["current_llil"] is None: return None @@ -1538,6 +1547,28 @@ PythonScriptingProvider.register_magic_variable( ) +def _get_current_mapped_mlil(instance: PythonScriptingInstance): + if instance.interpreter.active_func is None: + return None + return instance.interpreter.active_func.mmlil_if_available + + +PythonScriptingProvider.register_magic_variable("current_mapped_mlil", _get_current_mapped_mlil) + + +def _get_current_mapped_mlil_ssa(instance: PythonScriptingInstance): + if instance.interpreter.locals["current_mapped_mlil"] is None: + return None + return instance.interpreter.locals["current_mapped_mlil"].ssa_form + + +PythonScriptingProvider.register_magic_variable( + "current_mapped_mlil_ssa", + _get_current_mapped_mlil_ssa, + depends_on=["current_mapped_mlil"] +) + + def _get_current_mlil(instance: PythonScriptingInstance): if instance.interpreter.active_func is None: return None @@ -1770,8 +1801,14 @@ def _get_current_il_function(instance: PythonScriptingInstance): ilType = instance.interpreter.locals["current_ui_view_location"].getILViewType() if ilType == FunctionGraphType.LowLevelILFunctionGraph: return instance.interpreter.locals["current_llil"] + elif ilType == FunctionGraphType.LiftedILFunctionGraph: + return instance.interpreter.locals["current_lifted_il"] elif ilType == FunctionGraphType.LowLevelILSSAFormFunctionGraph: return instance.interpreter.locals["current_llil_ssa"] + elif ilType == FunctionGraphType.MappedMediumLevelILFunctionGraph: + return instance.interpreter.locals["current_mapped_mlil"] + elif ilType == FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph: + return instance.interpreter.locals["current_mapped_mlil_ssa"] elif ilType == FunctionGraphType.MediumLevelILFunctionGraph: return instance.interpreter.locals["current_mlil"] elif ilType == FunctionGraphType.MediumLevelILSSAFormFunctionGraph: @@ -1789,11 +1826,14 @@ PythonScriptingProvider.register_magic_variable( depends_on=[ "current_ui_view_location", "current_llil", + "current_lifted_il", "current_llil_ssa", + "current_mapped_mlil", + "current_mapped_mlil_ssa", "current_mlil", "current_mlil_ssa", "current_hlil", - "current_hlil_ssa" + "current_hlil_ssa", ] ) -- cgit v1.3.1