713 references to UnsafeNativeMethods
System.Core (713)
Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs (1)
32
return
UnsafeNativeMethods
.FreeLibrary(handle);
Microsoft\Win32\SafeHandles\SafeMemoryMappedFileHandle.cs (1)
46
return
UnsafeNativeMethods
.CloseHandle(handle);
Microsoft\Win32\SafeHandles\SafeMemoryMappedViewHandle.cs (1)
48
if (
UnsafeNativeMethods
.UnmapViewOfFile(handle)) {
Microsoft\Win32\SafeHandles\SafePerfProviderHandle.cs (2)
24
uint Status =
UnsafeNativeMethods
.PerfStopProvider(tempProviderHandle);
25
Debug.Assert(Status == (uint)
UnsafeNativeMethods
.ERROR_SUCCESS, "PerfStopProvider() fails");
Microsoft\Win32\SafeHandles\SafePipeHandle.cs (1)
36
return
UnsafeNativeMethods
.CloseHandle(handle);
Microsoft\Win32\UnsafeNativeMethods.cs (6)
196
int fileType =
UnsafeNativeMethods
.GetFileType(handle);
197
if (fileType !=
UnsafeNativeMethods
.FILE_TYPE_DISK) {
259
int result =
UnsafeNativeMethods
.FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
261
UnsafeNativeMethods
.NULL, errorCode, 0, sb, sb.Capacity,
UnsafeNativeMethods
.NULL);
327
UnsafeNativeMethods
.SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition,
System\Diagnostics\Eventing\EventProvider.cs (17)
24
UnsafeNativeMethods
.EtwEnableCallback m_etwCallback; // Trace Callback function
114
m_etwCallback = new
UnsafeNativeMethods
.EtwEnableCallback(EtwEnableCallBack);
117
status =
UnsafeNativeMethods
.EventRegister(ref m_providerId, m_etwCallback, null, ref m_regHandle);
194
UnsafeNativeMethods
.EventUnregister(m_regHandle);
278
case
UnsafeNativeMethods
.ERROR_ARITHMETIC_OVERFLOW:
279
case
UnsafeNativeMethods
.ERROR_MORE_DATA:
282
case
UnsafeNativeMethods
.ERROR_NOT_ENOUGH_MEMORY:
481
status = (int)
UnsafeNativeMethods
.EventWriteString(m_regHandle, eventLevel, eventKeywords, pdata);
559
status =
UnsafeNativeMethods
.EventWrite(m_regHandle,
566
status =
UnsafeNativeMethods
.EventWriteTransfer(m_regHandle,
606
status =
UnsafeNativeMethods
.EventWrite(
616
status =
UnsafeNativeMethods
.EventWriteTransfer(
757
status =
UnsafeNativeMethods
.EventWrite (m_regHandle,
764
status =
UnsafeNativeMethods
.EventWriteTransfer (m_regHandle,
791
status =
UnsafeNativeMethods
.EventWriteTransfer(
820
UnsafeNativeMethods
.EventActivityIdControl((int)ActivityControl.EVENT_ACTIVITY_CTRL_SET_ID, ref id);
827
UnsafeNativeMethods
.EventActivityIdControl((int)ActivityControl.EVENT_ACTIVITY_CTRL_CREATE_ID, ref newId);
System\Diagnostics\Eventing\Reader\EventLogConfiguration.cs (30)
94
return (EventLogType)((uint)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelConfigType));
100
return (EventLogIsolation)((uint)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelConfigIsolation));
106
return (bool)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelConfigEnabled);
109
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelConfigEnabled, (object)value);
115
return (bool)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelConfigClassicEventlog);
121
return (string)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelConfigAccess);
124
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelConfigAccess, (object)value);
130
return (string)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigLogFilePath);
133
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigLogFilePath, (object)value);
139
return (long)((ulong)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigMaxSize));
142
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigMaxSize, (object)value);
148
object nativeRetentionObject = NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigRetention);
149
object nativeAutoBackupObject = NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigAutoBackup);
166
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigAutoBackup, (object)false);
167
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigRetention, (object)false);
170
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigAutoBackup, (object)true);
171
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigRetention, (object)true);
174
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigAutoBackup, (object)false);
175
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigRetention, (object)true);
183
return (string)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelConfigOwningPublisher);
189
return (string[])NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublisherList);
195
return (int?)((uint?)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigLevel));
198
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigLevel, (object)value);
204
return (long?)((ulong?)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigKeywords));
207
NativeWrapper.EvtSetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigKeywords, (object)value);
213
return (int?)((uint?)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigBufferSize));
219
return (int?)((uint?)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigMinBuffers));
225
return (int?)((uint?)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigMaxBuffers));
231
return (int?)((uint?)NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigLatency));
237
return (Guid?)(NativeWrapper.EvtGetChannelConfigProperty(this.handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigControlGuid));
System\Diagnostics\Eventing\Reader\EventLogInformation.cs (8)
47
creationTime = (DateTime?)NativeWrapper.EvtGetLogInfo(logHandle,
UnsafeNativeMethods
.EvtLogPropertyId.EvtLogCreationTime);
48
lastAccessTime = (DateTime?)NativeWrapper.EvtGetLogInfo(logHandle,
UnsafeNativeMethods
.EvtLogPropertyId.EvtLogLastAccessTime);
49
lastWriteTime = (DateTime?)NativeWrapper.EvtGetLogInfo(logHandle,
UnsafeNativeMethods
.EvtLogPropertyId.EvtLogLastWriteTime);
50
fileSize = (long?)((ulong?)NativeWrapper.EvtGetLogInfo(logHandle,
UnsafeNativeMethods
.EvtLogPropertyId.EvtLogFileSize));
51
fileAttributes = (int?)((uint?)NativeWrapper.EvtGetLogInfo(logHandle,
UnsafeNativeMethods
.EvtLogPropertyId.EvtLogAttributes));
52
recordCount = (long?)((ulong?)NativeWrapper.EvtGetLogInfo(logHandle,
UnsafeNativeMethods
.EvtLogPropertyId.EvtLogNumberOfLogRecords));
53
oldestRecordNumber = (long?)((ulong?)NativeWrapper.EvtGetLogInfo(logHandle,
UnsafeNativeMethods
.EvtLogPropertyId.EvtLogOldestRecordNumber));
54
isLogFull = (bool?)NativeWrapper.EvtGetLogInfo(logHandle,
UnsafeNativeMethods
.EvtLogPropertyId.EvtLogFull);
System\Diagnostics\Eventing\Reader\EventLogPropertySelector.cs (1)
59
renderContextHandleValues = NativeWrapper.EvtCreateRenderContext(paths.Length, paths,
UnsafeNativeMethods
.EvtRenderContextFlags.EvtRenderContextValues);
System\Diagnostics\Eventing\Reader\EventLogReader.cs (11)
103
flag |= (int)
UnsafeNativeMethods
.EvtQueryFlags.EvtQueryChannelPath;
105
flag |= (int)
UnsafeNativeMethods
.EvtQueryFlags.EvtQueryFilePath;
108
flag |= (int)
UnsafeNativeMethods
.EvtQueryFlags.EvtQueryReverseDirection;
111
flag |= (int)
UnsafeNativeMethods
.EvtQueryFlags.EvtQueryTolerateQueryErrors;
123
NativeWrapper.EvtSeek(handle, 1, bookmarkHandle, 0,
UnsafeNativeMethods
.EvtSeekFlags.EvtSeekRelativeToBookmark);
244
NativeWrapper.EvtSeek(this.handle, offset, EventLogHandle.Zero, 0,
UnsafeNativeMethods
.EvtSeekFlags.EvtSeekRelativeToCurrent);
260
NativeWrapper.EvtSeek(this.handle, offset, bookmarkHandle, 0,
UnsafeNativeMethods
.EvtSeekFlags.EvtSeekRelativeToBookmark);
272
NativeWrapper.EvtSeek(this.handle, offset, EventLogHandle.Zero, 0,
UnsafeNativeMethods
.EvtSeekFlags.EvtSeekRelativeToFirst);
278
NativeWrapper.EvtSeek(this.handle, offset, EventLogHandle.Zero, 0,
UnsafeNativeMethods
.EvtSeekFlags.EvtSeekRelativeToLast);
337
channelNames = (string[])NativeWrapper.EvtGetQueryInfo(queryHandle,
UnsafeNativeMethods
.EvtQueryPropertyId.EvtQueryNames);
338
errorStatuses = (int[])NativeWrapper.EvtGetQueryInfo(queryHandle,
UnsafeNativeMethods
.EvtQueryPropertyId.EvtQueryStatuses);
System\Diagnostics\Eventing\Reader\EventLogRecord.cs (4)
89
NativeWrapper.EvtRenderBufferWithContextSystem(this.session.renderContextHandleSystem, this.handle,
UnsafeNativeMethods
.EvtRenderFlags.EvtRenderEventValues, this.systemProperties, SYSTEM_PROPERTY_COUNT);
229
this.containerChannel = (string)NativeWrapper.EvtGetEventInfo(this.Handle,
UnsafeNativeMethods
.EvtEventPropertyId.EvtEventPath);
242
this.matchedQueryIds = (int[])NativeWrapper.EvtGetEventInfo(this.Handle,
UnsafeNativeMethods
.EvtEventPropertyId.EvtEventQueryIDs);
364
NativeWrapper.EvtRender(EventLogHandle.Zero, this.handle,
UnsafeNativeMethods
.EvtRenderFlags.EvtRenderEventXml, renderBuffer);
System\Diagnostics\Eventing\Reader\EventLogSession.cs (9)
82
this.renderContextHandleSystem = NativeWrapper.EvtCreateRenderContext(0, null,
UnsafeNativeMethods
.EvtRenderContextFlags.EvtRenderContextSystem);
94
this.renderContextHandleUser = NativeWrapper.EvtCreateRenderContext(0, null,
UnsafeNativeMethods
.EvtRenderContextFlags.EvtRenderContextUser);
128
UnsafeNativeMethods
.EvtRpcLogin erLogin = new
UnsafeNativeMethods
.EvtRpcLogin();
139
handle = NativeWrapper.EvtOpenSession(
UnsafeNativeMethods
.EvtLoginClass.EvtRpcLogin, ref erLogin, 0, 0);
252
UnsafeNativeMethods
.EvtExportLogFlags flag;
256
flag =
UnsafeNativeMethods
.EvtExportLogFlags.EvtExportLogChannelPath;
259
flag =
UnsafeNativeMethods
.EvtExportLogFlags.EvtExportLogFilePath;
268
NativeWrapper.EvtExportLog(this.Handle, path, query, targetFilePath, (int)flag | (int)
UnsafeNativeMethods
.EvtExportLogFlags.EvtExportLogTolerateQueryErrors);
System\Diagnostics\Eventing\Reader\EventLogWatcher.cs (4)
160
flag |= (int)
UnsafeNativeMethods
.EvtSubscribeFlags.EvtSubscribeStartAfterBookmark;
162
flag |= (int)
UnsafeNativeMethods
.EvtSubscribeFlags.EvtSubscribeStartAtOldestRecord;
164
flag |= (int)
UnsafeNativeMethods
.EvtSubscribeFlags.EvtSubscribeToFutureEvents;
167
flag |= (int)
UnsafeNativeMethods
.EvtSubscribeFlags.EvtSubscribeTolerateQueryErrors;
System\Diagnostics\Eventing\Reader\NativeWrapper.cs (328)
70
EventLogHandle handle =
UnsafeNativeMethods
.EvtQuery(session, path, query, flags);
84
UnsafeNativeMethods
.EvtSeekFlags flags) {
85
bool status =
UnsafeNativeMethods
.EvtSeek(resultSet, position, bookmark, timeout, flags);
104
EventLogHandle handle =
UnsafeNativeMethods
.EvtSubscribe(
129
bool status =
UnsafeNativeMethods
.EvtNext(queryHandle, eventSize, events, timeout, flags, ref returned);
131
if (!status && win32Error !=
UnsafeNativeMethods
.ERROR_NO_MORE_ITEMS)
141
if (!
UnsafeNativeMethods
.EvtCancel(handle)) {
154
UnsafeNativeMethods
.EvtClose(handle);
173
EventLogHandle handle =
UnsafeNativeMethods
.EvtOpenPublisherMetadata(session, ProviderId, logFilePath, 0, flags);
184
bool status =
UnsafeNativeMethods
.EvtGetObjectArraySize(objectArray, out arraySize);
193
EventLogHandle emEnumHandle =
UnsafeNativeMethods
.EvtOpenEventMetadataEnum(ProviderMetadata, flags);
203
EventLogHandle emHandle =
UnsafeNativeMethods
.EvtNextEventMetadata(eventMetadataEnum, flags);
207
if (win32Error !=
UnsafeNativeMethods
.ERROR_NO_MORE_ITEMS)
220
EventLogHandle channelEnum =
UnsafeNativeMethods
.EvtOpenChannelEnum(session, flags);
232
EventLogHandle pubEnum =
UnsafeNativeMethods
.EvtOpenPublisherEnum(session, flags);
244
EventLogHandle handle =
UnsafeNativeMethods
.EvtOpenChannelConfig(session, channelPath, flags);
254
bool status =
UnsafeNativeMethods
.EvtSaveChannelConfig(channelConfig, flags);
266
EventLogHandle logHandle =
UnsafeNativeMethods
.EvtOpenLog(session, path, flags);
287
status =
UnsafeNativeMethods
.EvtExportLog(session, channelPath, query, targetFilePath, flags);
306
status =
UnsafeNativeMethods
.EvtArchiveExportedLog(session, logFilePath, locale, flags);
325
status =
UnsafeNativeMethods
.EvtClearLog(session, channelPath, targetFilePath, flags);
335
UnsafeNativeMethods
.EvtRenderContextFlags flags) {
339
EventLogHandle renderContextHandleValues =
UnsafeNativeMethods
.EvtCreateRenderContext(valuePathsCount, valuePaths, flags);
350
UnsafeNativeMethods
.EvtRenderFlags flags,
357
bool status =
UnsafeNativeMethods
.EvtRender(context, eventHandle, flags, buffer.Capacity, buffer, out buffUsed, out propCount);
361
if (win32Error ==
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER) {
364
status =
UnsafeNativeMethods
.EvtRender(context, eventHandle, flags, buffer.Capacity, buffer, out buffUsed, out propCount);
374
public static EventLogHandle EvtOpenSession(
UnsafeNativeMethods
.EvtLoginClass loginClass, ref
UnsafeNativeMethods
.EvtRpcLogin login, int timeout, int flags) {
378
EventLogHandle handle =
UnsafeNativeMethods
.EvtOpenSession(loginClass, ref login, timeout, flags);
390
EventLogHandle handle =
UnsafeNativeMethods
.EvtCreateBookmark(bookmarkXml);
399
bool status =
UnsafeNativeMethods
.EvtUpdateBookmark(bookmark, eventHandle);
406
public static object EvtGetEventInfo(EventLogHandle handle,
UnsafeNativeMethods
.EvtEventPropertyId enumType) {
413
bool status =
UnsafeNativeMethods
.EvtGetEventInfo(handle, enumType, 0, IntPtr.Zero, out bufferNeeded);
416
if (error ==
UnsafeNativeMethods
.ERROR_SUCCESS) { }
418
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
422
status =
UnsafeNativeMethods
.EvtGetEventInfo(handle, enumType, bufferNeeded, buffer, out bufferNeeded);
427
UnsafeNativeMethods
.EvtVariant varVal = (
UnsafeNativeMethods
.EvtVariant)Marshal.PtrToStructure(buffer, typeof(
UnsafeNativeMethods
.EvtVariant));
438
public static object EvtGetQueryInfo(EventLogHandle handle,
UnsafeNativeMethods
.EvtQueryPropertyId enumType) {
442
bool status =
UnsafeNativeMethods
.EvtGetQueryInfo(handle, enumType, 0, IntPtr.Zero, ref bufferNeeded);
445
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
449
status =
UnsafeNativeMethods
.EvtGetQueryInfo(handle, enumType, bufferNeeded, buffer, ref bufferNeeded);
454
UnsafeNativeMethods
.EvtVariant varVal = (
UnsafeNativeMethods
.EvtVariant)Marshal.PtrToStructure(buffer, typeof(
UnsafeNativeMethods
.EvtVariant));
463
public static object EvtGetPublisherMetadataProperty(EventLogHandle pmHandle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId thePropertyId) {
470
bool status =
UnsafeNativeMethods
.EvtGetPublisherMetadataProperty(pmHandle, thePropertyId, 0, 0, IntPtr.Zero, out bufferNeeded);
473
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
477
status =
UnsafeNativeMethods
.EvtGetPublisherMetadataProperty(pmHandle, thePropertyId, 0, bufferNeeded, buffer, out bufferNeeded);
482
UnsafeNativeMethods
.EvtVariant varVal = (
UnsafeNativeMethods
.EvtVariant)Marshal.PtrToStructure(buffer, typeof(
UnsafeNativeMethods
.EvtVariant));
492
internal static EventLogHandle EvtGetPublisherMetadataPropertyHandle(EventLogHandle pmHandle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId thePropertyId) {
496
bool status =
UnsafeNativeMethods
.EvtGetPublisherMetadataProperty(pmHandle, thePropertyId, 0, 0, IntPtr.Zero, out bufferNeeded);
499
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
503
status =
UnsafeNativeMethods
.EvtGetPublisherMetadataProperty(pmHandle, thePropertyId, 0, bufferNeeded, buffer, out bufferNeeded);
515
UnsafeNativeMethods
.EvtVariant varVal = (
UnsafeNativeMethods
.EvtVariant)Marshal.PtrToStructure(buffer, typeof(
UnsafeNativeMethods
.EvtVariant));
533
bool status =
UnsafeNativeMethods
.EvtFormatMessage(handle, EventLogHandle.Zero, msgId, 0, null,
UnsafeNativeMethods
.EvtFormatMessageFlags.EvtFormatMessageId, 0, sb, out bufferNeeded);
537
if (!status && error !=
UnsafeNativeMethods
.ERROR_EVT_UNRESOLVED_VALUE_INSERT
538
&& error !=
UnsafeNativeMethods
.ERROR_EVT_UNRESOLVED_PARAMETER_INSERT
539
&& error !=
UnsafeNativeMethods
.ERROR_EVT_MAX_INSERTS_REACHED ) {
541
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_NOT_FOUND:
542
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_ID_NOT_FOUND:
543
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND:
544
case
UnsafeNativeMethods
.ERROR_RESOURCE_LANG_NOT_FOUND:
545
case
UnsafeNativeMethods
.ERROR_MUI_FILE_NOT_FOUND:
548
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
553
status =
UnsafeNativeMethods
.EvtFormatMessage(handle, EventLogHandle.Zero, msgId, 0, null,
UnsafeNativeMethods
.EvtFormatMessageFlags.EvtFormatMessageId, bufferNeeded, sb, out bufferNeeded);
556
if (!status && error !=
UnsafeNativeMethods
.ERROR_EVT_UNRESOLVED_VALUE_INSERT
557
&& error !=
UnsafeNativeMethods
.ERROR_EVT_UNRESOLVED_PARAMETER_INSERT
558
&& error !=
UnsafeNativeMethods
.ERROR_EVT_MAX_INSERTS_REACHED ) {
560
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_NOT_FOUND:
561
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_ID_NOT_FOUND:
562
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND:
563
case
UnsafeNativeMethods
.ERROR_RESOURCE_LANG_NOT_FOUND:
564
case
UnsafeNativeMethods
.ERROR_MUI_FILE_NOT_FOUND:
567
if (error ==
UnsafeNativeMethods
.ERROR_EVT_UNRESOLVED_VALUE_INSERT) {
581
bool status =
UnsafeNativeMethods
.EvtGetObjectArrayProperty(objArrayHandle, thePropertyId, index, 0, 0, IntPtr.Zero, out bufferNeeded);
585
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
589
status =
UnsafeNativeMethods
.EvtGetObjectArrayProperty(objArrayHandle, thePropertyId, index, 0, bufferNeeded, buffer, out bufferNeeded);
594
UnsafeNativeMethods
.EvtVariant varVal = (
UnsafeNativeMethods
.EvtVariant)Marshal.PtrToStructure(buffer, typeof(
UnsafeNativeMethods
.EvtVariant));
603
public static object EvtGetEventMetadataProperty(EventLogHandle handle,
UnsafeNativeMethods
.EvtEventMetadataPropertyId enumType) {
608
bool status =
UnsafeNativeMethods
.EvtGetEventMetadataProperty(handle, enumType, 0, 0, IntPtr.Zero, out bufferNeeded);
611
if (win32Error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
615
status =
UnsafeNativeMethods
.EvtGetEventMetadataProperty(handle, enumType, 0, bufferNeeded, buffer, out bufferNeeded);
620
UnsafeNativeMethods
.EvtVariant varVal = (
UnsafeNativeMethods
.EvtVariant)Marshal.PtrToStructure(buffer, typeof(
UnsafeNativeMethods
.EvtVariant));
630
public static object EvtGetChannelConfigProperty(EventLogHandle handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId enumType) {
638
bool status =
UnsafeNativeMethods
.EvtGetChannelConfigProperty(handle, enumType, 0, 0, IntPtr.Zero, out bufferNeeded);
641
if (win32Error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
645
status =
UnsafeNativeMethods
.EvtGetChannelConfigProperty(handle, enumType, 0, bufferNeeded, buffer, out bufferNeeded);
657
UnsafeNativeMethods
.EvtVariant varVal = (
UnsafeNativeMethods
.EvtVariant)Marshal.PtrToStructure(buffer, typeof(
UnsafeNativeMethods
.EvtVariant));
667
public static void EvtSetChannelConfigProperty(EventLogHandle handle,
UnsafeNativeMethods
.EvtChannelConfigPropertyId enumType, object val) {
671
UnsafeNativeMethods
.EvtVariant varVal = new
UnsafeNativeMethods
.EvtVariant();
680
case
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelConfigEnabled: {
681
varVal.Type = (uint)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeBoolean;
686
case
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelConfigAccess: {
687
varVal.Type = (uint)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeString;
692
case
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigLogFilePath: {
693
varVal.Type = (uint)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeString;
698
case
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigMaxSize: {
699
varVal.Type = (uint)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt64;
703
case
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigLevel: {
704
varVal.Type = (uint)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt32;
708
case
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelPublishingConfigKeywords: {
709
varVal.Type = (uint)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt64;
713
case
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigRetention: {
714
varVal.Type = (uint)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeBoolean;
719
case
UnsafeNativeMethods
.EvtChannelConfigPropertyId.EvtChannelLoggingConfigAutoBackup: {
720
varVal.Type = (uint)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeBoolean;
730
varVal.Type = (uint)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeNull;
732
bool status =
UnsafeNativeMethods
.EvtSetChannelConfigProperty(handle, enumType, 0, ref varVal);
744
bool status =
UnsafeNativeMethods
.EvtNextChannelPath(handle, 0, sb, out channelNameNeeded);
747
if (win32Error ==
UnsafeNativeMethods
.ERROR_NO_MORE_ITEMS) {
752
if (win32Error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
757
status =
UnsafeNativeMethods
.EvtNextChannelPath(handle, channelNameNeeded, sb, out channelNameNeeded);
770
bool status =
UnsafeNativeMethods
.EvtNextPublisherId(handle, 0, sb, out ProviderIdNeeded);
773
if (win32Error ==
UnsafeNativeMethods
.ERROR_NO_MORE_ITEMS) {
778
if (win32Error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
783
status =
UnsafeNativeMethods
.EvtNextPublisherId(handle, ProviderIdNeeded, sb, out ProviderIdNeeded);
792
public static object EvtGetLogInfo(EventLogHandle handle,
UnsafeNativeMethods
.EvtLogPropertyId enumType) {
797
bool status =
UnsafeNativeMethods
.EvtGetLogInfo(handle, enumType, 0, IntPtr.Zero, out bufferNeeded);
800
if (win32Error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
804
status =
UnsafeNativeMethods
.EvtGetLogInfo(handle, enumType, bufferNeeded, buffer, out bufferNeeded);
809
UnsafeNativeMethods
.EvtVariant varVal = (
UnsafeNativeMethods
.EvtVariant)Marshal.PtrToStructure(buffer, typeof(
UnsafeNativeMethods
.EvtVariant));
819
public static void EvtRenderBufferWithContextSystem(EventLogHandle contextHandle, EventLogHandle eventHandle,
UnsafeNativeMethods
.EvtRenderFlags flag, SystemProperties systemProperties, int SYSTEM_PROPERTY_COUNT) {
828
bool status =
UnsafeNativeMethods
.EvtRender(contextHandle, eventHandle, flag, 0, IntPtr.Zero, out bufferNeeded, out propCount);
831
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
836
status =
UnsafeNativeMethods
.EvtRender(contextHandle, eventHandle, flag, bufferNeeded, buffer, out bufferNeeded, out propCount);
847
UnsafeNativeMethods
.EvtVariant varVal = (
UnsafeNativeMethods
.EvtVariant)Marshal.PtrToStructure(pointer, typeof(
UnsafeNativeMethods
.EvtVariant));
849
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemProviderName:
850
systemProperties.ProviderName = (string)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeString);
852
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemProviderGuid:
853
systemProperties.ProviderId = (Guid?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeGuid);
855
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemEventID:
856
systemProperties.Id = (ushort?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt16);
858
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemQualifiers:
859
systemProperties.Qualifiers = (ushort?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt16);
861
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemLevel:
862
systemProperties.Level = (byte?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeByte);
864
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemTask:
865
systemProperties.Task = (ushort?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt16);
867
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemOpcode:
868
systemProperties.Opcode = (byte?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeByte);
870
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemKeywords:
871
systemProperties.Keywords = (ulong?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeHexInt64);
873
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemTimeCreated:
874
systemProperties.TimeCreated = (DateTime?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeFileTime);
876
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemEventRecordId:
877
systemProperties.RecordId = (ulong?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt64);
879
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemActivityID:
880
systemProperties.ActivityId = (Guid?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeGuid);
882
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemRelatedActivityID:
883
systemProperties.RelatedActivityId = (Guid?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeGuid);
885
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemProcessID:
886
systemProperties.ProcessId = (uint?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt32);
888
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemThreadID:
889
systemProperties.ThreadId = (uint?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt32);
891
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemChannel:
892
systemProperties.ChannelName = (string)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeString);
894
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemComputer:
895
systemProperties.ComputerName = (string)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeString);
897
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemUserID:
898
systemProperties.UserId = (SecurityIdentifier)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSid);
900
case (int)
UnsafeNativeMethods
.EvtSystemPropertyId.EvtSystemVersion:
901
systemProperties.Version = (byte?)ConvertToObject(varVal,
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeByte);
921
UnsafeNativeMethods
.EvtRenderFlags flag =
UnsafeNativeMethods
.EvtRenderFlags.EvtRenderEventValues;
926
bool status =
UnsafeNativeMethods
.EvtRender(contextHandle, eventHandle, flag, 0, IntPtr.Zero, out bufferNeeded, out propCount);
929
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
934
status =
UnsafeNativeMethods
.EvtRender(contextHandle, eventHandle, flag, bufferNeeded, buffer, out bufferNeeded, out propCount);
943
UnsafeNativeMethods
.EvtVariant varVal = (
UnsafeNativeMethods
.EvtVariant)Marshal.PtrToStructure(pointer, typeof(
UnsafeNativeMethods
.EvtVariant));
957
public static string EvtFormatMessageRenderName(EventLogHandle pmHandle, EventLogHandle eventHandle,
UnsafeNativeMethods
.EvtFormatMessageFlags flag) {
964
bool status =
UnsafeNativeMethods
.EvtFormatMessage(pmHandle, eventHandle, 0, 0, null, flag, 0, sb, out bufferNeeded);
967
if (!status && error !=
UnsafeNativeMethods
.ERROR_EVT_UNRESOLVED_VALUE_INSERT) {
975
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_NOT_FOUND:
976
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_ID_NOT_FOUND:
977
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND:
978
case
UnsafeNativeMethods
.ERROR_RESOURCE_LANG_NOT_FOUND:
979
case
UnsafeNativeMethods
.ERROR_MUI_FILE_NOT_FOUND:
982
if (error != (int)
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
987
status =
UnsafeNativeMethods
.EvtFormatMessage(pmHandle, eventHandle, 0, 0, null, flag, bufferNeeded, sb, out bufferNeeded);
990
if (!status && error !=
UnsafeNativeMethods
.ERROR_EVT_UNRESOLVED_VALUE_INSERT)
993
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_NOT_FOUND:
994
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_ID_NOT_FOUND:
995
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND:
996
case
UnsafeNativeMethods
.ERROR_RESOURCE_LANG_NOT_FOUND:
997
case
UnsafeNativeMethods
.ERROR_MUI_FILE_NOT_FOUND:
1008
public static IEnumerable<string> EvtFormatMessageRenderKeywords(EventLogHandle pmHandle, EventLogHandle eventHandle,
UnsafeNativeMethods
.EvtFormatMessageFlags flag) {
1017
bool status =
UnsafeNativeMethods
.EvtFormatMessageBuffer(pmHandle, eventHandle, 0, 0, IntPtr.Zero, flag, 0, IntPtr.Zero, out bufferNeeded);
1022
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_NOT_FOUND:
1023
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_ID_NOT_FOUND:
1024
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND:
1025
case
UnsafeNativeMethods
.ERROR_RESOURCE_LANG_NOT_FOUND:
1026
case
UnsafeNativeMethods
.ERROR_MUI_FILE_NOT_FOUND:
1029
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
1034
status =
UnsafeNativeMethods
.EvtFormatMessageBuffer(pmHandle, eventHandle, 0, 0, IntPtr.Zero, flag, bufferNeeded, buffer, out bufferNeeded);
1039
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_NOT_FOUND:
1040
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_ID_NOT_FOUND:
1041
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND:
1042
case
UnsafeNativeMethods
.ERROR_RESOURCE_LANG_NOT_FOUND:
1043
case
UnsafeNativeMethods
.ERROR_MUI_FILE_NOT_FOUND:
1073
UnsafeNativeMethods
.EvtRenderFlags flag =
UnsafeNativeMethods
.EvtRenderFlags.EvtRenderBookmark;
1076
bool status =
UnsafeNativeMethods
.EvtRender(EventLogHandle.Zero, eventHandle, flag, 0, IntPtr.Zero, out bufferNeeded, out propCount);
1079
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
1084
status =
UnsafeNativeMethods
.EvtRender(EventLogHandle.Zero, eventHandle, flag, bufferNeeded, buffer, out bufferNeeded, out propCount);
1108
UnsafeNativeMethods
.EvtStringVariant [] stringVariants = new
UnsafeNativeMethods
.EvtStringVariant[values.Length];
1110
stringVariants[i].Type = (uint)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeString;
1115
bool status =
UnsafeNativeMethods
.EvtFormatMessage(handle, eventHandle, 0xffffffff, values.Length, stringVariants,
UnsafeNativeMethods
.EvtFormatMessageFlags.EvtFormatMessageEvent, 0, sb, out bufferNeeded);
1118
if (!status && error !=
UnsafeNativeMethods
.ERROR_EVT_UNRESOLVED_VALUE_INSERT) {
1127
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_NOT_FOUND:
1128
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_ID_NOT_FOUND:
1129
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND:
1130
case
UnsafeNativeMethods
.ERROR_RESOURCE_LANG_NOT_FOUND:
1131
case
UnsafeNativeMethods
.ERROR_MUI_FILE_NOT_FOUND:
1134
if (error !=
UnsafeNativeMethods
.ERROR_INSUFFICIENT_BUFFER)
1139
status =
UnsafeNativeMethods
.EvtFormatMessage(handle, eventHandle, 0xffffffff, values.Length, stringVariants,
UnsafeNativeMethods
.EvtFormatMessageFlags.EvtFormatMessageEvent, bufferNeeded, sb, out bufferNeeded);
1142
if (!status && error !=
UnsafeNativeMethods
.ERROR_EVT_UNRESOLVED_VALUE_INSERT) {
1145
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_NOT_FOUND:
1146
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_ID_NOT_FOUND:
1147
case
UnsafeNativeMethods
.ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND:
1148
case
UnsafeNativeMethods
.ERROR_RESOURCE_LANG_NOT_FOUND:
1149
case
UnsafeNativeMethods
.ERROR_MUI_FILE_NOT_FOUND:
1159
private static object ConvertToObject(
UnsafeNativeMethods
.EvtVariant val) {
1162
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt32:
1164
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeInt32:
1166
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt16:
1168
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeInt16:
1170
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeByte:
1172
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSByte:
1174
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt64:
1176
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeInt64:
1178
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeHexInt64:
1180
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeHexInt32:
1182
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSingle:
1184
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeDouble:
1186
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeNull:
1188
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeString:
1190
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeAnsiString:
1192
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSid:
1194
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeGuid:
1196
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeEvtHandle:
1198
case (int)(int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeFileTime:
1200
case (int)(int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSysTime:
1201
UnsafeNativeMethods
.SystemTime sysTime = (
UnsafeNativeMethods
.SystemTime)Marshal.PtrToStructure(val.SystemTime, typeof(
UnsafeNativeMethods
.SystemTime));
1203
case (int)(int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSizeT:
1205
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeBoolean:
1208
case (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeBinary:
1209
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeByte):
1214
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeInt16):
1219
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeInt32):
1224
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeInt64):
1229
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSingle):
1234
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeDouble):
1239
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSByte):
1241
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt16):
1243
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt64):
1244
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeHexInt64):
1246
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeUInt32):
1247
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeHexInt32):
1249
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeString):
1251
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeAnsiString):
1253
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeBoolean):
1255
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeGuid):
1257
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeFileTime):
1259
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSysTime):
1261
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeBinary): //both length and count in the manifest: tracrpt supports, Crimson APIs don't
1262
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSizeT): //unused: array of win:pointer is returned as HexIntXX
1263
case ((int)
UnsafeNativeMethods
.EvtMasks.EVT_VARIANT_TYPE_ARRAY | (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeSid): //unsupported by native APIs
1270
public static object ConvertToObject(
UnsafeNativeMethods
.EvtVariant val,
UnsafeNativeMethods
.EvtVariantType desiredType) {
1271
if (val.Type == (int)
UnsafeNativeMethods
.EvtVariantType.EvtVarTypeNull) return null;
1280
public static string ConvertToString(
UnsafeNativeMethods
.EvtVariant val) {
1288
public static string ConvertToAnsiString(
UnsafeNativeMethods
.EvtVariant val) {
1297
public static EventLogHandle ConvertToSafeHandle(
UnsafeNativeMethods
.EvtVariant val) {
1306
public static Array ConvertToArray(
UnsafeNativeMethods
.EvtVariant val, Type objType, int size) {
1322
public static Array ConvertToBoolArray(
UnsafeNativeMethods
.EvtVariant val) {
1341
public static Array ConvertToFileTimeArray(
UnsafeNativeMethods
.EvtVariant val) {
1357
public static Array ConvertToSysTimeArray(
UnsafeNativeMethods
.EvtVariant val) {
1366
UnsafeNativeMethods
.SystemTime sysTime = (
UnsafeNativeMethods
.SystemTime)Marshal.PtrToStructure(ptr, typeof(
UnsafeNativeMethods
.SystemTime));
1377
public static string[] ConvertToStringArray(
UnsafeNativeMethods
.EvtVariant val, bool ansi) {
System\Diagnostics\Eventing\Reader\ProviderMetadata.cs (51)
105
return (Guid)NativeWrapper.EvtGetPublisherMetadataProperty(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataPublisherGuid);
111
return (string)NativeWrapper.EvtGetPublisherMetadataProperty(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataMessageFilePath);
117
return (string)NativeWrapper.EvtGetPublisherMetadataProperty(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataResourceFilePath);
123
return (string)NativeWrapper.EvtGetPublisherMetadataProperty(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataParameterFilePath);
129
string helpLinkStr = (string)NativeWrapper.EvtGetPublisherMetadataProperty(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataHelpLink);
138
return (uint)NativeWrapper.EvtGetPublisherMetadataProperty(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataPublisherMessageID);
171
elHandle = NativeWrapper.EvtGetPublisherMetadataPropertyHandle(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataChannelReferences);
180
string channelName = (string)NativeWrapper.EvtGetObjectArrayProperty(elHandle, index, (int)
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataChannelReferencePath);
182
uint channelId = (uint)NativeWrapper.EvtGetObjectArrayProperty(elHandle, index, (int)
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataChannelReferenceID);
184
uint flag = (uint)NativeWrapper.EvtGetObjectArrayProperty(elHandle, index, (int)
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataChannelReferenceFlags);
187
if (flag == (int)
UnsafeNativeMethods
.EvtChannelReferenceFlags.EvtChannelReferenceImported) isImported = true;
190
int channelRefMessageId = (int)((uint)NativeWrapper.EvtGetObjectArrayProperty(elHandle, index, (int)
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataChannelReferenceMessageID));
246
this.standardLevels = (List<EventLevel>)GetProviderListProperty(this.defaultProviderHandle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataLevels);
256
this.standardOpcodes = (List<EventOpcode>)GetProviderListProperty(this.defaultProviderHandle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataOpcodes);
266
this.standardKeywords = (List<EventKeyword>)GetProviderListProperty(this.defaultProviderHandle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataKeywords);
276
this.standardTasks = (List<EventTask>)GetProviderListProperty(this.defaultProviderHandle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTasks);
285
internal object GetProviderListProperty(EventLogHandle providerHandle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId metadataProperty) {
292
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId propName;
293
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId propValue;
294
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId propMessageId;
307
case
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataLevels:
308
propName =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataLevelName;
309
propValue =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataLevelValue;
310
propMessageId =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataLevelMessageID;
315
case
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataOpcodes:
316
propName =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataOpcodeName;
317
propValue =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataOpcodeValue;
318
propMessageId =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataOpcodeMessageID;
323
case
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataKeywords:
324
propName =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataKeywordName;
325
propValue =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataKeywordValue;
326
propMessageId =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataKeywordMessageID;
331
case
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTasks:
332
propName =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTaskName;
333
propValue =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTaskValue;
334
propMessageId =
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTaskMessageID;
403
Guid taskGuid = (Guid)NativeWrapper.EvtGetObjectArrayProperty(elHandle, index, (int)
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTaskEventGuid);
436
el = (List<EventLevel>)this.GetProviderListProperty( this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataLevels);
451
eo = (List<EventOpcode>)this.GetProviderListProperty(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataOpcodes);
465
ek = (List<EventKeyword>)this.GetProviderListProperty(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataKeywords);
480
et = (List<EventTask>)this.GetProviderListProperty(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTasks);
504
uint emId = (uint)NativeWrapper.EvtGetEventMetadataProperty(emHandle,
UnsafeNativeMethods
.EvtEventMetadataPropertyId.EventMetadataEventID);
506
byte emVersion = (byte)((uint)(NativeWrapper.EvtGetEventMetadataProperty(emHandle,
UnsafeNativeMethods
.EvtEventMetadataPropertyId.EventMetadataEventVersion)));
508
byte emChannelId = (byte)((uint)NativeWrapper.EvtGetEventMetadataProperty(emHandle,
UnsafeNativeMethods
.EvtEventMetadataPropertyId.EventMetadataEventChannel));
510
byte emLevel = (byte)((uint)NativeWrapper.EvtGetEventMetadataProperty(emHandle,
UnsafeNativeMethods
.EvtEventMetadataPropertyId.EventMetadataEventLevel));
512
byte emOpcode = (byte)((uint)NativeWrapper.EvtGetEventMetadataProperty(emHandle,
UnsafeNativeMethods
.EvtEventMetadataPropertyId.EventMetadataEventOpcode));
514
short emTask = (short)((uint)NativeWrapper.EvtGetEventMetadataProperty(emHandle,
UnsafeNativeMethods
.EvtEventMetadataPropertyId.EventMetadataEventTask));
516
long emKeywords = (long)(ulong)NativeWrapper.EvtGetEventMetadataProperty(emHandle,
UnsafeNativeMethods
.EvtEventMetadataPropertyId.EventMetadataEventKeyword);
518
string emTemplate = (string)NativeWrapper.EvtGetEventMetadataProperty(emHandle,
UnsafeNativeMethods
.EvtEventMetadataPropertyId.EventMetadataEventTemplate);
520
int messageId = (int)((uint)NativeWrapper.EvtGetEventMetadataProperty(emHandle,
UnsafeNativeMethods
.EvtEventMetadataPropertyId.EventMetadataEventMessageID));
542
this.GetProviderListProperty(this.handle,
UnsafeNativeMethods
.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTasks);
System\Diagnostics\Eventing\Reader\ProviderMetadataCachedInformation.cs (5)
209
return NativeWrapper.EvtFormatMessageRenderName(pm.Handle, eventHandle,
UnsafeNativeMethods
.EvtFormatMessageFlags.EvtFormatMessageEvent);
237
return NativeWrapper.EvtFormatMessageRenderName(pm.Handle, eventHandle,
UnsafeNativeMethods
.EvtFormatMessageFlags.EvtFormatMessageLevel);
247
return NativeWrapper.EvtFormatMessageRenderName(pm.Handle, eventHandle,
UnsafeNativeMethods
.EvtFormatMessageFlags.EvtFormatMessageOpcode);
257
return NativeWrapper.EvtFormatMessageRenderName(pm.Handle, eventHandle,
UnsafeNativeMethods
.EvtFormatMessageFlags.EvtFormatMessageTask);
267
return NativeWrapper.EvtFormatMessageRenderKeywords(pm.Handle, eventHandle,
UnsafeNativeMethods
.EvtFormatMessageFlags.EvtFormatMessageKeyword);
System\Diagnostics\PerformanceData\CounterSet.cs (12)
194
uint Status = (uint)
UnsafeNativeMethods
.ERROR_SUCCESS;
197
uint CounterSetInfoSize = (uint) sizeof(
UnsafeNativeMethods
.PerfCounterSetInfoStruct)
198
+ (uint) m_idToCounter.Count * (uint) sizeof(
UnsafeNativeMethods
.PerfCounterInfoStruct);
206
UnsafeNativeMethods
.PerfCounterSetInfoStruct * CounterSetInfo;
207
UnsafeNativeMethods
.PerfCounterInfoStruct * CounterInfo;
212
CounterSetInfo = (
UnsafeNativeMethods
.PerfCounterSetInfoStruct *) CounterSetBuffer;
219
CounterSetInfoUsed = (uint)sizeof(
UnsafeNativeMethods
.PerfCounterSetInfoStruct)
220
+ (uint)CurrentCounter * (uint)sizeof(
UnsafeNativeMethods
.PerfCounterInfoStruct);
222
CounterInfo = (
UnsafeNativeMethods
.PerfCounterInfoStruct *) (CounterSetBuffer + CounterSetInfoUsed);
235
Status =
UnsafeNativeMethods
.PerfSetCounterSetInfo(m_provider.m_hProvider, CounterSetInfo, CounterSetInfoSize);
237
if (Status != (uint)
UnsafeNativeMethods
.ERROR_SUCCESS) {
239
case (uint)
UnsafeNativeMethods
.ERROR_ALREADY_EXISTS:
System\Diagnostics\PerformanceData\CounterSetInstance.cs (7)
27
unsafe internal
UnsafeNativeMethods
.PerfCounterSetInstanceStruct * m_nativeInst;
45
m_nativeInst =
UnsafeNativeMethods
.PerfCreateInstance(
47
int Status = (int) ((m_nativeInst != null) ?
UnsafeNativeMethods
.ERROR_SUCCESS : Marshal.GetLastWin32Error());
58
case (int)
UnsafeNativeMethods
.ERROR_ALREADY_EXISTS:
61
case (int)
UnsafeNativeMethods
.ERROR_NOT_FOUND:
64
case (int)
UnsafeNativeMethods
.ERROR_INVALID_PARAMETER:
104
uint Status =
UnsafeNativeMethods
.PerfDeleteInstance(m_counterSet.m_provider.m_hProvider, m_nativeInst);
System\Diagnostics\PerformanceData\CounterSetInstanceCounterDataSet.cs (3)
139
uint Status =
UnsafeNativeMethods
.PerfSetCounterRefValue(
144
if (Status != (uint)
UnsafeNativeMethods
.ERROR_SUCCESS) {
149
case (uint)
UnsafeNativeMethods
.ERROR_NOT_FOUND:
System\Diagnostics\PerformanceData\PerfProviderCollection.cs (2)
27
uint Status =
UnsafeNativeMethods
.PerfStartProvider(ref m_providerGuid, null, out m_hProvider);
29
if (Status != (uint)
UnsafeNativeMethods
.ERROR_SUCCESS) {
System\IO\__Error.cs (21)
25
using UnsafeNativeMethods = Microsoft.Win32.
UnsafeNativeMethods
;
151
bool isInvalidPath = errorCode ==
UnsafeNativeMethods
.ERROR_INVALID_NAME || errorCode ==
UnsafeNativeMethods
.ERROR_BAD_PATHNAME;
155
case
UnsafeNativeMethods
.ERROR_FILE_NOT_FOUND:
163
case
UnsafeNativeMethods
.ERROR_PATH_NOT_FOUND:
171
case
UnsafeNativeMethods
.ERROR_ACCESS_DENIED:
179
case
UnsafeNativeMethods
.ERROR_ALREADY_EXISTS:
183
throw new IOException(SR.GetString(SR.IO_IO_AlreadyExists_Name, str),
UnsafeNativeMethods
.MakeHRFromErrorCode(errorCode));
185
case
UnsafeNativeMethods
.ERROR_FILENAME_EXCED_RANGE:
188
case
UnsafeNativeMethods
.ERROR_INVALID_DRIVE:
191
case
UnsafeNativeMethods
.ERROR_INVALID_PARAMETER:
192
throw new IOException(
UnsafeNativeMethods
.GetMessage(errorCode),
UnsafeNativeMethods
.MakeHRFromErrorCode(errorCode));
194
case
UnsafeNativeMethods
.ERROR_SHARING_VIOLATION:
196
throw new IOException(SR.GetString(SR.IO_IO_SharingViolation_NoFileName),
UnsafeNativeMethods
.MakeHRFromErrorCode(errorCode));
199
throw new IOException(SR.GetString(SR.IO_IO_SharingViolation_File, str),
UnsafeNativeMethods
.MakeHRFromErrorCode(errorCode));
202
case
UnsafeNativeMethods
.ERROR_FILE_EXISTS:
206
throw new IOException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.IO_IO_FileExists_Name), str),
UnsafeNativeMethods
.MakeHRFromErrorCode(errorCode));
208
case
UnsafeNativeMethods
.ERROR_OPERATION_ABORTED:
212
throw new IOException(
UnsafeNativeMethods
.GetMessage(errorCode),
UnsafeNativeMethods
.MakeHRFromErrorCode(errorCode));
System\IO\LogStream.cs (22)
59
UnsafeNativeMethods
.SECURITY_ATTRIBUTES _secAttrsSav;
87
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(FileShare.Read);
92
int flagsAndAttributes = (int)FileOptions.None | (
UnsafeNativeMethods
.SECURITY_SQOS_PRESENT |
UnsafeNativeMethods
.SECURITY_ANONYMOUS);
100
_fAccessSav =
UnsafeNativeMethods
.GENERIC_WRITE;
117
internal void _Init(String path, int fAccess, FileShare share,
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs, FileIOPermissionAccess secAccess,
126
int oldMode =
UnsafeNativeMethods
.SetErrorMode(
UnsafeNativeMethods
.SEM_FAILCRITICALERRORS);
128
_handle =
UnsafeNativeMethods
.SafeCreateFile(filePath, fAccess, share, secAttrs, mode, flagsAndAttributes,
UnsafeNativeMethods
.NULL);
158
UnsafeNativeMethods
.SetErrorMode(oldMode);
160
Debug.Assert(
UnsafeNativeMethods
.GetFileType(_handle) ==
UnsafeNativeMethods
.FILE_TYPE_DISK, "did someone accidentally removed the device type check from SafeCreateFile P/Invoke wrapper?");
226
if (hr ==
UnsafeNativeMethods
.ERROR_NO_DATA) {
234
if (hr ==
UnsafeNativeMethods
.ERROR_INVALID_PARAMETER)
277
r =
UnsafeNativeMethods
.WriteFile(_handle, p + offset, count, out numBytesWritten, overlapped);
290
if (hr ==
UnsafeNativeMethods
.ERROR_INVALID_HANDLE)
311
ret =
UnsafeNativeMethods
.SetFilePointer(_handle, offset, origin, out hr);
316
if (hr ==
UnsafeNativeMethods
.ERROR_INVALID_HANDLE)
455
private static
UnsafeNativeMethods
.SECURITY_ATTRIBUTES GetSecAttrs(FileShare share)
457
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = null;
459
secAttrs = new
UnsafeNativeMethods
.SECURITY_ATTRIBUTES();
System\IO\MemoryMappedFiles\MemoryMappedFile.cs (31)
387
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(inheritability, memoryMappedFileSecurity, out pinningHandle);
395
handle =
UnsafeNativeMethods
.CreateFileMapping(fileHandle, secAttrs, GetPageAccess(access) | (int)options,
399
if (!handle.IsInvalid && errorCode ==
UnsafeNativeMethods
.ERROR_ALREADY_EXISTS) {
423
SafeMemoryMappedFileHandle handle =
UnsafeNativeMethods
.OpenFileMapping(desiredAccessRights,
428
if (createOrOpen && (lastError ==
UnsafeNativeMethods
.ERROR_FILE_NOT_FOUND)) {
464
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(inheritability, memoryMappedFileSecurity, out pinningHandle);
479
handle =
UnsafeNativeMethods
.CreateFileMapping(fileHandle, secAttrs,
487
if (createErrorCode !=
UnsafeNativeMethods
.ERROR_ACCESS_DENIED) {
497
handle =
UnsafeNativeMethods
.OpenFileMapping(GetFileMapAccess(access), (inheritability &
509
if (openErrorCode !=
UnsafeNativeMethods
.ERROR_FILE_NOT_FOUND) {
660
UnsafeNativeMethods
.SYSTEM_INFO info = new
UnsafeNativeMethods
.SYSTEM_INFO();
661
UnsafeNativeMethods
.GetSystemInfo(ref info);
672
return
UnsafeNativeMethods
.PAGE_READONLY;
675
return
UnsafeNativeMethods
.PAGE_READWRITE;
678
return
UnsafeNativeMethods
.PAGE_WRITECOPY;
681
return
UnsafeNativeMethods
.PAGE_EXECUTE_READ;
684
return
UnsafeNativeMethods
.PAGE_EXECUTE_READWRITE;
696
return
UnsafeNativeMethods
.FILE_MAP_READ;
699
return
UnsafeNativeMethods
.FILE_MAP_WRITE;
702
return
UnsafeNativeMethods
.FILE_MAP_READ |
UnsafeNativeMethods
.FILE_MAP_WRITE;
705
return
UnsafeNativeMethods
.FILE_MAP_COPY;
708
return
UnsafeNativeMethods
.FILE_MAP_EXECUTE |
UnsafeNativeMethods
.FILE_MAP_READ;
711
return
UnsafeNativeMethods
.FILE_MAP_EXECUTE |
UnsafeNativeMethods
.FILE_MAP_READ |
712
UnsafeNativeMethods
.FILE_MAP_WRITE;
776
private unsafe static
UnsafeNativeMethods
.SECURITY_ATTRIBUTES GetSecAttrs(HandleInheritability inheritability,
780
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = null;
783
secAttrs = new
UnsafeNativeMethods
.SECURITY_ATTRIBUTES();
System\IO\MemoryMappedFiles\MemoryMappedView.cs (16)
104
UnsafeNativeMethods
.MEMORYSTATUSEX memStatus = new
UnsafeNativeMethods
.MEMORYSTATUSEX();
105
bool result =
UnsafeNativeMethods
.GlobalMemoryStatusEx(ref memStatus);
116
SafeMemoryMappedViewHandle viewHandle =
UnsafeNativeMethods
.MapViewOfFile(memMappedFileHandle,
123
UnsafeNativeMethods
.MEMORY_BASIC_INFORMATION viewInfo = new
UnsafeNativeMethods
.MEMORY_BASIC_INFORMATION();
124
UnsafeNativeMethods
.VirtualQuery(viewHandle, ref viewInfo, (IntPtr)Marshal.SizeOf(viewInfo));
138
if (((viewInfo.State &
UnsafeNativeMethods
.MEM_RESERVE) != 0) || (viewSize < nativeSize)) {
140
IntPtr tempHandle =
UnsafeNativeMethods
.VirtualAlloc(viewHandle, (UIntPtr)allocSize,
UnsafeNativeMethods
.MEM_COMMIT,
151
viewInfo = new
UnsafeNativeMethods
.MEMORY_BASIC_INFORMATION();
152
UnsafeNativeMethods
.VirtualQuery(viewHandle, ref viewInfo, (IntPtr)Marshal.SizeOf(viewInfo));
186
bool success =
UnsafeNativeMethods
.FlushViewOfFile(firstPagePtr, capacity);
199
bool canRetry = (!success && error ==
UnsafeNativeMethods
.ERROR_LOCK_VIOLATION);
208
success =
UnsafeNativeMethods
.FlushViewOfFile(firstPagePtr, capacity);
215
canRetry = (error ==
UnsafeNativeMethods
.ERROR_LOCK_VIOLATION);
System\IO\Pipes\IOCancellationHelper.cs (2)
11
using UnsafeNativeMethods = Microsoft.Win32.
UnsafeNativeMethods
;
87
if (!
UnsafeNativeMethods
.CancelIoEx(handle, overlapped))
System\IO\Pipes\Pipe.cs (64)
74
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = PipeStream.GetSecAttrs(inheritability);
92
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = PipeStream.GetSecAttrs(inheritability, pipeSecurity, out pinningHandle);
131
if (
UnsafeNativeMethods
.GetFileType(serverSafePipeHandle) !=
UnsafeNativeMethods
.FILE_TYPE_PIPE) {
134
if (
UnsafeNativeMethods
.GetFileType(clientSafePipeHandle) !=
UnsafeNativeMethods
.FILE_TYPE_PIPE) {
195
private void Create(PipeDirection direction,
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs, int bufferSize) {
205
bSuccess =
UnsafeNativeMethods
.CreatePipe(out serverHandle, out m_clientHandle, secAttrs, bufferSize);
208
bSuccess =
UnsafeNativeMethods
.CreatePipe(out m_clientHandle, out serverHandle, secAttrs, bufferSize);
219
bSuccess =
UnsafeNativeMethods
.DuplicateHandle(
UnsafeNativeMethods
.GetCurrentProcess(), serverHandle,
UnsafeNativeMethods
.GetCurrentProcess(),
220
out newServerHandle, 0, false,
UnsafeNativeMethods
.DUPLICATE_SAME_ACCESS);
325
if (
UnsafeNativeMethods
.GetFileType(safePipeHandle) !=
UnsafeNativeMethods
.FILE_TYPE_PIPE) {
515
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = PipeStream.GetSecAttrs(inheritability, pipeSecurity, out pinningHandle);
542
if (
UnsafeNativeMethods
.GetFileType(safePipeHandle) !=
UnsafeNativeMethods
.FILE_TYPE_PIPE) {
560
PipeAccessRights rights,
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs) {
569
(maxNumberOfServerInstances == 1 ?
UnsafeNativeMethods
.FILE_FLAG_FIRST_PIPE_INSTANCE : 0) |
581
SafePipeHandle handle =
UnsafeNativeMethods
.CreateNamedPipe(fullPipeName, openMode, pipeModes,
606
if (!
UnsafeNativeMethods
.ConnectNamedPipe(InternalHandle,
UnsafeNativeMethods
.NULL)) {
609
if (errorCode !=
UnsafeNativeMethods
.ERROR_PIPE_CONNECTED) {
614
if (errorCode ==
UnsafeNativeMethods
.ERROR_PIPE_CONNECTED && State == PipeState.Connected) {
676
if (!
UnsafeNativeMethods
.ConnectNamedPipe(InternalHandle, intOverlapped)) {
679
if (errorCode ==
UnsafeNativeMethods
.ERROR_IO_PENDING) {
692
if (errorCode ==
UnsafeNativeMethods
.ERROR_PIPE_CONNECTED) {
764
if (afsar._errorCode ==
UnsafeNativeMethods
.ERROR_OPERATION_ABORTED) {
781
if (!
UnsafeNativeMethods
.DisconnectNamedPipe(InternalHandle)) {
820
if (
UnsafeNativeMethods
.ImpersonateNamedPipeClient(execHelper.m_handle)) {
840
if (!
UnsafeNativeMethods
.RevertToSelf()) {
869
StringBuilder userName = new StringBuilder(
UnsafeNativeMethods
.CREDUI_MAX_USERNAME_LENGTH + 1);
871
if (!
UnsafeNativeMethods
.GetNamedPipeHandleState(InternalHandle,
UnsafeNativeMethods
.NULL,
UnsafeNativeMethods
.NULL,
872
UnsafeNativeMethods
.NULL,
UnsafeNativeMethods
.NULL, userName, userName.Capacity)) {
894
if (errorCode ==
UnsafeNativeMethods
.ERROR_PIPE_CONNECTED) {
1056
m_access |=
UnsafeNativeMethods
.GENERIC_READ;
1059
m_access |=
UnsafeNativeMethods
.GENERIC_WRITE;
1139
if (
UnsafeNativeMethods
.GetFileType(safePipeHandle) !=
UnsafeNativeMethods
.FILE_TYPE_PIPE) {
1170
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = PipeStream.GetSecAttrs(m_inheritability);
1174
_pipeFlags |=
UnsafeNativeMethods
.SECURITY_SQOS_PRESENT;
1188
if (!
UnsafeNativeMethods
.WaitNamedPipe(m_normalizedPipePath, timeout - elapsed)) {
1192
if (errorCode ==
UnsafeNativeMethods
.ERROR_FILE_NOT_FOUND) {
1198
if (errorCode ==
UnsafeNativeMethods
.ERROR_SUCCESS) {
1206
SafePipeHandle handle =
UnsafeNativeMethods
.CreateNamedPipeClient(m_normalizedPipePath,
1212
UnsafeNativeMethods
.NULL); // template file: null
1219
if (errorCode ==
UnsafeNativeMethods
.ERROR_PIPE_BUSY) {
1276
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = PipeStream.GetSecAttrs(m_inheritability);
1280
_pipeFlags |=
UnsafeNativeMethods
.SECURITY_SQOS_PRESENT;
1305
if (!
UnsafeNativeMethods
.WaitNamedPipe(m_normalizedPipePath, waitTime)) {
1309
if (errorCode ==
UnsafeNativeMethods
.ERROR_FILE_NOT_FOUND) {
1315
if (errorCode ==
UnsafeNativeMethods
.ERROR_SUCCESS) {
1331
SafePipeHandle handle =
UnsafeNativeMethods
.CreateNamedPipeClient(m_normalizedPipePath,
1337
UnsafeNativeMethods
.NULL); // template file: null
1344
if (errorCode ==
UnsafeNativeMethods
.ERROR_PIPE_BUSY) {
1377
if (!
UnsafeNativeMethods
.GetNamedPipeHandleState(InternalHandle,
UnsafeNativeMethods
.NULL, out numInstances,
1378
UnsafeNativeMethods
.NULL,
UnsafeNativeMethods
.NULL,
UnsafeNativeMethods
.NULL, 0)) {
System\IO\Pipes\PipeStream.cs (51)
221
if (hr ==
UnsafeNativeMethods
.ERROR_BROKEN_PIPE ||
222
hr ==
UnsafeNativeMethods
.ERROR_PIPE_NOT_CONNECTED) {
230
m_isMessageComplete = (hr !=
UnsafeNativeMethods
.ERROR_MORE_DATA);
338
if (hr ==
UnsafeNativeMethods
.ERROR_BROKEN_PIPE ||
339
hr ==
UnsafeNativeMethods
.ERROR_PIPE_NOT_CONNECTED) {
350
else if (hr !=
UnsafeNativeMethods
.ERROR_IO_PENDING) {
552
if (hr !=
UnsafeNativeMethods
.ERROR_IO_PENDING) {
640
r =
UnsafeNativeMethods
.ReadFile(handle, p + offset, count, IntPtr.Zero, overlapped);
643
r =
UnsafeNativeMethods
.ReadFile(handle, p + offset, count, out numBytesRead, IntPtr.Zero);
655
if (hr ==
UnsafeNativeMethods
.ERROR_MORE_DATA) {
690
r =
UnsafeNativeMethods
.WriteFile(handle, p + offset, count, IntPtr.Zero, overlapped);
693
r =
UnsafeNativeMethods
.WriteFile(handle, p + offset, count, out numBytesWritten, IntPtr.Zero);
759
if (!
UnsafeNativeMethods
.FlushFileBuffers(m_handle)) {
841
if (!
UnsafeNativeMethods
.GetNamedPipeInfo(m_handle, out pipeFlags,
UnsafeNativeMethods
.NULL,
UnsafeNativeMethods
.NULL,
842
UnsafeNativeMethods
.NULL)) {
845
if ((pipeFlags &
UnsafeNativeMethods
.PIPE_TYPE_MESSAGE) != 0) {
870
if (!
UnsafeNativeMethods
.GetNamedPipeInfo(m_handle,
UnsafeNativeMethods
.NULL,
UnsafeNativeMethods
.NULL, out inBufferSize,
UnsafeNativeMethods
.NULL)) {
897
else if (!
UnsafeNativeMethods
.GetNamedPipeInfo(m_handle,
UnsafeNativeMethods
.NULL, out outBufferSize,
898
UnsafeNativeMethods
.NULL,
UnsafeNativeMethods
.NULL)) {
930
if (!
UnsafeNativeMethods
.SetNamedPipeHandleState(m_handle, &pipeReadType,
UnsafeNativeMethods
.NULL,
UnsafeNativeMethods
.NULL)) {
946
if (!
UnsafeNativeMethods
.GetNamedPipeHandleState(SafePipeHandle, out flags,
UnsafeNativeMethods
.NULL,
UnsafeNativeMethods
.NULL,
947
UnsafeNativeMethods
.NULL,
UnsafeNativeMethods
.NULL, 0)) {
951
if ((flags &
UnsafeNativeMethods
.PIPE_READMODE_MESSAGE) != 0) {
1145
if (errorCode ==
UnsafeNativeMethods
.ERROR_BROKEN_PIPE ||
1146
errorCode ==
UnsafeNativeMethods
.ERROR_PIPE_NOT_CONNECTED ||
1147
errorCode ==
UnsafeNativeMethods
.ERROR_NO_DATA
1151
throw new IOException(SR.GetString(SR.IO_IO_PipeBroken),
UnsafeNativeMethods
.MakeHRFromErrorCode(errorCode));
1154
else if (errorCode ==
UnsafeNativeMethods
.ERROR_HANDLE_EOF) {
1161
if (errorCode ==
UnsafeNativeMethods
.ERROR_INVALID_HANDLE) {
1182
internal unsafe static
UnsafeNativeMethods
.SECURITY_ATTRIBUTES GetSecAttrs(HandleInheritability inheritability, PipeSecurity pipeSecurity, out Object pinningHandle) {
1184
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = null;
1186
secAttrs = new
UnsafeNativeMethods
.SECURITY_ATTRIBUTES();
1206
internal static
UnsafeNativeMethods
.SECURITY_ATTRIBUTES GetSecAttrs(HandleInheritability inheritability) {
1207
UnsafeNativeMethods
.SECURITY_ATTRIBUTES secAttrs = null;
1209
secAttrs = new
UnsafeNativeMethods
.SECURITY_ATTRIBUTES();
1231
if (errorCode ==
UnsafeNativeMethods
.ERROR_BROKEN_PIPE ||
1232
errorCode ==
UnsafeNativeMethods
.ERROR_PIPE_NOT_CONNECTED ||
1233
errorCode ==
UnsafeNativeMethods
.ERROR_NO_DATA) {
1241
if (errorCode ==
UnsafeNativeMethods
.ERROR_MORE_DATA) {
System\Security\Cryptography\BCryptNative.cs (1)
466
using (SafeLibraryHandle bcrypt = Microsoft.Win32.
UnsafeNativeMethods
.LoadLibraryEx("bcrypt", IntPtr.Zero, 0)) {
System\Security\Cryptography\NCryptNative.cs (1)
925
using (SafeLibraryHandle ncrypt = Microsoft.Win32.
UnsafeNativeMethods
.LoadLibraryEx("ncrypt", IntPtr.Zero, 0)) {