diff options
author | Jeremy Koritzinsky <jekoritz@microsoft.com> | 2021-06-22 19:32:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-22 19:32:53 +0300 |
commit | 2a61c25b26814431163b53e9f9f2e47a750c48e7 (patch) | |
tree | a13741d9df462b61a56aba0c1357f32c10f8e22e /src/coreclr/vm | |
parent | 85aebc422ee12c13a15c94aedd5a2e7627e47db7 (diff) |
Fail COM CoClass creation during construction instead of during jitting (#54508)
Diffstat (limited to 'src/coreclr/vm')
-rw-r--r-- | src/coreclr/vm/ecall.cpp | 20 | ||||
-rw-r--r-- | src/coreclr/vm/ecall.h | 2 | ||||
-rw-r--r-- | src/coreclr/vm/gchelpers.cpp | 12 |
3 files changed, 18 insertions, 16 deletions
diff --git a/src/coreclr/vm/ecall.cpp b/src/coreclr/vm/ecall.cpp index 974556232f6..c6d1b6d2f1e 100644 --- a/src/coreclr/vm/ecall.cpp +++ b/src/coreclr/vm/ecall.cpp @@ -434,12 +434,6 @@ PCODE ECall::GetFCallImpl(MethodDesc * pMD, BOOL * pfSharedOrDynamicFCallImpl /* #endif // FEATURE_COMINTEROP ) { -#ifdef FEATURE_COMINTEROP - if (g_pBaseCOMObject == NULL) - { - COMPlusThrow(kPlatformNotSupportedException, IDS_EE_ERROR_COM); - } - if (pfSharedOrDynamicFCallImpl) *pfSharedOrDynamicFCallImpl = TRUE; @@ -448,9 +442,6 @@ PCODE ECall::GetFCallImpl(MethodDesc * pMD, BOOL * pfSharedOrDynamicFCallImpl /* // FCComCtor does not need to be in the fcall hashtable since it does not erect frame. return GetEEFuncEntryPoint(FCComCtor); -#else - COMPlusThrow(kPlatformNotSupportedException, IDS_EE_ERROR_COM); -#endif // FEATURE_COMINTEROP } if (!pMD->GetModule()->IsSystem()) @@ -571,9 +562,7 @@ BOOL ECall::IsSharedFCallImpl(PCODE pImpl) PCODE pNativeCode = pImpl; return -#ifdef FEATURE_COMINTEROP (pNativeCode == GetEEFuncEntryPoint(FCComCtor)) || -#endif (pNativeCode == GetEEFuncEntryPoint(COMDelegate::DelegateConstruct)); } @@ -619,7 +608,12 @@ BOOL ECall::CheckUnusedECalls(SetSHash<DWORD>& usedIDs) } -#if defined(FEATURE_COMINTEROP) && !defined(CROSSGEN_COMPILE) +#if !defined(CROSSGEN_COMPILE) +// This function is a stub implementation for the constructor of a ComImport class. +// The actual work to implement COM Activation (and built-in COM support checks) is done as part +// of the implementation of object allocation. As a result, the constructor itself has no extra +// work to do once the object has been allocated. As a result, we just provide a dummy implementation +// here since a constructor has to have an implementation. FCIMPL1(VOID, FCComCtor, LPVOID pV) { FCALL_CONTRACT; @@ -627,7 +621,7 @@ FCIMPL1(VOID, FCComCtor, LPVOID pV) FCUnique(0x34); } FCIMPLEND -#endif // FEATURE_COMINTEROP && !CROSSGEN_COMPILE +#endif // !CROSSGEN_COMPILE diff --git a/src/coreclr/vm/ecall.h b/src/coreclr/vm/ecall.h index 387bbc2e9dd..9b946ad1982 100644 --- a/src/coreclr/vm/ecall.h +++ b/src/coreclr/vm/ecall.h @@ -134,8 +134,6 @@ class ECall static LPVOID GetQCallImpl(MethodDesc * pMD); }; -#ifdef FEATURE_COMINTEROP extern "C" FCDECL1(VOID, FCComCtor, LPVOID pV); -#endif #endif // _ECALL_H_ diff --git a/src/coreclr/vm/gchelpers.cpp b/src/coreclr/vm/gchelpers.cpp index 74412a9e06d..0cecfc624a7 100644 --- a/src/coreclr/vm/gchelpers.cpp +++ b/src/coreclr/vm/gchelpers.cpp @@ -930,15 +930,25 @@ OBJECTREF AllocateObject(MethodTable *pMT #ifdef FEATURE_COMINTEROP_UNMANAGED_ACTIVATION if (fHandleCom && pMT->IsComObjectType()) { + if (!g_pConfig->IsBuiltInCOMSupported()) + { + COMPlusThrow(kNotSupportedException, W("NotSupported_COM")); + } + // Create a instance of __ComObject here is not allowed as we don't know what COM object to create if (pMT == g_pBaseCOMObject) COMPlusThrow(kInvalidComObjectException, IDS_EE_NO_BACKING_CLASS_FACTORY); oref = OBJECTREF_TO_UNCHECKED_OBJECTREF(AllocateComObject_ForManaged(pMT)); } - else #endif // FEATURE_COMINTEROP_UNMANAGED_ACTIVATION +#else // FEATURE_COMINTEROP + if (pMT->IsComObjectType()) + { + COMPlusThrow(kPlatformNotSupportedException, IDS_EE_ERROR_COM); + } #endif // FEATURE_COMINTEROP + else { GC_ALLOC_FLAGS flags = GC_ALLOC_NO_FLAGS; if (pMT->ContainsPointers()) |