1-
21// Copyright (c) Microsoft Corporation. All rights reserved.
32// Licensed under the MIT License.
43
@@ -18,7 +17,6 @@ internal static class UnsafeNativeMethods
1817 private static readonly IntPtr s_NULL = IntPtr . Zero ;
1918
2019 // WinError.h codes:
21-
2220 internal const int ERROR_SUCCESS = 0x0 ;
2321 internal const int ERROR_FILE_NOT_FOUND = 0x2 ;
2422 internal const int ERROR_PATH_NOT_FOUND = 0x3 ;
@@ -62,7 +60,6 @@ internal static class UnsafeNativeMethods
6260 internal const int ERROR_RESOURCE_LANG_NOT_FOUND = 0x717 ; // 1815
6361
6462 // Event log specific codes:
65-
6663 internal const int ERROR_EVT_MESSAGE_NOT_FOUND = 15027 ;
6764 internal const int ERROR_EVT_MESSAGE_ID_NOT_FOUND = 15028 ;
6865 internal const int ERROR_EVT_UNRESOLVED_VALUE_INSERT = 15029 ;
@@ -71,10 +68,7 @@ internal static class UnsafeNativeMethods
7168 internal const int ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND = 15033 ;
7269 internal const int ERROR_MUI_FILE_NOT_FOUND = 15100 ;
7370
74- //
7571 // ErrorCode & format
76- //
77-
7872 // for win32 error message formatting
7973 private const int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200 ;
8074 private const int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 ;
@@ -108,12 +102,8 @@ internal static string GetMessage(int errorCode)
108102 }
109103 }
110104
111- //
112105 // ETW Methods
113- //
114- //
115106 // Callback
116- //
117107 [ SecurityCritical ]
118108 internal unsafe delegate void EtwEnableCallback (
119109 [ In ] ref Guid sourceId ,
@@ -125,9 +115,7 @@ internal unsafe delegate void EtwEnableCallback(
125115 [ In ] void * callbackContext
126116 ) ;
127117
128- //
129118 // Registration APIs
130- //
131119 [ DllImport ( EventProviderDllName , ExactSpelling = true , EntryPoint = "EventRegister" , CharSet = System . Runtime . InteropServices . CharSet . Unicode ) ]
132120 [ SecurityCritical ]
133121 internal static extern unsafe uint EventRegister (
@@ -141,9 +129,7 @@ [In][Out]ref long registrationHandle
141129 [ SecurityCritical ]
142130 internal static extern int EventUnregister ( [ In ] long registrationHandle ) ;
143131
144- //
145132 // Control (Is Enabled) APIs
146- //
147133 [ DllImport ( EventProviderDllName , ExactSpelling = true , EntryPoint = "EventEnabled" , CharSet = System . Runtime . InteropServices . CharSet . Unicode ) ]
148134 [ SecurityCritical ]
149135 internal static extern int EventEnabled ( [ In ] long registrationHandle , [ In ] ref System . Diagnostics . Eventing . EventDescriptor eventDescriptor ) ;
@@ -152,9 +138,7 @@ [In][Out]ref long registrationHandle
152138 [ SecurityCritical ]
153139 internal static extern int EventProviderEnabled ( [ In ] long registrationHandle , [ In ] byte level , [ In ] long keywords ) ;
154140
155- //
156141 // Writing (Publishing/Logging) APIs
157- //
158142 [ DllImport ( EventProviderDllName , ExactSpelling = true , EntryPoint = "EventWrite" , CharSet = System . Runtime . InteropServices . CharSet . Unicode ) ]
159143 [ SecurityCritical ]
160144 internal static extern unsafe uint EventWrite (
@@ -164,9 +148,7 @@ internal static extern unsafe uint EventWrite(
164148 [ In ] void * userData
165149 ) ;
166150
167- //
168151 // Writing (Publishing/Logging) APIs
169- //
170152 [ DllImport ( EventProviderDllName , ExactSpelling = true , EntryPoint = "EventWrite" , CharSet = System . Runtime . InteropServices . CharSet . Unicode ) ]
171153 [ SecurityCritical ]
172154 internal static extern unsafe uint EventWrite (
@@ -195,16 +177,12 @@ internal static extern unsafe uint EventWriteString(
195177 [ In ] long keywords ,
196178 [ In ] char * message
197179 ) ;
198- //
199180 // ActivityId Control APIs
200- //
201181 [ DllImport ( EventProviderDllName , ExactSpelling = true , EntryPoint = "EventActivityIdControl" , CharSet = System . Runtime . InteropServices . CharSet . Unicode ) ]
202182 [ SecurityCritical ]
203183 internal static extern unsafe uint EventActivityIdControl ( [ In ] int ControlCode , [ In ] [ Out ] ref Guid ActivityId ) ;
204184
205- //
206185 // EventLog
207- //
208186 [ Flags ]
209187 internal enum EvtQueryFlags
210188 {
@@ -384,7 +362,7 @@ internal enum EvtPublisherMetadataPropertyId
384362 EvtPublisherMetadataKeywords = 25 , // EvtVarTypeEvtHandle, ObjectArray
385363 EvtPublisherMetadataKeywordName = 26 , // EvtVarTypeString
386364 EvtPublisherMetadataKeywordValue = 27 , // EvtVarTypeUInt64
387- EvtPublisherMetadataKeywordMessageID = 28 //, // EvtVarTypeUInt32
365+ EvtPublisherMetadataKeywordMessageID = 28 // EvtVarTypeUInt32
388366 // EvtPublisherMetadataPropertyIdEND
389367 }
390368
@@ -631,7 +609,6 @@ out int publisherMetadataPropertyBufferUsed
631609 ) ;
632610
633611 // NEW
634-
635612 [ DllImport ( WEVTAPI , CharSet = CharSet . Unicode , SetLastError = true ) ]
636613 [ SecurityCritical ]
637614 [ return : MarshalAs ( UnmanagedType . Bool ) ]
@@ -682,7 +659,6 @@ out int eventMetadataPropertyBufferUsed
682659 ) ;
683660
684661 // Channel Configuration Native Api
685-
686662 [ DllImport ( WEVTAPI , CharSet = CharSet . Unicode , SetLastError = true ) ]
687663 [ SecurityCritical ]
688664 internal static extern EventLogHandle EvtOpenChannelEnum (
@@ -756,8 +732,7 @@ internal static extern bool EvtGetChannelConfigProperty(
756732 out int propertyValueBufferUsed
757733 ) ;
758734
759- // Log Information Native Api
760-
735+ // Log Information Native API
761736 [ DllImport ( WEVTAPI , CharSet = CharSet . Unicode , SetLastError = true ) ]
762737 [ SecurityCritical ]
763738 internal static extern EventLogHandle EvtOpenLog (
@@ -778,7 +753,6 @@ out int propertyValueBufferUsed
778753 ) ;
779754
780755 // LOG MANIPULATION
781-
782756 [ DllImport ( WEVTAPI , CharSet = CharSet . Unicode , SetLastError = true ) ]
783757 [ SecurityCritical ]
784758 [ return : MarshalAs ( UnmanagedType . Bool ) ]
0 commit comments