diff options
author | Jan Kotas <jkotas@microsoft.com> | 2018-12-03 16:11:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-03 16:11:29 -0800 |
commit | 3b47496ef2656333684526cf71478253a207c1a5 (patch) | |
tree | 72bc3933479a1e6d45b62a87ff4a200663a878fe | |
parent | 248449d08f5436fbeb140a6011e412f2fea4621f (diff) | |
download | coreclr-3b47496ef2656333684526cf71478253a207c1a5.tar.gz coreclr-3b47496ef2656333684526cf71478253a207c1a5.tar.bz2 coreclr-3b47496ef2656333684526cf71478253a207c1a5.zip |
Refactor all FCalls out of AppDomain.cs (#21337)
This saves the unmanaged->managed->unmanaged trip to initialize the assembly binder.
Includes small bits of unrelated cleanup.
33 files changed, 294 insertions, 1193 deletions
diff --git a/src/System.Private.CoreLib/ILLinkTrim.xml b/src/System.Private.CoreLib/ILLinkTrim.xml index 50548b8ad1..5445899b06 100644 --- a/src/System.Private.CoreLib/ILLinkTrim.xml +++ b/src/System.Private.CoreLib/ILLinkTrim.xml @@ -39,7 +39,5 @@ <type fullname="System.Diagnostics.Tracing.RuntimeEventSource" /> <!-- Accessed via reflection in TraceLogging-style EventSource events. --> <type fullname="*f__AnonymousType*" /> - <!-- Accessed by native code in the VM --> - <type fullname="System.Runtime.CompilerServices.PinningHelper" /> </assembly> </linker> diff --git a/src/System.Private.CoreLib/Resources/Strings.resx b/src/System.Private.CoreLib/Resources/Strings.resx index e5de28bf3a..982d552ec6 100644 --- a/src/System.Private.CoreLib/Resources/Strings.resx +++ b/src/System.Private.CoreLib/Resources/Strings.resx @@ -2611,9 +2611,6 @@ <data name="InvalidOperation_ShouldNotHaveMethodBody" xml:space="preserve"> <value>Method body should not exist.</value> </data> - <data name="InvalidOperation_StrongNameKeyPairRequired" xml:space="preserve"> - <value>A strong name key pair is required to emit a strong-named dynamic assembly.</value> - </data> <data name="InvalidOperation_ThreadWrongThreadStart" xml:space="preserve"> <value>The thread was created with a ThreadStart delegate that does not accept a parameter.</value> </data> diff --git a/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/System.Private.CoreLib.csproj index ca7e85f5e9..6f1c424a38 100644 --- a/src/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -241,7 +241,7 @@ <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CLRIKeyValuePairImpl.cs" /> </ItemGroup> <ItemGroup> - <Compile Include="$(BclSourcesRoot)\System\AppContext\AppContext.cs" /> + <Compile Include="$(BclSourcesRoot)\System\AppContext.cs" /> <Compile Include="$(BclSourcesRoot)\System\Object.cs" /> <Compile Include="$(BclSourcesRoot)\System\Array.cs" /> <Compile Include="$(BclSourcesRoot)\System\ThrowHelper.cs" /> diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs index cba324c1fa..9eed287c59 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs @@ -4092,7 +4092,7 @@ namespace System.Diagnostics.Tracing if (!s_EventSourceShutdownRegistered) { s_EventSourceShutdownRegistered = true; -#if ES_BUILD_PN +#if CORECLR || ES_BUILD_PN AppContext.ProcessExit += DisposeOnShutdown; #else AppDomain.CurrentDomain.ProcessExit += DisposeOnShutdown; diff --git a/src/System.Private.CoreLib/src/System/AppContext/AppContext.cs b/src/System.Private.CoreLib/src/System/AppContext.cs index 3fe39095b5..0f3ee35f00 100644 --- a/src/System.Private.CoreLib/src/System/AppContext/AppContext.cs +++ b/src/System.Private.CoreLib/src/System/AppContext.cs @@ -23,6 +23,14 @@ namespace System AppDomain.CurrentDomain.ProcessExit += OnProcessExit; } + internal static unsafe void Setup(char** pNames, char** pValues, int count) + { + for (int i = 0; i < count; i++) + { + s_dataStore.Add(new string(pNames[i]), new string(pValues[i])); + } + } + public static string BaseDirectory { get diff --git a/src/System.Private.CoreLib/src/System/AppDomain.cs b/src/System.Private.CoreLib/src/System/AppDomain.cs index 53a26f52ac..78ef0fcd6e 100644 --- a/src/System.Private.CoreLib/src/System/AppDomain.cs +++ b/src/System.Private.CoreLib/src/System/AppDomain.cs @@ -104,28 +104,8 @@ namespace System private IntPtr _pDomain; // this is an unmanaged pointer (AppDomain * m_pDomain)` used from the VM. - /// <summary> - /// If this AppDomain is configured to have an AppDomain manager then create the instance of it. - /// This method is also called from the VM to create the domain manager in the default domain. - /// </summary> - private void CreateAppDomainManager() - { - string trustedPlatformAssemblies = (string)AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES"); - if (trustedPlatformAssemblies != null) - { - string platformResourceRoots = (string)AppContext.GetData("PLATFORM_RESOURCE_ROOTS") ?? string.Empty; - string appPaths = (string)AppContext.GetData("APP_PATHS") ?? string.Empty; - string appNiPaths = (string)AppContext.GetData("APP_NI_PATHS") ?? string.Empty; - string appLocalWinMD = (string)AppContext.GetData("APP_LOCAL_WINMETADATA") ?? string.Empty; - SetupBindingPaths(trustedPlatformAssemblies, platformResourceRoots, appPaths, appNiPaths, appLocalWinMD); - } - } - public static AppDomain CurrentDomain => Thread.GetDomain(); - [MethodImpl(MethodImplOptions.InternalCall)] - internal static extern void PublishAnonymouslyHostedDynamicMethodsAssembly(RuntimeAssembly assemblyHandle); - [Obsolete("AppDomain.GetCurrentThreadId has been deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads). To get a stable identifier for a managed thread, use the ManagedThreadId property on Thread. http://go.microsoft.com/fwlink/?linkid=14202", false)] [DllImport(Interop.Libraries.Kernel32)] public static extern int GetCurrentThreadId(); @@ -135,14 +115,6 @@ namespace System Debug.Fail("Object cannot be created through this constructor."); } - [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern void nSetupBindingPaths(string trustedPlatformAssemblies, string platformResourceRoots, string appPath, string appNiPaths, string appLocalWinMD); - - internal void SetupBindingPaths(string trustedPlatformAssemblies, string platformResourceRoots, string appPath, string appNiPaths, string appLocalWinMD) - { - nSetupBindingPaths(trustedPlatformAssemblies, platformResourceRoots, appPath, appNiPaths, appLocalWinMD); - } - // support reliability for certain event handlers, if the target // methods also participate in this discipline. If caller passes // an existing MulticastDelegate, then we could use a MDA to indicate @@ -284,55 +256,6 @@ namespace System null; } - [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern void nSetNativeDllSearchDirectories(string paths); - - private static void Setup(string friendlyName, - string[] propertyNames, - string[] propertyValues) - { - AppDomain ad = CurrentDomain; - - if (propertyNames != null && propertyValues != null) - { - for (int i = 0; i < propertyNames.Length; i++) - { - // We want to set native dll probing directories before any P/Invokes have a - // chance to fire. The Path class, for one, has P/Invokes. - if (propertyNames[i] == "NATIVE_DLL_SEARCH_DIRECTORIES") - { - if (propertyValues[i] == null) - throw new ArgumentNullException("NATIVE_DLL_SEARCH_DIRECTORIES"); - - string paths = propertyValues[i]; - if (paths.Length == 0) - break; - - nSetNativeDllSearchDirectories(paths); - } - } - - for (int i = 0; i < propertyNames.Length; i++) - { - if (propertyNames[i] != null) - { - AppContext.SetData(propertyNames[i], propertyValues[i]); - } - } - } - - // set up the friendly name - ad.nSetupFriendlyName(friendlyName); - - ad.CreateAppDomainManager(); // could modify FusionStore's object - } - - [MethodImpl(MethodImplOptions.InternalCall)] - private extern void nSetupFriendlyName(string friendlyName); - - public int Id => GetId(); - - [MethodImpl(MethodImplOptions.InternalCall)] - internal extern int GetId(); + internal int GetId() => 1; } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs index 0414de5e2e..d6f50cde42 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs @@ -84,7 +84,7 @@ namespace System.Reflection { if (!s_LoadFromResolveHandlerSetup) { - AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromResolveHandler); + AssemblyLoadContext.AssemblyResolve += LoadFromResolveHandler; s_LoadFromResolveHandlerSetup = true; } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs index f87e4779f7..a8c09d50e9 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs @@ -235,11 +235,6 @@ namespace System.Reflection.Emit if (s_anonymouslyHostedDynamicMethodsModule != null) return s_anonymouslyHostedDynamicMethodsModule; - ConstructorInfo transparencyCtor = typeof(SecurityTransparentAttribute).GetConstructor(Type.EmptyTypes); - CustomAttributeBuilder transparencyAttribute = new CustomAttributeBuilder(transparencyCtor, Array.Empty<object>()); - List<CustomAttributeBuilder> assemblyAttributes = new List<CustomAttributeBuilder>(); - assemblyAttributes.Add(transparencyAttribute); - AssemblyName assemblyName = new AssemblyName("Anonymously Hosted DynamicMethods Assembly"); StackCrawlMark stackMark = StackCrawlMark.LookForMe; @@ -247,9 +242,7 @@ namespace System.Reflection.Emit assemblyName, AssemblyBuilderAccess.Run, ref stackMark, - assemblyAttributes); - - AppDomain.PublishAnonymouslyHostedDynamicMethodsAssembly(assembly.GetNativeHandle()); + null); // this always gets the internal module. s_anonymouslyHostedDynamicMethodsModule = (InternalModuleBuilder)assembly.ManifestModule; diff --git a/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs index f6f27b0b2b..e003ce2fad 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs @@ -148,7 +148,7 @@ namespace System.Runtime.Loader public bool IsCollectible { get; } [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern void LoadFromPath(IntPtr ptrNativeAssemblyLoadContet, string ilPath, string niPath, ObjectHandleOnStack retAssembly); + private static extern void LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, string ilPath, string niPath, ObjectHandleOnStack retAssembly); [MethodImpl(MethodImplOptions.InternalCall)] public static extern Assembly[] GetLoadedAssemblies(); @@ -382,9 +382,7 @@ namespace System.Runtime.Loader public Assembly LoadFromAssemblyName(AssemblyName assemblyName) { // Attempt to load the assembly, using the same ordering as static load, in the current load context. - Assembly loadedAssembly = Assembly.Load(assemblyName, m_pNativeAssemblyLoadContext); - - return loadedAssembly; + return Assembly.Load(assemblyName, m_pNativeAssemblyLoadContext); } [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] @@ -611,6 +609,4 @@ namespace System.Runtime.Loader return null; } } - } - diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs index 3acb1a01d7..b942ecbc28 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs @@ -276,7 +276,7 @@ namespace System.Threading.Tasks private static ulong GetOperationId(uint taskId) { - return (((ulong)AppDomain.CurrentDomain.Id) << 32) + taskId; + return (((ulong)Thread.GetDomainID()) << 32) + taskId; } } } diff --git a/src/binder/assemblybinder.cpp b/src/binder/assemblybinder.cpp index 85005be3a0..203e1c1f93 100644 --- a/src/binder/assemblybinder.cpp +++ b/src/binder/assemblybinder.cpp @@ -54,9 +54,6 @@ extern HRESULT RuntimeInvokeHostAssemblyResolver(INT_PTR pManagedAssemblyLoadCon IAssemblyName *pIAssemblyName, CLRPrivBinderCoreCLR *pTPABinder, BINDER_SPACE::AssemblyName *pAssemblyName, ICLRPrivAssembly **ppLoadedAssembly); -// Helper to check if we have a host assembly resolver set -extern BOOL RuntimeCanUseAppPathAssemblyResolver(DWORD adid); - #endif // !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) namespace BINDER_SPACE @@ -1402,149 +1399,142 @@ namespace BINDER_SPACE // We either didn't find a candidate, or the ref-def failed. Either way; fall back to app path probing. } - bool fUseAppPathsBasedResolver = !excludeAppPaths; - -#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) - // If Host Assembly Resolver is specified, then we will use that as the override for the default resolution mechanism (that uses AppPath probing). - if (fUseAppPathsBasedResolver && !RuntimeCanUseAppPathAssemblyResolver(pApplicationContext->GetAppDomainId())) - { - fUseAppPathsBasedResolver = false; - } -#endif // !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) - - // This loop executes twice max. First time through we probe AppNiPaths, the second time we probe AppPaths - bool parseNiPaths = true; - while (fUseAppPathsBasedResolver) + if (!excludeAppPaths) { - StringArrayList *pBindingPaths = parseNiPaths ? pApplicationContext->GetAppNiPaths() : pApplicationContext->GetAppPaths(); - - // Loop through the binding paths looking for a matching assembly - for (DWORD i = 0; i < pBindingPaths->GetCount(); i++) + // This loop executes twice max. First time through we probe AppNiPaths, the second time we probe AppPaths + bool parseAppNiPaths = true; + for (;;) { - ReleaseHolder<Assembly> pAssembly; - LPCWSTR wszBindingPath = (*pBindingPaths)[i]; - - SString &simpleName = pRequestedAssemblyName->GetSimpleName(); + StringArrayList *pBindingPaths = parseAppNiPaths ? pApplicationContext->GetAppNiPaths() : pApplicationContext->GetAppPaths(); - // Look for a matching dll first - hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); - + // Loop through the binding paths looking for a matching assembly + for (DWORD i = 0; i < pBindingPaths->GetCount(); i++) { - SString fileName(wszBindingPath); - CombinePath(fileName, simpleName, fileName); - if (parseNiPaths) - { - fileName.Append(W(".ni.dll")); - hr = GetAssembly(fileName, - fInspectionOnly, - FALSE, /* fIsInGAC */ - TRUE /* fExplicitBindToNativeImage */, - &pAssembly); - } - else + ReleaseHolder<Assembly> pAssembly; + LPCWSTR wszBindingPath = (*pBindingPaths)[i]; + + SString &simpleName = pRequestedAssemblyName->GetSimpleName(); + + // Look for a matching dll first + hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); + { - if (FAILED(hr)) + SString fileName(wszBindingPath); + CombinePath(fileName, simpleName, fileName); + if (parseAppNiPaths) { - fileName.Append(W(".dll")); - + fileName.Append(W(".ni.dll")); hr = GetAssembly(fileName, - fInspectionOnly, - FALSE, /* fIsInGAC */ - FALSE /* fExplicitBindToNativeImage */, - &pAssembly); + fInspectionOnly, + FALSE, /* fIsInGAC */ + TRUE /* fExplicitBindToNativeImage */, + &pAssembly); } - } - } - - if (FAILED(hr)) - { - SString fileName(wszBindingPath); - CombinePath(fileName, simpleName, fileName); + else + { + if (FAILED(hr)) + { + fileName.Append(W(".dll")); - if (parseNiPaths) - { - fileName.Append(W(".ni.exe")); - hr = GetAssembly(fileName, - fInspectionOnly, - FALSE, /* fIsInGAC */ - TRUE /* fExplicitBindToNativeImage */, - &pAssembly); + hr = GetAssembly(fileName, + fInspectionOnly, + FALSE, /* fIsInGAC */ + FALSE /* fExplicitBindToNativeImage */, + &pAssembly); + } + } } - else + + if (FAILED(hr)) { - if (FAILED(hr)) - { - fileName.Append(W(".exe")); + SString fileName(wszBindingPath); + CombinePath(fileName, simpleName, fileName); + if (parseAppNiPaths) + { + fileName.Append(W(".ni.exe")); hr = GetAssembly(fileName, - fInspectionOnly, - FALSE, /* fIsInGAC */ - FALSE /* fExplicitBindToNativeImage */, - &pAssembly); + fInspectionOnly, + FALSE, /* fIsInGAC */ + TRUE /* fExplicitBindToNativeImage */, + &pAssembly); + } + else + { + if (FAILED(hr)) + { + fileName.Append(W(".exe")); + + hr = GetAssembly(fileName, + fInspectionOnly, + FALSE, /* fIsInGAC */ + FALSE /* fExplicitBindToNativeImage */, + &pAssembly); + } } } - } - - // Since we're probing, file not founds are ok and we should just try another - // probing path - if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) - { - continue; - } - IF_FAIL_GO(hr); - // We found a candidate. - // - // Below this point, we either establish that the ref-def matches, or - // we fail the bind. + // Since we're probing, file not founds are ok and we should just try another + // probing path + if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) + { + continue; + } + IF_FAIL_GO(hr); - // Compare requested AssemblyName with that from the candidate assembly - if (TestCandidateRefMatchesDef(pApplicationContext, pRequestedAssemblyName, pAssembly->GetAssemblyName(), false /*tpaListAssembly*/)) - { - // At this point, we have found an assembly with the expected name in the App paths. If this was also found on TPA, - // make sure that the app assembly has the same fullname (excluding version) as the TPA version. If it does, then - // we should bind to the TPA assembly. If it does not, then bind to the app assembly since it has a different fullname than the - // TPA assembly. - if (fPartialMatchOnTpa) + // We found a candidate. + // + // Below this point, we either establish that the ref-def matches, or + // we fail the bind. + + // Compare requested AssemblyName with that from the candidate assembly + if (TestCandidateRefMatchesDef(pApplicationContext, pRequestedAssemblyName, pAssembly->GetAssemblyName(), false /*tpaListAssembly*/)) { - if (TestCandidateRefMatchesDef(pApplicationContext, pAssembly->GetAssemblyName(), pTPAAssembly->GetAssemblyName(), true /*tpaListAssembly*/)) + // At this point, we have found an assembly with the expected name in the App paths. If this was also found on TPA, + // make sure that the app assembly has the same fullname (excluding version) as the TPA version. If it does, then + // we should bind to the TPA assembly. If it does not, then bind to the app assembly since it has a different fullname than the + // TPA assembly. + if (fPartialMatchOnTpa) { - // Fullname (SimpleName+Culture+PKT) matched for TPA and app assembly - so bind to TPA instance. - pBindResult->SetResult(pTPAAssembly); - GO_WITH_HRESULT(S_OK); + if (TestCandidateRefMatchesDef(pApplicationContext, pAssembly->GetAssemblyName(), pTPAAssembly->GetAssemblyName(), true /*tpaListAssembly*/)) + { + // Fullname (SimpleName+Culture+PKT) matched for TPA and app assembly - so bind to TPA instance. + pBindResult->SetResult(pTPAAssembly); + GO_WITH_HRESULT(S_OK); + } + else + { + // Fullname (SimpleName+Culture+PKT) did not match for TPA and app assembly - so bind to app instance. + pBindResult->SetResult(pAssembly); + GO_WITH_HRESULT(S_OK); + } } else { - // Fullname (SimpleName+Culture+PKT) did not match for TPA and app assembly - so bind to app instance. + // We didnt see this assembly on TPA - so simply bind to the app instance. pBindResult->SetResult(pAssembly); GO_WITH_HRESULT(S_OK); } } - else - { - // We didnt see this assembly on TPA - so simply bind to the app instance. - pBindResult->SetResult(pAssembly); - GO_WITH_HRESULT(S_OK); - } + +#ifdef FEATURE_VERSIONING_LOG + // Log the candidates we throw out for diagnostics + IF_FAIL_GO(LogConfigurationError(pApplicationContext, + pRequestedAssemblyName, + pAssembly->GetAssemblyName())); +#endif // FEATURE_VERSIONING_LOG + + IF_FAIL_GO(FUSION_E_REF_DEF_MISMATCH); + } - #ifdef FEATURE_VERSIONING_LOG - // Log the candidates we throw out for diagnostics - IF_FAIL_GO(LogConfigurationError(pApplicationContext, - pRequestedAssemblyName, - pAssembly->GetAssemblyName())); - #endif // FEATURE_VERSIONING_LOG - - IF_FAIL_GO(FUSION_E_REF_DEF_MISMATCH); + if (!parseAppNiPaths) + { + break; + } + parseAppNiPaths = false; } - - if (!parseNiPaths) - { - break; - } - - parseNiPaths = false; } } diff --git a/src/inc/cor.h b/src/inc/cor.h index a050eb42aa..3494b05e4f 100644 --- a/src/inc/cor.h +++ b/src/inc/cor.h @@ -1956,7 +1956,6 @@ typedef enum nltAnsi = 2, // ansi keyword specified nltUnicode = 3, // unicode keyword specified nltAuto = 4, // auto keyword specified - nltOle = 5, // ole keyword specified nltMaxValue = 7, // used so we can assert how many bits are required for this enum } CorNativeLinkType; diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index 509b4849bf..54f66ca03f 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -1122,6 +1122,52 @@ void AppDomain::RegisterLoaderAllocatorForDeletion(LoaderAllocator * pLoaderAllo m_pDelayedLoaderAllocatorUnloadList = pLoaderAllocator; } +void AppDomain::SetNativeDllSearchDirectories(LPCWSTR wszNativeDllSearchDirectories) +{ + STANDARD_VM_CONTRACT; + + SString sDirectories(wszNativeDllSearchDirectories); + + if (sDirectories.GetCount() > 0) + { + SString::CIterator start = sDirectories.Begin(); + SString::CIterator itr = sDirectories.Begin(); + SString::CIterator end = sDirectories.End(); + SString qualifiedPath; + + while (itr != end) + { + start = itr; + BOOL found = sDirectories.Find(itr, PATH_SEPARATOR_CHAR_W); + if (!found) + { + itr = end; + } + + SString qualifiedPath(sDirectories, start, itr); + + if (found) + { + itr++; + } + + unsigned len = qualifiedPath.GetCount(); + + if (len > 0) + { + if (qualifiedPath[len - 1] != DIRECTORY_SEPARATOR_CHAR_W) + { + qualifiedPath.Append(DIRECTORY_SEPARATOR_CHAR_W); + } + + NewHolder<SString> stringHolder(new SString(qualifiedPath)); + IfFailThrow(m_NativeDllSearchDirectories.Append(stringHolder.GetValue())); + stringHolder.SuppressRelease(); + } + } + } +} + void AppDomain::ShutdownNativeDllSearchDirectories() { LIMITED_METHOD_CONTRACT; @@ -3548,8 +3594,6 @@ AppDomain::AppDomain() m_pRootAssembly = NULL; - m_pwDynamicDir = NULL; - m_dwFlags = 0; m_pDefaultContext = NULL; #ifdef FEATURE_COMINTEROP @@ -3578,7 +3622,6 @@ AppDomain::AppDomain() #endif m_pRefClassFactHash = NULL; - m_anonymouslyHostedDynamicMethodsAssembly = NULL; m_ReversePInvokeCanEnter=TRUE; m_ForceTrivialWaitOperations = false; @@ -3611,8 +3654,6 @@ AppDomain::AppDomain() m_pDomainFileWithNativeImageList = NULL; #endif - m_fIsBindingModelLocked.Store(FALSE); - } // AppDomain::AppDomain AppDomain::~AppDomain() @@ -3795,16 +3836,8 @@ void AppDomain::Init() m_ExposedObject = CreateHandle(NULL); - // Create the Application Security Descriptor - COUNTER_ONLY(GetPerfCounters().m_Loading.cAppDomains++); -#ifdef FEATURE_COMINTEROP - if (!AppX::IsAppXProcess()) - { - } -#endif //FEATURE_COMINTEROP - #ifdef FEATURE_TIERED_COMPILATION m_tieredCompilationManager.Init(GetId()); #endif @@ -5505,12 +5538,6 @@ void AppDomain::SetFriendlyName(LPCWSTR pwzFriendlyName, BOOL fDebuggerCares/*=T } } -void AppDomain::ResetFriendlyName(BOOL fDebuggerCares/*=TRUE*/) -{ - WRAPPER_NO_CONTRACT; - SetFriendlyName(NULL, fDebuggerCares); -} - LPCWSTR AppDomain::GetFriendlyName(BOOL fDebuggerCares/*=TRUE*/) { CONTRACT (LPCWSTR) @@ -5849,7 +5876,7 @@ BOOL AppDomain::PostBindResolveAssembly(AssemblySpec *pPrePolicySpec, (hrBindResult == FUSION_E_REF_DEF_MISMATCH) || (hrBindResult == FUSION_E_INVALID_NAME)) { - result = TryResolveAssembly(*ppFailedSpec, FALSE /* fPreBind */); + result = TryResolveAssembly(*ppFailedSpec); if (result != NULL && pPrePolicySpec->CanUseWithBindingCache() && result->CanUseWithBindingCache()) { @@ -6438,7 +6465,7 @@ EndTry2:; -PEAssembly *AppDomain::TryResolveAssembly(AssemblySpec *pSpec, BOOL fPreBind) +PEAssembly *AppDomain::TryResolveAssembly(AssemblySpec *pSpec) { STATIC_CONTRACT_THROWS; STATIC_CONTRACT_GC_TRIGGERS; @@ -6448,7 +6475,7 @@ PEAssembly *AppDomain::TryResolveAssembly(AssemblySpec *pSpec, BOOL fPreBind) EX_TRY { - result = pSpec->ResolveAssemblyFile(this, fPreBind); + result = pSpec->ResolveAssemblyFile(this); } EX_HOOK { @@ -7779,8 +7806,7 @@ Assembly* AppDomain::RaiseResourceResolveEvent(DomainAssembly* pAssembly, LPCSTR Assembly * AppDomain::RaiseAssemblyResolveEvent( - AssemblySpec * pSpec, - BOOL fPreBind) + AssemblySpec * pSpec) { CONTRACT(Assembly*) { @@ -7792,19 +7818,8 @@ AppDomain::RaiseAssemblyResolveEvent( } CONTRACT_END; - BinderMethodID methodId; StackSString ssName; pSpec->GetFileOrDisplayName(0, ssName); - - if (!fPreBind) - { - methodId = METHOD__APP_DOMAIN__ON_ASSEMBLY_RESOLVE; // post-bind execution event (the classic V1.0 event) - } - else - { - RETURN NULL; - } - // 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 @@ -7829,11 +7844,10 @@ AppDomain::RaiseAssemblyResolveEvent( { if (pSpec->GetParentAssembly() != NULL) { - { - gc.AssemblyRef=pSpec->GetParentAssembly()->GetExposedAssemblyObject(); - } + gc.AssemblyRef=pSpec->GetParentAssembly()->GetExposedAssemblyObject(); } - MethodDescCallSite onAssemblyResolve(methodId, &gc.AppDomainRef); + + MethodDescCallSite onAssemblyResolve(METHOD__APP_DOMAIN__ON_ASSEMBLY_RESOLVE, &gc.AppDomainRef); gc.str = StringObject::NewString(ssName); ARG_SLOT args[3] = { @@ -8285,66 +8299,6 @@ BOOL AppDomain::IsImageFromTrustedPath(PEImage* pPEImage) #if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) -// Returns a BOOL indicating if the binding model has been locked for the AppDomain -BOOL AppDomain::IsBindingModelLocked() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - return m_fIsBindingModelLocked.Load(); -} - -// Marks the binding model locked for AppDomain -BOOL AppDomain::LockBindingModel() -{ - LIMITED_METHOD_CONTRACT; - - BOOL fDidWeLockBindingModel = FALSE; - - if (InterlockedCompareExchangeT<BOOL>(&m_fIsBindingModelLocked, TRUE, FALSE) == FALSE) - { - fDidWeLockBindingModel = TRUE; - } - - return fDidWeLockBindingModel; -} - -BOOL AppDomain::IsHostAssemblyResolverInUse() -{ - LIMITED_METHOD_CONTRACT; - - return (GetFusionContext() != GetTPABinderContext()); -} - -// Helper used by the assembly binder to check if the specified AppDomain can use apppath assembly resolver -BOOL RuntimeCanUseAppPathAssemblyResolver(DWORD adid) -{ - CONTRACTL - { - NOTHROW; // Cannot throw since it is invoked by the Binder that expects to get a hresult - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - ADID id(adid); - - // We need to be in COOP mode to get the AppDomain* - GCX_COOP(); - - AppDomain *pTargetDomain = SystemDomain::GetAppDomainFromId(id, ADV_CURRENTAD); - _ASSERTE(pTargetDomain != NULL); - - pTargetDomain->LockBindingModel(); - - return !pTargetDomain->IsHostAssemblyResolverInUse(); -} - // Returns S_OK if the assembly was successfully loaded HRESULT RuntimeInvokeHostAssemblyResolver(INT_PTR pManagedAssemblyLoadContextToBindWithin, IAssemblyName *pIAssemblyName, CLRPrivBinderCoreCLR *pTPABinder, BINDER_SPACE::AssemblyName *pAssemblyName, ICLRPrivAssembly **ppLoadedAssembly) { @@ -8935,7 +8889,7 @@ void AppDomain::UnPublishHostedAssembly( } #if defined(FEATURE_COMINTEROP) -HRESULT AppDomain::SetWinrtApplicationContext(SString &appLocalWinMD) +HRESULT AppDomain::SetWinrtApplicationContext(LPCWSTR pwzAppLocalWinMD) { STANDARD_VM_CONTRACT; @@ -8946,7 +8900,7 @@ HRESULT AppDomain::SetWinrtApplicationContext(SString &appLocalWinMD) BINDER_SPACE::ApplicationContext *pApplicationContext = GetTPABinderContext()->GetAppContext(); _ASSERTE(pApplicationContext != NULL); - return m_pWinRtBinder->SetApplicationContext(pApplicationContext, appLocalWinMD); + return m_pWinRtBinder->SetApplicationContext(pApplicationContext, pwzAppLocalWinMD); } #endif // FEATURE_COMINTEROP @@ -8996,8 +8950,7 @@ void ZapperSetBindingPaths(ICorCompilationDomain *pDomain, SString &trustedPlatf _ASSERTE(pBinder != NULL); pBinder->SetupBindingPaths(trustedPlatformAssemblies, platformResourceRoots, appPaths, appNiPaths); #ifdef FEATURE_COMINTEROP - SString emptString; - ((CompilationDomain*)pDomain)->SetWinrtApplicationContext(emptString); + ((CompilationDomain*)pDomain)->SetWinrtApplicationContext(NULL); #endif } diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp index 4163c306d9..cb9cab2fb4 100644 --- a/src/vm/appdomain.hpp +++ b/src/vm/appdomain.hpp @@ -1823,7 +1823,7 @@ public: void Init(); #if defined(FEATURE_COMINTEROP) - HRESULT SetWinrtApplicationContext(SString &appLocalWinMD); + HRESULT SetWinrtApplicationContext(LPCWSTR pwzAppLocalWinMD); #endif // FEATURE_COMINTEROP bool MustForceTrivialWaitOperations(); @@ -2157,7 +2157,6 @@ public: return dac_cast<PTR_SString>(m_i.GetElement()); } }; - BOOL BindingByManifestFile(); PathIterator IterateNativeDllSearchDirectories(); void SetNativeDllSearchDirectories(LPCWSTR paths); @@ -2274,7 +2273,6 @@ public: PVOID GetFriendlyNameNoSet(bool* isUtf8); #endif void SetFriendlyName(LPCWSTR pwzFriendlyName, BOOL fDebuggerCares = TRUE); - void ResetFriendlyName(BOOL fDebuggerCares = TRUE); //**************************************************************************************** @@ -2300,7 +2298,7 @@ public: PEAssembly ** ppAssembly) DAC_EMPTY_RET(S_OK); - PEAssembly *TryResolveAssembly(AssemblySpec *pSpec, BOOL fPreBind); + PEAssembly *TryResolveAssembly(AssemblySpec *pSpec); // Store a successful binding into the cache. This will keep the file from // being physically unmapped, as well as shortcutting future attempts to bind @@ -2512,37 +2510,6 @@ public: IUnknown *CreateFusionContext(); -#ifdef FEATURE_PREJIT - CorCompileConfigFlags GetNativeConfigFlags(); -#endif // FEATURE_PREJIT - - //**************************************************************************************** - // Create a domain context rooted at the fileName. The directory containing the file name - // is the application base and the configuration file is the fileName appended with - // .config. If no name is passed in then no domain is created. - static AppDomain* CreateDomainContext(LPCWSTR fileName); - - // Sets up the current domain's fusion context based on the given exe file name - // (app base & config file) - void SetupExecutableFusionContext(LPCWSTR exePath); - - //**************************************************************************************** - // Manage a pool of asyncrhonous objects used to fetch assemblies. When a sink is released - // it places itself back on the pool list. Only one object is kept in the pool. - void SetIsUserCreatedDomain() - { - LIMITED_METHOD_CONTRACT; - - m_dwFlags |= USER_CREATED_DOMAIN; - } - - BOOL IsUserCreatedDomain() - { - LIMITED_METHOD_CONTRACT; - - return (m_dwFlags & USER_CREATED_DOMAIN); - } - void SetIgnoreUnhandledExceptions() { LIMITED_METHOD_CONTRACT; @@ -2561,7 +2528,7 @@ public: { LIMITED_METHOD_CONTRACT; - m_dwFlags |= (COMPILATION_DOMAIN); + m_dwFlags |= COMPILATION_DOMAIN; } BOOL IsCompilationDomain(); @@ -2657,20 +2624,6 @@ public: return m_Stage >= STAGE_READYFORMANAGEDCODE; } - void SetAnonymouslyHostedDynamicMethodsAssembly(DomainAssembly * pDomainAssembly) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(pDomainAssembly != NULL); - _ASSERTE(m_anonymouslyHostedDynamicMethodsAssembly == NULL); - m_anonymouslyHostedDynamicMethodsAssembly = pDomainAssembly; - } - - DomainAssembly * GetAnonymouslyHostedDynamicMethodsAssembly() - { - LIMITED_METHOD_CONTRACT; - return m_anonymouslyHostedDynamicMethodsAssembly; - } - static void RefTakerAcquire(AppDomain* pDomain) { WRAPPER_NO_CONTRACT; @@ -2788,7 +2741,7 @@ public: static void RaiseExitProcessEvent(); Assembly* RaiseResourceResolveEvent(DomainAssembly* pAssembly, LPCSTR szName); DomainAssembly* RaiseTypeResolveEventThrowing(DomainAssembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef); - Assembly* RaiseAssemblyResolveEvent(AssemblySpec *pSpec, BOOL fPreBind); + Assembly* RaiseAssemblyResolveEvent(AssemblySpec *pSpec); private: CrstExplicitInit m_ReflectionCrst; @@ -2968,8 +2921,6 @@ public: protected: #endif // FEATURE_COMINTEROP - LPWSTR m_pwDynamicDir; - private: void RaiseLoadingAssemblyEvent(DomainAssembly* pAssembly); @@ -3155,8 +3106,6 @@ private: ArrayList m_failedAssemblies; - DomainAssembly * m_anonymouslyHostedDynamicMethodsAssembly; - #ifdef _DEBUG Volatile<LONG> m_dwIterHolders; Volatile<LONG> m_dwRefTakers; @@ -3213,24 +3162,11 @@ private: public: -private: - Volatile<BOOL> m_fIsBindingModelLocked; -public: - BOOL IsHostAssemblyResolverInUse(); - BOOL IsBindingModelLocked(); - BOOL LockBindingModel(); - enum { CONTEXT_INITIALIZED = 0x0001, - USER_CREATED_DOMAIN = 0x0002, // created by call to AppDomain.CreateDomain - ALLOCATEDCOM = 0x0008, LOAD_SYSTEM_ASSEMBLY_EVENT_SENT = 0x0040, COMPILATION_DOMAIN = 0x0400, // Are we ngenning? IGNORE_UNHANDLED_EXCEPTIONS = 0x10000, // AppDomain was created using the APPDOMAIN_IGNORE_UNHANDLED_EXCEPTIONS flag - ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP = 0x20000, // AppDomain was created using the APPDOMAIN_ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP flag - ENABLE_SKIP_PLAT_CHECKS = 0x200000, // Skip various assembly checks (like platform check) - ENABLE_ASSEMBLY_LOADFILE = 0x400000, // Allow Assembly.LoadFile in CoreCLR - DISABLE_TRANSPARENCY_ENFORCEMENT= 0x800000, // Disable enforcement of security transparency rules }; AssemblySpecBindingCache m_AssemblyCache; diff --git a/src/vm/appdomainnative.cpp b/src/vm/appdomainnative.cpp index c2cc06a748..bbc5817b8c 100644 --- a/src/vm/appdomainnative.cpp +++ b/src/vm/appdomainnative.cpp @@ -19,120 +19,6 @@ #include "clr/fs/path.h" using namespace clr::fs; -//************************************************************************ -inline AppDomain *AppDomainNative::ValidateArg(APPDOMAINREF pThis) -{ - CONTRACTL - { - MODE_COOPERATIVE; - DISABLED(GC_TRIGGERS); // can't use this in an FCALL because we're in forbid gc mode until we setup a H_M_F. - THROWS; - } - CONTRACTL_END; - - if (pThis == NULL) - { - COMPlusThrow(kNullReferenceException, W("NullReference_This")); - } - - // Should not get here with a Transparent proxy for the this pointer - - // should have always called through onto the real object - - AppDomain* pDomain = (AppDomain*)pThis->GetDomain(); - - if(!pDomain) - { - COMPlusThrow(kNullReferenceException, W("NullReference_This")); - } - - // can only be accessed from within current domain - _ASSERTE(GetAppDomain() == pDomain); - - // should not get here with an invalid appdomain. Once unload it, we won't let anyone else - // in and any threads that are already in will be unwound. - _ASSERTE(SystemDomain::GetAppDomainAtIndex(pDomain->GetIndex()) != NULL); - return pDomain; -} - -FCIMPL2(void, AppDomainNative::SetupFriendlyName, AppDomainBaseObject* refThisUNSAFE, StringObject* strFriendlyNameUNSAFE) -{ - FCALL_CONTRACT; - - struct _gc - { - APPDOMAINREF refThis; - STRINGREF strFriendlyName; - } gc; - - gc.refThis = (APPDOMAINREF) refThisUNSAFE; - gc.strFriendlyName = (STRINGREF) strFriendlyNameUNSAFE; - - HELPER_METHOD_FRAME_BEGIN_PROTECT(gc) - - AppDomainRefHolder pDomain(ValidateArg(gc.refThis)); - pDomain->AddRef(); - - // If the user created this domain, need to know this so the debugger doesn't - // go and reset the friendly name that was provided. - pDomain->SetIsUserCreatedDomain(); - - WCHAR* pFriendlyName = NULL; - Thread *pThread = GetThread(); - - CheckPointHolder cph(pThread->m_MarshalAlloc.GetCheckpoint()); //hold checkpoint for autorelease - if (gc.strFriendlyName != NULL) { - WCHAR* pString = NULL; - int iString; - gc.strFriendlyName->RefInterpretGetStringValuesDangerousForGC(&pString, &iString); - if (ClrSafeInt<int>::addition(iString, 1, iString)) - { - pFriendlyName = new (&pThread->m_MarshalAlloc) WCHAR[(iString)]; - - // Check for a valid string allocation - if (pFriendlyName == (WCHAR*)-1) - pFriendlyName = NULL; - else - memcpy(pFriendlyName, pString, iString*sizeof(WCHAR)); - } - } - - pDomain->SetFriendlyName(pFriendlyName); - - HELPER_METHOD_FRAME_END(); -} -FCIMPLEND - -void QCALLTYPE AppDomainNative::SetupBindingPaths(__in_z LPCWSTR wszTrustedPlatformAssemblies, __in_z LPCWSTR wszPlatformResourceRoots, __in_z LPCWSTR wszAppPaths, __in_z LPCWSTR wszAppNiPaths, __in_z LPCWSTR appLocalWinMD) -{ - QCALL_CONTRACT; - - BEGIN_QCALL; - - AppDomain* pDomain = GetAppDomain(); - - SString sTrustedPlatformAssemblies(wszTrustedPlatformAssemblies); - SString sPlatformResourceRoots(wszPlatformResourceRoots); - SString sAppPaths(wszAppPaths); - SString sAppNiPaths(wszAppNiPaths); - SString sappLocalWinMD(appLocalWinMD); - - CLRPrivBinderCoreCLR *pBinder = pDomain->GetTPABinderContext(); - _ASSERTE(pBinder != NULL); - IfFailThrow(pBinder->SetupBindingPaths(sTrustedPlatformAssemblies, - sPlatformResourceRoots, - sAppPaths, - sAppNiPaths)); - -#ifdef FEATURE_COMINTEROP - if (WinRTSupported()) - { - pDomain->SetWinrtApplicationContext(sappLocalWinMD); - } -#endif - - END_QCALL; -} - FCIMPL3(Object*, AppDomainNative::CreateDynamicAssembly, AssemblyNameBaseObject* assemblyNameUNSAFE, StackCrawlMark* stackMark, INT32 access) { FCALL_CONTRACT; @@ -253,26 +139,6 @@ FCIMPL0(Object*, AppDomainNative::GetLoadedAssemblies) } // AppDomainNative::GetAssemblies FCIMPLEND -FCIMPL1(INT32, AppDomainNative::GetId, AppDomainBaseObject* refThisUNSAFE) -{ - FCALL_CONTRACT; - - INT32 iRetVal = 0; - APPDOMAINREF refThis = (APPDOMAINREF) refThisUNSAFE; - - HELPER_METHOD_FRAME_BEGIN_RET_1(refThis); - - AppDomain* pApp = ValidateArg(refThis); - // can only be accessed from within current domain - _ASSERTE(GetThread()->GetDomain() == pApp); - - iRetVal = pApp->GetId().m_dwId; - - HELPER_METHOD_FRAME_END(); - return iRetVal; -} -FCIMPLEND - FCIMPL1(Object*, AppDomainNative::IsStringInterned, StringObject* pStringUNSAFE) { FCALL_CONTRACT; @@ -318,210 +184,3 @@ FCIMPL1(Object*, AppDomainNative::GetOrInternString, StringObject* pStringUNSAFE return OBJECTREFToObject(refRetVal); } FCIMPLEND - -FCIMPL1(UINT32, AppDomainNative::GetAppDomainId, AppDomainBaseObject* refThisUNSAFE) -{ - FCALL_CONTRACT; - - FCUnique(0x91); - - UINT32 retVal = 0; - APPDOMAINREF domainRef = (APPDOMAINREF) refThisUNSAFE; - - HELPER_METHOD_FRAME_BEGIN_RET_1(domainRef); - - AppDomain* pDomain = ValidateArg(domainRef); - retVal = pDomain->GetId().m_dwId; - - HELPER_METHOD_FRAME_END(); - return retVal; -} -FCIMPLEND - -FCIMPL1(void , AppDomainNative::PublishAnonymouslyHostedDynamicMethodsAssembly, AssemblyBaseObject * pAssemblyUNSAFE); -{ - CONTRACTL - { - FCALL_CHECK; - } - CONTRACTL_END; - - ASSEMBLYREF refAssembly = (ASSEMBLYREF)ObjectToOBJECTREF(pAssemblyUNSAFE); - if (refAssembly == NULL) - FCThrowResVoid(kArgumentNullException, W("Arg_InvalidHandle")); - - DomainAssembly* pDomainAssembly = refAssembly->GetDomainAssembly(); - - pDomainAssembly->GetAppDomain()->SetAnonymouslyHostedDynamicMethodsAssembly(pDomainAssembly); -} -FCIMPLEND - - -void QCALLTYPE AppDomainNative::SetNativeDllSearchDirectories(__in_z LPCWSTR wszNativeDllSearchDirectories) -{ - CONTRACTL - { - QCALL_CHECK; - PRECONDITION(CheckPointer(wszNativeDllSearchDirectories)); - } - CONTRACTL_END; - - BEGIN_QCALL; - AppDomain *pDomain = GetAppDomain(); - - SString sDirectories(wszNativeDllSearchDirectories); - - if(sDirectories.GetCount() > 0) - { - SString::CIterator start = sDirectories.Begin(); - SString::CIterator itr = sDirectories.Begin(); - SString::CIterator end = sDirectories.End(); - SString qualifiedPath; - - while (itr != end) - { - start = itr; - BOOL found = sDirectories.Find(itr, PATH_SEPARATOR_CHAR_W); - if (!found) - { - itr = end; - } - - SString qualifiedPath(sDirectories,start,itr); - - if (found) - { - itr++; - } - - unsigned len = qualifiedPath.GetCount(); - - if (len > 0) - { - if (qualifiedPath[len - 1] != DIRECTORY_SEPARATOR_CHAR_W) - { - qualifiedPath.Append(DIRECTORY_SEPARATOR_CHAR_W); - } - - NewHolder<SString> stringHolder (new SString(qualifiedPath)); - IfFailThrow(pDomain->m_NativeDllSearchDirectories.Append(stringHolder.GetValue())); - stringHolder.SuppressRelease(); - } - } - } - END_QCALL; -} - - -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING -FCIMPL0(void, AppDomainNative::EnableMonitoring) -{ - FCALL_CONTRACT; - - HELPER_METHOD_FRAME_BEGIN_0(); - - EnableARM(); - - HELPER_METHOD_FRAME_END(); -} -FCIMPLEND - -FCIMPL0(FC_BOOL_RET, AppDomainNative::MonitoringIsEnabled) -{ - FCALL_CONTRACT; - - FC_GC_POLL_NOT_NEEDED(); - - FC_RETURN_BOOL(g_fEnableARM); -} -FCIMPLEND - -FCIMPL1(INT64, AppDomainNative::GetTotalProcessorTime, AppDomainBaseObject* refThisUNSAFE) -{ - FCALL_CONTRACT; - - INT64 i64RetVal = -1; - - if (g_fEnableARM) - { - APPDOMAINREF refThis = (APPDOMAINREF) refThisUNSAFE; - HELPER_METHOD_FRAME_BEGIN_RET_1(refThis); - - AppDomain* pDomain = ValidateArg(refThis); - // can only be accessed from within current domain - _ASSERTE(GetThread()->GetDomain() == pDomain); - - i64RetVal = (INT64)pDomain->QueryProcessorUsage(); - - HELPER_METHOD_FRAME_END(); - } - - return i64RetVal; -} -FCIMPLEND - -FCIMPL1(INT64, AppDomainNative::GetTotalAllocatedMemorySize, AppDomainBaseObject* refThisUNSAFE) -{ - FCALL_CONTRACT; - - INT64 i64RetVal = -1; - - if (g_fEnableARM) - { - APPDOMAINREF refThis = (APPDOMAINREF) refThisUNSAFE; - HELPER_METHOD_FRAME_BEGIN_RET_1(refThis); - - AppDomain* pDomain = ValidateArg(refThis); - // can only be accessed from within current domain - _ASSERTE(GetThread()->GetDomain() == pDomain); - - i64RetVal = (INT64)pDomain->GetAllocBytes(); - - HELPER_METHOD_FRAME_END(); - } - - return i64RetVal; -} -FCIMPLEND - -FCIMPL1(INT64, AppDomainNative::GetLastSurvivedMemorySize, AppDomainBaseObject* refThisUNSAFE) -{ - FCALL_CONTRACT; - - INT64 i64RetVal = -1; - - if (g_fEnableARM) - { - APPDOMAINREF refThis = (APPDOMAINREF) refThisUNSAFE; - HELPER_METHOD_FRAME_BEGIN_RET_1(refThis); - - AppDomain* pDomain = ValidateArg(refThis); - // can only be accessed from within current domain - _ASSERTE(GetThread()->GetDomain() == pDomain); - - i64RetVal = (INT64)pDomain->GetSurvivedBytes(); - - HELPER_METHOD_FRAME_END(); - } - - return i64RetVal; -} -FCIMPLEND - -FCIMPL0(INT64, AppDomainNative::GetLastSurvivedProcessMemorySize) -{ - FCALL_CONTRACT; - - INT64 i64RetVal = -1; - - if (g_fEnableARM) - { - i64RetVal = SystemDomain::GetTotalSurvivedBytes(); - } - - return i64RetVal; - - -} -FCIMPLEND -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING diff --git a/src/vm/appdomainnative.hpp b/src/vm/appdomainnative.hpp index 464ced73e6..0e3aa0e9b3 100644 --- a/src/vm/appdomainnative.hpp +++ b/src/vm/appdomainnative.hpp @@ -20,31 +20,13 @@ class AppDomainNative { public: - static AppDomain *ValidateArg(APPDOMAINREF pThis); - static FCDECL2(void, SetupFriendlyName, AppDomainBaseObject* refThisUNSAFE, StringObject* strFriendlyNameUNSAFE); - static FCDECL3(Object*, CreateDynamicAssembly, AssemblyNameBaseObject* assemblyNameUNSAFE, StackCrawlMark* stackMark, INT32 access); static FCDECL0(Object*, GetLoadedAssemblies); static FCDECL1(Object*, GetOrInternString, StringObject* pStringUNSAFE); - static void QCALLTYPE SetupBindingPaths(__in_z LPCWSTR wszTrustedPlatformAssemblies, __in_z LPCWSTR wszPlatformResourceRoots, __in_z LPCWSTR wszAppPaths, __in_z LPCWSTR wszAppNiPaths, __in_z LPCWSTR appLocalWinMD); - static FCDECL1(INT32, GetId, AppDomainBaseObject* refThisUNSAFE); static FCDECL1(Object*, IsStringInterned, StringObject* pString); - static FCDECL1(UINT32, GetAppDomainId, AppDomainBaseObject* refThisUNSAFE); - static FCDECL1(void , PublishAnonymouslyHostedDynamicMethodsAssembly, AssemblyBaseObject * pAssemblyUNSAFE); - static void QCALLTYPE SetNativeDllSearchDirectories(__in_z LPCWSTR wszAssembly); - -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - static FCDECL0(void, EnableMonitoring); - static FCDECL0(FC_BOOL_RET, MonitoringIsEnabled); - static FCDECL1(INT64, GetTotalProcessorTime, AppDomainBaseObject* refThisUNSAFE); - static FCDECL1(INT64, GetTotalAllocatedMemorySize, AppDomainBaseObject* refThisUNSAFE); - static FCDECL1(INT64, GetLastSurvivedMemorySize, AppDomainBaseObject* refThisUNSAFE); - static FCDECL0(INT64, GetLastSurvivedProcessMemorySize); -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING #ifdef FEATURE_APPX - static - INT32 QCALLTYPE IsAppXProcess(); + static INT32 QCALLTYPE IsAppXProcess(); #endif }; diff --git a/src/vm/assembly.cpp b/src/vm/assembly.cpp index ecba83456d..2f82a97c2e 100644 --- a/src/vm/assembly.cpp +++ b/src/vm/assembly.cpp @@ -665,24 +665,6 @@ Assembly *Assembly::CreateDynamic(AppDomain *pDomain, CreateDynamicAssemblyArgs pAssem->m_isDynamic = true; - if (publicKey.GetSize() > 0) - { - // Since we have no way to validate the public key of a dynamic assembly we don't allow - // partial trust code to emit a dynamic assembly with an arbitrary public key. - // Ideally we shouldn't allow anyone to emit a dynamic assembly with only a public key, - // but we allow a couple of exceptions to reduce the compat risk: full trust, caller's own key. - // As usual we treat anonymously hosted dynamic methods as partial trust code. - DomainAssembly* pCallerDomainAssembly = pCallerAssembly->GetDomainAssembly(pCallersDomain); - if (pCallerDomainAssembly == pCallersDomain->GetAnonymouslyHostedDynamicMethodsAssembly()) - { - DWORD cbKey = 0; - const void* pKey = pCallerAssembly->GetPublicKey(&cbKey); - - if (!publicKey.Equals((const BYTE *)pKey, cbKey)) - COMPlusThrow(kInvalidOperationException, W("InvalidOperation_StrongNameKeyPairRequired")); - } - } - //we need to suppress release for pAssem to avoid double release pAssem.SuppressRelease (); diff --git a/src/vm/assemblyname.cpp b/src/vm/assemblyname.cpp index 090365f2d6..6c95d05c08 100644 --- a/src/vm/assemblyname.cpp +++ b/src/vm/assemblyname.cpp @@ -176,7 +176,7 @@ FCIMPL3(void, AssemblyNameNative::Init, Object * refThisUNSAFE, OBJECTREF * pAss } else if ((hr == FUSION_E_INVALID_NAME) && fRaiseResolveEvent) { - Assembly * pAssembly = GetAppDomain()->RaiseAssemblyResolveEvent(&spec, FALSE); + Assembly * pAssembly = GetAppDomain()->RaiseAssemblyResolveEvent(&spec); if (pAssembly == NULL) { diff --git a/src/vm/assemblyspec.cpp b/src/vm/assemblyspec.cpp index 2d3d76cf03..861b3f537d 100644 --- a/src/vm/assemblyspec.cpp +++ b/src/vm/assemblyspec.cpp @@ -723,7 +723,7 @@ void AssemblySpec::MatchPublicKeys(Assembly *pAssembly) } -PEAssembly *AssemblySpec::ResolveAssemblyFile(AppDomain *pDomain, BOOL fPreBind) +PEAssembly *AssemblySpec::ResolveAssemblyFile(AppDomain *pDomain) { CONTRACT(PEAssembly *) { @@ -740,7 +740,7 @@ PEAssembly *AssemblySpec::ResolveAssemblyFile(AppDomain *pDomain, BOOL fPreBind) if (GetName() == NULL) RETURN NULL; - Assembly *pAssembly = pDomain->RaiseAssemblyResolveEvent(this, fPreBind); + Assembly *pAssembly = pDomain->RaiseAssemblyResolveEvent(this); if (pAssembly != NULL) { PEAssembly *pFile = pAssembly->GetManifestFile(); diff --git a/src/vm/assemblyspec.hpp b/src/vm/assemblyspec.hpp index bbcc2ea2b4..5cf87f2c35 100644 --- a/src/vm/assemblyspec.hpp +++ b/src/vm/assemblyspec.hpp @@ -244,7 +244,7 @@ class AssemblySpec : public BaseAssemblySpec void MatchRetargetedPublicKeys(Assembly *pAssembly); public: void MatchPublicKeys(Assembly *pAssembly); - PEAssembly *ResolveAssemblyFile(AppDomain *pAppDomain, BOOL fPreBind); + PEAssembly *ResolveAssemblyFile(AppDomain *pAppDomain); AppDomain *GetAppDomain() { diff --git a/src/vm/clrprivbinderwinrt.cpp b/src/vm/clrprivbinderwinrt.cpp index f73d01a46d..a4d009b63e 100644 --- a/src/vm/clrprivbinderwinrt.cpp +++ b/src/vm/clrprivbinderwinrt.cpp @@ -212,8 +212,7 @@ CreateAssemblyNameObjectFromMetaData( //===================================================================================================================== HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName( IAssemblyName * pAssemblyName, - CLRPrivAssemblyWinRT ** ppAssembly, - BOOL fPreBind) + CLRPrivAssemblyWinRT ** ppAssembly) { STANDARD_VM_CONTRACT; HRESULT hr = S_OK; @@ -393,14 +392,13 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName( //===================================================================================================================== HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName( IAssemblyName * pAssemblyName, - ICLRPrivAssembly ** ppPrivAssembly, - BOOL fPreBind) + ICLRPrivAssembly ** ppPrivAssembly) { STANDARD_VM_CONTRACT; HRESULT hr = S_OK; ReleaseHolder<CLRPrivAssemblyWinRT> pWinRTAssembly; - IfFailRet(BindWinRTAssemblyByName(pAssemblyName, &pWinRTAssembly, fPreBind)); + IfFailRet(BindWinRTAssemblyByName(pAssemblyName, &pWinRTAssembly)); IfFailRet(pWinRTAssembly->QueryInterface(__uuidof(ICLRPrivAssembly), (LPVOID *)ppPrivAssembly)); return hr; @@ -409,8 +407,7 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName( //===================================================================================================================== HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName( IAssemblyName * pAssemblyName, - IBindResult ** ppIBindResult, - BOOL fPreBind) + IBindResult ** ppIBindResult) { STANDARD_VM_CONTRACT; HRESULT hr = S_OK; @@ -419,7 +416,7 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName( VALIDATE_ARG_RET(ppIBindResult != nullptr); ReleaseHolder<CLRPrivAssemblyWinRT> pWinRTAssembly; - IfFailRet(BindWinRTAssemblyByName(pAssemblyName, &pWinRTAssembly, fPreBind)); + IfFailRet(BindWinRTAssemblyByName(pAssemblyName, &pWinRTAssembly)); IfFailRet(pWinRTAssembly->GetIBindResult(ppIBindResult)); return hr; @@ -512,7 +509,7 @@ HRESULT CLRPrivBinderWinRT::GetAssemblyAndTryFindNativeImage(SString &sWinmdFile } //===================================================================================================================== -HRESULT CLRPrivBinderWinRT::SetApplicationContext(BINDER_SPACE::ApplicationContext *pApplicationContext, SString &appLocalWinMD) +HRESULT CLRPrivBinderWinRT::SetApplicationContext(BINDER_SPACE::ApplicationContext *pApplicationContext, LPCWSTR pwzAppLocalWinMD) { STANDARD_VM_CONTRACT; @@ -535,9 +532,9 @@ HRESULT CLRPrivBinderWinRT::SetApplicationContext(BINDER_SPACE::ApplicationConte m_rgAltPaths.GetRawArray() + i)); } - if (!appLocalWinMD.IsEmpty()) + if (pwzAppLocalWinMD != NULL) { - m_appLocalWinMDPath = DuplicateStringThrowing(appLocalWinMD.GetUnicode()); + m_appLocalWinMDPath = DuplicateStringThrowing(pwzAppLocalWinMD); } #else Crossgen::SetAppPaths(pAppPaths); diff --git a/src/vm/clrprivbinderwinrt.h b/src/vm/clrprivbinderwinrt.h index 2bf1061d18..3515874ce0 100644 --- a/src/vm/clrprivbinderwinrt.h +++ b/src/vm/clrprivbinderwinrt.h @@ -210,26 +210,23 @@ public: // Binds WinRT assemblies only. HRESULT BindWinRTAssemblyByName( IAssemblyName * pIAssemblyName, - CLRPrivAssemblyWinRT ** ppAssembly, - BOOL fPreBind = FALSE); + CLRPrivAssemblyWinRT ** ppAssembly); // Binds WinRT assemblies only. HRESULT BindWinRTAssemblyByName( IAssemblyName * pIAssemblyName, - ICLRPrivAssembly ** ppPrivAssembly, - BOOL fPreBind = FALSE); + ICLRPrivAssembly ** ppPrivAssembly); // Binds WinRT assemblies only. HRESULT BindWinRTAssemblyByName( IAssemblyName * pIAssemblyName, - IBindResult ** ppIBindResult, - BOOL fPreBind = FALSE); + IBindResult ** ppIBindResult); HRESULT GetAssemblyAndTryFindNativeImage(SString &sWinmdFilename, LPCWSTR pwzSimpleName, BINDER_SPACE::Assembly ** ppAssembly); // On Phone the application's APP_PATH CoreCLR hosting config property is used as the app // package graph for RoResolveNamespace to find 3rd party WinMDs. This method wires up // the app paths so the WinRT binder will find 3rd party WinMDs. - HRESULT SetApplicationContext(BINDER_SPACE::ApplicationContext *pApplicationContext, SString &appLocalWinMD); + HRESULT SetApplicationContext(BINDER_SPACE::ApplicationContext *pApplicationContext, LPCWSTR pwzAppLocalWinMD); // Finds assembly with WinRT type if it is already loaded // Note: This method could implement interface code:ICLRPrivWinRtTypeBinder if it is ever needed PTR_Assembly FindAssemblyForTypeIfLoaded( diff --git a/src/vm/comcallablewrapper.cpp b/src/vm/comcallablewrapper.cpp index 57d1ede8ff..9a17ccbcca 100644 --- a/src/vm/comcallablewrapper.cpp +++ b/src/vm/comcallablewrapper.cpp @@ -3657,37 +3657,6 @@ IUnknown * ComCallWrapper::GetComIPFromCCW_ForIntfMT_Worker( RETURN NULL; } - -//-------------------------------------------------------------------------- -// Get an interface from wrapper, based on riid or pIntfMT. The returned interface is AddRef'd. -//-------------------------------------------------------------------------- -IUnknown* ComCallWrapper::GetComIPFromCCWNoThrow(ComCallWrapper *pWrap, REFIID riid, MethodTable* pIntfMT, - GetComIPFromCCW::flags flags) -{ - CONTRACT(IUnknown*) - { - DISABLED(NOTHROW); - GC_TRIGGERS; - MODE_ANY; - PRECONDITION(CheckPointer(pWrap)); - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - } - CONTRACT_END; - - IUnknown * pUnk = NULL; - - EX_TRY - { - pUnk = GetComIPFromCCW(pWrap, riid, pIntfMT, flags); - } - EX_CATCH - { - } - EX_END_CATCH(SwallowAllExceptions); - - RETURN pUnk; -} - //-------------------------------------------------------------------------- // Get the IDispatch interface pointer for the wrapper. // The returned interface is AddRef'd. diff --git a/src/vm/comcallablewrapper.h b/src/vm/comcallablewrapper.h index e58b4c80f9..34587ac5ff 100644 --- a/src/vm/comcallablewrapper.h +++ b/src/vm/comcallablewrapper.h @@ -1335,8 +1335,6 @@ public: // Get an interface from wrapper, based on riid or pIntfMT static IUnknown* GetComIPFromCCW(ComCallWrapper *pWrap, REFIID riid, MethodTable* pIntfMT, GetComIPFromCCW::flags flags = GetComIPFromCCW::None); - static IUnknown* GetComIPFromCCWNoThrow(ComCallWrapper *pWrap, REFIID riid, MethodTable* pIntfMT, GetComIPFromCCW::flags flags = GetComIPFromCCW::None); - private: // pointer to OBJECTREF diff --git a/src/vm/comsynchronizable.h b/src/vm/comsynchronizable.h index ddd55cc21f..79c0bee667 100644 --- a/src/vm/comsynchronizable.h +++ b/src/vm/comsynchronizable.h @@ -108,8 +108,6 @@ public: #endif //FEATURE_COMINTEROP static FCDECL1(FC_BOOL_RET,IsThreadpoolThread, ThreadBaseObject* thread); - static FCDECL1(void, SetIsThreadStaticsArray, Object* pObject); - static FCDECL2(void, SetAbortReason, ThreadBaseObject* pThisUNSAFE, Object* pObject); static FCDECL1(void, ClearAbortReason, ThreadBaseObject* pThisUNSAFE); diff --git a/src/vm/corhost.cpp b/src/vm/corhost.cpp index 6519616ffe..a09752016e 100644 --- a/src/vm/corhost.cpp +++ b/src/vm/corhost.cpp @@ -694,31 +694,30 @@ HRESULT CorHost2::_CreateAppDomain( EMPTY_STRING_TO_NULL(wszAppDomainManagerAssemblyName); EMPTY_STRING_TO_NULL(wszAppDomainManagerTypeName); - if(pAppDomainID==NULL) + if (pAppDomainID==NULL) return E_POINTER; if (!m_fStarted) return HOST_E_INVALIDOPERATION; - if(wszFriendlyName == NULL) + if (wszFriendlyName == NULL) return E_INVALIDARG; - if((wszAppDomainManagerAssemblyName == NULL) != (wszAppDomainManagerTypeName == NULL)) + if ((wszAppDomainManagerAssemblyName != NULL) || (wszAppDomainManagerTypeName != NULL)) return E_INVALIDARG; BEGIN_ENTRYPOINT_NOTHROW; BEGIN_EXTERNAL_ENTRYPOINT(&hr); - GCX_COOP_THREAD_EXISTS(GET_THREAD()); AppDomain* pDomain = SystemDomain::System()->DefaultDomain(); + pDomain->SetFriendlyName(wszFriendlyName); + ETW::LoaderLog::DomainLoad(pDomain, (LPWSTR)wszFriendlyName); if (dwFlags & APPDOMAIN_IGNORE_UNHANDLED_EXCEPTIONS) - { pDomain->SetIgnoreUnhandledExceptions(); - } if (dwFlags & APPDOMAIN_FORCE_TRIVIAL_WAIT_OPERATIONS) pDomain->SetForceTrivialWaitOperations(); @@ -727,56 +726,95 @@ HRESULT CorHost2::_CreateAppDomain( { GCX_COOP(); - - struct - { - STRINGREF friendlyName; - PTRARRAYREF propertyNames; - PTRARRAYREF propertyValues; - } _gc; - ZeroMemory(&_gc,sizeof(_gc)); + MethodDescCallSite setup(METHOD__APPCONTEXT__SETUP); - GCPROTECT_BEGIN(_gc) - _gc.friendlyName=StringObject::NewString(wszFriendlyName); - - if (nProperties>0) + ARG_SLOT args[3]; + args[0] = PtrToArgSlot(pPropertyNames); + args[1] = PtrToArgSlot(pPropertyValues); + args[2] = PtrToArgSlot(nProperties); + + setup.Call(args); + } + + LPCWSTR pwzNativeDllSearchDirectories = NULL; + LPCWSTR pwzTrustedPlatformAssemblies = NULL; + LPCWSTR pwzPlatformResourceRoots = NULL; + LPCWSTR pwzAppPaths = NULL; + LPCWSTR pwzAppNiPaths = NULL; +#ifdef FEATURE_COMINTEROP + LPCWSTR pwzAppLocalWinMD = NULL; +#endif + + for (int i = 0; i < nProperties; i++) + { + if (wcscmp(pPropertyNames[i], W("NATIVE_DLL_SEARCH_DIRECTORIES")) == 0) { - _gc.propertyNames = (PTRARRAYREF) AllocateObjectArray(nProperties, g_pStringClass); - _gc.propertyValues= (PTRARRAYREF) AllocateObjectArray(nProperties, g_pStringClass); - for (int i=0;i< nProperties;i++) - { - STRINGREF obj = StringObject::NewString(pPropertyNames[i]); - _gc.propertyNames->SetAt(i, obj); - - obj = StringObject::NewString(pPropertyValues[i]); - _gc.propertyValues->SetAt(i, obj); - } + pwzNativeDllSearchDirectories = pPropertyValues[i]; } + else + if (wcscmp(pPropertyNames[i], W("TRUSTED_PLATFORM_ASSEMBLIES")) == 0) + { + pwzTrustedPlatformAssemblies = pPropertyValues[i]; + } + else + if (wcscmp(pPropertyNames[i], W("PLATFORM_RESOURCE_ROOTS")) == 0) + { + pwzPlatformResourceRoots = pPropertyValues[i]; + } + else + if (wcscmp(pPropertyNames[i], W("APP_PATHS")) == 0) + { + pwzAppPaths = pPropertyValues[i]; + } + else + if (wcscmp(pPropertyNames[i], W("APP_NI_PATHS")) == 0) + { + pwzAppNiPaths = pPropertyValues[i]; + } +#ifdef FEATURE_COMINTEROP + else + if (wcscmp(pPropertyNames[i], W("APP_LOCAL_WINMETADATA")) == 0) + { + pwzAppLocalWinMD = pPropertyValues[i]; + } +#endif + } - MethodDescCallSite setup(METHOD__APP_DOMAIN__SETUP); - - ARG_SLOT args[3]; - args[0]=ObjToArgSlot(_gc.friendlyName); - args[1]=ObjToArgSlot(_gc.propertyNames); - args[2]=ObjToArgSlot(_gc.propertyValues); + pDomain->SetNativeDllSearchDirectories(pwzNativeDllSearchDirectories); - setup.Call(args); - - GCPROTECT_END(); + { + SString sTrustedPlatformAssemblies(pwzTrustedPlatformAssemblies); + SString sPlatformResourceRoots(pwzPlatformResourceRoots); + SString sAppPaths(pwzAppPaths); + SString sAppNiPaths(pwzAppNiPaths); - *pAppDomainID=pDomain->GetId().m_dwId; + CLRPrivBinderCoreCLR *pBinder = pDomain->GetTPABinderContext(); + _ASSERTE(pBinder != NULL); + IfFailThrow(pBinder->SetupBindingPaths( + sTrustedPlatformAssemblies, + sPlatformResourceRoots, + sAppPaths, + sAppNiPaths)); + } - m_fAppDomainCreated = TRUE; +#ifdef FEATURE_COMINTEROP + if (WinRTSupported()) + { + pDomain->SetWinrtApplicationContext(pwzAppLocalWinMD); } +#endif + + *pAppDomainID=pDomain->GetId().m_dwId; + + m_fAppDomainCreated = TRUE; END_EXTERNAL_ENTRYPOINT; END_ENTRYPOINT_NOTHROW; return hr; - -}; +} HRESULT CorHost2::_CreateDelegate( DWORD appDomainID, diff --git a/src/vm/crossgencompile.cpp b/src/vm/crossgencompile.cpp index cd45e1f1be..4f7d532041 100644 --- a/src/vm/crossgencompile.cpp +++ b/src/vm/crossgencompile.cpp @@ -380,7 +380,7 @@ void EEPolicy::HandleFatalError(UINT exitCode, UINT_PTR address, LPCWSTR pszMess //--------------------------------------------------------------------------------------- -Assembly * AppDomain::RaiseAssemblyResolveEvent(AssemblySpec * pSpec, BOOL fPreBind) +Assembly * AppDomain::RaiseAssemblyResolveEvent(AssemblySpec * pSpec) { return NULL; } @@ -398,8 +398,3 @@ DomainAssembly * AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssem void AppDomain::RaiseLoadingAssemblyEvent(DomainAssembly *pAssembly) { } - -BOOL AppDomain::BindingByManifestFile() -{ - return FALSE; -} diff --git a/src/vm/domainfile.cpp b/src/vm/domainfile.cpp index 19adf33ce1..2f881ac5f3 100644 --- a/src/vm/domainfile.cpp +++ b/src/vm/domainfile.cpp @@ -1715,16 +1715,6 @@ void DomainAssembly::DeliverSyncEvents() { SetShouldNotifyDebugger(); - if (m_pDomain->IsDebuggerAttached()) - { - // If this is the first assembly in the AppDomain, it may be possible to get a better name than the - // default. - CollectibleAssemblyHolder<DomainAssembly *> pDomainAssembly; - m_pDomain->m_Assemblies.Get(m_pDomain, 0, pDomainAssembly.This()); - if ((pDomainAssembly == this) && !m_pDomain->IsUserCreatedDomain()) - m_pDomain->ResetFriendlyName(); - } - // Still work to do even if no debugger is attached. NotifyDebuggerLoad(ATTACH_ASSEMBLY_LOAD, FALSE); diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h index 91ca5e019d..04c9fba8ba 100644 --- a/src/vm/ecalllist.h +++ b/src/vm/ecalllist.h @@ -439,23 +439,6 @@ FCFuncStart(gCompatibilitySwitchFuncs) FCFuncElement("GetValueInternalCall", CompatibilitySwitch::GetValue) FCFuncEnd() -FCFuncStart(gAppDomainFuncs) - FCFuncElement("nSetupFriendlyName", AppDomainNative::SetupFriendlyName) - FCFuncElement("GetId", AppDomainNative::GetId) - QCFuncElement("nSetupBindingPaths", AppDomainNative::SetupBindingPaths) - QCFuncElement("nSetNativeDllSearchDirectories", AppDomainNative::SetNativeDllSearchDirectories) - FCFuncElement("PublishAnonymouslyHostedDynamicMethodsAssembly", AppDomainNative::PublishAnonymouslyHostedDynamicMethodsAssembly) -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - FCFuncElement("nEnableMonitoring", AppDomainNative::EnableMonitoring) - FCFuncElement("nMonitoringIsEnabled", AppDomainNative::MonitoringIsEnabled) - FCFuncElement("nGetTotalProcessorTime", AppDomainNative::GetTotalProcessorTime) - FCFuncElement("nGetTotalAllocatedMemorySize", AppDomainNative::GetTotalAllocatedMemorySize) - FCFuncElement("nGetLastSurvivedMemorySize", AppDomainNative::GetLastSurvivedMemorySize) - FCFuncElement("nGetLastSurvivedProcessMemorySize", AppDomainNative::GetLastSurvivedProcessMemorySize) - -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING -FCFuncEnd() - #ifdef FEATURE_APPX FCFuncStart(gApplicationModelFuncs) QCFuncElement("IsAppXProcess", AppDomainNative::IsAppXProcess) @@ -1238,7 +1221,6 @@ FCFuncEnd() // Note these have to remain sorted by name:namespace pair (Assert will wack you if you don't) // The sorting is case-sensitive -FCClassElement("AppDomain", "System", gAppDomainFuncs) #ifdef FEATURE_APPX FCClassElement("ApplicationModel", "System", gApplicationModelFuncs) #endif diff --git a/src/vm/interoputil.cpp b/src/vm/interoputil.cpp index 510e494f18..513813c4d8 100644 --- a/src/vm/interoputil.cpp +++ b/src/vm/interoputil.cpp @@ -2149,40 +2149,6 @@ void ReleaseRCWsInCaches(LPVOID pCtxCookie) } } -// Out-of-line to keep SafeComHolder's required C++ prolog/epilog out of GetCCWfromIUnknown -NOINLINE ComCallWrapper* GetCCWFromIUnknown_CrossDomain(IUnknown* pUnk, ComCallWrapper* pWrap, AppDomain* pDomain) -{ - CONTRACTL - { - NOTHROW; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - // We ignore PreferComInsteadOfManagedRemoting/ICustomQueryInterface if the CCW is from - // the current domain (we never create RCWs pointing to CCWs in the same domain). - - if (pDomain) - { - return NULL; - } - - // If the user specifically does not support IManagedObject then don't do this bypass - if (pWrap && pWrap->GetSimpleWrapper() && pWrap->GetSimpleWrapper()->SupportsICustomQueryInterface()) - { - SafeComHolder<IUnknown> pUnk = ComCallWrapper::GetComIPFromCCWNoThrow( - pWrap, IID_IManagedObject, NULL, - GetComIPFromCCW::CheckVisibility); - if(!pUnk) - { - // They bypassed QueryInterface so don't collapse this IUnknown to the underlying managed object - pWrap = NULL; - } - } - return pWrap; -} - //-------------------------------------------------------------------------------- // Marshalling Helpers //-------------------------------------------------------------------------------- @@ -2211,16 +2177,6 @@ ComCallWrapper* GetCCWFromIUnknown(IUnknown* pUnk, BOOL bEnableCustomization) { pWrap = NULL; } - - // Only check for an interface if caller set bEnableCustomization to TRUE - if (bEnableCustomization) - { - AppDomain *pDomain = GetAppDomain(); - if (pDomain == NULL || pWrap == NULL || pDomain->GetId() != pWrap->GetDomainID()) - { - pWrap = GetCCWFromIUnknown_CrossDomain(pUnk, pWrap, pDomain); - } - } } RETURN pWrap; diff --git a/src/vm/metasig.h b/src/vm/metasig.h index 5d899dfe54..ea0fb6f57d 100644 --- a/src/vm/metasig.h +++ b/src/vm/metasig.h @@ -486,7 +486,7 @@ DEFINE_METASIG_T(IM(Str_RetPropertyInfo, s, C(PROPERTY_INFO))) DEFINE_METASIG(SM(Str_RetStr, s, s)) DEFINE_METASIG_T(SM(Str_CultureInfo_RetStr, s C(CULTURE_INFO), s)) DEFINE_METASIG_T(SM(Str_CultureInfo_RefBool_RetStr, s C(CULTURE_INFO) r(F), s)) -DEFINE_METASIG(IM(Str_ArrStr_ArrStr_RetVoid, s a(s) a(s), v)) +DEFINE_METASIG(SM(PtrPtrChar_PtrPtrChar_Int_RetVoid, P(P(u)) P(P(u)) i, v)) DEFINE_METASIG(SM(ArrStr_RetVoid, a(s), v)) DEFINE_METASIG(IM(Str_RetVoid, s, v)) DEFINE_METASIG(SM(RefBool_RefBool_RetVoid, r(F) r(F), v)) diff --git a/src/vm/mscorlib.h b/src/vm/mscorlib.h index 26be735b79..6128711489 100644 --- a/src/vm/mscorlib.h +++ b/src/vm/mscorlib.h @@ -66,6 +66,9 @@ DEFINE_FIELD(ACCESS_VIOLATION_EXCEPTION, IP, _ip) DEFINE_FIELD(ACCESS_VIOLATION_EXCEPTION, TARGET, _target) DEFINE_FIELD(ACCESS_VIOLATION_EXCEPTION, ACCESSTYPE, _accessType) +DEFINE_CLASS(APPCONTEXT, System, AppContext) +DEFINE_METHOD(APPCONTEXT, SETUP, Setup, SM_PtrPtrChar_PtrPtrChar_Int_RetVoid) + DEFINE_CLASS_U(System, AppDomain, AppDomainBaseObject) DEFINE_FIELD_U(AssemblyLoad, AppDomainBaseObject, m_pAssemblyEventHandler) DEFINE_FIELD_U(_TypeResolve, AppDomainBaseObject, m_pTypeEventHandler) @@ -78,7 +81,6 @@ DEFINE_FIELD_U(_firstChanceException, AppDomainBaseObject, m_pFirstChanceEx DEFINE_FIELD_U(_pDomain, AppDomainBaseObject, m_pDomain) DEFINE_CLASS(APP_DOMAIN, System, AppDomain) -DEFINE_METHOD(APP_DOMAIN, SETUP,Setup,SM_Str_ArrStr_ArrStr_RetVoid) DEFINE_METHOD(APP_DOMAIN, ON_ASSEMBLY_LOAD, OnAssemblyLoadEvent, IM_Assembly_RetVoid) DEFINE_METHOD(APP_DOMAIN, ON_RESOURCE_RESOLVE, OnResourceResolveEvent, IM_Assembly_Str_RetAssembly) DEFINE_METHOD(APP_DOMAIN, ON_TYPE_RESOLVE, OnTypeResolveEvent, IM_Assembly_Str_RetAssembly) @@ -87,19 +89,6 @@ DEFINE_METHOD(APP_DOMAIN, ON_ASSEMBLY_RESOLVE, OnAssemblyResolveEve DEFINE_METHOD(APP_DOMAIN, ON_DESIGNER_NAMESPACE_RESOLVE, OnDesignerNamespaceResolveEvent, IM_Str_RetArrStr) #endif //FEATURE_COMINTEROP -DEFINE_CLASS(CLEANUP_WORK_LIST_ELEMENT, StubHelpers, CleanupWorkListElement) - -#ifdef FEATURE_COMINTEROP -// Define earlier in mscorlib.h to avoid BinderClassID to const BYTE truncation warning -DEFINE_CLASS(DATETIMENATIVE, StubHelpers, DateTimeNative) -DEFINE_CLASS(TYPENAMENATIVE, StubHelpers, TypeNameNative) - -DEFINE_CLASS_U(StubHelpers, TypeNameNative, TypeNameNative) -DEFINE_FIELD_U(typeName, TypeNameNative, typeName) -DEFINE_FIELD_U(typeKind, TypeNameNative, typeKind) - -#endif - DEFINE_CLASS(ARG_ITERATOR, System, ArgIterator) DEFINE_CLASS_U(System, ArgIterator, VARARGS) // Includes a SigPointer. DEFINE_METHOD(ARG_ITERATOR, CTOR2, .ctor, IM_RuntimeArgumentHandle_PtrVoid_RetVoid) @@ -597,38 +586,6 @@ DEFINE_METHOD(SPAN, GET_ITEM, get_Item, IM_Int_Ret DEFINE_CLASS(READONLY_SPAN, System, ReadOnlySpan`1) DEFINE_METHOD(READONLY_SPAN, GET_ITEM, get_Item, IM_Int_RetReadOnlyRefT) -// Keep this in sync with System.Globalization.NumberFormatInfo -DEFINE_CLASS_U(Globalization, NumberFormatInfo, NumberFormatInfo) -DEFINE_FIELD_U(numberGroupSizes, NumberFormatInfo, cNumberGroup) -DEFINE_FIELD_U(currencyGroupSizes, NumberFormatInfo, cCurrencyGroup) -DEFINE_FIELD_U(percentGroupSizes, NumberFormatInfo, cPercentGroup) -DEFINE_FIELD_U(positiveSign, NumberFormatInfo, sPositive) -DEFINE_FIELD_U(negativeSign, NumberFormatInfo, sNegative) -DEFINE_FIELD_U(numberDecimalSeparator, NumberFormatInfo, sNumberDecimal) -DEFINE_FIELD_U(numberGroupSeparator, NumberFormatInfo, sNumberGroup) -DEFINE_FIELD_U(currencyGroupSeparator, NumberFormatInfo, sCurrencyGroup) -DEFINE_FIELD_U(currencyDecimalSeparator,NumberFormatInfo, sCurrencyDecimal) -DEFINE_FIELD_U(currencySymbol, NumberFormatInfo, sCurrency) -DEFINE_FIELD_U(nanSymbol, NumberFormatInfo, sNaN) -DEFINE_FIELD_U(positiveInfinitySymbol, NumberFormatInfo, sPositiveInfinity) -DEFINE_FIELD_U(negativeInfinitySymbol, NumberFormatInfo, sNegativeInfinity) -DEFINE_FIELD_U(percentDecimalSeparator,NumberFormatInfo, sPercentDecimal) -DEFINE_FIELD_U(percentGroupSeparator, NumberFormatInfo, sPercentGroup) -DEFINE_FIELD_U(percentSymbol, NumberFormatInfo, sPercent) -DEFINE_FIELD_U(perMilleSymbol, NumberFormatInfo, sPerMille) -DEFINE_FIELD_U(nativeDigits, NumberFormatInfo, sNativeDigits) -DEFINE_FIELD_U(numberDecimalDigits, NumberFormatInfo, cNumberDecimals) -DEFINE_FIELD_U(currencyDecimalDigits, NumberFormatInfo, cCurrencyDecimals) -DEFINE_FIELD_U(currencyPositivePattern,NumberFormatInfo, cPosCurrencyFormat) -DEFINE_FIELD_U(currencyNegativePattern,NumberFormatInfo, cNegCurrencyFormat) -DEFINE_FIELD_U(numberNegativePattern, NumberFormatInfo, cNegativeNumberFormat) -DEFINE_FIELD_U(percentPositivePattern, NumberFormatInfo, cPositivePercentFormat) -DEFINE_FIELD_U(percentNegativePattern, NumberFormatInfo, cNegativePercentFormat) -DEFINE_FIELD_U(percentDecimalDigits, NumberFormatInfo, cPercentDecimals) -DEFINE_FIELD_U(digitSubstitution, NumberFormatInfo, iDigitSubstitution) -DEFINE_FIELD_U(isReadOnly, NumberFormatInfo, bIsReadOnly) -DEFINE_FIELD_U(m_isInvariant, NumberFormatInfo, bIsInvariant) - // Defined as element type alias // DEFINE_CLASS(OBJECT, System, Object) DEFINE_METHOD(OBJECT, CTOR, .ctor, IM_RetVoid) @@ -1042,6 +999,17 @@ DEFINE_METHOD(STUBHELPERS, ARRAY_TYPE_CHECK, ArrayTypeCheck, DEFINE_METHOD(STUBHELPERS, MULTICAST_DEBUGGER_TRACE_HELPER, MulticastDebuggerTraceHelper, SM_Obj_Int_RetVoid) #endif +DEFINE_CLASS(CLEANUP_WORK_LIST_ELEMENT, StubHelpers, CleanupWorkListElement) + +#ifdef FEATURE_COMINTEROP +DEFINE_CLASS(DATETIMENATIVE, StubHelpers, DateTimeNative) +DEFINE_CLASS(TYPENAMENATIVE, StubHelpers, TypeNameNative) + +DEFINE_CLASS_U(StubHelpers, TypeNameNative, TypeNameNative) +DEFINE_FIELD_U(typeName, TypeNameNative, typeName) +DEFINE_FIELD_U(typeKind, TypeNameNative, typeKind) +#endif + DEFINE_CLASS(ANSICHARMARSHALER, StubHelpers, AnsiCharMarshaler) DEFINE_METHOD(ANSICHARMARSHALER, CONVERT_TO_NATIVE, ConvertToNative, SM_Char_Bool_Bool_RetByte) DEFINE_METHOD(ANSICHARMARSHALER, CONVERT_TO_MANAGED, ConvertToManaged, SM_Byte_RetChar) diff --git a/src/vm/object.h b/src/vm/object.h index 179d9c4d9e..50ab19d261 100644 --- a/src/vm/object.h +++ b/src/vm/object.h @@ -1731,161 +1731,6 @@ class VersionBaseObject : public Object int GetRevision() { LIMITED_METHOD_CONTRACT; return m_Revision; } }; -// FrameSecurityDescriptorBaseObject -// This class is the base class for the frame security descriptor -// - -class FrameSecurityDescriptorBaseObject : public Object -{ - friend class MscorlibBinder; - - protected: - // READ ME: - // Modifying the order or fields of this object may require other changes to the - // classlib class definition of this object. - - OBJECTREF m_assertions; // imperative - OBJECTREF m_denials; // imperative - OBJECTREF m_restriction; // imperative - OBJECTREF m_DeclarativeAssertions; - OBJECTREF m_DeclarativeDenials; - OBJECTREF m_DeclarativeRestrictions; - CLR_BOOL m_assertFT; - CLR_BOOL m_assertAllPossible; - CLR_BOOL m_declSecComputed; - - - - protected: - FrameSecurityDescriptorBaseObject() {LIMITED_METHOD_CONTRACT;} - ~FrameSecurityDescriptorBaseObject() {LIMITED_METHOD_CONTRACT;} - - public: - - INT32 GetOverridesCount() - { - LIMITED_METHOD_CONTRACT; - INT32 ret =0; - if (m_restriction != NULL) - ret++; - if (m_denials != NULL) - ret++; - if (m_DeclarativeDenials != NULL) - ret++; - if (m_DeclarativeRestrictions != NULL) - ret++; - return ret; - } - - INT32 GetAssertCount() - { - LIMITED_METHOD_CONTRACT; - INT32 ret =0; - if (m_assertions != NULL || m_DeclarativeAssertions != NULL || HasAssertAllPossible()) - ret++; - return ret; - } - - BOOL HasAssertFT() - { - LIMITED_METHOD_CONTRACT; - return m_assertFT; - } - - BOOL IsDeclSecComputed() - { - LIMITED_METHOD_CONTRACT; - return m_declSecComputed; - } - - BOOL HasAssertAllPossible() - { - LIMITED_METHOD_CONTRACT; - return m_assertAllPossible; - } - - OBJECTREF GetImperativeAssertions() - { - LIMITED_METHOD_CONTRACT; - return m_assertions; - } - OBJECTREF GetDeclarativeAssertions() - { - LIMITED_METHOD_CONTRACT; - return m_DeclarativeAssertions; - } - OBJECTREF GetImperativeDenials() - { - LIMITED_METHOD_CONTRACT; - return m_denials; - } - OBJECTREF GetDeclarativeDenials() - { - LIMITED_METHOD_CONTRACT; - return m_DeclarativeDenials; - } - OBJECTREF GetImperativeRestrictions() - { - LIMITED_METHOD_CONTRACT; - return m_restriction; - } - OBJECTREF GetDeclarativeRestrictions() - { - LIMITED_METHOD_CONTRACT; - return m_DeclarativeRestrictions; - } - void SetImperativeAssertions(OBJECTREF assertRef) - { - LIMITED_METHOD_CONTRACT; - SetObjectReference(&m_assertions, assertRef, this->GetAppDomain()); - } - void SetDeclarativeAssertions(OBJECTREF assertRef) - { - LIMITED_METHOD_CONTRACT; - SetObjectReference(&m_DeclarativeAssertions, assertRef, this->GetAppDomain()); - } - void SetImperativeDenials(OBJECTREF denialRef) - { - LIMITED_METHOD_CONTRACT; - SetObjectReference(&m_denials, denialRef, this->GetAppDomain()); - } - - void SetDeclarativeDenials(OBJECTREF denialRef) - { - LIMITED_METHOD_CONTRACT; - SetObjectReference(&m_DeclarativeDenials, denialRef, this->GetAppDomain()); - } - - void SetImperativeRestrictions(OBJECTREF restrictRef) - { - LIMITED_METHOD_CONTRACT; - SetObjectReference(&m_restriction, restrictRef, this->GetAppDomain()); - } - - void SetDeclarativeRestrictions(OBJECTREF restrictRef) - { - LIMITED_METHOD_CONTRACT; - SetObjectReference(&m_DeclarativeRestrictions, restrictRef, this->GetAppDomain()); - } - void SetAssertAllPossible(BOOL assertAllPossible) - { - LIMITED_METHOD_CONTRACT; - m_assertAllPossible = !!assertAllPossible; - } - - void SetAssertFT(BOOL assertFT) - { - LIMITED_METHOD_CONTRACT; - m_assertFT = !!assertFT; - } - void SetDeclSecComputed(BOOL declSec) - { - LIMITED_METHOD_CONTRACT; - m_declSecComputed = !!declSec; - } -}; - - class WeakReferenceObject : public Object { public: @@ -1914,8 +1759,6 @@ typedef REF<AssemblyNameBaseObject> ASSEMBLYNAMEREF; typedef REF<VersionBaseObject> VERSIONREF; -typedef REF<FrameSecurityDescriptorBaseObject> FRAMESECDESCREF; - typedef REF<WeakReferenceObject> WEAKREFERENCEREF; @@ -1965,9 +1808,6 @@ typedef PTR_AssemblyNameBaseObject ASSEMBLYNAMEREF; #ifndef DACCESS_COMPILE typedef MarshalByRefObjectBaseObject* MARSHALBYREFOBJECTBASEREF; typedef VersionBaseObject* VERSIONREF; -typedef FrameSecurityDescriptorBaseObject* FRAMESECDESCREF; - - typedef WeakReferenceObject* WEAKREFERENCEREF; #endif // #ifndef DACCESS_COMPILE @@ -2960,49 +2800,6 @@ typedef REF<ContractExceptionObject> CONTRACTEXCEPTIONREF; typedef PTR_ContractExceptionObject CONTRACTEXCEPTIONREF; #endif // USE_CHECKED_OBJECTREFS -class NumberFormatInfo: public Object -{ -public: - // C++ data members // Corresponding data member in NumberFormatInfo.cs - // Also update mscorlib.h when you add/remove fields - - I4ARRAYREF cNumberGroup; // numberGroupSize - I4ARRAYREF cCurrencyGroup; // currencyGroupSize - I4ARRAYREF cPercentGroup; // percentGroupSize - - STRINGREF sPositive; // positiveSign - STRINGREF sNegative; // negativeSign - STRINGREF sNumberDecimal; // numberDecimalSeparator - STRINGREF sNumberGroup; // numberGroupSeparator - STRINGREF sCurrencyGroup; // currencyDecimalSeparator - STRINGREF sCurrencyDecimal; // currencyGroupSeparator - STRINGREF sCurrency; // currencySymbol - STRINGREF sNaN; // nanSymbol - STRINGREF sPositiveInfinity; // positiveInfinitySymbol - STRINGREF sNegativeInfinity; // negativeInfinitySymbol - STRINGREF sPercentDecimal; // percentDecimalSeparator - STRINGREF sPercentGroup; // percentGroupSeparator - STRINGREF sPercent; // percentSymbol - STRINGREF sPerMille; // perMilleSymbol - - PTRARRAYREF sNativeDigits; // nativeDigits (a string array) - - INT32 cNumberDecimals; // numberDecimalDigits - INT32 cCurrencyDecimals; // currencyDecimalDigits - INT32 cPosCurrencyFormat; // positiveCurrencyFormat - INT32 cNegCurrencyFormat; // negativeCurrencyFormat - INT32 cNegativeNumberFormat; // negativeNumberFormat - INT32 cPositivePercentFormat; // positivePercentFormat - INT32 cNegativePercentFormat; // negativePercentFormat - INT32 cPercentDecimals; // percentDecimalDigits - INT32 iDigitSubstitution; // digitSubstitution - - CLR_BOOL bIsReadOnly; // Is this NumberFormatInfo ReadOnly? - CLR_BOOL bIsInvariant; // Is this the NumberFormatInfo for the Invariant Culture? -}; - -typedef NumberFormatInfo * NUMFMTREF; - //=============================================================================== // #NullableFeature // #NullableArchitecture |