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
- TransformerConfigurationWizardBase.cs
- CapabilitiesUse.cs
- FileCodeGroup.cs
- Deflater.cs
- FlowDocumentFormatter.cs
- WebPartMenu.cs
- ControlAdapter.cs
- ObjectHandle.cs
- DispatcherProcessingDisabled.cs
- SQLMembershipProvider.cs
- MatchingStyle.cs
- ServiceChannelFactory.cs
- AttributeData.cs
- ProcessModuleCollection.cs
- GestureRecognitionResult.cs
- _NestedMultipleAsyncResult.cs
- PageAsyncTask.cs
- NamespaceList.cs
- LineServices.cs
- FixedTextBuilder.cs
- XmlSecureResolver.cs
- AmbientLight.cs
- CompilationUtil.cs
- CodeLinePragma.cs
- UndoEngine.cs
- PageParserFilter.cs
- AutoGeneratedFieldProperties.cs
- MethodMessage.cs
- Event.cs
- SoapHelper.cs
- Partitioner.cs
- WebBrowserNavigatedEventHandler.cs
- DataGridViewImageColumn.cs
- RowsCopiedEventArgs.cs
- AttributeUsageAttribute.cs
- Vector3DValueSerializer.cs
- MetadataProperty.cs
- ConfigXmlElement.cs
- SqlVisitor.cs
- MissingSatelliteAssemblyException.cs
- KeyConverter.cs
- Point.cs
- TextReturnReader.cs
- Model3DCollection.cs
- HtmlCalendarAdapter.cs
- XmlSchemaExporter.cs
- VerticalAlignConverter.cs
- DataGridViewRowsRemovedEventArgs.cs
- Utilities.cs
- counter.cs
- ADMembershipUser.cs
- LineServicesCallbacks.cs
- MediaSystem.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- AnimatedTypeHelpers.cs
- CheckBoxPopupAdapter.cs
- SqlMethodTransformer.cs
- GridViewRowEventArgs.cs
- TransactionFlowBindingElementImporter.cs
- ReachSerializationUtils.cs
- ReadContentAsBinaryHelper.cs
- EntityDataSourceState.cs
- oledbmetadatacollectionnames.cs
- CodeDOMUtility.cs
- Win32SafeHandles.cs
- Matrix3D.cs
- BufferedReadStream.cs
- FileUpload.cs
- DbConnectionPoolGroup.cs
- DataObjectPastingEventArgs.cs
- StyleCollection.cs
- AsyncOperationManager.cs
- SevenBitStream.cs
- CounterSet.cs
- DataGridCaption.cs
- WorkflowApplicationException.cs
- SmtpNtlmAuthenticationModule.cs
- HandlerFactoryCache.cs
- X509CertificateCollection.cs
- CacheModeConverter.cs
- PrimitiveDataContract.cs
- TextMessageEncodingElement.cs
- Rss20ItemFormatter.cs
- Emitter.cs
- NativeCppClassAttribute.cs
- SystemBrushes.cs
- Size.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- ServiceBuildProvider.cs
- SqlDataSourceEnumerator.cs
- SettingsBindableAttribute.cs
- AtomContentProperty.cs
- ImageEditor.cs
- QueryableDataSource.cs
- TdsRecordBufferSetter.cs
- securitycriticaldataClass.cs
- HttpCapabilitiesBase.cs
- RangeContentEnumerator.cs
- SocketInformation.cs
- VerificationAttribute.cs