Debian Codegraph @

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

raw
1 // ==++==
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // ==--==
6 /*============================================================
7 **
8 ** Class: SafeEventLogWriteHandle
9 **
10 ** <EMAIL>Author: David Gutierrez (Microsoft) </EMAIL>
11 **
12 ** A wrapper for event log handles
13 **
14 ** Date: July 8, 2002
15 **
16 ===========================================================*/
17
18 using System;
19 using System.Security;
20 using System.Security.Permissions;
21 using System.Runtime.InteropServices;
22 using System.Runtime.CompilerServices;
23 using Microsoft.Win32;
24 using Microsoft.Win32.SafeHandles;
25 using System.Runtime.ConstrainedExecution;
26 using System.Runtime.Versioning;
27
28 namespace Microsoft.Win32.SafeHandles {
29 [HostProtectionAttribute(MayLeakOnAbort = true)]
30 [SuppressUnmanagedCodeSecurityAttribute]
31 internal sealed class SafeEventLogWriteHandle : SafeHandleZeroOrMinusOneIsInvalid
32 {
33 // Note: RegisterEventSource returns 0 on failure
34
35 internal SafeEventLogWriteHandle () : base(true) {}
36
37 [DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
38 [ResourceExposure(ResourceScope.Machine)]
39 internal static extern SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName);
40
41 [DllImport(ExternDll.Advapi32, SetLastError=true)]
42 [ResourceExposure(ResourceScope.None)]
43 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
44 private static extern bool DeregisterEventSource(IntPtr hEventLog);
45
46 override protected bool ReleaseHandle()
47 {
48 return DeregisterEventSource(handle);
49 }
50 }
51 }
52
53
54