Skip to content

Commit

Permalink
- create gef.ui.libc_args_table (#821)
Browse files Browse the repository at this point in the history
- make the old  `libc_args_definitions` dict point to `gef.ui.libc_args_table`
  • Loading branch information
hugsy authored Feb 9, 2022
1 parent 4365d9c commit 8c0f625
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -3518,19 +3518,19 @@ def load_libc_args() -> bool:
_libc_args_file = path / f"{_arch_mode}.json"

# current arch and mode already loaded
if _arch_mode in gef.ui.highlight_table:
if _arch_mode in gef.ui.libc_args_table:
return True

gef.ui.highlight_table[_arch_mode] = {}
gef.ui.libc_args_table[_arch_mode] = {}
try:
with _libc_args_file.open() as _libc_args:
gef.ui.highlight_table[_arch_mode] = json.load(_libc_args)
gef.ui.libc_args_table[_arch_mode] = json.load(_libc_args)
return True
except FileNotFoundError:
del gef.ui.highlight_table[_arch_mode]
del gef.ui.libc_args_table[_arch_mode]
warn(f"Config context.libc_args is set but definition cannot be loaded: file {_libc_args_file} not found")
except json.decoder.JSONDecodeError as e:
del gef.ui.highlight_table[_arch_mode]
del gef.ui.libc_args_table[_arch_mode]
warn(f"Config context.libc_args is set but definition cannot be loaded from file {_libc_args_file}: {e}")
return False

Expand Down Expand Up @@ -8546,7 +8546,7 @@ def __get_current_block_start_address() -> Optional[int]:
if function_name.endswith("@plt"):
_function_name = function_name.split("@")[0]
try:
nb_argument = len(gef.ui.highlight_table[_arch_mode][_function_name])
nb_argument = len(gef.ui.libc_args_table[_arch_mode][_function_name])
except KeyError:
pass

Expand Down Expand Up @@ -11523,6 +11523,7 @@ def __init__(self) -> None:
self.context_hidden = False
self.stream_buffer : Optional[StringIO] = None
self.highlight_table: Dict[str, str] = {}
self.libc_args_table: Dict[str, Dict[str, Dict[str, str]]] = {}
self.watches: Dict[int, Tuple[int, str]] = {}
self.context_messages: List[str] = []
return
Expand Down

0 comments on commit 8c0f625

Please sign in to comment.