diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-03-23 12:38:37 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2016-03-23 13:11:31 -0700 |
commit | e8a39ef3ee0501ff62d3fc8cdb8d063e7f0d149f (patch) | |
tree | 0e694fc322211aa6721ad605f4a34f637654e55c /src | |
parent | 21cbca6a3165ac9f3e2a3c1753ac6ee023aa9443 (diff) | |
download | coreclr-e8a39ef3ee0501ff62d3fc8cdb8d063e7f0d149f.tar.gz coreclr-e8a39ef3ee0501ff62d3fc8cdb8d063e7f0d149f.tar.bz2 coreclr-e8a39ef3ee0501ff62d3fc8cdb8d063e7f0d149f.zip |
Remove special casing of platform assemblies
Diffstat (limited to 'src')
31 files changed, 40 insertions, 1091 deletions
diff --git a/src/inc/MSCOREE.IDL b/src/inc/MSCOREE.IDL index e292069ec9..832783c36f 100644 --- a/src/inc/MSCOREE.IDL +++ b/src/inc/MSCOREE.IDL @@ -365,10 +365,6 @@ typedef enum // Otherwise, by default, only platform assemblies can perform those operations. APPDOMAIN_ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP = 0x10, -#if defined(FEATURE_WINDOWSPHONE) && defined(FEATURE_STRONGNAME_TESTKEY_ALLOWED) - APPDOMAIN_SET_TEST_KEY = 0x20, -#endif // defined(FEATURE_WINDOWSPHONE) && defined(FEATURE_STRONGNAME_TESTKEY_ALLOWED) - APPDOMAIN_ENABLE_PLATFORM_SPECIFIC_APPS = 0x40, APPDOMAIN_ENABLE_ASSEMBLY_LOADFILE = 0x80, diff --git a/src/mscorlib/src/System/Reflection/Assembly.cs b/src/mscorlib/src/System/Reflection/Assembly.cs index b05fb42953..b666566066 100644 --- a/src/mscorlib/src/System/Reflection/Assembly.cs +++ b/src/mscorlib/src/System/Reflection/Assembly.cs @@ -855,17 +855,6 @@ namespace System.Reflection throw new NotImplementedException(); } -#if FEATURE_CORECLR - internal virtual bool IsProfileAssembly - { - [System.Security.SecurityCritical] - get - { - throw new NotImplementedException(); - } - } -#endif // FEATURE_CORECLR - public virtual IList<CustomAttributeData> GetCustomAttributesData() { throw new NotImplementedException(); @@ -1165,11 +1154,10 @@ namespace System.Reflection { ASSEMBLY_FLAGS flags = ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_UNKNOWN; -#if !FEATURE_CORECLR - if (RuntimeAssembly.IsFrameworkAssembly(GetName())) +#if FEATURE_CORECLR + flags |= ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_FRAMEWORK | ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_SAFE_REFLECTION; #else - if (IsProfileAssembly) -#endif + if (RuntimeAssembly.IsFrameworkAssembly(GetName())) { flags |= ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_FRAMEWORK | ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_SAFE_REFLECTION; @@ -1206,6 +1194,7 @@ namespace System.Reflection { flags = ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_SAFE_REFLECTION; } +#endif m_flags = flags | ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_INITIALIZED; } @@ -1213,7 +1202,7 @@ namespace System.Reflection return m_flags; } } -#endif // FEATURE_APPX +#endif // FEATURE_CORECLR internal object SyncRoot { @@ -2532,24 +2521,6 @@ namespace System.Reflection newGrant = granted; newDenied = denied; } -#if FEATURE_CORECLR - [System.Security.SecurityCritical] - [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetIsProfileAssembly(RuntimeAssembly assembly); - - // True if the assembly is a trusted platform assembly - internal override bool IsProfileAssembly - { - [System.Security.SecurityCritical] - get - { - return GetIsProfileAssembly(GetNativeHandle()); - } - } -#endif // FEATURE_CORECLR - [System.Security.SecurityCritical] // auto-generated [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] [SuppressUnmanagedCodeSecurity] diff --git a/src/mscorlib/src/mscorlib.Friends.cs b/src/mscorlib/src/mscorlib.Friends.cs index f0232157ff..fc24b2b853 100644 --- a/src/mscorlib/src/mscorlib.Friends.cs +++ b/src/mscorlib/src/mscorlib.Friends.cs @@ -7,48 +7,16 @@ using System.Runtime.CompilerServices; // AssemblyAttributes.cspp model for the other build types at a future point in time. #if FEATURE_CORESYSTEM -// System and System.Core depend on all kinds of things. -[assembly: InternalsVisibleTo("System, PublicKey=" + _InternalsVisibleToKeys.SilverlightPlatformPublicKeyFull, AllInternalsVisible=false)] -[assembly: InternalsVisibleTo("System.Core, PublicKey=" + _InternalsVisibleToKeys.SilverlightPlatformPublicKeyFull, AllInternalsVisible=false)] - // Depends on things like SuppressUnmanagedCodeAttribute and WindowsRuntimeImportAttribute [assembly: InternalsVisibleTo("System.Runtime.WindowsRuntime, PublicKey=" + _InternalsVisibleToKeys.EcmaPublicKeyFull, AllInternalsVisible=false)] // Depends on WindowsRuntimeImportAttribute [assembly: InternalsVisibleTo("System.Runtime.WindowsRuntime.UI.Xaml, PublicKey=" + _InternalsVisibleToKeys.EcmaPublicKeyFull, AllInternalsVisible=false)] -// Depends on things like FormattingServices and System.Reflection.Pointer -// For mango appcompat also needs access to System.Version..ctor() in order to deserialize Version -[assembly: InternalsVisibleTo("System.Runtime.Serialization, PublicKey=" + _InternalsVisibleToKeys.SilverlightPlatformPublicKeyFull, AllInternalsVisible=false)] - -// Depends on things like System.Number -[assembly: InternalsVisibleTo("System.Numerics, PublicKey=" + _InternalsVisibleToKeys.SilverlightPublicKeyFull, AllInternalsVisible=false)] - -// Depends on things like internal constructor on TypeInfo as well as few other internal reflection members -[assembly: InternalsVisibleTo("System.Reflection.Context, PublicKey=" + _InternalsVisibleToKeys.SilverlightPlatformPublicKeyFull, AllInternalsVisible=false)] - -// Depends on things like EncoderExptionFallback and EncoderFallback -[assembly: InternalsVisibleTo("System.Xml, PublicKey=" + _InternalsVisibleToKeys.SilverlightPlatformPublicKeyFull, AllInternalsVisible=false)] - -// See ndp\fx\src\ReferenceAssemblies\WindowsPhone\v8.0\mscorlib\mscorlib.Private.cs for the exact set of internal API's -// System.Windows, System.Windows.RuntimeHost, and System.Net use. -[assembly: InternalsVisibleTo("System.Windows, PublicKey=" + _InternalsVisibleToKeys.SilverlightPlatformPublicKeyFull, AllInternalsVisible=false)] -[assembly: InternalsVisibleTo("System.Windows.RuntimeHost, PublicKey=" + _InternalsVisibleToKeys.SilverlightPlatformPublicKeyFull, AllInternalsVisible=false)] -[assembly: InternalsVisibleTo("System.Net, PublicKey=" + _InternalsVisibleToKeys.SilverlightPlatformPublicKeyFull, AllInternalsVisible=false)] - internal class _InternalsVisibleToKeys { // Token = b77a5c561934e089 internal const string EcmaPublicKeyFull = "00000000000000000400000000000000"; - - // Token = b03f5f7f11d50a3a - internal const string MicrosoftPublicKeyFull = "002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293"; - - // Token = 7cec85d7bea7798e - internal const string SilverlightPlatformPublicKeyFull= "00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB"; - - // Token = 31bf3856ad364e35 (also known as SharedLibPublicKey) - internal const string SilverlightPublicKeyFull = "0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9"; } #endif // FEATURE_CORESYS diff --git a/src/strongname/api/strongnameinternal.cpp b/src/strongname/api/strongnameinternal.cpp index 6b4472b1a0..843436772c 100644 --- a/src/strongname/api/strongnameinternal.cpp +++ b/src/strongname/api/strongnameinternal.cpp @@ -11,12 +11,6 @@ #include "thekey.h" #include "ecmakey.h" -#ifdef FEATURE_STRONGNAME_TESTKEY_ALLOWED -#include "thetestkey.h" - -BYTE g_rbTestKeyBuffer[] = { TEST_KEY_HEADER TEST_KEY_BUFFER }; -#endif // FEATURE_STRONGNAME_TESTKEY_ALLOWED - //--------------------------------------------------------------------------------------- // // Check to see if a public key blob is the ECMA public key blob @@ -143,76 +137,6 @@ bool StrongNameIsSilverlightPlatformKey(const PublicKeyBlob &keyPublicKey) } #endif //FEATURE_CORECLR -#ifdef FEATURE_STRONGNAME_TESTKEY_ALLOWED - -//--------------------------------------------------------------------------------------- -// -// Check to see if a public key blob is the Silverlight Platform public key blob -// -// See code:g_rbTestKeyBuffer#TestKeyStamping -// -// Arguments: -// pbKey - public key blob to check -// cbKey - size in bytes of pbKey -// - -bool StrongNameIsTestKey(__in_ecount(cbKey) const BYTE *pbKey, DWORD cbKey) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - // The key should be the same size as the ECMA key - if (cbKey != sizeof(g_rbTestKeyBuffer) - 2 * sizeof(GUID)) - { - return false; - } - - const PublicKeyBlob *pKeyBlob = reinterpret_cast<const PublicKeyBlob *>(pbKey); - return StrongNameIsTestKey(*pKeyBlob); -} - -//--------------------------------------------------------------------------------------- -// -// Determine if the public key blob is the test public key stamped into the VM. -// -// See code:g_rbTestKeyBuffer#TestKeyStamping -// -// Arguments: -// keyPublicKey - public key blob to check for emptyness -// - -bool StrongNameIsTestKey(const PublicKeyBlob &keyPublicKey) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - // Find the blob in the VM by looking past the two header GUIDs in the buffer - _ASSERTE(sizeof(g_rbTestKeyBuffer) > 2 * sizeof(GUID) + sizeof(PublicKeyBlob)); - const PublicKeyBlob *pbTestPublicKey = reinterpret_cast<const PublicKeyBlob *>(g_rbTestKeyBuffer + 2 * sizeof(GUID)); - - DWORD cbTestPublicKey = StrongNameSizeOfPublicKey(*pbTestPublicKey); - DWORD cbCheckPublicKey = StrongNameSizeOfPublicKey(keyPublicKey); - - // Check whether valid test key was stamped in - if (cbTestPublicKey == 0) - return false; - - // This is the test public key if it is the same size as the public key in the buffer, and is identical - // to the test key as well. - return cbTestPublicKey == cbCheckPublicKey && - memcmp(reinterpret_cast<const void *>(pbTestPublicKey), reinterpret_cast<const void *>(&keyPublicKey), cbTestPublicKey) == 0; -} - -#endif // FEATURE_STRONGNAME_TESTKEY_ALLOWED - //--------------------------------------------------------------------------------------- // // Verify that a public key blob looks like a reasonable public key diff --git a/src/strongname/inc/strongnameinternal.h b/src/strongname/inc/strongnameinternal.h index 3b66607533..614fdfb53a 100644 --- a/src/strongname/inc/strongnameinternal.h +++ b/src/strongname/inc/strongnameinternal.h @@ -23,11 +23,6 @@ #define CALG_SHA_512 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512) #endif //ALG_SID_SHA_256 -#ifdef FEATURE_STRONGNAME_TESTKEY_ALLOWED -bool StrongNameIsTestKey(__in_ecount(cbKey) const BYTE *pbKey, DWORD cbKey); -bool StrongNameIsTestKey(const PublicKeyBlob &keyPublicKey); -#endif // FEATURE_STRONGNAME_TESTKEY_ALLOWED - // Determine the number of bytes in a public key DWORD StrongNameSizeOfPublicKey(const PublicKeyBlob &keyPublicKey); diff --git a/src/strongname/inc/thetestkey.h b/src/strongname/inc/thetestkey.h deleted file mode 100644 index 89ccdd7687..0000000000 --- a/src/strongname/inc/thetestkey.h +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// This file allows customization of the test strongname key used in place of the real MS key - -#ifdef FEATURE_STRONGNAME_TESTKEY_ALLOWED - -// -// #TestKeyStamping -// -// On CoreCLR, we have a requirement that only keys signed with the Microsoft public key can be considered -// part of the platform and therefore contain critical code. This leads to an issue with testing the -// product, since any tests which need to test platform only feautres would need to be signed by the -// Microsoft public key, and for a variety of reasons it is not feasable to sign all of our test assemblies -// with that key. -// -// Instead, we provide an extension where any assembly signed with the public key contained in the -// g_rbTestKeyBuffer will also be considered part of the platform. The buffer is filled with a zero key, -// which means by default non-Microsoft signatures will not be accepted. However, the slstampkey tool looks -// for the two GUIDs in the beginning of the buffer, and can replace the key with a real one of the test -// team's choosing. Once this modification is in place, test assemblies can be considered part of the -// platform and can access critical APIs. -// -// Since this buffer is searched for in the VM using external tools, it's very important that it only appear -// once in the final image of the runtime. If it appears multiple times, tools will be unable to determine -// which test key buffer is the real buffer, and therefore tests which rely on containing platform code will -// be unable to run on the build. -// - -#define TEST_KEY_HEADER \ - /* Test key buffer header 1: { cd517db8-a1b1-44bf-aa64-bf66fefa3831 } */ \ - 0xb8, 0x7d, 0x51, 0xcd, 0xb1, 0xa1, 0xbf, 0x44, 0x64, 0xaa, 0xbf, 0x66, 0xfe, 0xfa, 0x38, 0x31, \ - \ - /* Test key buffer header 2: { 5f363032-eaaf-4103-b312-ab2c8e35cf58 } */ \ - 0x32, 0x30, 0x36, 0x5f, 0xaf, 0xea, 0x03, 0x41, 0x12, 0xb3, 0xab, 0x2c, 0x8e, 0x35, 0xcf, 0x58, - - -#define TEST_KEY_VALUE \ - /* SigAlgId = */\ - 0x00, 0x24, 0x00, 0x00, \ - \ - /* HashAlgId = */\ - 0x04, 0x80, 0x00, 0x00, \ - \ - /* cbPublicKey = 0x94 */ \ - 0x94, 0x00, 0x00, 0x00, \ - \ - /* 1024 bit public key */ \ - 0x06, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41, 0x31, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, \ - 0x0f, 0xc5, 0x99, 0x3e, 0x0f, 0x51, 0x1a, 0xd5, 0xe1, 0x6e, 0x8b, 0x22, 0x65, 0x53, 0x49, 0x3e, 0x09, 0x06, 0x7a, 0xfc, \ - 0x41, 0x03, 0x9f, 0x70, 0xda, 0xeb, 0x94, 0xa9, 0x68, 0xd6, 0x64, 0xf4, 0x0e, 0x69, 0xa4, 0x6b, 0x61, 0x7d, 0x15, 0xd3, \ - 0xd5, 0x32, 0x8b, 0xe7, 0xdb, 0xed, 0xd0, 0x59, 0xeb, 0x98, 0x49, 0x5a, 0x3b, 0x03, 0xcb, 0x4e, 0xa4, 0xba, 0x12, 0x74, \ - 0x44, 0x67, 0x1c, 0x3c, 0x84, 0xcb, 0xc1, 0xfd, 0xc3, 0x93, 0xd7, 0xe1, 0x0b, 0x5e, 0xe3, 0xf3, 0x1f, 0x5a, 0x29, 0xf0, \ - 0x05, 0xe5, 0xee, 0xd7, 0xe3, 0xc9, 0xc8, 0xaf, 0x74, 0xf4, 0x13, 0xf0, 0x00, 0x4f, 0x0c, 0x2c, 0xab, 0xb2, 0x2f, 0x9d, \ - 0xd4, 0xf7, 0x5a, 0x6f, 0x59, 0x97, 0x84, 0xe1, 0xba, 0xb7, 0x09, 0x85, 0xef, 0x81, 0x74, 0xca, 0x6c, 0x68, 0x42, 0x78, \ - 0xbe, 0x82, 0xce, 0x05, 0x5a, 0x03, 0xeb, 0xaf - - // - // Test Public key blob - // - - // - // No prestamped test key - create an empty key buffer - // -#define TEST_KEY_BUFFER \ - /* SigAlgId */ \ - 0x00, 0x00, 0x00, 0x00, \ - \ - /* HashAlgId */ \ - 0x00, 0x00, 0x00, 0x00, \ - \ - /* cbPublicKey = 0x94 - this needs to match the size of the public key section below */ \ - 0x94, 0x00, 0x00, 0x00, \ - \ - /* 1024 bit public key - 0x94 bytes */ \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - -#endif // FEATURE_STRONGNAME_TESTKEY_ALLOWED diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp index 0ec336dffa..19d22bde91 100644 --- a/src/vm/appdomain.hpp +++ b/src/vm/appdomain.hpp @@ -2867,66 +2867,6 @@ public: return (m_dwFlags & IGNORE_UNHANDLED_EXCEPTIONS); } -#if defined(FEATURE_CORECLR) - void SetEnablePInvokeAndClassicComInterop() - { - LIMITED_METHOD_CONTRACT; - - m_dwFlags |= ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP; - } - - BOOL EnablePInvokeAndClassicComInterop() - { - LIMITED_METHOD_CONTRACT; - - return (m_dwFlags & ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP); - } - - void SetAllowPlatformSpecificAppAssemblies() - { - LIMITED_METHOD_CONTRACT; - - m_dwFlags |= ENABLE_SKIP_PLAT_CHECKS; - } - - BOOL AllowPlatformSpecificAppAssemblies() - { - LIMITED_METHOD_CONTRACT; - if(IsCompilationDomain()) - return TRUE; - - return (m_dwFlags & ENABLE_SKIP_PLAT_CHECKS); - } - - void SetAllowLoadFile() - { - LIMITED_METHOD_CONTRACT; - - m_dwFlags |= ENABLE_ASSEMBLY_LOADFILE; - } - - BOOL IsLoadFileAllowed() - { - LIMITED_METHOD_CONTRACT; - - return (m_dwFlags & ENABLE_ASSEMBLY_LOADFILE); - } - - void DisableTransparencyEnforcement() - { - LIMITED_METHOD_CONTRACT; - - m_dwFlags |= DISABLE_TRANSPARENCY_ENFORCEMENT; - } - - BOOL IsTransparencyEnforcementDisabled() - { - LIMITED_METHOD_CONTRACT; - - return (m_dwFlags & DISABLE_TRANSPARENCY_ENFORCEMENT); - } -#endif // defined(FEATURE_CORECLR) - void SetPassiveDomain() { LIMITED_METHOD_CONTRACT; diff --git a/src/vm/assembly.cpp b/src/vm/assembly.cpp index 596d81cd43..45329103e9 100644 --- a/src/vm/assembly.cpp +++ b/src/vm/assembly.cpp @@ -4704,22 +4704,8 @@ Assembly::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) #ifndef DACCESS_COMPILE -#ifdef FEATURE_FRAMEWORK_INTERNAL - -// static -const LPCSTR FriendAssemblyDescriptor::AllInternalsVisibleProperty = "AllInternalsVisible"; - -#endif // FEATURE_FRAMEWORK_INTERNAL - FriendAssemblyDescriptor::FriendAssemblyDescriptor() -#ifdef FEATURE_FRAMEWORK_INTERNAL - : m_crstFriendMembersCache(CrstFriendAccessCache) -#endif // FEATURE_FRAMEWORK_INTERNAL { -#ifdef FEATURE_FRAMEWORK_INTERNAL - LockOwner lockOwner = { &m_crstFriendMembersCache, IsOwnerOfCrst }; - m_htFriendMembers.Init(FriendMemberHashSize, &lockOwner); -#endif // FEATURE_FRAMEWORK_INTERNAL } FriendAssemblyDescriptor::~FriendAssemblyDescriptor() @@ -4740,19 +4726,6 @@ FriendAssemblyDescriptor::~FriendAssemblyDescriptor() delete pFriendAssemblyName; #endif // FEATURE_FUSION } - -#if FEATURE_FRAMEWORK_INTERNAL - ArrayList::Iterator itPartialAccessAssemblies = m_alPartialAccessFriendAssemblies.Iterate(); - while (itPartialAccessAssemblies.Next()) - { - FriendAssemblyName_t *pFriendAssemblyName = static_cast<FriendAssemblyName_t *>(itPartialAccessAssemblies.GetElement()); -#ifdef FEATURE_FUSION - pFriendAssemblyName->Release(); -#else // FEATURE_FUSION - delete pFriendAssemblyName; -#endif // FEATURE_FUSION - } -#endif // FEATURE_FRAMEWORK_INTERNAL } @@ -4890,33 +4863,7 @@ FriendAssemblyDescriptor *FriendAssemblyDescriptor::CreateFriendAssemblyDescript } #endif // !defined(FEATURE_CORECLR) -#ifdef FEATURE_FRAMEWORK_INTERNAL - bool fAllInternalsVisible = true; - - // Framework internal is only available for framework assemblies - if (pAssembly->IsProfileAssembly()) - { - // - // Find out if the friend assembly is allowed access to all internals, or only selected internals. - // We default to true for compatibility with behavior of previous runtimes. - // - - CaNamedArg allInternalsArg; - allInternalsArg.InitBoolField(const_cast<LPCSTR>(AllInternalsVisibleProperty), true); - hr = ParseKnownCaNamedArgs(cap, &allInternalsArg, 1); - if (FAILED(hr) && hr != META_E_CA_UNKNOWN_ARGUMENT) - { - IfFailThrow(hr); - } - - fAllInternalsVisible = !!allInternalsArg.val.u1; - } - - pFriendAssemblies->AddFriendAssembly(pFriendAssemblyName, fAllInternalsVisible); - -#else // FEATURE_FRAMEWORK_INTERNAL pFriendAssemblies->AddFriendAssembly(pFriendAssemblyName); -#endif // FEATURE_FRAMEWORK_INTERNAL pFriendAssemblyName.SuppressRelease(); } @@ -4940,11 +4887,7 @@ FriendAssemblyDescriptor *FriendAssemblyDescriptor::CreateFriendAssemblyDescript // see if an assembly has already been added to the friend assembly list. // -#ifdef FEATURE_FRAMEWORK_INTERNAL -void FriendAssemblyDescriptor::AddFriendAssembly(FriendAssemblyName_t *pFriendAssembly, bool fAllInternalsVisible) -#else // FEATURE_FRAMEWORK_INTERNAL void FriendAssemblyDescriptor::AddFriendAssembly(FriendAssemblyName_t *pFriendAssembly) -#endif // FEATURE_FRAMEWORK_INTERNAL { CONTRACTL { @@ -4954,18 +4897,7 @@ void FriendAssemblyDescriptor::AddFriendAssembly(FriendAssemblyName_t *pFriendAs } CONTRACTL_END -#ifdef FEATURE_FRAMEWORK_INTERNAL - if (fAllInternalsVisible) -#endif // FEATURE_FRAMEWORK_INTERNAL - { - m_alFullAccessFriendAssemblies.Append(pFriendAssembly); - } -#ifdef FEATURE_FRAMEWORK_INTERNAL - else - { - m_alPartialAccessFriendAssemblies.Append(pFriendAssembly); - } -#endif // FEATURE_FRAMEWORK_INTERNAL + m_alFullAccessFriendAssemblies.Append(pFriendAssembly); } void FriendAssemblyDescriptor::AddSubjectAssembly(FriendAssemblyName_t *pFriendAssembly) @@ -4981,95 +4913,6 @@ void FriendAssemblyDescriptor::AddSubjectAssembly(FriendAssemblyName_t *pFriendA m_subjectAssemblies.Append(pFriendAssembly); } -#ifdef FEATURE_FRAMEWORK_INTERNAL - -// -// Helpers to see if a member is internal, and therefore could be considered for friend access. -// - -// static -bool FriendAssemblyDescriptor::FriendAccessAppliesTo(FieldDesc *pFD) -{ - LIMITED_METHOD_CONTRACT; - - DWORD dwFieldProtection = pFD->GetFieldProtection(); - return IsFdAssembly(dwFieldProtection) || - IsFdFamANDAssem(dwFieldProtection) || - IsFdFamORAssem(dwFieldProtection); -} - -// static -bool FriendAssemblyDescriptor::FriendAccessAppliesTo(MethodDesc *pMD) -{ - LIMITED_METHOD_CONTRACT; - - DWORD dwMethodProtection = pMD->GetAttrs(); - return IsMdAssem(dwMethodProtection) || - IsMdFamANDAssem(dwMethodProtection) || - IsMdFamORAssem(dwMethodProtection); -} - -// static -bool FriendAssemblyDescriptor::FriendAccessAppliesTo(MethodTable *pMT) -{ - LIMITED_METHOD_CONTRACT; - - DWORD dwTypeProtection = pMT->GetClass()->GetProtection(); - return IsTdNotPublic(dwTypeProtection) || - IsTdNestedAssembly(dwTypeProtection) || - IsTdNestedFamANDAssem(dwTypeProtection) || - IsTdNestedFamORAssem(dwTypeProtection); -} - -// -// Helper methods to get the metadata token for items that may have the FriendAccessAllowed attribute. -// - -// static -mdToken FriendAssemblyDescriptor::GetMetadataToken(FieldDesc *pFD) -{ - WRAPPER_NO_CONTRACT; - return pFD->GetMemberDef(); -} - -// static -mdToken FriendAssemblyDescriptor::GetMetadataToken(MethodDesc *pMD) -{ - WRAPPER_NO_CONTRACT; - return pMD->GetMemberDef(); -} - -// static -mdToken FriendAssemblyDescriptor::GetMetadataToken(MethodTable *pMT) -{ - WRAPPER_NO_CONTRACT; - return pMT->GetCl(); -} - -// static -bool FriendAssemblyDescriptor::HasFriendAccessAttribute(IMDInternalImport *pMDImport, mdToken tkMember) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - PRECONDITION(CheckPointer(pMDImport)); - } - CONTRACTL_END; - - const BYTE *pbAttribute = NULL; - ULONG cbAttribute = 0; - HRESULT hr = pMDImport->GetCustomAttributeByName(tkMember, - FRIEND_ACCESS_ALLOWED_ATTRIBUTE_TYPE, - reinterpret_cast<const void **>(&pbAttribute), - &cbAttribute); - IfFailThrow(hr); - - return hr == S_OK; -} - -#endif // FEATURE_FRAMEWORK_INTERNAL - // static bool FriendAssemblyDescriptor::IsAssemblyOnList(PEAssembly *pAssembly, const ArrayList &alAssemblyNames) { diff --git a/src/vm/assembly.hpp b/src/vm/assembly.hpp index f8f6b3535e..83fc53bcb8 100644 --- a/src/vm/assembly.hpp +++ b/src/vm/assembly.hpp @@ -923,32 +923,7 @@ public: } CONTRACTL_END; -#ifdef FEATURE_FRAMEWORK_INTERNAL - if (IsAssemblyOnList(pAccessingAssembly, m_alPartialAccessFriendAssemblies)) - { - return FriendAccessAppliesTo(pMember) && IsMemberVisibleToFriends(pMember); - } - else -#endif // FEATURE_FRAMEWORK_INTERNAL - if (IsAssemblyOnList(pAccessingAssembly, m_alFullAccessFriendAssemblies)) - { - return true; - } -#if defined(FEATURE_STRONGNAME_TESTKEY_ALLOWED) && defined(FEATURE_FRAMEWORK_INTERNAL) - else if (pMember->GetModule()->GetFile()->GetAssembly()->IsProfileAssembly()&& - pAccessingAssembly->GetManifestFile() != NULL && - pAccessingAssembly->GetManifestFile()->IsProfileTestAssembly()) - { - // Test hook - All platoform assemblies consider any test assembly which is part of the profile to implicitly - // be on the friends list. This allows test access to the framework internal attributes, without - // having to add test assemblies to the explicit friend assembly list. - return FriendAccessAppliesTo(pMember) && IsMemberVisibleToFriends(pMember); - } -#endif // FEATURE_STRONGNAME_TESTKEY_ALLOWED && FEATURE_FRAMEWORK_INTERNAL - else - { - return false; - } + return IsAssemblyOnList(pAccessingAssembly, m_alFullAccessFriendAssemblies); } #ifndef FEATURE_CORECLR @@ -967,18 +942,7 @@ public: } CONTRACTL_END; -#ifdef FEATURE_FRAMEWORK_INTERNAL - if (IsAssemblyOnList(pAccessingAssembly, m_alPartialAccessFriendAssemblies)) - { - return true; - } - else -#endif // FEATURE_FRAMEWORK_INTERNAL - if (IsAssemblyOnList(pAccessingAssembly, m_alFullAccessFriendAssemblies)) - { - return true; - } - return false; + return IsAssemblyOnList(pAccessingAssembly, m_alFullAccessFriendAssemblies); } #endif // !FEATURE_CORECLR @@ -988,11 +952,6 @@ public: } private: -#ifdef FEATURE_FRAMEWORK_INTERNAL - static const LPCSTR AllInternalsVisibleProperty; - static const DWORD FriendMemberHashSize = 31; // Number of buckets in the friend member hash table -#endif // FEATURE_FRAMEWORK_INTERNAL - #ifdef FEATURE_FUSION typedef IAssemblyName FriendAssemblyName_t; typedef NonVMComHolder<IAssemblyName> FriendAssemblyNameHolder; @@ -1004,44 +963,11 @@ private: ArrayList m_alFullAccessFriendAssemblies; // Friend assemblies which have access to all internals ArrayList m_subjectAssemblies; // Subject assemblies which we will not perform access checks against -#ifdef FEATURE_FRAMEWORK_INTERNAL - ArrayList m_alPartialAccessFriendAssemblies; // Friend assemblies which have access to only specific internals - EEPtrHashTable m_htFriendMembers; // Cache of internal members checked for visibility to friend assemblies - Crst m_crstFriendMembersCache; // Critical section guarding m_htFriendMembers -#endif // FEATURE_FRAMEWORK_INTERNAL - FriendAssemblyDescriptor(); -#ifdef FEATURE_FRAMEWORK_INTERNAL - void AddFriendAssembly(FriendAssemblyName_t *pFriendAssembly, bool fAllInternalsVisible); -#else // FEATURE_FRAMEWORK_INTERNAL void AddFriendAssembly(FriendAssemblyName_t *pFriendAssembly); -#endif // FEATURE_FRAMEWORK_INTERNAL void AddSubjectAssembly(FriendAssemblyName_t *pSubjectAssembly); -#ifdef FEATURE_FRAMEWORK_INTERNAL - static - bool FriendAccessAppliesTo(FieldDesc *pFD); - - static - bool FriendAccessAppliesTo(MethodDesc *pMD); - - static - bool FriendAccessAppliesTo(MethodTable *pMT); - - static - mdToken GetMetadataToken(FieldDesc *pFD); - - static - mdToken GetMetadataToken(MethodDesc *pMD); - - static - mdToken GetMetadataToken(MethodTable *pMT); - - static - bool HasFriendAccessAttribute(IMDInternalImport *pMDImport); -#endif // FEATURE_FRAMEWORK_INTERNAL - static bool IsAssemblyOnList(Assembly *pAssembly, const ArrayList &alAssemblyNames) { @@ -1050,42 +976,6 @@ private: static bool IsAssemblyOnList(PEAssembly *pAssembly, const ArrayList &alAssemblyNames); - -#ifdef FEATURE_FRAMEWORK_INTERNAL - bool HasFriendAccessAttribute(IMDInternalImport *pMDImport, mdToken tkMember); - - //--------------------------------------------------------------------------------------- - // - // Checks to see if a specific member has the FriendAccessAllowed attribute - // - // - - template<class T> - bool IsMemberVisibleToFriends(T *pMember) - { - CONTRACTL - { - THROWS; - GC_TRIGGERS; - PRECONDITION(CheckPointer(pMember)); - PRECONDITION(FriendAccessAppliesTo(pMember)); - } - CONTRACTL_END; - - CrstHolder lock(&m_crstFriendMembersCache); - - HashDatum hd; - if (!m_htFriendMembers.GetValue(pMember, &hd)) - { - bool fAllowsAccess = HasFriendAccessAttribute(pMember->GetMDImport(), GetMetadataToken(pMember)); - hd = reinterpret_cast<HashDatum>(fAllowsAccess); - - m_htFriendMembers.InsertValue(pMember, hd); - } - - return static_cast<bool>(!!hd); - } -#endif // FEATURE_FRAMEWORK_INTERNAL }; #endif // !DACCESS_COMPILE diff --git a/src/vm/assemblynative.cpp b/src/vm/assemblynative.cpp index c89e927404..1e199bac94 100644 --- a/src/vm/assemblynative.cpp +++ b/src/vm/assemblynative.cpp @@ -530,28 +530,6 @@ Assembly* AssemblyNative::LoadFromBuffer(BOOL fForIntrospection, const BYTE* pAs return pAssembly; } -#ifdef FEATURE_CORECLR -// static -void QCALLTYPE AssemblyNative::LoadFromUnmanagedArray(CLR_BOOL fForIntrospection, BYTE* pAssemblyData, UINT64 uAssemblyLength, BYTE* pPDBData, UINT64 uPDBLength, QCall::StackCrawlMarkHandle stackMark, QCall::ObjectHandleOnStack retAssembly) -{ - QCALL_CONTRACT; - - DomainAssembly * pDomainAssembly = NULL; - - BEGIN_QCALL; - Assembly* pAssembly = NULL; - GCX_COOP(); - pAssembly=LoadFromBuffer(fForIntrospection, pAssemblyData, uAssemblyLength, pPDBData, uPDBLength, stackMark, NULL, kCurrentAppDomain); - pDomainAssembly = pAssembly->GetDomainAssembly(); - retAssembly.Set(pDomainAssembly->GetExposedAssemblyObject()); - END_QCALL; -} -#endif // FEATURE_CORECLR - - - - - FCIMPL6(Object*, AssemblyNative::LoadImage, U1Array* PEByteArrayUNSAFE, U1Array* SymByteArrayUNSAFE, Object* securityUNSAFE, StackCrawlMark* stackMark, CLR_BOOL fForIntrospection, SecurityContextSource securityContextSource) @@ -636,11 +614,6 @@ FCIMPL2(Object*, AssemblyNative::LoadFile, StringObject* pathUNSAFE, Object* sec HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc); -#ifdef FEATURE_CORECLR - if(!GetAppDomain()->IsLoadFileAllowed()) - COMPlusThrow(kNotSupportedException); -#endif - if(CorHost2::IsLoadFromBlocked()) COMPlusThrow(kFileLoadException, FUSION_E_LOADFROM_BLOCKED); @@ -2221,23 +2194,6 @@ void QCALLTYPE AssemblyNative::GetGrantSet(QCall::AssemblyHandle pAssembly, QCal END_QCALL; } -#ifdef FEATURE_LEGACYNETCF -BOOL QCALLTYPE AssemblyNative::GetIsProfileAssembly(QCall::AssemblyHandle pAssembly) -{ - QCALL_CONTRACT; - - BOOL fIsProfile = FALSE; - - BEGIN_QCALL; - - fIsProfile = pAssembly->GetFile()->IsProfileAssembly(); - - END_QCALL; - - return fIsProfile; -} -#endif // FEATURE_LEGACYNETCF - // // QCalls to determine if everything introduced by the assembly is either security critical or safe critical // diff --git a/src/vm/assemblynative.hpp b/src/vm/assemblynative.hpp index 35c2fb1c3c..0c0df020c2 100644 --- a/src/vm/assemblynative.hpp +++ b/src/vm/assemblynative.hpp @@ -49,16 +49,6 @@ public: static FCDECL2(Object*, LoadFile, StringObject* pathUNSAFE, Object* securityUNSAFE); static FCDECL6(Object*, LoadImage, U1Array* PEByteArrayUNSAFE, U1Array* SymByteArrayUNSAFE, Object* securityUNSAFE, StackCrawlMark* stackMark, CLR_BOOL fForIntrospection, SecurityContextSource securityContextSource); -#ifdef FEATURE_CORECLR - static - void QCALLTYPE LoadFromUnmanagedArray(CLR_BOOL fForIntrospection, - BYTE* pAssembly, - UINT64 uAssemblyLength, - BYTE* pPDB, - UINT64 uPDBLength, - QCall::StackCrawlMarkHandle stackMark, - QCall::ObjectHandleOnStack retAssembly); -#endif #ifdef FEATURE_HOSTED_BINDER static FCDECL9(Object*, Load, AssemblyNameBaseObject* assemblyNameUNSAFE, @@ -193,11 +183,6 @@ public: static void QCALLTYPE GetImageRuntimeVersion(QCall::AssemblyHandle pAssembly, QCall::StringHandleOnStack retString); -#ifdef FEATURE_LEGACYNETCF - static - BOOL QCALLTYPE GetIsProfileAssembly(QCall::AssemblyHandle pAssembly); -#endif // FEATURE_LEGACYNETCF - static INT64 QCALLTYPE GetHostContext(QCall::AssemblyHandle pAssembly); diff --git a/src/vm/clsload.cpp b/src/vm/clsload.cpp index 1b8b3eed58..034daaa226 100644 --- a/src/vm/clsload.cpp +++ b/src/vm/clsload.cpp @@ -4898,8 +4898,7 @@ BOOL AccessCheckOptions::DemandMemberAccess(AccessCheckContext *pContext, Method if (visibilityCheck && Security::IsTransparencyEnforcementEnabled()) { // In CoreCLR RMA means visibility checks always succeed if the target is user code. - if ((m_accessCheckType == kRestrictedMemberAccess || m_accessCheckType == kRestrictedMemberAccessNoTransparency) && - !Security::IsMicrosoftPlatform(pTargetMT->GetAssembly()->GetSecurityDescriptor())) + if (m_accessCheckType == kRestrictedMemberAccess || m_accessCheckType == kRestrictedMemberAccessNoTransparency) return TRUE; // Accessing private types/members in platform code. @@ -4919,10 +4918,9 @@ BOOL AccessCheckOptions::DemandMemberAccess(AccessCheckContext *pContext, Method MethodDesc* pCallerMD = pContext->GetCallerMethod(); - // Platform critical code is exempted from all accessibility rules, regardless of the AccessCheckType. + // critical code is exempted from all accessibility rules, regardless of the AccessCheckType. if (pCallerMD != NULL && - !Security::IsMethodTransparent(pCallerMD) - && Security::IsMicrosoftPlatform(pCallerMD->GetAssembly()->GetSecurityDescriptor())) + !Security::IsMethodTransparent(pCallerMD)) { return TRUE; } @@ -5121,15 +5119,6 @@ BOOL AccessCheckOptions::DemandMemberAccessOrFail(AccessCheckContext *pContext, return TRUE; } -#if defined(FEATURE_CORECLR) && defined(CROSSGEN_COMPILE) - CONSISTENCY_CHECK_MSGF(!pContext->GetCallerAssembly()->GetManifestFile()->IsProfileAssembly(), - ("Accessibility check failed while compiling platform assembly. Are you missing FriendAccessAllowed attribute? Caller: %s %s %s Target: %s", - pContext->GetCallerAssembly() ? pContext->GetCallerAssembly()->GetSimpleName() : "", - pContext->GetCallerMT() ? pContext->GetCallerMT()->GetDebugClassName() : "", - pContext->GetCallerMethod() ? pContext->GetCallerMethod()->GetName() : "", - pTargetMT ? pTargetMT->GetDebugClassName() : "")); -#endif - if (m_fThrowIfTargetIsInaccessible) { ThrowAccessException(pContext, pTargetMT); diff --git a/src/vm/corhost.cpp b/src/vm/corhost.cpp index f0e90291b7..f3f9adbb7e 100644 --- a/src/vm/corhost.cpp +++ b/src/vm/corhost.cpp @@ -55,10 +55,6 @@ #include "clrprivtypecachewinrt.h" #endif -#ifdef FEATURE_WINDOWSPHONE -#include "thetestkey.h" -#endif - GVAL_IMPL_INIT(DWORD, g_fHostConfig, 0); #ifdef FEATURE_IMPLICIT_TLS @@ -1588,15 +1584,6 @@ HRESULT CorHost2::_CreateAppDomain( #ifdef FEATURE_CORECLR if (!m_fStarted) return HOST_E_INVALIDOPERATION; - -#if defined(FEATURE_WINDOWSPHONE) && defined(FEATURE_STRONGNAME_TESTKEY_ALLOWED) - if((APPDOMAIN_SET_TEST_KEY & dwFlags) && (m_dwStartupFlags & STARTUP_SINGLE_APPDOMAIN)) - { - const BYTE testKey[] = { TEST_KEY_VALUE }; - memcpy_s(g_rbTestKeyBuffer + sizeof(GUID)*2, sizeof(testKey), testKey, sizeof(testKey)); - } -#endif // defined(FEATURE_WINDOWSPHONE) && defined(FEATURE_STRONGNAME_TESTKEY_ALLOWED) - #endif // FEATURE_CORECLR if(wszFriendlyName == NULL) @@ -1631,30 +1618,9 @@ HRESULT CorHost2::_CreateAppDomain( { pDomain->SetIgnoreUnhandledExceptions(); } - - // Enable interop for all assemblies if the host has asked us to. - if (dwFlags & APPDOMAIN_ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP) - { - pDomain->SetEnablePInvokeAndClassicComInterop(); - } - - if (dwFlags & APPDOMAIN_ENABLE_PLATFORM_SPECIFIC_APPS) - { - pDomain->SetAllowPlatformSpecificAppAssemblies(); - } - - if (dwFlags & APPDOMAIN_ENABLE_ASSEMBLY_LOADFILE) - { - pDomain->SetAllowLoadFile(); - } - - if (dwFlags & APPDOMAIN_DISABLE_TRANSPARENCY_ENFORCEMENT) - { - pDomain->DisableTransparencyEnforcement(); - } #endif // FEATURE_CORECLR - if (dwFlags & APPDOMAIN_SECURITY_FORBID_CROSSAD_REVERSE_PINVOKE) + if (dwFlags & APPDOMAIN_SECURITY_FORBID_CROSSAD_REVERSE_PINVOKE) pDomain->SetReversePInvokeCannotEnter(); if (dwFlags & APPDOMAIN_FORCE_TRIVIAL_WAIT_OPERATIONS) diff --git a/src/vm/dllimport.cpp b/src/vm/dllimport.cpp index 1332c72d1b..45a33e2854 100644 --- a/src/vm/dllimport.cpp +++ b/src/vm/dllimport.cpp @@ -7272,14 +7272,6 @@ VOID NDirect::NDirectLink(NDirectMethodDesc *pMD) // On the phone, we only allow platform assemblies to define pinvokes // unless the host has asked us otherwise. // -#ifdef FEATURE_WINDOWSPHONE - if (!GetAppDomain()->EnablePInvokeAndClassicComInterop()) - { - if (!pMD->GetModule()->GetFile()->GetAssembly()->IsProfileAssembly()) - COMPlusThrow(kNotSupportedException, W("NotSupported_UserDllImport")); - } -#endif //FEATURE_WINDOWS_PHONE - if (pMD->IsClassConstructorTriggeredAtLinkTime()) { diff --git a/src/vm/domainfile.cpp b/src/vm/domainfile.cpp index e16f9d8ab5..3837e82a60 100644 --- a/src/vm/domainfile.cpp +++ b/src/vm/domainfile.cpp @@ -3519,6 +3519,10 @@ BOOL DomainAssembly::CheckZapSecurity(PEImage *pNativeImage) } CONTRACTL_END; +#ifdef FEATURE_CORECLR + return TRUE; +#else + // // System libraries are a special case, the security info's always OK. // @@ -3536,21 +3540,6 @@ BOOL DomainAssembly::CheckZapSecurity(PEImage *pNativeImage) return TRUE; #endif -#if defined(FEATURE_CORECLR) - // Lets first check whether the assembly is going to receive full trust - BOOL fAssemblyIsFullyTrusted = this->GetAppDomain()->IsImageFullyTrusted(pNativeImage); - - // Check if the assembly was ngen as platform - Module * pNativeModule = pNativeImage->GetLoadedLayout()->GetPersistedModuleImage(); - BOOL fImageAndDependenciesAreFullTrust = pNativeModule->m_pModuleSecurityDescriptor->IsMicrosoftPlatform(); - - // return true only if image was ngen at the same trust level as the current trust level. - // images ngen'd as fulltrust can only be loaded in fulltrust and - // non-trusted transparent assembly ngen image can only be loaded in partial trust - // ( only tranparent assemblies can be ngen'd as partial trust.....if it has critical code ngen will error out) - return (fAssemblyIsFullyTrusted == fImageAndDependenciesAreFullTrust); - -#else // FEATURE_CORECLR ETWOnStartup (SecurityCatchCall_V1, SecurityCatchCallEnd_V1); #ifdef CROSSGEN_COMPILE diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h index 2966ab5dbe..babb2676f4 100644 --- a/src/vm/ecalllist.h +++ b/src/vm/ecalllist.h @@ -527,9 +527,6 @@ FCFuncStart(gSignatureNative) FCFuncElement("GetSignature", SignatureNative::GetSignature) FCFuncElement("GetCustomModifiers", SignatureNative::GetCustomModifiers) FCFuncElement("CompareSig", SignatureNative::CompareSig) -#if FEATURE_LEGACYNETCF - FCFuncElement("CompareSigForAppCompat", SignatureNative::CompareSigForAppCompat) -#endif FCFuncEnd() FCFuncStart(gRuntimeMethodHandle) @@ -569,10 +566,10 @@ FCFuncStart(gRuntimeMethodHandle) FCFuncElement("IsConstructor", RuntimeMethodHandle::IsConstructor) QCFuncElement("Destroy", RuntimeMethodHandle::Destroy) FCFuncElement("GetResolver", RuntimeMethodHandle::GetResolver) - QCFuncElement("GetCallerType", RuntimeMethodHandle::GetCallerType) FCFuncElement("GetLoaderAllocator", RuntimeMethodHandle::GetLoaderAllocator) FCFuncElement("GetSpecialSecurityFlags", ReflectionInvocation::GetSpecialSecurityFlags) #ifndef FEATURE_CORECLR + QCFuncElement("GetCallerType", RuntimeMethodHandle::GetCallerType) FCFuncElement("PerformSecurityCheck", ReflectionInvocation::PerformSecurityCheck) #endif // FEATURE_CORECLR FCFuncEnd() @@ -687,7 +684,6 @@ FCFuncStart(gCOMClassWriter) QCFuncElement("SetMethodIL", COMDynamicWrite::SetMethodIL) QCFuncElement("TermCreateClass", COMDynamicWrite::TermCreateClass) QCFuncElement("DefineField", COMDynamicWrite::DefineField) - QCFuncElement("SetPInvokeData", COMDynamicWrite::SetPInvokeData) QCFuncElement("DefineProperty", COMDynamicWrite::DefineProperty) QCFuncElement("DefineEvent", COMDynamicWrite::DefineEvent) QCFuncElement("DefineMethodSemantics", COMDynamicWrite::DefineMethodSemantics) @@ -698,6 +694,7 @@ FCFuncStart(gCOMClassWriter) QCFuncElement("SetClassLayout", COMDynamicWrite::SetClassLayout) QCFuncElement("SetParamInfo", COMDynamicWrite::SetParamInfo) #ifndef FEATURE_CORECLR + QCFuncElement("SetPInvokeData", COMDynamicWrite::SetPInvokeData) QCFuncElement("SetFieldMarshal", COMDynamicWrite::SetFieldMarshal) #endif // FEATURE_CORECLR QCFuncElement("SetConstantValue", COMDynamicWrite::SetConstantValue) @@ -736,9 +733,9 @@ FCFuncEnd() #endif // FEATURE_CAS_POLICY FCFuncStart(gCompatibilitySwitchFuncs) - FCFuncElement("IsEnabledInternalCall", CompatibilitySwitch::IsEnabled) FCFuncElement("GetValueInternalCall", CompatibilitySwitch::GetValue) #ifndef FEATURE_CORECLR + FCFuncElement("IsEnabledInternalCall", CompatibilitySwitch::IsEnabled) FCFuncElement("GetAppContextOverridesInternalCall", CompatibilitySwitch::GetAppContextOverrides) #endif FCFuncEnd() @@ -970,8 +967,6 @@ FCFuncStart(gAppDomainFuncs) #ifndef FEATURE_CORECLR FCFuncElement("GetSecurityDescriptor", AppDomainNative::GetSecurityDescriptor) FCFuncElement("nIsDefaultAppDomainForEvidence", AppDomainNative::IsDefaultAppDomainForEvidence) -#endif -#if defined(FEATURE_CORESYSTEM) || !defined(FEATURE_CORECLR) FCFuncElement("nGetAssemblies", AppDomainNative::GetAssemblies) #endif #ifdef FEATURE_CAS_POLICY @@ -987,7 +982,9 @@ FCFuncStart(gAppDomainFuncs) #if FEATURE_COMINTEROP FCFuncElement("nSetDisableInterfaceCache", AppDomainNative::SetDisableInterfaceCache) #endif // FEATURE_COMINTEROP +#ifndef FEATURE_CORECLR FCFuncElement("_nExecuteAssembly", AppDomainNative::ExecuteAssembly) +#endif #ifdef FEATURE_VERSIONING FCFuncElement("nCreateContext", AppDomainNative::CreateContext) #endif // FEATURE_VERSIONING @@ -1099,11 +1096,8 @@ FCFuncStart(gAssemblyFuncs) FCFuncElement("IsNewPortableAssembly", AssemblyNative::IsNewPortableAssembly) #endif FCFuncElement("nLoadImage", AssemblyNative::LoadImage) -#ifdef FEATURE_CORECLR - QCFuncElement("nLoadFromUnmanagedArray", AssemblyNative::LoadFromUnmanagedArray) -#endif - FCFuncElement("nLoadFile", AssemblyNative::LoadFile) #ifndef FEATURE_CORECLR + FCFuncElement("nLoadFile", AssemblyNative::LoadFile) QCFuncElement("LoadModule", AssemblyNative::LoadModule) #endif // FEATURE_CORECLR QCFuncElement("GetType", AssemblyNative::GetType) @@ -1120,9 +1114,6 @@ FCFuncStart(gAssemblyFuncs) QCFuncElement("GetExportedTypes", AssemblyNative::GetExportedTypes) FCFuncElement("GetManifestResourceNames", AssemblyNative::GetManifestResourceNames) QCFuncElement("GetEntryPoint", AssemblyNative::GetEntryPoint) -#ifdef FEATURE_LEGACYNETCF - QCFuncElement("GetIsProfileAssembly", AssemblyNative::GetIsProfileAssembly) -#endif // FEATURE_LEGACYNETCF QCFuncElement("IsAllSecurityTransparent", AssemblyNative::IsAllSecurityTransparent) QCFuncElement("IsAllSecurityCritical", AssemblyNative::IsAllSecurityCritical) #ifndef FEATURE_CORECLR @@ -1178,16 +1169,14 @@ FCFuncEnd() #endif // defined(FEATURE_HOST_ASSEMBLY_RESOLVER) FCFuncStart(gAssemblyNameFuncs) -#ifndef FEATURE_CORECLR - FCFuncElement("nGetFileInformation", AssemblyNameNative::GetFileInformation) -#endif // FEATURE_CORECLR + FCFuncElement("nInit", AssemblyNameNative::Init) FCFuncElement("nToString", AssemblyNameNative::ToString) FCFuncElement("nGetPublicKeyToken", AssemblyNameNative::GetPublicKeyToken) #ifndef FEATURE_CORECLR FCFuncElement("EscapeCodeBase", AssemblyNameNative::EscapeCodeBase) -#endif // !FEATURE_CORECLR - FCFuncElement("nInit", AssemblyNameNative::Init) FCFuncElement("ReferenceMatchesDefinitionInternal", AssemblyNameNative::ReferenceMatchesDefinition) + FCFuncElement("nGetFileInformation", AssemblyNameNative::GetFileInformation) +#endif // !FEATURE_CORECLR FCFuncEnd() FCFuncStart(gLoaderAllocatorFuncs) @@ -1355,9 +1344,9 @@ FCFuncStart(gThreadFuncs) FCFuncEnd() FCFuncStart(gThreadPoolFuncs) - FCFuncElement("PostQueuedCompletionStatus", ThreadPoolNative::CorPostQueuedCompletionStatus) #ifndef FEATURE_CORECLR - FCFuncElement("GetAvailableThreadsNative", ThreadPoolNative::CorGetAvailableThreads) + FCFuncElement("PostQueuedCompletionStatus", ThreadPoolNative::CorPostQueuedCompletionStatus) + FCFuncElement("GetAvailableThreadsNative", ThreadPoolNative::CorGetAvailableThreads) #endif // FEATURE_CORECLR FCFuncElement("SetMinThreadsNative", ThreadPoolNative::CorSetMinThreads) FCFuncElement("GetMinThreadsNative", ThreadPoolNative::CorGetMinThreads) diff --git a/src/vm/interoputil.cpp b/src/vm/interoputil.cpp index 6b5f897a3b..a9ab7d0039 100644 --- a/src/vm/interoputil.cpp +++ b/src/vm/interoputil.cpp @@ -5315,18 +5315,6 @@ ClassFactoryBase *GetComClassFactory(MethodTable* pClassMT) } else { -#ifdef FEATURE_WINDOWSPHONE - // - // On the phone, anyone can activate WinRT objects, but only platform code can do legacy COM interop. - // (Hosts can override this.) - // - if (!pClassMT->GetModule()->GetFile()->GetAssembly()->IsProfileAssembly() && - !GetAppDomain()->EnablePInvokeAndClassicComInterop()) - { - COMPlusThrow(kNotSupportedException, W("NotSupported_UserCOM")); - } -#endif //FEATURE_WINDOWSPHONE - GUID guid; pClassMT->GetGuid(&guid, TRUE); diff --git a/src/vm/jithelpers.cpp b/src/vm/jithelpers.cpp index 07f263cd55..95ba2b4ae2 100644 --- a/src/vm/jithelpers.cpp +++ b/src/vm/jithelpers.cpp @@ -6039,24 +6039,7 @@ NOINLINE HCIMPL1(void, JIT_VerificationRuntimeCheck_Internal, CORINFO_METHOD_HAN #ifdef FEATURE_CORECLR // Transparent methods that contains unverifiable code is not allowed. MethodDesc *pMethod = GetMethod(methHnd_); - -#if defined(FEATURE_CORECLR_COVERAGE_BUILD) && defined(FEATURE_STRONGNAME_DELAY_SIGNING_ALLOWED) - // For code coverage builds we have an issue where the inserted IL is not verifiable. - // This means that transparent methods in platform assemblies will throw verification exceptions. - // Temporary fix is to allow transparent methods in platform assemblies to be unverifiable only on coverage builds. - // Paranoia: allow this only on non ret builds - all builds except the RET type will have - // FEATURE_STRONGNAME_DELAY_SIGNING_ALLOWED defined. So we can use that to figure out if this is a RET build - // type that someone is trying to relax that constraint on and not allow that. - if (!pMethod->GetModule()->GetFile()->GetAssembly()->IsProfileAssembly()) - { - // Only throw if pMethod is not in any platform assembly. - SecurityTransparent::ThrowMethodAccessException(pMethod); - } -#else // defined(FEATURE_CORECLR_COVERAGE_BUILD) && defined(FEATURE_STRONGNAME_DELAY_SIGNING_ALLOWED) - SecurityTransparent::ThrowMethodAccessException(pMethod); -#endif // defined(FEATURE_CORECLR_COVERAGE_BUILD) && defined(FEATURE_STRONGNAME_DELAY_SIGNING_ALLOWED) - #else // FEATURE_CORECLR // // inject a full-demand for unmanaged code permission at runtime diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp index 0a5154aa4f..3247ccb100 100644 --- a/src/vm/jitinterface.cpp +++ b/src/vm/jitinterface.cpp @@ -7671,15 +7671,6 @@ CorInfoInstantiationVerification goto exit; } -#ifdef FEATURE_CORECLR - //Skip verification of all methods in profile assemblies. We will ensure that they are all verifiable. - if (pMethod->GetModule()->GetFile()->GetAssembly()->IsProfileAssembly()) - { - result = INSTVER_GENERIC_PASSED_VERIFICATION; - goto exit; - } -#endif - result = pMethod->IsVerifiable() ? INSTVER_GENERIC_PASSED_VERIFICATION : INSTVER_GENERIC_FAILED_VERIFICATION; diff --git a/src/vm/pefile.cpp b/src/vm/pefile.cpp index f4abb5f2f5..f6bf408cac 100644 --- a/src/vm/pefile.cpp +++ b/src/vm/pefile.cpp @@ -266,57 +266,6 @@ BOOL PEFile::CanLoadLibrary() return IsILOnly(); } - -#ifdef FEATURE_CORECLR -void PEFile::ValidateImagePlatformNeutrality() -{ - STANDARD_VM_CONTRACT; - - //-------------------------------------------------------------------------------- - // There are no useful applications of the "/platform" switch for CoreCLR. - // CoreCLR will do the conservative thing and by default only accept appbase assemblies - // compiled with "/platform:anycpu" (or no "/platform" switch at all.) - // However, with hosting flags it is possible to suppress this check and allow - // platform specific assemblies. This was primarily added to support C++/CLI - // generated assemblies build with /CLR:PURE flags. This was a need for the CoreSystem - // server work. - // - // We do allow Platform assemblies to have platform specific code (because they - // in fact do have such code. - //-------------------------------------------------------------------------------- - if (!(GetAssembly()->IsProfileAssembly()) && !GetAppDomain()->AllowPlatformSpecificAppAssemblies()) - { - - DWORD machine, kind; - BOOL fMachineOk,fPlatformFlagsOk; - -#ifdef FEATURE_TREAT_NI_AS_MSIL_DURING_DIAGNOSTICS - if (ShouldTreatNIAsMSIL() && GetILimage()->HasNativeHeader()) - { - GetILimage()->GetNativeILPEKindAndMachine(&kind, &machine); - } - else -#endif // FEATURE_TREAT_NI_AS_MSIL_DURING_DIAGNOSTICS - { - //The following function gets the kind and machine given by the IL image. - //In the case of NGened images- It gets the original kind and machine of the IL image - //from the copy maintained by NI - GetPEKindAndMachine(&kind, &machine); - } - - fMachineOk = (machine == IMAGE_FILE_MACHINE_I386); - fPlatformFlagsOk = ((kind & (peILonly | pe32Plus | pe32BitRequired)) == peILonly); - - if (!(fMachineOk && - fPlatformFlagsOk)) - { - // This exception matches what the desktop OS hook throws - unfortunate that this is so undescriptive. - COMPlusThrowHR(COR_E_BADIMAGEFORMAT); - } - } -} -#endif - #ifdef FEATURE_MIXEDMODE #ifndef CROSSGEN_COMPILE @@ -595,11 +544,6 @@ void PEFile::LoadLibrary(BOOL allowNativeSkip/*=TRUE*/) // if allowNativeSkip==F // See if we've already loaded it. if (CheckLoaded(allowNativeSkip)) { -#ifdef FEATURE_CORECLR - if (!IsResource() && !IsDynamic()) - ValidateImagePlatformNeutrality(); -#endif //FEATURE_CORECLR - #ifdef FEATURE_MIXEDMODE // Prevent loading C++/CLI images into multiple runtimes in the same process. Note that if ILOnly images // stop being LoadLibrary'ed, the check for pure 2.0 C++/CLI images will need to be done somewhere else. @@ -618,10 +562,6 @@ void PEFile::LoadLibrary(BOOL allowNativeSkip/*=TRUE*/) // if allowNativeSkip==F RETURN; } -#ifdef FEATURE_CORECLR - ValidateImagePlatformNeutrality(); -#endif //FEATURE_CORECLR - #if !defined(_WIN64) if (!HasNativeImage() && (!GetILimage()->Has32BitNTHeaders()) && !IsIntrospectionOnly()) { @@ -4397,72 +4337,10 @@ BOOL PEAssembly::IsProfileAssembly() // from the old Silverlight binder, people took advantage of it and we cannot easily get rid of it now. See DevDiv #710462. // BOOL bProfileAssembly = IsSourceGAC() && (IsSystem() || m_bIsOnTpaList); - if(!AppX::IsAppXProcess()) - { - bProfileAssembly |= IsSourceGAC() && IsSilverlightPlatformStrongNameSignature(); - } m_fProfileAssembly = bProfileAssembly ? 1 : -1; return bProfileAssembly; } - -BOOL PEAssembly::IsSilverlightPlatformStrongNameSignature() -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - if (IsDynamic()) - return FALSE; - - DWORD cbPublicKey; - const BYTE *pbPublicKey = static_cast<const BYTE *>(GetPublicKey(&cbPublicKey)); - if (pbPublicKey == nullptr) - { - return false; - } - - if (StrongNameIsSilverlightPlatformKey(pbPublicKey, cbPublicKey)) - return true; - -#ifdef FEATURE_STRONGNAME_TESTKEY_ALLOWED - if (StrongNameIsTestKey(pbPublicKey, cbPublicKey)) - return true; -#endif - - return false; -} - -#ifdef FEATURE_STRONGNAME_TESTKEY_ALLOWED -BOOL PEAssembly::IsProfileTestAssembly() -{ - WRAPPER_NO_CONTRACT; - - return IsSourceGAC() && IsTestKeySignature(); -} - -BOOL PEAssembly::IsTestKeySignature() -{ - WRAPPER_NO_CONTRACT; - - if (IsDynamic()) - return FALSE; - - DWORD cbPublicKey; - const BYTE *pbPublicKey = static_cast<const BYTE *>(GetPublicKey(&cbPublicKey)); - if (pbPublicKey == nullptr) - { - return false; - } - - return StrongNameIsTestKey(pbPublicKey, cbPublicKey); -} -#endif // FEATURE_STRONGNAME_TESTKEY_ALLOWED - #endif // FEATURE_CORECLR // ------------------------------------------------------------ diff --git a/src/vm/pefile.h b/src/vm/pefile.h index 1d1b715feb..5cf5dfb937 100644 --- a/src/vm/pefile.h +++ b/src/vm/pefile.h @@ -834,9 +834,6 @@ class PEAssembly : public PEFile BOOL IsSourceGAC(); #ifdef FEATURE_CORECLR BOOL IsProfileAssembly(); - BOOL IsSilverlightPlatformStrongNameSignature(); - BOOL IsProfileTestAssembly(); - BOOL IsTestKeySignature(); #endif // FEATURE_CORECLR ULONG HashIdentity(); diff --git a/src/vm/security.cpp b/src/vm/security.cpp index daa32be6e9..95c16bf5cd 100644 --- a/src/vm/security.cpp +++ b/src/vm/security.cpp @@ -55,9 +55,9 @@ BOOL Security::IsTransparencyEnforcementEnabled() LIMITED_METHOD_CONTRACT; #ifdef FEATURE_CORECLR - if (GetAppDomain()->IsTransparencyEnforcementDisabled()) - return FALSE; -#endif + // No transparency enforcement in .NET Core + return FALSE; +#else #ifdef _DEBUG if (g_pConfig->DisableTransparencyEnforcement()) @@ -65,6 +65,7 @@ BOOL Security::IsTransparencyEnforcementEnabled() #endif return TRUE; +#endif // FEATURE_CORECLR } //--------------------------------------------------------------------------------------- diff --git a/src/vm/security.h b/src/vm/security.h index e5698e6575..2238279cd7 100644 --- a/src/vm/security.h +++ b/src/vm/security.h @@ -236,10 +236,6 @@ namespace Security inline SString GetConditionalAptcaAccessExceptionContext(Assembly *pTargetAssembly); #endif // FEATURE_APTCA -#ifdef FEATURE_CORECLR - inline BOOL IsMicrosoftPlatform(IAssemblySecurityDescriptor *pSecDesc); -#endif // FEATURE_CORECLR - inline bool SecurityCalloutQuickCheck(MethodDesc *pCallerMD); inline bool CanShareAssembly(DomainAssembly *pAssembly); diff --git a/src/vm/security.inl b/src/vm/security.inl index 745de2866d..2f1f96cca8 100644 --- a/src/vm/security.inl +++ b/src/vm/security.inl @@ -550,6 +550,11 @@ inline BOOL Security::CanSkipVerification(MethodDesc * pMD) } CONTRACTL_END; +#ifdef FEATURE_CORECLR + // Always skip verification on CoreCLR + return TRUE; +#else + // Special case the System.Object..ctor: // System.Object..ctor is not verifiable according to current verifier rules (that require to call the base // class ctor). But since we want System.Object..ctor() to be marked transparent, it cannot be unverifiable @@ -570,32 +575,18 @@ inline BOOL Security::CanSkipVerification(MethodDesc * pMD) BOOL fCanSkipVerification = Security::CanSkipVerification(pMD->GetAssembly()->GetDomainAssembly()); if (fCanSkipVerification) { -#ifdef FEATURE_CORECLR - //For Profile assemblies, do not verify any code. All Transparent methods are guaranteed to be - //verifiable (verified by tests). Therefore, skip all verification on platform assemblies. - if(pMD->GetAssembly()->GetDomainAssembly()->GetFile()->IsProfileAssembly()) - return TRUE; -#endif // check for transparency if (SecurityTransparent::IsMethodTransparent(pMD)) { -#ifndef FEATURE_CORECLR ModuleSecurityDescriptor *pModuleSecDesc = ModuleSecurityDescriptor::GetModuleSecurityDescriptor(pMD->GetAssembly()); if (!pModuleSecDesc->CanTransparentCodeSkipVerification()) -#endif // !FEATURE_CORECLR { return FALSE; } } } -#if defined(_DEBUG) && defined(FEATURE_CORECLR) - else - { - //Profile assemblies must have skip verification. - _ASSERTE(!pMD->GetAssembly()->GetDomainAssembly()->GetFile()->IsProfileAssembly()); - } -#endif //_DEBUG && FEATURE_CORECLR return fCanSkipVerification; +#endif // !FEATURE_CORECLR } #endif //!DACCESS_COMPILE @@ -657,18 +648,6 @@ inline SString Security::GetConditionalAptcaAccessExceptionContext(Assembly *pTa #endif // FEATURE_APTCA -#ifdef FEATURE_CORECLR -#ifndef DACCESS_COMPILE - -inline BOOL Security::IsMicrosoftPlatform(IAssemblySecurityDescriptor *pSecDesc) -{ - WRAPPER_NO_CONTRACT; - return static_cast<AssemblySecurityDescriptor*>(pSecDesc)->IsMicrosoftPlatform(); -} -#endif // DACCESS_COMPILE -#endif // FEATURE_CORECLR - - inline bool Security::SecurityCalloutQuickCheck(MethodDesc *pCallerMD) { WRAPPER_NO_CONTRACT; diff --git a/src/vm/securitydescriptorassembly.cpp b/src/vm/securitydescriptorassembly.cpp index fb28bd4c7b..c2aef22019 100644 --- a/src/vm/securitydescriptorassembly.cpp +++ b/src/vm/securitydescriptorassembly.cpp @@ -486,90 +486,7 @@ void AssemblySecurityDescriptor::ResolveWorker() } CONTRACTL_END; #ifdef FEATURE_CORECLR - - if (NingenEnabled()) - { - int dwSpecialFlags; - BOOL platformAssembly = FALSE; - - if (IsSystem()) - { - dwSpecialFlags = 0xFFFFFFFF; - platformAssembly = TRUE; - } - else - { - // Decide if this is a platform assembly - if (m_pAssem->GetFile()->IsProfileAssembly()) - platformAssembly = TRUE; - - // Decide trust level - if (platformAssembly) - { - dwSpecialFlags = 0xFFFFFFFF; - } - else - { - dwSpecialFlags = m_pAppDomain->GetSecurityDescriptor()->GetSpecialFlags(); - } - } - - SetGrantedPermissionSet(NULL, NULL, dwSpecialFlags); - if (platformAssembly) - SetMicrosoftPlatform(); - - return; - } - -#ifndef CROSSGEN_COMPILE - int dwSpecialFlags; - BOOL platformAssembly = FALSE; - BOOL trustedAssembly = FALSE; - - struct _gc { - OBJECTREF granted; // Policy based Granted Permission - } gc; - ZeroMemory(&gc, sizeof(gc)); - GCPROTECT_BEGIN(gc); - - if (IsSystem()) - { - // mscorlib is always FT, but we can't create permissionsets yet. So grantset for mscorlib will be NULL: we should never look at it though. - dwSpecialFlags = 0xFFFFFFFF; - platformAssembly = TRUE; - } - else - { - // Decide if this is a platform assembly - if (m_pAssem->GetFile()->IsProfileAssembly()) - platformAssembly = TRUE; - - // Decide trust level - if (platformAssembly || trustedAssembly) - { - Security::GetPermissionInstance(&gc.granted, SECURITY_FULL_TRUST); - dwSpecialFlags = 0xFFFFFFFF; - } - else - { - // get grant from AppDomain grant set. - gc.granted = m_pAppDomain->GetSecurityDescriptor()->GetGrantedPermissionSet(NULL); - dwSpecialFlags = m_pAppDomain->GetSecurityDescriptor()->GetSpecialFlags(); - } - - } - SetGrantedPermissionSet(gc.granted, NULL, dwSpecialFlags); - if (platformAssembly) - SetMicrosoftPlatform(); - - // Only fully trusted assemblies are allowed to be loaded when - // the AppDomain is in the initialization phase. - if (m_pAppDomain->GetSecurityDescriptor()->IsInitializationInProgress() && !IsFullyTrusted()) - COMPlusThrow(kApplicationException, W("Policy_CannotLoadSemiTrustAssembliesDuringInit")); - - GCPROTECT_END(); -#endif // CROSSGEN_COMPILE - + SetGrantedPermissionSet(NULL, NULL, 0xFFFFFFFF); #else if (CanSkipPolicyResolution() || NingenEnabled()) { SetGrantedPermissionSet(NULL, NULL, 0xFFFFFFFF); @@ -1017,9 +934,6 @@ void SharedSecurityDescriptor::Resolve(IAssemblySecurityDescriptor *pSecDesc) m_fFullyTrusted = pSecDesc->IsFullyTrusted(); m_fCanCallUnmanagedCode = pSecDesc->CanCallUnmanagedCode(); m_fCanAssert = pSecDesc->CanAssert(); -#ifdef FEATURE_CORECLR - m_fMicrosoftPlatform = static_cast<AssemblySecurityDescriptor*>(pSecDesc)->IsMicrosoftPlatform(); -#endif // FEATURE_CORECLR m_fResolved = TRUE; } diff --git a/src/vm/securitydescriptorassembly.h b/src/vm/securitydescriptorassembly.h index 132a1d8c86..15bc83eef6 100644 --- a/src/vm/securitydescriptorassembly.h +++ b/src/vm/securitydescriptorassembly.h @@ -133,10 +133,6 @@ public: virtual void CheckAllowAssemblyLoad(); -#ifdef FEATURE_CORECLR - inline BOOL IsMicrosoftPlatform(); -#endif // FEATURE_CORECLR - private: BOOL CanSkipPolicyResolution(); OBJECTREF UpgradePEFileEvidenceToAssemblyEvidence(const OBJECTREF& objPEFileEvidence); @@ -156,9 +152,6 @@ private: inline BOOL IsConditionalAptca(); #endif // FEATURE_APTCA -#ifdef FEATURE_CORECLR - inline void SetMicrosoftPlatform(); -#endif // FEAUTRE_CORECLR #endif // #ifndef DACCESS_COMPILE }; @@ -193,7 +186,6 @@ public: virtual BOOL IsSystem(); virtual Assembly* GetAssembly(); - inline BOOL IsMicrosoftPlatform(); BOOL IsFullyTrusted(); BOOL CanCallUnmanagedCode() const; BOOL CanAssert(); diff --git a/src/vm/securitydescriptorassembly.inl b/src/vm/securitydescriptorassembly.inl index a72efa2123..44b49a32c9 100644 --- a/src/vm/securitydescriptorassembly.inl +++ b/src/vm/securitydescriptorassembly.inl @@ -57,22 +57,6 @@ inline void AssemblySecurityDescriptor::SetSignatureLoaded() #endif // FEATURE_CAS_POLICY -#ifdef FEATURE_CORECLR - -inline BOOL AssemblySecurityDescriptor::IsMicrosoftPlatform() -{ - LIMITED_METHOD_CONTRACT; - return m_fMicrosoftPlatform; -} - -inline void AssemblySecurityDescriptor::SetMicrosoftPlatform() -{ - LIMITED_METHOD_CONTRACT; - m_fMicrosoftPlatform = TRUE; -} - -#endif // FEATURE_CORECLR - #ifdef FEATURE_APTCA inline BOOL AssemblySecurityDescriptor::IsConditionalAptca() @@ -86,12 +70,6 @@ inline BOOL AssemblySecurityDescriptor::IsConditionalAptca() #endif // !DACCESS_COMPILE -inline BOOL SharedSecurityDescriptor::IsMicrosoftPlatform() -{ - LIMITED_METHOD_CONTRACT; - return m_fMicrosoftPlatform; -} - inline AssemblyLoadSecurity::AssemblyLoadSecurity() : m_pEvidence(NULL), m_pAdditionalEvidence(NULL), diff --git a/src/vm/securitymeta.cpp b/src/vm/securitymeta.cpp index 85c81f75db..980958d49f 100644 --- a/src/vm/securitymeta.cpp +++ b/src/vm/securitymeta.cpp @@ -1712,17 +1712,6 @@ void ModuleSecurityDescriptor::VerifyDataComputed() } #endif // _DEBUG -#ifdef FEATURE_CORECLR - if (pAssembly->IsSystem() || (pAssembly->GetManifestFile()->HasOpenedILimage() && GetAppDomain()->IsImageFullyTrusted(pAssembly->GetManifestFile()->GetOpenedILimage()))) - { - // Set the flag if the assembly is microsoft platform. This gets saved in Ngen Image - // to determinne if the NI was genrated as full-trust. If NI is generated as full-trust - // the codegen is generated different as compared to non-trusted. - _ASSERTE(!(moduleFlags & ModuleSecurityDescriptorFlags_IsMicrosoftPlatform)); - moduleFlags |= ModuleSecurityDescriptorFlags_IsMicrosoftPlatform; - } -#endif - // Mark the module as having its security state computed moduleFlags |= ModuleSecurityDescriptorFlags_IsComputed; InterlockedCompareExchange(reinterpret_cast<LONG *>(&m_flags), diff --git a/src/vm/securitymeta.h b/src/vm/securitymeta.h index 01b7e325a2..d78b7bde54 100644 --- a/src/vm/securitymeta.h +++ b/src/vm/securitymeta.h @@ -559,8 +559,6 @@ enum ModuleSecurityDescriptorFlags ModuleSecurityDescriptorFlags_IsOpportunisticallyCritical = 0x0020, // Ensure that the assembly follows all transparency rules by making all methods critical or safe critical as needed ModuleSecurityDescriptorFlags_SkipFullTrustVerification = 0x0040, // Fully trusted transparent code does not require verification ModuleSecurityDescriptorFlags_TransparentDueToPartialTrust = 0x0080, // Whether we made the assembly all transparent because it was partially-trusted - ModuleSecurityDescriptorFlags_IsMicrosoftPlatform = 0x0100, // Whether we made the assembly microsoft platform. Stored in ngen image to determine if the ngen - // was generated as microsoft platform assembly (full trust) or not. }; inline ModuleSecurityDescriptorFlags operator|(ModuleSecurityDescriptorFlags lhs, @@ -615,9 +613,6 @@ public: inline ModuleSecurityDescriptorFlags GetRawFlags(); #endif // DACCESS_COMPILE - // Is Microsoft Platform - inline BOOL IsMicrosoftPlatform(); - // Is every method and type in the assembly transparent inline BOOL IsAllTransparent(); diff --git a/src/vm/securitymeta.inl b/src/vm/securitymeta.inl index a735599c61..adb6faa5ac 100644 --- a/src/vm/securitymeta.inl +++ b/src/vm/securitymeta.inl @@ -1060,13 +1060,6 @@ inline ModuleSecurityDescriptorFlags ModuleSecurityDescriptor::GetRawFlags() } #endif // DACCESS_COMPILE -inline BOOL ModuleSecurityDescriptor::IsMicrosoftPlatform() -{ - WRAPPER_NO_CONTRACT; - VerifyDataComputed(); - return !!(m_flags & ModuleSecurityDescriptorFlags_IsMicrosoftPlatform); -} - inline BOOL ModuleSecurityDescriptor::IsAllTransparent() { WRAPPER_NO_CONTRACT; diff --git a/src/vm/securitytransparentassembly.cpp b/src/vm/securitytransparentassembly.cpp index f3ab6e22cd..4a23c276d8 100644 --- a/src/vm/securitytransparentassembly.cpp +++ b/src/vm/securitytransparentassembly.cpp @@ -528,29 +528,7 @@ CorInfoCanSkipVerificationResult SecurityTransparent::JITCanSkipVerification(Met CorInfoCanSkipVerificationResult canSkipVerif = hasSkipVerificationPermisson ? CORINFO_VERIFICATION_CAN_SKIP : CORINFO_VERIFICATION_CANNOT_SKIP; -#ifdef FEATURE_CORECLR - //For Profile assemblies, do not verify any code. All Transparent methods are guaranteed to be - //verifiable (verified by tests). Therefore, skip all verification on platform assemblies. - - //All profile assemblies have skip verification. - _ASSERTE(!(pDomainAssembly->GetFile()->IsProfileAssembly() && !hasSkipVerificationPermisson)); - -#ifdef FEATURE_CORESYSTEM - // - // On Phone, at runtime, enable verification for user code that will run as transparent: - // - All Mango applications - // - Apollo applications with transparent code - // - if (hasSkipVerificationPermisson && !pDomainAssembly->GetFile()->IsProfileAssembly()) - { - if (SecurityTransparent::IsMethodTransparent(pMD)) - { - canSkipVerif = CORINFO_VERIFICATION_CANNOT_SKIP; - } - } -#endif // FEATURE_CORESYSTEM - -#else //FEATURE_CORECLR +#ifndef FEATURE_CORECLR // also check to see if the method is marked transparent if (hasSkipVerificationPermisson) { @@ -943,17 +921,7 @@ static void ConvertLinkDemandToFullDemand(MethodDesc* pCallerMD, MethodDesc* pCa } else { -#if defined(FEATURE_CORECLR_COVERAGE_BUILD) && defined(FEATURE_STRONGNAME_DELAY_SIGNING_ALLOWED) - // For code coverage builds we have an issue where the inserted types/methods are not annotated. - // In patricular, there may be p/invokes from transparent code. Allow that on cov builds for platform assemblies. - // Paranoia: allow this only on non shp builds - all builds except the SHP type will have - // FEATURE_STRONGNAME_DELAY_SIGNING_ALLOWED defined. So we can use that to figure out if this is a SHP build - // type that someone is trying to relax that constraint on and not allow that. - if (!pCalleeMD->GetModule()->GetFile()->GetAssembly()->IsProfileAssembly()) -#endif // defined(FEATURE_CORECLR_COVERAGE_BUILD) && defined(FEATURE_STRONGNAME_DELAY_SIGNING_ALLOWED) - { - ::ThrowMethodAccessException(pCallerMD, pCalleeMD, FALSE, IDS_E_TRANSPARENT_CALL_NATIVE); - } + ::ThrowMethodAccessException(pCallerMD, pCalleeMD, FALSE, IDS_E_TRANSPARENT_CALL_NATIVE); } } |