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
- dataprotectionpermission.cs
- SafeLibraryHandle.cs
- _ConnectStream.cs
- PrivilegedConfigurationManager.cs
- IsolatedStorageFile.cs
- AssertSection.cs
- LinkButton.cs
- SqlReferenceCollection.cs
- TreeViewImageIndexConverter.cs
- DetailsViewUpdateEventArgs.cs
- RegistrySecurity.cs
- MultiplexingDispatchMessageFormatter.cs
- EventLogPermissionEntry.cs
- TextEditorMouse.cs
- ViewBox.cs
- XMLSyntaxException.cs
- WorkflowCommandExtensionItem.cs
- TrustLevel.cs
- DbReferenceCollection.cs
- RolePrincipal.cs
- CachedFontFace.cs
- XmlSchemaObject.cs
- AsyncResult.cs
- CompensationExtension.cs
- QilChoice.cs
- ImportCatalogPart.cs
- DependencyPropertyKind.cs
- X509CertificateRecipientServiceCredential.cs
- ImageIndexEditor.cs
- RecognizerBase.cs
- ProtectedConfigurationSection.cs
- WebServiceTypeData.cs
- unitconverter.cs
- LassoHelper.cs
- TextRangeAdaptor.cs
- ListView.cs
- XmlMembersMapping.cs
- InstanceKey.cs
- UIHelper.cs
- ValidatorCollection.cs
- VectorCollection.cs
- FontResourceCache.cs
- EntityContainerRelationshipSetEnd.cs
- MSAANativeProvider.cs
- CurrentChangingEventArgs.cs
- UrlPath.cs
- SiteMapNode.cs
- XmlCountingReader.cs
- LinqDataView.cs
- DateTimeValueSerializer.cs
- TreeView.cs
- TransformerTypeCollection.cs
- UpdatePanelTrigger.cs
- oledbmetadatacolumnnames.cs
- TableStyle.cs
- BidPrivateBase.cs
- EntityDataSourceDesigner.cs
- PointCollectionValueSerializer.cs
- SqlAliaser.cs
- Screen.cs
- webbrowsersite.cs
- WebPartConnectionsEventArgs.cs
- HwndKeyboardInputProvider.cs
- SafeHandle.cs
- X509IssuerSerialKeyIdentifierClause.cs
- ParameterInfo.cs
- RegexStringValidator.cs
- ListenDesigner.cs
- ContextMenu.cs
- COM2FontConverter.cs
- QueryParameter.cs
- BackStopAuthenticationModule.cs
- UnitySerializationHolder.cs
- XMLUtil.cs
- EntityDataSourceQueryBuilder.cs
- UIElementParagraph.cs
- EpmSyndicationContentSerializer.cs
- ToolStripGrip.cs
- Double.cs
- DecimalAnimationBase.cs
- CacheDependency.cs
- HandleCollector.cs
- ServerValidateEventArgs.cs
- SimpleModelProvider.cs
- CalendarAutoFormatDialog.cs
- SchemaTableColumn.cs
- FileDialog.cs
- ParameterModifier.cs
- TemplateXamlParser.cs
- AutoFocusStyle.xaml.cs
- fixedPageContentExtractor.cs
- CodeRemoveEventStatement.cs
- DefaultBinder.cs
- HtmlControlAdapter.cs
- Animatable.cs
- EntitySqlQueryBuilder.cs
- FormViewPagerRow.cs
- WSSecurityJan2004.cs
- ClientScriptManagerWrapper.cs
- ListBindingHelper.cs