Win32 API Reference

Microsoft Developer Network

DebugActiveProcessEx

Attaches the calling process to the specified client process, enabling it to debug the client process.

BOOL DebugActiveProcessEx(
    DWORD dwProcessId
);

Parameters

dwProcessId
The identifier of the process to be debugged. This parameter can be 0. If this parameter is 0, the calling process is attached to the first process that is being debugged.

Return value

If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The DebugActiveProcessEx function enables a process to be debugged by another process. When a debugger attaches to a process, the system sends a CREATE_PROCESS_DEBUG_EVENT or CREATE_THREAD_DEBUG_EVENT notification to the debugger.

A process can only be attached to one debugger at a time. If the process is already being debugged, DebugActiveProcessEx fails.

Use the DebugActiveProcessStop function to detach the debugger from the process.

If dwProcessId is 0, the debugger attaches to the first process that is being debugged. This can be useful if a debugger process is started before the process it is intended to debug.

Requirements

Win32
SDK Headers
Library

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

winbase.h (include windows.h)

SDK Headers

winbase.h

Library

Kernel32.lib

See also

DebugActiveProcessStop

WaitForDebugEvent

Debugging Functions