|
3 | 3 | // See the LICENSE file in the project root for more information. |
4 | 4 |
|
5 | 5 | #include "comwrappers.hpp" |
| 6 | +#include <interoplibabi.h> |
6 | 7 | #include <interoplibimports.h> |
7 | 8 |
|
8 | 9 | #include <new> // placement new |
@@ -47,8 +48,8 @@ namespace ABI |
47 | 48 | }; |
48 | 49 | ABI_ASSERT(sizeof(ComInterfaceDispatch) == sizeof(void*)); |
49 | 50 |
|
50 | | - const size_t DispatchAlignmentThisPtr = 16; // Should be a power of 2. |
51 | | - const intptr_t DispatchThisPtrMask = ~(DispatchAlignmentThisPtr - 1); |
| 51 | + using InteropLib::ABI::DispatchAlignmentThisPtr; |
| 52 | + using InteropLib::ABI::DispatchThisPtrMask; |
52 | 53 | ABI_ASSERT(sizeof(void*) < DispatchAlignmentThisPtr); |
53 | 54 |
|
54 | 55 | const intptr_t AlignmentThisPtrMaxPadding = DispatchAlignmentThisPtr - sizeof(void*); |
@@ -179,17 +180,20 @@ namespace ABI |
179 | 180 | } |
180 | 181 | } |
181 | 182 |
|
182 | | -namespace |
| 183 | +// ManagedObjectWrapper_QueryInterface needs to be visible outside of this compilation unit |
| 184 | +// to support the DAC. See code:ClrDataAccess::DACTryGetComWrappersObjectFromCCW for the |
| 185 | +// usage in the DAC (look for the GetEEFuncEntryPoint call). |
| 186 | +HRESULT STDMETHODCALLTYPE ManagedObjectWrapper_QueryInterface( |
| 187 | + _In_ ABI::ComInterfaceDispatch* disp, |
| 188 | + /* [in] */ REFIID riid, |
| 189 | + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject) |
183 | 190 | { |
184 | | - HRESULT STDMETHODCALLTYPE ManagedObjectWrapper_QueryInterface( |
185 | | - _In_ ABI::ComInterfaceDispatch* disp, |
186 | | - /* [in] */ REFIID riid, |
187 | | - /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject) |
188 | | - { |
189 | | - ManagedObjectWrapper* wrapper = ABI::ToManagedObjectWrapper(disp); |
190 | | - return wrapper->QueryInterface(riid, ppvObject); |
191 | | - } |
| 191 | + ManagedObjectWrapper* wrapper = ABI::ToManagedObjectWrapper(disp); |
| 192 | + return wrapper->QueryInterface(riid, ppvObject); |
| 193 | +} |
192 | 194 |
|
| 195 | +namespace |
| 196 | +{ |
193 | 197 | ULONG STDMETHODCALLTYPE ManagedObjectWrapper_AddRef(_In_ ABI::ComInterfaceDispatch* disp) |
194 | 198 | { |
195 | 199 | ManagedObjectWrapper* wrapper = ABI::ToManagedObjectWrapper(disp); |
@@ -310,6 +314,7 @@ void ManagedObjectWrapper::GetIUnknownImpl( |
310 | 314 | *fpRelease = ManagedObjectWrapper_IUnknownImpl.Release; |
311 | 315 | } |
312 | 316 |
|
| 317 | +// The logic here should match code:ClrDataAccess::DACTryGetComWrappersObjectFromCCW in daccess/request.cpp |
313 | 318 | ManagedObjectWrapper* ManagedObjectWrapper::MapFromIUnknown(_In_ IUnknown* pUnk) |
314 | 319 | { |
315 | 320 | _ASSERTE(pUnk != nullptr); |
|
0 commit comments