Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PieceDirectory.cs
- ScrollableControl.cs
- StylusCaptureWithinProperty.cs
- BeginEvent.cs
- AccessedThroughPropertyAttribute.cs
- CdpEqualityComparer.cs
- DataSourceXmlSerializer.cs
- ParallelTimeline.cs
- DateTimeUtil.cs
- DataListItem.cs
- Stroke.cs
- IPEndPoint.cs
- ObjectDataSourceChooseMethodsPanel.cs
- DataServices.cs
- StyleHelper.cs
- DateTimeConstantAttribute.cs
- TemplateControlCodeDomTreeGenerator.cs
- FileRegion.cs
- BaseValidator.cs
- SecureStringHasher.cs
- TypeForwardedToAttribute.cs
- PartialArray.cs
- FreezableCollection.cs
- PropertyEntry.cs
- XmlStreamNodeWriter.cs
- ContentDisposition.cs
- InvalidCastException.cs
- Decoder.cs
- DependencyPropertyKey.cs
- DataObjectAttribute.cs
- LinqDataSourceValidationException.cs
- MessageDecoder.cs
- AppDomainFactory.cs
- WebConfigurationFileMap.cs
- ISAPIApplicationHost.cs
- CapabilitiesAssignment.cs
- GridViewRowEventArgs.cs
- PageDeviceFont.cs
- LocalizableResourceBuilder.cs
- ResourceProviderFactory.cs
- UriSection.cs
- AssemblyAttributesGoHere.cs
- SoapSchemaMember.cs
- ResourceContainer.cs
- GridViewCellAutomationPeer.cs
- ListViewItemEventArgs.cs
- HwndProxyElementProvider.cs
- XsdDuration.cs
- FormatException.cs
- _WinHttpWebProxyDataBuilder.cs
- SmtpAuthenticationManager.cs
- ConfigsHelper.cs
- WebPartPersonalization.cs
- BinaryFormatter.cs
- ConfigurationManagerInternalFactory.cs
- Model3D.cs
- TabletCollection.cs
- XmlSchemaInclude.cs
- SpanIndex.cs
- StateWorkerRequest.cs
- SoapServerMessage.cs
- WebPermission.cs
- Operand.cs
- Attachment.cs
- XmlSchemaAppInfo.cs
- CounterSampleCalculator.cs
- Bidi.cs
- ApplicationContext.cs
- UIElementPropertyUndoUnit.cs
- PageRanges.cs
- SamlSecurityToken.cs
- TextAnchor.cs
- PopupEventArgs.cs
- GrowingArray.cs
- ThicknessKeyFrameCollection.cs
- SrgsElementFactoryCompiler.cs
- VectorCollectionValueSerializer.cs
- QueryableFilterUserControl.cs
- _HeaderInfoTable.cs
- ImportCatalogPart.cs
- ParserHooks.cs
- PropertyEntry.cs
- DefaultClaimSet.cs
- VScrollProperties.cs
- CodeIdentifier.cs
- ListItemsCollectionEditor.cs
- Screen.cs
- BindingOperations.cs
- SafeCryptoHandles.cs
- OdbcConnection.cs
- SHA384CryptoServiceProvider.cs
- HtmlLinkAdapter.cs
- HttpRuntimeSection.cs
- SqlProviderUtilities.cs
- ViewStateModeByIdAttribute.cs
- LocationUpdates.cs
- ProgressBar.cs
- RegisteredHiddenField.cs
- SmiEventSink_Default.cs
- ZipIOLocalFileHeader.cs