diff --git a/libbs/__init__.py b/libbs/__init__.py index 906d362f..43c4ab00 100644 --- a/libbs/__init__.py +++ b/libbs/__init__.py @@ -1 +1 @@ -__version__ = "0.6.0" +__version__ = "0.6.1" diff --git a/libbs/api/decompiler_interface.py b/libbs/api/decompiler_interface.py index a97a2e83..e06aba74 100644 --- a/libbs/api/decompiler_interface.py +++ b/libbs/api/decompiler_interface.py @@ -557,6 +557,22 @@ def artifact_set_event_handler( return had_changes + # + # Special Loggers + # + + def info(self, msg: str): + _l.info(msg) + + def debug(self, msg: str): + _l.debug(msg) + + def warning(self, msg: str): + _l.warning(msg) + + def error(self, msg: str): + _l.error(msg) + # # Utils # diff --git a/libbs/decompilers/ghidra/interface.py b/libbs/decompilers/ghidra/interface.py index d40dd523..2e6757e3 100644 --- a/libbs/decompilers/ghidra/interface.py +++ b/libbs/decompilers/ghidra/interface.py @@ -300,13 +300,17 @@ def _structs(self) -> Dict[str, Struct]: name: Struct(name, size, members=self._struct_members_from_gstruct(name)) for name, size in name_sizes } if name_sizes else {} + @ghidra_transaction def _set_comment(self, comment: Comment, **kwargs) -> bool: - code_unit = self.ghidra.import_module_object("ghidra.program.model.listing", "CodeUnit") - set_cmt_cmd_cls = self.ghidra.import_module_object("ghidra.app.cmd.comments", "SetCommentCmd") - cmt_type = code_unit.PRE_COMMENT if comment.decompiled else code_unit.EOL_COMMENT + CodeUnit = self.ghidra.import_module_object("ghidra.program.model.listing", "CodeUnit") + SetCommentCmd = self.ghidra.import_module_object("ghidra.app.cmd.comments", "SetCommentCmd") + cmt_type = CodeUnit.PRE_COMMENT if comment.decompiled else CodeUnit.EOL_COMMENT + if comment.addr == comment.func_addr: + cmt_type = CodeUnit.PLATE_COMMENT + if comment.comment: # TODO: check if comment already exists, and append? - return set_cmt_cmd_cls( + return SetCommentCmd( self.ghidra.toAddr(comment.addr), cmt_type, comment.comment ).applyTo(self.ghidra.currentProgram) return True diff --git a/libbs/decompilers/ida/compat.py b/libbs/decompilers/ida/compat.py index b3ffe6d9..f4950142 100644 --- a/libbs/decompilers/ida/compat.py +++ b/libbs/decompilers/ida/compat.py @@ -263,6 +263,9 @@ def set_function(func: Function, decompiler_available=True, **kwargs): for svar in func.stack_vars.values(): changes |= set_stack_variable(svar, decompiler_available=decompiler_available, **kwargs) + if changes and ida_code_view is not None: + ida_code_view.refresh_view(changes) + return changes @execute_write @@ -368,7 +371,6 @@ def set_function_header(libbs_header: libbs.data.FunctionHeader, exit_on_bad_typ return False data_changed |= success is True - return data_changed #