Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / System.Runtime.DurableInstancing / System / Runtime / Interop / SafeEventLogWriteHandle.cs / 1305376 / SafeEventLogWriteHandle.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Runtime.Interop { using Microsoft.Win32.SafeHandles; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Globalization; using System.Diagnostics; using System.Security; [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] sealed class SafeEventLogWriteHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note: RegisterEventSource returns 0 on failure [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] SafeEventLogWriteHandle() : base(true) { } [ResourceConsumption(ResourceScope.Machine)] [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] public static SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName) { SafeEventLogWriteHandle retval = UnsafeNativeMethods.RegisterEventSource(uncServerName, sourceName); int error = Marshal.GetLastWin32Error(); if (retval.IsInvalid) { Debug.Print("SafeEventLogWriteHandle::RegisterEventSource[" + uncServerName + ", " + sourceName + "] Failed. Last Error: " + error.ToString(CultureInfo.InvariantCulture)); } return retval; } [DllImport("advapi32", SetLastError = true)] [ResourceExposure(ResourceScope.None)] static extern bool DeregisterEventSource(IntPtr hEventLog); [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] protected override bool ReleaseHandle() { return DeregisterEventSource(this.handle); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Runtime.Interop { using Microsoft.Win32.SafeHandles; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Globalization; using System.Diagnostics; using System.Security; [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] sealed class SafeEventLogWriteHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note: RegisterEventSource returns 0 on failure [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] SafeEventLogWriteHandle() : base(true) { } [ResourceConsumption(ResourceScope.Machine)] [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] public static SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName) { SafeEventLogWriteHandle retval = UnsafeNativeMethods.RegisterEventSource(uncServerName, sourceName); int error = Marshal.GetLastWin32Error(); if (retval.IsInvalid) { Debug.Print("SafeEventLogWriteHandle::RegisterEventSource[" + uncServerName + ", " + sourceName + "] Failed. Last Error: " + error.ToString(CultureInfo.InvariantCulture)); } return retval; } [DllImport("advapi32", SetLastError = true)] [ResourceExposure(ResourceScope.None)] static extern bool DeregisterEventSource(IntPtr hEventLog); [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] protected override bool ReleaseHandle() { return DeregisterEventSource(this.handle); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SubtreeProcessor.cs
- ReferentialConstraint.cs
- UnrecognizedPolicyAssertionElement.cs
- UpDownEvent.cs
- InvokeWebServiceDesigner.cs
- TypedRowHandler.cs
- TraceXPathNavigator.cs
- SHA1Managed.cs
- DrawingDrawingContext.cs
- Helpers.cs
- TrackingDataItem.cs
- SoapIncludeAttribute.cs
- TableProviderWrapper.cs
- ChineseLunisolarCalendar.cs
- AnyAllSearchOperator.cs
- FusionWrap.cs
- HtmlHistory.cs
- ElementMarkupObject.cs
- Sql8ConformanceChecker.cs
- DeviceContexts.cs
- ListViewDeleteEventArgs.cs
- EventMappingSettingsCollection.cs
- OdbcConnectionString.cs
- InfoCardX509Validator.cs
- ClassicBorderDecorator.cs
- DescendantQuery.cs
- Decorator.cs
- InOutArgumentConverter.cs
- UnsafeNativeMethodsCLR.cs
- ConfigurationFileMap.cs
- InvokeSchedule.cs
- RoleService.cs
- RemotingAttributes.cs
- DbExpressionRules.cs
- KeyValueConfigurationElement.cs
- IteratorFilter.cs
- DbMetaDataCollectionNames.cs
- SpeakCompletedEventArgs.cs
- AuthenticationService.cs
- GenericIdentity.cs
- StreamGeometry.cs
- WindowsEditBoxRange.cs
- InputLangChangeRequestEvent.cs
- DecoderNLS.cs
- SecurityUtils.cs
- EmptyQuery.cs
- PaginationProgressEventArgs.cs
- DeliveryStrategy.cs
- FrameworkContentElementAutomationPeer.cs
- SqlConnectionHelper.cs
- DataSourceCacheDurationConverter.cs
- CodeAttributeDeclaration.cs
- CodeCommentStatement.cs
- FixUpCollection.cs
- ValueTypePropertyReference.cs
- Baml2006ReaderSettings.cs
- ValueConversionAttribute.cs
- MsmqVerifier.cs
- SmtpReplyReaderFactory.cs
- ExceptionRoutedEventArgs.cs
- XmlObjectSerializerReadContextComplex.cs
- SimpleWebHandlerParser.cs
- FontFaceLayoutInfo.cs
- X509RawDataKeyIdentifierClause.cs
- User.cs
- HostedElements.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- Stacktrace.cs
- ToolStripItem.cs
- StylusPointPropertyInfo.cs
- FileEnumerator.cs
- DelegateTypeInfo.cs
- XmlSchemaType.cs
- RbTree.cs
- path.cs
- BufferModeSettings.cs
- ThicknessAnimationBase.cs
- NamedPipeConnectionPool.cs
- TimersDescriptionAttribute.cs
- Context.cs
- Helper.cs
- GradientBrush.cs
- BufferedReadStream.cs
- ScrollPatternIdentifiers.cs
- HtmlElementEventArgs.cs
- BindingObserver.cs
- XmlSchemaSimpleType.cs
- Models.cs
- ProviderIncompatibleException.cs
- MemoryStream.cs
- printdlgexmarshaler.cs
- HostSecurityManager.cs
- StorageBasedPackageProperties.cs
- CodeNamespaceImportCollection.cs
- DrawingAttributeSerializer.cs
- PropertyChangedEventManager.cs
- BitmapMetadataBlob.cs
- LoadRetryHandler.cs
- _ConnectStream.cs
- BaseDataBoundControl.cs