summaryrefslogtreecommitdiff
path: root/src/vm/clrprivbinderwinrt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vm/clrprivbinderwinrt.cpp')
-rw-r--r--src/vm/clrprivbinderwinrt.cpp477
1 files changed, 0 insertions, 477 deletions
diff --git a/src/vm/clrprivbinderwinrt.cpp b/src/vm/clrprivbinderwinrt.cpp
index b4fb45c083..f73d01a46d 100644
--- a/src/vm/clrprivbinderwinrt.cpp
+++ b/src/vm/clrprivbinderwinrt.cpp
@@ -11,9 +11,6 @@
#include "common.h" // precompiled header
-#ifndef FEATURE_CORECLR
-#include "assemblyusagelogmanager.h"
-#endif
#include "clr/fs/file.h"
#include "clrprivbinderwinrt.h"
#include "clrprivbinderutil.h"
@@ -22,25 +19,17 @@
//=====================================================================================================================
#include "sstring.h"
-#ifdef FEATURE_FUSION
-#include "fusionlogging.h"
-#include "policy.h"
-#include "imprthelpers.h" // in fusion/inc
-#include "asmimprt.h"
-#endif
#ifdef FEATURE_APPX
#include "appxutil.h"
#endif
#include <TypeResolution.h>
#include "delayloadhelpers.h"
-#ifdef FEATURE_CORECLR
#include "../binder/inc/applicationcontext.hpp"
#include "../binder/inc/assemblybinder.hpp"
#include "../binder/inc/assembly.hpp"
#include "../binder/inc/debuglog.hpp"
#include "../binder/inc/utils.hpp"
#include "../binder/inc/fusionassemblyname.hpp"
-#endif
#ifdef CROSSGEN_COMPILE
#include "crossgenroresolvenamespace.h"
@@ -134,17 +123,9 @@ CLRPrivBinderWinRT::CLRPrivBinderWinRT(
BOOL fCanUseNativeImages)
: m_pTypeCache(clr::SafeAddRef(pWinRtTypeCache))
, m_pParentBinder(pParentBinder) // Do not addref, lifetime directly tied to parent.
-#ifdef FEATURE_FUSION
- , m_fCanUseNativeImages(fCanUseNativeImages)
-#endif
, m_fNamespaceResolutionKind(fNamespaceResolutionKind)
-#ifdef FEATURE_CORECLR
, m_pApplicationContext(nullptr)
, m_appLocalWinMDPath(nullptr)
-#endif
-#ifdef FEATURE_COMINTEROP_WINRT_DESKTOP_HOST
- , m_fCanSetLocalWinMDPath(TRUE)
-#endif // FEATURE_COMINTEROP_WINRT_DESKTOP_HOST
{
STANDARD_VM_CONTRACT;
PRECONDITION(CheckPointer(pWinRtTypeCache));
@@ -160,9 +141,6 @@ CLRPrivBinderWinRT::CLRPrivBinderWinRT(
INDEBUG(| CRST_DEBUG_ONLY_CHECK_FORBID_SUSPEND_THREAD)));
m_MapsAddLock.Init(CrstCLRPrivBinderMapsAdd);
-#ifdef FEATURE_COMINTEROP_WINRT_DESKTOP_HOST
- m_localWinMDPathLock.Init(CrstCrstCLRPrivBinderLocalWinMDPath);
-#endif // FEATURE_COMINTEROP_WINRT_DESKTOP_HOST
// Copy altpaths
if (cAltPaths > 0)
@@ -177,39 +155,8 @@ CLRPrivBinderWinRT::CLRPrivBinderWinRT(
m_rgAltPaths.GetRawArray() + iAltPath));
}
}
-#if defined(FEATURE_APPX) && !defined(FEATURE_CORECLR)
- else if (AppX::IsAppXNGen())
- {
- // If this is an NGen worker process for AppX, then the process doesn't actually run in the package,
- // and RoResolveNamespace won't work without some help. AppX::GetCurrentPackageInfo can give us the
- // package graph, which we can pass to RoResolveNamespace to make it work properly.
- UINT32 cbBuffer = 0;
- UINT32 nCount = 0;
- HRESULT hr = AppX::GetCurrentPackageInfo(PACKAGE_FILTER_CLR_DEFAULT, &cbBuffer, nullptr, nullptr);
- if (hr != HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER))
- ThrowHR(hr);
-
- NewArrayHolder<BYTE> pbBuffer(new (nothrow) BYTE[cbBuffer]);
- IfNullThrow(pbBuffer);
- IfFailThrow(AppX::GetCurrentPackageInfo(PACKAGE_FILTER_CLR_DEFAULT, &cbBuffer, pbBuffer, &nCount));
-
- m_rgAltPaths.Allocate(nCount);
-
- PCPACKAGE_INFO pPackageInfo = reinterpret_cast<PCPACKAGE_INFO>(static_cast<PBYTE>(pbBuffer));
- for (UINT32 iAltPath = 0; iAltPath < nCount; iAltPath++)
- {
- IfFailThrow(WindowsCreateString(
- pPackageInfo[iAltPath].path,
- (UINT32)wcslen(pPackageInfo[iAltPath].path),
- m_rgAltPaths.GetRawArray() + iAltPath));
- }
- }
-#endif //FEATURE_APPX && !FEATURE_CORECLR
#endif //CROSSGEN_COMPILE
-#ifdef FEATURE_FUSION
- IfFailThrow(RuntimeCreateCachingILFingerprintFactory(&m_pFingerprintFactory));
-#endif
}
//=====================================================================================================================
@@ -217,9 +164,6 @@ CLRPrivBinderWinRT::~CLRPrivBinderWinRT()
{
WRAPPER_NO_CONTRACT;
-#if !defined(FEATURE_CORECLR) && !defined(CROSSGEN_COMPILE)
- AssemblyUsageLogManager::UnRegisterBinderFromUsageLog((UINT_PTR)this);
-#endif
if (m_pTypeCache != nullptr)
{
m_pTypeCache->Release();
@@ -235,11 +179,6 @@ CLRPrivBinderWinRT::GetOrCreateBinder(
STANDARD_VM_CONTRACT;
HRESULT hr = S_OK;
- // This should be allocated directly by CLRPrivBinderAppX in the AppX scenario.
-#ifdef FEATURE_APPX_BINDER
- _ASSERTE(!AppX::IsAppXProcess());
-#endif
-
if (s_pSingleton == nullptr)
{
ReleaseHolder<CLRPrivBinderWinRT> pBinder;
@@ -256,15 +195,6 @@ CLRPrivBinderWinRT::GetOrCreateBinder(
{
pBinder.SuppressRelease();
}
-#if !defined(FEATURE_CORECLR) && !defined(CROSSGEN_COMPILE)
- // Create and register WinRT usage log
- ReleaseHolder<IAssemblyUsageLog> pNewWinRTUsageLog;
- IfFailThrow(AssemblyUsageLogManager::GetUsageLogForContext(W("WinRT"), W("NotApp"), &pNewWinRTUsageLog));
-
- UINT_PTR winRTBinderId;
- IfFailThrow(pBinder->GetBinderID(&winRTBinderId));
- IfFailThrow(AssemblyUsageLogManager::RegisterBinderWithUsageLog(winRTBinderId, pNewWinRTUsageLog));
-#endif
}
_ASSERTE(s_pSingleton->m_fNamespaceResolutionKind == fNamespaceResolutionKind);
@@ -289,17 +219,10 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName(
HRESULT hr = S_OK;
ReleaseHolder<CLRPrivAssemblyWinRT> pAssembly;
LPWSTR wszFullTypeName = nullptr;
-#ifndef FEATURE_CORECLR
- NewArrayHolder<WCHAR> wszAssemblySimpleName;
-#endif
#ifndef CROSSGEN_COMPILE
-#ifndef FEATURE_CORECLR
- fusion::logging::StatusScope logStatus(0, ID_FUSLOG_BINDING_STATUS_WINRT, &hr);
-#else
BINDER_SPACE::BINDER_LOG_ENTER(W("CLRPrivBinderWinRT_CoreCLR::BindWinRTAssemblyByName"));
#endif
-#endif
VALIDATE_ARG_RET(pAssemblyName != nullptr);
VALIDATE_ARG_RET(ppAssembly != nullptr);
@@ -316,15 +239,11 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName(
IfFailGo(COR_E_PLATFORMNOTSUPPORTED);
}
-#ifndef FEATURE_CORECLR
- IfFailGo(fusion::util::GetProperty(pAssemblyName, ASM_NAME_NAME, &wszAssemblySimpleName));
-#else
WCHAR wszAssemblySimpleName[_MAX_PATH];
{
DWORD cchAssemblySimpleName = _MAX_PATH;
IfFailGo(pAssemblyName->GetName(&cchAssemblySimpleName, wszAssemblySimpleName));
}
-#endif
wszFullTypeName = wcschr(wszAssemblySimpleName, W('!'));
@@ -414,10 +333,6 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName(
//
IfFailGo(pAssemblyDefName->SetProperty(ASM_NAME_NAME, wszFileNameStripped, (lstrlenW(wszFileNameStripped) + 1) * sizeof(WCHAR)));
-#ifdef FEATURE_FUSION
- NewHolder<CLRPrivAssemblyBindResultWrapper> pBindResult(
- new CLRPrivAssemblyBindResultWrapper(pAssemblyDefName, wszFileName, m_pFingerprintFactory));
-#else
NewHolder<CoreBindResult> pBindResult(new CoreBindResult());
StackSString sAssemblyPath(pResource->GetPath());
ReleaseHolder<BINDER_SPACE::Assembly> pBinderAssembly;
@@ -427,7 +342,6 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName(
// We have set bInGac to TRUE here because the plan is full trust for WinRT. If this changes, we may need to check with
// AppDomain to verify trust based on the WinMD's path
pBindResult->Init(pBinderAssembly, TRUE);
-#endif
NewHolder<CLRPrivAssemblyWinRT> pNewAssembly(
new CLRPrivAssemblyWinRT(this, pResource, pBindResult, fIsWindowsNamespace));
@@ -445,49 +359,7 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName(
pNewAssembly.SuppressRelease();
}
-#ifndef FEATURE_CORECLR
- if (fPreBind)
- {
- // We are pre-binding to this WinMD and do not want to open it
- // Compare the filename to the assembly simple name. This is legal to do with WinRT because at NGen time
- // we embed a WinRT dependency as assembly def name component plus a namespace and type from it.
- // At bind time, this type should still exist in the same assembly. If it doesn't, and has been moved,
- // the native image validation will fail anyway and we'll fall back to IL. This is because if the type has
- // been moved to another WinMD, it must have been removed from the first one because WinRT allows no duplicates.
- // See comment on CLRPrivBinderWinRT::PreBind for further details.
- if (!_wcsicmp(wszAssemblySimpleName, wszFileNameStripped))
- {
- *ppAssembly = pAssembly.Extract();
- return (hr = S_OK);
- }
- else
- {
- continue;
- }
- }
-#endif
- }
-#ifndef FEATURE_CORECLR
- else if (fPreBind)
- {
- // We are pre-binding to this WinMD and do not want to force it to be loaded into the runtime yet.
- // Compare the filename to the assembly simple name. This is legal to do with WinRT because at NGen time
- // we embed a WinRT dependency as assembly def name component plus a namespace and type from it.
- // At bind time, this type should still exist in the same assembly. If it doesn't, and has been moved,
- // the native image validation will fail anyway and we'll fall back to IL. This is because if the type has
- // been moved to another WinMD, it must have been removed from the first one because WinRT allows no duplicates.
- // See comment on CLRPrivBinderWinRT::PreBind for further details.
- if (!_wcsicmp(wszAssemblySimpleName, wszFileNameStripped))
- {
- *ppAssembly = pAssembly.Extract();
- return (hr = S_OK);
- }
- else
- {
- continue;
- }
}
-#endif
//
// Look to see if there's a native image available.
@@ -499,12 +371,8 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName(
if (hr == S_OK)
{ // The type we are looking for has been found in this assembly
#ifndef CROSSGEN_COMPILE
-#ifndef FEATURE_CORECLR
- fusion::logging::LogMessage(0, ID_FUSLOG_BINDING_STATUS_FOUND, wszFileName);
-#else
BINDER_SPACE::BINDER_LOG_LEAVE_HR(W("CLRPrivBinderWinRT_CoreCLR::BindWinRTAssemblyByName"), hr);
#endif
-#endif
*ppAssembly = pAssembly.Extract();
return (hr = S_OK);
}
@@ -516,102 +384,11 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName(
hr = CLR_E_BIND_TYPE_NOT_FOUND;
ErrExit:
-#ifdef FEATURE_CORECLR
BINDER_SPACE::BINDER_LOG_LEAVE_HR(W("CLRPrivBinderWinRT_CoreCLR::BindWinRTAssemblyByName"), hr);
-#endif
return hr;
} // CLRPrivBinderWinRT::BindWinRTAssemblyByName
-#ifdef FEATURE_FUSION
-//=====================================================================================================================
-HRESULT CLRPrivBinderWinRT::BindAssemblyToNativeAssembly(CLRPrivAssemblyWinRT *pAssembly)
-{
- HRESULT hr = S_OK;
-
- if (!m_fCanUseNativeImages)
- return hr;
- ReleaseHolder<IBindResult> pIBindResultIL;
- IfFailRet(pAssembly->GetIBindResult(&pIBindResultIL));
- _ASSERTE(pIBindResultIL != nullptr);
-
- NewArrayHolder<WCHAR> wzZapSet = DuplicateStringThrowing(g_pConfig->ZapSet());
- NativeConfigData cfgData = {
- wzZapSet,
- PEFile::GetNativeImageConfigFlags()
- };
-
- ReleaseHolder<IBindContext> pIBindContext;
- IfFailRet(GetParentIBindContext(&pIBindContext));
-
- // Fire BindingNgenPhaseStart ETW event if enabled.
- {
- InlineSString<_MAX_PATH> ssAssemblyName;
- FireEtwBindingNgenPhaseStart(
- (AppDomain::GetCurrentDomain()->GetId().m_dwId),
- LOADCTX_TYPE_HOSTED,
- ETWFieldUnused,
- ETWLoaderLoadTypeNotAvailable,
- NULL,
- pAssembly->m_pResourceIL->GetPath(),
- GetClrInstanceId());
- }
-
- IfFailRet(BindToNativeAssembly(pIBindResultIL, &cfgData, pIBindContext, fusion::logging::GetCurrentFusionBindLog()));
-
- // Fire BindingNgenPhaseEnd ETW event if enabled.
- {
- InlineSString<_MAX_PATH> ssAssemblyName;
- FireEtwBindingNgenPhaseEnd(
- (AppDomain::GetCurrentDomain()->GetId().m_dwId),
- LOADCTX_TYPE_HOSTED,
- ETWFieldUnused,
- ETWLoaderLoadTypeNotAvailable,
- NULL,
- pAssembly->m_pResourceIL->GetPath(),
- GetClrInstanceId());
- }
-
- // BindToNativeAssembly can return S_FALSE, but this could be misleading.
- if (hr == S_FALSE)
- hr = S_OK;
-
- return hr;
-}
-#endif
-
-#if defined(FEATURE_COMINTEROP_WINRT_DESKTOP_HOST) && !defined(CROSSGEN_COMPILE)
-BOOL CLRPrivBinderWinRT::SetLocalWinMDPath(HSTRING localWinMDPath)
-{
- STANDARD_VM_CONTRACT;
- STATIC_CONTRACT_CAN_TAKE_LOCK;
-
- CrstHolder lock(&m_localWinMDPathLock);
-
- // We use the empty string as a sential, so don't allow explicitly setting the binding base to empty.
- if (localWinMDPath == nullptr)
- {
- return FALSE;
- }
-
- // If we've already set a binding base, then the current base must match the exisitng one exactly
- if (!m_localWinMDPath.IsEmpty())
- {
- return m_localWinMDPath.CompareOrdinal(clr::winrt::StringReference(localWinMDPath)) == 0;
- }
-
- // If we've already done WinRT binding, we can't set the binding base because that could lead to inconsistent results when binding
- // the same name after the base is set.
- if (!m_fCanSetLocalWinMDPath)
- {
- return FALSE;
- }
-
- m_localWinMDPath.Initialize(localWinMDPath);
-
- return TRUE;
-}
-#endif // FEATURE_COMINTEROP_WINRT_DESKTOP_HOST && !CROSSGEN_COMPILE
//=====================================================================================================================
HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName(
@@ -648,7 +425,6 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName(
return hr;
}
-#ifndef FEATURE_FUSION
//
// This method opens the assembly using the CoreCLR Binder, which has logic supporting opening either the IL or
// even just the native image without IL present.
@@ -659,7 +435,6 @@ HRESULT CLRPrivBinderWinRT::GetAssemblyAndTryFindNativeImage(SString &sWinmdFile
{
HRESULT hr = S_OK;
-#ifdef FEATURE_CORECLR
if (!m_pApplicationContext->IsTpaListProvided())
return COR_E_FILENOTFOUND;
@@ -732,24 +507,10 @@ HRESULT CLRPrivBinderWinRT::GetAssemblyAndTryFindNativeImage(SString &sWinmdFile
FALSE, /* fIsInGAC */
FALSE /* fExplicitBindToNativeImage */,
ppAssembly);
-#else
- ReleaseHolder<BINDER_SPACE::Assembly> pAssembly;
-
- // This codepath is used for desktop crossgen
- pAssembly = new BINDER_SPACE::Assembly();
-
- pAssembly->SetPEImage(PEImage::OpenImage(sWinmdFilename, MDInternalImport_Default));
-
- pAssembly->m_assemblyPath.Set(sWinmdFilename);
-
- *ppAssembly = pAssembly.Extract();
-#endif
return hr;
}
-#endif // !FEATURE_FUSION
-#ifdef FEATURE_CORECLR
//=====================================================================================================================
HRESULT CLRPrivBinderWinRT::SetApplicationContext(BINDER_SPACE::ApplicationContext *pApplicationContext, SString &appLocalWinMD)
{
@@ -784,7 +545,6 @@ HRESULT CLRPrivBinderWinRT::SetApplicationContext(BINDER_SPACE::ApplicationConte
return hr;
}
-#endif //FEATURE_CORECLR
//=====================================================================================================================
// Implements interface method code:ICLRPrivBinder::BindAssemblyByName.
@@ -950,20 +710,7 @@ CLRPrivBinderWinRT::GetFileNameListForNamespace(
LPWSTR wszWinMDPath = nullptr;
UINT32 cchWinMDPath = 0;
-#ifdef FEATURE_CORECLR
wszWinMDPath = m_appLocalWinMDPath;
-#else
- if (AppX::IsAdaptiveApp())
- {
- IfFailRet(AppX::GetWinMetadataDirForAdaptiveApps(&wszWinMDPath));
- }
-
- else if (AppX::IsAppXDesignMode() || IsNgenOffline())
- {
- wszWinMDPathConfig = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_WinMDPath);
- wszWinMDPath = wszWinMDPathConfig;
- }
-#endif // FEATURE_CORECLR
if (wszWinMDPath != nullptr)
{
@@ -981,7 +728,6 @@ CLRPrivBinderWinRT::GetFileNameListForNamespace(
&rgFileNames,
nullptr, // pcDirectNamespaceChildren
nullptr); // rgDirectNamespaceChildren
-#ifdef FEATURE_CORECLR
// For CoreCLR, if the process is not AppX, deliver more appropriate error message
// when trying to bind to 3rd party WinMDs that is not confusing.
if (HRESULT_FROM_WIN32(APPMODEL_ERROR_NO_PACKAGE) == hr)
@@ -991,57 +737,7 @@ CLRPrivBinderWinRT::GetFileNameListForNamespace(
IfFailRet(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED));
}
}
-#endif
-#ifdef FEATURE_COMINTEROP_WINRT_DESKTOP_HOST
- // If we failed to find the requested name, but we have an application local probing path setup, then
- // we can use that to try to find the name now.
- if (hr == RO_E_METADATA_NAME_NOT_FOUND || hr == HRESULT_FROM_WIN32(APPMODEL_ERROR_NO_PACKAGE))
- {
- // We only want to probe the application local path for 3rd party WinMDs as these are the only ones
- // which do not have code sharing enabled. Although we currently only allow a single alternate probing
- // path per process, shutting this off now will give us easier behavior to support in the future if we
- // do need to enable per-domain local paths.
- if (!IsWindowsNamespace(wszNamespaceRoResolve))
- {
- HSTRING localWinMDPath = nullptr;
- {
- CrstHolder lock(&m_localWinMDPathLock);
-
- localWinMDPath = m_localWinMDPath.Get();
-
- // If the host has not configured the local winmd path, and we have not yet done any winmd probing
- // then see if we have config to setup a local winmd path.
- if (localWinMDPath == nullptr && m_fCanSetLocalWinMDPath)
- {
- NewArrayHolder<WCHAR> configWinMDPath(CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LocalWinMDPath));
- if (!configWinMDPath.IsNull())
- {
- m_localWinMDPath.Initialize(configWinMDPath);
- localWinMDPath = m_localWinMDPath.Get();
- }
- }
-
- // Do not allow any further setting of the application binding base at this point, since if it
- // is not currently set, setting it in the future could result in different binding results.
- m_fCanSetLocalWinMDPath = FALSE;
- }
-
- if (localWinMDPath != nullptr)
- {
- hr = RoResolveNamespace(
- WinRtStringRef(wszNamespaceRoResolve, cchNamespaceRoResolve),
- wszWinMDPath != nullptr ? (HSTRING)WinRtStringRef(wszWinMDPath, cchWinMDPath) : nullptr, // hsWindowsSdkPath
- 1, // cPackageGraph
- &localWinMDPath, // rgPackageGraph
- &cFileNames,
- &rgFileNames,
- nullptr, // pcDirectNamespaceChildren
- nullptr); // rgDirectNamespaceChildren
- }
- }
- }
-#endif // FEATURE_COMINTEROP_WINRT_DESKTOP_HOST
IfFailRet(hr);
if (hr != S_OK)
@@ -1059,33 +755,6 @@ CLRPrivBinderWinRT::GetFileNameListForNamespace(
&cchFileName);
BOOL fSkipFilename = FALSE;
-#ifndef FEATURE_CORECLR
- // If we have a specified path list. Be certain to only find filenames in that list.
- // NGen for AppX is an exception, where the path list contains the package graph, and we can
- // accept files found elsewhere (e.g., in the Windows WinMD directory).
- // On CoreCLR, we have no concept of an AppX package, so we want the passed in app
- // paths to additively contribute to the set of WinMDs the API can find.
- if (m_rgAltPaths.GetCount() > 0 && !AppX::IsAppXNGen())
- {
- fSkipFilename = TRUE;
- for (DWORD iAltPath = 0; iAltPath < m_rgAltPaths.GetCount(); iAltPath++)
- {
- UINT32 cchAltPath = 0;
- LPCWSTR wszAltPath = WindowsGetStringRawBuffer(
- m_rgAltPaths.GetAt(iAltPath),
- &cchAltPath);
-
- if (cchAltPath >= cchFileName)
- continue;
-
- if (wcsncmp(wszAltPath, wszFileName, cchAltPath) == 0)
- {
- fSkipFilename = FALSE;
- break;
- }
- }
- }
-#endif
if (!fSkipFilename)
hFileNameList.InsertTail(wszFileName);
}
@@ -1309,60 +978,6 @@ CLRPrivBinderWinRT::FindAssemblyForTypeIfLoaded(
#ifndef DACCESS_COMPILE
-#ifdef FEATURE_FUSION
-//=====================================================================================================================
-// Implements interface method code:IBindContext::PreBind.
-//
-// Prebinding to WinMD files follows a special contract. We want to avoid loading the actual target assembly
-// and we need to validate that all dependencies of the file remain equivalent to that which was available at ngen time
-// We do this by comparing the filename to the assembly simple name. This is legal to do with WinRT because at NGen time
-// we embed a WinRT dependency as assembly def name component plus a namespace and type from it.
-// At bind time, this type should still exist in the same assembly. If it doesn't, and has been moved,
-// the native image validation will fail anyway and we'll fall back to IL. This is because if the type has
-// been moved to another WinMD, it must have been removed from the first one because WinRT allows no duplicates.
-// This no duplicate rule is obviously not actually gauranteed by the WinRT runtime for 3rd party assemblies,
-// but violating the rule is known to cause a number of binding behavior errors that we do not attempt to protect against.
-HRESULT
-CLRPrivBinderWinRT::PreBind(
- IAssemblyName * pAssemblyName,
- DWORD dwPreBindFlags,
- IBindResult ** ppIBindResult)
-{
- STANDARD_VM_CONTRACT;
- HRESULT hr = S_OK;
-
- // Assert that we are only working with a binder that supports native images
- _ASSERTE(m_fCanUseNativeImages);
-
- ReleaseHolder<IBindContext> pIBindContext;
- IfFailRet(GetParentIBindContext(&pIBindContext));
-
- DWORD dwContentType = AssemblyContentType_Default;
- DWORD cbContentTypeSize = sizeof(dwContentType);
- IfFailRet(pAssemblyName->GetProperty(ASM_NAME_CONTENT_TYPE, &dwContentType, &cbContentTypeSize));
-
- if (dwContentType == AssemblyContentType_Default)
- {
- hr = pIBindContext->PreBind(pAssemblyName, dwPreBindFlags, ppIBindResult);
- }
- else
- {
- hr = BindWinRTAssemblyByName(pAssemblyName, ppIBindResult, TRUE);
- }
-
- return hr;
-}
-
-//=====================================================================================================================
-// Implements interface method code:IBindContext::IsDefaultContext.
-//
-HRESULT
-CLRPrivBinderWinRT::IsDefaultContext()
-{
- LIMITED_METHOD_CONTRACT;
- return S_OK;
-}
-#endif
//=====================================================================================================================
CLRPrivAssemblyWinRT::CLRPrivAssemblyWinRT(
@@ -1470,21 +1085,6 @@ HRESULT CLRPrivAssemblyWinRT::GetAvailableImageTypes(
return hr;
}
-#ifdef FEATURE_FUSION
-static ICLRPrivResource * GetResourceForBindResult(
- IBindResult * pIBindResult)
-{
- STANDARD_VM_CONTRACT;
- VALIDATE_ARG_THROW(pIBindResult != nullptr);
-
- WCHAR wzPath[_MAX_PATH];
- DWORD cchPath = NumItems(wzPath);
- ReleaseHolder<IAssemblyLocation> pIAssemLoc;
- IfFailThrow(pIBindResult->GetAssemblyLocation(&pIAssemLoc));
- IfFailThrow(pIAssemLoc->GetPath(wzPath, &cchPath));
- return ToInterface<ICLRPrivResource>(new CLRPrivResourcePathImpl(wzPath));
-}
-#endif
//=====================================================================================================================
// Implements interface method code:ICLRPrivAssembly::GetImageResource.
@@ -1573,7 +1173,6 @@ HRESULT CLRPrivBinderWinRT::GetBinderID(
return S_OK;
}
-#if defined(FEATURE_CORECLR) || defined(CROSSGEN_COMPILE)
//=====================================================================================================================
HRESULT CLRPrivBinderWinRT::FindWinRTAssemblyBySpec(
LPVOID pvAppDomain,
@@ -1584,68 +1183,7 @@ HRESULT CLRPrivBinderWinRT::FindWinRTAssemblyBySpec(
STATIC_CONTRACT_WRAPPER;
return E_FAIL;
}
-#endif
-#ifdef FEATURE_FUSION
-//=====================================================================================================================
-HRESULT CLRPrivBinderWinRT::FindWinRTAssemblyBySpec(
- LPVOID pvAppDomain,
- LPVOID pvAssemblySpec,
- HRESULT * pResult,
- ICLRPrivAssembly ** ppAssembly)
-{
- LIMITED_METHOD_CONTRACT;;
- HRESULT hr = S_OK;
-
- AppDomain* pAppDomain = reinterpret_cast<AppDomain*>(pvAppDomain);
- AssemblySpec* pAssemblySpec = reinterpret_cast<AssemblySpec*>(pvAssemblySpec);
- VALIDATE_PTR_RET(pAppDomain);
- VALIDATE_PTR_RET(pAssemblySpec);
- VALIDATE_PTR_RET(pResult);
- VALIDATE_PTR_RET(ppAssembly);
-
- if (pAssemblySpec->IsContentType_WindowsRuntime())
- {
- // FindAssemblyBySpec is not supported by this binder.
- *pResult = CLR_E_BIND_TYPE_NOT_FOUND;
- *ppAssembly = nullptr;
- return S_OK;
- }
- else
- {
- return CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT;
- }
-}
-
-//=====================================================================================================================
-HRESULT CLRPrivBinderWinRT::GetParentIBindContext(
- IBindContext **ppIBindContext)
-{
- STANDARD_BIND_CONTRACT;
- VALIDATE_ARG_RET(ppIBindContext != nullptr);
-
- HRESULT hr = S_OK;
-
- if (m_pParentBinder != nullptr)
- {
- _ASSERTE(AppX::IsAppXProcess());
- IfFailRet(m_pParentBinder->QueryInterface(__uuidof(IBindContext), (void**)ppIBindContext));
- }
- else
- {
- _ASSERTE(!AppX::IsAppXProcess());
- EX_TRY
- {
- AppDomain* pDomain = AppDomain::GetCurrentDomain();
- hr = GetBindContextFromApplicationContext(pDomain->CreateFusionContext(), ppIBindContext);
- }
- EX_CATCH_HRESULT(hr);
- }
-
- _ASSERTE(FAILED(hr) || *ppIBindContext != nullptr);
- return hr;
-}
-#endif
//=====================================================================================================================
HRESULT CLRPrivAssemblyWinRT::GetIBindResult(
@@ -1672,29 +1210,14 @@ HRESULT CLRPrivAssemblyWinRT::EnsureAvailableImageTypes()
// If image types has not yet been set, attempt to bind to native assembly
if (dwImageTypesLocal == 0)
{
-#ifdef FEATURE_FUSION
- CLRPrivBinderWinRT *pBinder = m_pBinder;
- IfFailGo(pBinder->BindAssemblyToNativeAssembly(this));
-#endif
if (m_pIResourceNI == nullptr)
{
-#ifdef FEATURE_FUSION
- ReleaseHolder<IBindResult> pIBindResultNI;
-
- if (SUCCEEDED(hr = m_pIBindResult->GetNativeImage(&pIBindResultNI, nullptr)) && pIBindResultNI != nullptr)
- {
- ReleaseHolder<ICLRPrivResource> pResourceNI = GetResourceForBindResult(pIBindResultNI);
- if (InterlockedCompareExchangeT<ICLRPrivResource *>(&m_pIResourceNI, pResourceNI, nullptr) == nullptr)
- pResourceNI.SuppressRelease();
- }
-#else
if (m_pIBindResult->HasNativeImage())
{
SString sPath = m_pIBindResult->GetNativeImage()->GetPath();
m_pIResourceNI = new CLRPrivResourcePathImpl(sPath.GetUnicode());
m_pIResourceNI->AddRef();
}
-#endif
IfFailGo(hr);
}