diff options
Diffstat (limited to 'src/mscorlib/src/Microsoft/Win32/SafeHandles')
9 files changed, 3 insertions, 100 deletions
diff --git a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.cs b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.cs deleted file mode 100644 index ab06347ee4..0000000000 --- a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.cs +++ /dev/null @@ -1,43 +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. - -/*============================================================ -** -** -** -** A wrapper for file handles -** -** -===========================================================*/ - -using System; -using System.Security; -using System.Security.Permissions; -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; -using System.Runtime.ConstrainedExecution; -using System.Runtime.Versioning; -using Microsoft.Win32; - -namespace Microsoft.Win32.SafeHandles { - - [System.Security.SecurityCritical] // auto-generated_required - public sealed class SafeFileHandle: SafeHandleZeroOrMinusOneIsInvalid { - - private SafeFileHandle() : base(true) - { - } - - public SafeFileHandle(IntPtr preexistingHandle, bool ownsHandle) : base(ownsHandle) { - SetHandle(preexistingHandle); - } - - [System.Security.SecurityCritical] - override protected bool ReleaseHandle() - { - return Win32Native.CloseHandle(handle); - } - } -} - diff --git a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFileMappingHandle.cs b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFileMappingHandle.cs index 5e1b5100bc..cb915fe7c3 100644 --- a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFileMappingHandle.cs +++ b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFileMappingHandle.cs @@ -20,20 +20,16 @@ using System.Runtime.Versioning; namespace Microsoft.Win32.SafeHandles { - [System.Security.SecurityCritical] // auto-generated internal sealed class SafeFileMappingHandle : SafeHandleZeroOrMinusOneIsInvalid { - [System.Security.SecurityCritical] // auto-generated_required internal SafeFileMappingHandle() : base(true) {} // 0 is an Invalid Handle - [System.Security.SecurityCritical] // auto-generated_required internal SafeFileMappingHandle(IntPtr handle, bool ownsHandle) : base (ownsHandle) { SetHandle(handle); } - [System.Security.SecurityCritical] override protected bool ReleaseHandle() { return Win32Native.CloseHandle(handle); diff --git a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFindHandle.cs b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFindHandle.cs index b24535f997..219fb77001 100644 --- a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFindHandle.cs +++ b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeFindHandle.cs @@ -20,13 +20,10 @@ using System.Runtime.ConstrainedExecution; using Microsoft.Win32; namespace Microsoft.Win32.SafeHandles { - [System.Security.SecurityCritical] // auto-generated internal sealed class SafeFindHandle : SafeHandleZeroOrMinusOneIsInvalid { - [System.Security.SecurityCritical] // auto-generated_required internal SafeFindHandle() : base(true) {} - [System.Security.SecurityCritical] override protected bool ReleaseHandle() { return Win32Native.FindClose(handle); diff --git a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeLibraryHandle.cs b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeLibraryHandle.cs index d2ea42b14e..23631987a5 100644 --- a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeLibraryHandle.cs +++ b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeLibraryHandle.cs @@ -3,24 +3,12 @@ // See the LICENSE file in the project root for more information. namespace Microsoft.Win32 { - using Microsoft.Win32; using Microsoft.Win32.SafeHandles; - using System; - using System.Runtime.CompilerServices; - using System.Runtime.ConstrainedExecution; - using System.Runtime.InteropServices; - using System.Runtime.Serialization; - using System.Runtime.Versioning; - using System.Security; using System.Security.Permissions; - using System.Text; - [System.Security.SecurityCritical] // auto-generated - [HostProtectionAttribute(MayLeakOnAbort = true)] sealed internal class SafeLibraryHandle : SafeHandleZeroOrMinusOneIsInvalid { internal SafeLibraryHandle() : base(true) {} - [System.Security.SecurityCritical] override protected bool ReleaseHandle() { return UnsafeNativeMethods.FreeLibrary(handle); diff --git a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeLocalAllocHandle.cs b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeLocalAllocHandle.cs index 3eea2b9937..d6c1577eeb 100644 --- a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeLocalAllocHandle.cs +++ b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeLocalAllocHandle.cs @@ -1,13 +1,14 @@ // 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. -namespace Microsoft.Win32.SafeHandles { + +namespace Microsoft.Win32.SafeHandles +{ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.ConstrainedExecution; - [System.Security.SecurityCritical] // auto-generated internal sealed class SafeLocalAllocHandle : SafeBuffer { private SafeLocalAllocHandle () : base(true) {} @@ -20,7 +21,6 @@ namespace Microsoft.Win32.SafeHandles { get { return new SafeLocalAllocHandle(IntPtr.Zero); } } - [System.Security.SecurityCritical] override protected bool ReleaseHandle() { return Win32Native.LocalFree(handle) == IntPtr.Zero; diff --git a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs index d0e3f048f2..4f96b81e72 100644 --- a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs +++ b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs @@ -17,17 +17,13 @@ namespace Microsoft.Win32.SafeHandles { using System.Runtime.ConstrainedExecution; using System.Runtime.Versioning; - [System.Security.SecurityCritical] public sealed class SafeRegistryHandle : SafeHandleZeroOrMinusOneIsInvalid { - [System.Security.SecurityCritical] internal SafeRegistryHandle() : base(true) {} - [System.Security.SecurityCritical] public SafeRegistryHandle(IntPtr preexistingHandle, bool ownsHandle) : base(ownsHandle) { SetHandle(preexistingHandle); } - [System.Security.SecurityCritical] override protected bool ReleaseHandle() { return (RegCloseKey(handle) == Win32Native.ERROR_SUCCESS); } diff --git a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeViewOfFileHandle.cs b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeViewOfFileHandle.cs index 01ec4d2ad8..38a9323c0b 100644 --- a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeViewOfFileHandle.cs +++ b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeViewOfFileHandle.cs @@ -22,19 +22,15 @@ using Microsoft.Win32.SafeHandles; namespace Microsoft.Win32.SafeHandles { - [System.Security.SecurityCritical] // auto-generated internal sealed class SafeViewOfFileHandle : SafeHandleZeroOrMinusOneIsInvalid { - [System.Security.SecurityCritical] // auto-generated_required internal SafeViewOfFileHandle() : base(true) {} // 0 is an Invalid Handle - [System.Security.SecurityCritical] // auto-generated_required internal SafeViewOfFileHandle(IntPtr handle, bool ownsHandle) : base (ownsHandle) { SetHandle(handle); } - [System.Security.SecurityCritical] override protected bool ReleaseHandle() { if (Win32Native.UnmapViewOfFile(handle)) diff --git a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs index fa24c96718..0e57136952 100644 --- a/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs +++ b/src/mscorlib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs @@ -24,7 +24,6 @@ using System.Threading; namespace Microsoft.Win32.SafeHandles { - [System.Security.SecurityCritical] // auto-generated_required public sealed class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid { // Called by P/Invoke marshaler @@ -38,7 +37,6 @@ namespace Microsoft.Win32.SafeHandles { SetHandle(existingHandle); } - [System.Security.SecurityCritical] override protected bool ReleaseHandle() { return Win32Native.CloseHandle(handle); diff --git a/src/mscorlib/src/Microsoft/Win32/SafeHandles/Win32SafeHandles.cs b/src/mscorlib/src/Microsoft/Win32/SafeHandles/Win32SafeHandles.cs index 58e0d7ad1d..08ae0955a8 100644 --- a/src/mscorlib/src/Microsoft/Win32/SafeHandles/Win32SafeHandles.cs +++ b/src/mscorlib/src/Microsoft/Win32/SafeHandles/Win32SafeHandles.cs @@ -22,10 +22,6 @@ namespace Microsoft.Win32.SafeHandles using System.Runtime.ConstrainedExecution; // Class of safe handle which uses 0 or -1 as an invalid handle. - [System.Security.SecurityCritical] // auto-generated_required -#if !FEATURE_CORECLR - [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] -#endif public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] @@ -33,25 +29,18 @@ namespace Microsoft.Win32.SafeHandles { } -#if FEATURE_CORECLR // A default constructor is needed to satisfy CoreCLR inheritence rules. It should not be called at runtime protected SafeHandleZeroOrMinusOneIsInvalid() { throw new NotImplementedException(); } -#endif // FEATURE_CORECLR public override bool IsInvalid { - [System.Security.SecurityCritical] get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of safe handle which uses only -1 as an invalid handle. - [System.Security.SecurityCritical] // auto-generated_required -#if !FEATURE_CORECLR - [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] -#endif public abstract class SafeHandleMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] @@ -59,25 +48,18 @@ namespace Microsoft.Win32.SafeHandles { } -#if FEATURE_CORECLR // A default constructor is needed to satisfy CoreCLR inheritence rules. It should not be called at runtime protected SafeHandleMinusOneIsInvalid() { throw new NotImplementedException(); } -#endif // FEATURE_CORECLR public override bool IsInvalid { - [System.Security.SecurityCritical] get { return handle == new IntPtr(-1); } } } // Class of critical handle which uses 0 or -1 as an invalid handle. - [System.Security.SecurityCritical] // auto-generated_required -#if !FEATURE_CORECLR - [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] -#endif public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] @@ -86,16 +68,11 @@ namespace Microsoft.Win32.SafeHandles } public override bool IsInvalid { - [System.Security.SecurityCritical] get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of critical handle which uses only -1 as an invalid handle. - [System.Security.SecurityCritical] // auto-generated_required -#if !FEATURE_CORECLR - [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] -#endif public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] @@ -104,9 +81,7 @@ namespace Microsoft.Win32.SafeHandles } public override bool IsInvalid { - [System.Security.SecurityCritical] get { return handle == new IntPtr(-1); } } } - } |