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. |
4 | //***************************************************************************** |
5 | // |
6 | // Define a Data-Target for a live process. |
7 | // |
8 | //***************************************************************************** |
9 | |
10 | #ifndef _LIVEPROC_DATATARGET_H_ |
11 | #define _LIVEPROC_DATATARGET_H_ |
12 | |
13 | // Defines the Data-Target and other public interfaces. |
14 | // Does not include IXClrData definitions. |
15 | #include <clrdata.h> |
16 | |
17 | #ifndef FEATURE_PAL |
18 | |
19 | //--------------------------------------------------------------------------------------- |
20 | // |
21 | // Provides a simple legacy data-target implementation for a live, local, process. |
22 | // Note that in arrowhead, most debuggers use ICorDebugDataTarget, and we have |
23 | // implementations of this in MDbg. |
24 | // |
25 | class LiveProcDataTarget : public ICLRDataTarget |
26 | { |
27 | public: |
28 | LiveProcDataTarget(HANDLE process, |
29 | DWORD processId, |
30 | CLRDATA_ADDRESS baseAddressOfEngine = NULL); |
31 | |
32 | // |
33 | // IUnknown. |
34 | // |
35 | // This class is intended to be kept on the stack |
36 | // or as a member and does not maintain a refcount. |
37 | // |
38 | |
39 | STDMETHOD(QueryInterface)( |
40 | THIS_ |
41 | IN REFIID InterfaceId, |
42 | OUT PVOID* Interface |
43 | ); |
44 | STDMETHOD_(ULONG, AddRef)( |
45 | THIS |
46 | ); |
47 | STDMETHOD_(ULONG, Release)( |
48 | THIS |
49 | ); |
50 | |
51 | // |
52 | // ICLRDataTarget. |
53 | // |
54 | |
55 | virtual HRESULT STDMETHODCALLTYPE GetMachineType( |
56 | /* [out] */ ULONG32 *machine); |
57 | virtual HRESULT STDMETHODCALLTYPE GetPointerSize( |
58 | /* [out] */ ULONG32 *size); |
59 | virtual HRESULT STDMETHODCALLTYPE GetImageBase( |
60 | /* [string][in] */ LPCWSTR name, |
61 | /* [out] */ CLRDATA_ADDRESS *base); |
62 | virtual HRESULT STDMETHODCALLTYPE ReadVirtual( |
63 | /* [in] */ CLRDATA_ADDRESS address, |
64 | /* [length_is][size_is][out] */ PBYTE buffer, |
65 | /* [in] */ ULONG32 request, |
66 | /* [optional][out] */ ULONG32 *done); |
67 | virtual HRESULT STDMETHODCALLTYPE WriteVirtual( |
68 | /* [in] */ CLRDATA_ADDRESS address, |
69 | /* [size_is][in] */ PBYTE buffer, |
70 | /* [in] */ ULONG32 request, |
71 | /* [optional][out] */ ULONG32 *done); |
72 | virtual HRESULT STDMETHODCALLTYPE GetTLSValue( |
73 | /* [in] */ ULONG32 threadID, |
74 | /* [in] */ ULONG32 index, |
75 | /* [out] */ CLRDATA_ADDRESS* value); |
76 | virtual HRESULT STDMETHODCALLTYPE SetTLSValue( |
77 | /* [in] */ ULONG32 threadID, |
78 | /* [in] */ ULONG32 index, |
79 | /* [in] */ CLRDATA_ADDRESS value); |
80 | virtual HRESULT STDMETHODCALLTYPE GetCurrentThreadID( |
81 | /* [out] */ ULONG32* threadID); |
82 | virtual HRESULT STDMETHODCALLTYPE GetThreadContext( |
83 | /* [in] */ ULONG32 threadID, |
84 | /* [in] */ ULONG32 contextFlags, |
85 | /* [in] */ ULONG32 contextSize, |
86 | /* [out, size_is(contextSize)] */ PBYTE context); |
87 | virtual HRESULT STDMETHODCALLTYPE SetThreadContext( |
88 | /* [in] */ ULONG32 threadID, |
89 | /* [in] */ ULONG32 contextSize, |
90 | /* [in, size_is(contextSize)] */ PBYTE context); |
91 | virtual HRESULT STDMETHODCALLTYPE Request( |
92 | /* [in] */ ULONG32 reqCode, |
93 | /* [in] */ ULONG32 inBufferSize, |
94 | /* [size_is][in] */ BYTE *inBuffer, |
95 | /* [in] */ ULONG32 outBufferSize, |
96 | /* [size_is][out] */ BYTE *outBuffer); |
97 | |
98 | private: |
99 | HANDLE m_process; |
100 | DWORD m_processId; |
101 | CLRDATA_ADDRESS m_baseAddressOfEngine; |
102 | }; |
103 | |
104 | #endif // FEATURE_PAL |
105 | |
106 | #endif // _LIVEPROC_DATATARGET_H_ |
107 | |
108 | |