Skip to content

proc ¤

Classes:

  • EventHandler

    The event types that make sense for us to track in the process driver aren't

  • LaunchResult

    Base class for results of launch operations.

  • LaunchResultSuccess

    Indicates that the process was fully launched or attached to.

  • LaunchResultEarlyExit

    Indicates that the process was fully launched or attached to, but that it

  • LaunchResultConnected

    Indicates that there has been a successful connection to a remote

  • LaunchResultError

    Indicates that there was an error launching the process.

  • ProcessDriver

    Drives the execution of a process, responding to its events and handling its

EventHandler ¤

The event types that make sense for us to track in the process driver aren't the same as the ones in the rest of Pwndbg, so we just expose the native events in process driver, and let the rest of the REPL deal with any complexities that might arise from the translation.

This is mostly intended to keep the complexity of generating the START and NEW_THREAD events correctly out of the process driver.

Methods:

  • created

    This function is called when a process is created or attached to.

  • suspended

    This function is called when the execution of a process is suspended.

  • resumed

    This function is called when the execution of a process is resumed.

  • exited

    This function is called when a process terminates or is detached from.

  • modules_loaded

    This function is called when a new modules have been loaded.

created ¤

created()

This function is called when a process is created or attached to.

suspended ¤

suspended(cause: SBEvent)

This function is called when the execution of a process is suspended.

resumed ¤

resumed()

This function is called when the execution of a process is resumed.

exited ¤

exited()

This function is called when a process terminates or is detached from.

modules_loaded ¤

modules_loaded()

This function is called when a new modules have been loaded.

LaunchResult ¤

Base class for results of launch operations.

LaunchResultSuccess ¤

Bases: LaunchResult

Indicates that the process was fully launched or attached to.

LaunchResultEarlyExit ¤

Bases: LaunchResult

Indicates that the process was fully launched or attached to, but that it exited immediately, with no stop events.

LaunchResultConnected ¤

Bases: LaunchResult

Indicates that there has been a successful connection to a remote debugserver, but that no process is being debugged yet.

LaunchResultError ¤

LaunchResultError(what: SBError, disconnected: bool)

Bases: LaunchResult

Indicates that there was an error launching the process.

Attributes:

__match_args__ class-attribute instance-attribute ¤

__match_args__ = ('what', 'disconnected')

what instance-attribute ¤

what = what

disconnected instance-attribute ¤

disconnected = disconnected

ProcessDriver ¤

ProcessDriver(event_handler: EventHandler, debug=False)

Drives the execution of a process, responding to its events and handling its I/O, and exposes a simple synchronous interface to the REPL interface.

IODriver State Machine¤

Because LLDB can make Python code from Pwndbg execute while an I/O driver is active, and having the I/O driver active while Pwndbg is running leads to all sorts of fun failure modes, we want to be able to pause it temporarily.

We, thus, use the states described in _IODriverState to keep track of what operations may be performed on the current IODriver.

Methods:

  • __enter__
  • __exit__
  • debug_print
  • has_process

    Whether there's an active process in this driver.

  • has_connection

    Whether this driver's connected to a target. All drivers that have an

  • interrupt

    Interrupts the currently running process or command.

  • suspend_interrupts

    Sometimes it's necessary to guard against interruption by

  • pause_io_if_running

    Pauses the handling of process I/O if it is currently running.

  • resume_io_if_running

    Resumes the handling of process I/O if it is currently running.

  • cont

    Continues execution of the process this object is driving, and returns

  • run_lldb_command

    Runs the given LLDB command and ataches I/O if necessary.

  • run_coroutine

    Runs the given coroutine and allows it to control the execution of the

  • launch

    Launches the process and handles startup events. Always stops on first

  • attach

    Attach to a process and handles startup events. Always stops on first

  • connect

    Connects to a remote proces with the given URL using the plugin with the

Attributes:

io instance-attribute ¤

io: IODriver = None

process instance-attribute ¤

process: SBProcess = None

listener instance-attribute ¤

listener: SBListener = None

debug instance-attribute ¤

debug: bool = debug

eh instance-attribute ¤

eh: EventHandler = event_handler

__enter__ ¤

__enter__() -> ProcessDriver

__exit__ ¤

__exit__(_exc_type, _exc_val, _exc_tb) -> None

debug_print ¤

debug_print(*args, **kwargs) -> None

has_process ¤

has_process() -> bool

Whether there's an active process in this driver.

has_connection ¤

has_connection() -> bool

Whether this driver's connected to a target. All drivers that have an active process also must necessarily be connected.

interrupt ¤

interrupt(in_lldb_command_handler: bool = False) -> None

Interrupts the currently running process or command.

suspend_interrupts ¤

suspend_interrupts(interrupt: Callable[[], None] | None = None)

Sometimes it's necessary to guard against interruption by self.interrupt, especially when being interrupted would lead to bad process state.

pause_io_if_running ¤

pause_io_if_running() -> None

Pauses the handling of process I/O if it is currently running.

resume_io_if_running ¤

resume_io_if_running() -> None

Resumes the handling of process I/O if it is currently running.

cont ¤

cont() -> None

Continues execution of the process this object is driving, and returns whenever the process stops.

run_lldb_command ¤

run_lldb_command(command: str, target: BinaryIO) -> None

Runs the given LLDB command and ataches I/O if necessary.

run_coroutine ¤

run_coroutine(coroutine: Coroutine[Any, Any, None]) -> bool

Runs the given coroutine and allows it to control the execution of the process in this driver. Returns True if the coroutine ran to completion, and False if it was cancelled.

launch ¤

launch(
    target: SBTarget,
    io: IODriver,
    env: list[str],
    args: list[str],
    working_dir: str | None,
    disable_aslr: bool,
) -> LaunchResult

Launches the process and handles startup events. Always stops on first opportunity, and returns immediately after the process has stopped.

Fires the created() event.

attach ¤

attach(target: SBTarget, info: SBAttachInfo) -> LaunchResult

Attach to a process and handles startup events. Always stops on first opportunity, and returns immediately after the process has stopped.

Fires the created() event.

connect ¤

connect(target: SBTarget, io: IODriver, url: str, plugin: str) -> LaunchResult

Connects to a remote proces with the given URL using the plugin with the given name. This might cause the process to launch in some implementations, or it might require a call to launch(), in implementations that require a further call to SBProcess::RemoteLaunch().

Fires the created() event if a process is automatically attached to or launched when a connection succeeds.