Debian Codegraph @

mcs/class/referencesource/System/compmod/microsoft/win32/safehandles/SafeFileMappingHandle.cs

raw
1 // ==++==
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // ==--==
6 /*============================================================
7 **
8 ** Class: SafeFileMappingHandle
9 **
10 ** <EMAIL>Author: David Gutierrez (Microsoft) </EMAIL>
11 **
12 ** A wrapper for handle to file mappings, returned by
13 ** CreateFileMapping and OpenFileMapping. Used for shared
14 ** memory.
15 **
16 ** Date: July 8, 2002
17 **
18 ===========================================================*/
19
20 using System;
21 using System.Security;
22 using System.Security.Permissions;
23 using System.Runtime.InteropServices;
24 using System.Runtime.CompilerServices;
25 using Microsoft.Win32;
26 using Microsoft.Win32.SafeHandles;
27 using System.Runtime.ConstrainedExecution;
28 using System.Runtime.Versioning;
29
30 namespace Microsoft.Win32.SafeHandles {
31 [HostProtectionAttribute(MayLeakOnAbort = true)]
32 [SuppressUnmanagedCodeSecurityAttribute]
33 internal sealed class SafeFileMappingHandle : SafeHandleZeroOrMinusOneIsInvalid
34 {
35 // Note that CreateFileMapping returns 0 on failure.
36
37 // Note that you can pass in -1 for the hFile parameter.
38 [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)]
39 internal SafeFileMappingHandle() : base(true) {}
40
41 [DllImport(ExternDll.Kernel32, ExactSpelling=true, SetLastError=true)]
42 [ResourceExposure(ResourceScope.None)]
43 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
44 private static extern bool CloseHandle(IntPtr handle);
45
46 override protected bool ReleaseHandle()
47 {
48 return CloseHandle(handle);
49 }
50 }
51 }