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
- ListViewDeleteEventArgs.cs
- NameValueFileSectionHandler.cs
- _SSPISessionCache.cs
- BufferedResponseStream.cs
- WinFormsComponentEditor.cs
- XmlSchemaObjectTable.cs
- BrushValueSerializer.cs
- BitmapDownload.cs
- ClickablePoint.cs
- SqlConnectionHelper.cs
- Brush.cs
- TextTreeTextElementNode.cs
- SvcMapFileLoader.cs
- BindingContext.cs
- DataGridViewCellLinkedList.cs
- DataContractSet.cs
- Crypto.cs
- ToolboxItemAttribute.cs
- XmlRawWriter.cs
- SimpleTableProvider.cs
- DefaultValueAttribute.cs
- OleDbSchemaGuid.cs
- OwnerDrawPropertyBag.cs
- GenericRootAutomationPeer.cs
- HttpListenerContext.cs
- ObjectHandle.cs
- CheckBoxField.cs
- ClientScriptManagerWrapper.cs
- HostingEnvironmentException.cs
- HMACSHA512.cs
- ExtensionWindowHeader.cs
- TemplateBindingExpression.cs
- TextProperties.cs
- AttributeUsageAttribute.cs
- RightsManagementEncryptedStream.cs
- CodeTypeReferenceExpression.cs
- SeparatorAutomationPeer.cs
- TrackBarRenderer.cs
- TimeSpanValidator.cs
- SchemaImporterExtension.cs
- JapaneseCalendar.cs
- XmlCDATASection.cs
- TraceContextEventArgs.cs
- Util.cs
- StorageScalarPropertyMapping.cs
- QuaternionValueSerializer.cs
- HTTPNotFoundHandler.cs
- GridViewCancelEditEventArgs.cs
- AttachmentCollection.cs
- TransactionProtocolConverter.cs
- SqlGatherConsumedAliases.cs
- PointLight.cs
- TransportBindingElementImporter.cs
- DataControlField.cs
- ComponentGlyph.cs
- XamlBrushSerializer.cs
- WebPartCancelEventArgs.cs
- OracleDateTime.cs
- DbConnectionPoolGroup.cs
- XmlDeclaration.cs
- ServiceProviders.cs
- DataGridCommandEventArgs.cs
- SafeNativeMethods.cs
- ProcessModelInfo.cs
- iisPickupDirectory.cs
- JsonFaultDetail.cs
- RepeaterItem.cs
- QueryCursorEventArgs.cs
- DrawingContext.cs
- MessageDescriptionCollection.cs
- PanelStyle.cs
- WebControl.cs
- MediaContext.cs
- ClientSponsor.cs
- DataGridPagerStyle.cs
- PtsHost.cs
- CodeEventReferenceExpression.cs
- ComplexType.cs
- ObservableCollection.cs
- SqlNotificationEventArgs.cs
- FragmentNavigationEventArgs.cs
- ProcessRequestAsyncResult.cs
- SendContent.cs
- List.cs
- DebugControllerThread.cs
- AutomationElementCollection.cs
- TranslateTransform3D.cs
- SqlRewriteScalarSubqueries.cs
- StaticFileHandler.cs
- DBParameter.cs
- XmlCollation.cs
- StatusBarPanel.cs
- ResourceDefaultValueAttribute.cs
- OpenTypeLayoutCache.cs
- UIElementParaClient.cs
- XamlSerializerUtil.cs
- XmlSerializer.cs
- UpdateTranslator.cs
- StorageAssociationSetMapping.cs
- DataGridViewColumn.cs