mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-4745: catchpoint fixes
This commit is contained in:
parent
5ab72bf4f2
commit
4a9eec28cc
2 changed files with 36 additions and 13 deletions
|
@ -546,19 +546,7 @@ def install_hooks():
|
|||
if HOOK_STATE.mem_catchpoint is not None:
|
||||
HOOK_STATE.mem_catchpoint.enabled = True
|
||||
else:
|
||||
breaks_before = set(gdb.breakpoints())
|
||||
try:
|
||||
gdb.execute("""
|
||||
catch syscall group:memory
|
||||
commands
|
||||
silent
|
||||
hooks-ghidra event-memory
|
||||
cont
|
||||
end
|
||||
""")
|
||||
HOOK_STATE.mem_catchpoint = (set(gdb.breakpoints()) - breaks_before).pop()
|
||||
except Exception as e:
|
||||
print(f"Error setting memory catchpoint: {e}")
|
||||
HOOK_STATE.mem_catchpoint = util.MEM_CATCHPOINT_SETTER.install_catchpoint()
|
||||
|
||||
gdb.events.cont.connect(on_cont)
|
||||
gdb.events.stop.connect(on_stop)
|
||||
|
|
|
@ -344,6 +344,41 @@ def _choose_breakpoint_location_info_reader():
|
|||
BREAKPOINT_LOCATION_INFO_READER = _choose_breakpoint_location_info_reader()
|
||||
|
||||
|
||||
class MemCatchpointSetterV8(object):
|
||||
def install_catchpoint(self):
|
||||
return object()
|
||||
|
||||
|
||||
class MemCatchpointSetterV11(object):
|
||||
def install_catchpoint(self):
|
||||
breaks_before = set(gdb.breakpoints())
|
||||
try:
|
||||
gdb.execute("""
|
||||
catch syscall group:memory
|
||||
commands
|
||||
silent
|
||||
hooks-ghidra event-memory
|
||||
cont
|
||||
end
|
||||
""")
|
||||
return (set(gdb.breakpoints()) - breaks_before).pop()
|
||||
except Exception as e:
|
||||
print(f"Error setting memory catchpoint: {e}")
|
||||
return object()
|
||||
|
||||
|
||||
def _choose_mem_catchpoint_setter():
|
||||
if GDB_VERSION.major >= 11:
|
||||
return MemCatchpointSetterV11()
|
||||
if GDB_VERSION.major >= 8:
|
||||
return MemCatchpointSetterV8()
|
||||
else:
|
||||
raise gdb.GdbError(
|
||||
"GDB version not recognized by ghidragdb: " + GDB_VERSION.full)
|
||||
|
||||
|
||||
MEM_CATCHPOINT_SETTER = _choose_mem_catchpoint_setter()
|
||||
|
||||
def set_bool_param_by_api(name, value):
|
||||
gdb.set_parameter(name, value)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue