Skip to content

Commit

Permalink
making ptrsize static for x86 and x64
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Jan 8, 2022
1 parent ece1662 commit b95c4ac
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -2160,6 +2160,7 @@ class GenericArchitecture(Architecture):
mode = ""
all_registers = ()
instruction_length = 0
ptrsize = 0
return_register = ""
function_parameters = ()
syscall_register = ""
Expand Down Expand Up @@ -2546,6 +2547,10 @@ class X86(Architecture):
syscall_register = "$eax"
syscall_instructions = ["sysenter", "int 0x80"]

@property
def ptrsize(self):
return 4

def flag_register_to_human(self, val=None):
reg = self.flag_register
if not val:
Expand Down Expand Up @@ -2664,6 +2669,10 @@ class X86_64(X86):
# We don't want to inherit x86's stack based param getter
get_ith_parameter = Architecture.get_ith_parameter

@property
def ptrsize(self):
return 8

@classmethod
def mprotect_asm(cls, addr, size, perm):
_NR_mprotect = 10
Expand Down Expand Up @@ -11450,7 +11459,8 @@ def __init__(self):
return

class Gef:
"""The GEF root class"""
"""The GEF root class, which serves as a base classe for all the attributes for the debugging session (architecture,
memory, settings, etc.)."""
def __init__(self):
self.binary = None
self.arch = GenericArchitecture() # see PR #516, will be reset by `new_objfile_handler`
Expand All @@ -11459,6 +11469,7 @@ def __init__(self):
return

def reinitialize_managers(self):
"""Reinitialize the managers. Avoid calling this function directly, using `pi reset()` is preferred"""
self.memory = GefMemoryManager()
self.heap = GefHeapManager()
self.session = GefSessionManager()
Expand All @@ -11475,7 +11486,9 @@ def setup(self):
return

def reset_caches(self):
for mgr in (self.memory, self.heap, self.session, self.ui):
"""Recursively clean the cache of all the managers. Avoid calling this function directly, using `reset-cache`
is preferred"""
for mgr in (self.memory, self.heap, self.session):
mgr.reset_caches()
return

Expand Down

0 comments on commit b95c4ac

Please sign in to comment.