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 | // ReadOnlyDataTargetFacade.h |
6 | // |
7 | |
8 | // |
9 | //***************************************************************************** |
10 | |
11 | #ifndef READONLYDATATARGETFACADE_H_ |
12 | #define READONLYDATATARGETFACADE_H_ |
13 | |
14 | #include <cordebug.h> |
15 | |
16 | //--------------------------------------------------------------------------------------- |
17 | // ReadOnlyDataTargetFacade |
18 | // |
19 | // This class is designed to be used as an ICorDebugMutableDataTarget when none is |
20 | // supplied. All of the write APIs will fail with CORDBG_E_TARGET_READONLY as required |
21 | // by the data target spec when a write operation is invoked on a read-only data target. |
22 | // The desire here is to merge the error code paths for the case when a write fails, |
23 | // and the case when a write is requested but the data target supplied doesn't |
24 | // implement ICorDebugMutableDataTarget. |
25 | // |
26 | // Note that this is intended to be used only for the additional APIs defined by |
27 | // ICorDebugMutableDataTarget. Calling any of the base ICorDebugDataTarget APIs |
28 | // will ASSERT and fail. An alternative design would be to make this class a wrapper |
29 | // class (similar to DataTargetAdapter) over an existing ICorDebugDataTarget interface. |
30 | // In general, we'd like callers of the data target to differentiate between when they're |
31 | // using read-only APIs and mutation APIs since they need to be aware that the latter often |
32 | // won't be supported by the data target. Also, that design would have the draw-back |
33 | // of incuring an extra virtual dispatch on every read API call (makaing debugging more |
34 | // complex and possibly having a performance impact). |
35 | // |
36 | class ReadOnlyDataTargetFacade : public ICorDebugMutableDataTarget |
37 | { |
38 | public: |
39 | ReadOnlyDataTargetFacade(); |
40 | virtual ~ReadOnlyDataTargetFacade() {} |
41 | |
42 | // |
43 | // IUnknown. |
44 | // |
45 | virtual HRESULT STDMETHODCALLTYPE QueryInterface( |
46 | REFIID InterfaceId, |
47 | PVOID* Interface); |
48 | |
49 | virtual ULONG STDMETHODCALLTYPE AddRef(); |
50 | |
51 | virtual ULONG STDMETHODCALLTYPE Release(); |
52 | |
53 | // |
54 | // ICorDebugDataTarget. |
55 | // |
56 | |
57 | virtual HRESULT STDMETHODCALLTYPE GetPlatform( |
58 | CorDebugPlatform *pPlatform); |
59 | |
60 | virtual HRESULT STDMETHODCALLTYPE ReadVirtual( |
61 | CORDB_ADDRESS address, |
62 | BYTE * pBuffer, |
63 | ULONG32 request, |
64 | ULONG32 * pcbRead); |
65 | |
66 | virtual HRESULT STDMETHODCALLTYPE GetThreadContext( |
67 | DWORD dwThreadID, |
68 | ULONG32 contextFlags, |
69 | ULONG32 contextSize, |
70 | BYTE * context); |
71 | |
72 | // |
73 | // ICorDebugMutableDataTarget. |
74 | // |
75 | |
76 | virtual HRESULT STDMETHODCALLTYPE WriteVirtual( |
77 | CORDB_ADDRESS address, |
78 | const BYTE * pBuffer, |
79 | ULONG32 request); |
80 | |
81 | virtual HRESULT STDMETHODCALLTYPE SetThreadContext( |
82 | DWORD dwThreadID, |
83 | ULONG32 contextSize, |
84 | const BYTE * context); |
85 | |
86 | virtual HRESULT STDMETHODCALLTYPE ContinueStatusChanged( |
87 | DWORD dwThreadId, |
88 | CORDB_CONTINUE_STATUS dwContinueStatus); |
89 | |
90 | private: |
91 | // Reference count. |
92 | LONG m_ref; |
93 | }; |
94 | |
95 | #include "readonlydatatargetfacade.inl" |
96 | |
97 | #endif // READONLYDATATARGETFACADE_H_ |
98 | |
99 | |