GP-3823: TraceRmi Launcher framework + dbgeng for Windows.

This commit is contained in:
Dan 2023-11-28 10:38:27 -05:00
parent 80d92aa32f
commit c126cf51c0
33 changed files with 1206 additions and 1303 deletions

View file

@ -19,6 +19,7 @@ import os.path
import socket
import time
import sys
import re
from ghidratrace import sch
from ghidratrace.client import Client, Address, AddressRange, TraceObject
@ -185,7 +186,7 @@ def compute_name(progname=None):
progname = buffer.decode('utf-8')
except Exception:
return 'pydbg/noname'
return 'pydbg/' + progname.split('/')[-1]
return 'pydbg/' + re.split(r'/|\\', progname)[-1]
def start_trace(name):
@ -1301,7 +1302,36 @@ def ghidra_util_wait_stopped(timeout=1):
time.sleep(0.1)
if time.time() - start > timeout:
raise RuntimeError('Timed out waiting for thread to stop')
def dbg():
return util.get_debugger()
SHOULD_WAIT = ['GO', 'STEP_BRANCH', 'STEP_INTO', 'STEP_OVER']
def repl():
print("This is the dbgeng.dll (WinDbg) REPL. To drop to Python3, press Ctrl-C.")
while True:
# TODO: Implement prompt retrieval in PR to pybag?
print('dbg> ', end='')
try:
cmd = input().strip()
if not cmd:
continue
dbg().cmd(cmd, quiet=False)
stat = dbg().exec_status()
if stat != 'BREAK':
dbg().wait()
else:
pass
#dbg().dispatch_events()
except KeyboardInterrupt as e:
print("")
print("You have left the dbgeng REPL and are now at the Python3 interpreter.")
print("use repl() to re-enter.")
return
except:
# Assume cmd() has already output the error
pass

View file

@ -383,7 +383,7 @@ def interrupt():
@REGISTRY.method(action='step_into')
def step_into(thread: sch.Schema('Thread'), n: ParamDesc(int, display='N')=1):
"""Step on instruction exactly."""
"""Step one instruction exactly."""
find_thread_by_obj(thread)
dbg().stepi(n)
@ -511,7 +511,7 @@ def write_mem(process: sch.Schema('Process'), address: Address, data: bytes):
@REGISTRY.method
def write_reg(frame: sch.Schema('Frame'), name: str, value: bytes):
def write_reg(frame: sch.Schema('StackFrame'), name: str, value: bytes):
"""Write a register."""
util.select_frame()
nproc = pydbg.selected_process()