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
- OleDbRowUpdatingEvent.cs
- CombinedTcpChannel.cs
- TableRowGroupCollection.cs
- GenericUriParser.cs
- Logging.cs
- MatrixAnimationUsingKeyFrames.cs
- UniqueIdentifierService.cs
- SQLDateTime.cs
- XmlAttributes.cs
- ObsoleteAttribute.cs
- NamespaceQuery.cs
- WebPartCloseVerb.cs
- CustomAttributeSerializer.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- SafeHandle.cs
- WindowPattern.cs
- CredentialCache.cs
- TableStyle.cs
- ContentValidator.cs
- querybuilder.cs
- FontDifferentiator.cs
- ExceptionRoutedEventArgs.cs
- PaintEvent.cs
- ItemContainerGenerator.cs
- FileLoadException.cs
- ListViewItem.cs
- CodeBlockBuilder.cs
- Property.cs
- ArgumentOutOfRangeException.cs
- HttpCapabilitiesSectionHandler.cs
- Tile.cs
- DependencyPropertyKey.cs
- MulticastDelegate.cs
- ClientData.cs
- PolygonHotSpot.cs
- WindowsListViewItemStartMenu.cs
- ACE.cs
- DataGridViewEditingControlShowingEventArgs.cs
- TreeSet.cs
- ThrowHelper.cs
- ConditionalAttribute.cs
- InOutArgument.cs
- FixUp.cs
- SHA1Managed.cs
- BaseDataListDesigner.cs
- XmlDocumentFragment.cs
- Part.cs
- OdbcEnvironment.cs
- TempFiles.cs
- Panel.cs
- LiteralControl.cs
- DelegateTypeInfo.cs
- GridViewCellAutomationPeer.cs
- SystemParameters.cs
- NullExtension.cs
- ApplicationTrust.cs
- WebConfigurationFileMap.cs
- LongValidatorAttribute.cs
- FocusManager.cs
- DependencyPropertyValueSerializer.cs
- itemelement.cs
- MetadataArtifactLoaderComposite.cs
- BevelBitmapEffect.cs
- ViewStateModeByIdAttribute.cs
- GrammarBuilderBase.cs
- ContentControl.cs
- RijndaelManagedTransform.cs
- DeploymentSectionCache.cs
- Selection.cs
- hwndwrapper.cs
- BookmarkUndoUnit.cs
- RepeaterItemCollection.cs
- SoapSchemaImporter.cs
- DateTimeConverter.cs
- InvokeWebService.cs
- SqlTriggerAttribute.cs
- Floater.cs
- CommandValueSerializer.cs
- ComplexBindingPropertiesAttribute.cs
- HtmlTextBoxAdapter.cs
- UIElementIsland.cs
- ThreadStartException.cs
- AutomationPropertyInfo.cs
- namescope.cs
- FormView.cs
- StsCommunicationException.cs
- ZipIOCentralDirectoryBlock.cs
- XmlMemberMapping.cs
- RestHandler.cs
- ApplicationBuildProvider.cs
- Repeater.cs
- PixelFormatConverter.cs
- DataAdapter.cs
- _HeaderInfoTable.cs
- XmlWrappingReader.cs
- AppDomainAttributes.cs
- PeerNearMe.cs
- OlePropertyStructs.cs
- DataGridComboBoxColumn.cs
- KernelTypeValidation.cs