/** * Debugger launcher — auto-detect PE architecture and spawn x32dbg / x64dbg. * * Reads the PE header to determine if a target is 32-bit or 64-bit, * launches the correct debugger, and waits for the bridge plugin to * become reachable over TCP. */ import { ChildProcess } from "child_process"; /** * Detect PE architecture by reading the PE header from disk. * Returns "x86" or "x64", or throws if the file is not a valid PE. */ export declare function detectPEArchitecture(exePath: string): "x86" | "x64"; /** * Pick a free TCP port for a per-session bridge listener. * * Default range 30000–44999 sits in the IANA registered range and below the * Windows default TCP ephemeral pool (49152–65535). Picking inside the * ephemeral pool produced false positives in waitForBridge: a port briefly * used by an unrelated outbound connection looked "reachable" but refused * the next connect a few hundred ms later. * * Probes by binding a throwaway server; the first successful bind wins. * * @throws McpError(E_PORT_EXHAUSTED) after `attempts` random failures. */ export declare function pickFreePort(min?: number, max?: number, attempts?: number): Promise; /** * Resolve the path to x32dbg.exe or x64dbg.exe based on the * configured x64dbg installation directory. */ export declare function resolveDebuggerExe(arch: "x86" | "x64"): string; /** * Launch x64dbg (or x32dbg) with the given executable and wait for * the bridge plugin to start accepting TCP connections. * * @returns The detected architecture. */ export declare function launchDebugger(targetExe: string): Promise<"x86" | "x64">; /** * Multi-session variant: launch x64dbg on a specific bridge port and return * both the detected architecture and the ChildProcess handle. * * Caller is responsible for tracking the ChildProcess (typically by passing * it into rememberDebuggerForSession after the session is registered). */ export declare function launchDebuggerOnPort(targetExe: string, port: number): Promise<{ arch: "x86" | "x64"; child: ChildProcess; }>; /** * Launch x64dbg (or x32dbg) for attaching to a running process by PID. * Similar to launchDebugger but takes a PID and architecture instead of an executable. * * @param pid Process ID to attach to * @param arch Target process architecture ("x86" or "x64") * @returns The target process architecture. */ export declare function launchDebuggerForAttach(pid: number, arch: "x86" | "x64"): Promise<"x86" | "x64">; /** * Multi-session attach variant: launch x64dbg/x32dbg on a specific bridge port * for attaching to a running process by PID. Returns the ChildProcess handle. */ export declare function launchDebuggerForAttachOnPort(pid: number, arch: "x86" | "x64", port: number): Promise; /** * Track a spawned x64dbg ChildProcess against a sessionId so it can be killed * during session teardown. Call after sessions.create() succeeds. */ export declare function rememberDebuggerForSession(sessionId: string, child: ChildProcess): void; /** * Kill the x64dbg/x32dbg ChildProcess associated with a session, if any. * No-op if KEEP_DEBUGGER=1 or the process already exited. */ export declare function killDebuggerForSession(sessionId: string): void; /** * Kill all spawned x64dbg/x32dbg processes (used during MCP server shutdown). * Honors KEEP_DEBUGGER=1. */ export declare function killAllDebuggers(): void; /** Legacy single-instance kill — kept until a later cleanup task removes the last caller. */ export declare function killDebugger(): void; /** Legacy state check for the singleton — kept until callers migrate. */ export declare function isDebuggerRunning(): boolean; /** * Detect the architecture (x86 or x64) of a running process by PID. * Uses PowerShell to check if process is 32-bit (Wow64) or 64-bit. * Returns "x86" or "x64", or throws if the PID is invalid or inaccessible. */ export declare function detectProcessArchitecture(pid: number): "x86" | "x64"; //# sourceMappingURL=launcher.d.ts.map