The CreateProcessAndAttach2 method creates a process from a specified command line, then attaches to that process or another user-mode process.
HRESULT CreateProcessAndAttach2( ULONG64 Server, PSTR CommandLine, PVOID OptionsBuffer, ULONG OptionsBufferSize, PCSTR InitialDirectory, PCSTR Environment, ULONG ProcessId, ULONG AttachFlags );
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.
Specifies the command line to execute to create the new process. If CommandLine is NULL, no process is created and these methods will use ProcessId to attach to an existing process.
Specifies the process creation options. OptionsBuffer is a pointer to a DEBUG_CREATE_PROCESS_OPTIONS structure.
Specifies the size of the buffer OptionsBuffer. This should be set to sizeof(DEBUG_CREATE_PROCESS_OPTIONS).
Specifies the starting directory for the process. This parameter is used only if CommandLine is not NULL. If InitialDirectory is NULL, the current directory for the process server is used.
Specifies an environment block for the new process. An environment block consists of a null-terminated block of null-terminated strings. Each string is of the form:
If Environment is set to NULL, the new process inherits the environment block of the process server. If the DEBUG_CREATE_PROCESS_THROUGH_RTL flag is set in OptionsBuffer, then Environment must be NULL.
Specifies the process ID of the target process to which the debugger will attach. If ProcessID is zero, the debugger will attach to the process it created from CommandLine.
Specifies the flags that control how the debugger attaches to the target process. For details on these flags, see DEBUG_ATTACH_XXX.
This method may also return error values. See Return Values for more details.
||The method was successful.|
||This is returned if CommandLine is NULL and ProcessId is zero.|
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.
|Header||dbgeng.h (include Dbgeng.h)|