Skip to content

Commit

Permalink
GP-4620: Fix process termination (esp., on kill)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsadeveloper789 committed May 21, 2024
1 parent 587307e commit 121608a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def main():
from ghidradbg import commands as cmd
from ghidradbg.util import dbg

# So that the user can re-enter by typing repl()
global repl
repl = cmd.repl

cmd.ghidra_trace_connect(os.getenv('GHIDRA_TRACE_RMI_ADDR'))
args = os.getenv('OPT_TARGET_ARGS')
if args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from pybag import pydbg, userdbg, kerneldbg
from pybag.dbgeng import core as DbgEng
from pybag.dbgeng import exception
from pybag.dbgeng.win32.kernel32 import STILL_ACTIVE

from . import util, arch, methods, hooks
from .dbgmodel.imodelobject import ModelObjectKind
Expand Down Expand Up @@ -841,6 +842,9 @@ def ghidra_trace_disassemble(address):

@util.dbg.eng_thread
def compute_proc_state(nproc=None):
exit_code = util.GetExitCode()
if exit_code is not None and exit_code != STILL_ACTIVE:
return 'TERMINATED'
status = util.dbg._base._control.GetExecutionStatus()
if status == DbgEng.DEBUG_STATUS_BREAK:
return 'STOPPED'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ def on_process_selected():
@log_errors
def on_process_deleted(*args):
# print("ON_PROCESS_DELETED")
proc = args[0]
exit_code = args[0]
proc = util.selected_process()
on_exited(proc)
if proc in PROC_STATE:
del PROC_STATE[proc]
Expand Down

0 comments on commit 121608a

Please sign in to comment.