return (m_pBinder == NULL) ? E_FAIL : m_pBinder->BindAssemblyByName(pIAssemblyName, ppAssembly);
}
- HRESULT Assembly::FindAssemblyBySpec(
- LPVOID pvAppDomain,
- LPVOID pvAssemblySpec,
- HRESULT * pResult,
- ICLRPrivAssembly ** ppAssembly)
- {
- return (m_pBinder == NULL) ? E_FAIL : m_pBinder->FindAssemblyBySpec(pvAppDomain, pvAssemblySpec, pResult, ppAssembly);
- }
-
- HRESULT Assembly::VerifyBind (
- IAssemblyName * pIAssemblyName,
- ICLRPrivAssembly *pAssembly,
- ICLRPrivAssemblyInfo *pAssemblyInfo)
- {
- return (m_pBinder == NULL) ? E_FAIL : m_pBinder->VerifyBind(pIAssemblyName, pAssembly, pAssemblyInfo);
- }
-
HRESULT Assembly::GetBinderID(UINT_PTR *pBinderId)
{
return (m_pBinder == NULL) ? E_FAIL : m_pBinder->GetBinderID(pBinderId);
}
- HRESULT Assembly::GetBinderFlags(DWORD *pBinderFlags)
- {
- return (m_pBinder == NULL) ? E_FAIL : m_pBinder->GetBinderFlags(pBinderFlags);
- }
-
HRESULT Assembly::GetLoaderAllocator(LPVOID* pLoaderAllocator)
{
return (m_pBinder == NULL) ? E_FAIL : m_pBinder->GetLoaderAllocator(pLoaderAllocator);
return hr;
}
-HRESULT CLRPrivBinderAssemblyLoadContext::VerifyBind(IAssemblyName *AssemblyName,
- ICLRPrivAssembly *pAssembly,
- ICLRPrivAssemblyInfo *pAssemblyInfo)
-{
- return E_FAIL;
-}
-
-HRESULT CLRPrivBinderAssemblyLoadContext::GetBinderFlags(DWORD *pBinderFlags)
-{
- if (pBinderFlags == NULL)
- return E_INVALIDARG;
- *pBinderFlags = BINDER_NONE;
- return S_OK;
-}
-
HRESULT CLRPrivBinderAssemblyLoadContext::GetBinderID(
UINT_PTR *pBinderId)
{
return S_OK;
}
-HRESULT CLRPrivBinderAssemblyLoadContext::FindAssemblyBySpec(
- LPVOID pvAppDomain,
- LPVOID pvAssemblySpec,
- HRESULT *pResult,
- ICLRPrivAssembly **ppAssembly)
-{
- // We are not using a cache at this level
- // However, assemblies bound by the CoreCLR binder is already cached in the
- // AppDomain and will be resolved from there if required
- return E_FAIL;
-}
-
HRESULT CLRPrivBinderAssemblyLoadContext::GetLoaderAllocator(LPVOID* pLoaderAllocator)
{
_ASSERTE(pLoaderAllocator != NULL);
}
#endif // !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
-HRESULT CLRPrivBinderCoreCLR::VerifyBind(IAssemblyName *AssemblyName,
- ICLRPrivAssembly *pAssembly,
- ICLRPrivAssemblyInfo *pAssemblyInfo)
-{
- return E_FAIL;
-}
-
-HRESULT CLRPrivBinderCoreCLR::GetBinderFlags(DWORD *pBinderFlags)
-{
- if (pBinderFlags == NULL)
- return E_INVALIDARG;
- *pBinderFlags = BINDER_NONE;
- return S_OK;
-}
-
HRESULT CLRPrivBinderCoreCLR::GetBinderID(
UINT_PTR *pBinderId)
{
return S_OK;
}
-HRESULT CLRPrivBinderCoreCLR::FindAssemblyBySpec(
- LPVOID pvAppDomain,
- LPVOID pvAssemblySpec,
- HRESULT *pResult,
- ICLRPrivAssembly **ppAssembly)
-{
- // We are not using a cache at this level
- // However, assemblies bound by the CoreCLR binder is already cached in the
- // AppDomain and will be resolved from there if required
- return E_FAIL;
-}
-
HRESULT CLRPrivBinderCoreCLR::SetupBindingPaths(SString &sTrustedPlatformAssemblies,
SString &sPlatformResourceRoots,
SString &sAppPaths,
DWORD *pdwImageType,
ICLRPrivResource ** ppIResource);
- STDMETHOD(VerifyBind)(
- IAssemblyName * pIAssemblyName,
- ICLRPrivAssembly *pAssembly,
- ICLRPrivAssemblyInfo *pAssemblyInfo);
-
STDMETHOD(GetBinderID)(UINT_PTR *pBinderId);
- STDMETHOD(FindAssemblyBySpec)(
- LPVOID pvAppDomain,
- LPVOID pvAssemblySpec,
- HRESULT * pResult,
- ICLRPrivAssembly ** ppAssembly);
-
- STDMETHOD(GetBinderFlags)(DWORD *pBinderFlags);
-
STDMETHOD(GetLoaderAllocator)(LPVOID* pLoaderAllocator);
// --------------------------------------------------------------------
/* [in] */ IAssemblyName *pIAssemblyName,
/* [retval][out] */ ICLRPrivAssembly **ppAssembly);
- STDMETHOD(VerifyBind)(
- /* [in] */ IAssemblyName *pIAssemblyName,
- /* [in] */ ICLRPrivAssembly *pAssembly,
- /* [in] */ ICLRPrivAssemblyInfo *pAssemblyInfo);
-
- STDMETHOD(GetBinderFlags)(
- /* [retval][out] */ DWORD *pBinderFlags);
-
STDMETHOD(GetBinderID)(
/* [retval][out] */ UINT_PTR *pBinderId);
- STDMETHOD(FindAssemblyBySpec)(
- /* [in] */ LPVOID pvAppDomain,
- /* [in] */ LPVOID pvAssemblySpec,
- /* [out] */ HRESULT *pResult,
- /* [out] */ ICLRPrivAssembly **ppAssembly);
-
STDMETHOD(GetLoaderAllocator)(
/* [retval][out] */ LPVOID *pLoaderAllocator);
/* [in] */ IAssemblyName *pIAssemblyName,
/* [retval][out] */ ICLRPrivAssembly **ppAssembly);
- STDMETHOD(VerifyBind)(
- /* [in] */ IAssemblyName *pIAssemblyName,
- /* [in] */ ICLRPrivAssembly *pAssembly,
- /* [in] */ ICLRPrivAssemblyInfo *pAssemblyInfo);
-
- STDMETHOD(GetBinderFlags)(
- /* [retval][out] */ DWORD *pBinderFlags);
-
STDMETHOD(GetBinderID)(
/* [retval][out] */ UINT_PTR *pBinderId);
- STDMETHOD(FindAssemblyBySpec)(
- /* [in] */ LPVOID pvAppDomain,
- /* [in] */ LPVOID pvAssemblySpec,
- /* [out] */ HRESULT *pResult,
- /* [out] */ ICLRPrivAssembly **ppAssembly);
-
STDMETHOD(GetLoaderAllocator)(
/* [retval][out] */ LPVOID *pLoaderAllocator);
//-----------------------------------------------------------------------------------------------------------------
// Forwards to wrapped binder.
- STDMETHOD(VerifyBind)(
- IAssemblyName *pAssemblyName,
- ICLRPrivAssembly *pAssembly,
- ICLRPrivAssemblyInfo *pAssemblyInfo)
- {
- WRAPPER_NO_CONTRACT;
- return _pWrapped->VerifyBind(pAssemblyName, pAssembly, pAssemblyInfo);
- }
-
- //---------------------------------------------------------------------------------------------
- // Forwards to wrapped binder.
- STDMETHOD(GetBinderFlags)(
- DWORD *pBinderFlags)
- {
- WRAPPER_NO_CONTRACT;
- return _pWrapped->GetBinderFlags(pBinderFlags);
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // Forwards to wrapped binder.
STDMETHOD(GetBinderID)(
UINT_PTR *pBinderId)
{
//-----------------------------------------------------------------------------------------------------------------
// Forwards to wrapped binder.
- STDMETHOD(FindAssemblyBySpec)(
- LPVOID pvAppDomain,
- LPVOID pvAssemblySpec,
- HRESULT * pResult,
- ICLRPrivAssembly ** ppAssembly)
- { STATIC_CONTRACT_WRAPPER; return _pWrapped->FindAssemblyBySpec(pvAppDomain, pvAssemblySpec, pResult, ppAssembly); }
-
- //-----------------------------------------------------------------------------------------------------------------
- // Forwards to wrapped binder.
STDMETHOD(GetLoaderAllocator)(
LPVOID * pLoaderAllocator)
{
CLRPrivBinderUtil::PublicKeyToken KeyToken;
};
- //=================================================================================================================
- HRESULT VerifyBind(
- IAssemblyName *pRefAssemblyName,
- ICLRPrivAssemblyInfo *pDefAssemblyInfo);
-
- //=================================================================================================================
- HRESULT VerifyBind(
- CLRPrivBinderUtil::AssemblyIdentity const & refIdentity,
- CLRPrivBinderUtil::AssemblyIdentity const & defIdentity);
-
//=================================================================================================
template <typename ItfT>
struct CLRPrivResourceBase :
[out, retval] ICLRPrivAssembly ** ppAssembly);
/**********************************************************************************
- ** VerifyBind
- **********************************************************************************/
- HRESULT VerifyBind(
- [in] IAssemblyName * AssemblyName,
- [in] ICLRPrivAssembly * pAssembly,
- [in] ICLRPrivAssemblyInfo * pAssemblyInfo);
-
- /**********************************************************************************
- ** GetBinderFlags
- ** pBinderFlags, pointer to binder flags.
- **********************************************************************************/
- HRESULT GetBinderFlags(
- [out, retval] DWORD *pBinderFlags);
-
- /**********************************************************************************
** GetBinderID
** pBinderId, pointer to binder id. The binder id has the following properties
** It is a pointer that does not change over the lifetime of a binder object
[out, retval] UINT_PTR *pBinderId);
/**********************************************************************************
- ** FindAssemblyBySpec -- if it has been previously bound, guarantees that the same
- ** result will be returned; if previous result was successful, the bound
- ** ICLRPrivAssembly will be returned, and if previous result was not successful
- ** the same failure HRESULT will be assigned to *pResult. Returns failure HR if
- ** identity has not been requested previously.
- **
- ** pvAssemblySpec - the AssemblySpec identity to bind.
- ** pResult - the result of the previous bind request.
- ** ppAssembly - when successful, contains the corresponding assembly object.
- **********************************************************************************/
- HRESULT FindAssemblyBySpec(
- [in] LPVOID pvAppDomain,
- [in] LPVOID pvAssemblySpec,
- [out] HRESULT * pResult,
- [out] ICLRPrivAssembly ** ppAssembly);
-
- /**********************************************************************************
** GetLoaderAllocator
** Get LoaderAllocator for binders that contain it. For other binders, return
** E_FAIL
[out, retval] LPVOID * pLoaderAllocator);
};
-enum CLR_PRIV_BINDER_FLAGS
-{
- BINDER_NONE = 0x0,
- BINDER_DESIGNER_BINDING_CONTEXT = 0x1,
- BINDER_FINDASSEMBLYBYSPEC_REQUIRES_EXACT_MATCH = 0x2,
-};
-
/**************************************************************************************
** ASSEMBLY_IMAGE_TYPES - The set of assembly image formats.
**************************************************************************************/
/* [in] */ IAssemblyName *pAssemblyName,
/* [retval][out] */ ICLRPrivAssembly **ppAssembly) = 0;
- virtual HRESULT STDMETHODCALLTYPE VerifyBind(
- /* [in] */ IAssemblyName *AssemblyName,
- /* [in] */ ICLRPrivAssembly *pAssembly,
- /* [in] */ ICLRPrivAssemblyInfo *pAssemblyInfo) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBinderFlags(
- /* [retval][out] */ DWORD *pBinderFlags) = 0;
-
virtual HRESULT STDMETHODCALLTYPE GetBinderID(
/* [retval][out] */ UINT_PTR *pBinderId) = 0;
- virtual HRESULT STDMETHODCALLTYPE FindAssemblyBySpec(
- /* [in] */ LPVOID pvAppDomain,
- /* [in] */ LPVOID pvAssemblySpec,
- /* [out] */ HRESULT *pResult,
- /* [out] */ ICLRPrivAssembly **ppAssembly) = 0;
-
virtual HRESULT STDMETHODCALLTYPE GetLoaderAllocator(
/* [retval][out] */ LPVOID* pLoaderAllocator) = 0;
};
/* [in] */ IAssemblyName *pAssemblyName,
/* [retval][out] */ ICLRPrivAssembly **ppAssembly);
- HRESULT ( STDMETHODCALLTYPE *VerifyBind )(
- ICLRPrivBinder * This,
- /* [in] */ IAssemblyName *AssemblyName,
- /* [in] */ ICLRPrivAssembly *pAssembly,
- /* [in] */ ICLRPrivAssemblyInfo *pAssemblyInfo);
-
- HRESULT ( STDMETHODCALLTYPE *GetBinderFlags )(
- ICLRPrivBinder * This,
- /* [retval][out] */ DWORD *pBinderFlags);
-
HRESULT ( STDMETHODCALLTYPE *GetBinderID )(
ICLRPrivBinder * This,
/* [retval][out] */ UINT_PTR *pBinderId);
- HRESULT ( STDMETHODCALLTYPE *FindAssemblyBySpec )(
- ICLRPrivBinder * This,
- /* [in] */ LPVOID pvAppDomain,
- /* [in] */ LPVOID pvAssemblySpec,
- /* [out] */ HRESULT *pResult,
- /* [out] */ ICLRPrivAssembly **ppAssembly);
-
HRESULT(STDMETHODCALLTYPE *GetLoaderAllocator)(
ICLRPrivBinder * This,
/* [retval][out] */ LPVOID *pLoaderAllocator) = 0;
#define ICLRPrivBinder_BindAssemblyByName(This,pAssemblyName,ppAssembly) \
( (This)->lpVtbl -> BindAssemblyByName(This,pAssemblyName,ppAssembly) )
-#define ICLRPrivBinder_VerifyBind(This,AssemblyName,pAssembly,pAssemblyInfo) \
- ( (This)->lpVtbl -> VerifyBind(This,AssemblyName,pAssembly,pAssemblyInfo) )
-
-#define ICLRPrivBinder_GetBinderFlags(This,pBinderFlags) \
- ( (This)->lpVtbl -> GetBinderFlags(This,pBinderFlags) )
-
#define ICLRPrivBinder_GetBinderID(This,pBinderId) \
( (This)->lpVtbl -> GetBinderID(This,pBinderId) )
-#define ICLRPrivBinder_FindAssemblyBySpec(This,pvAppDomain,pvAssemblySpec,pResult,ppAssembly) \
- ( (This)->lpVtbl -> FindAssemblyBySpec(This,pvAppDomain,pvAssemblySpec,pResult,ppAssembly) )
-
#endif /* COBJMACROS */
/* [local] */
-enum CLR_PRIV_BINDER_FLAGS
- {
- BINDER_NONE = 0,
- BINDER_DESIGNER_BINDING_CONTEXT = 0x1,
- BINDER_FINDASSEMBLYBYSPEC_REQUIRES_EXACT_MATCH = 0x2
- } ;
-
enum ASSEMBLY_IMAGE_TYPES
{
ASSEMBLY_IMAGE_TYPE_IL = 0x1,
/* [in] */ IAssemblyName *pAssemblyName,
/* [retval][out] */ ICLRPrivAssembly **ppAssembly);
- HRESULT ( STDMETHODCALLTYPE *VerifyBind )(
- ICLRPrivAssembly * This,
- /* [in] */ IAssemblyName *AssemblyName,
- /* [in] */ ICLRPrivAssembly *pAssembly,
- /* [in] */ ICLRPrivAssemblyInfo *pAssemblyInfo);
-
- HRESULT ( STDMETHODCALLTYPE *GetBinderFlags )(
- ICLRPrivAssembly * This,
- /* [retval][out] */ DWORD *pBinderFlags);
-
HRESULT ( STDMETHODCALLTYPE *GetBinderID )(
ICLRPrivAssembly * This,
/* [retval][out] */ UINT_PTR *pBinderId);
- HRESULT ( STDMETHODCALLTYPE *FindAssemblyBySpec )(
- ICLRPrivAssembly * This,
- /* [in] */ LPVOID pvAppDomain,
- /* [in] */ LPVOID pvAssemblySpec,
- /* [out] */ HRESULT *pResult,
- /* [out] */ ICLRPrivAssembly **ppAssembly);
-
HRESULT ( STDMETHODCALLTYPE *IsShareable )(
ICLRPrivAssembly * This,
/* [retval][out] */ BOOL *pbIsShareable);
#define ICLRPrivAssembly_BindAssemblyByName(This,pAssemblyName,ppAssembly) \
( (This)->lpVtbl -> BindAssemblyByName(This,pAssemblyName,ppAssembly) )
-#define ICLRPrivAssembly_VerifyBind(This,AssemblyName,pAssembly,pAssemblyInfo) \
- ( (This)->lpVtbl -> VerifyBind(This,AssemblyName,pAssembly,pAssemblyInfo) )
-
-#define ICLRPrivAssembly_GetBinderFlags(This,pBinderFlags) \
- ( (This)->lpVtbl -> GetBinderFlags(This,pBinderFlags) )
-
#define ICLRPrivAssembly_GetBinderID(This,pBinderId) \
( (This)->lpVtbl -> GetBinderID(This,pBinderId) )
-#define ICLRPrivAssembly_FindAssemblyBySpec(This,pvAppDomain,pvAssemblySpec,pResult,ppAssembly) \
- ( (This)->lpVtbl -> FindAssemblyBySpec(This,pvAppDomain,pvAssemblySpec,pResult,ppAssembly) )
-
#define ICLRPrivAssembly_IsShareable(This,pbIsShareable) \
( (This)->lpVtbl -> IsShareable(This,pbIsShareable) )
};
//-----------------------------------------------------------------------------------------------------------------
-static HRESULT VerifyBindHelper(
- ICLRPrivAssembly *pPrivAssembly,
- IAssemblyName *pAssemblyName,
- PEAssembly *pPEAssembly)
-{
- STATIC_CONTRACT_THROWS;
- STATIC_CONTRACT_GC_TRIGGERS;
-
- HRESULT hr = S_OK;
- // Create an ICLRPrivAssemblyInfo to call to ICLRPrivAssembly::VerifyBind
- NewHolder<PEAssemblyAsPrivAssemblyInfo> pPrivAssemblyInfoImpl = new PEAssemblyAsPrivAssemblyInfo(pPEAssembly);
- ReleaseHolder<ICLRPrivAssemblyInfo> pPrivAssemblyInfo;
- IfFailRet(pPrivAssemblyInfoImpl->QueryInterface(__uuidof(ICLRPrivAssemblyInfo), (LPVOID *)&pPrivAssemblyInfo));
- pPrivAssemblyInfoImpl.SuppressRelease();
-
- // Call VerifyBind to give the host a chance to reject the bind based on assembly image contents.
- IfFailRet(pPrivAssembly->VerifyBind(pAssemblyName, pPrivAssembly, pPrivAssemblyInfo));
-
- return hr;
-}
-
-//-----------------------------------------------------------------------------------------------------------------
HRESULT AppDomain::BindAssemblySpecForHostedBinder(
AssemblySpec * pSpec,
IAssemblyName * pAssemblyName,
}
if (*ppAssembly != nullptr)
- { // Already exists: ask the binder to verify and return the assembly.
- return VerifyBindHelper(pPrivAssembly, pAssemblyName, *ppAssembly);
+ { // Already exists: return the assembly.
+ return S_OK;
}
// Get the IL PEFile.
// Create a PEAssembly using the IL and NI images.
PEAssemblyHolder pPEAssembly = PEAssembly::Open(pParentAssembly, pPEImageIL, pPEImageNI, pPrivAssembly);
-
- // Ask the binder to verify.
- IfFailRet(VerifyBindHelper(pPrivAssembly, pAssemblyName, pPEAssembly));
-
// The result.
*ppAssembly = pPEAssembly.Extract();
pBinder = GetBindingContextFromParentAssembly(pDomain);
}
-
- if (pBinder != nullptr)
- {
- ReleaseHolder<ICLRPrivAssembly> pPrivAssembly;
- HRESULT hrCachedResult;
- if (SUCCEEDED(pBinder->FindAssemblyBySpec(GetAppDomain(), this, &hrCachedResult, &pPrivAssembly)) &&
- SUCCEEDED(hrCachedResult))
- {
- pAssembly = pDomain->FindAssembly(pPrivAssembly);
- }
- }
-
if ((pAssembly == nullptr) && CanUseWithBindingCache())
{
pAssembly = pDomain->FindCachedAssembly(this);
}
else
{
- DWORD binderFlags = 0;
- ICLRPrivAssembly * pPrivBinder = pAssemblyCandidate->GetManifestFile()->GetHostAssembly();
- HRESULT hrBinderFlagCheck = pPrivBinder->GetBinderFlags(&binderFlags);
- if (SUCCEEDED(hrBinderFlagCheck) && (binderFlags & BINDER_FINDASSEMBLYBYSPEC_REQUIRES_EXACT_MATCH))
- {
- pAssembly = pAssemblyCandidate;
- }
- else
- {
- // This should only happen in the generic instantiation case when multiple threads are racing and
- // the assembly found is one which we will determine is the wrong assembly.
- //
- // We can't assert that (as its possible under stress); however it shouldn't happen in the stack walk or GC case, so we assert in those cases.
- _ASSERTE("Non-AssemblySpecBindingCache based assembly found with extended search" && !(IsStackWalkerThread() || IsGCThread()) && IsGenericInstantiationLookupCompareThread());
- }
+ // This should only happen in the generic instantiation case when multiple threads are racing and
+ // the assembly found is one which we will determine is the wrong assembly.
+ //
+ // We can't assert that (as its possible under stress); however it shouldn't happen in the stack walk or GC case, so we assert in those cases.
+ _ASSERTE("Non-AssemblySpecBindingCache based assembly found with extended search" && !(IsStackWalkerThread() || IsGCThread()) && IsGenericInstantiationLookupCompareThread());
}
}
}
BOOL eligibleForAdditionalChecks = TRUE;
if (szWinRtNamespace != NULL)
eligibleForAdditionalChecks = FALSE; // WinRT binds do not support this scan
- else if (this->GetAssembly()->GetManifestFile()->IsDesignerBindingContext())
- {
- eligibleForAdditionalChecks = FALSE;
- // assemblies loaded into leaf designer binding contexts cannot be ngen images, or be depended on by ngen assemblies that bind to different versions of assemblies.
- // However, in the shared designer binding context assemblies can be loaded with ngen images, and therefore can depend on assemblies in a designer binding context. (the shared context)
- // A more correct version of this check would probably allow assemblies loaded into the shared designer binding context to be eligibleForAdditionalChecks; however
- // there are problems. In particular, the logic below which scans through all native images is not strictly correct for scenarios involving a shared assembly context
- // as the shared assembly context may have different binding rules as compared to the root context. At this time, we prefer to not fix this scenario until
- // there is customer need for a fix.
- }
AssemblySpec specSearchAssemblyRef;
namespace CLRPrivBinderUtil
{
-
- //-----------------------------------------------------------------------------------------------------------------
- HRESULT VerifyBind(
- IAssemblyName *pRefAssemblyName,
- ICLRPrivAssemblyInfo *pDefAssemblyInfo)
- {
- STANDARD_BIND_CONTRACT;
-
- HRESULT hr = S_OK;
- VALIDATE_PTR_RET(pRefAssemblyName);
- VALIDATE_PTR_RET(pDefAssemblyInfo);
-
- AssemblyIdentity refIdentity;
- IfFailRet(refIdentity.Initialize(pRefAssemblyName));
-
- AssemblyIdentity defIdentity;
- IfFailRet(defIdentity.Initialize(pDefAssemblyInfo));
-
- return VerifyBind(refIdentity, defIdentity);
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- HRESULT VerifyBind(
- CLRPrivBinderUtil::AssemblyIdentity const & refIdentity,
- CLRPrivBinderUtil::AssemblyIdentity const & defIdentity)
- {
- LIMITED_METHOD_CONTRACT;
-
- //
- // Compare versions. Success conditions are the same as those in Silverlight:
- // 1. Reference identity has no version.
- // 2. Both identities have versions, and ref.version <= def.version.
- //
- // Since the default value of AssemblyVersion is 0.0.0.0, then if the
- // ref has no value set then the comparison will use 0.0.0.0, which will
- // always compare as true to the version contained in the def.
- //
-
- if (defIdentity.Version < refIdentity.Version)
- { // Bound assembly has a lower version number than the reference.
- return CLR_E_BIND_ASSEMBLY_VERSION_TOO_LOW;
- }
-
- //
- // Compare public key tokens. Success conditions are:
- // 1. Reference identity has no PKT.
- // 2. Both identities have identical PKT values.
- //
-
- if (refIdentity.KeyToken.GetSize() != 0 && // Ref without PKT always passes.
- refIdentity.KeyToken != defIdentity.KeyToken) // Otherwise Def must have matching PKT.
- {
- return CLR_E_BIND_ASSEMBLY_PUBLIC_KEY_MISMATCH;
- }
-
- return S_OK;
- }
-
//---------------------------------------------------------------------------------------------
CLRPrivResourcePathImpl::CLRPrivResourcePathImpl(LPCWSTR wzPath)
: m_wzPath(CopyStringThrowing(wzPath))
}
//=====================================================================================================================
-// Implements interface method code:ICLRPrivBinder::VerifyBind.
-//
-HRESULT CLRPrivBinderWinRT::VerifyBind(
- IAssemblyName * pAssemblyName,
- ICLRPrivAssembly * pAssembly,
- ICLRPrivAssemblyInfo * pAssemblyInfo)
-{
- STANDARD_BIND_CONTRACT;
- HRESULT hr = S_OK;
-
- VALIDATE_ARG_RET(pAssemblyInfo != nullptr);
-
- UINT_PTR binderID;
- IfFailRet(pAssembly->GetBinderID(&binderID));
- if (binderID != reinterpret_cast<UINT_PTR>(this))
- {
- return pAssembly->VerifyBind(pAssemblyName, pAssembly, pAssemblyInfo);
- }
-
- // Since WinRT types are bound by type name and not assembly name, assembly-level version validation
- // does not make sense here. Just return S_OK.
- return S_OK;
-}
-
-//=====================================================================================================================
// Implements interface method code:ICLRPrivBinder::GetBinderID.
//
HRESULT CLRPrivBinderWinRT::GetBinderID(
return S_OK;
}
-//=====================================================================================================================
-HRESULT CLRPrivBinderWinRT::FindWinRTAssemblyBySpec(
- LPVOID pvAppDomain,
- LPVOID pvAssemblySpec,
- HRESULT * pResult,
- ICLRPrivAssembly ** ppAssembly)
-{
- STATIC_CONTRACT_WRAPPER;
- return E_FAIL;
-}
-
//=====================================================================================================================
HRESULT CLRPrivAssemblyWinRT::GetIBindResult(
IAssemblyName * pAssemblyName,
ICLRPrivAssembly ** ppAssembly);
- // Implements interface method code:ICLRPrivBinder::VerifyBind.
- STDMETHOD(VerifyBind)(
- IAssemblyName * pAssemblyName,
- ICLRPrivAssembly * pAssembly,
- ICLRPrivAssemblyInfo * pAssemblyInfo);
-
- // Implements interface method code:ICLRPrivBinder::GetBinderFlags
- STDMETHOD(GetBinderFlags)(
- DWORD *pBinderFlags)
- {
- STATIC_CONTRACT_WRAPPER;
-
- if (pBinderFlags == NULL)
- return E_INVALIDARG;
-
- HRESULT hr = S_OK;
-
- if (m_pParentBinder != NULL)
- hr = m_pParentBinder->GetBinderFlags(pBinderFlags);
- else
- *pBinderFlags = BINDER_NONE;
-
- return hr;
- }
-
// Implements interface method code:ICLRPrivBinder::GetBinderID.
STDMETHOD(GetBinderID)(
UINT_PTR * pBinderId);
- STDMETHOD(FindAssemblyBySpec)(
- LPVOID pvAppDomain,
- LPVOID pvAssemblySpec,
- HRESULT * pResult,
- ICLRPrivAssembly ** ppAssembly)
- {
- LIMITED_METHOD_CONTRACT;
-
-#ifndef DACCESS_COMPILE
- // CLRPrivBinderWinRT instances only have parent binders in Metro processes (not in classic).
- _ASSERTE((AppX::IsAppXProcess()) == (m_pParentBinder != nullptr));
-#endif
-
- if (m_pParentBinder != NULL)
- {
- return m_pParentBinder->FindAssemblyBySpec(pvAppDomain, pvAssemblySpec, pResult, ppAssembly);
- }
- else
- {
- // Note: should never get here if caller is Module::GetAssemblyIfLoaded, but can
- // be called from AssemblySpec::LoadDomainAssembly..
- return FindWinRTAssemblyBySpec(pvAppDomain, pvAssemblySpec, pResult, ppAssembly);
- }
- }
-
STDMETHOD(GetLoaderAllocator)(
LPVOID * pLoaderAllocator)
{
return E_FAIL;
}
- HRESULT FindWinRTAssemblyBySpec(
- LPVOID pvAppDomain,
- LPVOID pvAssemblySpec,
- HRESULT * pResult,
- ICLRPrivAssembly ** ppAssembly);
-
//=============================================================================================
// Class methods
return m_pBinder->BindAssemblyByName(pAssemblyName, ppAssembly);
}
- // Implements interface method code:ICLRPrivBinder::VerifyBind.
- STDMETHOD(VerifyBind)(
- IAssemblyName * pAssemblyName,
- ICLRPrivAssembly * pAssembly,
- ICLRPrivAssemblyInfo * pAssemblyInfo)
- {
- STATIC_CONTRACT_WRAPPER;
- return m_pBinder->VerifyBind(pAssemblyName, pAssembly, pAssemblyInfo);
- }
-
- // Implements interface method code:ICLRPrivBinder::GetBinderFlags
- STDMETHOD(GetBinderFlags)(
- DWORD *pBinderFlags)
- {
- STATIC_CONTRACT_WRAPPER;
- return m_pBinder->GetBinderFlags(pBinderFlags);
- }
-
// Implements interface method code:ICLRPrivBinder::GetBinderID.
STDMETHOD(GetBinderID)(
UINT_PTR * pBinderId)
return m_pBinder->GetBinderID(pBinderId);
}
- // Implements code:ICLRPrivBinder::FindAssemblyBySpec
- STDMETHOD(FindAssemblyBySpec)(
- LPVOID pvAppDomain,
- LPVOID pvAssemblySpec,
- HRESULT * pResult,
- ICLRPrivAssembly ** ppAssembly)
- {
- STATIC_CONTRACT_WRAPPER;
- return m_pBinder->FindAssemblyBySpec(pvAppDomain, pvAssemblySpec, pResult, ppAssembly);
- }
-
STDMETHOD(GetLoaderAllocator)(
LPVOID * pLoaderAllocator)
{
return HasOpenedILimage() && GetOpenedILimage()->HasLoadedLayout();
}
- BOOL IsDesignerBindingContext()
- {
- LIMITED_METHOD_CONTRACT;
-
- DWORD binderFlags = BINDER_NONE;
-
- HRESULT hr = E_FAIL;
- if (HasHostAssembly())
- hr = GetHostAssembly()->GetBinderFlags(&binderFlags);
-
- return hr == S_OK ? binderFlags & BINDER_DESIGNER_BINDING_CONTEXT : FALSE;
- }
-
LPCWSTR GetPathForErrorMessages();
static PEFile* Dummy();