Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / SMDiagnostics / System / ServiceModel / Diagnostics / SafeEventLogWriteHandle.cs / 1305376 / SafeEventLogWriteHandle.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Diagnostics { using Microsoft.Win32.SafeHandles; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Globalization; using System.Diagnostics; using System.Security; using System.Runtime; [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] internal static SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName) { SafeEventLogWriteHandle retval = NativeMethods.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)] private static extern bool DeregisterEventSource(IntPtr hEventLog); #pragma warning disable 56523 [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] override protected bool ReleaseHandle() { return DeregisterEventSource(this.handle); } #pragma warning restore 56523 } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Diagnostics { using Microsoft.Win32.SafeHandles; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Globalization; using System.Diagnostics; using System.Security; using System.Runtime; [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] internal static SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName) { SafeEventLogWriteHandle retval = NativeMethods.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)] private static extern bool DeregisterEventSource(IntPtr hEventLog); #pragma warning disable 56523 [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] override protected bool ReleaseHandle() { return DeregisterEventSource(this.handle); } #pragma warning restore 56523 } } // 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
- TransformerConfigurationWizardBase.cs
- ImmutableObjectAttribute.cs
- RegexFCD.cs
- COM2PropertyDescriptor.cs
- FileNotFoundException.cs
- WebPartCollection.cs
- HttpHandlerAction.cs
- DataObjectMethodAttribute.cs
- ImageFormat.cs
- SyncOperationState.cs
- FlowDecisionLabelFeature.cs
- DecoderNLS.cs
- ServiceAuthorizationManager.cs
- BooleanAnimationBase.cs
- ConnectionStringsExpressionBuilder.cs
- TripleDES.cs
- Permission.cs
- IgnoreFileBuildProvider.cs
- SchemaNotation.cs
- XmlFormatWriterGenerator.cs
- TextServicesHost.cs
- ProjectionPlan.cs
- MimePart.cs
- WSSecurityPolicy.cs
- diagnosticsswitches.cs
- IfAction.cs
- AnnotationMap.cs
- PolicyReader.cs
- CTreeGenerator.cs
- Brush.cs
- GeometryCombineModeValidation.cs
- XmlHelper.cs
- ConfigXmlWhitespace.cs
- SourceItem.cs
- nulltextnavigator.cs
- LinqDataSourceStatusEventArgs.cs
- ClientBuildManager.cs
- ReadOnlyNameValueCollection.cs
- WebPartConnection.cs
- ListSurrogate.cs
- ScriptingProfileServiceSection.cs
- AnnotationDocumentPaginator.cs
- _NtlmClient.cs
- DynamicMethod.cs
- OdbcConnectionFactory.cs
- CacheDependency.cs
- OpCopier.cs
- Errors.cs
- OleDbFactory.cs
- ChangesetResponse.cs
- ScriptControl.cs
- SafeSecurityHelper.cs
- XmlSchemaAnyAttribute.cs
- ProfileService.cs
- EncoderParameters.cs
- SystemIPv6InterfaceProperties.cs
- Rect3DValueSerializer.cs
- MergeFailedEvent.cs
- CustomError.cs
- DynamicFilterExpression.cs
- LoadRetryHandler.cs
- PersonalizableAttribute.cs
- RegistrySecurity.cs
- Vector.cs
- VectorCollectionValueSerializer.cs
- SqlMethods.cs
- RelOps.cs
- PathParser.cs
- DoubleLinkList.cs
- XmlDownloadManager.cs
- DataSourceView.cs
- DataRow.cs
- ImageField.cs
- ReachUIElementCollectionSerializerAsync.cs
- CodeExpressionStatement.cs
- XdrBuilder.cs
- SuppressIldasmAttribute.cs
- dtdvalidator.cs
- HMACSHA1.cs
- CompositeTypefaceMetrics.cs
- XmlSubtreeReader.cs
- StringValueSerializer.cs
- FileStream.cs
- CapacityStreamGeometryContext.cs
- PropertyEmitter.cs
- DrawingCollection.cs
- NamedElement.cs
- ProtectedConfigurationProviderCollection.cs
- HttpWebRequestElement.cs
- TiffBitmapDecoder.cs
- QuadraticBezierSegment.cs
- AutomationPeer.cs
- FontCacheLogic.cs
- BamlRecordWriter.cs
- AddressingProperty.cs
- ToolStripContentPanel.cs
- TextAutomationPeer.cs
- Timer.cs
- AppPool.cs
- DescendantQuery.cs