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
- DataGridClipboardCellContent.cs
- SyndicationContent.cs
- Type.cs
- XmlTextReaderImplHelpers.cs
- ListChunk.cs
- graph.cs
- CodeDelegateInvokeExpression.cs
- PassportAuthentication.cs
- XamlPointCollectionSerializer.cs
- ProcessInputEventArgs.cs
- ColorContextHelper.cs
- TypeInformation.cs
- BinaryReader.cs
- SqlDataSourceView.cs
- ObjectStateFormatter.cs
- IntegerValidator.cs
- IteratorFilter.cs
- ConnectorSelectionGlyph.cs
- PositiveTimeSpanValidator.cs
- DataGridViewRowEventArgs.cs
- UnsafeNativeMethods.cs
- Transform3DCollection.cs
- FileCodeGroup.cs
- XmlTypeAttribute.cs
- Part.cs
- WebPartManagerInternals.cs
- NotifyIcon.cs
- PropertyFilterAttribute.cs
- ServiceManager.cs
- CellRelation.cs
- ObjectStateManager.cs
- Zone.cs
- AliasedSlot.cs
- SQLSingleStorage.cs
- Command.cs
- XmlObjectSerializerReadContextComplexJson.cs
- BooleanKeyFrameCollection.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- RelationshipSet.cs
- printdlgexmarshaler.cs
- SplitterEvent.cs
- FileUtil.cs
- DecoratedNameAttribute.cs
- SpnEndpointIdentityExtension.cs
- PatternMatcher.cs
- AxisAngleRotation3D.cs
- BaseConfigurationRecord.cs
- CommandID.cs
- DescendentsWalkerBase.cs
- ClientSettingsProvider.cs
- TextBox.cs
- GridPatternIdentifiers.cs
- XPathDocumentIterator.cs
- TextBoxDesigner.cs
- FontUnitConverter.cs
- ManagedCodeMarkers.cs
- LayoutSettings.cs
- AbstractExpressions.cs
- EntityDataSourceWrapperCollection.cs
- ExpressionNormalizer.cs
- OutputScope.cs
- ExpressionContext.cs
- EventsTab.cs
- TextRangeAdaptor.cs
- PreservationFileWriter.cs
- TableMethodGenerator.cs
- AppSettingsReader.cs
- TypefaceMap.cs
- InheritanceAttribute.cs
- HttpWebRequestElement.cs
- Table.cs
- XmlWellformedWriter.cs
- Mouse.cs
- InstanceCreationEditor.cs
- ColumnReorderedEventArgs.cs
- CalendarAutomationPeer.cs
- PropertyKey.cs
- DefaultValueConverter.cs
- BuildResultCache.cs
- ButtonBaseAdapter.cs
- DataGridViewRowStateChangedEventArgs.cs
- MatrixCamera.cs
- UrlMappingsSection.cs
- UserPreferenceChangedEventArgs.cs
- RuntimeConfigLKG.cs
- CompositeActivityTypeDescriptor.cs
- SatelliteContractVersionAttribute.cs
- SectionVisual.cs
- AuthenticationModuleElement.cs
- safemediahandle.cs
- OutputScopeManager.cs
- WebControlAdapter.cs
- AppSecurityManager.cs
- SelectorItemAutomationPeer.cs
- SessionIDManager.cs
- UnsafeNetInfoNativeMethods.cs
- LiteralControl.cs
- HwndTarget.cs
- AddInServer.cs
- UpdateException.cs