mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-20 05:01:55 +08:00
GP-4745: catchpoint fixes
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user