Skip to content

Commit

Permalink
Fix printing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mahaloz committed Dec 4, 2023
1 parent b2ce608 commit ac17123
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libbs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.0"
__version__ = "0.6.1"
16 changes: 16 additions & 0 deletions libbs/api/decompiler_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
12 changes: 8 additions & 4 deletions libbs/decompilers/ghidra/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion libbs/decompilers/ida/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

#
Expand Down

0 comments on commit ac17123

Please sign in to comment.