Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-5105: same for ttd GP-5105: better labeling

d-millar8e6d269b8ea3
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/methods.py b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/methods.py
index 1661e5220e..4251c99050 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/methods.py
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/methods.py
@@ -1,17 +1,17 @@
## ###
-# IP: GHIDRA
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# IP: GHIDRA
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
##
from concurrent.futures import Future, ThreadPoolExecutor
from contextlib import redirect_stdout
@@ -199,9 +199,11 @@ def execute(cmd: str, to_string: bool=False):
exec(cmd, shared_globals)
[email protected](action='evaluate', display='Evaluate')
# @util.dbg.eng_thread
-def evaluate(expr: str):
+def evaluate(
+ session: sch.Schema('Session'),
+ expr: ParamDesc(str, display='Expr')):
"""Evaluate a Python3 expression."""
return str(eval(expr, shared_globals))
@@ -323,15 +325,16 @@ def remove_process(process: sch.Schema('Process')):
dbg().detach_proc()
[email protected](action='connect')
[email protected](action='connect', display='Connect')
@util.dbg.eng_thread
-def target(process: sch.Schema('Process'), spec: str):
+def target(
+ session: sch.Schema('Session'),
+ cmd: ParamDesc(str, display='Command')):
"""Connect to a target machine or process."""
- find_proc_by_obj(process)
- dbg().attach_kernel(spec)
+ dbg().attach_kernel(cmd)
[email protected](action='attach')
[email protected](action='attach', display='Attach')
@util.dbg.eng_thread
def attach_obj(target: sch.Schema('Attachable')):
"""Attach the process to the given target."""
@@ -339,29 +342,34 @@ def attach_obj(target: sch.Schema('Attachable')):
dbg().attach_proc(pid)
[email protected](action='attach')
[email protected](action='attach', display='Attach by pid')
@util.dbg.eng_thread
-def attach_pid(pid: int):
+def attach_pid(
+ session: sch.Schema('Session'),
+ pid: ParamDesc(str, display='PID')):
"""Attach the process to the given target."""
- dbg().attach_proc(pid)
+ dbg().attach_proc(int(pid))
[email protected](action='attach')
[email protected](action='attach', display='Attach by name')
@util.dbg.eng_thread
-def attach_name(process: sch.Schema('Process'), name: str):
+def attach_name(
+ session: sch.Schema('Session'),
+ name: ParamDesc(str, display='Name')):
"""Attach the process to the given target."""
dbg().attach_proc(name)
[email protected](action='detach', display='Detach')
@util.dbg.eng_thread
def detach(process: sch.Schema('Process')):
"""Detach the process's target."""
dbg().detach_proc()
[email protected](action='launch')
[email protected](action='launch', display='Launch')
def launch_loader(
+ session: sch.Schema('Session'),
file: ParamDesc(str, display='File'),
args: ParamDesc(str, display='Arguments')=''):
"""
@@ -373,8 +381,9 @@ def launch_loader(
commands.ghidra_trace_create(command=file, start_trace=False)
[email protected](action='launch')
[email protected](action='launch', display='LaunchEx')
def launch(
+ session: sch.Schema('Session'),
file: ParamDesc(str, display='File'),
args: ParamDesc(str, display='Arguments')='',
initial_break: ParamDesc(bool, display='Initial Break')=True,
@@ -431,7 +440,7 @@ def step_out(thread: sch.Schema('Thread')):
util.dbg.run_async(lambda: dbg().stepout())
[email protected](action='step_to')
[email protected](action='step_to', display='Step To')
def step_to(thread: sch.Schema('Thread'), address: Address, max=None):
"""Continue execution up to the given address."""
find_thread_by_obj(thread)
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidrattd/methods.py b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidrattd/methods.py
index f96c2f5d44..51c445ddca 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidrattd/methods.py
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidrattd/methods.py
@@ -1,17 +1,17 @@
## ###
-# IP: GHIDRA
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# IP: GHIDRA
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
##
from concurrent.futures import Future, ThreadPoolExecutor
import re
@@ -196,8 +196,10 @@ def execute(cmd: str, to_string: bool=False):
exec("{}".format(cmd), shared_globals)
-def evaluate(expr: str):
[email protected](action='evaluate', display='Evaluate')
+def evaluate(
+ session: sch.Schema('Session'),
+ expr: ParamDesc(str, display='Expr')):
"""Execute a CLI command."""
return str(eval("{}".format(expr), shared_globals))
@@ -311,40 +313,51 @@ def remove_process(process: sch.Schema('Process')):
dbg().detach()
[email protected](action='connect')
-def target(process: sch.Schema('Process'), spec: str):
[email protected](action='connect', display='Connect')
+def target(
+ session: sch.Schema('Session'),
+ cmd: ParamDesc(str, display='Command')):
"""Connect to a target machine or process."""
- find_proc_by_obj(process)
- dbg().attach(spec)
+ dbg().attach_kernel(cmd)
[email protected](action='attach')
[email protected](action='attach', display='Attach')
def attach_obj(target: sch.Schema('Attachable')):
"""Attach the process to the given target."""
pid = find_availpid_by_obj(target)
dbg().attach(pid)
[email protected](action='attach')
-def attach_pid(pid: int):
[email protected](action='attach', display='Attach by pid')
+def attach_pid(
+ session: sch.Schema('Session'),
+ pid: ParamDesc(str, display='PID')):
"""Attach the process to the given target."""
- dbg().attach(pid)
+ dbg().attach_proc(int(pid))
[email protected](action='attach')
-def attach_name(process: sch.Schema('Process'), name: str):
[email protected](action='attach', display='Attach by name')
+def attach_name(
+ session: sch.Schema('Session'),
+ name: ParamDesc(str, display='Name')):
"""Attach the process to the given target."""
- dbg().atach(name)
+ dbg().attach_proc(name)
[email protected](action='detach', display='Detach')
def detach(process: sch.Schema('Process')):
"""Detach the process's target."""
dbg().detach()
[email protected](action='launch')
[email protected](action='launch', display='Launch')
def launch_loader(
+ session: sch.Schema('Session'),
file: ParamDesc(str, display='File'),
args: ParamDesc(str, display='Arguments')=''):
"""
@@ -356,11 +369,13 @@ def launch_loader(
commands.ghidra_trace_create(command=file, start_trace=False)
[email protected](action='launch')
[email protected](action='launch', display='LaunchEx')
def launch(
- timeout: ParamDesc(int, display='Timeout'),
+ session: sch.Schema('Session'),
file: ParamDesc(str, display='File'),
- args: ParamDesc(str, display='Arguments')=''):
+ args: ParamDesc(str, display='Arguments')='',
+ initial_break: ParamDesc(bool, display='Initial Break')=True,
+ timeout: ParamDesc(int, display='Timeout')=-1):
"""
Run a native process with the given command line.
"""
@@ -368,7 +383,7 @@ def launch(
if args != None:
command += " "+args
commands.ghidra_trace_create(
- command, initial_break=False, timeout=timeout, start_trace=False)
+ command, initial_break=initial_break, timeout=timeout, start_trace=False)
@REGISTRY.method
@@ -413,7 +428,7 @@ def step_out(thread: sch.Schema('Thread')):
hooks.on_stop()
[email protected](action='step_to')
[email protected](action='step_to', display='Step To')
def step_to(thread: sch.Schema('Thread'), address: Address, max=None):
"""Continue execution up to the given address."""
find_thread_by_obj(thread)