diff options
Diffstat (limited to 'src/mscorlib/src/System/StubHelpers.cs')
-rw-r--r-- | src/mscorlib/src/System/StubHelpers.cs | 161 |
1 files changed, 11 insertions, 150 deletions
diff --git a/src/mscorlib/src/System/StubHelpers.cs b/src/mscorlib/src/System/StubHelpers.cs index a9c584e9fc..26a227628a 100644 --- a/src/mscorlib/src/System/StubHelpers.cs +++ b/src/mscorlib/src/System/StubHelpers.cs @@ -16,6 +16,7 @@ namespace System.StubHelpers { #endif // FEATURE_COMINTEROP using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; + using System.Diagnostics; using System.Diagnostics.Contracts; [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] @@ -23,7 +24,6 @@ namespace System.StubHelpers { { // The length of the returned array is an approximation based on the length of the input string and the system // character set. It is only guaranteed to be larger or equal to cbLength, don't depend on the exact value. - [System.Security.SecurityCritical] unsafe static internal byte[] DoAnsiConversion(string str, bool fBestFit, bool fThrowOnUnmappableChar, out int cbLength) { byte[] buffer = new byte[(str.Length + 1) * Marshal.SystemMaxDBCSCharSize]; @@ -34,7 +34,6 @@ namespace System.StubHelpers { return buffer; } - [System.Security.SecurityCritical] unsafe static internal byte ConvertToNative(char managedChar, bool fBestFit, bool fThrowOnUnmappableChar) { int cbAllocLength = (1 + 1) * Marshal.SystemMaxDBCSCharSize; @@ -57,7 +56,6 @@ namespace System.StubHelpers { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class CSTRMarshaler { - [System.Security.SecurityCritical] // auto-generated static internal unsafe IntPtr ConvertToNative(int flags, string strManaged, IntPtr pNativeBuffer) { if (null == strManaged) @@ -109,7 +107,6 @@ namespace System.StubHelpers { return (IntPtr)pbNativeBuffer; } - [System.Security.SecurityCritical] // auto-generated static internal unsafe string ConvertToManaged(IntPtr cstr) { if (IntPtr.Zero == cstr) @@ -118,7 +115,6 @@ namespace System.StubHelpers { return new String((sbyte*)cstr); } - [System.Security.SecurityCritical] // auto-generated static internal void ClearNative(IntPtr pNative) { Win32Native.CoTaskMemFree(pNative); @@ -129,7 +125,6 @@ namespace System.StubHelpers { internal static class UTF8Marshaler { const int MAX_UTF8_CHAR_SIZE = 3; - [System.Security.SecurityCritical] static internal unsafe IntPtr ConvertToNative(int flags, string strManaged, IntPtr pNativeBuffer) { if (null == strManaged) @@ -166,7 +161,6 @@ namespace System.StubHelpers { return (IntPtr)pbNativeBuffer; } - [System.Security.SecurityCritical] static internal unsafe string ConvertToManaged(IntPtr cstr) { if (IntPtr.Zero == cstr) @@ -175,7 +169,6 @@ namespace System.StubHelpers { return String.CreateStringFromEncoding((byte*)cstr, nbBytes, Encoding.UTF8); } - [System.Security.SecurityCritical] static internal void ClearNative(IntPtr pNative) { if (pNative != IntPtr.Zero) @@ -188,7 +181,6 @@ namespace System.StubHelpers { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class UTF8BufferMarshaler { - [System.Security.SecurityCritical] static internal unsafe IntPtr ConvertToNative(StringBuilder sb, IntPtr pNativeBuffer, int flags) { if (null == sb) @@ -210,7 +202,6 @@ namespace System.StubHelpers { return (IntPtr)pbNativeBuffer; } - [System.Security.SecurityCritical] static internal unsafe void ConvertToManaged(StringBuilder sb, IntPtr pNative) { if (pNative == null) @@ -241,7 +232,6 @@ namespace System.StubHelpers { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class BSTRMarshaler { - [System.Security.SecurityCritical] // auto-generated static internal unsafe IntPtr ConvertToNative(string strManaged, IntPtr pNativeBuffer) { if (null == strManaged) @@ -311,7 +301,6 @@ namespace System.StubHelpers { } } - [System.Security.SecurityCritical] // auto-generated static internal unsafe string ConvertToManaged(IntPtr bstr) { if (IntPtr.Zero == bstr) @@ -356,7 +345,6 @@ namespace System.StubHelpers { } } - [System.Security.SecurityCritical] // auto-generated static internal void ClearNative(IntPtr pNative) { if (IntPtr.Zero != pNative) @@ -372,7 +360,6 @@ namespace System.StubHelpers { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class VBByValStrMarshaler { - [System.Security.SecurityCritical] // auto-generated static internal unsafe IntPtr ConvertToNative(string strManaged, bool fBestFit, bool fThrowOnUnmappableChar, ref int cch) { if (null == strManaged) @@ -414,7 +401,6 @@ namespace System.StubHelpers { return new IntPtr(pNative); } - [System.Security.SecurityCritical] // auto-generated static internal unsafe string ConvertToManaged(IntPtr pNative, int cch) { if (IntPtr.Zero == pNative) @@ -425,7 +411,6 @@ namespace System.StubHelpers { return new String((sbyte*)pNative, 0, cch); } - [System.Security.SecurityCritical] // auto-generated static internal unsafe void ClearNative(IntPtr pNative) { if (IntPtr.Zero != pNative) @@ -441,7 +426,6 @@ namespace System.StubHelpers { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class AnsiBSTRMarshaler { - [System.Security.SecurityCritical] // auto-generated static internal unsafe IntPtr ConvertToNative(int flags, string strManaged) { if (null == strManaged) @@ -464,7 +448,6 @@ namespace System.StubHelpers { return Win32Native.SysAllocStringByteLen(bytes, (uint)nb); } - [System.Security.SecurityCritical] // auto-generated static internal unsafe string ConvertToManaged(IntPtr bstr) { if (IntPtr.Zero == bstr) @@ -480,7 +463,6 @@ namespace System.StubHelpers { } } - [System.Security.SecurityCritical] // auto-generated static internal unsafe void ClearNative(IntPtr pNative) { if (IntPtr.Zero != pNative) @@ -498,19 +480,19 @@ namespace System.StubHelpers { { static internal IntPtr ConvertToNative(string strManaged) { - Contract.Assert(false, "NYI"); + Debug.Assert(false, "NYI"); return IntPtr.Zero; } static internal unsafe string ConvertToManaged(IntPtr bstr) { - Contract.Assert(false, "NYI"); + Debug.Assert(false, "NYI"); return null; } static internal void ClearNative(IntPtr pNative) { - Contract.Assert(false, "NYI"); + Debug.Assert(false, "NYI"); } } // class WSTRBufferMarshaler @@ -531,14 +513,12 @@ namespace System.StubHelpers { // You can get this through: (new DateTimeOffset(1601, 1, 1, 0, 0, 1, TimeSpan.Zero)).Ticks; private const Int64 ManagedUtcTicksAtNativeZero = 504911232000000000; - [SecurityCritical] internal static void ConvertToNative(ref DateTimeOffset managedDTO, out DateTimeNative dateTime) { Int64 managedUtcTicks = managedDTO.UtcTicks; dateTime.UniversalTime = managedUtcTicks - ManagedUtcTicksAtNativeZero; } - [SecurityCritical] internal static void ConvertToManaged(out DateTimeOffset managedLocalDTO, ref DateTimeNative nativeTicks) { Int64 managedUtcTicks = ManagedUtcTicksAtNativeZero + nativeTicks.UniversalTime; @@ -558,7 +538,6 @@ namespace System.StubHelpers { internal static class HStringMarshaler { // Slow-path, which requires making a copy of the managed string into the resulting HSTRING - [SecurityCritical] internal static unsafe IntPtr ConvertToNative(string managed) { if (!Environment.IsWinRTSupported) @@ -578,7 +557,6 @@ namespace System.StubHelpers { // Note that the managed string input to this method MUST be pinned, and stay pinned for the lifetime of // the returned HSTRING object. If the string is not pinned, or becomes unpinned before the HSTRING's // lifetime ends, the HSTRING instance will be corrupted. - [SecurityCritical] internal static unsafe IntPtr ConvertToNativeReference(string managed, [Out] HSTRING_HEADER *hstringHeader) { @@ -598,7 +576,6 @@ namespace System.StubHelpers { } } - [SecurityCritical] internal static string ConvertToManaged(IntPtr hstring) { if (!Environment.IsWinRTSupported) @@ -609,10 +586,9 @@ namespace System.StubHelpers { return WindowsRuntimeMarshal.HStringToString(hstring); } - [SecurityCritical] internal static void ClearNative(IntPtr hstring) { - Contract.Assert(Environment.IsWinRTSupported); + Debug.Assert(Environment.IsWinRTSupported); if (hstring != IntPtr.Zero) { @@ -639,7 +615,6 @@ namespace System.StubHelpers { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class ValueClassMarshaler { - [SecurityCritical] [MethodImplAttribute(MethodImplOptions.InternalCall)] static internal extern void ConvertToNative(IntPtr dst, IntPtr src, IntPtr pMT, ref CleanupWorkList pCleanupWorkList); @@ -672,7 +647,6 @@ namespace System.StubHelpers { [MethodImplAttribute(MethodImplOptions.InternalCall)] static internal extern object ConvertToManaged(IntPtr pUnk, IntPtr itfMT, IntPtr classMT, int flags); - [SecurityCritical] [DllImport(JitHelpers.QCall), SuppressUnmanagedCodeSecurity] static internal extern void ClearNative(IntPtr pUnk); @@ -690,10 +664,8 @@ namespace System.StubHelpers { static internal extern string GetRawUriFromNative(IntPtr pUri); [MethodImplAttribute(MethodImplOptions.InternalCall)] - [System.Security.SecurityCritical] static unsafe internal extern IntPtr CreateNativeUriInstanceHelper(char* rawUri, int strLen); - [System.Security.SecurityCritical] static unsafe internal IntPtr CreateNativeUriInstance(string rawUri) { fixed(char* pManaged = rawUri) @@ -707,7 +679,6 @@ namespace System.StubHelpers { [FriendAccessAllowed] internal static class EventArgsMarshaler { - [SecurityCritical] [FriendAccessAllowed] static internal IntPtr CreateNativeNCCEventArgsInstance(int action, object newItems, object oldItems, int newIndex, int oldIndex) { @@ -733,12 +704,10 @@ namespace System.StubHelpers { } } - [SecurityCritical] [FriendAccessAllowed] [DllImport(JitHelpers.QCall), SuppressUnmanagedCodeSecurity] static extern internal IntPtr CreateNativePCEventArgsInstance([MarshalAs(UnmanagedType.HString)]string name); - [SecurityCritical] [DllImport(JitHelpers.QCall), SuppressUnmanagedCodeSecurity] static extern internal IntPtr CreateNativeNCCEventArgsInstanceHelper(int action, IntPtr newItem, IntPtr oldItem, int newIndex, int oldIndex); } @@ -796,19 +765,15 @@ namespace System.StubHelpers { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class MngdHiddenLengthArrayMarshaler { - [SecurityCritical] [MethodImplAttribute(MethodImplOptions.InternalCall)] static internal extern void CreateMarshaler(IntPtr pMarshalState, IntPtr pMT, IntPtr cbElementSize, ushort vt); - [SecurityCritical] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void ConvertSpaceToNative(IntPtr pMarshalState, ref object pManagedHome, IntPtr pNativeHome); - [SecurityCritical] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void ConvertContentsToNative(IntPtr pMarshalState, ref object pManagedHome, IntPtr pNativeHome); - [SecurityCritical] internal static unsafe void ConvertContentsToNative_DateTime(ref DateTimeOffset[] managedArray, IntPtr pNativeHome) { if (managedArray != null) @@ -821,7 +786,6 @@ namespace System.StubHelpers { } } - [SecurityCritical] internal static unsafe void ConvertContentsToNative_Type(ref System.Type[] managedArray, IntPtr pNativeHome) { if (managedArray != null) @@ -834,7 +798,6 @@ namespace System.StubHelpers { } } - [SecurityCritical] internal static unsafe void ConvertContentsToNative_Exception(ref Exception[] managedArray, IntPtr pNativeHome) { if (managedArray != null) @@ -847,7 +810,6 @@ namespace System.StubHelpers { } } - [SecurityCritical] internal static unsafe void ConvertContentsToNative_Nullable<T>(ref Nullable<T>[] managedArray, IntPtr pNativeHome) where T : struct { @@ -861,7 +823,6 @@ namespace System.StubHelpers { } } - [SecurityCritical] internal static unsafe void ConvertContentsToNative_KeyValuePair<K, V>(ref KeyValuePair<K, V>[] managedArray, IntPtr pNativeHome) { if (managedArray != null) @@ -874,15 +835,12 @@ namespace System.StubHelpers { } } - [SecurityCritical] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void ConvertSpaceToManaged(IntPtr pMarshalState, ref object pManagedHome, IntPtr pNativeHome, int elementCount); - [SecurityCritical] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void ConvertContentsToManaged(IntPtr pMarshalState, ref object pManagedHome, IntPtr pNativeHome); - [SecurityCritical] internal static unsafe void ConvertContentsToManaged_DateTime(ref DateTimeOffset[] managedArray, IntPtr pNativeHome) { if (managedArray != null) @@ -895,7 +853,6 @@ namespace System.StubHelpers { } } - [SecurityCritical] internal static unsafe void ConvertContentsToManaged_Type(ref System.Type[] managedArray, IntPtr pNativeHome) { if (managedArray != null) @@ -908,7 +865,6 @@ namespace System.StubHelpers { } } - [SecurityCritical] internal static unsafe void ConvertContentsToManaged_Exception(ref Exception[] managedArray, IntPtr pNativeHome) { if (managedArray != null) @@ -921,7 +877,6 @@ namespace System.StubHelpers { } } - [SecurityCritical] internal static unsafe void ConvertContentsToManaged_Nullable<T>(ref Nullable<T>[] managedArray, IntPtr pNativeHome) where T : struct { @@ -935,7 +890,6 @@ namespace System.StubHelpers { } } - [SecurityCritical] internal static unsafe void ConvertContentsToManaged_KeyValuePair<K, V>(ref KeyValuePair<K, V>[] managedArray, IntPtr pNativeHome) { if (managedArray != null) @@ -948,14 +902,12 @@ namespace System.StubHelpers { } } - [SecurityCritical] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void ClearNativeContents(IntPtr pMarshalState, IntPtr pNativeHome, int cElements); - [SecurityCritical] internal static unsafe void ClearNativeContents_Type(IntPtr pNativeHome, int cElements) { - Contract.Assert(Environment.IsWinRTSupported); + Debug.Assert(Environment.IsWinRTSupported); TypeNameNative *pNativeTypeArray = *(TypeNameNative **)pNativeHome; if (pNativeTypeArray != null) @@ -991,7 +943,6 @@ namespace System.StubHelpers { } // class MngdRefCustomMarshaler [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - [System.Security.SecurityCritical] internal struct AsAnyMarshaler { private const ushort VTHACK_ANSICHAR = 253; @@ -1037,7 +988,6 @@ namespace System.StubHelpers { #region ConvertToNative helpers - [System.Security.SecurityCritical] private unsafe IntPtr ConvertArrayToNative(object pManagedHome, int dwFlags) { Type elementType = pManagedHome.GetType().GetElementType(); @@ -1109,7 +1059,6 @@ namespace System.StubHelpers { return pNativeHome; } - [System.Security.SecurityCritical] private static IntPtr ConvertStringToNative(string pManagedHome, int dwFlags) { IntPtr pNativeHome; @@ -1137,7 +1086,6 @@ namespace System.StubHelpers { return pNativeHome; } - [System.Security.SecurityCritical] private unsafe IntPtr ConvertStringBuilderToNative(StringBuilder pManagedHome, int dwFlags) { IntPtr pNativeHome; @@ -1176,7 +1124,7 @@ namespace System.StubHelpers { ptr, allocSize, IsBestFit(dwFlags), IsThrowOn(dwFlags)); - Contract.Assert(length < allocSize, "Expected a length less than the allocated size"); + Debug.Assert(length < allocSize, "Expected a length less than the allocated size"); } if (IsOut(dwFlags)) { @@ -1211,7 +1159,6 @@ namespace System.StubHelpers { return pNativeHome; } - [System.Security.SecurityCritical] private unsafe IntPtr ConvertLayoutToNative(object pManagedHome, int dwFlags) { // Note that the following call will not throw exception if the type @@ -1237,7 +1184,6 @@ namespace System.StubHelpers { #endregion - [System.Security.SecurityCritical] internal IntPtr ConvertToNative(object pManagedHome, int dwFlags) { if (pManagedHome == null) @@ -1283,7 +1229,6 @@ namespace System.StubHelpers { return pNativeHome; } - [System.Security.SecurityCritical] internal unsafe void ConvertToManaged(object pManagedHome, IntPtr pNativeHome) { switch (backPropAction) @@ -1321,7 +1266,6 @@ namespace System.StubHelpers { } } - [System.Security.SecurityCritical] internal void ClearNative(IntPtr pNativeHome) { if (pNativeHome != IntPtr.Zero) @@ -1341,7 +1285,6 @@ namespace System.StubHelpers { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class NullableMarshaler { - [SecurityCritical] static internal IntPtr ConvertToNative<T>(ref Nullable<T> pManaged) where T : struct { if (pManaged.HasValue) @@ -1355,14 +1298,12 @@ namespace System.StubHelpers { } } - [SecurityCritical] static internal void ConvertToManagedRetVoid<T>(IntPtr pNative, ref Nullable<T> retObj) where T : struct { retObj = ConvertToManaged<T>(pNative); } - [SecurityCritical] static internal Nullable<T> ConvertToManaged<T>(IntPtr pNative) where T : struct { if (pNative != IntPtr.Zero) @@ -1406,7 +1347,6 @@ namespace System.StubHelpers { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class SystemTypeMarshaler { - [SecurityCritical] internal static unsafe void ConvertToNative(System.Type managedType, TypeNameNative *pNativeType) { if (!Environment.IsWinRTSupported) @@ -1450,7 +1390,6 @@ namespace System.StubHelpers { Marshal.ThrowExceptionForHR(hrCreate, new IntPtr(-1)); } - [SecurityCritical] internal static unsafe void ConvertToManaged(TypeNameNative *pNativeType, ref System.Type managedType) { if (!Environment.IsWinRTSupported) @@ -1480,10 +1419,9 @@ namespace System.StubHelpers { } } - [SecurityCritical] internal static unsafe void ClearNative(TypeNameNative *pNativeType) { - Contract.Assert(Environment.IsWinRTSupported); + Debug.Assert(Environment.IsWinRTSupported); if (pNativeType->typeName != IntPtr.Zero) { @@ -1509,7 +1447,6 @@ namespace System.StubHelpers { return ex._HResult; } - [SecuritySafeCritical] static internal unsafe Exception ConvertToManaged(int hr) { Contract.Ensures(Contract.Result<Exception>() != null || hr >= 0); @@ -1527,7 +1464,7 @@ namespace System.StubHelpers { // S_OK should be marshaled as null. WinRT API's should not return S_FALSE by convention. // We've chosen to treat S_FALSE as success and return null. - Contract.Assert(e != null || hr == 0 || hr == 1, "Unexpected HRESULT - it is a success HRESULT (without the high bit set) other than S_OK & S_FALSE."); + Debug.Assert(e != null || hr == 0 || hr == 1, "Unexpected HRESULT - it is a success HRESULT (without the high bit set) other than S_OK & S_FALSE."); return e; } } // class HResultExceptionMarshaler @@ -1535,14 +1472,12 @@ namespace System.StubHelpers { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class KeyValuePairMarshaler { - [SecurityCritical] internal static IntPtr ConvertToNative<K, V>([In] ref KeyValuePair<K, V> pair) { IKeyValuePair<K, V> impl = new CLRIKeyValuePairImpl<K, V>(ref pair); return Marshal.GetComInterfaceForObject(impl, typeof(IKeyValuePair<K, V>)); } - [SecurityCritical] internal static KeyValuePair<K, V> ConvertToManaged<K, V>(IntPtr pInsp) { object obj = InterfaceMarshaler.ConvertToManagedWithoutUnboxing(pInsp); @@ -1552,7 +1487,6 @@ namespace System.StubHelpers { } // Called from COMInterfaceMarshaler - [SecurityCritical] internal static object ConvertToManagedBox<K, V>(IntPtr pInsp) { return (object)ConvertToManaged<K, V>(pInsp); @@ -1583,48 +1517,9 @@ namespace System.StubHelpers { #endif } // struct NativeVariant -#if !BIT64 && !FEATURE_CORECLR - // Structure filled by IL stubs if copy constructor(s) and destructor(s) need to be called - // on value types pushed on the stack. The structure is stored in s_copyCtorStubDesc by - // SetCopyCtorCookieChain and fetched by CopyCtorCallStubWorker. Must be stack-allocated. - [StructLayout(LayoutKind.Sequential)] - unsafe internal struct CopyCtorStubCookie - { - public void SetData(IntPtr srcInstancePtr, uint dstStackOffset, IntPtr ctorPtr, IntPtr dtorPtr) - { - m_srcInstancePtr = srcInstancePtr; - m_dstStackOffset = dstStackOffset; - m_ctorPtr = ctorPtr; - m_dtorPtr = dtorPtr; - } - - public void SetNext(IntPtr pNext) - { - m_pNext = pNext; - } - - public IntPtr m_srcInstancePtr; // pointer to the source instance - public uint m_dstStackOffset; // offset from the start of stack arguments of the pushed 'this' instance - - public IntPtr m_ctorPtr; // fnptr to the managed copy constructor, result of ldftn - public IntPtr m_dtorPtr; // fnptr to the managed destructor, result of ldftn - - public IntPtr m_pNext; // pointer to next cookie in the chain or IntPtr.Zero - } // struct CopyCtorStubCookie - - // Aggregates pointer to CopyCtorStubCookie and the target of the interop call. - [StructLayout(LayoutKind.Sequential)] - unsafe internal struct CopyCtorStubDesc - { - public IntPtr m_pCookie; - public IntPtr m_pTarget; - } // struct CopyCtorStubDes -#endif // !BIT64 && !FEATURE_CORECLR - // Aggregates SafeHandle and the "owned" bit which indicates whether the SafeHandle // has been successfully AddRef'ed. This allows us to do realiable cleanup (Release) // if and only if it is needed. - [System.Security.SecurityCritical] internal sealed class CleanupWorkListElement { public CleanupWorkListElement(SafeHandle handle) @@ -1640,7 +1535,6 @@ namespace System.StubHelpers { } // class CleanupWorkListElement [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - [System.Security.SecurityCritical] internal sealed class CleanupWorkList { private List<CleanupWorkListElement> m_list = new List<CleanupWorkListElement>(); @@ -1662,7 +1556,6 @@ namespace System.StubHelpers { } } // class CleanupWorkList - [System.Security.SecurityCritical] // auto-generated [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] [SuppressUnmanagedCodeSecurityAttribute()] internal static class StubHelpers @@ -1679,33 +1572,8 @@ namespace System.StubHelpers { [MethodImplAttribute(MethodImplOptions.InternalCall)] static internal extern IntPtr GetDelegateTarget(Delegate pThis, ref IntPtr pStubArg); -#if !BIT64 && !FEATURE_CORECLR - // Written to by a managed stub helper, read by CopyCtorCallStubWorker in VM. - [ThreadStatic] - static CopyCtorStubDesc s_copyCtorStubDesc; - - static internal void SetCopyCtorCookieChain(IntPtr pStubArg, IntPtr pUnmngThis, int dwStubFlags, IntPtr pCookie) - { - // we store both the cookie chain head and the target of the copy ctor stub to a thread - // static field to be accessed by the copy ctor (see code:CopyCtorCallStubWorker) - s_copyCtorStubDesc.m_pCookie = pCookie; - s_copyCtorStubDesc.m_pTarget = GetFinalStubTarget(pStubArg, pUnmngThis, dwStubFlags); - } - - // Returns the final unmanaged stub target, ignores interceptors. - [MethodImplAttribute(MethodImplOptions.InternalCall)] - static internal extern IntPtr GetFinalStubTarget(IntPtr pStubArg, IntPtr pUnmngThis, int dwStubFlags); -#endif // !FEATURE_CORECLR && !BIT64 - -#if !FEATURE_CORECLR - [MethodImplAttribute(MethodImplOptions.InternalCall)] - static internal extern void DemandPermission(IntPtr pNMD); -#endif // !FEATURE_CORECLR - -#if FEATURE_CORECLR [MethodImplAttribute(MethodImplOptions.InternalCall)] static internal extern void ClearLastError(); -#endif [MethodImplAttribute(MethodImplOptions.InternalCall)] static internal extern void SetLastError(); @@ -1713,7 +1581,6 @@ namespace System.StubHelpers { [MethodImplAttribute(MethodImplOptions.InternalCall)] static internal extern void ThrowInteropParamException(int resID, int paramIdx); - [System.Security.SecurityCritical] static internal IntPtr AddToCleanupList(ref CleanupWorkList pCleanupWorkList, SafeHandle handle) { if (pCleanupWorkList == null) @@ -1726,7 +1593,6 @@ namespace System.StubHelpers { return SafeHandleAddRef(handle, ref element.m_owned); } - [System.Security.SecurityCritical] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] static internal void DestroyCleanupList(ref CleanupWorkList pCleanupWorkList) { @@ -1775,12 +1641,11 @@ namespace System.StubHelpers { //------------------------------------------------------- // AddRefs the SH and returns the underlying unmanaged handle. - [System.Security.SecurityCritical] // auto-generated static internal IntPtr SafeHandleAddRef(SafeHandle pHandle, ref bool success) { if (pHandle == null) { - throw new ArgumentNullException("pHandle", Environment.GetResourceString("ArgumentNull_SafeHandle")); + throw new ArgumentNullException(nameof(pHandle), Environment.GetResourceString("ArgumentNull_SafeHandle")); } Contract.EndContractBlock(); @@ -1790,13 +1655,12 @@ namespace System.StubHelpers { } // Releases the SH (to be called from finally block). - [System.Security.SecurityCritical] // auto-generated [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] static internal void SafeHandleRelease(SafeHandle pHandle) { if (pHandle == null) { - throw new ArgumentNullException("pHandle", Environment.GetResourceString("ArgumentNull_SafeHandle")); + throw new ArgumentNullException(nameof(pHandle), Environment.GetResourceString("ArgumentNull_SafeHandle")); } Contract.EndContractBlock(); @@ -1848,15 +1712,12 @@ namespace System.StubHelpers { static internal extern IntPtr GetDelegateInvokeMethod(Delegate pThis); [MethodImplAttribute(MethodImplOptions.InternalCall)] - [System.Security.SecurityCritical] static internal extern object GetWinRTFactoryObject(IntPtr pCPCMD); [MethodImplAttribute(MethodImplOptions.InternalCall)] - [System.Security.SecurityCritical] static internal extern IntPtr GetWinRTFactoryReturnValue(object pThis, IntPtr pCtorEntry); [MethodImplAttribute(MethodImplOptions.InternalCall)] - [System.Security.SecurityCritical] static internal extern IntPtr GetOuterInspectable(object pThis, IntPtr pCtorMD); #if MDA_SUPPORTED |