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
- CookielessHelper.cs
- MediaElement.cs
- HttpRuntime.cs
- DataListItemCollection.cs
- SqlProfileProvider.cs
- DecimalAnimation.cs
- EventDriven.cs
- SqlTriggerAttribute.cs
- WebPageTraceListener.cs
- UriTemplateMatchException.cs
- TimeIntervalCollection.cs
- AuthenticationSchemesHelper.cs
- ImageClickEventArgs.cs
- PseudoWebRequest.cs
- SqlCaseSimplifier.cs
- EmptyReadOnlyDictionaryInternal.cs
- ProjectionCamera.cs
- Crc32.cs
- CodeAssignStatement.cs
- VisualTarget.cs
- httpserverutility.cs
- HMACMD5.cs
- PeerName.cs
- DataList.cs
- KnowledgeBase.cs
- RtfControlWordInfo.cs
- DelegatedStream.cs
- FunctionImportElement.cs
- WizardPanelChangingEventArgs.cs
- DataSourceCache.cs
- SpoolingTask.cs
- HebrewCalendar.cs
- transactioncontext.cs
- BaseCodePageEncoding.cs
- CustomErrorsSection.cs
- FragmentQueryKB.cs
- GetCardDetailsRequest.cs
- WriteLineDesigner.xaml.cs
- JsonDeserializer.cs
- TargetConverter.cs
- Options.cs
- CallSiteBinder.cs
- CompatibleIComparer.cs
- DirectoryObjectSecurity.cs
- TiffBitmapEncoder.cs
- OracleConnectionString.cs
- UIElement.cs
- GridItemPatternIdentifiers.cs
- SymLanguageVendor.cs
- AppDomainProtocolHandler.cs
- Single.cs
- XPathDescendantIterator.cs
- ApplicationHost.cs
- QuaternionRotation3D.cs
- WSHttpTransportSecurityElement.cs
- WCFBuildProvider.cs
- SqlServer2KCompatibilityAnnotation.cs
- QuaternionConverter.cs
- DataGridViewCellValueEventArgs.cs
- DataObject.cs
- Parameter.cs
- SQLInt64Storage.cs
- XPathDocumentBuilder.cs
- FloaterParagraph.cs
- ToolBarPanel.cs
- entityreference_tresulttype.cs
- formatter.cs
- CodeGenerationManager.cs
- DataGridColumnStyleMappingNameEditor.cs
- OdbcParameter.cs
- TemplateKey.cs
- X509CertificateCollection.cs
- InvalidOleVariantTypeException.cs
- StyleTypedPropertyAttribute.cs
- PrimitiveXmlSerializers.cs
- UserControlBuildProvider.cs
- OverflowException.cs
- ReverseInheritProperty.cs
- WebDisplayNameAttribute.cs
- Bits.cs
- ToolStripPanelCell.cs
- _Connection.cs
- SchemaDeclBase.cs
- LabelEditEvent.cs
- RenameRuleObjectDialog.Designer.cs
- TextPenaltyModule.cs
- MessageEnumerator.cs
- TripleDESCryptoServiceProvider.cs
- FixedDocument.cs
- LinkLabel.cs
- BaseParser.cs
- DigitShape.cs
- DependencyPropertyConverter.cs
- SerializationEventsCache.cs
- CompositeDispatchFormatter.cs
- SemanticResolver.cs
- TraceUtility.cs
- ComplexPropertyEntry.cs
- Wildcard.cs
- NullableDoubleMinMaxAggregationOperator.cs