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
- MetadataUtilsSmi.cs
- StylusPointPropertyUnit.cs
- MetadataLocation.cs
- LocatorManager.cs
- ObjectParameterCollection.cs
- UnauthorizedAccessException.cs
- ReflectTypeDescriptionProvider.cs
- ToolStripManager.cs
- IPHostEntry.cs
- Walker.cs
- FilteredDataSetHelper.cs
- PtsHost.cs
- VisualStateGroup.cs
- WindowsListView.cs
- FixedTextView.cs
- ToolBarPanel.cs
- ValidatorCompatibilityHelper.cs
- LinkLabel.cs
- SpecularMaterial.cs
- GridEntry.cs
- _BasicClient.cs
- PerformanceCounterCategory.cs
- DeobfuscatingStream.cs
- OleCmdHelper.cs
- ServiceDescriptionSerializer.cs
- StringTraceRecord.cs
- SspiWrapper.cs
- SubtreeProcessor.cs
- CssTextWriter.cs
- DesignTimeType.cs
- HttpPostProtocolImporter.cs
- ActionFrame.cs
- MembershipValidatePasswordEventArgs.cs
- HttpAsyncResult.cs
- Int32AnimationBase.cs
- ActivationArguments.cs
- WebSysDisplayNameAttribute.cs
- SiteMapSection.cs
- figurelengthconverter.cs
- DynamicRenderer.cs
- listviewsubitemcollectioneditor.cs
- FontDifferentiator.cs
- ScrollableControl.cs
- BroadcastEventHelper.cs
- RetrieveVirtualItemEventArgs.cs
- HtmlTable.cs
- SurrogateSelector.cs
- StaticTextPointer.cs
- TableRow.cs
- UIElementPropertyUndoUnit.cs
- FilterInvalidBodyAccessException.cs
- StateWorkerRequest.cs
- ComponentRenameEvent.cs
- NavigateEvent.cs
- XamlDesignerSerializationManager.cs
- ScrollViewerAutomationPeer.cs
- WrappedReader.cs
- LabelDesigner.cs
- RelativeSource.cs
- SocketManager.cs
- ColorAnimationUsingKeyFrames.cs
- _RequestCacheProtocol.cs
- ScriptReferenceEventArgs.cs
- SHA1Managed.cs
- unsafenativemethodsother.cs
- DataGridViewComboBoxColumnDesigner.cs
- PassportAuthenticationEventArgs.cs
- CaretElement.cs
- IndexerNameAttribute.cs
- XmlCountingReader.cs
- AssociationTypeEmitter.cs
- ProtectedConfigurationProviderCollection.cs
- HMACSHA1.cs
- Span.cs
- NamedPipeConnectionPool.cs
- SchemaEntity.cs
- PropertyConverter.cs
- RemoveStoryboard.cs
- EditorZoneDesigner.cs
- DetailsViewActionList.cs
- PropertyGridDesigner.cs
- MultiBindingExpression.cs
- TableRowCollection.cs
- AnchoredBlock.cs
- RegisterResponseInfo.cs
- ConfigurationSettings.cs
- _TimerThread.cs
- HttpFileCollectionBase.cs
- EdmEntityTypeAttribute.cs
- AudioException.cs
- ValidationErrorCollection.cs
- TrackingConditionCollection.cs
- EventWaitHandle.cs
- StringComparer.cs
- DataGridViewSelectedColumnCollection.cs
- UiaCoreApi.cs
- DecimalStorage.cs
- GeneralTransform3DCollection.cs
- SQLMembershipProvider.cs
- StringStorage.cs