Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SecurityKeyIdentifier.cs
- RuleAttributes.cs
- UserControlParser.cs
- SafeNativeMethodsMilCoreApi.cs
- AttachmentCollection.cs
- ListBox.cs
- TTSEvent.cs
- UInt32Storage.cs
- webproxy.cs
- TextDecorationCollectionConverter.cs
- ToolboxBitmapAttribute.cs
- MDIClient.cs
- SHA1CryptoServiceProvider.cs
- NeutralResourcesLanguageAttribute.cs
- TextTreeUndoUnit.cs
- RootProfilePropertySettingsCollection.cs
- ObjectStateFormatter.cs
- SqlUnionizer.cs
- Comparer.cs
- UIElementParaClient.cs
- NavigationPropertyEmitter.cs
- VirtualDirectoryMappingCollection.cs
- CachedBitmap.cs
- DataGridCellClipboardEventArgs.cs
- PageCache.cs
- HttpAsyncResult.cs
- RemotingServices.cs
- DataContractSerializer.cs
- Registration.cs
- StrokeSerializer.cs
- TemplatedAdorner.cs
- ProcessHost.cs
- BindingFormattingDialog.cs
- SHA256Managed.cs
- CustomCategoryAttribute.cs
- ControlBuilder.cs
- WorkflowMessageEventArgs.cs
- JpegBitmapEncoder.cs
- ScrollPattern.cs
- SystemInfo.cs
- SecurityState.cs
- ButtonStandardAdapter.cs
- DocobjHost.cs
- WrappingXamlSchemaContext.cs
- Int32CAMarshaler.cs
- DataGridViewButtonColumn.cs
- PhoneCall.cs
- ObjectDataSourceDisposingEventArgs.cs
- RelationshipDetailsRow.cs
- HtmlTableCellCollection.cs
- QuestionEventArgs.cs
- ListBindingHelper.cs
- TabPanel.cs
- MessageEncodingBindingElementImporter.cs
- PixelShader.cs
- TrackPoint.cs
- SoapFormatter.cs
- EncoderParameters.cs
- Rotation3DAnimationUsingKeyFrames.cs
- MemoryPressure.cs
- TemplateControlParser.cs
- PersistenceTypeAttribute.cs
- FixedPosition.cs
- OperationAbortedException.cs
- ClientScriptManager.cs
- basevalidator.cs
- WindowsIPAddress.cs
- DataBindingHandlerAttribute.cs
- LinkConverter.cs
- RuntimeIdentifierPropertyAttribute.cs
- GPRECT.cs
- IisTraceWebEventProvider.cs
- JoinCqlBlock.cs
- WsatConfiguration.cs
- AspProxy.cs
- PropertyPath.cs
- BuildProviderCollection.cs
- XmlSchemaAnnotated.cs
- TimeZoneNotFoundException.cs
- VersionedStreamOwner.cs
- ExpressionHelper.cs
- SqlReferenceCollection.cs
- ItemCheckEvent.cs
- TraceProvider.cs
- DataGridViewSelectedRowCollection.cs
- XmlSerializer.cs
- DataSetFieldSchema.cs
- DateTimeStorage.cs
- PagerSettings.cs
- DefaultHttpHandler.cs
- EnterpriseServicesHelper.cs
- ComponentManagerBroker.cs
- PaintEvent.cs
- CategoryState.cs
- SmtpLoginAuthenticationModule.cs
- XhtmlBasicSelectionListAdapter.cs
- MsdtcClusterUtils.cs
- EditableTreeList.cs
- ClosableStream.cs
- EmptyControlCollection.cs