#include <xcordebug.h>
#include "dacimpl.h"
-#if defined(FEATURE_APPX_BINDER)
-#include <clrprivbinderappx.h>
-#endif // defined(FEATURE_APPX)
#define STRSAFE_NO_DEPRECATE
#include <strsafe.h>
#endif //defined(DEBUGGING_SUPPORTED) && defined (FEATURE_PREJIT)
-#if defined(FEATURE_APPX_BINDER)
-DEFINE_DACVAR(ULONG, PTR_CLRPrivBinderAppX, CLRPrivBinderAppX__s_pSingleton, CLRPrivBinderAppX::s_pSingleton)
-#endif //defined(FEATURE_APPX)
#ifdef FEATURE_MINIMETADATA_IN_TRIAGEDUMPS
DEFINE_DACVAR(ULONG, DWORD, dac__g_MiniMetaDataBuffMaxSize, ::g_MiniMetaDataBuffMaxSize)
#include "../binder/inc/clrprivbindercoreclr.h"
-#if defined(FEATURE_APPX_BINDER)
-#include "appxutil.h"
-#include "clrprivbinderappx.h"
-#endif
#include "clrprivtypecachewinrt.h"
// Allocate the managed standard interfaces information.
m_pMngStdInterfacesInfo = new MngStdInterfacesInfo();
-#if defined(FEATURE_APPX_BINDER)
- if (!AppX::IsAppXProcess())
-#endif
{
CLRPrivBinderWinRT::NamespaceResolutionKind fNamespaceResolutionKind = CLRPrivBinderWinRT::NamespaceResolutionKind_WindowsAPI;
if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_DesignerNamespaceResolutionEnabled) != FALSE)
{
pDefaultDomain->SetLoadContextHostBinder(pBinder);
}
- #ifdef FEATURE_APPX_BINDER
- else if (AppX::IsAppXProcess())
- {
- CLRPrivBinderAppX * pAppXBinder = CLRPrivBinderAppX::GetOrCreateBinder();
- pDefaultDomain->SetLoadContextHostBinder(pAppXBinder);
- }
- #endif
{
GCX_COOP();
m_pReflectionOnlyWinRtBinder = clr::SafeAddRef(new CLRPrivBinderReflectionOnlyWinRT(m_pReflectionOnlyWinRtTypeCache));
#endif
}
-#ifdef FEATURE_APPX_BINDER
- else if (g_fEEStarted && !IsDefaultDomain())
- { // Non-default domain in an AppX process. This exists only for designers and we'd better be in dev mode.
- _ASSERTE(IsCompilationProcess() || AppX::IsAppXDesignMode());
-
- // Inherit AppX binder from default domain.
- SetLoadContextHostBinder(SystemDomain::System()->DefaultDomain()->GetLoadContextHostBinder());
-
- // Note: LoadFrom, LoadFile, Load(byte[], ...), ReflectionOnlyLoad, LoadWithPartialName,
- /// etc. are not supported and are actively blocked.
- }
-#endif //FEATURE_APPX_BINDER
#endif //FEATURE_COMINTEROP
#endif // CROSSGEN_COMPILE
BOOL fForceReThrow = FALSE;
-#if defined(FEATURE_APPX_BINDER)
- //
- // If there is a host binder available and this is an unparented bind within the
- // default load context, then the bind will be delegated to the domain-wide host
- // binder. If there is a parent assembly, then a bind will occur only if it has
- // an associated ICLRPrivAssembly to serve as the binder.
- //
- // fUseHostBinderIfAvailable can be false if this method is called by
- // CLRPrivBinderFusion::BindAssemblyByName, which explicitly indicates that it
- // wants to use the fusion binder.
- //
-
- if (AppX::IsAppXProcess() &&
- fUseHostBinderIfAvailable &&
- (
- ( pSpec->HasParentAssembly()
- ? // Parent assembly is hosted
- pSpec->GetParentAssembly()->GetFile()->HasHostAssembly()
- : // Non-parented default context bind
- ( HasLoadContextHostBinder() &&
- !pSpec->IsIntrospectionOnly()
- )
- ) ||
- (pSpec->GetHostBinder() != nullptr)
- )
- )
- {
- HRESULT hr = S_OK;
-
- if (pSpec->GetCodeBase() != nullptr)
- { // LoadFrom is not supported in AppX (we should never even get here)
- IfFailThrow(E_INVALIDARG);
- }
-
- // Get the assembly display name.
- ReleaseHolder<IAssemblyName> pAssemblyName;
- IfFailThrow(pSpec->CreateFusionName(&pAssemblyName, TRUE, TRUE));
-
- // Create new binding scope for fusion logging.
- fusion::logging::BindingScope defaultScope(pAssemblyName, FUSION_BIND_LOG_CATEGORY_DEFAULT);
-
- PEAssemblyHolder pAssembly;
- EX_TRY
- {
- // If there is a specified binder, then it is used.
- // Otherwise if there exist a parent assembly, then it provides the binding context
- // Otherwise the domain's root-level binder is used.
- ICLRPrivBinder * pBinder = nullptr;
-
- if (pSpec->GetHostBinder() != nullptr)
- {
- pBinder = pSpec->GetHostBinder();
- }
- else
- {
- PEAssembly * pParentAssembly =
- (pSpec->GetParentAssembly() == nullptr) ? nullptr : pSpec->GetParentAssembly()->GetFile();
-
- if ((pParentAssembly != nullptr) && (pParentAssembly->HasHostAssembly()))
- {
- BOOL fMustUseOriginalLoadContextBinder = FALSE;
- if (pSpec->IsContentType_WindowsRuntime())
- {
- // Ugly, but we need to handle Framework assemblies that contain WinRT type references,
- // and the Fusion binder won't resolve these in AppX processes. The shareable flag is currently
- // a reasonable proxy for these cases. (It also catches first party WinMD files, but depedencies
- // from those can also be resolved by the original load context binder).
- // TODO! Update the fusion binder to resolve WinMD references correctly.
- IfFailThrow(pParentAssembly->GetHostAssembly()->IsShareable(&fMustUseOriginalLoadContextBinder));
- }
-
- if (fMustUseOriginalLoadContextBinder)
- {
- pBinder = GetLoadContextHostBinder();
- }
- else
- {
- pBinder = pParentAssembly->GetHostAssembly();
- }
- }
- else
- {
- pBinder = GetCurrentLoadContextHostBinder();
- }
- }
- _ASSERTE(pBinder != nullptr);
-
- hr = BindAssemblySpecForHostedBinder(pSpec, pAssemblyName, pBinder, &pAssembly);
- if (FAILED(hr))
- {
- goto EndTry1;
- }
-EndTry1:;
- }
- // The combination of this conditional catch/ the following if statement which will throw reduces the count of exceptions
- // thrown in scenarios where the exception does not escape the method. We cannot get rid of the try/catch block, as
- // there are cases within some of the clrpriv binder's which throw.
- // Note: In theory, FileNotFound should always come here as HRESULT, never as exception.
- EX_CATCH_HRESULT_IF(hr,
- !fThrowOnFileNotFound && Assembly::FileNotFound(hr))
-
- if (FAILED(hr) && (fThrowOnFileNotFound || !Assembly::FileNotFound(hr)))
- {
- if (Assembly::FileNotFound(hr))
- {
- _ASSERTE(fThrowOnFileNotFound);
- // Uses defaultScope
- EEFileLoadException::Throw(pSpec, fusion::logging::GetCurrentFusionBindLog(), hr);
- }
- if ((hr == CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT) && pSpec->IsContentType_WindowsRuntime())
- { // Error returned e.g. for WinRT type name without namespace
- if (fThrowOnFileNotFound)
- { // Throw ArgumentException (with the HRESULT) wrapped by TypeLoadException to give user type name for diagnostics
- // Note: TypeLoadException is equivalent of FileNotFound in WinRT world
- EEMessageException ex(hr);
- EX_THROW_WITH_INNER(EETypeLoadException, (pSpec->GetWinRtTypeNamespace(), pSpec->GetWinRtTypeClassName(), nullptr, nullptr, IDS_EE_WINRT_LOADFAILURE), &ex);
- }
- }
- else
- {
- IfFailThrow(hr);
- }
- }
-
- _ASSERTE((pAssembly != nullptr) || (FAILED(hr) && !fThrowOnFileNotFound));
- return pAssembly.Extract();
- }
- else
-#endif // FEATURE_APPX_BINDER
#if defined(FEATURE_COMINTEROP)
// Handle WinRT assemblies in the classic/hybrid scenario. If this is an AppX process,
// then this case will be handled by the previous block as part of the full set of
// available binding hosts.
-#ifndef FEATURE_APPX_BINDER
if (pSpec->IsContentType_WindowsRuntime())
-#else
- if (!AppX::IsAppXProcess() && pSpec->IsContentType_WindowsRuntime())
-#endif
{
HRESULT hr = S_OK;
}
else
{
-#ifdef FEATURE_APPX_BINDER
- // In AppX processes, all PEAssemblies that are reach this stage should have host binders.
- _ASSERTE(!AppX::IsAppXProcess());
-#endif
}
}
}
else
{
-#ifdef FEATURE_APPX_BINDER
- // In AppX processes, all PEAssemblies that are reach this stage should have host binders.
- _ASSERTE(!AppX::IsAppXProcess());
-#endif
pAssembly->UpdatePEFileWorker(pFile);
}
#if defined(FEATURE_APPX)
#include "appxutil.h"
#endif // FEATURE_APPX
-#if defined(FEATURE_APPX_BINDER)
-#include "clrprivbinderappx.h"
-#include "clrprivtypecachewinrt.h"
-#endif // FEATURE_APPX_BINDER
#include "../binder/inc/clrprivbindercoreclr.h"
#include "clr/fs/path.h"
FCIMPLEND
#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING
-#if defined(FEATURE_APPX_BINDER)
-ICLRPrivBinder * QCALLTYPE AppDomainNative::CreateDesignerContext(LPCWSTR *rgPaths,
- UINT cPaths,
- BOOL fShared)
-{
- QCALL_CONTRACT;
-
- ICLRPrivBinder *pRetVal = nullptr;
-
- BEGIN_QCALL;
- ReleaseHolder<ICLRPrivBinder> pBinder;
-
- // The runtime check is done on the managed side to enable the debugger to use
- // FuncEval to create designer contexts outside of DesignMode.
- _ASSERTE(AppX::IsAppXDesignMode() || (AppX::IsAppXProcess() && CORDebuggerAttached()));
-
- AppDomain *pAppDomain = GetAppDomain();
-
- pBinder = CLRPrivBinderAppX::CreateParentedBinder(fShared ? pAppDomain->GetLoadContextHostBinder() : pAppDomain->GetSharedContextHostBinder(), CLRPrivTypeCacheWinRT::GetOrCreateTypeCache(), rgPaths, cPaths, fShared /* fCanUseNativeImages */);
-
- {
- BaseDomain::LockHolder lh(pAppDomain);
- pAppDomain->AppDomainInterfaceReleaseList.Append(pRetVal);
- }
- pBinder.SuppressRelease();
- pRetVal = pBinder;
-
- END_QCALL;
-
- return pRetVal;
-}
-
-void QCALLTYPE AppDomainNative::SetCurrentDesignerContext(BOOL fDesignerContext, ICLRPrivBinder *newContext)
-{
- QCALL_CONTRACT;
-
- BEGIN_QCALL;
-
- if (fDesignerContext)
- {
- GetAppDomain()->SetCurrentContextHostBinder(newContext);
- }
- else
- {
- // Managed code is responsible for ensuring this isn't called more than once per AppDomain.
- GetAppDomain()->SetSharedContextHostBinder(newContext);
- }
-
- END_QCALL;
-}
-#endif // defined(FEATURE_APPX_BINDER)
-#if defined(FEATURE_APPX_BINDER)
- static
- ICLRPrivBinder * QCALLTYPE CreateDesignerContext(LPCWSTR *rgPaths, UINT cPaths, BOOL fShared);
-
- static
- void QCALLTYPE SetCurrentDesignerContext(BOOL fDesignerContext, ICLRPrivBinder *newContext);
-#endif
};
#endif
if (pMeth) {
RunMainPre();
-#if defined(FEATURE_APPX_BINDER) && defined(FEATURE_MULTICOREJIT)
- if (AppX::IsAppXProcess())
- {
- GCX_PREEMP();
-
- // we call this to obtain and cache the PRAID value which is used
- // by multicore JIT manager and watson bucket params generation.
-
- // NOTE: this makes a COM call into WinRT so we must do this after we've
- // set the thread's apartment state which will do CoInitializeEx().
- LPCWSTR praid;
- hr = AppX::GetApplicationId(praid);
- _ASSERTE(SUCCEEDED(hr));
-
- if (!pMeth->GetModule()->HasNativeImage())
- {
- // For Appx, multicore JIT is only needed when root assembly does not have NI image
- // When it has NI image, we can't generate profile, and do not need to playback profile
- AppDomain * pDomain = pThread->GetDomain();
- pDomain->GetMulticoreJitManager().AutoStartProfileAppx(pDomain);
- }
- }
-#endif // FEATURE_APPX_BINDER && FEATURE_MULTICOREJIT
// Set the root assembly as the assembly that is containing the main method
// The root assembly is used in the GetEntryAssembly method that on CoreCLR is used
pBinder = GetBindingContextFromParentAssembly(pDomain);
}
-#ifdef FEATURE_APPX_BINDER
- // If no explicit or parent binder, check domain.
- if (pBinder == nullptr && AppX::IsAppXProcess())
- {
- pBinder = pDomain->GetCurrentLoadContextHostBinder();
- }
-#endif
if (pBinder != nullptr)
{
AssemblySpec *a1 = (AssemblySpec *) (u1 << 1);
AssemblySpec *a2 = (AssemblySpec *) u2;
-#if defined(FEATURE_APPX_BINDER)
- _ASSERTE(a1->GetAppDomain() == a2->GetAppDomain());
- if (a1->GetAppDomain()->HasLoadContextHostBinder())
- return (CLRPrivBinderUtil::CompareHostBinderSpecs(a1,a2));
-#endif
if ((!a1->CompareEx(a2)) ||
(a1->IsIntrospectionOnly() != a2->IsIntrospectionOnly()))
inline BOOL CanUseWithBindingCache() const
{
STATIC_CONTRACT_LIMITED_METHOD;
-#if defined(FEATURE_APPX_BINDER)
- return (GetHostBinder() == nullptr) && HasUniqueIdentity();
-#else
return HasUniqueIdentity();
-#endif
}
inline ICLRPrivBinder *GetHostBinder() const
Module * pModule = pMethod->GetModule_NoLogging();
-#if defined(FEATURE_APPX_BINDER)
-
- // For Appx process, allow certain modules to load on background thread
- if (AppX::IsAppXProcess())
- {
- if (MulticoreJitManager::IsLoadOkay(pModule))
- {
- return;
- }
- }
-#endif
_ASSERTE(pModule->IsSystem());
}
#include "peimagelayout.inl"
#include "ildbsymlib.h"
-#if defined(FEATURE_APPX_BINDER)
-#include "clrprivbinderappx.h"
-#endif // defined(FEATURE_APPX_BINDER)
#if defined(PROFILING_SUPPORTED)
#include "profilermetadataemitvalidator.h"
#endif //!DACCESS_COMPILE
if (pAssembly == nullptr)
{
-#if defined(FEATURE_APPX_BINDER)
- // Use WinRT binder from "global" AppX binder (there's only 1 AppDomain in non-design mode)
- CLRPrivBinderAppX * pAppXBinder = CLRPrivBinderAppX::GetBinderOrNull();
- if (pAppXBinder != nullptr)
- {
- pWinRtBinder = pAppXBinder->GetWinRtBinder();
- }
-#endif // defined(FEATURE_APPX_BINDER)
}
}
}
DomainAssembly * pDomainAssembly = nullptr;
-#ifdef FEATURE_APPX_BINDER
- if (AppX::IsAppXProcess_Initialized_NoFault() && GetAssembly()->GetManifestFile()->HasHostAssembly())
- {
- ICLRPrivAssembly * pPrivBinder = GetAssembly()->GetManifestFile()->GetHostAssembly();
- ReleaseHolder<ICLRPrivAssembly> pPrivAssembly;
- HRESULT hrCachedResult;
- if (SUCCEEDED(pPrivBinder->FindAssemblyBySpec(pAppDomainExamine, &spec, &hrCachedResult, &pPrivAssembly)) &&
- SUCCEEDED(hrCachedResult))
- {
- pDomainAssembly = pAppDomainExamine->FindAssembly(pPrivAssembly);
- }
- }
- else
-#endif // FEATURE_APPX_BINDER
{
pDomainAssembly = pAppDomainExamine->FindCachedAssembly(&spec, FALSE /*fThrow*/);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
///// ----------------------------- Direct calls to VM -------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////////
-#if defined(FEATURE_APPX_BINDER)
- ICLRPrivAssembly* RaiseAssemblyResolveEvent(IAssemblyName *pAssemblyName, ICLRPrivAssembly* pRequestingAssembly)
- {
- CONTRACT(ICLRPrivAssembly*)
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- PRECONDITION(AppX::IsAppXProcess());
- PRECONDITION(AppDomain::GetCurrentDomain()->IsDefaultDomain());
- POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
- INJECT_FAULT(COMPlusThrowOM(););
- }
- CONTRACT_END;
-
- BinderMethodID methodId;
-
- methodId = METHOD__APP_DOMAIN__ON_ASSEMBLY_RESOLVE; // post-bind execution event (the classic V1.0 event)
-
- // Elevate threads allowed loading level. This allows the host to load an assembly even in a restricted
- // condition. Note, however, that this exposes us to possible recursion failures, if the host tries to
- // load the assemblies currently being loaded. (Such cases would then throw an exception.)
-
- OVERRIDE_LOAD_LEVEL_LIMIT(FILE_ACTIVE);
- OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(CLASS_LOADED);
-
- DomainAssembly* pDomainAssembly = AppDomain::GetCurrentDomain()->FindAssembly(pRequestingAssembly);
-
- GCX_COOP();
-
- Assembly* pAssembly = NULL;
-
- struct _gc {
- OBJECTREF AppDomainRef;
- OBJECTREF AssemblyRef;
- STRINGREF str;
- } gc;
- ZeroMemory(&gc, sizeof(gc));
-
- SString ssAssemblyName;
- FusionBind::GetAssemblyNameDisplayName(pAssemblyName, ssAssemblyName);
-
- GCPROTECT_BEGIN(gc);
- if ((gc.AppDomainRef = GetAppDomain()->GetRawExposedObject()) != NULL)
- {
- gc.AssemblyRef = pDomainAssembly->GetExposedAssemblyObject();
-
- MethodDescCallSite onAssemblyResolve(methodId, &gc.AppDomainRef);
-
- gc.str = StringObject::NewString(ssAssemblyName.GetUnicode());
- ARG_SLOT args[3] = {
- ObjToArgSlot(gc.AppDomainRef),
- ObjToArgSlot(gc.AssemblyRef),
- ObjToArgSlot(gc.str)
- };
- ASSEMBLYREF ResultingAssemblyRef = (ASSEMBLYREF) onAssemblyResolve.Call_RetOBJECTREF(args);
- if (ResultingAssemblyRef != NULL)
- {
- pAssembly = ResultingAssemblyRef->GetAssembly();
- }
- }
- GCPROTECT_END();
-
- if (pAssembly != NULL)
- {
- if (pAssembly->IsIntrospectionOnly())
- {
- // Cannot return an introspection assembly from an execution callback or vice-versa
- COMPlusThrow(kFileLoadException, IDS_CLASSLOAD_ASSEMBLY_RESOLVE_RETURNED_INTROSPECTION );
- }
- if (pAssembly->IsCollectible())
- {
- COMPlusThrow(kNotSupportedException, W("NotSupported_CollectibleAssemblyResolve"));
- }
-
- // Check that the public key token matches the one specified in the spec
- // MatchPublicKeys throws as appropriate.
-
- StackScratchBuffer ssBuffer;
- AssemblySpec spec;
- IfFailThrow(spec.Init(ssAssemblyName.GetUTF8(ssBuffer)));
- spec.MatchPublicKeys(pAssembly);
-
- }
-
- if (pAssembly == nullptr)
- ThrowHR(COR_E_FILENOTFOUND);
-
- RETURN pAssembly->GetManifestFile()->GetHostAssembly();
- }
-
- BOOL CompareHostBinderSpecs(AssemblySpec * a1, AssemblySpec * a2)
- {
- WRAPPER_NO_CONTRACT;
- return a1->CompareEx(a2, AssemblySpec::ASC_Default);
- }
-#endif // FEATURE_APPX
} // namespace CLRPrivBinderUtil
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)
{
}
}
-#if defined(FEATURE_APPX_BINDER)
- if (!fUsingCompatJit)
- {
- // AppX applications don't have a .config file for per-app configuration. So, we allow the placement of a single
- // distinguished file, "UseLegacyJit.txt" in the root of the app's package to indicate that the app should fall
- // back to JIT64. This same file is also used to prevent this app from participating in AutoNgen.
- if (AppX::IsAppXProcess())
- {
- WCHAR szPathName[MAX_LONGPATH];
- UINT32 cchPathName = MAX_LONGPATH;
- if (AppX::FindFileInCurrentPackage(L"UseLegacyJit.txt", &cchPathName, szPathName, PACKAGE_FILTER_HEAD) == S_OK)
- {
- fUsingCompatJit = TRUE;
- }
- }
- }
-#endif // FEATURE_APPX_BINDER
if (fUsingCompatJit)
{
#include "cgensys.h"
#include "peimagelayout.inl"
-#if defined(FEATURE_APPX_BINDER)
-#include "appxutil.h"
-#include "clrprivbinderappx.h"
-#include "clrprivtypecachewinrt.h"
-#endif // defined(FEATURE_APPX_BINDER)
#ifdef FEATURE_COMINTEROP
#include "clrprivbinderwinrt.h"
if (pEmitter)
pCompilationDomain->SetDependencyEmitter(pEmitter);
-#if defined(FEATURE_APPX_BINDER)
- if (AppX::IsAppXProcess())
- {
- HRESULT hr = S_OK;
- ReleaseHolder<ICLRPrivBinder> pBinderInterface;
- CLRPrivBinderAppX * pBinder = CLRPrivBinderAppX::GetOrCreateBinder();
-
- IfFailThrow(pBinder->QueryInterface(IID_ICLRPrivBinder, &pBinderInterface));
- pCompilationDomain->SetLoadContextHostBinder(pBinderInterface);
- }
-#endif // defined(FEATURE_APPX_BINDER)
#ifdef DEBUGGING_SUPPORTED
// Notify the debugger here, before the thread transitions into the
// Now load assembly into domain.
DomainAssembly * pDomainAssembly = pDomain->LoadDomainAssembly(&spec, pAssemblyHolder, FILE_LOAD_BEGIN);
-#ifndef FEATURE_APPX_BINDER
if (spec.CanUseWithBindingCache() && pDomainAssembly->CanUseWithBindingCache())
pDomain->AddAssemblyToCache(&spec, pDomainAssembly);
-#endif
{
#include "winrttypenameconverter.h"
#endif
-#if defined(FEATURE_APPX_BINDER)
-#include "clrprivbinderappx.h"
-#include "clrprivtypecachewinrt.h"
-#endif
GVAL_IMPL_INIT(DWORD, g_fHostConfig, 0);
} gc;
memset(&gc, 0, sizeof(gc));
-#if defined(FEATURE_MULTICOREJIT) && defined(FEATURE_APPX_BINDER)
- // For Appx, multicore JIT is only needed when root assembly does not have NI image
- // When it has NI image, we can't generate profile, and do not need to playback profile
- if (AppX::IsAppXProcess() && ! typeHandle.IsZapped())
- {
- GCX_PREEMP();
-
- pDomain->GetMulticoreJitManager().AutoStartProfileAppx(pDomain);
- }
-#endif
IActivationFactory* activationFactory;
GCPROTECT_BEGIN(gc);
fInsertIntoAssemblySpecBindingCache = GetFile()->GetLoadContext() == LOADCTX_TYPE_DEFAULT;
#endif
-#if defined(FEATURE_APPX_BINDER)
- fInsertIntoAssemblySpecBindingCache = fInsertIntoAssemblySpecBindingCache && !GetFile()->HasHostAssembly();
-#else
fInsertIntoAssemblySpecBindingCache = fInsertIntoAssemblySpecBindingCache && GetFile()->CanUseWithBindingCache();
-#endif
if (fInsertIntoAssemblySpecBindingCache)
{
// Support for extracting MethodDesc of a delegate.
#include "comdelegate.h"
-#if defined(FEATURE_APPX_BINDER) && !defined(DACCESS_COMPILE)
-// For determining if we have a framework assembly trying to handle a corrupted state exception
-#include "policy.h"
-#endif // FEATURE_APPX && !DACCESS_COMPILE
#ifndef FEATURE_PAL
// Windows uses 64kB as the null-reference area
}
CONTRACTL_END;
-#ifdef FEATURE_APPX_BINDER
- // In an Metro application, disallow application code to catch any corrupted state exception
- if (AppX::IsAppXProcess())
- {
- // This call to GetFusionAssemblyNameNoCreate will return a valid fusion assembly name
- // in the second pass of exception dispatch as the name would have been created in the first pass,
- // if not already existent.
- IAssemblyName *pIAssemblyName = pMethodDesc->GetAssembly()->GetFusionAssemblyNameNoCreate();
- if (!pIAssemblyName)
- {
- pIAssemblyName = pMethodDesc->GetAssembly()->GetFusionAssemblyName();
- }
-
- if (Fusion::Util::IsAnyFrameworkAssembly(pIAssemblyName) != S_OK)
- {
- return FALSE;
- }
- }
-#endif // FEATURE_APPX
if (g_pConfig->LegacyCorruptedStateExceptionsPolicy())
{
const wchar_t * AppxProfile = W("Application.Profile");
-#if defined(FEATURE_APPX_BINDER)
-
-//static
-bool MulticoreJitManager::IsLoadOkay(Module * pModule)
-{
- CONTRACTL
- {
- THROWS;
- SO_INTOLERANT;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- if (pModule->GetAssembly()->GetManifestFile()->IsWindowsRuntime())
- {
- PEFile * pFile = pModule->GetFile();
-
- ICLRPrivAssembly * pHostAsm = pFile->GetHostAssembly();
-
- // Allow first party WinMD to load in multicore JIT background thread
- if (pHostAsm != NULL)
- {
- BOOL shared = FALSE;
-
- if (SUCCEEDED(pHostAsm->IsShareable(& shared)))
- {
- if (shared)
- {
- LPCUTF8 simpleName = pModule->GetSimpleName();
-
- if (IsWindowsNamespace(simpleName))
- {
- return true;
- }
- }
- }
- }
- }
-
- return false;
-}
-
-#endif
void MulticoreJitFireEtw(const wchar_t * pAction, const wchar_t * pTarget, int p1, int p2, int p3)
unsigned lenAssemblyName = sAssemblyName.GetCount();
assemblyName.Set((const BYTE *) pAssemblyName, lenAssemblyName);
-#if defined(FEATURE_APPX_BINDER)
-
- // Allow certain modules to load on background thread
- if (AppX::IsAppXProcess() && MulticoreJitManager::IsLoadOkay(pMod))
- {
- flags |= FLAG_LOADOKAY;
- }
-
-#endif
return moduleVersion.GetModuleVersion(pMod);
}
}
-#if defined(FEATURE_APPX_BINDER)
-// ProfileName = ProcessName_CoreAppId.Profile ; for server process, always use it for output
-// ProcessName.Profile
-
-void AppendAppxProfileName(SString & name)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- } CONTRACTL_END;
-
- {
- WCHAR wszProcessName[_MAX_PATH];
-
- if (WszGetModuleFileName(NULL, wszProcessName, _MAX_PATH) != 0)
- {
- WCHAR * pNameOnly = wcsrchr(wszProcessName, W('\\'));
-
- if (pNameOnly == NULL)
- {
- pNameOnly = wszProcessName;
- }
- else
- {
- pNameOnly ++;
- }
-
- WCHAR * pExt = wcsrchr(pNameOnly, W('.')); // last .
-
- if (pExt != NULL)
- {
- * pExt = 0;
- }
-
- // Use process name only
- name.Append(pNameOnly);
- name.Append(W("_"));
- }
- }
-
- LPCWSTR pAppId = NULL;
- if (SUCCEEDED(AppX::GetApplicationId(pAppId)))
- {
- name.Append(pAppId);
- name.Append(W(".Profile"));
-
- return;
- }
-
- // default name
- name.Append(AppxProfile);
-}
-#endif
// static: single instace within a process
if (pRecorder != NULL)
{
-#if defined(FEATURE_APPX_BINDER)
- if (pRecorder->m_fAppxMode)
- {
- const wchar_t * pOutputDir = NULL;
-
- HRESULT hr = Clr::Util::GetLocalAppDataDirectory(&pOutputDir);
-
- if (SUCCEEDED(hr))
- {
- pRecorder->m_fullFileName = pOutputDir;
- pRecorder->m_fullFileName.Append(W("\\"));
-
- AppendAppxProfileName(pRecorder->m_fullFileName);
-
- pRecorder->StopProfile(false);
- }
- }
- else
-#endif
{
pRecorder->StopProfile(false);
}
}
}
-#if defined(FEATURE_APPX_BINDER)
-
-// Called from CorHost2::ExecuteMain
-void MulticoreJitManager::AutoStartProfileAppx(AppDomain * pDomain)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_PREEMPTIVE;
- INJECT_FAULT(COMPlusThrowOM(););
- }
- CONTRACTL_END;
-
- if (InterlockedCompareExchange(& m_fAutoStartCalled, SETPROFILEROOTCALLED, 0) == 0) // Only allow the first call
- {
- WCHAR wzFilePath[_MAX_PATH];
-
- UINT32 cchFilePath = NumItems(wzFilePath);
-
- SString profileName;
-
- // Try to find ProcessName_AppId.Profile
- AppendAppxProfileName(profileName);
-
- // Search for Application.Profile within the package
- HRESULT hr = AppX::FindFileInCurrentPackage(profileName, &cchFilePath, wzFilePath);
-
- if (SUCCEEDED(hr))
- {
- m_fAppxMode = true;
- SetProfileRoot(pDomain, W("")); // Fake a SetProfileRoot call
- StartProfile(pDomain, NULL, wzFilePath);
- }
- else
- {
- _FireEtwMulticoreJit(W("AUTOSTARTPROFILEAPPX"), profileName, hr, 0, 0);
- }
- }
-}
-
-#endif
// Constructor
return m_fSetProfileRootCalled == 0;
}
-#if defined(FEATURE_APPX_BINDER)
-
- // Check for file appx.prof to automatically start multicore JIT
- void AutoStartProfileAppx(AppDomain * pDomain);
-
-#endif
// Check for environment variable to automatically start multicore JIT
void AutoStartProfile(AppDomain * pDomain);
static bool ModuleHasNoCode(Module * pModule);
-#if defined(FEATURE_APPX_BINDER)
-
- static bool IsLoadOkay(Module * pModule);
-
-#endif
};
m_fAborted = false;
m_fAppxMode = fAppxMode;
-#if defined(FEATURE_APPX_BINDER)
-
- s_delayedWriteTimer = NULL;
-#endif
m_stats.Clear();
}
LOADCTX_TYPE context = pAssembly->GetManifestFile()->GetLoadContext();
-#if defined(FEATURE_APPX_BINDER)
-
- if (fAppx)
- {
- if (context == LOADCTX_TYPE_HOSTED)
- {
- return true;
- }
- }
-
-#endif
return ((context == LOADCTX_TYPE_DEFAULT) || (context == LOADCTX_TYPE_LOADFROM));
PEAssembly* pPEAssembly = new PEAssembly(image, NULL, pIAssembly,pNativeFusionAssembly, NULL, pFusionLog, NULL, NULL, TRUE, FALSE);
-#ifdef FEATURE_APPX_BINDER
- if (AppX::IsAppXProcess())
- {
- // Since mscorlib is loaded as a special case, create and assign an ICLRPrivAssembly for the new PEAssembly here.
- CLRPrivBinderAppX * pBinder = CLRPrivBinderAppX::GetOrCreateBinder();
- CLRPrivBinderFusion * pFusionBinder = pBinder->GetFusionBinder();
-
- pFusionBinder->BindMscorlib(pPEAssembly);
- }
-#endif
RETURN pPEAssembly;
#else // FEATURE_FUSION
inline bool CanUseWithBindingCache()
{
STATIC_CONTRACT_WRAPPER;
-#if !defined(FEATURE_APPX_BINDER)
return (HasBindableIdentity());
-#else
- return (PEFile::CanUseWithBindingCache() && HasBindableIdentity());
-#endif // FEATURE_CORECLR
}
};