mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-30 01:50:16 +08:00
Merge remote-tracking branch 'origin/GP-4745_d-millar_catchpoint_logic'
(Closes #6666)
This commit is contained in:
@@ -546,19 +546,7 @@ def install_hooks():
|
|||||||
if HOOK_STATE.mem_catchpoint is not None:
|
if HOOK_STATE.mem_catchpoint is not None:
|
||||||
HOOK_STATE.mem_catchpoint.enabled = True
|
HOOK_STATE.mem_catchpoint.enabled = True
|
||||||
else:
|
else:
|
||||||
breaks_before = set(gdb.breakpoints())
|
HOOK_STATE.mem_catchpoint = util.MEM_CATCHPOINT_SETTER.install_catchpoint()
|
||||||
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}")
|
|
||||||
|
|
||||||
gdb.events.cont.connect(on_cont)
|
gdb.events.cont.connect(on_cont)
|
||||||
gdb.events.stop.connect(on_stop)
|
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()
|
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):
|
def set_bool_param_by_api(name, value):
|
||||||
gdb.set_parameter(name, value)
|
gdb.set_parameter(name, value)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user