diff options
author | dotnet-bot <dotnet-bot@microsoft.com> | 2015-01-30 14:14:42 -0800 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2015-01-30 14:14:42 -0800 |
commit | ef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch) | |
tree | dee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/vm/profattachclient.h | |
download | coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2 coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip |
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/vm/profattachclient.h')
-rw-r--r-- | src/vm/profattachclient.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/vm/profattachclient.h b/src/vm/profattachclient.h new file mode 100644 index 0000000000..69a8fb53dc --- /dev/null +++ b/src/vm/profattachclient.h @@ -0,0 +1,79 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// +// +// ProfAttachClient.h +// + +// +// Definition of ProfilingAPIAttachClient, which houses the prime portion of the +// implementation of the AttachProfiler() API, exported by mscoree.dll, and consumed by +// trigger processes in order to force the runtime of a target process to load a +// profiler. This handles opening a client connection to the pipe created by the target +// profilee, and sending requests across that pipe to force the target profilee (which +// acts as the pipe server) to attach a profiler. +// + +// ====================================================================================== + +#ifndef __PROF_ATTACH_CLIENT_H__ +#define __PROF_ATTACH_CLIENT_H__ + +#ifdef FEATURE_PROFAPI_ATTACH_DETACH +extern "C" HRESULT STDMETHODCALLTYPE AttachProfiler( + DWORD dwProfileeProcessID, + DWORD dwMillisecondsMax, + const CLSID * pClsidProfiler, + LPCWSTR wszProfilerPath, + void * pvClientData, + UINT cbClientData, + LPCWSTR wszRuntimeVersion); +#endif // FEATURE_PROFAPI_ATTACH_DETACH +// --------------------------------------------------------------------------------------- +// Here's the beef. All the pipe client stuff running in the trigger process (via call to +// AttachProfiler()) is housed in this class. Note that these functions cannot assume a +// fully initialized runtime (e.g., it would be nonsensical for these functions to +// reference ProfilingAPIAttachDetach::s_hAttachEvent). These functions operate solely by +// finding the attach event & pipes by name, and using them to communicate with the +// target profilee app. + +class ProfilingAPIAttachClient +{ +public: + HRESULT AttachProfiler( + DWORD dwProfileeProcessID, + DWORD dwMillisecondsMax, + const CLSID * pClsidProfiler, + LPCWSTR wszProfilerPath, + void * pvClientData, + UINT cbClientData, + LPCWSTR wszRuntimeVersion); + +protected: + // Client connection to the pipe that connects to the target profilee (server) + HandleHolder m_hPipeClient; + + BOOL MightProcessExist(DWORD dwProcessID); + HRESULT SignalAttachEvent(LPCWSTR wszEventName); + HRESULT OpenPipeClient( + LPCWSTR wszPipeName, + DWORD dwMillisecondsMax); + HRESULT VerifyVersionIsCompatible(DWORD dwMillisecondsMax); + HRESULT SendAttachRequest( + DWORD dwMillisecondsMax, + const CLSID * pClsidProfiler, + LPCWSTR wszProfilerPath, + void * pvClientData, + UINT cbClientData, + HRESULT * phrAttach); + HRESULT SendAndReceive( + DWORD dwMillisecondsMax, + LPVOID pvInBuffer, + DWORD cbInBuffer, + LPVOID pvOutBuffer, + DWORD cbOutBuffer, + DWORD * pcbReceived); +}; + +#endif //__PROF_ATTACH_CLIENT_H__ |