Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / clr / src / BCL / System / Security / Cryptography / X509Certificates / safex509handles.cs / 1 / safex509handles.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // SafeX509Handles.cs // namespace System.Security.Cryptography.X509Certificates { using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using Microsoft.Win32.SafeHandles; // Since we need sometimes to delete the key container associated with a cert // context, the handle used in this class is actually a pointer // to a CERT_CTX unmanaged structure defined in COMX509Certificate.h internal sealed class SafeCertContextHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeCertContextHandle() : base (true) {} // 0 is an Invalid Handle internal SafeCertContextHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeCertContextHandle InvalidHandle { get { return new SafeCertContextHandle(IntPtr.Zero); } } internal IntPtr pCertContext { get { if (handle == IntPtr.Zero) return IntPtr.Zero; return Marshal.ReadIntPtr(handle); } } // This method handles the case where pCert == NULL [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreePCertContext(IntPtr pCert); override protected bool ReleaseHandle() { _FreePCertContext(handle); return true; } } internal sealed class SafeCertStoreHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeCertStoreHandle() : base (true) {} // 0 is an Invalid Handle internal SafeCertStoreHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeCertStoreHandle InvalidHandle { get { return new SafeCertStoreHandle(IntPtr.Zero); } } // This method handles the case where hCertStore == NULL [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreeCertStoreContext(IntPtr hCertStore); override protected bool ReleaseHandle() { _FreeCertStoreContext(handle); return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // SafeX509Handles.cs // namespace System.Security.Cryptography.X509Certificates { using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using Microsoft.Win32.SafeHandles; // Since we need sometimes to delete the key container associated with a cert // context, the handle used in this class is actually a pointer // to a CERT_CTX unmanaged structure defined in COMX509Certificate.h internal sealed class SafeCertContextHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeCertContextHandle() : base (true) {} // 0 is an Invalid Handle internal SafeCertContextHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeCertContextHandle InvalidHandle { get { return new SafeCertContextHandle(IntPtr.Zero); } } internal IntPtr pCertContext { get { if (handle == IntPtr.Zero) return IntPtr.Zero; return Marshal.ReadIntPtr(handle); } } // This method handles the case where pCert == NULL [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreePCertContext(IntPtr pCert); override protected bool ReleaseHandle() { _FreePCertContext(handle); return true; } } internal sealed class SafeCertStoreHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeCertStoreHandle() : base (true) {} // 0 is an Invalid Handle internal SafeCertStoreHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeCertStoreHandle InvalidHandle { get { return new SafeCertStoreHandle(IntPtr.Zero); } } // This method handles the case where hCertStore == NULL [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreeCertStoreContext(IntPtr hCertStore); override protected bool ReleaseHandle() { _FreeCertStoreContext(handle); return true; } } } // 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
- Image.cs
- EventMap.cs
- Cursor.cs
- AppModelKnownContentFactory.cs
- SvcFileManager.cs
- SqlCacheDependencySection.cs
- WebResourceAttribute.cs
- CompressStream.cs
- DllNotFoundException.cs
- TableLayoutStyle.cs
- ProfileManager.cs
- DataViewSettingCollection.cs
- RequestCachingSection.cs
- TextInfo.cs
- FrameworkPropertyMetadata.cs
- ServiceMetadataContractBehavior.cs
- PreservationFileWriter.cs
- MsmqInputSessionChannel.cs
- XmlNamedNodeMap.cs
- SecurityAlgorithmSuiteConverter.cs
- DataGridLinkButton.cs
- CommonGetThemePartSize.cs
- _NegoStream.cs
- Identity.cs
- WebHttpSecurityElement.cs
- DataGrid.cs
- Msmq4SubqueuePoisonHandler.cs
- Int32CollectionConverter.cs
- GatewayDefinition.cs
- OutputCacheSection.cs
- FillErrorEventArgs.cs
- TableLayoutColumnStyleCollection.cs
- CodeSubDirectoriesCollection.cs
- TextLineResult.cs
- MembershipAdapter.cs
- URLAttribute.cs
- IssuedTokensHeader.cs
- MessageVersionConverter.cs
- ChannelManager.cs
- MSG.cs
- DesignerTextViewAdapter.cs
- XsdBuilder.cs
- ExtenderProvidedPropertyAttribute.cs
- Stylesheet.cs
- PagesSection.cs
- VirtualPathProvider.cs
- ContextMarshalException.cs
- wgx_commands.cs
- entityreference_tresulttype.cs
- SapiInterop.cs
- ClientTargetCollection.cs
- SQLSingle.cs
- SqlCommand.cs
- BuildResult.cs
- InheritanceRules.cs
- XmlSecureResolver.cs
- Variant.cs
- CodeDomSerializerException.cs
- SessionParameter.cs
- EntitySetRetriever.cs
- TabControlEvent.cs
- DivideByZeroException.cs
- PropertyEmitter.cs
- ProviderUtil.cs
- ScrollableControl.cs
- FixedLineResult.cs
- ToolStripItemBehavior.cs
- ModuleElement.cs
- SynchronizationValidator.cs
- ClientTarget.cs
- GridViewCancelEditEventArgs.cs
- MenuItem.cs
- HighlightComponent.cs
- ButtonFlatAdapter.cs
- XmlSchemaFacet.cs
- SingletonConnectionReader.cs
- ColumnHeader.cs
- XPathNodeIterator.cs
- RequestCacheEntry.cs
- FindCriteriaApril2005.cs
- EmptyEnumerable.cs
- HttpResponseHeader.cs
- ByValueEqualityComparer.cs
- IImplicitResourceProvider.cs
- columnmapkeybuilder.cs
- Cursors.cs
- ReadingWritingEntityEventArgs.cs
- FigureHelper.cs
- ScriptMethodAttribute.cs
- PrintControllerWithStatusDialog.cs
- LeftCellWrapper.cs
- Attributes.cs
- SystemFonts.cs
- ActivationArguments.cs
- StringPropertyBuilder.cs
- TimelineClockCollection.cs
- ListViewEditEventArgs.cs
- CheckedListBox.cs
- ConfigurationSectionGroupCollection.cs
- TypeUtils.cs