IDebugClient4::CreateProcessAndAttach method (dbgeng.h)

The CreateProcessAndAttach method creates a process from a specified command line, then attach to another user-mode process. The created process is suspended and only allowed to execute when the attach has completed. This allows rough synchronization when debugging both, client and server processes.

Syntax

HRESULT CreateProcessAndAttach(
  [in]           ULONG64 Server,
  [in, optional] PSTR    CommandLine,
  [in]           ULONG   CreateFlags,
  [in]           ULONG   ProcessId,
  [in]           ULONG   AttachFlags
);

Parameters

[in] Server

Specifies the process server to use to attach to the process. If Server is zero, the engine will connect to the local process without using a process server.

[in, optional] CommandLine

Specifies the command line to execute to create the new process. If CommandLine is NULL, then no process is created and these methods attach to an existing process, as AttachProcess does.

[in] CreateFlags

Specifies the flags to use when creating the process. For details on these flags, see DEBUG_CREATE_PROCESS_OPTIONS.CreateFlags.

[in] ProcessId

Specifies the process ID of the target process the debugger will attach to. If ProcessId is zero, the debugger will attach to the process it created from CommandLine.

[in] 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

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

Return code Description
S_OK
The method was successful.

Remarks

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

If CommandLine is not NULL and ProcessId is not zero, then the engine will create the process in a suspended state. The engine will resume this newly created process after it successfully connects to the process specified in ProcessId.

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

Requirement Value
Target Platform Desktop
Header dbgeng.h (include Dbgeng.h)

See also

.attach (Attach to Process)

.create (Create Process)

AbandonCurrentProcess

AttachProcess

ConnectProcessServer

CreateProcess2

CreateProcessAndAttach2

DetachCurrentProcess

GetRunningProcessDescription

GetRunningProcessSystemIds

IDebugClient

IDebugClient2

IDebugClient3

IDebugClient4

IDebugClient5

TerminateCurrentProcess