The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at IDebugProcess2::Attach.

Attaches the session debug manager (SDM) to the process.

int Attach(   
   IDebugEventCallback2 pCallback,  
   Guid[]               rgguidSpecificEngines,  
   uint                 celtSpecificEngines,  
   int[]                rghrEngineAttach  


[in] An IDebugEventCallback2 object that is used for debug event notification.

[in] An array of GUIDs of debug engines to be used to debug programs running in the process. This parameter can be a null value. See Remarks for details.

[in] The number of debug engines in the rgguidSpecificEngines array and the size of the rghrEngineAttach array.

[in, out] An array of HRESULT codes returned by the debug engines. The size of this array is specified in the celtSpecificEngines parameter. Each code is typically either S_OK or S_ATTACH_DEFERRED. The latter indicates that the DE is currently attached to no programs.

If successful, returns S_OK; otherwise, returns an error code. The following table shows other possible values.

E_ATTACH_DEBUGGER_ALREADY_ATTACHEDThe specified process is already attached to the debugger.
E_ATTACH_DEBUGGEE_PROCESS_SECURITY_VIOLATIONA security violation occurred during the attach procedure.
E_ATTACH_CANNOT_ATTACH_TO_DESKTOPA desktop process cannot be attached to the debugger.

Attaching to a process attaches the SDM to all programs running in that process that can be debugged by the debug engines (DE) specified in the rgguidSpecificEngines array. Set the rgguidSpecificEngines parameter to a null value or include GUID_NULL in the array to attach to all programs in the process.

All debug events that occur in the process are sent to the given IDebugEventCallback2 object. This IDebugEventCallback2 object is provided when the SDM calls this method.