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 | // File: ReadOnlyDataTargetFacade.inl |
6 | // |
7 | |
8 | // |
9 | //***************************************************************************** |
10 | |
11 | |
12 | //--------------------------------------------------------------------------------------- |
13 | // |
14 | // Ctor for ReadOnlyDataTargetFacade. Just initializes ref count to 0. |
15 | // |
16 | //--------------------------------------------------------------------------------------- |
17 | ReadOnlyDataTargetFacade::ReadOnlyDataTargetFacade() |
18 | : m_ref(0) |
19 | { |
20 | } |
21 | |
22 | // Standard impl of IUnknown::QueryInterface |
23 | HRESULT STDMETHODCALLTYPE |
24 | ReadOnlyDataTargetFacade::QueryInterface( |
25 | REFIID InterfaceId, |
26 | PVOID* pInterface |
27 | ) |
28 | { |
29 | if (InterfaceId == IID_IUnknown) |
30 | { |
31 | *pInterface = static_cast<IUnknown *>(static_cast<ICorDebugDataTarget *>(this)); |
32 | } |
33 | else if (InterfaceId == IID_ICorDebugDataTarget) |
34 | { |
35 | *pInterface = static_cast<ICorDebugDataTarget *>(this); |
36 | } |
37 | else if (InterfaceId == IID_ICorDebugMutableDataTarget) |
38 | { |
39 | *pInterface = static_cast<ICorDebugMutableDataTarget *>(this); |
40 | } |
41 | else |
42 | { |
43 | *pInterface = NULL; |
44 | return E_NOINTERFACE; |
45 | } |
46 | |
47 | AddRef(); |
48 | return S_OK; |
49 | } |
50 | |
51 | // Standard impl of IUnknown::AddRef |
52 | ULONG STDMETHODCALLTYPE |
53 | ReadOnlyDataTargetFacade::AddRef() |
54 | { |
55 | SUPPORTS_DAC; |
56 | LONG ref = InterlockedIncrement(&m_ref); |
57 | return ref; |
58 | } |
59 | |
60 | // Standard impl of IUnknown::Release |
61 | ULONG STDMETHODCALLTYPE |
62 | ReadOnlyDataTargetFacade::Release() |
63 | { |
64 | SUPPORTS_DAC; |
65 | LONG ref = InterlockedDecrement(&m_ref); |
66 | if (ref == 0) |
67 | { |
68 | delete this; |
69 | } |
70 | return ref; |
71 | } |
72 | |
73 | // impl of interface method ICorDebugDataTarget::GetPlatform |
74 | HRESULT STDMETHODCALLTYPE |
75 | ReadOnlyDataTargetFacade::GetPlatform( |
76 | CorDebugPlatform *pPlatform) |
77 | { |
78 | SUPPORTS_DAC; |
79 | _ASSERTE_MSG(false, "Unexpected call to read-API on read-only DataTarget facade" ); |
80 | return E_UNEXPECTED; |
81 | } |
82 | |
83 | // impl of interface method ICorDebugDataTarget::ReadVirtual |
84 | HRESULT STDMETHODCALLTYPE |
85 | ReadOnlyDataTargetFacade::ReadVirtual( |
86 | CORDB_ADDRESS address, |
87 | PBYTE pBuffer, |
88 | ULONG32 cbRequestSize, |
89 | ULONG32 *pcbRead) |
90 | { |
91 | SUPPORTS_DAC; |
92 | _ASSERTE_MSG(false, "Unexpected call to read-API on read-only DataTarget facade" ); |
93 | return E_UNEXPECTED; |
94 | } |
95 | |
96 | // impl of interface method ICorDebugDataTarget::GetThreadContext |
97 | HRESULT STDMETHODCALLTYPE |
98 | ReadOnlyDataTargetFacade::GetThreadContext( |
99 | DWORD dwThreadID, |
100 | ULONG32 contextFlags, |
101 | ULONG32 contextSize, |
102 | BYTE * pContext) |
103 | { |
104 | SUPPORTS_DAC; |
105 | _ASSERTE_MSG(false, "Unexpected call to read-API on read-only DataTarget facade" ); |
106 | return E_UNEXPECTED; |
107 | } |
108 | |
109 | // impl of interface method ICorDebugMutableDataTarget::WriteVirtual |
110 | HRESULT STDMETHODCALLTYPE |
111 | ReadOnlyDataTargetFacade::WriteVirtual( |
112 | CORDB_ADDRESS pAddress, |
113 | const BYTE * pBuffer, |
114 | ULONG32 cbRequestSize) |
115 | { |
116 | SUPPORTS_DAC; |
117 | return CORDBG_E_TARGET_READONLY; |
118 | } |
119 | |
120 | // impl of interface method ICorDebugMutableDataTarget::SetThreadContext |
121 | HRESULT STDMETHODCALLTYPE |
122 | ReadOnlyDataTargetFacade::SetThreadContext( |
123 | DWORD dwThreadID, |
124 | ULONG32 contextSize, |
125 | const BYTE * pContext) |
126 | { |
127 | SUPPORTS_DAC; |
128 | return CORDBG_E_TARGET_READONLY; |
129 | } |
130 | |
131 | // Public implementation of ICorDebugMutableDataTarget::ContinueStatusChanged |
132 | HRESULT STDMETHODCALLTYPE |
133 | ReadOnlyDataTargetFacade::ContinueStatusChanged( |
134 | DWORD dwThreadId, |
135 | CORDB_CONTINUE_STATUS dwContinueStatus) |
136 | { |
137 | SUPPORTS_DAC; |
138 | return CORDBG_E_TARGET_READONLY; |
139 | } |
140 | |