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