From ee8bc3272391e46862dd8d27d3e086dc3bf953cf Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 7 Jan 2019 04:16:50 +0100 Subject: Remove CAS era security checks around resource loads (#21825) --- .../src/System/Reflection/RuntimeAssembly.cs | 94 ++++++---------------- .../System/Resources/FileBasedResourceGroveler.cs | 2 +- .../src/System/Resources/IResourceGroveler.cs | 2 +- .../Resources/ManifestBasedResourceGroveler.cs | 41 +++------- .../src/System/Resources/ResourceManager.cs | 83 ++----------------- src/vm/assembly.cpp | 5 +- src/vm/assembly.hpp | 1 - src/vm/assemblynative.cpp | 16 ++-- src/vm/assemblynative.hpp | 4 +- src/vm/domainfile.cpp | 3 - src/vm/domainfile.h | 1 - src/vm/pefile.cpp | 28 ------- src/vm/pefile.h | 1 - 13 files changed, 53 insertions(+), 228 deletions(-) (limited to 'src') diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index 8d1b8c9254..45d73a65bf 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -194,19 +194,36 @@ namespace System.Reflection public override bool IsCollectible => GetIsCollectible(GetNativeHandle()); + // GetResource will return a pointer to the resources in memory. + [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] + private static extern unsafe byte* GetResource(RuntimeAssembly assembly, + string resourceName, + out uint length); + // Load a resource based on the NameSpace of the type. - [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public override Stream GetManifestResourceStream(Type type, string name) { - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - return GetManifestResourceStream(type, name, false, ref stackMark); + if (type == null && name == null) + throw new ArgumentNullException(nameof(type)); + + string nameSpace = type?.Namespace; + string delimiter = (nameSpace != null && name != null) ? Type.Delimiter.ToString() : null; + string resourceName = string.Concat(nameSpace, delimiter, name); + + return GetManifestResourceStream(resourceName); } - [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - public override Stream GetManifestResourceStream(string name) + public unsafe override Stream GetManifestResourceStream(string name) { - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - return GetManifestResourceStream(name, ref stackMark, false); + uint length = 0; + byte* pbInMemoryResource = GetResource(GetNativeHandle(), name, out length); + + if (pbInMemoryResource != null) + { + return new UnmanagedMemoryStream(pbInMemoryResource, length, length, FileAccess.Read); + } + + return null; } // ISerializable implementation @@ -433,19 +450,15 @@ namespace System.Reflection private static extern int GetManifestResourceInfo(RuntimeAssembly assembly, string resourceName, ObjectHandleOnStack assemblyRef, - StringHandleOnStack retFileName, - StackCrawlMarkHandle stackMark); + StringHandleOnStack retFileName); - [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public override ManifestResourceInfo GetManifestResourceInfo(string resourceName) { RuntimeAssembly retAssembly = null; string fileName = null; - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; int location = GetManifestResourceInfo(GetNativeHandle(), resourceName, JitHelpers.GetObjectHandleOnStack(ref retAssembly), - JitHelpers.GetStringHandleOnStack(ref fileName), - JitHelpers.GetStackCrawlMarkHandle(ref stackMark)); + JitHelpers.GetStringHandleOnStack(ref fileName)); if (location == -1) return null; @@ -526,61 +539,6 @@ namespace System.Reflection #endif // PLATFORM_WINDOWS } - internal Stream GetManifestResourceStream( - Type type, - string name, - bool skipSecurityCheck, - ref StackCrawlMark stackMark) - { - StringBuilder sb = new StringBuilder(); - if (type == null) - { - if (name == null) - throw new ArgumentNullException(nameof(type)); - } - else - { - string nameSpace = type.Namespace; - if (nameSpace != null) - { - sb.Append(nameSpace); - if (name != null) - sb.Append(Type.Delimiter); - } - } - - if (name != null) - sb.Append(name); - - return GetManifestResourceStream(sb.ToString(), ref stackMark, skipSecurityCheck); - } - - // GetResource will return a pointer to the resources in memory. - [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern unsafe byte* GetResource(RuntimeAssembly assembly, - string resourceName, - out ulong length, - StackCrawlMarkHandle stackMark, - bool skipSecurityCheck); - - internal unsafe Stream GetManifestResourceStream(string name, ref StackCrawlMark stackMark, bool skipSecurityCheck) - { - ulong length = 0; - byte* pbInMemoryResource = GetResource(GetNativeHandle(), name, out length, JitHelpers.GetStackCrawlMarkHandle(ref stackMark), skipSecurityCheck); - - if (pbInMemoryResource != null) - { - //Console.WriteLine("Creating an unmanaged memory stream of length "+length); - if (length > long.MaxValue) - throw new NotImplementedException(SR.NotImplemented_ResourcesLongerThanInt64Max); - - return new UnmanagedMemoryStream(pbInMemoryResource, (long)length, (long)length, FileAccess.Read); - } - - //Console.WriteLine("GetManifestResourceStream: Blob "+name+" not found..."); - return null; - } - [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void GetVersion(RuntimeAssembly assembly, out int majVer, diff --git a/src/System.Private.CoreLib/src/System/Resources/FileBasedResourceGroveler.cs b/src/System.Private.CoreLib/src/System/Resources/FileBasedResourceGroveler.cs index eafffd34cf..216ebb1e4a 100644 --- a/src/System.Private.CoreLib/src/System/Resources/FileBasedResourceGroveler.cs +++ b/src/System.Private.CoreLib/src/System/Resources/FileBasedResourceGroveler.cs @@ -34,7 +34,7 @@ namespace System.Resources // Consider modifying IResourceGroveler interface (hence this method signature) when we figure out // serialization compat story for moving ResourceManager members to either file-based or // manifest-based classes. Want to continue tightening the design to get rid of unused params. - public ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, bool createIfNotExists, ref StackCrawlMark stackMark) + public ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, bool createIfNotExists) { Debug.Assert(culture != null, "culture shouldn't be null; check caller"); diff --git a/src/System.Private.CoreLib/src/System/Resources/IResourceGroveler.cs b/src/System.Private.CoreLib/src/System/Resources/IResourceGroveler.cs index 8151a7a675..b954db969b 100644 --- a/src/System.Private.CoreLib/src/System/Resources/IResourceGroveler.cs +++ b/src/System.Private.CoreLib/src/System/Resources/IResourceGroveler.cs @@ -24,6 +24,6 @@ namespace System.Resources internal interface IResourceGroveler { ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, - bool createIfNotExists, ref StackCrawlMark stackMark); + bool createIfNotExists); } } diff --git a/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs b/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs index ea754c1489..fe95bf1c8f 100644 --- a/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs +++ b/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs @@ -51,7 +51,7 @@ namespace System.Resources _mediator = mediator; } - public ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, bool createIfNotExists, ref StackCrawlMark stackMark) + public ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, bool createIfNotExists) { Debug.Assert(culture != null, "culture shouldn't be null; check caller"); Debug.Assert(localResourceSets != null, "localResourceSets shouldn't be null; check caller"); @@ -100,7 +100,7 @@ namespace System.Resources localResourceSets.TryGetValue(culture.Name, out rs); } - stream = GetManifestResourceStream(satellite, fileName, ref stackMark); + stream = GetManifestResourceStream(satellite, fileName); } // 4a. Found a stream; create a ResourceSet if possible @@ -306,17 +306,12 @@ namespace System.Resources } } - private Stream GetManifestResourceStream(RuntimeAssembly satellite, string fileName, ref StackCrawlMark stackMark) + private Stream GetManifestResourceStream(RuntimeAssembly satellite, string fileName) { Debug.Assert(satellite != null, "satellite shouldn't be null; check caller"); Debug.Assert(fileName != null, "fileName shouldn't be null; check caller"); - // If we're looking in the main assembly AND if the main assembly was the person who - // created the ResourceManager, skip a security check for private manifest resources. - bool canSkipSecurityCheck = (_mediator.MainAssembly == satellite) - && (_mediator.CallingAssembly == _mediator.MainAssembly); - - Stream stream = satellite.GetManifestResourceStream(_mediator.LocationInfo, fileName, canSkipSecurityCheck, ref stackMark); + Stream stream = satellite.GetManifestResourceStream(_mediator.LocationInfo, fileName); if (stream == null) { stream = CaseInsensitiveManifestResourceStreamLookup(satellite, fileName); @@ -329,30 +324,19 @@ namespace System.Resources // case-insensitive lookup rules. Yes, this is slow. The metadata // dev lead refuses to make all assembly manifest resource lookups case-insensitive, // even optionally case-insensitive. - [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod private Stream CaseInsensitiveManifestResourceStreamLookup(RuntimeAssembly satellite, string name) { Debug.Assert(satellite != null, "satellite shouldn't be null; check caller"); Debug.Assert(name != null, "name shouldn't be null; check caller"); - StringBuilder sb = new StringBuilder(); - if (_mediator.LocationInfo != null) - { - string nameSpace = _mediator.LocationInfo.Namespace; - if (nameSpace != null) - { - sb.Append(nameSpace); - if (name != null) - sb.Append(Type.Delimiter); - } - } - sb.Append(name); + string nameSpace = _mediator.LocationInfo?.Namespace; + string delimiter = (nameSpace != null && name != null) ? Type.Delimiter.ToString() : null; + string resourceName = string.Concat(nameSpace, delimiter, name); - string givenName = sb.ToString(); string canonicalName = null; foreach (string existingName in satellite.GetManifestResourceNames()) { - if (string.Equals(existingName, givenName, StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(existingName, resourceName, StringComparison.InvariantCultureIgnoreCase)) { if (canonicalName == null) { @@ -360,7 +344,7 @@ namespace System.Resources } else { - throw new MissingManifestResourceException(SR.Format(SR.MissingManifestResource_MultipleBlobs, givenName, satellite.ToString())); + throw new MissingManifestResourceException(SR.Format(SR.MissingManifestResource_MultipleBlobs, resourceName, satellite.ToString())); } } } @@ -370,12 +354,7 @@ namespace System.Resources return null; } - // If we're looking in the main assembly AND if the main - // assembly was the person who created the ResourceManager, - // skip a security check for private manifest resources. - bool canSkipSecurityCheck = _mediator.MainAssembly == satellite && _mediator.CallingAssembly == _mediator.MainAssembly; - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - return satellite.GetManifestResourceStream(canonicalName, ref stackMark, canSkipSecurityCheck); + return satellite.GetManifestResourceStream(canonicalName); } private RuntimeAssembly GetSatelliteAssembly(CultureInfo lookForCulture) diff --git a/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs b/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs index d216db4bc7..69d8e5fc50 100644 --- a/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs +++ b/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs @@ -148,8 +148,6 @@ namespace System.Resources private Version _satelliteContractVersion; private bool _lookedForSatelliteContractVersion; - private RuntimeAssembly _callingAssembly; // Assembly who created the ResMgr. - private IResourceGroveler resourceGroveler; public static readonly int MagicNumber = unchecked((int)0xBEEFCACE); // If only hex had a K... @@ -180,16 +178,8 @@ namespace System.Resources internal const string ResFileExtension = ".resources"; internal const int ResFileExtensionLength = 10; - [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - private void Init() - { - _callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly(); - } - protected ResourceManager() { - Init(); - _lastUsedResourceCache = new CultureNameResourceSetPair(); ResourceManagerMediator mediator = new ResourceManagerMediator(this); resourceGroveler = new ManifestBasedResourceGroveler(mediator); @@ -227,7 +217,6 @@ namespace System.Resources resourceGroveler = new FileBasedResourceGroveler(mediator); } - [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public ResourceManager(string baseName, Assembly assembly) { if (null == baseName) @@ -245,19 +234,8 @@ namespace System.Resources SetAppXConfiguration(); CommonAssemblyInit(); - - _callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly(); - // Special case for mscorlib - protect mscorlib's private resources. - // This isn't for security reasons, but to ensure we can make - // breaking changes to mscorlib's internal resources without - // assuming users may have taken a dependency on them. - if (assembly == typeof(object).Assembly && _callingAssembly != assembly) - { - _callingAssembly = null; - } } - [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public ResourceManager(string baseName, Assembly assembly, Type usingResourceSet) { if (null == baseName) @@ -276,16 +254,8 @@ namespace System.Resources _userResourceSet = usingResourceSet; CommonAssemblyInit(); - _callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly(); - // Special case for mscorlib - protect mscorlib's private resources. - // This isn't for security reasons, but to ensure we can make - // breaking changes to mscorlib's internal resources without - // assuming users may have taken a dependency on them. - if (assembly == typeof(object).Assembly && _callingAssembly != assembly) - _callingAssembly = null; } - [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public ResourceManager(Type resourceSource) { if (null == resourceSource) @@ -301,13 +271,6 @@ namespace System.Resources SetAppXConfiguration(); CommonAssemblyInit(); - - _callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly(); - // Special case for mscorlib - protect mscorlib's private resources. - if (MainAssembly == typeof(object).Assembly && _callingAssembly != MainAssembly) - { - _callingAssembly = null; - } } // Trying to unify code as much as possible, even though having to do a @@ -466,7 +429,6 @@ namespace System.Resources // if it hasn't yet been loaded and if parent CultureInfos should be // loaded as well for resource inheritance. // - [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public virtual ResourceSet GetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents) { if (null == culture) @@ -483,13 +445,10 @@ namespace System.Resources } } - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - if (UseManifest && culture.HasInvariantCultureName) { string fileName = GetResourceFileName(culture); - RuntimeAssembly mainAssembly = (RuntimeAssembly)MainAssembly; - Stream stream = mainAssembly.GetManifestResourceStream(_locationInfo, fileName, _callingAssembly == MainAssembly, ref stackMark); + Stream stream = MainAssembly.GetManifestResourceStream(_locationInfo, fileName); if (createIfNotExists && stream != null) { rs = ((ManifestBasedResourceGroveler)resourceGroveler).CreateResourceSet(stream, MainAssembly); @@ -498,14 +457,6 @@ namespace System.Resources } } - // Note: ideally we could plumb through the stack crawl mark here, but we must - // call the virtual 3-argument InternalGetResourceSet method for compatibility. - // Security-wise, we're not overly interested in protecting access to resources, - // since full-trust callers can get them already and most resources are public. - // Also, the JIT inliner could always inline a caller into another assembly's - // method. - // So if we happen to return some resources in cases where we should really be - // doing a demand for member access permissions, we're not overly concerned. return InternalGetResourceSet(culture, createIfNotExists, tryParents); } @@ -513,33 +464,22 @@ namespace System.Resources // for getting a resource set lives. Access to it is controlled by // threadsafe methods such as GetResourceSet, GetString, & GetObject. // This will take a minimal number of locks. - [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod protected virtual ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents) { Debug.Assert(culture != null, "culture != null"); - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - return InternalGetResourceSet(culture, createIfNotExists, tryParents, ref stackMark); - } - - // InternalGetResourceSet is a non-threadsafe method where all the logic - // for getting a resource set lives. Access to it is controlled by - // threadsafe methods such as GetResourceSet, GetString, & GetObject. - // This will take a minimal number of locks. - private ResourceSet InternalGetResourceSet(CultureInfo requestedCulture, bool createIfNotExists, bool tryParents, ref StackCrawlMark stackMark) - { Dictionary localResourceSets = _resourceSets; ResourceSet rs = null; CultureInfo foundCulture = null; lock (localResourceSets) { - if (localResourceSets.TryGetValue(requestedCulture.Name, out rs)) + if (localResourceSets.TryGetValue(culture.Name, out rs)) { return rs; } } - ResourceFallbackManager mgr = new ResourceFallbackManager(requestedCulture, _neutralResourcesCulture, tryParents); + ResourceFallbackManager mgr = new ResourceFallbackManager(culture, _neutralResourcesCulture, tryParents); foreach (CultureInfo currentCultureInfo in mgr) { @@ -548,7 +488,7 @@ namespace System.Resources if (localResourceSets.TryGetValue(currentCultureInfo.Name, out rs)) { // we need to update the cache if we fellback - if (requestedCulture != currentCultureInfo) foundCulture = currentCultureInfo; + if (culture != currentCultureInfo) foundCulture = currentCultureInfo; break; } } @@ -560,7 +500,7 @@ namespace System.Resources // ResourceManager). It's happened. rs = resourceGroveler.GrovelForResourceSet(currentCultureInfo, localResourceSets, - tryParents, createIfNotExists, ref stackMark); + tryParents, createIfNotExists); // found a ResourceSet; we're done if (rs != null) @@ -768,9 +708,6 @@ namespace System.Resources RuntimeAssembly resourcesAssembly = (RuntimeAssembly)MainAssembly; - if (resourcesAssembly == null) - resourcesAssembly = _callingAssembly; - if (resourcesAssembly != null) { if (resourcesAssembly != typeof(object).Assembly) // We are not loading resources for mscorlib @@ -1016,11 +953,6 @@ namespace System.Resources foreach (CultureInfo currentCultureInfo in mgr) { - // Note: Technically this method should be passed in a stack crawl mark that we then pass - // to InternalGetResourceSet for ensuring we demand permissions to read your private resources - // if you're reading resources from an assembly other than yourself. But, we must call our - // three argument overload (without the stack crawl mark) for compatibility. After - // consideration, we aren't worried about the security impact. ResourceSet rs = InternalGetResourceSet(currentCultureInfo, true, true); if (rs == null) break; @@ -1137,11 +1069,6 @@ namespace System.Resources set { _rm._fallbackLoc = value; } } - internal RuntimeAssembly CallingAssembly - { - get { return _rm._callingAssembly; } - } - internal RuntimeAssembly MainAssembly { get { return (RuntimeAssembly)_rm.MainAssembly; } diff --git a/src/vm/assembly.cpp b/src/vm/assembly.cpp index 5724c6643d..4bd4a18b03 100644 --- a/src/vm/assembly.cpp +++ b/src/vm/assembly.cpp @@ -1855,7 +1855,6 @@ BOOL Assembly::FileNotFound(HRESULT hr) BOOL Assembly::GetResource(LPCSTR szName, DWORD *cbResource, PBYTE *pbInMemoryResource, Assembly** pAssemblyRef, LPCSTR *szFileName, DWORD *dwLocation, - StackCrawlMark *pStackMark, BOOL fSkipSecurityCheck, BOOL fSkipRaiseResolveEvent) { CONTRACTL @@ -1869,9 +1868,9 @@ BOOL Assembly::GetResource(LPCSTR szName, DWORD *cbResource, DomainAssembly *pAssembly = NULL; BOOL result = GetDomainAssembly()->GetResource(szName, cbResource, pbInMemoryResource, &pAssembly, - szFileName, dwLocation, pStackMark, fSkipSecurityCheck, + szFileName, dwLocation, fSkipRaiseResolveEvent); - if (result && pAssemblyRef != NULL && pAssembly!=NULL) + if (result && pAssemblyRef != NULL && pAssembly != NULL) *pAssemblyRef = pAssembly->GetAssembly(); return result; diff --git a/src/vm/assembly.hpp b/src/vm/assembly.hpp index 99f0fbfca7..d8d974b198 100644 --- a/src/vm/assembly.hpp +++ b/src/vm/assembly.hpp @@ -413,7 +413,6 @@ public: BOOL GetResource(LPCSTR szName, DWORD *cbResource, PBYTE *pbInMemoryResource, Assembly **pAssemblyRef, LPCSTR *szFileName, DWORD *dwLocation, - StackCrawlMark *pStackMark = NULL, BOOL fSkipSecurityCheck = FALSE, BOOL fSkipRaiseResolveEvent = FALSE); //**************************************************************************************** diff --git a/src/vm/assemblynative.cpp b/src/vm/assemblynative.cpp index b291dbea8a..30698cc13a 100644 --- a/src/vm/assemblynative.cpp +++ b/src/vm/assemblynative.cpp @@ -558,7 +558,7 @@ INT32 QCALLTYPE AssemblyNative::GetFlags(QCall::AssemblyHandle pAssembly) return retVal; } -BYTE * QCALLTYPE AssemblyNative::GetResource(QCall::AssemblyHandle pAssembly, LPCWSTR wszName, UINT64 * length, QCall::StackCrawlMarkHandle stackMark, BOOL skipSecurityCheck) +BYTE * QCALLTYPE AssemblyNative::GetResource(QCall::AssemblyHandle pAssembly, LPCWSTR wszName, DWORD * length) { QCALL_CONTRACT; @@ -578,13 +578,9 @@ BYTE * QCALLTYPE AssemblyNative::GetResource(QCall::AssemblyHandle pAssembly, LP if (*pNameUTF8 == '\0') COMPlusThrow(kArgumentException, W("Format_StringZeroLength")); - DWORD cbResource; - if (pAssembly->GetResource(pNameUTF8, &cbResource, - &pbInMemoryResource, NULL, NULL, - NULL, stackMark, skipSecurityCheck, FALSE)) - { - *length = cbResource; - } + pAssembly->GetResource(pNameUTF8, length, + &pbInMemoryResource, NULL, NULL, + NULL, FALSE); END_QCALL; @@ -592,7 +588,7 @@ BYTE * QCALLTYPE AssemblyNative::GetResource(QCall::AssemblyHandle pAssembly, LP return pbInMemoryResource; } -INT32 QCALLTYPE AssemblyNative::GetManifestResourceInfo(QCall::AssemblyHandle pAssembly, LPCWSTR wszName, QCall::ObjectHandleOnStack retAssembly, QCall::StringHandleOnStack retFileName, QCall::StackCrawlMarkHandle stackMark) +INT32 QCALLTYPE AssemblyNative::GetManifestResourceInfo(QCall::AssemblyHandle pAssembly, LPCWSTR wszName, QCall::ObjectHandleOnStack retAssembly, QCall::StringHandleOnStack retFileName) { QCALL_CONTRACT; @@ -617,7 +613,7 @@ INT32 QCALLTYPE AssemblyNative::GetManifestResourceInfo(QCall::AssemblyHandle pA DWORD dwLocation = 0; if (pAssembly->GetResource(pNameUTF8, NULL, NULL, &pReferencedAssembly, &pFileName, - &dwLocation, stackMark, FALSE, FALSE)) + &dwLocation, FALSE)) { if (pFileName) retFileName.Set(pFileName); diff --git a/src/vm/assemblynative.hpp b/src/vm/assemblynative.hpp index 433469f25a..3ef7b0be32 100644 --- a/src/vm/assemblynative.hpp +++ b/src/vm/assemblynative.hpp @@ -70,7 +70,7 @@ public: void QCALLTYPE GetCodeBase(QCall::AssemblyHandle pAssembly, BOOL fCopiedName, QCall::StringHandleOnStack retString); static - BYTE * QCALLTYPE GetResource(QCall::AssemblyHandle pAssembly, LPCWSTR wszName, UINT64 * length, QCall::StackCrawlMarkHandle stackMark, BOOL skipSecurityCheck); + BYTE * QCALLTYPE GetResource(QCall::AssemblyHandle pAssembly, LPCWSTR wszName, DWORD * length); static BOOL QCALLTYPE GetNeutralResourcesLanguageAttribute(QCall::AssemblyHandle pAssembly, QCall::StringHandleOnStack cultureName, INT16& outFallbackLocation); @@ -88,7 +88,7 @@ public: void QCALLTYPE GetForwardedType(QCall::AssemblyHandle pAssembly, mdToken mdtExternalType, QCall::ObjectHandleOnStack retType); static - INT32 QCALLTYPE GetManifestResourceInfo(QCall::AssemblyHandle pAssembly, LPCWSTR wszName, QCall::ObjectHandleOnStack retAssembly, QCall::StringHandleOnStack retFileName, QCall::StackCrawlMarkHandle stackMark); + INT32 QCALLTYPE GetManifestResourceInfo(QCall::AssemblyHandle pAssembly, LPCWSTR wszName, QCall::ObjectHandleOnStack retAssembly, QCall::StringHandleOnStack retFileName); static void QCALLTYPE GetModules(QCall::AssemblyHandle pAssembly, BOOL fLoadIfNotFound, BOOL fGetResourceModules, QCall::ObjectHandleOnStack retModules); diff --git a/src/vm/domainfile.cpp b/src/vm/domainfile.cpp index efd05fdd91..31bc7a823b 100644 --- a/src/vm/domainfile.cpp +++ b/src/vm/domainfile.cpp @@ -1714,7 +1714,6 @@ void DomainAssembly::DeliverSyncEvents() BOOL DomainAssembly::GetResource(LPCSTR szName, DWORD *cbResource, PBYTE *pbInMemoryResource, DomainAssembly** pAssemblyRef, LPCSTR *szFileName, DWORD *dwLocation, - StackCrawlMark *pStackMark, BOOL fSkipSecurityCheck, BOOL fSkipRaiseResolveEvent) { CONTRACTL @@ -1732,8 +1731,6 @@ BOOL DomainAssembly::GetResource(LPCSTR szName, DWORD *cbResource, pAssemblyRef, szFileName, dwLocation, - pStackMark, - fSkipSecurityCheck, fSkipRaiseResolveEvent, this, this->m_pDomain ); diff --git a/src/vm/domainfile.h b/src/vm/domainfile.h index 23295406e2..d6917b1fd5 100644 --- a/src/vm/domainfile.h +++ b/src/vm/domainfile.h @@ -641,7 +641,6 @@ public: BOOL GetResource(LPCSTR szName, DWORD *cbResource, PBYTE *pbInMemoryResource, DomainAssembly** pAssemblyRef, LPCSTR *szFileName, DWORD *dwLocation, - StackCrawlMark *pStackMark, BOOL fSkipSecurityCheck, BOOL fSkipRaiseResolveEvent); #ifdef FEATURE_PREJIT diff --git a/src/vm/pefile.cpp b/src/vm/pefile.cpp index 9cfde5f3ce..cd18037047 100644 --- a/src/vm/pefile.cpp +++ b/src/vm/pefile.cpp @@ -1683,7 +1683,6 @@ void PEFile::FlushExternalLog() BOOL PEFile::GetResource(LPCSTR szName, DWORD *cbResource, PBYTE *pbInMemoryResource, DomainAssembly** pAssemblyRef, LPCSTR *szFileName, DWORD *dwLocation, - StackCrawlMark *pStackMark, BOOL fSkipSecurityCheck, BOOL fSkipRaiseResolveEvent, DomainAssembly* pDomainAssembly, AppDomain* pAppDomain) { CONTRACTL @@ -1773,8 +1772,6 @@ BOOL PEFile::GetResource(LPCSTR szName, DWORD *cbResource, pAssemblyRef, szFileName, dwLocation, - pStackMark, - fSkipSecurityCheck, fSkipRaiseResolveEvent); } @@ -1783,31 +1780,6 @@ BOOL PEFile::GetResource(LPCSTR szName, DWORD *cbResource, { // The resource is embedded in the manifest file -#ifndef CROSSGEN_COMPILE - if (!IsMrPublic(dwResourceFlags) && pStackMark && !fSkipSecurityCheck) - { - Assembly *pCallersAssembly = SystemDomain::GetCallersAssembly(pStackMark); - - if (pCallersAssembly && // full trust for interop - (!pCallersAssembly->GetManifestFile()->Equals(this))) - { - RefSecContext sCtx(AccessCheckOptions::kMemberAccess); - - AccessCheckOptions accessCheckOptions( - AccessCheckOptions::kMemberAccess, /*accessCheckType*/ - NULL, /*pAccessContext*/ - FALSE, /*throwIfTargetIsInaccessible*/ - (MethodTable *) NULL /*pTargetMT*/ - ); - - // SL: return TRUE only if the caller is critical - // Desktop: return TRUE only if demanding MemberAccess succeeds - if (!accessCheckOptions.DemandMemberAccessOrFail(&sCtx, NULL, TRUE /*visibilityCheck*/)) - return FALSE; - } - } -#endif // CROSSGEN_COMPILE - if (dwLocation) { *dwLocation = *dwLocation | 5; // ResourceLocation.embedded | diff --git a/src/vm/pefile.h b/src/vm/pefile.h index c92ebaa345..3e237dc093 100644 --- a/src/vm/pefile.h +++ b/src/vm/pefile.h @@ -283,7 +283,6 @@ public: BOOL GetResource(LPCSTR szName, DWORD *cbResource, PBYTE *pbInMemoryResource, DomainAssembly** pAssemblyRef, LPCSTR *szFileName, DWORD *dwLocation, - StackCrawlMark *pStackMark, BOOL fSkipSecurityCheck, BOOL fSkipRaiseResolveEvent, DomainAssembly* pDomainAssembly, AppDomain* pAppDomain); #ifndef DACCESS_COMPILE -- cgit v1.2.3