Debugging Tools for Windows |
The CreateProcessAndAttach2 and CreateProcessAndAttach2Wide methods create a process from a specified command line, then attach to that process or another user-mode process.
HRESULT
IDebugClient5::CreateProcessAndAttach2(
IN ULONG64 Server,
IN OPTIONAL PSTR CommandLine,
IN PVOID OptionsBuffer,
IN ULONG OptionsBufferSize,
IN OPTIONAL PCSTR InitialDirectory,
IN OPTIONAL PCSTR Environment,
IN ULONG ProcessId,
IN ULONG AttachFlags
);
HRESULT
IDebugClient5::CreateProcessAndAttach2Wide(
IN ULONG64 Server,
IN OPTIONAL PWSTR CommandLine,
IN PVOID OptionsBuffer,
IN ULONG OptionsBufferSize,
IN OPTIONAL PCWSTR InitialDirectory,
IN OPTIONAL PCWSTR Environment,
IN ULONG ProcessId,
IN ULONG AttachFlags
);
#ifdef UNICODE
#define CreateProcessAndAttach2T CreateProcessAndAttach2Wide
#else
#define CreateProcessAndAttach2T CreateProcessAndAttach2
#endif
Note that the last two characters of the environment block are both NULL: one to terminate the string and one to terminate the block.
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.
This method may also return error values. See Return Values for more details.
CreateProcessAndAttach2 and CreateProcessAndAttach2Wide are available in IDebugClient5 and later versions.
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.
Headers: Defined in dbgeng.h. Include dbgeng.h.
AttachProcess, .attach (Attach to Process), .create (Create Process), ConnectProcessServer, CreateProcess2, GetRunningProcessSystemIds, GetRunningProcessDescription , DetachCurrentProcess, TerminateCurrentProcess, AbandonCurrentProcess