diff options
author | Aaron Robinson <arobins@microsoft.com> | 2019-03-04 18:58:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-04 18:58:56 -0800 |
commit | 88ada237f7765b7edd39967adab8ea2ba25ea16c (patch) | |
tree | aa06f4463840d434d0670104006b8119e43f5a4a /src/vm | |
parent | 77fcaf6b738941a0c5dc3c00b70b49c7d9f63b69 (diff) | |
download | coreclr-88ada237f7765b7edd39967adab8ea2ba25ea16c.tar.gz coreclr-88ada237f7765b7edd39967adab8ea2ba25ea16c.tar.bz2 coreclr-88ada237f7765b7edd39967adab8ea2ba25ea16c.zip |
Remove loose dependency in runtime on System.ComponentModel. (#23010)
Remove loose dependency in runtime on System.ComponentModel.
Disable test to sync with CoreFX
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/appdomain.cpp | 42 | ||||
-rw-r--r-- | src/vm/appdomain.hpp | 5 | ||||
-rw-r--r-- | src/vm/metasig.h | 11 | ||||
-rw-r--r-- | src/vm/mscorlib.h | 6 | ||||
-rw-r--r-- | src/vm/namespace.h | 1 | ||||
-rw-r--r-- | src/vm/runtimecallablewrapper.cpp | 206 |
6 files changed, 102 insertions, 169 deletions
diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index 21161763ef..563de46075 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -1828,47 +1828,6 @@ void BaseDomain::InitLargeHeapHandleTable() #endif } -#ifdef FEATURE_COMINTEROP -MethodTable* AppDomain::GetLicenseInteropHelperMethodTable() -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - } - CONTRACTL_END; - - if(m_pLicenseInteropHelperMT == NULL) - { - // Do this work outside of the lock so we don't have an unbreakable lock condition - - TypeHandle licenseMgrTypeHnd; - MethodDescCallSite loadLM(METHOD__MARSHAL__LOAD_LICENSE_MANAGER); - - licenseMgrTypeHnd = (MethodTable*) loadLM.Call_RetLPVOID((ARG_SLOT*)NULL); - - // - // Look up this method by name, because the type is actually declared in System.dll. <TODO>@todo: why?</TODO> - // - - MethodDesc *pGetLIHMD = MemberLoader::FindMethod(licenseMgrTypeHnd.AsMethodTable(), - "GetLicenseInteropHelperType", &gsig_SM_Void_RetIntPtr); - _ASSERTE(pGetLIHMD); - - TypeHandle lihTypeHnd; - - MethodDescCallSite getLIH(pGetLIHMD); - lihTypeHnd = (MethodTable*) getLIH.Call_RetLPVOID((ARG_SLOT*)NULL); - - BaseDomain::LockHolder lh(this); - - if(m_pLicenseInteropHelperMT == NULL) - m_pLicenseInteropHelperMT = lihTypeHnd.AsMethodTable(); - } - return m_pLicenseInteropHelperMT; -} -#endif // FEATURE_COMINTEROP - #endif // CROSSGEN_COMPILE //***************************************************************************** @@ -3489,7 +3448,6 @@ AppDomain::AppDomain() #ifdef FEATURE_COMINTEROP m_pRCWCache = NULL; m_pRCWRefCache = NULL; - m_pLicenseInteropHelperMT = NULL; memset(m_rpCLRTypes, 0, sizeof(m_rpCLRTypes)); #endif // FEATURE_COMINTEROP diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp index e6655246eb..7fdf912327 100644 --- a/src/vm/appdomain.hpp +++ b/src/vm/appdomain.hpp @@ -2448,8 +2448,6 @@ public: } RCWRefCache *GetRCWRefCache(); - - MethodTable* GetLicenseInteropHelperMethodTable(); #endif // FEATURE_COMINTEROP //**************************************************************************************** @@ -2995,9 +2993,6 @@ private: // this cache stores the RCW -> CCW references in this domain RCWRefCache *m_pRCWRefCache; - - // The method table used for LicenseInteropHelper - MethodTable* m_pLicenseInteropHelperMT; #endif // FEATURE_COMINTEROP // The index of this app domain among existing app domains (starting from 1) diff --git a/src/vm/metasig.h b/src/vm/metasig.h index 7700c0a5b4..5321fd3ee3 100644 --- a/src/vm/metasig.h +++ b/src/vm/metasig.h @@ -347,6 +347,8 @@ DEFINE_METASIG_T(SM(Str_PtrHStringHeader_RetIntPtr, s P(g(HSTRING_HEADER_MANAGED DEFINE_METASIG_T(SM(RefDateTimeOffset_RefDateTimeNative_RetVoid, r(g(DATE_TIME_OFFSET)) r(g(DATETIMENATIVE)), v)) +DEFINE_METASIG_T(IM(RuntimeTypeHandle_RefBool_RefIntPtr_RetVoid, g(RT_TYPE_HANDLE) r(F) r(I), v)) + #endif @@ -363,9 +365,6 @@ DEFINE_METASIG(SM(ArrByte_Bool_RetObj, a(b) F, j)) DEFINE_METASIG(SM(ArrByte_ArrByte_RefObj_RetObj, a(b) a(b) r(j), j)) DEFINE_METASIG_T(SM(PtrSByt_Int_Int_Encoding_RetStr, P(B) i i C(ENCODING), s)) -DEFINE_METASIG_T(SM(Void_RetRuntimeTypeHandle, _, g(RT_TYPE_HANDLE))) -DEFINE_METASIG(SM(Void_RetIntPtr, _, I)) - DEFINE_METASIG_T(SM(UInt_UInt_PtrNativeOverlapped_RetVoid, K K P(g(NATIVEOVERLAPPED)), v)) DEFINE_METASIG(IM(Long_RetVoid, l, v)) @@ -381,6 +380,7 @@ DEFINE_METASIG_T(IM(Str_ArrB_ArrB_Ver_CI_AHA_AVC_Str_ANF_SNKP_RetV, DEFINE_METASIG_T(IM(PEK_IFM_RetV, g(PORTABLE_EXECUTABLE_KINDS) g(IMAGE_FILE_MACHINE), v)) DEFINE_METASIG(IM(RetObj, _, j)) +DEFINE_METASIG(SM(RetObj, _, j)) DEFINE_METASIG_T(IM(RetIEnumerator, _, C(IENUMERATOR))) DEFINE_METASIG(IM(RetStr, _, s)) DEFINE_METASIG(IM(RetLong, _, l)) @@ -532,11 +532,6 @@ DEFINE_METASIG_T(IM(RuntimeType_RetVoid, C(CLASS) , v)) DEFINE_METASIG_T(SM(ArrException_PtrInt_RetVoid, a(C(EXCEPTION)) P(i), v)) DEFINE_METASIG_T(IM(RuntimeArgumentHandle_PtrVoid_RetVoid, g(ARGUMENT_HANDLE) P(v), v)) -DEFINE_METASIG_T(IM(LicenseInteropHelper_GetCurrentContextInfo, r(i) r(I) g(RT_TYPE_HANDLE), v)) -DEFINE_METASIG(IM(LicenseInteropHelper_SaveKeyInCurrentContext, I, v)) -DEFINE_METASIG_T(SM(LicenseInteropHelper_AllocateAndValidateLicense, g(RT_TYPE_HANDLE) I i, j)) -DEFINE_METASIG_T(SM(LicenseInteropHelper_RequestLicKey, g(RT_TYPE_HANDLE) r(I), i)) -DEFINE_METASIG_T(IM(LicenseInteropHelper_GetLicInfo, g(RT_TYPE_HANDLE) r(i) r(i), v)) DEFINE_METASIG_T(SM(Assembly_RetVoid, C(ASSEMBLY), v)) DEFINE_METASIG_T(SM(Assembly_Str_RetArrAssembly, C(ASSEMBLY) s, a(C(ASSEMBLY)))) diff --git a/src/vm/mscorlib.h b/src/vm/mscorlib.h index b78684da62..aea2197f9a 100644 --- a/src/vm/mscorlib.h +++ b/src/vm/mscorlib.h @@ -195,6 +195,11 @@ DEFINE_CLASS(COM_OBJECT, System, __ComObject) DEFINE_METHOD(COM_OBJECT, RELEASE_ALL_DATA, ReleaseAllData, IM_RetVoid) DEFINE_METHOD(COM_OBJECT, GET_EVENT_PROVIDER, GetEventProvider, IM_Class_RetObj) +DEFINE_CLASS(LICENSE_INTEROP_PROXY, InternalInteropServices, LicenseInteropProxy) +DEFINE_METHOD(LICENSE_INTEROP_PROXY, CREATE, Create, SM_RetObj) +DEFINE_METHOD(LICENSE_INTEROP_PROXY, GETCURRENTCONTEXTINFO, GetCurrentContextInfo, IM_RuntimeTypeHandle_RefBool_RefIntPtr_RetVoid) +DEFINE_METHOD(LICENSE_INTEROP_PROXY, SAVEKEYINCURRENTCONTEXT, SaveKeyInCurrentContext, IM_IntPtr_RetVoid) + DEFINE_CLASS(RUNTIME_CLASS, WinRT, RuntimeClass) #endif // FEATURE_COMINTEROP @@ -483,7 +488,6 @@ DEFINE_CLASS(LCID_CONVERSION_TYPE, Interop, LCIDConversionAttrib DEFINE_CLASS(MARSHAL, Interop, Marshal) #ifdef FEATURE_COMINTEROP -DEFINE_METHOD(MARSHAL, LOAD_LICENSE_MANAGER, LoadLicenseManager, SM_Void_RetIntPtr) DEFINE_METHOD(MARSHAL, INITIALIZE_WRAPPER_FOR_WINRT, InitializeWrapperForWinRT, SM_Obj_RefIntPtr_RetVoid) DEFINE_METHOD(MARSHAL, GET_HR_FOR_EXCEPTION, GetHRForException, SM_Exception_RetInt) DEFINE_METHOD(MARSHAL, GET_HR_FOR_EXCEPTION_WINRT, GetHRForException_WinRT, SM_Exception_RetInt) diff --git a/src/vm/namespace.h b/src/vm/namespace.h index 7275584c03..ce40247f43 100644 --- a/src/vm/namespace.h +++ b/src/vm/namespace.h @@ -28,6 +28,7 @@ #define g_CollectionsGenericNS g_SystemNS ".Collections.Generic" #define g_InteropServicesNS g_SystemNS ".Runtime.InteropServices" +#define g_InternalInteropServicesNS "Internal.Runtime.InteropServices" #define g_ReflectionNS g_SystemNS ".Reflection" #define g_ReflectionEmitNS g_ReflectionNS ".Emit" diff --git a/src/vm/runtimecallablewrapper.cpp b/src/vm/runtimecallablewrapper.cpp index 83f246e6ca..51c2ee016f 100644 --- a/src/vm/runtimecallablewrapper.cpp +++ b/src/vm/runtimecallablewrapper.cpp @@ -104,18 +104,16 @@ IUnknown *ComClassFactory::CreateInstanceFromClassFactory(IClassFactory *pClassF } CONTRACT_END; - HRESULT hr = S_OK; - SafeComHolder<IClassFactory2> pClassFact2 = NULL; - SafeComHolder<IUnknown> pUnk = NULL; - BSTRHolder bstrKey = NULL; - - Thread *pThread = GetThread(); + HRESULT hr = S_OK; + SafeComHolder<IClassFactory2> pClassFact2 = NULL; + SafeComHolder<IUnknown> pUnk = NULL; + BSTRHolder bstrKey = NULL; - // Does this support licensing? - if (FAILED(SafeQueryInterface(pClassFact, IID_IClassFactory2, (IUnknown**)&pClassFact2))) + // If the class doesn't support licensing or if it is missing a managed + // type to use for querying a license, just use IClassFactory. + if (FAILED(SafeQueryInterface(pClassFact, IID_IClassFactory2, (IUnknown**)&pClassFact2)) + || m_pClassMT == NULL) { - // not a licensed class - just createinstance the usual way. - // Create an instance of the object. FrameWithCookie<DebuggerExitFrame> __def; { GCX_PREEMP(); @@ -131,127 +129,109 @@ IUnknown *ComClassFactory::CreateInstanceFromClassFactory(IClassFactory *pClassF } else { - if (m_pClassMT == NULL) + _ASSERTE(m_pClassMT != NULL); + + // Get the type to query for licensing. + TypeHandle rth = TypeHandle(m_pClassMT); + + struct { - // Create an instance of the object. - FrameWithCookie<DebuggerExitFrame> __def; + OBJECTREF pProxy; + OBJECTREF pType; + } gc; + gc.pProxy = NULL; // LicenseInteropProxy + gc.pType = NULL; + + GCPROTECT_BEGIN(gc); + + // Create an instance of the object + MethodDescCallSite createObj(METHOD__LICENSE_INTEROP_PROXY__CREATE); + gc.pProxy = createObj.Call_RetOBJECTREF(NULL); + gc.pType = rth.GetManagedClassObject(); + + // Query the current licensing context + MethodDescCallSite getCurrentContextInfo(METHOD__LICENSE_INTEROP_PROXY__GETCURRENTCONTEXTINFO, &gc.pProxy); + CLR_BOOL fDesignTime = FALSE; + ARG_SLOT args[4]; + args[0] = ObjToArgSlot(gc.pProxy); + args[1] = ObjToArgSlot(gc.pType); + args[2] = (ARG_SLOT)&fDesignTime; + args[3] = (ARG_SLOT)(BSTR*)&bstrKey; + + getCurrentContextInfo.Call(args); + + if (fDesignTime) + { + // If designtime, we're supposed to obtain the runtime license key + // from the component and save it away in the license context. + // (the design tool can then grab it and embedded it into the + // app it is creating) + if (bstrKey != NULL) { - GCX_PREEMP(); - hr = pClassFact->CreateInstance(punkOuter, IID_IUnknown, (void **)&pUnk); - if (FAILED(hr) && punkOuter) - { - hr = pClassFact->CreateInstance(NULL, IID_IUnknown, (void**)&pUnk); - if (pfDidContainment) - *pfDidContainment = TRUE; - } + // It's illegal for our helper to return a non-null bstrKey + // when the context is design-time. But we'll try to do the + // right thing anyway. + _ASSERTE(!"We're not supposed to get here, but we'll try to cope anyway."); + SysFreeString(bstrKey); + bstrKey = NULL; } - __def.Pop(); - } - else - { - MethodTable *pHelperMT = pThread->GetDomain()->GetLicenseInteropHelperMethodTable(); - MethodDesc *pMD = MemberLoader::FindMethod(pHelperMT, "GetCurrentContextInfo", &gsig_IM_LicenseInteropHelper_GetCurrentContextInfo); - MethodDescCallSite getCurrentContextInfo(pMD); - - TypeHandle rth = TypeHandle(m_pClassMT); - - struct _gc { - OBJECTREF pHelper; - OBJECTREF pType; - } gc; - gc.pHelper = NULL; // LicenseInteropHelper - gc.pType = NULL; - - GCPROTECT_BEGIN(gc); - - gc.pHelper = pHelperMT->Allocate(); - gc.pType = rth.GetManagedClassObject(); - // First, crack open the current licensing context. - INT32 fDesignTime = 0; - ARG_SLOT args[4]; - args[0] = ObjToArgSlot(gc.pHelper); - args[1] = (ARG_SLOT)&fDesignTime; - args[2] = (ARG_SLOT)(BSTR*)&bstrKey; - args[3] = ObjToArgSlot(gc.pType); - - getCurrentContextInfo.Call(args); - - if (fDesignTime) { - // If designtime, we're supposed to obtain the runtime license key - // from the component and save it away in the license context - // (the design tool can then grab it and embedded it into the - // app it's creating.) - - if (bstrKey != NULL) - { - // It's illegal for our helper to return a non-null bstrKey - // when the context is design-time. But we'll try to do the - // right thing anyway. - _ASSERTE(!"We're not supposed to get here, but we'll try to cope anyway."); - SysFreeString(bstrKey); - bstrKey = NULL; - } + GCX_PREEMP(); + hr = pClassFact2->RequestLicKey(0, &bstrKey); + } - { - GCX_PREEMP(); - hr = pClassFact2->RequestLicKey(0, &bstrKey); - } - - // E_NOTIMPL is not a true failure. It simply indicates that - // the component doesn't support a runtime license key. - if (hr == E_NOTIMPL) - hr = S_OK; + // E_NOTIMPL is not a true failure. It simply indicates that + // the component doesn't support a runtime license key. + if (hr == E_NOTIMPL) + hr = S_OK; - if (SUCCEEDED(hr)) - { - MethodDesc *pMDSaveKey = MemberLoader::FindMethod(pHelperMT, "SaveKeyInCurrentContext", &gsig_IM_LicenseInteropHelper_SaveKeyInCurrentContext); - MethodDescCallSite saveKeyInCurrentContext(pMDSaveKey); + // Store the requested license key + if (SUCCEEDED(hr)) + { + MethodDescCallSite saveKeyInCurrentContext(METHOD__LICENSE_INTEROP_PROXY__SAVEKEYINCURRENTCONTEXT, &gc.pProxy); - args[0] = ObjToArgSlot(gc.pHelper); - args[1] = (ARG_SLOT)(BSTR)bstrKey; - saveKeyInCurrentContext.Call(args); - } + args[0] = ObjToArgSlot(gc.pProxy); + args[1] = (ARG_SLOT)(BSTR)bstrKey; + saveKeyInCurrentContext.Call(args); } - - if (SUCCEEDED(hr)) + } + + // Create the instance + if (SUCCEEDED(hr)) + { + FrameWithCookie<DebuggerExitFrame> __def; { - FrameWithCookie<DebuggerExitFrame> __def; + GCX_PREEMP(); + if (fDesignTime || bstrKey == NULL) { - GCX_PREEMP(); - - if (fDesignTime || bstrKey == NULL) + // Either it's design time, or the current context doesn't + // supply a runtime license key. + hr = pClassFact->CreateInstance(punkOuter, IID_IUnknown, (void **)&pUnk); + if (FAILED(hr) && punkOuter) { - // Either it's design time, or the current context doesn't - // supply a runtime license key. - hr = pClassFact->CreateInstance(punkOuter, IID_IUnknown, (void **)&pUnk); - if (FAILED(hr) && punkOuter) - { - hr = pClassFact->CreateInstance(NULL, IID_IUnknown, (void**)&pUnk); - if (pfDidContainment) - *pfDidContainment = TRUE; - } + hr = pClassFact->CreateInstance(NULL, IID_IUnknown, (void**)&pUnk); + if (pfDidContainment) + *pfDidContainment = TRUE; } - else + } + else + { + // It is runtime and we have a license key. + _ASSERTE(bstrKey != NULL); + hr = pClassFact2->CreateInstanceLic(punkOuter, NULL, IID_IUnknown, bstrKey, (void**)&pUnk); + if (FAILED(hr) && punkOuter) { - // It's runtime, and we do have a non-null license key. - _ASSERTE(bstrKey != NULL); - hr = pClassFact2->CreateInstanceLic(punkOuter, NULL, IID_IUnknown, bstrKey, (void**)&pUnk); - if (FAILED(hr) && punkOuter) - { - hr = pClassFact2->CreateInstanceLic(NULL, NULL, IID_IUnknown, bstrKey, (void**)&pUnk); - if (pfDidContainment) - *pfDidContainment = TRUE; - } - + hr = pClassFact2->CreateInstanceLic(NULL, NULL, IID_IUnknown, bstrKey, (void**)&pUnk); + if (pfDidContainment) + *pfDidContainment = TRUE; } } - __def.Pop(); } - - GCPROTECT_END(); + __def.Pop(); } + + GCPROTECT_END(); } if (FAILED(hr)) |