Skip to content

Commit

Permalink
allow gef to save temporary values
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Nov 10, 2024
1 parent e8527ad commit 14c35bd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -11683,6 +11683,7 @@ class Gef:
heap : GefHeapManager
session : GefSessionManager
gdb: GefCommand
temp: dict[str, Any]

def __init__(self) -> None:
self.binary: FileFormat | None = None
Expand All @@ -11691,6 +11692,7 @@ def __init__(self) -> None:
self.config = GefSettingsManager()
self.ui = GefUiManager()
self.libc = GefLibcManager()
self.temp = {}
return

def __str__(self) -> str:
Expand Down Expand Up @@ -11720,13 +11722,15 @@ def setup(self) -> None:
def reset_caches(self) -> None:
"""Recursively clean the cache of all the managers. Avoid calling this function directly, using `reset-cache`
is preferred"""
self.temp.clear()
for mgr in (self.memory, self.heap, self.session, self.arch):
mgr.reset_caches()
return


def target_remote_hook():
# disable the context until the session has been fully established
gef.temp["context_old_value"] = gef.config["context.enable"]
gef.config["context.enable"] = False


Expand All @@ -11737,8 +11741,8 @@ def target_remote_posthook():
assert is_target_remote_or_extended(conn), "Target is not remote"
gef.session.remote = GefRemoteSessionManager(conn)

# re-enable context
gef.config["context.enable"] = True
# switch back context to its old context
gef.config["context.enable"] = gef.temp.pop("context_old_value", False)

# if here, no exception was thrown, print context
gdb.execute("context")
Expand Down

0 comments on commit 14c35bd

Please sign in to comment.