Skip to content

Commit

Permalink
Finished stack_var test
Browse files Browse the repository at this point in the history
  • Loading branch information
Flipout50 committed Apr 4, 2024
1 parent 2f7e2d7 commit d1418b4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libbs/api/artifact_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, artifact_cls, deci: "DecompilerInterface", error_on_duplicate
# ArtifactType: (setter, getter, lister)
Function: (self._deci._set_function, self._deci._get_function, self._deci._functions),
StackVariable: (self._deci._set_stack_variable, self._deci._get_stack_variable, self._deci._stack_variables),
GlobalVariable: (self._deci._set_global_variable, self._deci._get_global_var, self._deci._global_vars),
GlobalVariable: (self._deci._set_global_var, self._deci._get_global_var, self._deci._global_vars),
Struct: (self._deci._set_struct, self._deci._get_struct, self._deci._structs),
Enum: (self._deci._set_enum, self._deci._get_enum, self._deci._enums),
Comment: (self._deci._set_comment, self._deci._get_comment, self._deci._comments),
Expand Down
2 changes: 1 addition & 1 deletion libbs/decompilers/ghidra/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def _enums(self) -> Dict[str, Enum]:
name.count('/') == 1} if names else {}

@ghidra_transaction
def fill_global_var(self, var_addr, user=None, artifact=None, **kwargs):
def _set_global_var(self, var_addr, user=None, artifact=None, **kwargs):
"""
TODO: remove me and implement me properly as setters and getters
"""
Expand Down
12 changes: 12 additions & 0 deletions tests/test_decompilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ def test_ghidra(self):
deci.enums[enum.name] = enum
assert deci.enums[enum.name] == enum

# gvar_addr = deci.art_lifter.lift_addr(0x4008e0)
# g1 = deci.global_vars[gvar_addr]
# g1.name = "gvar1"
# deci.global_vars[gvar_addr] = g1
# assert deci.global_vars[gvar_addr] == g1

stack_var = main.stack_vars[-24]
stack_var.name = "named_char_array"
stack_var.type = 'double'
deci.functions[func_addr] = main
assert deci.functions[func_addr].stack_vars[-24] == stack_var

#
# Test Artifact Watchers
#
Expand Down

0 comments on commit d1418b4

Please sign in to comment.