1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
9 // Definition of ProfilingAPIAttachClient, which houses the prime portion of the
10 // implementation of the AttachProfiler() API, exported by mscoree.dll, and consumed by
11 // trigger processes in order to force the runtime of a target process to load a
12 // profiler. This handles opening a client connection to the pipe created by the target
13 // profilee, and sending requests across that pipe to force the target profilee (which
14 // acts as the pipe server) to attach a profiler.
17 // ======================================================================================
19 #ifndef __PROF_ATTACH_CLIENT_H__
20 #define __PROF_ATTACH_CLIENT_H__
22 #ifdef FEATURE_PROFAPI_ATTACH_DETACH
23 extern "C" HRESULT STDMETHODCALLTYPE AttachProfiler(
24 DWORD dwProfileeProcessID,
25 DWORD dwMillisecondsMax,
26 const CLSID * pClsidProfiler,
27 LPCWSTR wszProfilerPath,
30 LPCWSTR wszRuntimeVersion);
31 #endif // FEATURE_PROFAPI_ATTACH_DETACH
32 // ---------------------------------------------------------------------------------------
33 // Here's the beef. All the pipe client stuff running in the trigger process (via call to
34 // AttachProfiler()) is housed in this class. Note that these functions cannot assume a
35 // fully initialized runtime (e.g., it would be nonsensical for these functions to
36 // reference ProfilingAPIAttachDetach::s_hAttachEvent). These functions operate solely by
37 // finding the attach event & pipes by name, and using them to communicate with the
38 // target profilee app.
40 class ProfilingAPIAttachClient
43 HRESULT AttachProfiler(
44 DWORD dwProfileeProcessID,
45 DWORD dwMillisecondsMax,
46 const CLSID * pClsidProfiler,
47 LPCWSTR wszProfilerPath,
50 LPCWSTR wszRuntimeVersion);
53 // Client connection to the pipe that connects to the target profilee (server)
54 HandleHolder m_hPipeClient;
56 BOOL MightProcessExist(DWORD dwProcessID);
57 HRESULT SignalAttachEvent(LPCWSTR wszEventName);
58 HRESULT OpenPipeClient(
60 DWORD dwMillisecondsMax);
61 HRESULT VerifyVersionIsCompatible(DWORD dwMillisecondsMax);
62 HRESULT SendAttachRequest(
63 DWORD dwMillisecondsMax,
64 const CLSID * pClsidProfiler,
65 LPCWSTR wszProfilerPath,
69 HRESULT SendAndReceive(
70 DWORD dwMillisecondsMax,
78 #endif //__PROF_ATTACH_CLIENT_H__