Debugging Tools for Windows

AttachProcess

The AttachProcess method connects the debugger engine to a user-mode process.

HRESULT
  IDebugClient::AttachProcess(
    IN ULONG64  Server,
    IN ULONG  ProcessId,
    IN ULONG  AttachFlags
    );

Parameters

Server
Specifies the process server to use to attach to the process. If Server is zero, the engine will connect to a local process without using a process server.
ProcessId
Specifies the process ID of the target process the debugger will attach to.
AttachFlags
Specifies the flags that control how the debugger attaches to the target process. For details on these flags, see DEBUG_ATTACH_XXX.

Return Value

S_OK
The method was successful.

This method may also return error values. See Return Values for more details.

Interface Version

AttachProcess is available in all versions of IDebugClient.

Comments

This method is available only for live user-mode debugging.

Note  The engine doesn't completely attach to the process until the WaitForEvent method has been called. Only after the process has generated an event — for example, the create-process event — does it become available in the debugger session.

For more information about creating and attaching to live user-mode targets, see Live User-Mode Targets.

Requirements

Headers: Defined in dbgeng.h. Include dbgeng.h.

See Also

.attach (Attach to Process), ConnectProcessServer, CreateProcess2, CreateProcessAndAttach2, GetRunningProcessSystemIds, GetRunningProcessDescription , DetachCurrentProcess, TerminateCurrentProcess, AbandonCurrentProcess

Build machine: CAPEBUILD